diff options
Diffstat (limited to 'services/surfaceflinger')
-rw-r--r-- | services/surfaceflinger/Layer.cpp | 25 | ||||
-rw-r--r-- | services/surfaceflinger/Layer.h | 3 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 1 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceTextureLayer.cpp | 62 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceTextureLayer.h | 24 |
5 files changed, 34 insertions, 81 deletions
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index df7fe5c..4643071 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -97,9 +97,19 @@ void Layer::onFirstRef() } } }; - mSurfaceTexture = new SurfaceTextureLayer(mTextureName, this); + + // Creates a custom BufferQueue for SurfaceTexture to use + sp<BufferQueue> bq = new SurfaceTextureLayer(); + mSurfaceTexture = new SurfaceTexture(mTextureName, true, + GL_TEXTURE_EXTERNAL_OES, false,bq); + + + + mSurfaceTexture->setTransformHint(getTransformHint()); + mSurfaceTexture->setConsumerUsageBits(getEffectiveUsage(0)); mSurfaceTexture->setFrameAvailableListener(new FrameQueuedListener(this)); mSurfaceTexture->setSynchronousMode(true); + #ifdef USE_TRIPLE_BUFFERING #warning "using triple buffering" mSurfaceTexture->setBufferCountServer(3); @@ -131,6 +141,14 @@ void Layer::setName(const String8& name) { mSurfaceTexture->setName(name); } +void Layer::validateVisibility(const Transform& globalTransform) { + LayerBase::validateVisibility(globalTransform); + + // This optimization allows the SurfaceTexture to bake in + // the rotation so hardware overlays can be used + mSurfaceTexture->setTransformHint(getTransformHint()); +} + sp<ISurface> Layer::createSurface() { class BSurface : public BnSurface, public LayerCleaner { @@ -139,7 +157,7 @@ sp<ISurface> Layer::createSurface() sp<ISurfaceTexture> res; sp<const Layer> that( mOwner.promote() ); if (that != NULL) { - res = that->mSurfaceTexture; + res = that->mSurfaceTexture->getBufferQueue(); } return res; } @@ -154,7 +172,7 @@ sp<ISurface> Layer::createSurface() wp<IBinder> Layer::getSurfaceTextureBinder() const { - return mSurfaceTexture->asBinder(); + return mSurfaceTexture->getBufferQueue()->asBinder(); } status_t Layer::setBuffers( uint32_t w, uint32_t h, @@ -193,6 +211,7 @@ status_t Layer::setBuffers( uint32_t w, uint32_t h, mSurfaceTexture->setDefaultBufferSize(w, h); mSurfaceTexture->setDefaultBufferFormat(format); + mSurfaceTexture->setConsumerUsageBits(getEffectiveUsage(0)); // we use the red index int displayRedSize = displayInfo.getSize(PixelFormatInfo::INDEX_RED); diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h index 8d508c2..9a04848 100644 --- a/services/surfaceflinger/Layer.h +++ b/services/surfaceflinger/Layer.h @@ -77,6 +77,7 @@ public: virtual void onRemoved(); virtual sp<Layer> getLayer() const { return const_cast<Layer*>(this); } virtual void setName(const String8& name); + virtual void validateVisibility(const Transform& globalTransform); // LayerBaseClient interface virtual wp<IBinder> getSurfaceTextureBinder() const; @@ -105,7 +106,7 @@ private: // ----------------------------------------------------------------------- // constants - sp<SurfaceTextureLayer> mSurfaceTexture; + sp<SurfaceTexture> mSurfaceTexture; GLuint mTextureName; // thread-safe diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 0c597d6..0098889 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -1399,6 +1399,7 @@ status_t SurfaceFlinger::removeSurface(const sp<Client>& client, SurfaceID sid) status_t err = NAME_NOT_FOUND; Mutex::Autolock _l(mStateLock); sp<LayerBaseClient> layer = client->getLayerUser(sid); + if (layer != 0) { err = purgatorizeLayer_l(layer); if (err == NO_ERROR) { diff --git a/services/surfaceflinger/SurfaceTextureLayer.cpp b/services/surfaceflinger/SurfaceTextureLayer.cpp index 49e8e63..d7fd39e 100644 --- a/services/surfaceflinger/SurfaceTextureLayer.cpp +++ b/services/surfaceflinger/SurfaceTextureLayer.cpp @@ -27,72 +27,18 @@ namespace android { // --------------------------------------------------------------------------- -SurfaceTextureLayer::SurfaceTextureLayer(GLuint tex, const sp<Layer>& layer) - : SurfaceTexture(tex, true, GL_TEXTURE_EXTERNAL_OES, false), mLayer(layer) { +SurfaceTextureLayer::SurfaceTextureLayer() + : BufferQueue(true) { } SurfaceTextureLayer::~SurfaceTextureLayer() { } - -status_t SurfaceTextureLayer::setDefaultBufferSize(uint32_t w, uint32_t h) -{ - //ALOGD("%s, w=%u, h=%u", __PRETTY_FUNCTION__, w, h); - return SurfaceTexture::setDefaultBufferSize(w, h); -} - -status_t SurfaceTextureLayer::setDefaultBufferFormat(uint32_t format) -{ - mDefaultFormat = format; - return NO_ERROR; -} - -status_t SurfaceTextureLayer::setBufferCount(int bufferCount) { - status_t res = SurfaceTexture::setBufferCount(bufferCount); - return res; -} - -status_t SurfaceTextureLayer::queueBuffer(int buf, int64_t timestamp, - uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform) { - - status_t res = SurfaceTexture::queueBuffer(buf, timestamp, - outWidth, outHeight, outTransform); - sp<Layer> layer(mLayer.promote()); - if (layer != NULL) { - *outTransform = layer->getTransformHint(); - } - return res; -} - -status_t SurfaceTextureLayer::dequeueBuffer(int *buf, - uint32_t w, uint32_t h, uint32_t format, uint32_t usage) { - - status_t res(NO_INIT); - sp<Layer> layer(mLayer.promote()); - if (layer != NULL) { - if (format == 0) - format = mDefaultFormat; - uint32_t effectiveUsage = layer->getEffectiveUsage(usage); - //ALOGD("%s, w=%u, h=%u, format=%u, usage=%08x, effectiveUsage=%08x", - // __PRETTY_FUNCTION__, w, h, format, usage, effectiveUsage); - res = SurfaceTexture::dequeueBuffer(buf, w, h, format, effectiveUsage); - } - return res; -} - status_t SurfaceTextureLayer::connect(int api, uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform) { - status_t err = SurfaceTexture::connect(api, + status_t err = BufferQueue::connect(api, outWidth, outHeight, outTransform); if (err == NO_ERROR) { - sp<Layer> layer(mLayer.promote()); - if (layer != NULL) { - uint32_t orientation = layer->getOrientation(); - if (orientation & Transform::ROT_INVALID) { - orientation = 0; - } - *outTransform = orientation; - } switch(api) { case NATIVE_WINDOW_API_CPU: // SurfaceTextureClient supports only 2 buffers for CPU connections @@ -110,7 +56,7 @@ status_t SurfaceTextureLayer::connect(int api, #endif // fall through to set synchronous mode when not defaulting to // async mode. - deafult: + default: err = setSynchronousMode(true); break; } diff --git a/services/surfaceflinger/SurfaceTextureLayer.h b/services/surfaceflinger/SurfaceTextureLayer.h index 9508524..be26b2f 100644 --- a/services/surfaceflinger/SurfaceTextureLayer.h +++ b/services/surfaceflinger/SurfaceTextureLayer.h @@ -22,35 +22,21 @@ #include <sys/types.h> #include <utils/Errors.h> -#include <gui/SurfaceTexture.h> +#include <gui/BufferQueue.h> namespace android { // --------------------------------------------------------------------------- class Layer; -class SurfaceTextureLayer : public SurfaceTexture +// SurfaceTextureLayer is now a BufferQueue since SurfaceTexture has been +// refactored +class SurfaceTextureLayer : public BufferQueue { - wp<Layer> mLayer; - uint32_t mDefaultFormat; - public: - SurfaceTextureLayer(GLuint tex, const sp<Layer>& layer); + SurfaceTextureLayer(); ~SurfaceTextureLayer(); - status_t setDefaultBufferSize(uint32_t w, uint32_t h); - status_t setDefaultBufferFormat(uint32_t format); - -public: - virtual status_t setBufferCount(int bufferCount); - -protected: - virtual status_t queueBuffer(int buf, int64_t timestamp, - uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform); - - virtual status_t dequeueBuffer(int *buf, uint32_t w, uint32_t h, - uint32_t format, uint32_t usage); - virtual status_t connect(int api, uint32_t* outWidth, uint32_t* outHeight, uint32_t* outTransform); }; |