reset GL viewport and project when caputring the screen

Bug: 7241739
Change-Id: I3bb5214b070384de9be2026647865c6c236a4331
This commit is contained in:
Mathias Agopian 2012-09-28 01:00:47 -07:00 committed by Android (Google) Code Review
parent c01a79d77b
commit bae92d0d60
3 changed files with 15 additions and 7 deletions

View file

@ -259,18 +259,22 @@ EGLBoolean DisplayDevice::makeCurrent(EGLDisplay dpy,
if (sur != hw->mSurface) {
result = eglMakeCurrent(dpy, hw->mSurface, hw->mSurface, ctx);
if (result == EGL_TRUE) {
GLsizei w = hw->mDisplayWidth;
GLsizei h = hw->mDisplayHeight;
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// put the origin in the left-bottom corner
glOrthof(0, w, 0, h, 0, 1); // l=0, r=w ; b=0, t=h
setViewportAndProjection(hw);
}
}
return result;
}
void DisplayDevice::setViewportAndProjection(const sp<const DisplayDevice>& hw) {
GLsizei w = hw->mDisplayWidth;
GLsizei h = hw->mDisplayHeight;
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// put the origin in the left-bottom corner
glOrthof(0, w, 0, h, 0, 1); // l=0, r=w ; b=0, t=h
}
// ----------------------------------------------------------------------------
void DisplayDevice::setVisibleLayersSortedByZ(const Vector< sp<LayerBase> >& layers) {

View file

@ -125,6 +125,8 @@ public:
static EGLBoolean makeCurrent(EGLDisplay dpy,
const sp<const DisplayDevice>& hw, EGLContext ctx);
static void setViewportAndProjection(const sp<const DisplayDevice>& hw);
/* ------------------------------------------------------------------------
* blank / unblank management
*/

View file

@ -2510,6 +2510,8 @@ status_t SurfaceFlinger::renderScreenToTextureLocked(uint32_t layerStack,
glFramebufferTexture2DOES(GL_FRAMEBUFFER_OES,
GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, tname, 0);
DisplayDevice::setViewportAndProjection(hw);
// redraw the screen entirely...
glDisable(GL_TEXTURE_EXTERNAL_OES);
glDisable(GL_TEXTURE_2D);