From 2adaf04fab35cf47c824d74d901b54094e01ccd3 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Tue, 18 Dec 2012 09:49:45 -0800 Subject: [PATCH] Rename ISurfaceTexture and SurfaceTexture The C++ class names don't match what the classes do, so rename ISurfaceTexture to IGraphicBufferProducer, and SurfaceTexture to GLConsumer. Bug 7736700 Change-Id: Ia03e468888025b5cae3c0ee1995434515dbea387 --- include/gui/BufferItemConsumer.h | 2 +- include/gui/BufferQueue.h | 14 +-- include/gui/ConsumerBase.h | 4 +- include/gui/CpuConsumer.h | 2 +- include/gui/DummyConsumer.h | 4 +- .../gui/{SurfaceTexture.h => GLConsumer.h} | 64 +++++----- ...faceTexture.h => IGraphicBufferProducer.h} | 43 ++++--- include/gui/ISurface.h | 4 +- include/gui/ISurfaceComposer.h | 4 +- include/gui/Surface.h | 8 +- include/gui/SurfaceComposerClient.h | 4 +- include/gui/SurfaceTextureClient.h | 19 +-- include/private/gui/LayerState.h | 2 +- libs/gui/Android.mk | 4 +- libs/gui/BufferQueue.cpp | 20 +-- libs/gui/ConsumerBase.cpp | 4 +- .../{SurfaceTexture.cpp => GLConsumer.cpp} | 118 +++++++++--------- ...Texture.cpp => IGraphicBufferProducer.cpp} | 58 ++++----- libs/gui/ISurface.cpp | 6 +- libs/gui/ISurfaceComposer.cpp | 12 +- libs/gui/LayerState.cpp | 4 +- libs/gui/Surface.cpp | 30 ++--- libs/gui/SurfaceComposerClient.cpp | 11 +- libs/gui/SurfaceTextureClient.cpp | 28 ++--- libs/gui/tests/BufferQueue_test.cpp | 8 +- libs/gui/tests/SurfaceTextureClient_test.cpp | 14 +-- libs/gui/tests/SurfaceTexture_test.cpp | 38 +++--- opengl/tests/EGLTest/EGL_test.cpp | 2 +- opengl/tools/glgen/stubs/egl/EGL14cHeader.cpp | 4 +- .../stubs/egl/eglCreateWindowSurface.cpp | 6 +- .../DisplayHardware/FramebufferSurface.h | 2 +- services/surfaceflinger/Layer.cpp | 4 +- services/surfaceflinger/LayerBase.cpp | 2 +- services/surfaceflinger/LayerBase.h | 4 +- services/surfaceflinger/SurfaceFlinger.cpp | 10 +- services/surfaceflinger/SurfaceFlinger.h | 4 +- .../surfaceflinger/SurfaceFlingerConsumer.cpp | 2 +- .../surfaceflinger/SurfaceFlingerConsumer.h | 12 +- services/surfaceflinger/SurfaceTextureLayer.h | 2 - 39 files changed, 291 insertions(+), 292 deletions(-) rename include/gui/{SurfaceTexture.h => GLConsumer.h} (89%) rename include/gui/{ISurfaceTexture.h => IGraphicBufferProducer.h} (85%) rename libs/gui/{SurfaceTexture.cpp => GLConsumer.cpp} (88%) rename libs/gui/{ISurfaceTexture.cpp => IGraphicBufferProducer.cpp} (82%) diff --git a/include/gui/BufferItemConsumer.h b/include/gui/BufferItemConsumer.h index cd4df25c3..08408916c 100644 --- a/include/gui/BufferItemConsumer.h +++ b/include/gui/BufferItemConsumer.h @@ -82,7 +82,7 @@ class BufferItemConsumer: public ConsumerBase status_t releaseBuffer(const BufferItem &item, const sp& releaseFence = Fence::NO_FENCE); - sp getProducerInterface() const { return getBufferQueue(); } + sp getProducerInterface() const { return getBufferQueue(); } }; diff --git a/include/gui/BufferQueue.h b/include/gui/BufferQueue.h index 88bcd8f4a..c59e00e0d 100644 --- a/include/gui/BufferQueue.h +++ b/include/gui/BufferQueue.h @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include @@ -33,7 +33,7 @@ namespace android { // ---------------------------------------------------------------------------- -class BufferQueue : public BnSurfaceTexture { +class BufferQueue : public BnGraphicBufferProducer { public: enum { MIN_UNDEQUEUED_BUFFERS = 2 }; enum { NUM_BUFFER_SLOTS = 32 }; @@ -149,7 +149,7 @@ public: virtual status_t setSynchronousMode(bool enabled); // connect attempts to connect a producer client API to the BufferQueue. - // This must be called before any other ISurfaceTexture methods are called + // This must be called before any other IGraphicBufferProducer methods are called // except for getAllocator. // // This method will fail if the connect was previously called on the @@ -158,7 +158,7 @@ public: // disconnect attempts to disconnect a producer client API from the // BufferQueue. Calling this method will cause any subsequent calls to other - // ISurfaceTexture methods to fail except for getAllocator and connect. + // IGraphicBufferProducer methods to fail except for getAllocator and connect. // Successfully calling connect after this will allow the other methods to // succeed again. // @@ -265,7 +265,7 @@ public: // producer is connected to the BufferQueue. status_t setMaxAcquiredBufferCount(int maxAcquiredBuffers); - // isSynchronousMode returns whether the SurfaceTexture is currently in + // isSynchronousMode returns whether the BufferQueue is currently in // synchronous mode. bool isSynchronousMode() const; @@ -506,10 +506,10 @@ private: Fifo mQueue; // mAbandoned indicates that the BufferQueue will no longer be used to - // consume images buffers pushed to it using the ISurfaceTexture interface. + // consume images buffers pushed to it using the IGraphicBufferProducer interface. // It is initialized to false, and set to true in the abandon method. A // BufferQueue that has been abandoned will return the NO_INIT error from - // all ISurfaceTexture methods capable of returning an error. + // all IGraphicBufferProducer methods capable of returning an error. bool mAbandoned; // mName is a string used to identify the BufferQueue in log messages. diff --git a/include/gui/ConsumerBase.h b/include/gui/ConsumerBase.h index 5ae5a1995..49a764f95 100644 --- a/include/gui/ConsumerBase.h +++ b/include/gui/ConsumerBase.h @@ -53,7 +53,7 @@ public: // abandon frees all the buffers and puts the ConsumerBase into the // 'abandoned' state. Once put in this state the ConsumerBase can never // leave it. When in the 'abandoned' state, all methods of the - // ISurfaceTexture interface will fail with the NO_INIT error. + // IGraphicBufferProducer interface will fail with the NO_INIT error. // // Note that while calling this method causes all the buffers to be freed // from the perspective of the the ConsumerBase, if there are additional @@ -186,7 +186,7 @@ protected: Slot mSlots[BufferQueue::NUM_BUFFER_SLOTS]; // mAbandoned indicates that the BufferQueue will no longer be used to - // consume images buffers pushed to it using the ISurfaceTexture + // consume images buffers pushed to it using the IGraphicBufferProducer // interface. It is initialized to false, and set to true in the abandon // method. A BufferQueue that has been abandoned will return the NO_INIT // error from all IConsumerBase methods capable of returning an error. diff --git a/include/gui/CpuConsumer.h b/include/gui/CpuConsumer.h index 807a4b538..a08c71883 100644 --- a/include/gui/CpuConsumer.h +++ b/include/gui/CpuConsumer.h @@ -82,7 +82,7 @@ class CpuConsumer: public ConsumerBase // lockNextBuffer. status_t unlockBuffer(const LockedBuffer &nativeBuffer); - sp getProducerInterface() const { return getBufferQueue(); } + sp getProducerInterface() const { return getBufferQueue(); } private: // Maximum number of buffers that can be locked at a time diff --git a/include/gui/DummyConsumer.h b/include/gui/DummyConsumer.h index 7fe4d40bd..08e8ec807 100644 --- a/include/gui/DummyConsumer.h +++ b/include/gui/DummyConsumer.h @@ -24,7 +24,7 @@ namespace android { // The DummyConsumer does not keep a reference to BufferQueue -// unlike SurfaceTexture. This prevents a circular reference from +// unlike GLConsumer. This prevents a circular reference from // forming without having to use a ProxyConsumerListener class DummyConsumer : public BufferQueue::ConsumerListener { public: @@ -33,7 +33,7 @@ public: protected: // Implementation of the BufferQueue::ConsumerListener interface. These - // calls are used to notify the SurfaceTexture of asynchronous events in the + // calls are used to notify the GLConsumer of asynchronous events in the // BufferQueue. virtual void onFrameAvailable(); virtual void onBuffersReleased(); diff --git a/include/gui/SurfaceTexture.h b/include/gui/GLConsumer.h similarity index 89% rename from include/gui/SurfaceTexture.h rename to include/gui/GLConsumer.h index 50efb7385..e0fa8934f 100644 --- a/include/gui/SurfaceTexture.h +++ b/include/gui/GLConsumer.h @@ -14,15 +14,15 @@ * limitations under the License. */ -#ifndef ANDROID_GUI_SURFACETEXTURE_H -#define ANDROID_GUI_SURFACETEXTURE_H +#ifndef ANDROID_GUI_CONSUMER_H +#define ANDROID_GUI_CONSUMER_H #include #include #include #include -#include +#include #include #include @@ -43,10 +43,10 @@ namespace android { class String8; /* - * SurfaceTexture consumes buffers of graphics data from a BufferQueue, + * GLConsumer consumes buffers of graphics data from a BufferQueue, * and makes them available to OpenGL as a texture. * - * A typical usage pattern is to set up the SurfaceTexture with the + * A typical usage pattern is to set up the GLConsumer with the * desired options, and call updateTexImage() when a new frame is desired. * If a new frame is available, the texture will be updated. If not, * the previous contents are retained. @@ -55,13 +55,13 @@ class String8; * texture target, in the EGL context of the first thread that calls * updateTexImage(). * - * TODO: rename to GLConsumer (OpenGLConsumer?) + * This class was previously called SurfaceTexture. */ -class SurfaceTexture : public ConsumerBase { +class GLConsumer : public ConsumerBase { public: typedef ConsumerBase::FrameAvailableListener FrameAvailableListener; - // SurfaceTexture constructs a new SurfaceTexture object. tex indicates the + // GLConsumer constructs a new GLConsumer object. tex indicates the // name of the OpenGL ES texture to which images are to be streamed. // allowSynchronousMode specifies whether or not synchronous mode can be // enabled. texTarget specifies the OpenGL ES texture target to which the @@ -71,7 +71,7 @@ public: // if behavior for queue/dequeue/connect etc needs to be customized. // Otherwise a default BufferQueue will be created and used. // - // For legacy reasons, the SurfaceTexture is created in a state where it is + // For legacy reasons, the GLConsumer is created in a state where it is // considered attached to an OpenGL ES context for the purposes of the // attachToContext and detachFromContext methods. However, despite being // considered "attached" to a context, the specific OpenGL ES context @@ -79,13 +79,13 @@ public: // point, all calls to updateTexImage must be made with the same OpenGL ES // context current. // - // A SurfaceTexture may be detached from one OpenGL ES context and then + // A GLConsumer may be detached from one OpenGL ES context and then // attached to a different context using the detachFromContext and // attachToContext methods, respectively. The intention of these methods is - // purely to allow a SurfaceTexture to be transferred from one consumer + // purely to allow a GLConsumer to be transferred from one consumer // context to another. If such a transfer is not needed there is no // requirement that either of these methods be called. - SurfaceTexture(GLuint tex, bool allowSynchronousMode = true, + GLConsumer(GLuint tex, bool allowSynchronousMode = true, GLenum texTarget = GL_TEXTURE_EXTERNAL_OES, bool useFenceSync = true, const sp &bufferQueue = 0); @@ -102,7 +102,7 @@ public: // current buffer is no longer being read. This fence will be returned to // the producer when the current buffer is released by updateTexImage(). // Multiple fences can be set for a given buffer; they will be merged into - // a single union fence. The SurfaceTexture will close the file descriptor + // a single union fence. The GLConsumer will close the file descriptor // when finished with it. void setReleaseFence(int fenceFd); @@ -122,7 +122,7 @@ public: // // This transform is necessary to compensate for transforms that the stream // content producer may implicitly apply to the content. By forcing users of - // a SurfaceTexture to apply this transform we avoid performing an extra + // a GLConsumer to apply this transform we avoid performing an extra // copy of the data that would be needed to hide the transform from the // user. // @@ -178,11 +178,11 @@ public: // current texture buffer. status_t doGLFenceWait() const; - // isSynchronousMode returns whether the SurfaceTexture is currently in + // isSynchronousMode returns whether the GLConsumer is currently in // synchronous mode. bool isSynchronousMode() const; - // set the name of the SurfaceTexture that will be used to identify it in + // set the name of the GLConsumer that will be used to identify it in // log messages. void setName(const String8& name); @@ -194,29 +194,29 @@ public: virtual status_t setSynchronousMode(bool enabled); // getBufferQueue returns the BufferQueue object to which this - // SurfaceTexture is connected. + // GLConsumer is connected. sp getBufferQueue() const { return mBufferQueue; } - // detachFromContext detaches the SurfaceTexture from the calling thread's + // detachFromContext detaches the GLConsumer from the calling thread's // current OpenGL ES context. This context must be the same as the context // that was current for previous calls to updateTexImage. // - // Detaching a SurfaceTexture from an OpenGL ES context will result in the + // Detaching a GLConsumer from an OpenGL ES context will result in the // deletion of the OpenGL ES texture object into which the images were being - // streamed. After a SurfaceTexture has been detached from the OpenGL ES + // streamed. After a GLConsumer has been detached from the OpenGL ES // context calls to updateTexImage will fail returning INVALID_OPERATION - // until the SurfaceTexture is attached to a new OpenGL ES context using the + // until the GLConsumer is attached to a new OpenGL ES context using the // attachToContext method. status_t detachFromContext(); - // attachToContext attaches a SurfaceTexture that is currently in the - // 'detached' state to the current OpenGL ES context. A SurfaceTexture is + // attachToContext attaches a GLConsumer that is currently in the + // 'detached' state to the current OpenGL ES context. A GLConsumer is // in the 'detached' state iff detachFromContext has successfully been // called and no calls to attachToContext have succeeded since the last // detachFromContext call. Calls to attachToContext made on a - // SurfaceTexture that is not in the 'detached' state will result in an + // GLConsumer that is not in the 'detached' state will result in an // INVALID_OPERATION error. // // The tex argument specifies the OpenGL ES texture object name in the @@ -232,7 +232,7 @@ protected: // mCurrentTextureBuf in addition to the ConsumerBase behavior. virtual void abandonLocked(); - // dumpLocked overrides the ConsumerBase method to dump SurfaceTexture- + // dumpLocked overrides the ConsumerBase method to dump GLConsumer- // specific info in addition to the ConsumerBase behavior. virtual void dumpLocked(String8& result, const char* prefix, char* buffer, size_t size) const; @@ -268,7 +268,7 @@ protected: // values. status_t checkAndUpdateEglStateLocked(); - // If set, SurfaceTexture will use the EGL_ANDROID_native_fence_sync + // If set, GLConsumer will use the EGL_ANDROID_native_fence_sync // extension to create Android native fences for GLES activity. static const bool sUseNativeFenceSync; @@ -308,9 +308,9 @@ private: // binding the buffer without touching the EglSlots. status_t bindUnslottedBufferLocked(EGLDisplay dpy); - // The default consumer usage flags that SurfaceTexture always sets on its + // The default consumer usage flags that GLConsumer always sets on its // BufferQueue instance; these will be OR:d with any additional flags passed - // from the SurfaceTexture user. In particular, SurfaceTexture will always + // from the GLConsumer user. In particular, GLConsumer will always // consume buffers as hardware textures. static const uint32_t DEFAULT_USAGE_FLAGS = GraphicBuffer::USAGE_HW_TEXTURE; @@ -371,7 +371,7 @@ private: const GLenum mTexTarget; // EGLSlot contains the information and object references that - // SurfaceTexture maintains about a BufferQueue buffer slot. + // GLConsumer maintains about a BufferQueue buffer slot. struct EglSlot { EglSlot() : mEglImage(EGL_NO_IMAGE_KHR), @@ -388,13 +388,13 @@ private: EGLSyncKHR mEglFence; }; - // mEglDisplay is the EGLDisplay with which this SurfaceTexture is currently + // mEglDisplay is the EGLDisplay with which this GLConsumer is currently // associated. It is intialized to EGL_NO_DISPLAY and gets set to the // current display when updateTexImage is called for the first time and when // attachToContext is called. EGLDisplay mEglDisplay; - // mEglContext is the OpenGL ES context with which this SurfaceTexture is + // mEglContext is the OpenGL ES context with which this GLConsumer is // currently associated. It is initialized to EGL_NO_CONTEXT and gets set // to the current GL context when updateTexImage is called for the first // time and when attachToContext is called. @@ -429,4 +429,4 @@ private: // ---------------------------------------------------------------------------- }; // namespace android -#endif // ANDROID_GUI_SURFACETEXTURE_H +#endif // ANDROID_GUI_CONSUMER_H diff --git a/include/gui/ISurfaceTexture.h b/include/gui/IGraphicBufferProducer.h similarity index 85% rename from include/gui/ISurfaceTexture.h rename to include/gui/IGraphicBufferProducer.h index 58345a028..3b612295a 100644 --- a/include/gui/ISurfaceTexture.h +++ b/include/gui/IGraphicBufferProducer.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ANDROID_GUI_ISURFACETEXTURE_H -#define ANDROID_GUI_ISURFACETEXTURE_H +#ifndef ANDROID_GUI_IGRAPHICBUFFERPRODUCER_H +#define ANDROID_GUI_IGRAPHICBUFFERPRODUCER_H #include #include @@ -44,16 +44,15 @@ class SurfaceTextureClient; * producer calls dequeueBuffer() to get an empty buffer, fills it with * data, then calls queueBuffer() to make it available to the consumer. * - * The BnSurfaceTexture and BpSurfaceTexture classes provide the Binder - * IPC implementation. + * The BnGraphicBufferProducer and BpGraphicBufferProducer classes provide + * the Binder IPC implementation. * - * TODO: rename to IGraphicBufferProducer (IBufferProducer? - * IBufferQueueProducer?) + * This class was previously called ISurfaceTexture. */ -class ISurfaceTexture : public IInterface +class IGraphicBufferProducer : public IInterface { public: - DECLARE_META_INTERFACE(SurfaceTexture); + DECLARE_META_INTERFACE(GraphicBufferProducer); enum { BUFFER_NEEDS_REALLOCATION = 0x1, @@ -61,8 +60,8 @@ public: }; // requestBuffer requests a new buffer for the given index. The server (i.e. - // the ISurfaceTexture implementation) assigns the newly created buffer to - // the given slot index, and the client is expected to mirror the + // the IGraphicBufferProducer implementation) assigns the newly created + // buffer to the given slot index, and the client is expected to mirror the // slot->buffer mapping so that it's not necessary to transfer a // GraphicBuffer for every dequeue operation. virtual status_t requestBuffer(int slot, sp* buf) = 0; @@ -180,32 +179,32 @@ public: // The default mode is asynchronous. virtual status_t setSynchronousMode(bool enabled) = 0; - // connect attempts to connect a client API to the SurfaceTexture. This - // must be called before any other ISurfaceTexture methods are called except - // for getAllocator. + // connect attempts to connect a client API to the IGraphicBufferProducer. + // This must be called before any other IGraphicBufferProducer methods are + // called except for getAllocator. // // This method will fail if the connect was previously called on the - // SurfaceTexture and no corresponding disconnect call was made. + // IGraphicBufferProducer and no corresponding disconnect call was made. // // outWidth, outHeight and outTransform are filled with the default width // and height of the window and current transform applied to buffers, // respectively. virtual status_t connect(int api, QueueBufferOutput* output) = 0; - // disconnect attempts to disconnect a client API from the SurfaceTexture. - // Calling this method will cause any subsequent calls to other - // ISurfaceTexture methods to fail except for getAllocator and connect. - // Successfully calling connect after this will allow the other methods to - // succeed again. + // disconnect attempts to disconnect a client API from the + // IGraphicBufferProducer. Calling this method will cause any subsequent + // calls to other IGraphicBufferProducer methods to fail except for + // getAllocator and connect. Successfully calling connect after this will + // allow the other methods to succeed again. // - // This method will fail if the the SurfaceTexture is not currently + // This method will fail if the the IGraphicBufferProducer is not currently // connected to the specified client API. virtual status_t disconnect(int api) = 0; }; // ---------------------------------------------------------------------------- -class BnSurfaceTexture : public BnInterface +class BnGraphicBufferProducer : public BnInterface { public: virtual status_t onTransact( uint32_t code, @@ -217,4 +216,4 @@ public: // ---------------------------------------------------------------------------- }; // namespace android -#endif // ANDROID_GUI_ISURFACETEXTURE_H +#endif // ANDROID_GUI_IGRAPHICBUFFERPRODUCER_H diff --git a/include/gui/ISurface.h b/include/gui/ISurface.h index c0ff9fcb1..ce6e715b3 100644 --- a/include/gui/ISurface.h +++ b/include/gui/ISurface.h @@ -31,7 +31,7 @@ namespace android { typedef int32_t SurfaceID; -class ISurfaceTexture; +class IGraphicBufferProducer; class ISurface : public IInterface { @@ -43,7 +43,7 @@ protected: public: DECLARE_META_INTERFACE(Surface); - virtual sp getSurfaceTexture() const = 0; + virtual sp getSurfaceTexture() const = 0; }; // ---------------------------------------------------------------------------- diff --git a/include/gui/ISurfaceComposer.h b/include/gui/ISurfaceComposer.h index 6500ad584..50b2ad150 100644 --- a/include/gui/ISurfaceComposer.h +++ b/include/gui/ISurfaceComposer.h @@ -86,10 +86,10 @@ public: */ virtual void bootFinished() = 0; - /* verify that an ISurfaceTexture was created by SurfaceFlinger. + /* verify that an IGraphicBufferProducer was created by SurfaceFlinger. */ virtual bool authenticateSurfaceTexture( - const sp& surface) const = 0; + const sp& surface) const = 0; /* Capture the specified screen. requires READ_FRAME_BUFFER permission * This function will fail if there is a secure window on screen. diff --git a/include/gui/Surface.h b/include/gui/Surface.h index f3455b5d6..cba11b8a4 100644 --- a/include/gui/Surface.h +++ b/include/gui/Surface.h @@ -37,7 +37,7 @@ namespace android { // --------------------------------------------------------------------------- -class ISurfaceTexture; +class IGraphicBufferProducer; class Surface; class SurfaceComposerClient; @@ -126,7 +126,7 @@ public: uint32_t reserved[2]; }; - explicit Surface(const sp& st); + explicit Surface(const sp& bp); static status_t writeToParcel(const sp& control, Parcel* parcel); @@ -137,7 +137,7 @@ public: bool isValid(); uint32_t getIdentity() const { return mIdentity; } - sp getSurfaceTexture(); + sp getSurfaceTexture(); // TODO: rename this // the lock/unlock APIs must be used from the same thread status_t lock(SurfaceInfo* info, Region* dirty = NULL); @@ -161,7 +161,7 @@ private: /* * private stuff... */ - void init(const sp& surfaceTexture); + void init(const sp& bufferProducer); static void cleanCachedSurfacesLocked(); diff --git a/include/gui/SurfaceComposerClient.h b/include/gui/SurfaceComposerClient.h index ae5d69a11..22e6b14e0 100644 --- a/include/gui/SurfaceComposerClient.h +++ b/include/gui/SurfaceComposerClient.h @@ -39,7 +39,7 @@ class DisplayInfo; class Composer; class IMemoryHeap; class ISurfaceComposerClient; -class ISurfaceTexture; +class IGraphicBufferProducer; class Region; // --------------------------------------------------------------------------- @@ -122,7 +122,7 @@ public: status_t destroySurface(SurfaceID sid); static void setDisplaySurface(const sp& token, - const sp& surface); + const sp& bufferProducer); static void setDisplayLayerStack(const sp& token, uint32_t layerStack); diff --git a/include/gui/SurfaceTextureClient.h b/include/gui/SurfaceTextureClient.h index a582975e1..bce232987 100644 --- a/include/gui/SurfaceTextureClient.h +++ b/include/gui/SurfaceTextureClient.h @@ -17,8 +17,8 @@ #ifndef ANDROID_GUI_SURFACETEXTURECLIENT_H #define ANDROID_GUI_SURFACETEXTURECLIENT_H -#include -#include +#include +#include #include #include @@ -44,7 +44,7 @@ class Surface; * compositing. For example, a video decoder could render a frame and call * eglSwapBuffers(), which invokes ANativeWindow callbacks defined by * SurfaceTextureClient. STC then acts as the BufferQueue producer, - * providing the new frame to a consumer such as SurfaceTexture. + * providing the new frame to a consumer such as GLConsumer. * * TODO: rename to Surface. The existing Surface class wraps STC with * some Binder goodies, which most users of Surface class don't care about. @@ -54,14 +54,14 @@ class SurfaceTextureClient { public: - SurfaceTextureClient(const sp& surfaceTexture); + SurfaceTextureClient(const sp& bufferProducer); - sp getISurfaceTexture() const; + sp getISurfaceTexture() const; // TODO: rename protected: SurfaceTextureClient(); virtual ~SurfaceTextureClient(); - void setISurfaceTexture(const sp& surfaceTexture); + void setISurfaceTexture(const sp& bufferProducer); private: // can't be copied @@ -144,11 +144,12 @@ private: // mSurfaceTexture is the interface to the surface texture server. All // operations on the surface texture client ultimately translate into // interactions with the server using this interface. - sp mSurfaceTexture; + // TODO: rename to mBufferProducer + sp mSurfaceTexture; // mSlots stores the buffers that have been allocated for each buffer slot. // It is initialized to null pointers, and gets filled in with the result of - // ISurfaceTexture::requestBuffer when the client dequeues a buffer from a + // IGraphicBufferProducer::requestBuffer when the client dequeues a buffer from a // slot that has not yet been used. The buffer allocated to a slot will also // be replaced if the requested buffer usage or geometry differs from that // of the buffer allocated to a slot. @@ -214,7 +215,7 @@ private: mutable bool mConsumerRunningBehind; // mMutex is the mutex used to prevent concurrent access to the member - // variables of SurfaceTexture objects. It must be locked whenever the + // variables of SurfaceTextureClient objects. It must be locked whenever the // member variables are accessed. mutable Mutex mMutex; diff --git a/include/private/gui/LayerState.h b/include/private/gui/LayerState.h index a7eb48c66..5b400ca3a 100644 --- a/include/private/gui/LayerState.h +++ b/include/private/gui/LayerState.h @@ -114,7 +114,7 @@ struct DisplayState { uint32_t what; sp token; - sp surface; + sp surface; uint32_t layerStack; uint32_t orientation; Rect viewport; diff --git a/libs/gui/Android.mk b/libs/gui/Android.mk index 04444e937..b1aeb3288 100644 --- a/libs/gui/Android.mk +++ b/libs/gui/Android.mk @@ -9,23 +9,23 @@ LOCAL_SRC_FILES:= \ CpuConsumer.cpp \ DisplayEventReceiver.cpp \ DummyConsumer.cpp \ + GLConsumer.cpp \ GraphicBufferAlloc.cpp \ GuiConfig.cpp \ IDisplayEventConnection.cpp \ IGraphicBufferAlloc.cpp \ + IGraphicBufferProducer.cpp \ ISensorEventConnection.cpp \ ISensorServer.cpp \ ISurface.cpp \ ISurfaceComposer.cpp \ ISurfaceComposerClient.cpp \ - ISurfaceTexture.cpp \ LayerState.cpp \ Sensor.cpp \ SensorEventQueue.cpp \ SensorManager.cpp \ Surface.cpp \ SurfaceComposerClient.cpp \ - SurfaceTexture.cpp \ SurfaceTextureClient.cpp \ LOCAL_SHARED_LIBRARIES := \ diff --git a/libs/gui/BufferQueue.cpp b/libs/gui/BufferQueue.cpp index 609e7d2c9..4be655b3f 100644 --- a/libs/gui/BufferQueue.cpp +++ b/libs/gui/BufferQueue.cpp @@ -146,7 +146,7 @@ status_t BufferQueue::setBufferCount(int bufferCount) { Mutex::Autolock lock(mMutex); if (mAbandoned) { - ST_LOGE("setBufferCount: SurfaceTexture has been abandoned!"); + ST_LOGE("setBufferCount: BufferQueue has been abandoned!"); return NO_INIT; } if (bufferCount > NUM_BUFFER_SLOTS) { @@ -200,7 +200,7 @@ int BufferQueue::query(int what, int* outValue) Mutex::Autolock lock(mMutex); if (mAbandoned) { - ST_LOGE("query: SurfaceTexture has been abandoned!"); + ST_LOGE("query: BufferQueue has been abandoned!"); return NO_INIT; } @@ -233,7 +233,7 @@ status_t BufferQueue::requestBuffer(int slot, sp* buf) { ST_LOGV("requestBuffer: slot=%d", slot); Mutex::Autolock lock(mMutex); if (mAbandoned) { - ST_LOGE("requestBuffer: SurfaceTexture has been abandoned!"); + ST_LOGE("requestBuffer: BufferQueue has been abandoned!"); return NO_INIT; } int maxBufferCount = getMaxBufferCountLocked(); @@ -282,7 +282,7 @@ status_t BufferQueue::dequeueBuffer(int *outBuf, sp& outFence, bool tryAgain = true; while (tryAgain) { if (mAbandoned) { - ST_LOGE("dequeueBuffer: SurfaceTexture has been abandoned!"); + ST_LOGE("dequeueBuffer: BufferQueue has been abandoned!"); return NO_INIT; } @@ -294,7 +294,7 @@ status_t BufferQueue::dequeueBuffer(int *outBuf, sp& outFence, assert(mSlots[i].mBufferState == BufferSlot::FREE); if (mSlots[i].mGraphicBuffer != NULL) { freeBufferLocked(i); - returnFlags |= ISurfaceTexture::RELEASE_ALL_BUFFERS; + returnFlags |= IGraphicBufferProducer::RELEASE_ALL_BUFFERS; } } @@ -390,7 +390,7 @@ status_t BufferQueue::dequeueBuffer(int *outBuf, sp& outFence, mSlots[buf].mFence.clear(); mSlots[buf].mEglDisplay = EGL_NO_DISPLAY; - returnFlags |= ISurfaceTexture::BUFFER_NEEDS_REALLOCATION; + returnFlags |= IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION; } dpy = mSlots[buf].mEglDisplay; @@ -400,7 +400,7 @@ status_t BufferQueue::dequeueBuffer(int *outBuf, sp& outFence, mSlots[buf].mFence.clear(); } // end lock scope - if (returnFlags & ISurfaceTexture::BUFFER_NEEDS_REALLOCATION) { + if (returnFlags & IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION) { status_t error; sp graphicBuffer( mGraphicBufferAlloc->createGraphicBuffer( @@ -415,7 +415,7 @@ status_t BufferQueue::dequeueBuffer(int *outBuf, sp& outFence, Mutex::Autolock lock(mMutex); if (mAbandoned) { - ST_LOGE("dequeueBuffer: SurfaceTexture has been abandoned!"); + ST_LOGE("dequeueBuffer: BufferQueue has been abandoned!"); return NO_INIT; } @@ -449,7 +449,7 @@ status_t BufferQueue::setSynchronousMode(bool enabled) { Mutex::Autolock lock(mMutex); if (mAbandoned) { - ST_LOGE("setSynchronousMode: SurfaceTexture has been abandoned!"); + ST_LOGE("setSynchronousMode: BufferQueue has been abandoned!"); return NO_INIT; } @@ -498,7 +498,7 @@ status_t BufferQueue::queueBuffer(int buf, { // scope for the lock Mutex::Autolock lock(mMutex); if (mAbandoned) { - ST_LOGE("queueBuffer: SurfaceTexture has been abandoned!"); + ST_LOGE("queueBuffer: BufferQueue has been abandoned!"); return NO_INIT; } int maxBufferCount = getMaxBufferCountLocked(); diff --git a/libs/gui/ConsumerBase.cpp b/libs/gui/ConsumerBase.cpp index 2e7c42414..8f391aa49 100644 --- a/libs/gui/ConsumerBase.cpp +++ b/libs/gui/ConsumerBase.cpp @@ -69,7 +69,7 @@ ConsumerBase::ConsumerBase(const sp& bufferQueue) : status_t err = mBufferQueue->consumerConnect(proxy); if (err != NO_ERROR) { - CB_LOGE("SurfaceTexture: error connecting to BufferQueue: %s (%d)", + CB_LOGE("ConsumerBase: error connecting to BufferQueue: %s (%d)", strerror(-err), err); } else { mBufferQueue->setConsumerName(mName); @@ -233,4 +233,4 @@ status_t ConsumerBase::releaseBufferLocked(int slot, EGLDisplay display, return err; } -} // namespace android \ No newline at end of file +} // namespace android diff --git a/libs/gui/SurfaceTexture.cpp b/libs/gui/GLConsumer.cpp similarity index 88% rename from libs/gui/SurfaceTexture.cpp rename to libs/gui/GLConsumer.cpp index ee3079e56..ba23f9edf 100644 --- a/libs/gui/SurfaceTexture.cpp +++ b/libs/gui/GLConsumer.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#define LOG_TAG "SurfaceTexture" +#define LOG_TAG "GLConsumer" #define ATRACE_TAG ATRACE_TAG_GRAPHICS //#define LOG_NDEBUG 0 @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include @@ -41,7 +41,7 @@ namespace android { -// This compile option makes SurfaceTexture use the +// This compile option makes GLConsumer use the // EGL_ANDROID_native_fence_sync extension to create Android native fences to // signal when all GLES reads for a given buffer have completed. It is not // compatible with using the EGL_KHR_fence_sync extension for the same @@ -50,12 +50,12 @@ namespace android { #ifdef USE_FENCE_SYNC #error "USE_NATIVE_FENCE_SYNC and USE_FENCE_SYNC are incompatible" #endif -const bool SurfaceTexture::sUseNativeFenceSync = true; +const bool GLConsumer::sUseNativeFenceSync = true; #else -const bool SurfaceTexture::sUseNativeFenceSync = false; +const bool GLConsumer::sUseNativeFenceSync = false; #endif -// This compile option makes SurfaceTexture use the EGL_ANDROID_sync_wait +// This compile option makes GLConsumer use the EGL_ANDROID_sync_wait // extension to insert server-side waits into the GLES command stream. This // feature requires the EGL_ANDROID_native_fence_sync and // EGL_ANDROID_wait_sync extensions. @@ -65,7 +65,7 @@ static const bool useWaitSync = true; static const bool useWaitSync = false; #endif -// Macros for including the SurfaceTexture name in log messages +// Macros for including the GLConsumer name in log messages #define ST_LOGV(x, ...) ALOGV("[%s] "x, mName.string(), ##__VA_ARGS__) #define ST_LOGD(x, ...) ALOGD("[%s] "x, mName.string(), ##__VA_ARGS__) #define ST_LOGI(x, ...) ALOGI("[%s] "x, mName.string(), ##__VA_ARGS__) @@ -113,7 +113,7 @@ static float mtxRot270[16] = { static void mtxMul(float out[16], const float a[16], const float b[16]); -SurfaceTexture::SurfaceTexture(GLuint tex, bool allowSynchronousMode, +GLConsumer::GLConsumer(GLuint tex, bool allowSynchronousMode, GLenum texTarget, bool useFenceSync, const sp &bufferQueue) : ConsumerBase(bufferQueue == 0 ? new BufferQueue(allowSynchronousMode) : bufferQueue), mCurrentTransform(0), @@ -131,7 +131,7 @@ SurfaceTexture::SurfaceTexture(GLuint tex, bool allowSynchronousMode, mCurrentTexture(BufferQueue::INVALID_BUFFER_SLOT), mAttached(true) { - ST_LOGV("SurfaceTexture"); + ST_LOGV("GLConsumer"); memcpy(mCurrentTransformMatrix, mtxIdentity, sizeof(mCurrentTransformMatrix)); @@ -139,13 +139,13 @@ SurfaceTexture::SurfaceTexture(GLuint tex, bool allowSynchronousMode, mBufferQueue->setConsumerUsageBits(DEFAULT_USAGE_FLAGS); } -status_t SurfaceTexture::setDefaultMaxBufferCount(int bufferCount) { +status_t GLConsumer::setDefaultMaxBufferCount(int bufferCount) { Mutex::Autolock lock(mMutex); return mBufferQueue->setDefaultMaxBufferCount(bufferCount); } -status_t SurfaceTexture::setDefaultBufferSize(uint32_t w, uint32_t h) +status_t GLConsumer::setDefaultBufferSize(uint32_t w, uint32_t h) { Mutex::Autolock lock(mMutex); mDefaultWidth = w; @@ -153,13 +153,13 @@ status_t SurfaceTexture::setDefaultBufferSize(uint32_t w, uint32_t h) return mBufferQueue->setDefaultBufferSize(w, h); } -status_t SurfaceTexture::updateTexImage() { +status_t GLConsumer::updateTexImage() { ATRACE_CALL(); ST_LOGV("updateTexImage"); Mutex::Autolock lock(mMutex); if (mAbandoned) { - ST_LOGE("updateTexImage: SurfaceTexture is abandoned!"); + ST_LOGE("updateTexImage: GLConsumer is abandoned!"); return NO_INIT; } @@ -200,7 +200,7 @@ status_t SurfaceTexture::updateTexImage() { return bindTextureImageLocked(); } -status_t SurfaceTexture::acquireBufferLocked(BufferQueue::BufferItem *item) { +status_t GLConsumer::acquireBufferLocked(BufferQueue::BufferItem *item) { status_t err = ConsumerBase::acquireBufferLocked(item); if (err != NO_ERROR) { return err; @@ -223,7 +223,7 @@ status_t SurfaceTexture::acquireBufferLocked(BufferQueue::BufferItem *item) { return NO_ERROR; } -status_t SurfaceTexture::releaseBufferLocked(int buf, EGLDisplay display, +status_t GLConsumer::releaseBufferLocked(int buf, EGLDisplay display, EGLSyncKHR eglFence) { status_t err = ConsumerBase::releaseBufferLocked(buf, display, eglFence); @@ -232,12 +232,12 @@ status_t SurfaceTexture::releaseBufferLocked(int buf, EGLDisplay display, return err; } -status_t SurfaceTexture::releaseAndUpdateLocked(const BufferQueue::BufferItem& item) +status_t GLConsumer::releaseAndUpdateLocked(const BufferQueue::BufferItem& item) { status_t err = NO_ERROR; if (!mAttached) { - ST_LOGE("releaseAndUpdate: SurfaceTexture is not attached to an OpenGL " + ST_LOGE("releaseAndUpdate: GLConsumer is not attached to an OpenGL " "ES context"); return INVALID_OPERATION; } @@ -293,7 +293,7 @@ status_t SurfaceTexture::releaseAndUpdateLocked(const BufferQueue::BufferItem& i } } - // Update the SurfaceTexture state. + // Update the GLConsumer state. mCurrentTexture = buf; mCurrentTextureBuf = mSlots[buf].mGraphicBuffer; mCurrentCrop = item.mCrop; @@ -307,7 +307,7 @@ status_t SurfaceTexture::releaseAndUpdateLocked(const BufferQueue::BufferItem& i return err; } -status_t SurfaceTexture::bindTextureImageLocked() { +status_t GLConsumer::bindTextureImageLocked() { if (mEglDisplay == EGL_NO_DISPLAY) { ALOGE("bindTextureImage: invalid display"); return INVALID_OPERATION; @@ -345,7 +345,7 @@ status_t SurfaceTexture::bindTextureImageLocked() { } -status_t SurfaceTexture::checkAndUpdateEglStateLocked() { +status_t GLConsumer::checkAndUpdateEglStateLocked() { EGLDisplay dpy = eglGetCurrentDisplay(); EGLContext ctx = eglGetCurrentContext(); @@ -366,7 +366,7 @@ status_t SurfaceTexture::checkAndUpdateEglStateLocked() { return NO_ERROR; } -void SurfaceTexture::setReleaseFence(int fenceFd) { +void GLConsumer::setReleaseFence(int fenceFd) { sp fence(new Fence(fenceFd)); if (fenceFd == -1 || mCurrentTexture == BufferQueue::INVALID_BUFFER_SLOT) return; @@ -377,18 +377,18 @@ void SurfaceTexture::setReleaseFence(int fenceFd) { } } -status_t SurfaceTexture::detachFromContext() { +status_t GLConsumer::detachFromContext() { ATRACE_CALL(); ST_LOGV("detachFromContext"); Mutex::Autolock lock(mMutex); if (mAbandoned) { - ST_LOGE("detachFromContext: abandoned SurfaceTexture"); + ST_LOGE("detachFromContext: abandoned GLConsumer"); return NO_INIT; } if (!mAttached) { - ST_LOGE("detachFromContext: SurfaceTexture is not attached to a " + ST_LOGE("detachFromContext: GLConsumer is not attached to a " "context"); return INVALID_OPERATION; } @@ -417,7 +417,7 @@ status_t SurfaceTexture::detachFromContext() { // Because we're giving up the EGLDisplay we need to free all the EGLImages // that are associated with it. They'll be recreated when the - // SurfaceTexture gets attached to a new OpenGL ES context (and thus gets a + // GLConsumer gets attached to a new OpenGL ES context (and thus gets a // new EGLDisplay). for (int i =0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) { EGLImageKHR img = mEglSlots[i].mEglImage; @@ -434,18 +434,18 @@ status_t SurfaceTexture::detachFromContext() { return OK; } -status_t SurfaceTexture::attachToContext(GLuint tex) { +status_t GLConsumer::attachToContext(GLuint tex) { ATRACE_CALL(); ST_LOGV("attachToContext"); Mutex::Autolock lock(mMutex); if (mAbandoned) { - ST_LOGE("attachToContext: abandoned SurfaceTexture"); + ST_LOGE("attachToContext: abandoned GLConsumer"); return NO_INIT; } if (mAttached) { - ST_LOGE("attachToContext: SurfaceTexture is already attached to a " + ST_LOGE("attachToContext: GLConsumer is already attached to a " "context"); return INVALID_OPERATION; } @@ -469,7 +469,7 @@ status_t SurfaceTexture::attachToContext(GLuint tex) { if (mCurrentTextureBuf != NULL) { // The EGLImageKHR that was associated with the slot was destroyed when - // the SurfaceTexture was detached from the old context, so we need to + // the GLConsumer was detached from the old context, so we need to // recreate it here. status_t err = bindUnslottedBufferLocked(dpy); if (err != NO_ERROR) { @@ -485,7 +485,7 @@ status_t SurfaceTexture::attachToContext(GLuint tex) { return OK; } -status_t SurfaceTexture::bindUnslottedBufferLocked(EGLDisplay dpy) { +status_t GLConsumer::bindUnslottedBufferLocked(EGLDisplay dpy) { ST_LOGV("bindUnslottedBuffer ct=%d ctb=%p", mCurrentTexture, mCurrentTextureBuf.get()); @@ -517,7 +517,7 @@ status_t SurfaceTexture::bindUnslottedBufferLocked(EGLDisplay dpy) { } -status_t SurfaceTexture::syncForReleaseLocked(EGLDisplay dpy) { +status_t GLConsumer::syncForReleaseLocked(EGLDisplay dpy) { ST_LOGV("syncForReleaseLocked"); if (mCurrentTexture != BufferQueue::INVALID_BUFFER_SLOT) { @@ -580,7 +580,7 @@ status_t SurfaceTexture::syncForReleaseLocked(EGLDisplay dpy) { return OK; } -bool SurfaceTexture::isExternalFormat(uint32_t format) +bool GLConsumer::isExternalFormat(uint32_t format) { switch (format) { // supported YUV formats @@ -599,19 +599,19 @@ bool SurfaceTexture::isExternalFormat(uint32_t format) return false; } -GLenum SurfaceTexture::getCurrentTextureTarget() const { +GLenum GLConsumer::getCurrentTextureTarget() const { return mTexTarget; } -void SurfaceTexture::getTransformMatrix(float mtx[16]) { +void GLConsumer::getTransformMatrix(float mtx[16]) { Mutex::Autolock lock(mMutex); memcpy(mtx, mCurrentTransformMatrix, sizeof(mCurrentTransformMatrix)); } -void SurfaceTexture::setFilteringEnabled(bool enabled) { +void GLConsumer::setFilteringEnabled(bool enabled) { Mutex::Autolock lock(mMutex); if (mAbandoned) { - ST_LOGE("setFilteringEnabled: SurfaceTexture is abandoned!"); + ST_LOGE("setFilteringEnabled: GLConsumer is abandoned!"); return; } bool needsRecompute = mFilteringEnabled != enabled; @@ -626,7 +626,7 @@ void SurfaceTexture::setFilteringEnabled(bool enabled) { } } -void SurfaceTexture::computeCurrentTransformMatrixLocked() { +void GLConsumer::computeCurrentTransformMatrixLocked() { ST_LOGV("computeCurrentTransformMatrixLocked"); float xform[16]; @@ -719,19 +719,19 @@ void SurfaceTexture::computeCurrentTransformMatrixLocked() { mtxMul(mtxBeforeFlipV, crop, xform); // SurfaceFlinger expects the top of its window textures to be at a Y - // coordinate of 0, so SurfaceTexture must behave the same way. We don't + // coordinate of 0, so GLConsumer must behave the same way. We don't // want to expose this to applications, however, so we must add an // additional vertical flip to the transform after all the other transforms. mtxMul(mCurrentTransformMatrix, mtxFlipV, mtxBeforeFlipV); } -nsecs_t SurfaceTexture::getTimestamp() { +nsecs_t GLConsumer::getTimestamp() { ST_LOGV("getTimestamp"); Mutex::Autolock lock(mMutex); return mCurrentTimestamp; } -EGLImageKHR SurfaceTexture::createImage(EGLDisplay dpy, +EGLImageKHR GLConsumer::createImage(EGLDisplay dpy, const sp& graphicBuffer) { EGLClientBuffer cbuf = (EGLClientBuffer)graphicBuffer->getNativeBuffer(); EGLint attrs[] = { @@ -747,12 +747,12 @@ EGLImageKHR SurfaceTexture::createImage(EGLDisplay dpy, return image; } -sp SurfaceTexture::getCurrentBuffer() const { +sp GLConsumer::getCurrentBuffer() const { Mutex::Autolock lock(mMutex); return mCurrentTextureBuf; } -Rect SurfaceTexture::getCurrentCrop() const { +Rect GLConsumer::getCurrentCrop() const { Mutex::Autolock lock(mMutex); Rect outCrop = mCurrentCrop; @@ -788,27 +788,27 @@ Rect SurfaceTexture::getCurrentCrop() const { return outCrop; } -uint32_t SurfaceTexture::getCurrentTransform() const { +uint32_t GLConsumer::getCurrentTransform() const { Mutex::Autolock lock(mMutex); return mCurrentTransform; } -uint32_t SurfaceTexture::getCurrentScalingMode() const { +uint32_t GLConsumer::getCurrentScalingMode() const { Mutex::Autolock lock(mMutex); return mCurrentScalingMode; } -sp SurfaceTexture::getCurrentFence() const { +sp GLConsumer::getCurrentFence() const { Mutex::Autolock lock(mMutex); return mCurrentFence; } -status_t SurfaceTexture::doGLFenceWait() const { +status_t GLConsumer::doGLFenceWait() const { Mutex::Autolock lock(mMutex); return doGLFenceWaitLocked(); } -status_t SurfaceTexture::doGLFenceWaitLocked() const { +status_t GLConsumer::doGLFenceWaitLocked() const { EGLDisplay dpy = eglGetCurrentDisplay(); EGLContext ctx = eglGetCurrentContext(); @@ -857,7 +857,7 @@ status_t SurfaceTexture::doGLFenceWaitLocked() const { } } else { status_t err = mCurrentFence->waitForever(1000, - "SurfaceTexture::doGLFenceWaitLocked"); + "GLConsumer::doGLFenceWaitLocked"); if (err != NO_ERROR) { ST_LOGE("doGLFenceWait: error waiting for fence: %d", err); return err; @@ -868,12 +868,12 @@ status_t SurfaceTexture::doGLFenceWaitLocked() const { return NO_ERROR; } -bool SurfaceTexture::isSynchronousMode() const { +bool GLConsumer::isSynchronousMode() const { Mutex::Autolock lock(mMutex); return mBufferQueue->isSynchronousMode(); } -void SurfaceTexture::freeBufferLocked(int slotIndex) { +void GLConsumer::freeBufferLocked(int slotIndex) { ST_LOGV("freeBufferLocked: slotIndex=%d", slotIndex); if (slotIndex == mCurrentTexture) { mCurrentTexture = BufferQueue::INVALID_BUFFER_SLOT; @@ -887,42 +887,42 @@ void SurfaceTexture::freeBufferLocked(int slotIndex) { ConsumerBase::freeBufferLocked(slotIndex); } -void SurfaceTexture::abandonLocked() { +void GLConsumer::abandonLocked() { ST_LOGV("abandonLocked"); mCurrentTextureBuf.clear(); ConsumerBase::abandonLocked(); } -void SurfaceTexture::setName(const String8& name) { +void GLConsumer::setName(const String8& name) { Mutex::Autolock _l(mMutex); mName = name; mBufferQueue->setConsumerName(name); } -status_t SurfaceTexture::setDefaultBufferFormat(uint32_t defaultFormat) { +status_t GLConsumer::setDefaultBufferFormat(uint32_t defaultFormat) { Mutex::Autolock lock(mMutex); return mBufferQueue->setDefaultBufferFormat(defaultFormat); } -status_t SurfaceTexture::setConsumerUsageBits(uint32_t usage) { +status_t GLConsumer::setConsumerUsageBits(uint32_t usage) { Mutex::Autolock lock(mMutex); usage |= DEFAULT_USAGE_FLAGS; return mBufferQueue->setConsumerUsageBits(usage); } -status_t SurfaceTexture::setTransformHint(uint32_t hint) { +status_t GLConsumer::setTransformHint(uint32_t hint) { Mutex::Autolock lock(mMutex); return mBufferQueue->setTransformHint(hint); } -// Used for refactoring BufferQueue from SurfaceTexture -// Should not be in final interface once users of SurfaceTexture are clean up. -status_t SurfaceTexture::setSynchronousMode(bool enabled) { +// Used for refactoring BufferQueue from GLConsumer +// Should not be in final interface once users of GLConsumer are clean up. +status_t GLConsumer::setSynchronousMode(bool enabled) { Mutex::Autolock lock(mMutex); return mBufferQueue->setSynchronousMode(enabled); } -void SurfaceTexture::dumpLocked(String8& result, const char* prefix, +void GLConsumer::dumpLocked(String8& result, const char* prefix, char* buffer, size_t size) const { snprintf(buffer, size, diff --git a/libs/gui/ISurfaceTexture.cpp b/libs/gui/IGraphicBufferProducer.cpp similarity index 82% rename from libs/gui/ISurfaceTexture.cpp rename to libs/gui/IGraphicBufferProducer.cpp index a0b1e7446..923e39461 100644 --- a/libs/gui/ISurfaceTexture.cpp +++ b/libs/gui/IGraphicBufferProducer.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include namespace android { // ---------------------------------------------------------------------------- @@ -43,17 +43,17 @@ enum { }; -class BpSurfaceTexture : public BpInterface +class BpGraphicBufferProducer : public BpInterface { public: - BpSurfaceTexture(const sp& impl) - : BpInterface(impl) + BpGraphicBufferProducer(const sp& impl) + : BpInterface(impl) { } virtual status_t requestBuffer(int bufferIdx, sp* buf) { Parcel data, reply; - data.writeInterfaceToken(ISurfaceTexture::getInterfaceDescriptor()); + data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); data.writeInt32(bufferIdx); status_t result =remote()->transact(REQUEST_BUFFER, data, &reply); if (result != NO_ERROR) { @@ -71,7 +71,7 @@ public: virtual status_t setBufferCount(int bufferCount) { Parcel data, reply; - data.writeInterfaceToken(ISurfaceTexture::getInterfaceDescriptor()); + data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); data.writeInt32(bufferCount); status_t result =remote()->transact(SET_BUFFER_COUNT, data, &reply); if (result != NO_ERROR) { @@ -84,7 +84,7 @@ public: virtual status_t dequeueBuffer(int *buf, sp& fence, uint32_t w, uint32_t h, uint32_t format, uint32_t usage) { Parcel data, reply; - data.writeInterfaceToken(ISurfaceTexture::getInterfaceDescriptor()); + data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); data.writeInt32(w); data.writeInt32(h); data.writeInt32(format); @@ -107,7 +107,7 @@ public: virtual status_t queueBuffer(int buf, const QueueBufferInput& input, QueueBufferOutput* output) { Parcel data, reply; - data.writeInterfaceToken(ISurfaceTexture::getInterfaceDescriptor()); + data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); data.writeInt32(buf); data.write(input); status_t result = remote()->transact(QUEUE_BUFFER, data, &reply); @@ -122,7 +122,7 @@ public: virtual void cancelBuffer(int buf, sp fence) { Parcel data, reply; bool hasFence = fence.get() && fence->isValid(); - data.writeInterfaceToken(ISurfaceTexture::getInterfaceDescriptor()); + data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); data.writeInt32(buf); data.writeInt32(hasFence); if (hasFence) { @@ -133,7 +133,7 @@ public: virtual int query(int what, int* value) { Parcel data, reply; - data.writeInterfaceToken(ISurfaceTexture::getInterfaceDescriptor()); + data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); data.writeInt32(what); status_t result = remote()->transact(QUERY, data, &reply); if (result != NO_ERROR) { @@ -146,7 +146,7 @@ public: virtual status_t setSynchronousMode(bool enabled) { Parcel data, reply; - data.writeInterfaceToken(ISurfaceTexture::getInterfaceDescriptor()); + data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); data.writeInt32(enabled); status_t result = remote()->transact(SET_SYNCHRONOUS_MODE, data, &reply); if (result != NO_ERROR) { @@ -158,7 +158,7 @@ public: virtual status_t connect(int api, QueueBufferOutput* output) { Parcel data, reply; - data.writeInterfaceToken(ISurfaceTexture::getInterfaceDescriptor()); + data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); data.writeInt32(api); status_t result = remote()->transact(CONNECT, data, &reply); if (result != NO_ERROR) { @@ -171,7 +171,7 @@ public: virtual status_t disconnect(int api) { Parcel data, reply; - data.writeInterfaceToken(ISurfaceTexture::getInterfaceDescriptor()); + data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); data.writeInt32(api); status_t result =remote()->transact(DISCONNECT, data, &reply); if (result != NO_ERROR) { @@ -182,16 +182,16 @@ public: } }; -IMPLEMENT_META_INTERFACE(SurfaceTexture, "android.gui.SurfaceTexture"); +IMPLEMENT_META_INTERFACE(GraphicBufferProducer, "android.gui.SurfaceTexture"); // ---------------------------------------------------------------------- -status_t BnSurfaceTexture::onTransact( +status_t BnGraphicBufferProducer::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { case REQUEST_BUFFER: { - CHECK_INTERFACE(ISurfaceTexture, data, reply); + CHECK_INTERFACE(IGraphicBufferProducer, data, reply); int bufferIdx = data.readInt32(); sp buffer; int result = requestBuffer(bufferIdx, &buffer); @@ -203,14 +203,14 @@ status_t BnSurfaceTexture::onTransact( return NO_ERROR; } break; case SET_BUFFER_COUNT: { - CHECK_INTERFACE(ISurfaceTexture, data, reply); + CHECK_INTERFACE(IGraphicBufferProducer, data, reply); int bufferCount = data.readInt32(); int result = setBufferCount(bufferCount); reply->writeInt32(result); return NO_ERROR; } break; case DEQUEUE_BUFFER: { - CHECK_INTERFACE(ISurfaceTexture, data, reply); + CHECK_INTERFACE(IGraphicBufferProducer, data, reply); uint32_t w = data.readInt32(); uint32_t h = data.readInt32(); uint32_t format = data.readInt32(); @@ -228,7 +228,7 @@ status_t BnSurfaceTexture::onTransact( return NO_ERROR; } break; case QUEUE_BUFFER: { - CHECK_INTERFACE(ISurfaceTexture, data, reply); + CHECK_INTERFACE(IGraphicBufferProducer, data, reply); int buf = data.readInt32(); QueueBufferInput input(data); QueueBufferOutput* const output = @@ -239,7 +239,7 @@ status_t BnSurfaceTexture::onTransact( return NO_ERROR; } break; case CANCEL_BUFFER: { - CHECK_INTERFACE(ISurfaceTexture, data, reply); + CHECK_INTERFACE(IGraphicBufferProducer, data, reply); int buf = data.readInt32(); sp fence; bool hasFence = data.readInt32(); @@ -251,7 +251,7 @@ status_t BnSurfaceTexture::onTransact( return NO_ERROR; } break; case QUERY: { - CHECK_INTERFACE(ISurfaceTexture, data, reply); + CHECK_INTERFACE(IGraphicBufferProducer, data, reply); int value; int what = data.readInt32(); int res = query(what, &value); @@ -260,14 +260,14 @@ status_t BnSurfaceTexture::onTransact( return NO_ERROR; } break; case SET_SYNCHRONOUS_MODE: { - CHECK_INTERFACE(ISurfaceTexture, data, reply); + CHECK_INTERFACE(IGraphicBufferProducer, data, reply); bool enabled = data.readInt32(); status_t res = setSynchronousMode(enabled); reply->writeInt32(res); return NO_ERROR; } break; case CONNECT: { - CHECK_INTERFACE(ISurfaceTexture, data, reply); + CHECK_INTERFACE(IGraphicBufferProducer, data, reply); int api = data.readInt32(); QueueBufferOutput* const output = reinterpret_cast( @@ -277,7 +277,7 @@ status_t BnSurfaceTexture::onTransact( return NO_ERROR; } break; case DISCONNECT: { - CHECK_INTERFACE(ISurfaceTexture, data, reply); + CHECK_INTERFACE(IGraphicBufferProducer, data, reply); int api = data.readInt32(); status_t res = disconnect(api); reply->writeInt32(res); @@ -293,11 +293,11 @@ static bool isValid(const sp& fence) { return fence.get() && fence->isValid(); } -ISurfaceTexture::QueueBufferInput::QueueBufferInput(const Parcel& parcel) { +IGraphicBufferProducer::QueueBufferInput::QueueBufferInput(const Parcel& parcel) { parcel.read(*this); } -size_t ISurfaceTexture::QueueBufferInput::getFlattenedSize() const +size_t IGraphicBufferProducer::QueueBufferInput::getFlattenedSize() const { return sizeof(timestamp) + sizeof(crop) @@ -307,12 +307,12 @@ size_t ISurfaceTexture::QueueBufferInput::getFlattenedSize() const + (isValid(fence) ? fence->getFlattenedSize() : 0); } -size_t ISurfaceTexture::QueueBufferInput::getFdCount() const +size_t IGraphicBufferProducer::QueueBufferInput::getFdCount() const { return isValid(fence) ? fence->getFdCount() : 0; } -status_t ISurfaceTexture::QueueBufferInput::flatten(void* buffer, size_t size, +status_t IGraphicBufferProducer::QueueBufferInput::flatten(void* buffer, size_t size, int fds[], size_t count) const { status_t err = NO_ERROR; @@ -329,7 +329,7 @@ status_t ISurfaceTexture::QueueBufferInput::flatten(void* buffer, size_t size, return err; } -status_t ISurfaceTexture::QueueBufferInput::unflatten(void const* buffer, +status_t IGraphicBufferProducer::QueueBufferInput::unflatten(void const* buffer, size_t size, int fds[], size_t count) { status_t err = NO_ERROR; diff --git a/libs/gui/ISurface.cpp b/libs/gui/ISurface.cpp index c2ea18307..8c25f4513 100644 --- a/libs/gui/ISurface.cpp +++ b/libs/gui/ISurface.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include namespace android { @@ -37,11 +37,11 @@ public: { } - virtual sp getSurfaceTexture() const { + virtual sp getSurfaceTexture() const { Parcel data, reply; data.writeInterfaceToken(ISurface::getInterfaceDescriptor()); remote()->transact(GET_SURFACE_TEXTURE, data, &reply); - return interface_cast(reply.readStrongBinder()); + return interface_cast(reply.readStrongBinder()); } }; diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp index 85a94882e..72b627746 100644 --- a/libs/gui/ISurfaceComposer.cpp +++ b/libs/gui/ISurfaceComposer.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include @@ -124,7 +124,7 @@ public: } virtual bool authenticateSurfaceTexture( - const sp& surfaceTexture) const + const sp& bufferProducer) const { Parcel data, reply; int err = NO_ERROR; @@ -135,7 +135,7 @@ public: "interface descriptor: %s (%d)", strerror(-err), -err); return false; } - err = data.writeStrongBinder(surfaceTexture->asBinder()); + err = data.writeStrongBinder(bufferProducer->asBinder()); if (err != NO_ERROR) { ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing " "strong binder to parcel: %s (%d)", strerror(-err), -err); @@ -288,9 +288,9 @@ status_t BnSurfaceComposer::onTransact( } break; case AUTHENTICATE_SURFACE: { CHECK_INTERFACE(ISurfaceComposer, data, reply); - sp surfaceTexture = - interface_cast(data.readStrongBinder()); - int32_t result = authenticateSurfaceTexture(surfaceTexture) ? 1 : 0; + sp bufferProducer = + interface_cast(data.readStrongBinder()); + int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0; reply->writeInt32(result); } break; case CREATE_DISPLAY_EVENT_CONNECTION: { diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp index e2604f8e2..5e5edcd2d 100644 --- a/libs/gui/LayerState.cpp +++ b/libs/gui/LayerState.cpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include namespace android { @@ -74,7 +74,7 @@ status_t DisplayState::write(Parcel& output) const { status_t DisplayState::read(const Parcel& input) { token = input.readStrongBinder(); - surface = interface_cast(input.readStrongBinder()); + surface = interface_cast(input.readStrongBinder()); what = input.readInt32(); layerStack = input.readInt32(); orientation = input.readInt32(); diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp index 174506107..51d37b3cf 100644 --- a/libs/gui/Surface.cpp +++ b/libs/gui/Surface.cpp @@ -179,7 +179,7 @@ status_t SurfaceControl::writeSurfaceToParcel( identity = control->mIdentity; } parcel->writeStrongBinder(sur!=0 ? sur->asBinder() : NULL); - parcel->writeStrongBinder(NULL); // NULL ISurfaceTexture in this case. + parcel->writeStrongBinder(NULL); // NULL IGraphicBufferProducer in this case. parcel->writeInt32(identity); return NO_ERROR; } @@ -205,7 +205,7 @@ Surface::Surface(const sp& surface) mSurface(surface->mSurface), mIdentity(surface->mIdentity) { - sp st; + sp st; if (mSurface != NULL) { st = mSurface->getSurfaceTexture(); } @@ -217,9 +217,9 @@ Surface::Surface(const Parcel& parcel, const sp& ref) { mSurface = interface_cast(ref); sp st_binder(parcel.readStrongBinder()); - sp st; + sp st; if (st_binder != NULL) { - st = interface_cast(st_binder); + st = interface_cast(st_binder); } else if (mSurface != NULL) { st = mSurface->getSurfaceTexture(); } @@ -228,7 +228,7 @@ Surface::Surface(const Parcel& parcel, const sp& ref) init(st); } -Surface::Surface(const sp& st) +Surface::Surface(const sp& st) : SurfaceTextureClient(), mSurface(NULL), mIdentity(0) @@ -240,7 +240,7 @@ status_t Surface::writeToParcel( const sp& surface, Parcel* parcel) { sp sur; - sp st; + sp st; uint32_t identity = 0; if (Surface::isValid(surface)) { sur = surface->mSurface; @@ -249,8 +249,8 @@ status_t Surface::writeToParcel( } else if (surface != 0 && (surface->mSurface != NULL || surface->getISurfaceTexture() != NULL)) { - ALOGE("Parceling invalid surface with non-NULL ISurface/ISurfaceTexture as NULL: " - "mSurface = %p, surfaceTexture = %p, mIdentity = %d, ", + ALOGE("Parceling invalid surface with non-NULL ISurface/IGraphicBufferProducer " + "as NULL: mSurface = %p, bufferProducer = %p, mIdentity = %d, ", surface->mSurface.get(), surface->getISurfaceTexture().get(), surface->mIdentity); } @@ -275,7 +275,7 @@ sp Surface::readFromParcel(const Parcel& data) { } else { // The Surface was found in the cache, but we still should clear any // remaining data from the parcel. - data.readStrongBinder(); // ISurfaceTexture + data.readStrongBinder(); // IGraphicBufferProducer data.readInt32(); // identity } if (surface->mSurface == NULL && surface->getISurfaceTexture() == NULL) { @@ -296,12 +296,12 @@ void Surface::cleanCachedSurfacesLocked() { } } -void Surface::init(const sp& surfaceTexture) +void Surface::init(const sp& bufferProducer) { - if (mSurface != NULL || surfaceTexture != NULL) { - ALOGE_IF(surfaceTexture==0, "got a NULL ISurfaceTexture from ISurface"); - if (surfaceTexture != NULL) { - setISurfaceTexture(surfaceTexture); + if (mSurface != NULL || bufferProducer != NULL) { + ALOGE_IF(bufferProducer==0, "got a NULL IGraphicBufferProducer from ISurface"); + if (bufferProducer != NULL) { + setISurfaceTexture(bufferProducer); setUsage(GraphicBuffer::USAGE_HW_RENDER); } @@ -328,7 +328,7 @@ bool Surface::isValid() { return getISurfaceTexture() != NULL; } -sp Surface::getSurfaceTexture() { +sp Surface::getSurfaceTexture() { return getISurfaceTexture(); } diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index 746057b42..0c6881a69 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -157,7 +157,8 @@ public: status_t setLayerStack(const sp& client, SurfaceID id, uint32_t layerStack); - void setDisplaySurface(const sp& token, const sp& surface); + void setDisplaySurface(const sp& token, + const sp& bufferProducer); void setDisplayLayerStack(const sp& token, uint32_t layerStack); void setDisplayProjection(const sp& token, uint32_t orientation, @@ -386,10 +387,10 @@ DisplayState& Composer::getDisplayStateLocked(const sp& token) { } void Composer::setDisplaySurface(const sp& token, - const sp& surface) { + const sp& bufferProducer) { Mutex::Autolock _l(mLock); DisplayState& s(getDisplayStateLocked(token)); - s.surface = surface; + s.surface = bufferProducer; s.what |= DisplayState::eSurfaceChanged; } @@ -571,8 +572,8 @@ status_t SurfaceComposerClient::setMatrix(SurfaceID id, float dsdx, float dtdx, // ---------------------------------------------------------------------------- void SurfaceComposerClient::setDisplaySurface(const sp& token, - const sp& surface) { - Composer::getInstance().setDisplaySurface(token, surface); + const sp& bufferProducer) { + Composer::getInstance().setDisplaySurface(token, bufferProducer); } void SurfaceComposerClient::setDisplayLayerStack(const sp& token, diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp index 7588b9ecb..c015b812f 100644 --- a/libs/gui/SurfaceTextureClient.cpp +++ b/libs/gui/SurfaceTextureClient.cpp @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include @@ -35,10 +35,10 @@ namespace android { SurfaceTextureClient::SurfaceTextureClient( - const sp& surfaceTexture) + const sp& bufferProducer) { SurfaceTextureClient::init(); - SurfaceTextureClient::setISurfaceTexture(surfaceTexture); + SurfaceTextureClient::setISurfaceTexture(bufferProducer); } SurfaceTextureClient::SurfaceTextureClient() { @@ -86,12 +86,12 @@ void SurfaceTextureClient::init() { } void SurfaceTextureClient::setISurfaceTexture( - const sp& surfaceTexture) + const sp& bufferProducer) { - mSurfaceTexture = surfaceTexture; + mSurfaceTexture = bufferProducer; } -sp SurfaceTextureClient::getISurfaceTexture() const { +sp SurfaceTextureClient::getISurfaceTexture() const { return mSurfaceTexture; } @@ -197,20 +197,20 @@ int SurfaceTextureClient::dequeueBuffer(android_native_buffer_t** buffer, status_t result = mSurfaceTexture->dequeueBuffer(&buf, fence, reqW, reqH, mReqFormat, mReqUsage); if (result < 0) { - ALOGV("dequeueBuffer: ISurfaceTexture::dequeueBuffer(%d, %d, %d, %d)" + ALOGV("dequeueBuffer: IGraphicBufferProducer::dequeueBuffer(%d, %d, %d, %d)" "failed: %d", mReqWidth, mReqHeight, mReqFormat, mReqUsage, result); return result; } sp& gbuf(mSlots[buf].buffer); - if (result & ISurfaceTexture::RELEASE_ALL_BUFFERS) { + if (result & IGraphicBufferProducer::RELEASE_ALL_BUFFERS) { freeAllBuffers(); } - if ((result & ISurfaceTexture::BUFFER_NEEDS_REALLOCATION) || gbuf == 0) { + if ((result & IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION) || gbuf == 0) { result = mSurfaceTexture->requestBuffer(buf, &gbuf); if (result != NO_ERROR) { - ALOGE("dequeueBuffer: ISurfaceTexture::requestBuffer failed: %d", + ALOGE("dequeueBuffer: IGraphicBufferProducer::requestBuffer failed: %d", result); return result; } @@ -288,8 +288,8 @@ int SurfaceTextureClient::queueBuffer(android_native_buffer_t* buffer, int fence mCrop.intersect(Rect(buffer->width, buffer->height), &crop); sp fence(fenceFd >= 0 ? new Fence(fenceFd) : NULL); - ISurfaceTexture::QueueBufferOutput output; - ISurfaceTexture::QueueBufferInput input(timestamp, crop, mScalingMode, + IGraphicBufferProducer::QueueBufferOutput output; + IGraphicBufferProducer::QueueBufferInput input(timestamp, crop, mScalingMode, mTransform, fence); status_t err = mSurfaceTexture->queueBuffer(i, input, &output); if (err != OK) { @@ -497,7 +497,7 @@ int SurfaceTextureClient::connect(int api) { ATRACE_CALL(); ALOGV("SurfaceTextureClient::connect"); Mutex::Autolock lock(mMutex); - ISurfaceTexture::QueueBufferOutput output; + IGraphicBufferProducer::QueueBufferOutput output; int err = mSurfaceTexture->connect(api, &output); if (err == NO_ERROR) { uint32_t numPendingBuffers = 0; @@ -566,7 +566,7 @@ int SurfaceTextureClient::setBufferCount(int bufferCount) Mutex::Autolock lock(mMutex); status_t err = mSurfaceTexture->setBufferCount(bufferCount); - ALOGE_IF(err, "ISurfaceTexture::setBufferCount(%d) returned %s", + ALOGE_IF(err, "IGraphicBufferProducer::setBufferCount(%d) returned %s", bufferCount, strerror(-err)); if (err == NO_ERROR) { diff --git a/libs/gui/tests/BufferQueue_test.cpp b/libs/gui/tests/BufferQueue_test.cpp index 817abb483..12cbfb0d7 100644 --- a/libs/gui/tests/BufferQueue_test.cpp +++ b/libs/gui/tests/BufferQueue_test.cpp @@ -63,19 +63,19 @@ struct DummyConsumer : public BufferQueue::ConsumerListener { TEST_F(BufferQueueTest, AcquireBuffer_ExceedsMaxAcquireCount_Fails) { sp dc(new DummyConsumer); mBQ->consumerConnect(dc); - ISurfaceTexture::QueueBufferOutput qbo; + IGraphicBufferProducer::QueueBufferOutput qbo; mBQ->connect(NATIVE_WINDOW_API_CPU, &qbo); mBQ->setBufferCount(4); int slot; sp fence; sp buf; - ISurfaceTexture::QueueBufferInput qbi(0, Rect(0, 0, 1, 1), + IGraphicBufferProducer::QueueBufferInput qbi(0, Rect(0, 0, 1, 1), NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, fence); BufferQueue::BufferItem item; for (int i = 0; i < 2; i++) { - ASSERT_EQ(ISurfaceTexture::BUFFER_NEEDS_REALLOCATION, + ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION, mBQ->dequeueBuffer(&slot, fence, 1, 1, 0, GRALLOC_USAGE_SW_READ_OFTEN)); ASSERT_EQ(OK, mBQ->requestBuffer(slot, &buf)); @@ -83,7 +83,7 @@ TEST_F(BufferQueueTest, AcquireBuffer_ExceedsMaxAcquireCount_Fails) { ASSERT_EQ(OK, mBQ->acquireBuffer(&item)); } - ASSERT_EQ(ISurfaceTexture::BUFFER_NEEDS_REALLOCATION, + ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION, mBQ->dequeueBuffer(&slot, fence, 1, 1, 0, GRALLOC_USAGE_SW_READ_OFTEN)); ASSERT_EQ(OK, mBQ->requestBuffer(slot, &buf)); diff --git a/libs/gui/tests/SurfaceTextureClient_test.cpp b/libs/gui/tests/SurfaceTextureClient_test.cpp index baeca0652..2df83a08d 100644 --- a/libs/gui/tests/SurfaceTextureClient_test.cpp +++ b/libs/gui/tests/SurfaceTextureClient_test.cpp @@ -40,7 +40,7 @@ protected: ALOGV("Begin test: %s.%s", testInfo->test_case_name(), testInfo->name()); - mST = new SurfaceTexture(123); + mST = new GLConsumer(123); mSTC = new SurfaceTextureClient(mST->getBufferQueue()); mANW = mSTC; @@ -102,7 +102,7 @@ protected: return sDefaultConfigAttribs; } - sp mST; + sp mST; sp mSTC; sp mANW; @@ -112,7 +112,7 @@ protected: }; TEST_F(SurfaceTextureClientTest, GetISurfaceTextureIsNotNull) { - sp ist(mSTC->getISurfaceTexture()); + sp ist(mSTC->getISurfaceTexture()); ASSERT_TRUE(ist != NULL); } @@ -250,7 +250,7 @@ TEST_F(SurfaceTextureClientTest, BufferGeometrySizeCanBeChangedWithoutFormat) { } TEST_F(SurfaceTextureClientTest, SurfaceTextureSetDefaultSize) { - sp st(mST); + sp st(mST); ANativeWindowBuffer* buf; EXPECT_EQ(OK, st->setDefaultBufferSize(16, 8)); ASSERT_EQ(OK, native_window_dequeue_buffer_and_wait(mANW.get(), &buf)); @@ -464,7 +464,7 @@ TEST_F(SurfaceTextureClientTest, SetCropCropsCrop) { // from the SurfaceTexture class. TEST_F(SurfaceTextureClientTest, DISABLED_SurfaceTextureSyncModeWaitRetire) { class MyThread : public Thread { - sp mST; + sp mST; EGLContext ctx; EGLSurface sur; EGLDisplay dpy; @@ -480,7 +480,7 @@ TEST_F(SurfaceTextureClientTest, DISABLED_SurfaceTextureSyncModeWaitRetire) { return false; } public: - MyThread(const sp& mST) + MyThread(const sp& mST) : mST(mST), mBufferRetired(false) { ctx = eglGetCurrentContext(); sur = eglGetCurrentSurface(EGL_DRAW); @@ -685,7 +685,7 @@ protected: ASSERT_NE(EGL_NO_CONTEXT, mEglContext); for (int i = 0; i < NUM_SURFACE_TEXTURES; i++) { - sp st(new SurfaceTexture(i)); + sp st(new GLConsumer(i)); sp stc(new SurfaceTextureClient(st->getBufferQueue())); mEglSurfaces[i] = eglCreateWindowSurface(mEglDisplay, myConfig, static_cast(stc.get()), NULL); diff --git a/libs/gui/tests/SurfaceTexture_test.cpp b/libs/gui/tests/SurfaceTexture_test.cpp index 58976adba..b6020ca2a 100644 --- a/libs/gui/tests/SurfaceTexture_test.cpp +++ b/libs/gui/tests/SurfaceTexture_test.cpp @@ -18,7 +18,7 @@ //#define LOG_NDEBUG 0 #include -#include +#include #include #include #include @@ -384,7 +384,7 @@ protected: virtual void SetUp() { GLTest::SetUp(); - mST = new SurfaceTexture(TEX_ID); + mST = new GLConsumer(TEX_ID); mSTC = new SurfaceTextureClient(mST->getBufferQueue()); mANW = mSTC; mTextureRenderer = new TextureRenderer(TEX_ID, mST); @@ -406,7 +406,7 @@ protected: class TextureRenderer: public RefBase { public: - TextureRenderer(GLuint texName, const sp& st): + TextureRenderer(GLuint texName, const sp& st): mTexName(texName), mST(st) { } @@ -447,7 +447,7 @@ protected: ASSERT_NE(-1, mTexMatrixHandle); } - // drawTexture draws the SurfaceTexture over the entire GL viewport. + // drawTexture draws the GLConsumer over the entire GL viewport. void drawTexture() { static const GLfloat triangleVertices[] = { -1.0f, 1.0f, @@ -494,14 +494,14 @@ protected: } GLuint mTexName; - sp mST; + sp mST; GLuint mPgm; GLint mPositionHandle; GLint mTexSamplerHandle; GLint mTexMatrixHandle; }; - class FrameWaiter : public SurfaceTexture::FrameAvailableListener { + class FrameWaiter : public GLConsumer::FrameAvailableListener { public: FrameWaiter(): mPendingFrames(0) { @@ -526,7 +526,7 @@ protected: Condition mCondition; }; - // Note that SurfaceTexture will lose the notifications + // Note that GLConsumer will lose the notifications // onBuffersReleased and onFrameAvailable as there is currently // no way to forward the events. This DisconnectWaiter will not let the // disconnect finish until finishDisconnect() is called. It will @@ -575,7 +575,7 @@ protected: Condition mFrameCondition; }; - sp mST; + sp mST; sp mSTC; sp mANW; sp mTextureRenderer; @@ -1070,7 +1070,7 @@ TEST_F(SurfaceTextureGLTest, TexturingFromCpuFilledRGBABufferPow2) { EXPECT_TRUE(checkPixel( 3, 52, 35, 231, 35, 35)); } -// Tests if SurfaceTexture and BufferQueue are robust enough +// Tests if GLConsumer and BufferQueue are robust enough // to handle a special case where updateTexImage is called // in the middle of disconnect. This ordering is enforced // by blocking in the disconnect callback. @@ -1123,12 +1123,12 @@ TEST_F(SurfaceTextureGLTest, DisconnectStressTest) { sp pt(new ProducerThread(mANW)); pt->run(); - // eat a frame so SurfaceTexture will own an at least one slot + // eat a frame so GLConsumer will own an at least one slot dw->waitForFrame(); EXPECT_EQ(OK,mST->updateTexImage()); dw->waitForFrame(); - // Could fail here as SurfaceTexture thinks it still owns the slot + // Could fail here as GLConsumer thinks it still owns the slot // but bufferQueue has released all slots EXPECT_EQ(OK,mST->updateTexImage()); @@ -1136,7 +1136,7 @@ TEST_F(SurfaceTextureGLTest, DisconnectStressTest) { } -// This test ensures that the SurfaceTexture clears the mCurrentTexture +// This test ensures that the GLConsumer clears the mCurrentTexture // when it is disconnected and reconnected. Otherwise it will // attempt to release a buffer that it does not owned TEST_F(SurfaceTextureGLTest, DisconnectClearsCurrentTexture) { @@ -1581,7 +1581,7 @@ TEST_F(SurfaceTextureGLToGLTest, EglDestroySurfaceUnrefsBuffers) { // This test should have the only reference to buffer 0. EXPECT_EQ(1, buffers[0]->getStrongCount()); - // The SurfaceTexture should hold a single reference to buffer 1 in its + // The GLConsumer should hold a single reference to buffer 1 in its // mCurrentBuffer member. All of the references in the slots should have // been released. EXPECT_EQ(2, buffers[1]->getStrongCount()); @@ -1615,7 +1615,7 @@ TEST_F(SurfaceTextureGLToGLTest, EglDestroySurfaceAfterAbandonUnrefsBuffers) { buffers[i] = mST->getCurrentBuffer(); } - // Abandon the SurfaceTexture, releasing the ref that the SurfaceTexture has + // Abandon the GLConsumer, releasing the ref that the GLConsumer has // on buffers[2]. mST->abandon(); @@ -1847,7 +1847,7 @@ TEST_F(SurfaceTextureGLToGLTest, TexturingFromPreRotatedGLFilledBuffer) { * This test fixture is for testing GL -> GL texture streaming from one thread * to another. It contains functionality to create a producer thread that will * perform GL rendering to an ANativeWindow that feeds frames to a - * SurfaceTexture. Additionally it supports interlocking the producer and + * GLConsumer. Additionally it supports interlocking the producer and * consumer threads so that a specific sequence of calls can be * deterministically created by the test. * @@ -1914,13 +1914,13 @@ protected: // FrameCondition is a utility class for interlocking between the producer // and consumer threads. The FrameCondition object should be created and // destroyed in the consumer thread only. The consumer thread should set - // the FrameCondition as the FrameAvailableListener of the SurfaceTexture, + // the FrameCondition as the FrameAvailableListener of the GLConsumer, // and should call both waitForFrame and finishFrame once for each expected // frame. // // This interlocking relies on the fact that onFrameAvailable gets called - // synchronously from SurfaceTexture::queueBuffer. - class FrameCondition : public SurfaceTexture::FrameAvailableListener { + // synchronously from GLConsumer::queueBuffer. + class FrameCondition : public GLConsumer::FrameAvailableListener { public: FrameCondition(): mFrameAvailable(false), @@ -1951,7 +1951,7 @@ protected: ALOGV("-finishFrame"); } - // This should be called by SurfaceTexture on the producer thread. + // This should be called by GLConsumer on the producer thread. virtual void onFrameAvailable() { Mutex::Autolock lock(mMutex); ALOGV("+onFrameAvailable"); diff --git a/opengl/tests/EGLTest/EGL_test.cpp b/opengl/tests/EGLTest/EGL_test.cpp index d511cae5e..ec433fb08 100644 --- a/opengl/tests/EGLTest/EGL_test.cpp +++ b/opengl/tests/EGLTest/EGL_test.cpp @@ -104,7 +104,7 @@ TEST_F(EGLTest, EGLTerminateSucceedsWithRemainingObjects) { // Create a EGLSurface sp bq = new BufferQueue(); bq->consumerConnect(new DummyConsumer()); - sp mSTC = new SurfaceTextureClient(static_cast >( bq)); + sp mSTC = new SurfaceTextureClient(static_cast >( bq)); sp mANW = mSTC; EGLSurface eglSurface = eglCreateWindowSurface(mEglDisplay, config, diff --git a/opengl/tools/glgen/stubs/egl/EGL14cHeader.cpp b/opengl/tools/glgen/stubs/egl/EGL14cHeader.cpp index 7904ac76f..290d102df 100644 --- a/opengl/tools/glgen/stubs/egl/EGL14cHeader.cpp +++ b/opengl/tools/glgen/stubs/egl/EGL14cHeader.cpp @@ -1,4 +1,4 @@ -** +/* ** Copyright 2012, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include diff --git a/opengl/tools/glgen/stubs/egl/eglCreateWindowSurface.cpp b/opengl/tools/glgen/stubs/egl/eglCreateWindowSurface.cpp index 610cde52e..a3d000ac9 100644 --- a/opengl/tools/glgen/stubs/egl/eglCreateWindowSurface.cpp +++ b/opengl/tools/glgen/stubs/egl/eglCreateWindowSurface.cpp @@ -90,7 +90,7 @@ android_eglCreateWindowSurfaceTexture jint _remaining; EGLint *attrib_list = (EGLint *) 0; android::sp window; - android::sp surfaceTexture; + android::sp glConsumer; if (!attrib_list_ref) { _exception = 1; @@ -111,8 +111,8 @@ not_valid_surface: _exceptionMessage = "Make sure the SurfaceView or associated SurfaceHolder has a valid Surface"; goto exit; } - surfaceTexture = android::SurfaceTexture_getSurfaceTexture(_env, win); - window = new android::SurfaceTextureClient(surfaceTexture); + glConsumer = android::SurfaceTexture_getSurfaceTexture(_env, win); + window = new android::SurfaceTextureClient(glConsumer); if (window == NULL) goto not_valid_surface; diff --git a/services/surfaceflinger/DisplayHardware/FramebufferSurface.h b/services/surfaceflinger/DisplayHardware/FramebufferSurface.h index 633634522..b61b7f509 100644 --- a/services/surfaceflinger/DisplayHardware/FramebufferSurface.h +++ b/services/surfaceflinger/DisplayHardware/FramebufferSurface.h @@ -46,7 +46,7 @@ public: // current buffer is no longer being read. This fence will be returned to // the producer when the current buffer is released by updateTexImage(). // Multiple fences can be set for a given buffer; they will be merged into - // a single union fence. The SurfaceTexture will close the file descriptor + // a single union fence. The GLConsumer will close the file descriptor // when finished with it. status_t setReleaseFenceFd(int fenceFd); diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp index a1d46d99f..8c2dadec9 100644 --- a/services/surfaceflinger/Layer.cpp +++ b/services/surfaceflinger/Layer.cpp @@ -127,8 +127,8 @@ sp Layer::createSurface() { class BSurface : public BnSurface, public LayerCleaner { wp mOwner; - virtual sp getSurfaceTexture() const { - sp res; + virtual sp getSurfaceTexture() const { + sp res; sp that( mOwner.promote() ); if (that != NULL) { res = that->mSurfaceFlingerConsumer->getBufferQueue(); diff --git a/services/surfaceflinger/LayerBase.cpp b/services/surfaceflinger/LayerBase.cpp index 9b03c747f..31ef94174 100644 --- a/services/surfaceflinger/LayerBase.cpp +++ b/services/surfaceflinger/LayerBase.cpp @@ -506,7 +506,7 @@ LayerBaseClient::~LayerBaseClient() sp LayerBaseClient::createSurface() { class BSurface : public BnSurface, public LayerCleaner { - virtual sp getSurfaceTexture() const { return 0; } + virtual sp getSurfaceTexture() const { return 0; } public: BSurface(const sp& flinger, const sp& layer) diff --git a/services/surfaceflinger/LayerBase.h b/services/surfaceflinger/LayerBase.h index 46713faae..7a9471e92 100644 --- a/services/surfaceflinger/LayerBase.h +++ b/services/surfaceflinger/LayerBase.h @@ -243,8 +243,8 @@ public: virtual void onPostComposition() { } /** - * Updates the SurfaceTexture's transform hint, for layers that have - * a SurfaceTexture. + * Updates the GLConsumer's transform hint, for layers that have + * a GLConsumer. */ virtual void updateTransformHint(const sp& hw) const { } diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index f65b82fb7..f0e57198f 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -503,7 +503,7 @@ status_t SurfaceFlinger::readyToRun() sp fbs = new FramebufferSurface(*mHwc, i); sp stc = new SurfaceTextureClient( - static_cast< sp >(fbs->getBufferQueue())); + static_cast< sp >(fbs->getBufferQueue())); sp hw = new DisplayDevice(this, type, isSecure, token, stc, fbs, mEGLConfig); if (i > DisplayDevice::DISPLAY_PRIMARY) { @@ -571,9 +571,9 @@ uint32_t SurfaceFlinger::getMaxViewportDims() const { // ---------------------------------------------------------------------------- bool SurfaceFlinger::authenticateSurfaceTexture( - const sp& surfaceTexture) const { + const sp& bufferProducer) const { Mutex::Autolock _l(mStateLock); - sp surfaceTextureBinder(surfaceTexture->asBinder()); + sp surfaceTextureBinder(bufferProducer->asBinder()); // Check the visible layer list for the ISurface const LayerVector& currentLayers = mCurrentState.layersSortedByZ; @@ -590,7 +590,7 @@ bool SurfaceFlinger::authenticateSurfaceTexture( } // Check the layers in the purgatory. This check is here so that if a - // SurfaceTexture gets destroyed before all the clients are done using it, + // GLConsumer gets destroyed before all the clients are done using it, // the error will not be reported as "surface XYZ is not authenticated", but // will instead fail later on when the client tries to use the surface, // which should be reported as "surface XYZ returned an -ENODEV". The @@ -1172,7 +1172,7 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags) // own rendering surface fbs = new FramebufferSurface(*mHwc, state.type); stc = new SurfaceTextureClient( - static_cast< sp >( + static_cast< sp >( fbs->getBufferQueue())); } else { if (state.surface != NULL) { diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index 1b549e421..65fea30e9 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -163,7 +163,7 @@ private: bool isMainDisplay() const { return type == DisplayDevice::DISPLAY_PRIMARY; } bool isVirtualDisplay() const { return type >= DisplayDevice::DISPLAY_VIRTUAL; } DisplayDevice::DisplayType type; - sp surface; + sp surface; uint32_t layerStack; Rect viewport; Rect frame; @@ -195,7 +195,7 @@ private: const Vector& displays, uint32_t flags); virtual void bootFinished(); virtual bool authenticateSurfaceTexture( - const sp& surface) const; + const sp& bufferProducer) const; virtual sp createDisplayEventConnection(); virtual status_t captureScreen(const sp& display, sp* heap, uint32_t* width, uint32_t* height, PixelFormat* format, diff --git a/services/surfaceflinger/SurfaceFlingerConsumer.cpp b/services/surfaceflinger/SurfaceFlingerConsumer.cpp index a316896be..dc9089e3d 100644 --- a/services/surfaceflinger/SurfaceFlingerConsumer.cpp +++ b/services/surfaceflinger/SurfaceFlingerConsumer.cpp @@ -33,7 +33,7 @@ status_t SurfaceFlingerConsumer::updateTexImage(BufferRejecter* rejecter) Mutex::Autolock lock(mMutex); if (mAbandoned) { - ALOGE("updateTexImage: SurfaceTexture is abandoned!"); + ALOGE("updateTexImage: GLConsumer is abandoned!"); return NO_INIT; } diff --git a/services/surfaceflinger/SurfaceFlingerConsumer.h b/services/surfaceflinger/SurfaceFlingerConsumer.h index 308a2880f..22eec81f7 100644 --- a/services/surfaceflinger/SurfaceFlingerConsumer.h +++ b/services/surfaceflinger/SurfaceFlingerConsumer.h @@ -17,20 +17,20 @@ #ifndef ANDROID_SURFACEFLINGERCONSUMER_H #define ANDROID_SURFACEFLINGERCONSUMER_H -#include +#include namespace android { // ---------------------------------------------------------------------------- /* - * This is a thin wrapper around SurfaceTexture. + * This is a thin wrapper around GLConsumer. */ -class SurfaceFlingerConsumer : public SurfaceTexture { +class SurfaceFlingerConsumer : public GLConsumer { public: SurfaceFlingerConsumer(GLuint tex, bool allowSynchronousMode = true, GLenum texTarget = GL_TEXTURE_EXTERNAL_OES, bool useFenceSync = true, const sp &bufferQueue = 0) - : SurfaceTexture(tex, allowSynchronousMode, texTarget, useFenceSync, + : GLConsumer(tex, allowSynchronousMode, texTarget, useFenceSync, bufferQueue) {} @@ -44,12 +44,12 @@ public: }; // This version of updateTexImage() takes a functor that may be used to - // reject the newly acquired buffer. Unlike the SurfaceTexture version, + // reject the newly acquired buffer. Unlike the GLConsumer version, // this does not guarantee that the buffer has been bound to the GL // texture. status_t updateTexImage(BufferRejecter* rejecter); - // See SurfaceTexture::bindTextureImageLocked(). + // See GLConsumer::bindTextureImageLocked(). status_t bindTextureImage(); }; diff --git a/services/surfaceflinger/SurfaceTextureLayer.h b/services/surfaceflinger/SurfaceTextureLayer.h index e892ea0da..8baa8d268 100644 --- a/services/surfaceflinger/SurfaceTextureLayer.h +++ b/services/surfaceflinger/SurfaceTextureLayer.h @@ -29,8 +29,6 @@ namespace android { class Layer; -// SurfaceTextureLayer is now a BufferQueue since SurfaceTexture has been -// refactored class SurfaceTextureLayer : public BufferQueue { public: