always pass the BufferQueue explicitely to consumers
Change-Id: I883b0a7b19d8e722f9ab714ba6f49e658b02ca86
This commit is contained in:
parent
cdd7d8bc14
commit
8f938a5338
@ -199,8 +199,8 @@ bool GLHelper::getShaderProgram(const char* name, GLuint* outPgm) {
|
|||||||
bool GLHelper::createNamedSurfaceTexture(GLuint name, uint32_t w, uint32_t h,
|
bool GLHelper::createNamedSurfaceTexture(GLuint name, uint32_t w, uint32_t h,
|
||||||
sp<GLConsumer>* glConsumer, EGLSurface* surface) {
|
sp<GLConsumer>* glConsumer, EGLSurface* surface) {
|
||||||
sp<BufferQueue> bq = new BufferQueue(true, mGraphicBufferAlloc);
|
sp<BufferQueue> bq = new BufferQueue(true, mGraphicBufferAlloc);
|
||||||
sp<GLConsumer> glc = new GLConsumer(name, true,
|
sp<GLConsumer> glc = new GLConsumer(bq, name,
|
||||||
GL_TEXTURE_EXTERNAL_OES, false, bq);
|
GL_TEXTURE_EXTERNAL_OES, false);
|
||||||
glc->setDefaultBufferSize(w, h);
|
glc->setDefaultBufferSize(w, h);
|
||||||
glc->setDefaultMaxBufferCount(3);
|
glc->setDefaultMaxBufferCount(3);
|
||||||
glc->setConsumerUsageBits(GRALLOC_USAGE_HW_COMPOSER);
|
glc->setConsumerUsageBits(GRALLOC_USAGE_HW_COMPOSER);
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
|
class BufferQueue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BufferItemConsumer is a BufferQueue consumer endpoint that allows clients
|
* BufferItemConsumer is a BufferQueue consumer endpoint that allows clients
|
||||||
* access to the whole BufferItem entry from BufferQueue. Multiple buffers may
|
* access to the whole BufferItem entry from BufferQueue. Multiple buffers may
|
||||||
@ -49,7 +51,7 @@ class BufferItemConsumer: public ConsumerBase
|
|||||||
// the consumer usage flags passed to the graphics allocator. The
|
// the consumer usage flags passed to the graphics allocator. The
|
||||||
// bufferCount parameter specifies how many buffers can be locked for user
|
// bufferCount parameter specifies how many buffers can be locked for user
|
||||||
// access at the same time.
|
// access at the same time.
|
||||||
BufferItemConsumer(uint32_t consumerUsage,
|
BufferItemConsumer(const sp<BufferQueue>& bq, uint32_t consumerUsage,
|
||||||
int bufferCount = BufferQueue::MIN_UNDEQUEUED_BUFFERS,
|
int bufferCount = BufferQueue::MIN_UNDEQUEUED_BUFFERS,
|
||||||
bool synchronousMode = false);
|
bool synchronousMode = false);
|
||||||
|
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
|
class BufferQueue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CpuConsumer is a BufferQueue consumer endpoint that allows direct CPU
|
* CpuConsumer is a BufferQueue consumer endpoint that allows direct CPU
|
||||||
* access to the underlying gralloc buffers provided by BufferQueue. Multiple
|
* access to the underlying gralloc buffers provided by BufferQueue. Multiple
|
||||||
@ -64,7 +66,8 @@ class CpuConsumer : public ConsumerBase
|
|||||||
|
|
||||||
// Create a new CPU consumer. The maxLockedBuffers parameter specifies
|
// Create a new CPU consumer. The maxLockedBuffers parameter specifies
|
||||||
// how many buffers can be locked for user access at the same time.
|
// how many buffers can be locked for user access at the same time.
|
||||||
CpuConsumer(uint32_t maxLockedBuffers, bool synchronousMode = true);
|
CpuConsumer(const sp<BufferQueue>& bq,
|
||||||
|
uint32_t maxLockedBuffers, bool synchronousMode = true);
|
||||||
|
|
||||||
virtual ~CpuConsumer();
|
virtual ~CpuConsumer();
|
||||||
|
|
||||||
|
@ -85,9 +85,9 @@ public:
|
|||||||
// purely to allow a GLConsumer 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
|
// context to another. If such a transfer is not needed there is no
|
||||||
// requirement that either of these methods be called.
|
// requirement that either of these methods be called.
|
||||||
GLConsumer(GLuint tex, bool allowSynchronousMode = true,
|
GLConsumer(const sp<BufferQueue>& bq,
|
||||||
GLenum texTarget = GL_TEXTURE_EXTERNAL_OES, bool useFenceSync = true,
|
GLuint tex, GLenum texTarget = GL_TEXTURE_EXTERNAL_OES,
|
||||||
const sp<BufferQueue> &bufferQueue = 0);
|
bool useFenceSync = true);
|
||||||
|
|
||||||
// updateTexImage acquires the most recently queued buffer, and sets the
|
// updateTexImage acquires the most recently queued buffer, and sets the
|
||||||
// image contents of the target texture to it.
|
// image contents of the target texture to it.
|
||||||
|
@ -29,9 +29,9 @@
|
|||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
BufferItemConsumer::BufferItemConsumer(uint32_t consumerUsage,
|
BufferItemConsumer::BufferItemConsumer(const sp<BufferQueue>& bq,
|
||||||
int bufferCount, bool synchronousMode) :
|
uint32_t consumerUsage, int bufferCount, bool synchronousMode) :
|
||||||
ConsumerBase(new BufferQueue(true) )
|
ConsumerBase(bq)
|
||||||
{
|
{
|
||||||
mBufferQueue->setConsumerUsageBits(consumerUsage);
|
mBufferQueue->setConsumerUsageBits(consumerUsage);
|
||||||
mBufferQueue->setSynchronousMode(synchronousMode);
|
mBufferQueue->setSynchronousMode(synchronousMode);
|
||||||
|
@ -30,8 +30,9 @@
|
|||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
CpuConsumer::CpuConsumer(uint32_t maxLockedBuffers, bool synchronousMode) :
|
CpuConsumer::CpuConsumer(const sp<BufferQueue>& bq,
|
||||||
ConsumerBase(new BufferQueue(true) ),
|
uint32_t maxLockedBuffers, bool synchronousMode) :
|
||||||
|
ConsumerBase(bq),
|
||||||
mMaxLockedBuffers(maxLockedBuffers),
|
mMaxLockedBuffers(maxLockedBuffers),
|
||||||
mCurrentLockedBuffers(0)
|
mCurrentLockedBuffers(0)
|
||||||
{
|
{
|
||||||
|
@ -78,9 +78,9 @@ static float mtxRot90[16] = {
|
|||||||
static void mtxMul(float out[16], const float a[16], const float b[16]);
|
static void mtxMul(float out[16], const float a[16], const float b[16]);
|
||||||
|
|
||||||
|
|
||||||
GLConsumer::GLConsumer(GLuint tex, bool allowSynchronousMode,
|
GLConsumer::GLConsumer(const sp<BufferQueue>& bq, GLuint tex,
|
||||||
GLenum texTarget, bool useFenceSync, const sp<BufferQueue> &bufferQueue) :
|
GLenum texTarget, bool useFenceSync) :
|
||||||
ConsumerBase(bufferQueue == 0 ? new BufferQueue(allowSynchronousMode) : bufferQueue),
|
ConsumerBase(bq),
|
||||||
mCurrentTransform(0),
|
mCurrentTransform(0),
|
||||||
mCurrentScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE),
|
mCurrentScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE),
|
||||||
mCurrentFence(Fence::NO_FENCE),
|
mCurrentFence(Fence::NO_FENCE),
|
||||||
|
@ -633,7 +633,8 @@ ScreenshotClient::~ScreenshotClient() {
|
|||||||
|
|
||||||
sp<CpuConsumer> ScreenshotClient::getCpuConsumer() const {
|
sp<CpuConsumer> ScreenshotClient::getCpuConsumer() const {
|
||||||
if (mCpuConsumer == NULL) {
|
if (mCpuConsumer == NULL) {
|
||||||
mCpuConsumer = new CpuConsumer(1);
|
sp<BufferQueue> bq = new BufferQueue();
|
||||||
|
mCpuConsumer = new CpuConsumer(bq, 1);
|
||||||
mCpuConsumer->setName(String8("ScreenshotClient"));
|
mCpuConsumer->setName(String8("ScreenshotClient"));
|
||||||
}
|
}
|
||||||
return mCpuConsumer;
|
return mCpuConsumer;
|
||||||
|
@ -66,7 +66,8 @@ protected:
|
|||||||
test_info->name(),
|
test_info->name(),
|
||||||
params.width, params.height,
|
params.width, params.height,
|
||||||
params.maxLockedBuffers, params.format);
|
params.maxLockedBuffers, params.format);
|
||||||
mCC = new CpuConsumer(params.maxLockedBuffers);
|
sp<BufferQueue> bq = new BufferQueue();
|
||||||
|
mCC = new CpuConsumer(bq, params.maxLockedBuffers);
|
||||||
String8 name("CpuConsumer_Under_Test");
|
String8 name("CpuConsumer_Under_Test");
|
||||||
mCC->setName(name);
|
mCC->setName(name);
|
||||||
mSTC = new Surface(mCC->getProducerInterface());
|
mSTC = new Surface(mCC->getProducerInterface());
|
||||||
|
@ -40,7 +40,8 @@ protected:
|
|||||||
ALOGV("Begin test: %s.%s", testInfo->test_case_name(),
|
ALOGV("Begin test: %s.%s", testInfo->test_case_name(),
|
||||||
testInfo->name());
|
testInfo->name());
|
||||||
|
|
||||||
mST = new GLConsumer(123);
|
sp<BufferQueue> bq = new BufferQueue();
|
||||||
|
mST = new GLConsumer(bq, 123);
|
||||||
mSTC = new Surface(mST->getBufferQueue());
|
mSTC = new Surface(mST->getBufferQueue());
|
||||||
mANW = mSTC;
|
mANW = mSTC;
|
||||||
|
|
||||||
@ -715,7 +716,8 @@ protected:
|
|||||||
ASSERT_NE(EGL_NO_CONTEXT, mEglContext);
|
ASSERT_NE(EGL_NO_CONTEXT, mEglContext);
|
||||||
|
|
||||||
for (int i = 0; i < NUM_SURFACE_TEXTURES; i++) {
|
for (int i = 0; i < NUM_SURFACE_TEXTURES; i++) {
|
||||||
sp<GLConsumer> st(new GLConsumer(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(st->getBufferQueue()));
|
||||||
mEglSurfaces[i] = eglCreateWindowSurface(mEglDisplay, myConfig,
|
mEglSurfaces[i] = eglCreateWindowSurface(mEglDisplay, myConfig,
|
||||||
static_cast<ANativeWindow*>(stc.get()), NULL);
|
static_cast<ANativeWindow*>(stc.get()), NULL);
|
||||||
|
@ -385,7 +385,8 @@ protected:
|
|||||||
|
|
||||||
virtual void SetUp() {
|
virtual void SetUp() {
|
||||||
GLTest::SetUp();
|
GLTest::SetUp();
|
||||||
mGlConsumer = new GLConsumer(TEX_ID);
|
sp<BufferQueue> bq = new BufferQueue();
|
||||||
|
mGlConsumer = new GLConsumer(bq, TEX_ID);
|
||||||
mSurface = new Surface(mGlConsumer->getBufferQueue());
|
mSurface = new Surface(mGlConsumer->getBufferQueue());
|
||||||
mANW = mSurface.get();
|
mANW = mSurface.get();
|
||||||
|
|
||||||
@ -479,7 +480,8 @@ protected:
|
|||||||
|
|
||||||
virtual void SetUp() {
|
virtual void SetUp() {
|
||||||
GLTest::SetUp();
|
GLTest::SetUp();
|
||||||
mST = new GLConsumer(TEX_ID);
|
sp<BufferQueue> bq = new BufferQueue();
|
||||||
|
mST = new GLConsumer(bq, TEX_ID);
|
||||||
mSTC = new Surface(mST->getBufferQueue());
|
mSTC = new Surface(mST->getBufferQueue());
|
||||||
mANW = mSTC;
|
mANW = mSTC;
|
||||||
mTextureRenderer = new TextureRenderer(TEX_ID, mST);
|
mTextureRenderer = new TextureRenderer(TEX_ID, mST);
|
||||||
|
@ -110,8 +110,8 @@ void Layer::onFirstRef()
|
|||||||
{
|
{
|
||||||
// Creates a custom BufferQueue for SurfaceFlingerConsumer to use
|
// Creates a custom BufferQueue for SurfaceFlingerConsumer to use
|
||||||
sp<BufferQueue> bq = new SurfaceTextureLayer(mFlinger);
|
sp<BufferQueue> bq = new SurfaceTextureLayer(mFlinger);
|
||||||
mSurfaceFlingerConsumer = new SurfaceFlingerConsumer(mTextureName, true,
|
mSurfaceFlingerConsumer = new SurfaceFlingerConsumer(bq, mTextureName,
|
||||||
GL_TEXTURE_EXTERNAL_OES, false, bq);
|
GL_TEXTURE_EXTERNAL_OES, false);
|
||||||
|
|
||||||
mSurfaceFlingerConsumer->setConsumerUsageBits(getEffectiveUsage(0));
|
mSurfaceFlingerConsumer->setConsumerUsageBits(getEffectiveUsage(0));
|
||||||
mSurfaceFlingerConsumer->setFrameAvailableListener(this);
|
mSurfaceFlingerConsumer->setFrameAvailableListener(this);
|
||||||
|
@ -27,11 +27,10 @@ namespace android {
|
|||||||
*/
|
*/
|
||||||
class SurfaceFlingerConsumer : public GLConsumer {
|
class SurfaceFlingerConsumer : public GLConsumer {
|
||||||
public:
|
public:
|
||||||
SurfaceFlingerConsumer(GLuint tex, bool allowSynchronousMode = true,
|
SurfaceFlingerConsumer(const sp<BufferQueue>& bq, GLuint tex,
|
||||||
GLenum texTarget = GL_TEXTURE_EXTERNAL_OES, bool useFenceSync = true,
|
GLenum texTarget = GL_TEXTURE_EXTERNAL_OES,
|
||||||
const sp<BufferQueue> &bufferQueue = 0)
|
bool useFenceSync = true)
|
||||||
: GLConsumer(tex, allowSynchronousMode, texTarget, useFenceSync,
|
: GLConsumer(bq, tex, texTarget, useFenceSync)
|
||||||
bufferQueue)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
class BufferRejecter {
|
class BufferRejecter {
|
||||||
|
Loading…
Reference in New Issue
Block a user