From 830d083bf75f1dfe3753f9565f0c90b1dbcc264f Mon Sep 17 00:00:00 2001 From: Jamie Gennis Date: Fri, 7 Oct 2011 14:51:16 -0700 Subject: SurfaceFlinger: screenshots w/ protected buffers This change modifies SurfaceFlinger's screenshot behavior when a layer with a protected buffer is visible. The previous behavior was to simply fail the screenshot. The new behavior is to render the screenshot using a placeholder texture where the protected buffer would have been. Change-Id: I5e50cb2f3b31b2ea81cfe291c9b4a42e9ee71874 --- services/surfaceflinger/Layer.cpp | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'services/surfaceflinger/Layer.cpp') diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 41d7a90978ad..feb2c5272dbd 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -280,20 +280,29 @@ void Layer::onDraw(const Region& clip) const return; } - const GLenum target = GL_TEXTURE_EXTERNAL_OES; - glBindTexture(target, mTextureName); - if (getFiltering() || needsFiltering() || isFixedSize() || isCropped()) { - // TODO: we could be more subtle with isFixedSize() - glTexParameterx(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterx(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + GLenum target = GL_TEXTURE_EXTERNAL_OES; + if (!isProtected()) { + glBindTexture(target, mTextureName); + if (getFiltering() || needsFiltering() || isFixedSize() || isCropped()) { + // TODO: we could be more subtle with isFixedSize() + glTexParameterx(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameterx(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + } else { + glTexParameterx(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterx(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + } + glEnable(target); + glMatrixMode(GL_TEXTURE); + glLoadMatrixf(mTextureMatrix); + glMatrixMode(GL_MODELVIEW); } else { - glTexParameterx(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameterx(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + target = GL_TEXTURE_2D; + glBindTexture(target, mFlinger->getProtectedTexName()); + glEnable(target); + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); } - glEnable(target); - glMatrixMode(GL_TEXTURE); - glLoadMatrixf(mTextureMatrix); - glMatrixMode(GL_MODELVIEW); drawWithOpenGL(clip); -- cgit v1.2.3-59-g8ed1b