All consumers now take an IGraphicBufferConsumer instead of a BufferQueue
this means they only have access to the consumer end of the interface. we had a lot of code that assumed consumers where holding a BufferQueue (i.e.: both ends), so most of this change is untangling in fix that Bug: 9265647 Change-Id: Ic2e2596ee14c7535f51bf26d9a897a0fc036d22c
This commit is contained in:
parent
687821c05b
commit
db89edc94b
@ -87,8 +87,6 @@ class BufferItemConsumer: public ConsumerBase
|
||||
status_t releaseBuffer(const BufferItem &item,
|
||||
const sp<Fence>& releaseFence = Fence::NO_FENCE);
|
||||
|
||||
sp<IGraphicBufferProducer> getProducerInterface() const { return getBufferQueue(); }
|
||||
|
||||
// setDefaultBufferSize is used to set the size of buffers returned by
|
||||
// requestBuffers when a with and height of zero is requested.
|
||||
status_t setDefaultBufferSize(uint32_t w, uint32_t h);
|
||||
|
@ -78,10 +78,6 @@ public:
|
||||
BufferQueue(const sp<IGraphicBufferAlloc>& allocator = NULL);
|
||||
virtual ~BufferQueue();
|
||||
|
||||
// dump our state in a String
|
||||
virtual void dump(String8& result) const;
|
||||
virtual void dump(String8& result, const char* prefix) const;
|
||||
|
||||
/*
|
||||
* IGraphicBufferProducer interface
|
||||
*/
|
||||
@ -302,6 +298,9 @@ public:
|
||||
// NATIVE_WINDOW_TRANSFORM_ROT_90. The default is 0 (no transform).
|
||||
virtual status_t setTransformHint(uint32_t hint);
|
||||
|
||||
// dump our state in a String
|
||||
virtual void dump(String8& result, const char* prefix) const;
|
||||
|
||||
|
||||
private:
|
||||
// freeBufferLocked frees the GraphicBuffer and sync resources for the
|
||||
|
@ -66,10 +66,6 @@ public:
|
||||
// log messages.
|
||||
void setName(const String8& name);
|
||||
|
||||
// getBufferQueue returns the BufferQueue object to which this
|
||||
// ConsumerBase is connected.
|
||||
sp<BufferQueue> getBufferQueue() const;
|
||||
|
||||
// dump writes the current state to a string. Child classes should add
|
||||
// their state to the dump by overriding the dumpLocked method, which is
|
||||
// called by these methods after locking the mutex.
|
||||
@ -85,12 +81,11 @@ private:
|
||||
void operator=(const ConsumerBase&);
|
||||
|
||||
protected:
|
||||
|
||||
// ConsumerBase constructs a new ConsumerBase object to consume image
|
||||
// buffers from the given BufferQueue.
|
||||
// buffers from the given IGraphicBufferConsumer.
|
||||
// The controlledByApp flag indicates that this consumer is under the application's
|
||||
// control.
|
||||
ConsumerBase(const sp<BufferQueue> &bufferQueue, bool controlledByApp = false);
|
||||
ConsumerBase(const sp<IGraphicBufferConsumer>& consumer, bool controlledByApp = false);
|
||||
|
||||
// onLastStrongRef gets called by RefBase just before the dtor of the most
|
||||
// derived class. It is used to clean up the buffers so that ConsumerBase
|
||||
@ -104,7 +99,7 @@ protected:
|
||||
// from the derived class.
|
||||
virtual void onLastStrongRef(const void* id);
|
||||
|
||||
// Implementation of the BufferQueue::ConsumerListener interface. These
|
||||
// Implementation of the IConsumerListener interface. These
|
||||
// calls are used to notify the ConsumerBase of asynchronous events in the
|
||||
// BufferQueue. These methods should not need to be overridden by derived
|
||||
// classes, but if they are overridden the ConsumerBase implementation
|
||||
@ -155,7 +150,7 @@ protected:
|
||||
// initialization that must take place the first time a buffer is assigned
|
||||
// to a slot. If it is overridden the derived class's implementation must
|
||||
// call ConsumerBase::acquireBufferLocked.
|
||||
virtual status_t acquireBufferLocked(BufferQueue::BufferItem *item,
|
||||
virtual status_t acquireBufferLocked(IGraphicBufferConsumer::BufferItem *item,
|
||||
nsecs_t presentWhen);
|
||||
|
||||
// releaseBufferLocked relinquishes control over a buffer, returning that
|
||||
@ -226,7 +221,7 @@ protected:
|
||||
|
||||
// The ConsumerBase has-a BufferQueue and is responsible for creating this object
|
||||
// if none is supplied
|
||||
sp<BufferQueue> mBufferQueue;
|
||||
sp<IGraphicBufferConsumer> mConsumer;
|
||||
|
||||
// mMutex is the mutex used to prevent concurrent access to the member
|
||||
// variables of ConsumerBase objects. It must be locked whenever the
|
||||
|
@ -66,7 +66,7 @@ class CpuConsumer : public ConsumerBase
|
||||
|
||||
// Create a new CPU consumer. The maxLockedBuffers parameter specifies
|
||||
// how many buffers can be locked for user access at the same time.
|
||||
CpuConsumer(const sp<BufferQueue>& bq,
|
||||
CpuConsumer(const sp<IGraphicBufferConsumer>& bq,
|
||||
uint32_t maxLockedBuffers, bool controlledByApp = false);
|
||||
|
||||
virtual ~CpuConsumer();
|
||||
@ -104,8 +104,6 @@ class CpuConsumer : public ConsumerBase
|
||||
// lockNextBuffer.
|
||||
status_t unlockBuffer(const LockedBuffer &nativeBuffer);
|
||||
|
||||
sp<IGraphicBufferProducer> getProducerInterface() const { return getBufferQueue(); }
|
||||
|
||||
private:
|
||||
// Maximum number of buffers that can be locked at a time
|
||||
uint32_t mMaxLockedBuffers;
|
||||
|
@ -32,10 +32,6 @@
|
||||
#include <utils/Vector.h>
|
||||
#include <utils/threads.h>
|
||||
|
||||
#define ANDROID_GRAPHICS_SURFACETEXTURE_JNI_ID "mSurfaceTexture"
|
||||
#define ANDROID_GRAPHICS_FRAMEAVAILABLELISTENER_JNI_ID \
|
||||
"mFrameAvailableListener"
|
||||
|
||||
namespace android {
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@ -85,7 +81,7 @@ public:
|
||||
// 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.
|
||||
GLConsumer(const sp<BufferQueue>& bq,
|
||||
GLConsumer(const sp<IGraphicBufferConsumer>& bq,
|
||||
GLuint tex, GLenum texTarget = GL_TEXTURE_EXTERNAL_OES,
|
||||
bool useFenceSync = true, bool isControlledByApp = false);
|
||||
|
||||
@ -194,12 +190,6 @@ public:
|
||||
status_t setConsumerUsageBits(uint32_t usage);
|
||||
status_t setTransformHint(uint32_t hint);
|
||||
|
||||
// getBufferQueue returns the BufferQueue object to which this
|
||||
// GLConsumer is connected.
|
||||
sp<BufferQueue> getBufferQueue() const {
|
||||
return mBufferQueue;
|
||||
}
|
||||
|
||||
// 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.
|
||||
|
@ -188,6 +188,9 @@ public:
|
||||
// NATIVE_WINDOW_TRANSFORM_ROT_90. The default is 0 (no transform).
|
||||
virtual status_t setTransformHint(uint32_t hint) = 0;
|
||||
|
||||
// dump state into a string
|
||||
virtual void dump(String8& result, const char* prefix) const = 0;
|
||||
|
||||
public:
|
||||
DECLARE_META_INTERFACE(GraphicBufferConsumer);
|
||||
};
|
||||
|
@ -165,6 +165,7 @@ public:
|
||||
|
||||
private:
|
||||
mutable sp<CpuConsumer> mCpuConsumer;
|
||||
mutable sp<BufferQueue> mBufferQueue;
|
||||
CpuConsumer::LockedBuffer mBuffer;
|
||||
bool mHaveBuffer;
|
||||
|
||||
|
@ -33,8 +33,8 @@ BufferItemConsumer::BufferItemConsumer(const sp<BufferQueue>& bq,
|
||||
uint32_t consumerUsage, int bufferCount, bool controlledByApp) :
|
||||
ConsumerBase(bq, controlledByApp)
|
||||
{
|
||||
mBufferQueue->setConsumerUsageBits(consumerUsage);
|
||||
mBufferQueue->setMaxAcquiredBufferCount(bufferCount);
|
||||
mConsumer->setConsumerUsageBits(consumerUsage);
|
||||
mConsumer->setMaxAcquiredBufferCount(bufferCount);
|
||||
}
|
||||
|
||||
BufferItemConsumer::~BufferItemConsumer() {
|
||||
@ -43,7 +43,7 @@ BufferItemConsumer::~BufferItemConsumer() {
|
||||
void BufferItemConsumer::setName(const String8& name) {
|
||||
Mutex::Autolock _l(mMutex);
|
||||
mName = name;
|
||||
mBufferQueue->setConsumerName(name);
|
||||
mConsumer->setConsumerName(name);
|
||||
}
|
||||
|
||||
status_t BufferItemConsumer::acquireBuffer(BufferItem *item,
|
||||
@ -95,12 +95,12 @@ status_t BufferItemConsumer::releaseBuffer(const BufferItem &item,
|
||||
|
||||
status_t BufferItemConsumer::setDefaultBufferSize(uint32_t w, uint32_t h) {
|
||||
Mutex::Autolock _l(mMutex);
|
||||
return mBufferQueue->setDefaultBufferSize(w, h);
|
||||
return mConsumer->setDefaultBufferSize(w, h);
|
||||
}
|
||||
|
||||
status_t BufferItemConsumer::setDefaultBufferFormat(uint32_t defaultFormat) {
|
||||
Mutex::Autolock _l(mMutex);
|
||||
return mBufferQueue->setDefaultBufferFormat(defaultFormat);
|
||||
return mConsumer->setDefaultBufferFormat(defaultFormat);
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
|
@ -720,10 +720,6 @@ status_t BufferQueue::disconnect(int api) {
|
||||
return err;
|
||||
}
|
||||
|
||||
void BufferQueue::dump(String8& result) const {
|
||||
BufferQueue::dump(result, "");
|
||||
}
|
||||
|
||||
void BufferQueue::dump(String8& result, const char* prefix) const {
|
||||
Mutex::Autolock _l(mMutex);
|
||||
|
||||
|
@ -51,9 +51,9 @@ static int32_t createProcessUniqueId() {
|
||||
return android_atomic_inc(&globalCounter);
|
||||
}
|
||||
|
||||
ConsumerBase::ConsumerBase(const sp<BufferQueue>& bufferQueue, bool controlledByApp) :
|
||||
ConsumerBase::ConsumerBase(const sp<IGraphicBufferConsumer>& bufferQueue, bool controlledByApp) :
|
||||
mAbandoned(false),
|
||||
mBufferQueue(bufferQueue) {
|
||||
mConsumer(bufferQueue) {
|
||||
// Choose a name using the PID and a process-unique ID.
|
||||
mName = String8::format("unnamed-%d-%d", getpid(), createProcessUniqueId());
|
||||
|
||||
@ -64,12 +64,12 @@ ConsumerBase::ConsumerBase(const sp<BufferQueue>& bufferQueue, bool controlledBy
|
||||
wp<ConsumerListener> listener = static_cast<ConsumerListener*>(this);
|
||||
sp<IConsumerListener> proxy = new BufferQueue::ProxyConsumerListener(listener);
|
||||
|
||||
status_t err = mBufferQueue->consumerConnect(proxy, controlledByApp);
|
||||
status_t err = mConsumer->consumerConnect(proxy, controlledByApp);
|
||||
if (err != NO_ERROR) {
|
||||
CB_LOGE("ConsumerBase: error connecting to BufferQueue: %s (%d)",
|
||||
strerror(-err), err);
|
||||
} else {
|
||||
mBufferQueue->setConsumerName(mName);
|
||||
mConsumer->setConsumerName(mName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,12 +96,6 @@ void ConsumerBase::freeBufferLocked(int slotIndex) {
|
||||
mSlots[slotIndex].mFrameNumber = 0;
|
||||
}
|
||||
|
||||
// Used for refactoring, should not be in final interface
|
||||
sp<BufferQueue> ConsumerBase::getBufferQueue() const {
|
||||
Mutex::Autolock lock(mMutex);
|
||||
return mBufferQueue;
|
||||
}
|
||||
|
||||
void ConsumerBase::onFrameAvailable() {
|
||||
CB_LOGV("onFrameAvailable");
|
||||
|
||||
@ -128,7 +122,7 @@ void ConsumerBase::onBuffersReleased() {
|
||||
}
|
||||
|
||||
uint32_t mask = 0;
|
||||
mBufferQueue->getReleasedBuffers(&mask);
|
||||
mConsumer->getReleasedBuffers(&mask);
|
||||
for (int i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) {
|
||||
if (mask & (1 << i)) {
|
||||
freeBufferLocked(i);
|
||||
@ -152,8 +146,8 @@ void ConsumerBase::abandonLocked() {
|
||||
freeBufferLocked(i);
|
||||
}
|
||||
// disconnect from the BufferQueue
|
||||
mBufferQueue->consumerDisconnect();
|
||||
mBufferQueue.clear();
|
||||
mConsumer->consumerDisconnect();
|
||||
mConsumer.clear();
|
||||
}
|
||||
|
||||
void ConsumerBase::setFrameAvailableListener(
|
||||
@ -176,13 +170,13 @@ void ConsumerBase::dumpLocked(String8& result, const char* prefix) const {
|
||||
result.appendFormat("%smAbandoned=%d\n", prefix, int(mAbandoned));
|
||||
|
||||
if (!mAbandoned) {
|
||||
mBufferQueue->dump(result, prefix);
|
||||
mConsumer->dump(result, prefix);
|
||||
}
|
||||
}
|
||||
|
||||
status_t ConsumerBase::acquireBufferLocked(BufferQueue::BufferItem *item,
|
||||
nsecs_t presentWhen) {
|
||||
status_t err = mBufferQueue->acquireBuffer(item, presentWhen);
|
||||
status_t err = mConsumer->acquireBuffer(item, presentWhen);
|
||||
if (err != NO_ERROR) {
|
||||
return err;
|
||||
}
|
||||
@ -247,7 +241,7 @@ status_t ConsumerBase::releaseBufferLocked(
|
||||
|
||||
CB_LOGV("releaseBufferLocked: slot=%d/%llu",
|
||||
slot, mSlots[slot].mFrameNumber);
|
||||
status_t err = mBufferQueue->releaseBuffer(slot, mSlots[slot].mFrameNumber,
|
||||
status_t err = mConsumer->releaseBuffer(slot, mSlots[slot].mFrameNumber,
|
||||
display, eglFence, mSlots[slot].mFence);
|
||||
if (err == BufferQueue::STALE_BUFFER_SLOT) {
|
||||
freeBufferLocked(slot);
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
namespace android {
|
||||
|
||||
CpuConsumer::CpuConsumer(const sp<BufferQueue>& bq,
|
||||
CpuConsumer::CpuConsumer(const sp<IGraphicBufferConsumer>& bq,
|
||||
uint32_t maxLockedBuffers, bool controlledByApp) :
|
||||
ConsumerBase(bq, controlledByApp),
|
||||
mMaxLockedBuffers(maxLockedBuffers),
|
||||
@ -39,8 +39,8 @@ CpuConsumer::CpuConsumer(const sp<BufferQueue>& bq,
|
||||
// Create tracking entries for locked buffers
|
||||
mAcquiredBuffers.insertAt(0, maxLockedBuffers);
|
||||
|
||||
mBufferQueue->setConsumerUsageBits(GRALLOC_USAGE_SW_READ_OFTEN);
|
||||
mBufferQueue->setMaxAcquiredBufferCount(maxLockedBuffers);
|
||||
mConsumer->setConsumerUsageBits(GRALLOC_USAGE_SW_READ_OFTEN);
|
||||
mConsumer->setMaxAcquiredBufferCount(maxLockedBuffers);
|
||||
}
|
||||
|
||||
CpuConsumer::~CpuConsumer() {
|
||||
@ -52,19 +52,19 @@ CpuConsumer::~CpuConsumer() {
|
||||
void CpuConsumer::setName(const String8& name) {
|
||||
Mutex::Autolock _l(mMutex);
|
||||
mName = name;
|
||||
mBufferQueue->setConsumerName(name);
|
||||
mConsumer->setConsumerName(name);
|
||||
}
|
||||
|
||||
status_t CpuConsumer::setDefaultBufferSize(uint32_t width, uint32_t height)
|
||||
{
|
||||
Mutex::Autolock _l(mMutex);
|
||||
return mBufferQueue->setDefaultBufferSize(width, height);
|
||||
return mConsumer->setDefaultBufferSize(width, height);
|
||||
}
|
||||
|
||||
status_t CpuConsumer::setDefaultBufferFormat(uint32_t defaultFormat)
|
||||
{
|
||||
Mutex::Autolock _l(mMutex);
|
||||
return mBufferQueue->setDefaultBufferFormat(defaultFormat);
|
||||
return mConsumer->setDefaultBufferFormat(defaultFormat);
|
||||
}
|
||||
|
||||
status_t CpuConsumer::lockNextBuffer(LockedBuffer *nativeBuffer) {
|
||||
|
@ -85,7 +85,7 @@ static float mtxRot90[16] = {
|
||||
static void mtxMul(float out[16], const float a[16], const float b[16]);
|
||||
|
||||
|
||||
GLConsumer::GLConsumer(const sp<BufferQueue>& bq, GLuint tex,
|
||||
GLConsumer::GLConsumer(const sp<IGraphicBufferConsumer>& bq, GLuint tex,
|
||||
GLenum texTarget, bool useFenceSync, bool isControlledByApp) :
|
||||
ConsumerBase(bq, isControlledByApp),
|
||||
mCurrentTransform(0),
|
||||
@ -108,12 +108,12 @@ GLConsumer::GLConsumer(const sp<BufferQueue>& bq, GLuint tex,
|
||||
memcpy(mCurrentTransformMatrix, mtxIdentity,
|
||||
sizeof(mCurrentTransformMatrix));
|
||||
|
||||
mBufferQueue->setConsumerUsageBits(DEFAULT_USAGE_FLAGS);
|
||||
mConsumer->setConsumerUsageBits(DEFAULT_USAGE_FLAGS);
|
||||
}
|
||||
|
||||
status_t GLConsumer::setDefaultMaxBufferCount(int bufferCount) {
|
||||
Mutex::Autolock lock(mMutex);
|
||||
return mBufferQueue->setDefaultMaxBufferCount(bufferCount);
|
||||
return mConsumer->setDefaultMaxBufferCount(bufferCount);
|
||||
}
|
||||
|
||||
|
||||
@ -122,7 +122,7 @@ status_t GLConsumer::setDefaultBufferSize(uint32_t w, uint32_t h)
|
||||
Mutex::Autolock lock(mMutex);
|
||||
mDefaultWidth = w;
|
||||
mDefaultHeight = h;
|
||||
return mBufferQueue->setDefaultBufferSize(w, h);
|
||||
return mConsumer->setDefaultBufferSize(w, h);
|
||||
}
|
||||
|
||||
status_t GLConsumer::updateTexImage() {
|
||||
@ -946,23 +946,23 @@ void GLConsumer::abandonLocked() {
|
||||
void GLConsumer::setName(const String8& name) {
|
||||
Mutex::Autolock _l(mMutex);
|
||||
mName = name;
|
||||
mBufferQueue->setConsumerName(name);
|
||||
mConsumer->setConsumerName(name);
|
||||
}
|
||||
|
||||
status_t GLConsumer::setDefaultBufferFormat(uint32_t defaultFormat) {
|
||||
Mutex::Autolock lock(mMutex);
|
||||
return mBufferQueue->setDefaultBufferFormat(defaultFormat);
|
||||
return mConsumer->setDefaultBufferFormat(defaultFormat);
|
||||
}
|
||||
|
||||
status_t GLConsumer::setConsumerUsageBits(uint32_t usage) {
|
||||
Mutex::Autolock lock(mMutex);
|
||||
usage |= DEFAULT_USAGE_FLAGS;
|
||||
return mBufferQueue->setConsumerUsageBits(usage);
|
||||
return mConsumer->setConsumerUsageBits(usage);
|
||||
}
|
||||
|
||||
status_t GLConsumer::setTransformHint(uint32_t hint) {
|
||||
Mutex::Autolock lock(mMutex);
|
||||
return mBufferQueue->setTransformHint(hint);
|
||||
return mConsumer->setTransformHint(hint);
|
||||
}
|
||||
|
||||
void GLConsumer::dumpLocked(String8& result, const char* prefix) const
|
||||
|
@ -186,7 +186,8 @@ enum {
|
||||
SET_CONSUMER_NAME,
|
||||
SET_DEFAULT_BUFFER_FORMAT,
|
||||
SET_CONSUMER_USAGE_BITS,
|
||||
SET_TRANSFORM_HINT
|
||||
SET_TRANSFORM_HINT,
|
||||
DUMP,
|
||||
};
|
||||
|
||||
|
||||
@ -344,6 +345,15 @@ public:
|
||||
}
|
||||
return reply.readInt32();
|
||||
}
|
||||
|
||||
virtual void dump(String8& result, const char* prefix) const {
|
||||
Parcel data, reply;
|
||||
data.writeInterfaceToken(IGraphicBufferConsumer::getInterfaceDescriptor());
|
||||
data.writeString8(result);
|
||||
data.writeString8(String8(prefix ? prefix : ""));
|
||||
remote()->transact(DUMP, data, &reply);
|
||||
reply.readString8();
|
||||
}
|
||||
};
|
||||
|
||||
IMPLEMENT_META_INTERFACE(GraphicBufferConsumer, "android.gui.IGraphicBufferConsumer");
|
||||
@ -452,6 +462,14 @@ status_t BnGraphicBufferConsumer::onTransact(
|
||||
reply->writeInt32(result);
|
||||
return NO_ERROR;
|
||||
} break;
|
||||
case DUMP: {
|
||||
CHECK_INTERFACE(IGraphicBufferConsumer, data, reply);
|
||||
String8 result = data.readString8();
|
||||
String8 prefix = data.readString8();
|
||||
static_cast<IGraphicBufferConsumer*>(this)->dump(result, prefix);
|
||||
reply->writeString8(result);
|
||||
return NO_ERROR;
|
||||
}
|
||||
}
|
||||
return BBinder::onTransact(code, data, reply, flags);
|
||||
}
|
||||
|
@ -633,8 +633,8 @@ ScreenshotClient::~ScreenshotClient() {
|
||||
|
||||
sp<CpuConsumer> ScreenshotClient::getCpuConsumer() const {
|
||||
if (mCpuConsumer == NULL) {
|
||||
sp<BufferQueue> bq = new BufferQueue();
|
||||
mCpuConsumer = new CpuConsumer(bq, 1);
|
||||
mBufferQueue = new BufferQueue();
|
||||
mCpuConsumer = new CpuConsumer(mBufferQueue, 1);
|
||||
mCpuConsumer->setName(String8("ScreenshotClient"));
|
||||
}
|
||||
return mCpuConsumer;
|
||||
@ -653,7 +653,7 @@ status_t ScreenshotClient::update(const sp<IBinder>& display,
|
||||
mHaveBuffer = false;
|
||||
}
|
||||
|
||||
status_t err = s->captureScreen(display, cpuConsumer->getBufferQueue(),
|
||||
status_t err = s->captureScreen(display, mBufferQueue,
|
||||
reqWidth, reqHeight, minLayerZ, maxLayerZ, true);
|
||||
|
||||
if (err == NO_ERROR) {
|
||||
|
@ -70,7 +70,7 @@ protected:
|
||||
mCC = new CpuConsumer(bq, params.maxLockedBuffers);
|
||||
String8 name("CpuConsumer_Under_Test");
|
||||
mCC->setName(name);
|
||||
mSTC = new Surface(mCC->getProducerInterface());
|
||||
mSTC = new Surface(bq);
|
||||
mANW = mSTC;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ protected:
|
||||
|
||||
sp<BufferQueue> bq = new BufferQueue();
|
||||
mST = new GLConsumer(bq, 123);
|
||||
mSTC = new Surface(mST->getBufferQueue());
|
||||
mSTC = new Surface(bq);
|
||||
mANW = mSTC;
|
||||
|
||||
// We need a valid GL context so we can test updateTexImage()
|
||||
@ -710,7 +710,7 @@ protected:
|
||||
for (int i = 0; i < NUM_SURFACE_TEXTURES; i++) {
|
||||
sp<BufferQueue> bq = new BufferQueue();
|
||||
sp<GLConsumer> st(new GLConsumer(bq, i));
|
||||
sp<Surface> stc(new Surface(st->getBufferQueue()));
|
||||
sp<Surface> stc(new Surface(bq));
|
||||
mEglSurfaces[i] = eglCreateWindowSurface(mEglDisplay, myConfig,
|
||||
static_cast<ANativeWindow*>(stc.get()), NULL);
|
||||
ASSERT_EQ(EGL_SUCCESS, eglGetError());
|
||||
|
@ -387,7 +387,7 @@ protected:
|
||||
GLTest::SetUp();
|
||||
sp<BufferQueue> bq = new BufferQueue();
|
||||
mGlConsumer = new GLConsumer(bq, TEX_ID);
|
||||
mSurface = new Surface(mGlConsumer->getBufferQueue());
|
||||
mSurface = new Surface(bq);
|
||||
mANW = mSurface.get();
|
||||
|
||||
}
|
||||
@ -481,8 +481,9 @@ protected:
|
||||
virtual void SetUp() {
|
||||
GLTest::SetUp();
|
||||
sp<BufferQueue> bq = new BufferQueue();
|
||||
mBQ = bq;
|
||||
mST = new GLConsumer(bq, TEX_ID);
|
||||
mSTC = new Surface(mST->getBufferQueue());
|
||||
mSTC = new Surface(bq);
|
||||
mANW = mSTC;
|
||||
mTextureRenderer = new TextureRenderer(TEX_ID, mST);
|
||||
ASSERT_NO_FATAL_FAILURE(mTextureRenderer->SetUp());
|
||||
@ -672,6 +673,7 @@ protected:
|
||||
Condition mFrameCondition;
|
||||
};
|
||||
|
||||
sp<BufferQueue> mBQ;
|
||||
sp<GLConsumer> mST;
|
||||
sp<Surface> mSTC;
|
||||
sp<ANativeWindow> mANW;
|
||||
@ -1211,7 +1213,7 @@ TEST_F(SurfaceTextureGLTest, DisconnectStressTest) {
|
||||
};
|
||||
|
||||
sp<DisconnectWaiter> dw(new DisconnectWaiter());
|
||||
mST->getBufferQueue()->consumerConnect(dw, false);
|
||||
mBQ->consumerConnect(dw, false);
|
||||
|
||||
|
||||
sp<Thread> pt(new ProducerThread(mANW));
|
||||
|
@ -92,7 +92,7 @@ TEST_F(SurfaceTest, ScreenshotsOfProtectedBuffersSucceed) {
|
||||
sp<CpuConsumer> consumer = new CpuConsumer(bq, 1);
|
||||
sp<ISurfaceComposer> sf(ComposerService::getComposerService());
|
||||
sp<IBinder> display(sf->getBuiltInDisplay(ISurfaceComposer::eDisplayIdMain));
|
||||
ASSERT_EQ(NO_ERROR, sf->captureScreen(display, consumer->getBufferQueue(),
|
||||
ASSERT_EQ(NO_ERROR, sf->captureScreen(display, bq,
|
||||
64, 64, 0, 0x7fffffff, true));
|
||||
|
||||
// Set the PROTECTED usage bit and verify that the screenshot fails. Note
|
||||
@ -121,7 +121,7 @@ TEST_F(SurfaceTest, ScreenshotsOfProtectedBuffersSucceed) {
|
||||
&buf));
|
||||
ASSERT_EQ(NO_ERROR, anw->queueBuffer(anw.get(), buf, -1));
|
||||
}
|
||||
ASSERT_EQ(NO_ERROR, sf->captureScreen(display, consumer->getBufferQueue(),
|
||||
ASSERT_EQ(NO_ERROR, sf->captureScreen(display, bq,
|
||||
64, 64, 0, 0x7fffffff, true));
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ android_eglCreateWindowSurfaceTexture
|
||||
jint _remaining;
|
||||
EGLint *attrib_list = (EGLint *) 0;
|
||||
android::sp<ANativeWindow> window;
|
||||
android::sp<android::GLConsumer> glConsumer;
|
||||
android::sp<android::IGraphicBufferProducer> producer;
|
||||
|
||||
if (!attrib_list_ref) {
|
||||
_exception = 1;
|
||||
@ -111,12 +111,12 @@ not_valid_surface:
|
||||
_exceptionMessage = "Make sure the SurfaceView or associated SurfaceHolder has a valid Surface";
|
||||
goto exit;
|
||||
}
|
||||
glConsumer = android::SurfaceTexture_getSurfaceTexture(_env, win);
|
||||
producer = android::SurfaceTexture_getProducer(_env, win);
|
||||
|
||||
if (glConsumer == NULL)
|
||||
if (producer == NULL)
|
||||
goto not_valid_surface;
|
||||
|
||||
window = new android::Surface(glConsumer->getBufferQueue());
|
||||
window = new android::Surface(producer);
|
||||
|
||||
if (window == NULL)
|
||||
goto not_valid_surface;
|
||||
|
@ -56,6 +56,7 @@ DisplayDevice::DisplayDevice(
|
||||
bool isSecure,
|
||||
const wp<IBinder>& displayToken,
|
||||
const sp<DisplaySurface>& displaySurface,
|
||||
const sp<IGraphicBufferProducer>& producer,
|
||||
EGLConfig config)
|
||||
: mFlinger(flinger),
|
||||
mType(type), mHwcDisplayId(hwcId),
|
||||
@ -73,7 +74,7 @@ DisplayDevice::DisplayDevice(
|
||||
mLayerStack(NO_LAYER_STACK),
|
||||
mOrientation()
|
||||
{
|
||||
mNativeWindow = new Surface(mDisplaySurface->getIGraphicBufferProducer());
|
||||
mNativeWindow = new Surface(producer);
|
||||
ANativeWindow* const window = mNativeWindow.get();
|
||||
|
||||
int format;
|
||||
|
@ -76,6 +76,7 @@ public:
|
||||
bool isSecure,
|
||||
const wp<IBinder>& displayToken,
|
||||
const sp<DisplaySurface>& displaySurface,
|
||||
const sp<IGraphicBufferProducer>& producer,
|
||||
EGLConfig config);
|
||||
|
||||
~DisplayDevice();
|
||||
|
@ -30,8 +30,6 @@ class String8;
|
||||
|
||||
class DisplaySurface : public virtual RefBase {
|
||||
public:
|
||||
virtual sp<IGraphicBufferProducer> getIGraphicBufferProducer() const = 0;
|
||||
|
||||
// prepareFrame is called after the composition configuration is known but
|
||||
// before composition takes place. The DisplaySurface can use the
|
||||
// composition type to decide how to manage the flow of buffers between
|
||||
|
@ -50,25 +50,22 @@ namespace android {
|
||||
*
|
||||
*/
|
||||
|
||||
FramebufferSurface::FramebufferSurface(HWComposer& hwc, int disp) :
|
||||
ConsumerBase(new BufferQueue(new GraphicBufferAlloc())),
|
||||
FramebufferSurface::FramebufferSurface(HWComposer& hwc, int disp,
|
||||
const sp<IGraphicBufferConsumer>& consumer) :
|
||||
ConsumerBase(consumer),
|
||||
mDisplayType(disp),
|
||||
mCurrentBufferSlot(-1),
|
||||
mCurrentBuffer(0),
|
||||
mHwc(hwc)
|
||||
{
|
||||
mName = "FramebufferSurface";
|
||||
mBufferQueue->setConsumerName(mName);
|
||||
mBufferQueue->setConsumerUsageBits(GRALLOC_USAGE_HW_FB |
|
||||
mConsumer->setConsumerName(mName);
|
||||
mConsumer->setConsumerUsageBits(GRALLOC_USAGE_HW_FB |
|
||||
GRALLOC_USAGE_HW_RENDER |
|
||||
GRALLOC_USAGE_HW_COMPOSER);
|
||||
mBufferQueue->setDefaultBufferFormat(mHwc.getFormat(disp));
|
||||
mBufferQueue->setDefaultBufferSize(mHwc.getWidth(disp), mHwc.getHeight(disp));
|
||||
mBufferQueue->setDefaultMaxBufferCount(NUM_FRAMEBUFFER_SURFACE_BUFFERS);
|
||||
}
|
||||
|
||||
sp<IGraphicBufferProducer> FramebufferSurface::getIGraphicBufferProducer() const {
|
||||
return getBufferQueue();
|
||||
mConsumer->setDefaultBufferFormat(mHwc.getFormat(disp));
|
||||
mConsumer->setDefaultBufferSize(mHwc.getWidth(disp), mHwc.getHeight(disp));
|
||||
mConsumer->setDefaultMaxBufferCount(NUM_FRAMEBUFFER_SURFACE_BUFFERS);
|
||||
}
|
||||
|
||||
status_t FramebufferSurface::prepareFrame(CompositionType compositionType) {
|
||||
|
@ -37,9 +37,7 @@ class HWComposer;
|
||||
class FramebufferSurface : public ConsumerBase,
|
||||
public DisplaySurface {
|
||||
public:
|
||||
FramebufferSurface(HWComposer& hwc, int disp);
|
||||
|
||||
virtual sp<IGraphicBufferProducer> getIGraphicBufferProducer() const;
|
||||
FramebufferSurface(HWComposer& hwc, int disp, const sp<IGraphicBufferConsumer>& consumer);
|
||||
|
||||
virtual status_t prepareFrame(CompositionType compositionType);
|
||||
virtual status_t compositionComplete();
|
||||
|
@ -40,8 +40,10 @@ static const char* dbgCompositionTypeStr(DisplaySurface::CompositionType type) {
|
||||
}
|
||||
|
||||
VirtualDisplaySurface::VirtualDisplaySurface(HWComposer& hwc, int32_t dispId,
|
||||
const sp<IGraphicBufferProducer>& sink, const String8& name)
|
||||
: ConsumerBase(new BufferQueue()),
|
||||
const sp<IGraphicBufferProducer>& sink,
|
||||
const sp<BufferQueue>& bq,
|
||||
const String8& name)
|
||||
: ConsumerBase(bq),
|
||||
mHwc(hwc),
|
||||
mDisplayId(dispId),
|
||||
mDisplayName(name),
|
||||
@ -51,7 +53,7 @@ VirtualDisplaySurface::VirtualDisplaySurface(HWComposer& hwc, int32_t dispId,
|
||||
mDbgLastCompositionType(COMPOSITION_UNKNOWN)
|
||||
{
|
||||
mSource[SOURCE_SINK] = sink;
|
||||
mSource[SOURCE_SCRATCH] = mBufferQueue;
|
||||
mSource[SOURCE_SCRATCH] = bq;
|
||||
|
||||
resetPerFrameState();
|
||||
|
||||
@ -60,26 +62,15 @@ VirtualDisplaySurface::VirtualDisplaySurface(HWComposer& hwc, int32_t dispId,
|
||||
mSource[SOURCE_SINK]->query(NATIVE_WINDOW_HEIGHT, &sinkHeight);
|
||||
|
||||
ConsumerBase::mName = String8::format("VDS: %s", mDisplayName.string());
|
||||
mBufferQueue->setConsumerName(ConsumerBase::mName);
|
||||
mBufferQueue->setConsumerUsageBits(GRALLOC_USAGE_HW_COMPOSER);
|
||||
mBufferQueue->setDefaultBufferSize(sinkWidth, sinkHeight);
|
||||
mBufferQueue->setDefaultMaxBufferCount(2);
|
||||
mConsumer->setConsumerName(ConsumerBase::mName);
|
||||
mConsumer->setConsumerUsageBits(GRALLOC_USAGE_HW_COMPOSER);
|
||||
mConsumer->setDefaultBufferSize(sinkWidth, sinkHeight);
|
||||
mConsumer->setDefaultMaxBufferCount(2);
|
||||
}
|
||||
|
||||
VirtualDisplaySurface::~VirtualDisplaySurface() {
|
||||
}
|
||||
|
||||
sp<IGraphicBufferProducer> VirtualDisplaySurface::getIGraphicBufferProducer() const {
|
||||
if (mDisplayId >= 0) {
|
||||
return static_cast<IGraphicBufferProducer*>(
|
||||
const_cast<VirtualDisplaySurface*>(this));
|
||||
} else {
|
||||
// There won't be any interaction with HWC for this virtual display,
|
||||
// so the GLES driver can pass buffers directly to the sink.
|
||||
return mSource[SOURCE_SINK];
|
||||
}
|
||||
}
|
||||
|
||||
status_t VirtualDisplaySurface::prepareFrame(CompositionType compositionType) {
|
||||
if (mDisplayId < 0)
|
||||
return NO_ERROR;
|
||||
@ -294,7 +285,7 @@ status_t VirtualDisplaySurface::queueBuffer(int pslot,
|
||||
// Queue the buffer back into the scratch pool
|
||||
QueueBufferOutput scratchQBO;
|
||||
int sslot = mapProducer2SourceSlot(SOURCE_SCRATCH, pslot);
|
||||
result = mBufferQueue->queueBuffer(sslot, input, &scratchQBO);
|
||||
result = mSource[SOURCE_SCRATCH]->queueBuffer(sslot, input, &scratchQBO);
|
||||
if (result != NO_ERROR)
|
||||
return result;
|
||||
|
||||
|
@ -68,17 +68,17 @@ class HWComposer;
|
||||
* is released and the output buffer is queued to the sink.
|
||||
*/
|
||||
class VirtualDisplaySurface : public DisplaySurface,
|
||||
private BnGraphicBufferProducer,
|
||||
public BnGraphicBufferProducer,
|
||||
private ConsumerBase {
|
||||
public:
|
||||
VirtualDisplaySurface(HWComposer& hwc, int32_t dispId,
|
||||
const sp<IGraphicBufferProducer>& sink,
|
||||
const sp<BufferQueue>& bq,
|
||||
const String8& name);
|
||||
|
||||
//
|
||||
// DisplaySurface interface
|
||||
//
|
||||
virtual sp<IGraphicBufferProducer> getIGraphicBufferProducer() const;
|
||||
virtual status_t prepareFrame(CompositionType compositionType);
|
||||
virtual status_t compositionComplete();
|
||||
virtual status_t advanceFrame();
|
||||
|
@ -113,8 +113,8 @@ Layer::Layer(SurfaceFlinger* flinger, const sp<Client>& client,
|
||||
void Layer::onFirstRef()
|
||||
{
|
||||
// Creates a custom BufferQueue for SurfaceFlingerConsumer to use
|
||||
sp<BufferQueue> bq = new SurfaceTextureLayer(mFlinger);
|
||||
mSurfaceFlingerConsumer = new SurfaceFlingerConsumer(bq, mTextureName,
|
||||
mBufferQueue = new SurfaceTextureLayer(mFlinger);
|
||||
mSurfaceFlingerConsumer = new SurfaceFlingerConsumer(mBufferQueue, mTextureName,
|
||||
GL_TEXTURE_EXTERNAL_OES, false);
|
||||
|
||||
mSurfaceFlingerConsumer->setConsumerUsageBits(getEffectiveUsage(0));
|
||||
@ -228,8 +228,8 @@ sp<IBinder> Layer::getHandle() {
|
||||
return new Handle(mFlinger, this);
|
||||
}
|
||||
|
||||
sp<BufferQueue> Layer::getBufferQueue() const {
|
||||
return mSurfaceFlingerConsumer->getBufferQueue();
|
||||
sp<IGraphicBufferProducer> Layer::getBufferQueue() const {
|
||||
return mBufferQueue;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@ -926,7 +926,7 @@ Region Layer::latchBuffer(bool& recomputeVisibleRegions)
|
||||
}
|
||||
|
||||
virtual bool reject(const sp<GraphicBuffer>& buf,
|
||||
const BufferQueue::BufferItem& item) {
|
||||
const IGraphicBufferConsumer::BufferItem& item) {
|
||||
if (buf == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ public:
|
||||
Rect computeBounds() const;
|
||||
|
||||
sp<IBinder> getHandle();
|
||||
sp<BufferQueue> getBufferQueue() const;
|
||||
sp<IGraphicBufferProducer> getBufferQueue() const;
|
||||
const String8& getName() const;
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
@ -344,6 +344,7 @@ private:
|
||||
|
||||
// constants
|
||||
sp<SurfaceFlingerConsumer> mSurfaceFlingerConsumer;
|
||||
sp<BufferQueue> mBufferQueue;
|
||||
GLuint mTextureName;
|
||||
bool mPremultipliedAlpha;
|
||||
String8 mName;
|
||||
|
@ -451,9 +451,11 @@ status_t SurfaceFlinger::readyToRun()
|
||||
createBuiltinDisplayLocked(type);
|
||||
wp<IBinder> token = mBuiltinDisplays[i];
|
||||
|
||||
sp<BufferQueue> bq = new BufferQueue(new GraphicBufferAlloc());
|
||||
sp<FramebufferSurface> fbs = new FramebufferSurface(*mHwc, i, bq);
|
||||
sp<DisplayDevice> hw = new DisplayDevice(this,
|
||||
type, allocateHwcDisplayId(type), isSecure, token,
|
||||
new FramebufferSurface(*mHwc, i),
|
||||
fbs, bq,
|
||||
mEGLConfig);
|
||||
if (i > DisplayDevice::DISPLAY_PRIMARY) {
|
||||
// FIXME: currently we don't get blank/unblank requests
|
||||
@ -1101,16 +1103,29 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
|
||||
const DisplayDeviceState& state(curr[i]);
|
||||
|
||||
sp<DisplaySurface> dispSurface;
|
||||
sp<IGraphicBufferProducer> producer;
|
||||
sp<BufferQueue> bq = new BufferQueue(new GraphicBufferAlloc());
|
||||
|
||||
int32_t hwcDisplayId = -1;
|
||||
if (state.isVirtualDisplay()) {
|
||||
// Virtual displays without a surface are dormant:
|
||||
// they have external state (layer stack, projection,
|
||||
// etc.) but no internal state (i.e. a DisplayDevice).
|
||||
if (state.surface != NULL) {
|
||||
|
||||
hwcDisplayId = allocateHwcDisplayId(state.type);
|
||||
dispSurface = new VirtualDisplaySurface(
|
||||
*mHwc, hwcDisplayId, state.surface,
|
||||
sp<VirtualDisplaySurface> vds = new VirtualDisplaySurface(
|
||||
*mHwc, hwcDisplayId, state.surface, bq,
|
||||
state.displayName);
|
||||
|
||||
dispSurface = vds;
|
||||
if (hwcDisplayId >= 0) {
|
||||
producer = vds;
|
||||
} else {
|
||||
// There won't be any interaction with HWC for this virtual display,
|
||||
// so the GLES driver can pass buffers directly to the sink.
|
||||
producer = state.surface;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ALOGE_IF(state.surface!=NULL,
|
||||
@ -1120,14 +1135,15 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
|
||||
hwcDisplayId = allocateHwcDisplayId(state.type);
|
||||
// for supported (by hwc) displays we provide our
|
||||
// own rendering surface
|
||||
dispSurface = new FramebufferSurface(*mHwc, state.type);
|
||||
dispSurface = new FramebufferSurface(*mHwc, state.type, bq);
|
||||
producer = bq;
|
||||
}
|
||||
|
||||
const wp<IBinder>& display(curr.keyAt(i));
|
||||
if (dispSurface != NULL) {
|
||||
sp<DisplayDevice> hw = new DisplayDevice(this,
|
||||
state.type, hwcDisplayId, state.isSecure,
|
||||
display, dispSurface, mEGLConfig);
|
||||
display, dispSurface, producer, mEGLConfig);
|
||||
hw->setLayerStack(state.layerStack);
|
||||
hw->setProjection(state.orientation,
|
||||
state.viewport, state.frame);
|
||||
|
@ -36,7 +36,7 @@ public:
|
||||
class BufferRejecter {
|
||||
friend class SurfaceFlingerConsumer;
|
||||
virtual bool reject(const sp<GraphicBuffer>& buf,
|
||||
const BufferQueue::BufferItem& item) = 0;
|
||||
const IGraphicBufferConsumer::BufferItem& item) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~BufferRejecter() { }
|
||||
|
Loading…
Reference in New Issue
Block a user