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
This commit is contained in:
Andy McFadden 2012-12-18 09:49:45 -08:00
parent f7baee731e
commit 2adaf04fab
39 changed files with 291 additions and 292 deletions

View File

@ -82,7 +82,7 @@ class BufferItemConsumer: public ConsumerBase
status_t releaseBuffer(const BufferItem &item,
const sp<Fence>& releaseFence = Fence::NO_FENCE);
sp<ISurfaceTexture> getProducerInterface() const { return getBufferQueue(); }
sp<IGraphicBufferProducer> getProducerInterface() const { return getBufferQueue(); }
};

View File

@ -21,7 +21,7 @@
#include <EGL/eglext.h>
#include <gui/IGraphicBufferAlloc.h>
#include <gui/ISurfaceTexture.h>
#include <gui/IGraphicBufferProducer.h>
#include <ui/Fence.h>
#include <ui/GraphicBuffer.h>
@ -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.

View File

@ -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.

View File

@ -82,7 +82,7 @@ class CpuConsumer: public ConsumerBase
// lockNextBuffer.
status_t unlockBuffer(const LockedBuffer &nativeBuffer);
sp<ISurfaceTexture> getProducerInterface() const { return getBufferQueue(); }
sp<IGraphicBufferProducer> getProducerInterface() const { return getBufferQueue(); }
private:
// Maximum number of buffers that can be locked at a time

View File

@ -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();

View File

@ -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 <EGL/egl.h>
#include <EGL/eglext.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <gui/ISurfaceTexture.h>
#include <gui/IGraphicBufferProducer.h>
#include <gui/BufferQueue.h>
#include <gui/ConsumerBase.h>
@ -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> &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<BufferQueue> 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

View File

@ -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 <stdint.h>
#include <sys/types.h>
@ -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<GraphicBuffer>* 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<ISurfaceTexture>
class BnGraphicBufferProducer : public BnInterface<IGraphicBufferProducer>
{
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

View File

@ -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<ISurfaceTexture> getSurfaceTexture() const = 0;
virtual sp<IGraphicBufferProducer> getSurfaceTexture() const = 0;
};
// ----------------------------------------------------------------------------

View File

@ -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<ISurfaceTexture>& surface) const = 0;
const sp<IGraphicBufferProducer>& surface) const = 0;
/* Capture the specified screen. requires READ_FRAME_BUFFER permission
* This function will fail if there is a secure window on screen.

View File

@ -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<ISurfaceTexture>& st);
explicit Surface(const sp<IGraphicBufferProducer>& bp);
static status_t writeToParcel(const sp<Surface>& control, Parcel* parcel);
@ -137,7 +137,7 @@ public:
bool isValid();
uint32_t getIdentity() const { return mIdentity; }
sp<ISurfaceTexture> getSurfaceTexture();
sp<IGraphicBufferProducer> 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<ISurfaceTexture>& surfaceTexture);
void init(const sp<IGraphicBufferProducer>& bufferProducer);
static void cleanCachedSurfacesLocked();

View File

@ -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<IBinder>& token,
const sp<ISurfaceTexture>& surface);
const sp<IGraphicBufferProducer>& bufferProducer);
static void setDisplayLayerStack(const sp<IBinder>& token,
uint32_t layerStack);

View File

@ -17,8 +17,8 @@
#ifndef ANDROID_GUI_SURFACETEXTURECLIENT_H
#define ANDROID_GUI_SURFACETEXTURECLIENT_H
#include <gui/ISurfaceTexture.h>
#include <gui/SurfaceTexture.h>
#include <gui/IGraphicBufferProducer.h>
#include <gui/GLConsumer.h>
#include <gui/BufferQueue.h>
#include <ui/ANativeObjectBase.h>
@ -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<ISurfaceTexture>& surfaceTexture);
SurfaceTextureClient(const sp<IGraphicBufferProducer>& bufferProducer);
sp<ISurfaceTexture> getISurfaceTexture() const;
sp<IGraphicBufferProducer> getISurfaceTexture() const; // TODO: rename
protected:
SurfaceTextureClient();
virtual ~SurfaceTextureClient();
void setISurfaceTexture(const sp<ISurfaceTexture>& surfaceTexture);
void setISurfaceTexture(const sp<IGraphicBufferProducer>& 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<ISurfaceTexture> mSurfaceTexture;
// TODO: rename to mBufferProducer
sp<IGraphicBufferProducer> 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;

View File

@ -114,7 +114,7 @@ struct DisplayState {
uint32_t what;
sp<IBinder> token;
sp<ISurfaceTexture> surface;
sp<IGraphicBufferProducer> surface;
uint32_t layerStack;
uint32_t orientation;
Rect viewport;

View File

@ -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 := \

View File

@ -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<GraphicBuffer>* 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<Fence>& 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<Fence>& 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<Fence>& 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<Fence>& 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> graphicBuffer(
mGraphicBufferAlloc->createGraphicBuffer(
@ -415,7 +415,7 @@ status_t BufferQueue::dequeueBuffer(int *outBuf, sp<Fence>& 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();

View File

@ -69,7 +69,7 @@ ConsumerBase::ConsumerBase(const sp<BufferQueue>& 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);

View File

@ -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 <gui/IGraphicBufferAlloc.h>
#include <gui/ISurfaceComposer.h>
#include <gui/SurfaceComposerClient.h>
#include <gui/SurfaceTexture.h>
#include <gui/GLConsumer.h>
#include <private/gui/ComposerService.h>
@ -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> &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> 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>& graphicBuffer) {
EGLClientBuffer cbuf = (EGLClientBuffer)graphicBuffer->getNativeBuffer();
EGLint attrs[] = {
@ -747,12 +747,12 @@ EGLImageKHR SurfaceTexture::createImage(EGLDisplay dpy,
return image;
}
sp<GraphicBuffer> SurfaceTexture::getCurrentBuffer() const {
sp<GraphicBuffer> 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<Fence> SurfaceTexture::getCurrentFence() const {
sp<Fence> 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,

View File

@ -25,7 +25,7 @@
#include <binder/Parcel.h>
#include <binder/IInterface.h>
#include <gui/ISurfaceTexture.h>
#include <gui/IGraphicBufferProducer.h>
namespace android {
// ----------------------------------------------------------------------------
@ -43,17 +43,17 @@ enum {
};
class BpSurfaceTexture : public BpInterface<ISurfaceTexture>
class BpGraphicBufferProducer : public BpInterface<IGraphicBufferProducer>
{
public:
BpSurfaceTexture(const sp<IBinder>& impl)
: BpInterface<ISurfaceTexture>(impl)
BpGraphicBufferProducer(const sp<IBinder>& impl)
: BpInterface<IGraphicBufferProducer>(impl)
{
}
virtual status_t requestBuffer(int bufferIdx, sp<GraphicBuffer>* 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>& 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> 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<GraphicBuffer> 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> 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<QueueBufferOutput *>(
@ -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>& 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;

View File

@ -23,7 +23,7 @@
#include <binder/Parcel.h>
#include <gui/ISurface.h>
#include <gui/ISurfaceTexture.h>
#include <gui/IGraphicBufferProducer.h>
namespace android {
@ -37,11 +37,11 @@ public:
{
}
virtual sp<ISurfaceTexture> getSurfaceTexture() const {
virtual sp<IGraphicBufferProducer> getSurfaceTexture() const {
Parcel data, reply;
data.writeInterfaceToken(ISurface::getInterfaceDescriptor());
remote()->transact(GET_SURFACE_TEXTURE, data, &reply);
return interface_cast<ISurfaceTexture>(reply.readStrongBinder());
return interface_cast<IGraphicBufferProducer>(reply.readStrongBinder());
}
};

View File

@ -28,7 +28,7 @@
#include <gui/BitTube.h>
#include <gui/IDisplayEventConnection.h>
#include <gui/ISurfaceComposer.h>
#include <gui/ISurfaceTexture.h>
#include <gui/IGraphicBufferProducer.h>
#include <private/gui/LayerState.h>
@ -124,7 +124,7 @@ public:
}
virtual bool authenticateSurfaceTexture(
const sp<ISurfaceTexture>& surfaceTexture) const
const sp<IGraphicBufferProducer>& 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<ISurfaceTexture> surfaceTexture =
interface_cast<ISurfaceTexture>(data.readStrongBinder());
int32_t result = authenticateSurfaceTexture(surfaceTexture) ? 1 : 0;
sp<IGraphicBufferProducer> bufferProducer =
interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0;
reply->writeInt32(result);
} break;
case CREATE_DISPLAY_EVENT_CONNECTION: {

View File

@ -17,7 +17,7 @@
#include <utils/Errors.h>
#include <binder/Parcel.h>
#include <gui/ISurfaceComposerClient.h>
#include <gui/ISurfaceTexture.h>
#include <gui/IGraphicBufferProducer.h>
#include <private/gui/LayerState.h>
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<ISurfaceTexture>(input.readStrongBinder());
surface = interface_cast<IGraphicBufferProducer>(input.readStrongBinder());
what = input.readInt32();
layerStack = input.readInt32();
orientation = input.readInt32();

View File

@ -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<SurfaceControl>& surface)
mSurface(surface->mSurface),
mIdentity(surface->mIdentity)
{
sp<ISurfaceTexture> st;
sp<IGraphicBufferProducer> st;
if (mSurface != NULL) {
st = mSurface->getSurfaceTexture();
}
@ -217,9 +217,9 @@ Surface::Surface(const Parcel& parcel, const sp<IBinder>& ref)
{
mSurface = interface_cast<ISurface>(ref);
sp<IBinder> st_binder(parcel.readStrongBinder());
sp<ISurfaceTexture> st;
sp<IGraphicBufferProducer> st;
if (st_binder != NULL) {
st = interface_cast<ISurfaceTexture>(st_binder);
st = interface_cast<IGraphicBufferProducer>(st_binder);
} else if (mSurface != NULL) {
st = mSurface->getSurfaceTexture();
}
@ -228,7 +228,7 @@ Surface::Surface(const Parcel& parcel, const sp<IBinder>& ref)
init(st);
}
Surface::Surface(const sp<ISurfaceTexture>& st)
Surface::Surface(const sp<IGraphicBufferProducer>& st)
: SurfaceTextureClient(),
mSurface(NULL),
mIdentity(0)
@ -240,7 +240,7 @@ status_t Surface::writeToParcel(
const sp<Surface>& surface, Parcel* parcel)
{
sp<ISurface> sur;
sp<ISurfaceTexture> st;
sp<IGraphicBufferProducer> 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> 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<ISurfaceTexture>& surfaceTexture)
void Surface::init(const sp<IGraphicBufferProducer>& 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<ISurfaceTexture> Surface::getSurfaceTexture() {
sp<IGraphicBufferProducer> Surface::getSurfaceTexture() {
return getISurfaceTexture();
}

View File

@ -157,7 +157,8 @@ public:
status_t setLayerStack(const sp<SurfaceComposerClient>& client,
SurfaceID id, uint32_t layerStack);
void setDisplaySurface(const sp<IBinder>& token, const sp<ISurfaceTexture>& surface);
void setDisplaySurface(const sp<IBinder>& token,
const sp<IGraphicBufferProducer>& bufferProducer);
void setDisplayLayerStack(const sp<IBinder>& token, uint32_t layerStack);
void setDisplayProjection(const sp<IBinder>& token,
uint32_t orientation,
@ -386,10 +387,10 @@ DisplayState& Composer::getDisplayStateLocked(const sp<IBinder>& token) {
}
void Composer::setDisplaySurface(const sp<IBinder>& token,
const sp<ISurfaceTexture>& surface) {
const sp<IGraphicBufferProducer>& 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<IBinder>& token,
const sp<ISurfaceTexture>& surface) {
Composer::getInstance().setDisplaySurface(token, surface);
const sp<IGraphicBufferProducer>& bufferProducer) {
Composer::getInstance().setDisplaySurface(token, bufferProducer);
}
void SurfaceComposerClient::setDisplayLayerStack(const sp<IBinder>& token,

View File

@ -27,7 +27,7 @@
#include <gui/ISurfaceComposer.h>
#include <gui/SurfaceComposerClient.h>
#include <gui/SurfaceTexture.h>
#include <gui/GLConsumer.h>
#include <gui/SurfaceTextureClient.h>
#include <private/gui/ComposerService.h>
@ -35,10 +35,10 @@
namespace android {
SurfaceTextureClient::SurfaceTextureClient(
const sp<ISurfaceTexture>& surfaceTexture)
const sp<IGraphicBufferProducer>& bufferProducer)
{
SurfaceTextureClient::init();
SurfaceTextureClient::setISurfaceTexture(surfaceTexture);
SurfaceTextureClient::setISurfaceTexture(bufferProducer);
}
SurfaceTextureClient::SurfaceTextureClient() {
@ -86,12 +86,12 @@ void SurfaceTextureClient::init() {
}
void SurfaceTextureClient::setISurfaceTexture(
const sp<ISurfaceTexture>& surfaceTexture)
const sp<IGraphicBufferProducer>& bufferProducer)
{
mSurfaceTexture = surfaceTexture;
mSurfaceTexture = bufferProducer;
}
sp<ISurfaceTexture> SurfaceTextureClient::getISurfaceTexture() const {
sp<IGraphicBufferProducer> 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<GraphicBuffer>& 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> 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) {

View File

@ -63,19 +63,19 @@ struct DummyConsumer : public BufferQueue::ConsumerListener {
TEST_F(BufferQueueTest, AcquireBuffer_ExceedsMaxAcquireCount_Fails) {
sp<DummyConsumer> 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> fence;
sp<GraphicBuffer> 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));

View File

@ -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<SurfaceTexture> mST;
sp<GLConsumer> mST;
sp<SurfaceTextureClient> mSTC;
sp<ANativeWindow> mANW;
@ -112,7 +112,7 @@ protected:
};
TEST_F(SurfaceTextureClientTest, GetISurfaceTextureIsNotNull) {
sp<ISurfaceTexture> ist(mSTC->getISurfaceTexture());
sp<IGraphicBufferProducer> ist(mSTC->getISurfaceTexture());
ASSERT_TRUE(ist != NULL);
}
@ -250,7 +250,7 @@ TEST_F(SurfaceTextureClientTest, BufferGeometrySizeCanBeChangedWithoutFormat) {
}
TEST_F(SurfaceTextureClientTest, SurfaceTextureSetDefaultSize) {
sp<SurfaceTexture> st(mST);
sp<GLConsumer> 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<SurfaceTexture> mST;
sp<GLConsumer> mST;
EGLContext ctx;
EGLSurface sur;
EGLDisplay dpy;
@ -480,7 +480,7 @@ TEST_F(SurfaceTextureClientTest, DISABLED_SurfaceTextureSyncModeWaitRetire) {
return false;
}
public:
MyThread(const sp<SurfaceTexture>& mST)
MyThread(const sp<GLConsumer>& 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<SurfaceTexture> st(new SurfaceTexture(i));
sp<GLConsumer> st(new GLConsumer(i));
sp<SurfaceTextureClient> stc(new SurfaceTextureClient(st->getBufferQueue()));
mEglSurfaces[i] = eglCreateWindowSurface(mEglDisplay, myConfig,
static_cast<ANativeWindow*>(stc.get()), NULL);

View File

@ -18,7 +18,7 @@
//#define LOG_NDEBUG 0
#include <gtest/gtest.h>
#include <gui/SurfaceTexture.h>
#include <gui/GLConsumer.h>
#include <gui/SurfaceTextureClient.h>
#include <ui/GraphicBuffer.h>
#include <utils/String8.h>
@ -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<SurfaceTexture>& st):
TextureRenderer(GLuint texName, const sp<GLConsumer>& 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<SurfaceTexture> mST;
sp<GLConsumer> 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<SurfaceTexture> mST;
sp<GLConsumer> mST;
sp<SurfaceTextureClient> mSTC;
sp<ANativeWindow> mANW;
sp<TextureRenderer> 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<Thread> 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");

View File

@ -104,7 +104,7 @@ TEST_F(EGLTest, EGLTerminateSucceedsWithRemainingObjects) {
// Create a EGLSurface
sp<BufferQueue> bq = new BufferQueue();
bq->consumerConnect(new DummyConsumer());
sp<SurfaceTextureClient> mSTC = new SurfaceTextureClient(static_cast<sp<ISurfaceTexture> >( bq));
sp<SurfaceTextureClient> mSTC = new SurfaceTextureClient(static_cast<sp<IGraphicBufferProducer> >( bq));
sp<ANativeWindow> mANW = mSTC;
EGLSurface eglSurface = eglCreateWindowSurface(mEglDisplay, config,

View File

@ -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 <EGL/egl.h>
#include <gui/Surface.h>
#include <gui/SurfaceTexture.h>
#include <gui/GLConsumer.h>
#include <gui/SurfaceTextureClient.h>
#include <ui/ANativeObjectBase.h>

View File

@ -90,7 +90,7 @@ android_eglCreateWindowSurfaceTexture
jint _remaining;
EGLint *attrib_list = (EGLint *) 0;
android::sp<ANativeWindow> window;
android::sp<android::SurfaceTexture> surfaceTexture;
android::sp<android::GLConsumer> 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;

View File

@ -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);

View File

@ -127,8 +127,8 @@ sp<ISurface> Layer::createSurface()
{
class BSurface : public BnSurface, public LayerCleaner {
wp<const Layer> mOwner;
virtual sp<ISurfaceTexture> getSurfaceTexture() const {
sp<ISurfaceTexture> res;
virtual sp<IGraphicBufferProducer> getSurfaceTexture() const {
sp<IGraphicBufferProducer> res;
sp<const Layer> that( mOwner.promote() );
if (that != NULL) {
res = that->mSurfaceFlingerConsumer->getBufferQueue();

View File

@ -506,7 +506,7 @@ LayerBaseClient::~LayerBaseClient()
sp<ISurface> LayerBaseClient::createSurface()
{
class BSurface : public BnSurface, public LayerCleaner {
virtual sp<ISurfaceTexture> getSurfaceTexture() const { return 0; }
virtual sp<IGraphicBufferProducer> getSurfaceTexture() const { return 0; }
public:
BSurface(const sp<SurfaceFlinger>& flinger,
const sp<LayerBaseClient>& layer)

View File

@ -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<const DisplayDevice>& hw) const { }

View File

@ -503,7 +503,7 @@ status_t SurfaceFlinger::readyToRun()
sp<FramebufferSurface> fbs = new FramebufferSurface(*mHwc, i);
sp<SurfaceTextureClient> stc = new SurfaceTextureClient(
static_cast< sp<ISurfaceTexture> >(fbs->getBufferQueue()));
static_cast< sp<IGraphicBufferProducer> >(fbs->getBufferQueue()));
sp<DisplayDevice> 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<ISurfaceTexture>& surfaceTexture) const {
const sp<IGraphicBufferProducer>& bufferProducer) const {
Mutex::Autolock _l(mStateLock);
sp<IBinder> surfaceTextureBinder(surfaceTexture->asBinder());
sp<IBinder> 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<ISurfaceTexture> >(
static_cast< sp<IGraphicBufferProducer> >(
fbs->getBufferQueue()));
} else {
if (state.surface != NULL) {

View File

@ -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<ISurfaceTexture> surface;
sp<IGraphicBufferProducer> surface;
uint32_t layerStack;
Rect viewport;
Rect frame;
@ -195,7 +195,7 @@ private:
const Vector<DisplayState>& displays, uint32_t flags);
virtual void bootFinished();
virtual bool authenticateSurfaceTexture(
const sp<ISurfaceTexture>& surface) const;
const sp<IGraphicBufferProducer>& bufferProducer) const;
virtual sp<IDisplayEventConnection> createDisplayEventConnection();
virtual status_t captureScreen(const sp<IBinder>& display, sp<IMemoryHeap>* heap,
uint32_t* width, uint32_t* height, PixelFormat* format,

View File

@ -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;
}

View File

@ -17,20 +17,20 @@
#ifndef ANDROID_SURFACEFLINGERCONSUMER_H
#define ANDROID_SURFACEFLINGERCONSUMER_H
#include <gui/SurfaceTexture.h>
#include <gui/GLConsumer.h>
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> &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();
};

View File

@ -29,8 +29,6 @@ namespace android {
class Layer;
// SurfaceTextureLayer is now a BufferQueue since SurfaceTexture has been
// refactored
class SurfaceTextureLayer : public BufferQueue
{
public: