Index: gpu/command_buffer/service/gles2_cmd_decoder.cc |
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
index 2ec1e96e4a4fbe30f2a81b4996002b4cd88976d3..819f2aaeca9c381d161bc6280be321ee9d7330f4 100644 |
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc |
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
@@ -55,6 +55,7 @@ |
#include "gpu/command_buffer/service/texture_manager.h" |
#include "gpu/command_buffer/service/vertex_attrib_manager.h" |
#include "gpu/command_buffer/service/vertex_array_manager.h" |
+#include "ui/gl/async_pixel_transfer_delegate.h" |
#include "ui/gl/gl_image.h" |
#include "ui/gl/gl_implementation.h" |
#include "ui/gl/gl_surface.h" |
@@ -9399,9 +9400,43 @@ error::Error GLES2DecoderImpl::HandleAsyncTexSubImage2DCHROMIUM( |
return error::kOutOfBounds; |
} |
- // TODO(epenner): Do this via an async task. |
- DoTexSubImage2D( |
- target, level, xoffset, yoffset, width, height, format, type, pixels); |
+ // We only support async uploads to 2D textures for now. |
+ if (target != GL_TEXTURE_2D) { |
+ SetGLErrorInvalidEnum("glTexSubImage2D", type, "type"); |
greggman
2012/12/05 02:23:42
s/glTexSubImage2D/glAsyncTexSubImage2DCHROMIUM/
h
epenner
2012/12/08 03:15:03
Done.
|
+ return error::kNoError; |
+ } |
+ |
+ // We only support uploads to level zero for now. |
+ if (level != 0) { |
+ SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "level != 0"); |
+ return error::kNoError; |
+ } |
+ |
+ const TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; |
+ TextureManager::TextureInfo* info = unit.bound_texture_2d; |
+ |
+ // TODO(epenner): We should really do this level clear as part of the |
apatrick
2012/12/03 21:23:59
It might be a bit tricky to synchronize that. Mayb
epennerAtGoogle
2012/12/03 22:48:45
Hmm.. You are right. If we keep the clear here, th
epennerAtGoogle
2012/12/04 19:56:48
Done.
|
+ // async upload. However this clear is rarely needed anyway. |
+ GLsizei tex_width = 0; |
+ GLsizei tex_height = 0; |
+ bool ok = info->GetLevelSize(target, level, &tex_width, &tex_height); |
+ DCHECK(ok); |
+ if (xoffset != 0 || yoffset != 0 || |
+ width != tex_width || height != tex_height) { |
+ if (!texture_manager()->ClearTextureLevel(this, info, target, level)) { |
+ SetGLError(GL_OUT_OF_MEMORY, "glTexSubImage2D", "dimensions too big"); |
+ return error::kNoError; |
+ } |
+ } |
+ |
+ // TODO(epenner): The level is technically not cleared yet! |
+ // However we need to mark it as cleared to use the texture. |
+ // It looks like we need to mark as cleared in an async reply. |
+ texture_manager()->SetLevelCleared(info, target, level); |
+ gfx::AsyncPixelTransferDelegate::Get()->AsyncTexSubImage2D( |
greggman
2012/12/05 02:23:42
I thought singletons are discouraged in Chromium?
epenner
2012/12/05 04:01:54
It's one of my TODOs. Yeah I wasn't sure initially
|
+ info->AsyncTransferState(), target, level, xoffset, yoffset, |
+ width, height, format, type, pixels); |
+ |
return error::kNoError; |
} |