Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1263)

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc

Issue 1401423003: Re-land: ui: Move GLImage::BindTexImage fallback from GLImage implementations to GLES2CmdDecoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix unit tests and avoid unnecessary teximage2d call in decoder Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc
index 89dec15acd0cef4cc0ece6cf5dba74552742bbde..9a8d7945928d298a0f5e31d8f511cc99c82e0712 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc
@@ -2627,7 +2627,7 @@ TEST_P(GLES2DecoderTest, BindTexImage2DCHROMIUM) {
EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format));
EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format);
EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type);
- EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL);
+ EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, nullptr) == nullptr);
// Bind image to texture.
// ScopedGLErrorSuppressor calls GetError on its constructor and destructor.
@@ -2635,7 +2635,7 @@ TEST_P(GLES2DecoderTest, BindTexImage2DCHROMIUM) {
EXPECT_TRUE(
texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr));
// Image should now be set.
- EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL);
+ EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 0, nullptr) == nullptr);
// Define new texture image.
DoTexImage2D(
@@ -2643,7 +2643,7 @@ TEST_P(GLES2DecoderTest, BindTexImage2DCHROMIUM) {
EXPECT_TRUE(
texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr));
// Image should no longer be set.
- EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL);
+ EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, nullptr) == nullptr);
}
TEST_P(GLES2DecoderTest, BindTexImage2DCHROMIUMCubeMapNotAllowed) {
@@ -2669,10 +2669,10 @@ TEST_P(GLES2DecoderTest, OrphanGLImageWithTexImage2D) {
ASSERT_TRUE(texture_ref != NULL);
Texture* texture = texture_ref->texture();
- EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get());
+ EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, nullptr) == image.get());
DoTexImage2D(
GL_TEXTURE_2D, 0, GL_RGBA, 3, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0);
- EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL);
+ EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, nullptr) == nullptr);
}
TEST_P(GLES2DecoderTest, GLImageAttachedAfterSubTexImage2D) {
@@ -2710,7 +2710,7 @@ TEST_P(GLES2DecoderTest, GLImageAttachedAfterSubTexImage2D) {
group().texture_manager()->GetTexture(client_texture_id_);
ASSERT_TRUE(texture_ref != NULL);
Texture* texture = texture_ref->texture();
- EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get());
+ EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, nullptr) == image.get());
// TexSubImage2D should not unbind GLImage.
EXPECT_CALL(*gl_, TexSubImage2D(target, level, xoffset, yoffset, width,
@@ -2722,7 +2722,7 @@ TEST_P(GLES2DecoderTest, GLImageAttachedAfterSubTexImage2D) {
format, type, pixels_shm_id, pixels_shm_offset,
internal);
EXPECT_EQ(error::kNoError, ExecuteCmd(tex_sub_image_2d_cmd));
- EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get());
+ EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, nullptr) == image.get());
}
TEST_P(GLES2DecoderTest, GLImageAttachedAfterClearLevel) {
@@ -2754,7 +2754,7 @@ TEST_P(GLES2DecoderTest, GLImageAttachedAfterClearLevel) {
group().texture_manager()->GetTexture(client_texture_id_);
ASSERT_TRUE(texture_ref != NULL);
Texture* texture = texture_ref->texture();
- EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get());
+ EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, nullptr) == image.get());
// ClearLevel should use glTexSubImage2D to avoid unbinding GLImage.
EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId))
@@ -2766,7 +2766,7 @@ TEST_P(GLES2DecoderTest, GLImageAttachedAfterClearLevel) {
.RetiresOnSaturation();
GetDecoder()->ClearLevel(texture, target, level, format, type, 0, 0, width,
height);
- EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == image.get());
+ EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, nullptr) == image.get());
}
TEST_P(GLES2DecoderTest, ReleaseTexImage2DCHROMIUM) {
@@ -2795,7 +2795,7 @@ TEST_P(GLES2DecoderTest, ReleaseTexImage2DCHROMIUM) {
EXPECT_TRUE(texture->GetLevelType(GL_TEXTURE_2D, 0, &type, &internal_format));
EXPECT_EQ(static_cast<GLenum>(GL_RGBA), internal_format);
EXPECT_EQ(static_cast<GLenum>(GL_UNSIGNED_BYTE), type);
- EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL);
+ EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, nullptr) == nullptr);
// Bind image to texture.
// ScopedGLErrorSuppressor calls GetError on its constructor and destructor.
@@ -2803,7 +2803,7 @@ TEST_P(GLES2DecoderTest, ReleaseTexImage2DCHROMIUM) {
EXPECT_TRUE(
texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr));
// Image should now be set.
- EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL);
+ EXPECT_FALSE(texture->GetLevelImage(GL_TEXTURE_2D, 0, nullptr) == nullptr);
// Release image from texture.
// ScopedGLErrorSuppressor calls GetError on its constructor and destructor.
@@ -2817,7 +2817,7 @@ TEST_P(GLES2DecoderTest, ReleaseTexImage2DCHROMIUM) {
EXPECT_TRUE(
texture->GetLevelSize(GL_TEXTURE_2D, 0, &width, &height, nullptr));
// Image should no longer be set.
- EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0) == NULL);
+ EXPECT_TRUE(texture->GetLevelImage(GL_TEXTURE_2D, 0, nullptr) == nullptr);
}
class MockGLImage : public gfx::GLImage {
@@ -2830,12 +2830,9 @@ class MockGLImage : public gfx::GLImage {
MOCK_METHOD1(Destroy, void(bool));
MOCK_METHOD1(BindTexImage, bool(unsigned));
MOCK_METHOD1(ReleaseTexImage, void(unsigned));
+ MOCK_METHOD1(CopyTexImage, bool(unsigned));
MOCK_METHOD3(CopyTexSubImage,
bool(unsigned, const gfx::Point&, const gfx::Rect&));
- MOCK_METHOD0(WillUseTexImage, void());
- MOCK_METHOD0(DidUseTexImage, void());
- MOCK_METHOD0(WillModifyTexImage, void());
- MOCK_METHOD0(DidModifyTexImage, void());
MOCK_METHOD5(ScheduleOverlayPlane, bool(gfx::AcceleratedWidget,
int,
gfx::OverlayTransform,
@@ -2850,7 +2847,7 @@ class MockGLImage : public gfx::GLImage {
virtual ~MockGLImage() {}
};
-TEST_P(GLES2DecoderWithShaderTest, UseTexImage) {
+TEST_P(GLES2DecoderWithShaderTest, CopyTexImage) {
DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
DoTexImage2D(GL_TEXTURE_2D,
0,
@@ -2876,12 +2873,16 @@ TEST_P(GLES2DecoderWithShaderTest, UseTexImage) {
// Bind image to texture.
EXPECT_CALL(*image.get(), BindTexImage(GL_TEXTURE_2D))
.Times(1)
- .WillOnce(Return(true))
+ .WillOnce(Return(false))
.RetiresOnSaturation();
EXPECT_CALL(*image.get(), GetSize())
.Times(1)
.WillOnce(Return(gfx::Size(1, 1)))
.RetiresOnSaturation();
+ EXPECT_CALL(*image.get(), GetInternalFormat())
+ .Times(1)
+ .WillOnce(Return(GL_RGBA))
+ .RetiresOnSaturation();
// ScopedGLErrorSuppressor calls GetError on its constructor and destructor.
DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId);
@@ -2892,12 +2893,12 @@ TEST_P(GLES2DecoderWithShaderTest, UseTexImage) {
EXPECT_CALL(*gl_, GetError())
.WillOnce(Return(GL_NO_ERROR))
.WillOnce(Return(GL_NO_ERROR))
- .WillOnce(Return(GL_NO_ERROR))
- .WillOnce(Return(GL_NO_ERROR))
.RetiresOnSaturation();
- EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(3).RetiresOnSaturation();
- EXPECT_CALL(*image.get(), WillUseTexImage()).Times(1).RetiresOnSaturation();
- EXPECT_CALL(*image.get(), DidUseTexImage()).Times(1).RetiresOnSaturation();
+ EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(2).RetiresOnSaturation();
+ EXPECT_CALL(*image.get(), CopyTexImage(GL_TEXTURE_2D))
+ .Times(1)
+ .WillOnce(Return(true))
+ .RetiresOnSaturation();
EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
.Times(1)
.RetiresOnSaturation();
@@ -2906,6 +2907,25 @@ TEST_P(GLES2DecoderWithShaderTest, UseTexImage) {
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
EXPECT_EQ(GL_NO_ERROR, GetGLError());
+ DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
+ // Re-bind image to texture.
+ ReleaseTexImage2DCHROMIUM release_tex_image_2d_cmd;
+ release_tex_image_2d_cmd.Init(GL_TEXTURE_2D, kImageId);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(release_tex_image_2d_cmd));
+ EXPECT_CALL(*image.get(), BindTexImage(GL_TEXTURE_2D))
+ .Times(1)
+ .WillOnce(Return(false))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*image.get(), GetSize())
+ .Times(1)
+ .WillOnce(Return(gfx::Size(1, 1)))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*image.get(), GetInternalFormat())
+ .Times(1)
+ .WillOnce(Return(GL_RGBA))
+ .RetiresOnSaturation();
+ DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId);
+
DoBindFramebuffer(
GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId);
// ScopedGLErrorSuppressor calls GetError on its constructor and destructor.
@@ -2917,8 +2937,10 @@ TEST_P(GLES2DecoderWithShaderTest, UseTexImage) {
EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId))
.Times(2)
.RetiresOnSaturation();
- // Image will be 'in use' as long as bound to a framebuffer.
- EXPECT_CALL(*image.get(), WillUseTexImage()).Times(1).RetiresOnSaturation();
+ EXPECT_CALL(*image.get(), CopyTexImage(GL_TEXTURE_2D))
+ .Times(1)
+ .WillOnce(Return(true))
+ .RetiresOnSaturation();
EXPECT_CALL(*gl_,
FramebufferTexture2DEXT(GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0,
@@ -2939,34 +2961,8 @@ TEST_P(GLES2DecoderWithShaderTest, UseTexImage) {
EXPECT_EQ(error::kNoError, ExecuteCmd(fbtex_cmd));
EXPECT_EQ(GL_NO_ERROR, GetGLError());
- // ScopedGLErrorSuppressor calls GetError on its constructor and destructor.
- EXPECT_CALL(*gl_, GetError())
- .WillOnce(Return(GL_NO_ERROR))
- .WillOnce(Return(GL_NO_ERROR))
- .RetiresOnSaturation();
- EXPECT_CALL(*gl_,
- FramebufferRenderbufferEXT(GL_FRAMEBUFFER,
- GL_COLOR_ATTACHMENT0,
- GL_RENDERBUFFER,
- kServiceRenderbufferId))
- .Times(1)
- .RetiresOnSaturation();
- EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation();
- EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId))
- .Times(2)
- .RetiresOnSaturation();
- // Image should no longer be 'in use' after being unbound from framebuffer.
- EXPECT_CALL(*image.get(), DidUseTexImage()).Times(1).RetiresOnSaturation();
- EXPECT_CALL(*gl_, GetError())
- .WillOnce(Return(GL_NO_ERROR))
- .WillOnce(Return(GL_NO_ERROR))
- .RetiresOnSaturation();
- FramebufferRenderbuffer fbrb_cmd;
- fbrb_cmd.Init(GL_FRAMEBUFFER,
- GL_COLOR_ATTACHMENT0,
- GL_RENDERBUFFER,
- client_renderbuffer_id_);
- EXPECT_EQ(error::kNoError, ExecuteCmd(fbrb_cmd));
+ EXPECT_CALL(*image.get(), Destroy(true)).Times(1).RetiresOnSaturation();
+ image = nullptr;
}
TEST_P(GLES2DecoderManualInitTest, DrawWithGLImageExternal) {
@@ -2986,8 +2982,8 @@ TEST_P(GLES2DecoderManualInitTest, DrawWithGLImageExternal) {
group().texture_manager()->SetLevelInfo(texture_ref, GL_TEXTURE_EXTERNAL_OES,
0, GL_RGBA, 0, 0, 1, 0, GL_RGBA,
GL_UNSIGNED_BYTE, gfx::Rect());
- group().texture_manager()->SetLevelImage(
- texture_ref, GL_TEXTURE_EXTERNAL_OES, 0, image.get());
+ group().texture_manager()->SetLevelImage(texture_ref, GL_TEXTURE_EXTERNAL_OES,
+ 0, image.get(), Texture::BOUND);
DoBindTexture(GL_TEXTURE_EXTERNAL_OES, client_texture_id_, kServiceTextureId);
EXPECT_EQ(GL_NO_ERROR, GetGLError());
@@ -2999,24 +2995,7 @@ TEST_P(GLES2DecoderManualInitTest, DrawWithGLImageExternal) {
EXPECT_TRUE(group().texture_manager()->CanRender(texture_ref));
InSequence s;
- EXPECT_CALL(*gl_, GetError())
- .WillOnce(Return(GL_NO_ERROR))
- .RetiresOnSaturation();
- EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation();
- EXPECT_CALL(*image.get(), WillUseTexImage()).Times(1).RetiresOnSaturation();
- EXPECT_CALL(*gl_, GetError())
- .WillOnce(Return(GL_NO_ERROR))
- .RetiresOnSaturation();
EXPECT_CALL(*gl_, DrawElements(_, _, _, _)).Times(1);
- EXPECT_CALL(*gl_, GetError())
- .WillOnce(Return(GL_NO_ERROR))
- .RetiresOnSaturation();
- EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation();
- EXPECT_CALL(*image.get(), DidUseTexImage()).Times(1).RetiresOnSaturation();
- EXPECT_CALL(*gl_, GetError())
- .WillOnce(Return(GL_NO_ERROR))
- .RetiresOnSaturation();
- EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation();
DrawElements cmd;
cmd.Init(GL_TRIANGLES,
kValidIndexRangeCount,

Powered by Google App Engine
This is Rietveld 408576698