Merge "SurfaceFlinger: screenshots w/ protected buffers"
This commit is contained in:
@@ -280,20 +280,29 @@ void Layer::onDraw(const Region& clip) const
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const GLenum target = GL_TEXTURE_EXTERNAL_OES;
|
GLenum target = GL_TEXTURE_EXTERNAL_OES;
|
||||||
glBindTexture(target, mTextureName);
|
if (!isProtected()) {
|
||||||
if (getFiltering() || needsFiltering() || isFixedSize() || isCropped()) {
|
glBindTexture(target, mTextureName);
|
||||||
// TODO: we could be more subtle with isFixedSize()
|
if (getFiltering() || needsFiltering() || isFixedSize() || isCropped()) {
|
||||||
glTexParameterx(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
// TODO: we could be more subtle with isFixedSize()
|
||||||
glTexParameterx(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
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 {
|
} else {
|
||||||
glTexParameterx(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
target = GL_TEXTURE_2D;
|
||||||
glTexParameterx(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
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);
|
drawWithOpenGL(clip);
|
||||||
|
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ status_t SurfaceFlinger::readyToRun()
|
|||||||
|
|
||||||
const uint16_t g0 = pack565(0x0F,0x1F,0x0F);
|
const uint16_t g0 = pack565(0x0F,0x1F,0x0F);
|
||||||
const uint16_t g1 = pack565(0x17,0x2f,0x17);
|
const uint16_t g1 = pack565(0x17,0x2f,0x17);
|
||||||
const uint16_t textureData[4] = { g0, g1, g1, g0 };
|
const uint16_t wormholeTexData[4] = { g0, g1, g1, g0 };
|
||||||
glGenTextures(1, &mWormholeTexName);
|
glGenTextures(1, &mWormholeTexName);
|
||||||
glBindTexture(GL_TEXTURE_2D, mWormholeTexName);
|
glBindTexture(GL_TEXTURE_2D, mWormholeTexName);
|
||||||
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
@@ -283,7 +283,17 @@ status_t SurfaceFlinger::readyToRun()
|
|||||||
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 2, 2, 0,
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 2, 2, 0,
|
||||||
GL_RGB, GL_UNSIGNED_SHORT_5_6_5, textureData);
|
GL_RGB, GL_UNSIGNED_SHORT_5_6_5, wormholeTexData);
|
||||||
|
|
||||||
|
const uint16_t protTexData[] = { pack565(0x03, 0x03, 0x03) };
|
||||||
|
glGenTextures(1, &mProtectedTexName);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, mProtectedTexName);
|
||||||
|
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
|
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0,
|
||||||
|
GL_RGB, GL_UNSIGNED_SHORT_5_6_5, protTexData);
|
||||||
|
|
||||||
glViewport(0, 0, w, h);
|
glViewport(0, 0, w, h);
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
@@ -2255,22 +2265,6 @@ status_t SurfaceFlinger::captureScreenImplLocked(DisplayID dpy,
|
|||||||
if (UNLIKELY(uint32_t(dpy) >= DISPLAY_COUNT))
|
if (UNLIKELY(uint32_t(dpy) >= DISPLAY_COUNT))
|
||||||
return BAD_VALUE;
|
return BAD_VALUE;
|
||||||
|
|
||||||
// make sure none of the layers are protected
|
|
||||||
const LayerVector& layers(mDrawingState.layersSortedByZ);
|
|
||||||
const size_t count = layers.size();
|
|
||||||
for (size_t i=0 ; i<count ; ++i) {
|
|
||||||
const sp<LayerBase>& layer(layers[i]);
|
|
||||||
const uint32_t flags = layer->drawingState().flags;
|
|
||||||
if (!(flags & ISurfaceComposer::eLayerHidden)) {
|
|
||||||
const uint32_t z = layer->drawingState().z;
|
|
||||||
if (z >= minLayerZ && z <= maxLayerZ) {
|
|
||||||
if (layer->isProtected()) {
|
|
||||||
return INVALID_OPERATION;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!GLExtensions::getInstance().haveFramebufferObject())
|
if (!GLExtensions::getInstance().haveFramebufferObject())
|
||||||
return INVALID_OPERATION;
|
return INVALID_OPERATION;
|
||||||
|
|
||||||
@@ -2320,6 +2314,8 @@ status_t SurfaceFlinger::captureScreenImplLocked(DisplayID dpy,
|
|||||||
glClearColor(0,0,0,1);
|
glClearColor(0,0,0,1);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
const LayerVector& layers(mDrawingState.layersSortedByZ);
|
||||||
|
const size_t count = layers.size();
|
||||||
for (size_t i=0 ; i<count ; ++i) {
|
for (size_t i=0 ; i<count ; ++i) {
|
||||||
const sp<LayerBase>& layer(layers[i]);
|
const sp<LayerBase>& layer(layers[i]);
|
||||||
const uint32_t flags = layer->drawingState().flags;
|
const uint32_t flags = layer->drawingState().flags;
|
||||||
|
|||||||
@@ -192,6 +192,8 @@ public:
|
|||||||
|
|
||||||
sp<Layer> getLayer(const sp<ISurface>& sur) const;
|
sp<Layer> getLayer(const sp<ISurface>& sur) const;
|
||||||
|
|
||||||
|
GLuint getProtectedTexName() const { return mProtectedTexName; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// DeathRecipient interface
|
// DeathRecipient interface
|
||||||
virtual void binderDied(const wp<IBinder>& who);
|
virtual void binderDied(const wp<IBinder>& who);
|
||||||
@@ -349,6 +351,7 @@ private:
|
|||||||
sp<IMemoryHeap> mServerHeap;
|
sp<IMemoryHeap> mServerHeap;
|
||||||
surface_flinger_cblk_t* mServerCblk;
|
surface_flinger_cblk_t* mServerCblk;
|
||||||
GLuint mWormholeTexName;
|
GLuint mWormholeTexName;
|
||||||
|
GLuint mProtectedTexName;
|
||||||
nsecs_t mBootTime;
|
nsecs_t mBootTime;
|
||||||
|
|
||||||
// Can only accessed from the main thread, these members
|
// Can only accessed from the main thread, these members
|
||||||
|
|||||||
Reference in New Issue
Block a user