Loading include/gui/ConsumerBase.h +12 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,18 @@ protected: // buffers from the given BufferQueue. ConsumerBase(const sp<BufferQueue> &bufferQueue); // 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 // can coordinate the clean-up by calling into virtual methods implemented // by the derived classes. This would not be possible from the // ConsuemrBase dtor because by the time that gets called the derived // classes have already been destructed. // // This methods should not need to be overridden by derived classes, but // if they are overridden the ConsumerBase implementation must be called // from the derived class. virtual void onLastStrongRef(const void* id); // Implementation of the BufferQueue::ConsumerListener 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 Loading libs/gui/ConsumerBase.cpp +12 −1 Original line number Diff line number Diff line Loading @@ -77,6 +77,17 @@ ConsumerBase::ConsumerBase(const sp<BufferQueue>& bufferQueue) : ConsumerBase::~ConsumerBase() { CB_LOGV("~ConsumerBase"); Mutex::Autolock lock(mMutex); // Verify that abandon() has been called before we get here. This should // be done by ConsumerBase::onLastStrongRef(), but it's possible for a // derived class to override that method and not call // ConsumerBase::onLastStrongRef(). LOG_ALWAYS_FATAL_IF(!mAbandoned, "[%s] ~ConsumerBase was called, but the " "consumer is not abandoned!", mName.string()); } void ConsumerBase::onLastStrongRef(const void* id) { abandon(); } Loading libs/gui/tests/SurfaceTextureClient_test.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -178,21 +178,21 @@ TEST_F(SurfaceTextureClientTest, EglSwapBuffersAbandonErrorIsEglBadSurface) { EXPECT_EQ(EGL_SUCCESS, eglGetError()); EGLBoolean success = eglMakeCurrent(mEglDisplay, eglSurface, eglSurface, mEglContext); EXPECT_EQ(EGL_TRUE, success); EXPECT_TRUE(success); glClear(GL_COLOR_BUFFER_BIT); success = eglSwapBuffers(mEglDisplay, eglSurface); EXPECT_EQ(EGL_TRUE, success); EXPECT_TRUE(success); mST->abandon(); glClear(GL_COLOR_BUFFER_BIT); success = eglSwapBuffers(mEglDisplay, eglSurface); EXPECT_EQ(EGL_FALSE, success); EXPECT_FALSE(success); EXPECT_EQ(EGL_BAD_SURFACE, eglGetError()); success = eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext); ASSERT_EQ(EGL_TRUE, success); ASSERT_TRUE(success); if (eglSurface != EGL_NO_SURFACE) { eglDestroySurface(mEglDisplay, eglSurface); Loading libs/gui/tests/SurfaceTexture_test.cpp +12 −12 Original line number Diff line number Diff line Loading @@ -716,18 +716,18 @@ TEST_F(SurfaceTextureGLTest, TexturingFromCpuFilledYV12BufferNpot) { glViewport(0, 0, texWidth, texHeight); drawTexture(); EXPECT_TRUE(checkPixel( 0, 0, 255, 127, 255, 255)); EXPECT_TRUE(checkPixel(63, 0, 0, 133, 0, 255)); EXPECT_TRUE(checkPixel(63, 65, 0, 133, 0, 255)); EXPECT_TRUE(checkPixel( 0, 65, 255, 127, 255, 255)); EXPECT_TRUE(checkPixel(22, 44, 255, 127, 255, 255)); EXPECT_TRUE(checkPixel(45, 52, 255, 127, 255, 255)); EXPECT_TRUE(checkPixel(52, 51, 98, 255, 73, 255)); EXPECT_TRUE(checkPixel( 7, 31, 155, 0, 118, 255)); EXPECT_TRUE(checkPixel(31, 9, 107, 24, 87, 255)); EXPECT_TRUE(checkPixel(29, 35, 255, 127, 255, 255)); EXPECT_TRUE(checkPixel(36, 22, 155, 29, 0, 255)); EXPECT_TRUE(checkPixel( 0, 0, 255, 127, 255, 255, 3)); EXPECT_TRUE(checkPixel(63, 0, 0, 133, 0, 255, 3)); EXPECT_TRUE(checkPixel(63, 65, 0, 133, 0, 255, 3)); EXPECT_TRUE(checkPixel( 0, 65, 255, 127, 255, 255, 3)); EXPECT_TRUE(checkPixel(22, 44, 255, 127, 255, 255, 3)); EXPECT_TRUE(checkPixel(45, 52, 255, 127, 255, 255, 3)); EXPECT_TRUE(checkPixel(52, 51, 98, 255, 73, 255, 3)); EXPECT_TRUE(checkPixel( 7, 31, 155, 0, 118, 255, 3)); EXPECT_TRUE(checkPixel(31, 9, 107, 24, 87, 255, 3)); EXPECT_TRUE(checkPixel(29, 35, 255, 127, 255, 255, 3)); EXPECT_TRUE(checkPixel(36, 22, 155, 29, 0, 255, 3)); } TEST_F(SurfaceTextureGLTest, TexturingFromCpuFilledYV12BufferPow2) { Loading Loading
include/gui/ConsumerBase.h +12 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,18 @@ protected: // buffers from the given BufferQueue. ConsumerBase(const sp<BufferQueue> &bufferQueue); // 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 // can coordinate the clean-up by calling into virtual methods implemented // by the derived classes. This would not be possible from the // ConsuemrBase dtor because by the time that gets called the derived // classes have already been destructed. // // This methods should not need to be overridden by derived classes, but // if they are overridden the ConsumerBase implementation must be called // from the derived class. virtual void onLastStrongRef(const void* id); // Implementation of the BufferQueue::ConsumerListener 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 Loading
libs/gui/ConsumerBase.cpp +12 −1 Original line number Diff line number Diff line Loading @@ -77,6 +77,17 @@ ConsumerBase::ConsumerBase(const sp<BufferQueue>& bufferQueue) : ConsumerBase::~ConsumerBase() { CB_LOGV("~ConsumerBase"); Mutex::Autolock lock(mMutex); // Verify that abandon() has been called before we get here. This should // be done by ConsumerBase::onLastStrongRef(), but it's possible for a // derived class to override that method and not call // ConsumerBase::onLastStrongRef(). LOG_ALWAYS_FATAL_IF(!mAbandoned, "[%s] ~ConsumerBase was called, but the " "consumer is not abandoned!", mName.string()); } void ConsumerBase::onLastStrongRef(const void* id) { abandon(); } Loading
libs/gui/tests/SurfaceTextureClient_test.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -178,21 +178,21 @@ TEST_F(SurfaceTextureClientTest, EglSwapBuffersAbandonErrorIsEglBadSurface) { EXPECT_EQ(EGL_SUCCESS, eglGetError()); EGLBoolean success = eglMakeCurrent(mEglDisplay, eglSurface, eglSurface, mEglContext); EXPECT_EQ(EGL_TRUE, success); EXPECT_TRUE(success); glClear(GL_COLOR_BUFFER_BIT); success = eglSwapBuffers(mEglDisplay, eglSurface); EXPECT_EQ(EGL_TRUE, success); EXPECT_TRUE(success); mST->abandon(); glClear(GL_COLOR_BUFFER_BIT); success = eglSwapBuffers(mEglDisplay, eglSurface); EXPECT_EQ(EGL_FALSE, success); EXPECT_FALSE(success); EXPECT_EQ(EGL_BAD_SURFACE, eglGetError()); success = eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext); ASSERT_EQ(EGL_TRUE, success); ASSERT_TRUE(success); if (eglSurface != EGL_NO_SURFACE) { eglDestroySurface(mEglDisplay, eglSurface); Loading
libs/gui/tests/SurfaceTexture_test.cpp +12 −12 Original line number Diff line number Diff line Loading @@ -716,18 +716,18 @@ TEST_F(SurfaceTextureGLTest, TexturingFromCpuFilledYV12BufferNpot) { glViewport(0, 0, texWidth, texHeight); drawTexture(); EXPECT_TRUE(checkPixel( 0, 0, 255, 127, 255, 255)); EXPECT_TRUE(checkPixel(63, 0, 0, 133, 0, 255)); EXPECT_TRUE(checkPixel(63, 65, 0, 133, 0, 255)); EXPECT_TRUE(checkPixel( 0, 65, 255, 127, 255, 255)); EXPECT_TRUE(checkPixel(22, 44, 255, 127, 255, 255)); EXPECT_TRUE(checkPixel(45, 52, 255, 127, 255, 255)); EXPECT_TRUE(checkPixel(52, 51, 98, 255, 73, 255)); EXPECT_TRUE(checkPixel( 7, 31, 155, 0, 118, 255)); EXPECT_TRUE(checkPixel(31, 9, 107, 24, 87, 255)); EXPECT_TRUE(checkPixel(29, 35, 255, 127, 255, 255)); EXPECT_TRUE(checkPixel(36, 22, 155, 29, 0, 255)); EXPECT_TRUE(checkPixel( 0, 0, 255, 127, 255, 255, 3)); EXPECT_TRUE(checkPixel(63, 0, 0, 133, 0, 255, 3)); EXPECT_TRUE(checkPixel(63, 65, 0, 133, 0, 255, 3)); EXPECT_TRUE(checkPixel( 0, 65, 255, 127, 255, 255, 3)); EXPECT_TRUE(checkPixel(22, 44, 255, 127, 255, 255, 3)); EXPECT_TRUE(checkPixel(45, 52, 255, 127, 255, 255, 3)); EXPECT_TRUE(checkPixel(52, 51, 98, 255, 73, 255, 3)); EXPECT_TRUE(checkPixel( 7, 31, 155, 0, 118, 255, 3)); EXPECT_TRUE(checkPixel(31, 9, 107, 24, 87, 255, 3)); EXPECT_TRUE(checkPixel(29, 35, 255, 127, 255, 255, 3)); EXPECT_TRUE(checkPixel(36, 22, 155, 29, 0, 255, 3)); } TEST_F(SurfaceTextureGLTest, TexturingFromCpuFilledYV12BufferPow2) { Loading