Loading include/gui/SurfaceTexture.h +10 −2 Original line number Diff line number Diff line Loading @@ -79,7 +79,11 @@ public: // pointed to by the buf argument and a status of OK is returned. If no // slot is available then a status of -EBUSY is returned and buf is // unmodified. virtual status_t dequeueBuffer(int *buf, uint32_t w, uint32_t h, // The width and height parameters must be no greater than the minimum of // GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see: glGetIntegerv). // An error due to invalid dimensions might not be reported until // updateTexImage() is called. virtual status_t dequeueBuffer(int *buf, uint32_t width, uint32_t height, uint32_t format, uint32_t usage); // queueBuffer returns a filled buffer to the SurfaceTexture. In addition, a Loading Loading @@ -176,7 +180,11 @@ public: // requestBuffers when a with and height of zero is requested. // A call to setDefaultBufferSize() may trigger requestBuffers() to // be called from the client. status_t setDefaultBufferSize(uint32_t w, uint32_t h); // The width and height parameters must be no greater than the minimum of // GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see: glGetIntegerv). // An error due to invalid dimensions might not be reported until // updateTexImage() is called. status_t setDefaultBufferSize(uint32_t width, uint32_t height); // getCurrentBuffer returns the buffer associated with the current image. sp<GraphicBuffer> getCurrentBuffer() const; Loading libs/gui/tests/SurfaceTexture_test.cpp +32 −0 Original line number Diff line number Diff line Loading @@ -1520,4 +1520,36 @@ TEST_F(SurfaceTextureGLTest, EglDestroySurfaceAfterAbandonUnrefsBuffers) { EXPECT_EQ(1, buffers[2]->getStrongCount()); } TEST_F(SurfaceTextureGLTest, InvalidWidthOrHeightFails) { int texHeight = 16; ANativeWindowBuffer* anb; GLint maxTextureSize; glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); // make sure it works with small textures mST->setDefaultBufferSize(16, texHeight); EXPECT_EQ(NO_ERROR, mANW->dequeueBuffer(mANW.get(), &anb)); EXPECT_EQ(16, anb->width); EXPECT_EQ(texHeight, anb->height); EXPECT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), anb)); EXPECT_EQ(NO_ERROR, mST->updateTexImage()); // make sure it works with GL_MAX_TEXTURE_SIZE mST->setDefaultBufferSize(maxTextureSize, texHeight); EXPECT_EQ(NO_ERROR, mANW->dequeueBuffer(mANW.get(), &anb)); EXPECT_EQ(maxTextureSize, anb->width); EXPECT_EQ(texHeight, anb->height); EXPECT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), anb)); EXPECT_EQ(NO_ERROR, mST->updateTexImage()); // make sure it fails with GL_MAX_TEXTURE_SIZE+1 mST->setDefaultBufferSize(maxTextureSize+1, texHeight); EXPECT_EQ(NO_ERROR, mANW->dequeueBuffer(mANW.get(), &anb)); EXPECT_EQ(maxTextureSize+1, anb->width); EXPECT_EQ(texHeight, anb->height); EXPECT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), anb)); ASSERT_NE(NO_ERROR, mST->updateTexImage()); } } // namespace android Loading
include/gui/SurfaceTexture.h +10 −2 Original line number Diff line number Diff line Loading @@ -79,7 +79,11 @@ public: // pointed to by the buf argument and a status of OK is returned. If no // slot is available then a status of -EBUSY is returned and buf is // unmodified. virtual status_t dequeueBuffer(int *buf, uint32_t w, uint32_t h, // The width and height parameters must be no greater than the minimum of // GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see: glGetIntegerv). // An error due to invalid dimensions might not be reported until // updateTexImage() is called. virtual status_t dequeueBuffer(int *buf, uint32_t width, uint32_t height, uint32_t format, uint32_t usage); // queueBuffer returns a filled buffer to the SurfaceTexture. In addition, a Loading Loading @@ -176,7 +180,11 @@ public: // requestBuffers when a with and height of zero is requested. // A call to setDefaultBufferSize() may trigger requestBuffers() to // be called from the client. status_t setDefaultBufferSize(uint32_t w, uint32_t h); // The width and height parameters must be no greater than the minimum of // GL_MAX_VIEWPORT_DIMS and GL_MAX_TEXTURE_SIZE (see: glGetIntegerv). // An error due to invalid dimensions might not be reported until // updateTexImage() is called. status_t setDefaultBufferSize(uint32_t width, uint32_t height); // getCurrentBuffer returns the buffer associated with the current image. sp<GraphicBuffer> getCurrentBuffer() const; Loading
libs/gui/tests/SurfaceTexture_test.cpp +32 −0 Original line number Diff line number Diff line Loading @@ -1520,4 +1520,36 @@ TEST_F(SurfaceTextureGLTest, EglDestroySurfaceAfterAbandonUnrefsBuffers) { EXPECT_EQ(1, buffers[2]->getStrongCount()); } TEST_F(SurfaceTextureGLTest, InvalidWidthOrHeightFails) { int texHeight = 16; ANativeWindowBuffer* anb; GLint maxTextureSize; glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); // make sure it works with small textures mST->setDefaultBufferSize(16, texHeight); EXPECT_EQ(NO_ERROR, mANW->dequeueBuffer(mANW.get(), &anb)); EXPECT_EQ(16, anb->width); EXPECT_EQ(texHeight, anb->height); EXPECT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), anb)); EXPECT_EQ(NO_ERROR, mST->updateTexImage()); // make sure it works with GL_MAX_TEXTURE_SIZE mST->setDefaultBufferSize(maxTextureSize, texHeight); EXPECT_EQ(NO_ERROR, mANW->dequeueBuffer(mANW.get(), &anb)); EXPECT_EQ(maxTextureSize, anb->width); EXPECT_EQ(texHeight, anb->height); EXPECT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), anb)); EXPECT_EQ(NO_ERROR, mST->updateTexImage()); // make sure it fails with GL_MAX_TEXTURE_SIZE+1 mST->setDefaultBufferSize(maxTextureSize+1, texHeight); EXPECT_EQ(NO_ERROR, mANW->dequeueBuffer(mANW.get(), &anb)); EXPECT_EQ(maxTextureSize+1, anb->width); EXPECT_EQ(texHeight, anb->height); EXPECT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), anb)); ASSERT_NE(NO_ERROR, mST->updateTexImage()); } } // namespace android