summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authordongseong.hwang <dongseong.hwang@intel.com>2015-01-21 06:33:59 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-21 14:35:59 +0000
commit351519fd09084647cd154169c0d1f99181e029bb (patch)
treee1285b46f4d2d1e701e6fe613de66a253c2bfa72 /gpu
parentf4bdb54c848a8152503f37be998899c3236b114a (diff)
downloadchromium_src-351519fd09084647cd154169c0d1f99181e029bb.zip
chromium_src-351519fd09084647cd154169c0d1f99181e029bb.tar.gz
chromium_src-351519fd09084647cd154169c0d1f99181e029bb.tar.bz2
gpu: Don't clear texture level in DoCopyTexSubImage2D() if not needed.
This optimization is similar to one of TexSubImage2D(). TEST=Service/GLES2DecoderTest.CopyTexSubImage2DClearsUnclearedBackBufferSizedTexture Review URL: https://codereview.chromium.org/824173003 Cr-Commit-Position: refs/heads/master@{#312371}
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc15
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc26
2 files changed, 37 insertions, 4 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 0d778f3..f56d47b 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -9145,10 +9145,17 @@ void GLES2DecoderImpl::DoCopyTexSubImage2D(
Clip(x, width, size.width(), &copyX, &copyWidth);
Clip(y, height, size.height(), &copyY, &copyHeight);
- if (!texture_manager()->ClearTextureLevel(this, texture_ref, target, level)) {
- LOCAL_SET_GL_ERROR(
- GL_OUT_OF_MEMORY, "glCopyTexSubImage2D", "dimensions too big");
- return;
+ if (xoffset != 0 || yoffset != 0 || width != size.width() ||
+ height != size.height()) {
+ if (!texture_manager()->ClearTextureLevel(this, texture_ref, target,
+ level)) {
+ LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, "glCopyTexSubImage2D",
+ "dimensions too big");
+ return;
+ }
+ } else {
+ // Write all pixels in below.
+ texture_manager()->SetLevelCleared(texture_ref, target, level, true);
}
if (copyX != x ||
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 b0e8e8c..f0cadf1 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_textures.cc
@@ -1803,6 +1803,32 @@ TEST_P(GLES2DecoderTest, CopyTexSubImage2DClearsUnclearedTexture) {
CopyTexSubImage2D cmd;
cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+
+ TextureManager* manager = group().texture_manager();
+ TextureRef* texture_ref = manager->GetTexture(client_texture_id_);
+ ASSERT_TRUE(texture_ref != NULL);
+ Texture* texture = texture_ref->texture();
+ EXPECT_TRUE(texture->SafeToRenderFrom());
+}
+
+TEST_P(GLES2DecoderTest, CopyTexSubImage2DClearsUnclearedBackBufferSizedTexture) {
+ DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId);
+ DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kBackBufferWidth, kBackBufferHeight,
+ 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0);
+
+ EXPECT_CALL(*gl_, CopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0,
+ kBackBufferWidth, kBackBufferHeight))
+ .Times(1)
+ .RetiresOnSaturation();
+ CopyTexSubImage2D cmd;
+ cmd.Init(GL_TEXTURE_2D, 0, 0, 0, 0, 0, kBackBufferWidth, kBackBufferHeight);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+
+ TextureManager* manager = group().texture_manager();
+ TextureRef* texture_ref = manager->GetTexture(client_texture_id_);
+ ASSERT_TRUE(texture_ref != NULL);
+ Texture* texture = texture_ref->texture();
+ EXPECT_TRUE(texture->SafeToRenderFrom());
}
TEST_P(GLES2DecoderManualInitTest, CompressedImage2DMarksTextureAsCleared) {