diff options
author | Jamie Gennis <jgennis@google.com> | 2011-03-09 17:05:02 -0800 |
---|---|---|
committer | Jamie Gennis <jgennis@google.com> | 2011-03-10 16:25:48 -0800 |
commit | f72606ce3ea8cb787e5c71325f08b1898e0718d9 (patch) | |
tree | e81f8fb6a932f9660d8c65bde57fed694a18aacc /services | |
parent | 87e8ab372bd722c5c1a00ff5262acccee5dae5e5 (diff) | |
download | frameworks_base-f72606ce3ea8cb787e5c71325f08b1898e0718d9.zip frameworks_base-f72606ce3ea8cb787e5c71325f08b1898e0718d9.tar.gz frameworks_base-f72606ce3ea8cb787e5c71325f08b1898e0718d9.tar.bz2 |
SurfaceFlinger: Respect the PROTECTED gralloc bit.
This change makes SurfaceFlinger treat layers for which the active
buffer has the GRALLOC_USAGE_PROTECTED bit set as if they have the
'secure' flag set.
Change-Id: Ic60b6513a63e4bb92ec6ce9fd12fd39b4ba5f674
Bug: 4081304
Diffstat (limited to 'services')
-rw-r--r-- | services/surfaceflinger/Layer.cpp | 10 | ||||
-rw-r--r-- | services/surfaceflinger/Layer.h | 4 | ||||
-rw-r--r-- | services/surfaceflinger/LayerBase.h | 12 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 15 |
4 files changed, 24 insertions, 17 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index 57af001..1297363 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -57,7 +57,6 @@ Layer::Layer(SurfaceFlinger* flinger, mNeedsDithering(false), mSecure(false), mProtectedByApp(false), - mProtectedByDRM(false), mTextureManager(), mBufferManager(mTextureManager), mWidth(0), mHeight(0), mNeedsScaling(false), mFixedSize(false) @@ -191,7 +190,6 @@ status_t Layer::setBuffers( uint32_t w, uint32_t h, mSecure = (flags & ISurfaceComposer::eSecure) ? true : false; mProtectedByApp = (flags & ISurfaceComposer::eProtectedByApp) ? true : false; - mProtectedByDRM = (flags & ISurfaceComposer::eProtectedByDRM) ? true : false; mNeedsBlending = (info.h_alpha - info.l_alpha) > 0 && (flags & ISurfaceComposer::eOpaque) == 0; @@ -392,6 +390,12 @@ bool Layer::needsFiltering() const return LayerBase::needsFiltering(); } +bool Layer::isProtected() const +{ + sp<GraphicBuffer> activeBuffer(mBufferManager.getActiveBuffer()); + return (activeBuffer != 0) && + (activeBuffer->getUsage() & GRALLOC_USAGE_PROTECTED); +} status_t Layer::setBufferCount(int bufferCount) { @@ -515,7 +519,7 @@ uint32_t Layer::getEffectiveUsage(uint32_t usage) const // request EGLImage for all buffers usage |= GraphicBuffer::USAGE_HW_TEXTURE; } - if (mProtectedByApp || mProtectedByDRM) { + if (mProtectedByApp) { // need a hardware-protected path to external video sink usage |= GraphicBuffer::USAGE_PROTECTED; } diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h index bccc900..128f93d 100644 --- a/services/surfaceflinger/Layer.h +++ b/services/surfaceflinger/Layer.h @@ -80,8 +80,7 @@ public: virtual bool needsDithering() const { return mNeedsDithering; } virtual bool needsFiltering() const; virtual bool isSecure() const { return mSecure; } - virtual bool isProtectedByApp() const { return mProtectedByApp; } - virtual bool isProtectedByDRM() const { return mProtectedByDRM; } + virtual bool isProtected() const; virtual sp<Surface> createSurface() const; virtual status_t ditch(); virtual void onRemoved(); @@ -222,7 +221,6 @@ private: // page-flip thread (currently main thread) bool mSecure; // no screenshots bool mProtectedByApp; // application requires protected path to external sink - bool mProtectedByDRM; // DRM agent requires protected path to external sink Region mPostedDirtyRegion; // page-flip thread and transaction thread (currently main thread) diff --git a/services/surfaceflinger/LayerBase.h b/services/surfaceflinger/LayerBase.h index bfe92e6..7162e47 100644 --- a/services/surfaceflinger/LayerBase.h +++ b/services/surfaceflinger/LayerBase.h @@ -197,16 +197,10 @@ public: virtual bool isSecure() const { return false; } /** - * isProtectedByApp - true if application says this surface is protected, that - * is if it requires a hardware-protected data path to an external sink. + * isProtected - true if the layer may contain protected content in the + * GRALLOC_USAGE_PROTECTED sense. */ - virtual bool isProtectedByApp() const { return false; } - - /** - * isProtectedByDRM - true if DRM agent says this surface is protected, that - * is if it requires a hardware-protected data path to an external sink. - */ - virtual bool isProtectedByDRM() const { return false; } + virtual bool isProtected() const { return false; } /** Called from the main thread, when the surface is removed from the * draw list */ diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 7b19a4c..a9fa1ef 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -2169,6 +2169,19 @@ status_t SurfaceFlinger::captureScreenImplLocked(DisplayID dpy, if (UNLIKELY(uint32_t(dpy) >= DISPLAY_COUNT)) return BAD_VALUE; + // make sure none of the layers are protected + const Vector< sp<LayerBase> >& layers(mVisibleLayersSortedByZ); + const size_t count = layers.size(); + for (size_t i=0 ; i<count ; ++i) { + const sp<LayerBase>& layer(layers[i]); + const uint32_t z = layer->drawingState().z; + if (z >= minLayerZ && z <= maxLayerZ) { + if (layer->isProtected()) { + return INVALID_OPERATION; + } + } + } + if (!GLExtensions::getInstance().haveFramebufferObject()) return INVALID_OPERATION; @@ -2217,8 +2230,6 @@ status_t SurfaceFlinger::captureScreenImplLocked(DisplayID dpy, glClearColor(0,0,0,1); glClear(GL_COLOR_BUFFER_BIT); - const Vector< sp<LayerBase> >& layers(mVisibleLayersSortedByZ); - const size_t count = layers.size(); for (size_t i=0 ; i<count ; ++i) { const sp<LayerBase>& layer(layers[i]); const uint32_t z = layer->drawingState().z; |