diff options
author | Mathias Agopian <mathias@google.com> | 2012-10-24 16:29:17 -0700 |
---|---|---|
committer | The Android Automerger <android-build@android.com> | 2012-10-25 21:42:41 -0700 |
commit | 1b10e25356fed2d9d3480485638e737332be6ef7 (patch) | |
tree | 556d04bd8536c08086985a129b1cf4505eee70bc | |
parent | faece69c18f7d6a8a17e251f825e950048e02526 (diff) | |
download | frameworks_native-1b10e25356fed2d9d3480485638e737332be6ef7.zip frameworks_native-1b10e25356fed2d9d3480485638e737332be6ef7.tar.gz frameworks_native-1b10e25356fed2d9d3480485638e737332be6ef7.tar.bz2 |
partially implement external display clipping
we perform external display clipping only on the GL
side (ie: not done on the h/w composer side, which is
harder and would be too risky). in practice this means
that WFD will be clipped properly, while HDMI *may* or
may not depending on how hwc is used.
Bug: 7149437
Change-Id: I92d4d04220db72b6ffb134c7fa7a93af569723a5
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 26e9c60..7ee6e5e 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -1500,6 +1500,28 @@ void SurfaceFlinger::doComposeSurfaces(const sp<const DisplayDevice>& hw, const drawWormhole(hw, region); } } + + if (hw->getDisplayType() >= DisplayDevice::DISPLAY_EXTERNAL) { + // TODO: just to be on the safe side, we don't set the + // scissor on the main display. It should never be needed + // anyways (though in theory it could since the API allows it). + const Rect& bounds(hw->getBounds()); + const Transform& tr(hw->getTransform()); + const Rect scissor(tr.transform(hw->getViewport())); + if (scissor != bounds) { + // scissor doesn't match the screen's dimensions, so we + // need to clear everything outside of it and enable + // the GL scissor so we don't draw anything where we shouldn't + const GLint height = hw->getHeight(); + glScissor(scissor.left, height - scissor.bottom, + scissor.getWidth(), scissor.getHeight()); + // clear everything unscissored + glClearColor(0, 0, 0, 0); + glClear(GL_COLOR_BUFFER_BIT); + // enable scissor for this frame + glEnable(GL_SCISSOR_TEST); + } + } } /* @@ -1552,6 +1574,9 @@ void SurfaceFlinger::doComposeSurfaces(const sp<const DisplayDevice>& hw, const } } } + + // disable scissor at the end of the frame + glDisable(GL_SCISSOR_TEST); } void SurfaceFlinger::drawWormhole(const sp<const DisplayDevice>& hw, |