Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 48 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
| 49 #include "gpu/command_buffer/service/shader_manager.h" | 49 #include "gpu/command_buffer/service/shader_manager.h" |
| 50 #include "gpu/command_buffer/service/shader_translator.h" | 50 #include "gpu/command_buffer/service/shader_translator.h" |
| 51 #include "gpu/command_buffer/service/shader_translator_cache.h" | 51 #include "gpu/command_buffer/service/shader_translator_cache.h" |
| 52 #include "gpu/command_buffer/service/stream_texture.h" | 52 #include "gpu/command_buffer/service/stream_texture.h" |
| 53 #include "gpu/command_buffer/service/stream_texture_manager.h" | 53 #include "gpu/command_buffer/service/stream_texture_manager.h" |
| 54 #include "gpu/command_buffer/service/texture_definition.h" | 54 #include "gpu/command_buffer/service/texture_definition.h" |
| 55 #include "gpu/command_buffer/service/texture_manager.h" | 55 #include "gpu/command_buffer/service/texture_manager.h" |
| 56 #include "gpu/command_buffer/service/vertex_attrib_manager.h" | 56 #include "gpu/command_buffer/service/vertex_attrib_manager.h" |
| 57 #include "gpu/command_buffer/service/vertex_array_manager.h" | 57 #include "gpu/command_buffer/service/vertex_array_manager.h" |
| 58 #include "ui/gl/async_pixel_transfer_delegate.h" | |
| 58 #include "ui/gl/gl_image.h" | 59 #include "ui/gl/gl_image.h" |
| 59 #include "ui/gl/gl_implementation.h" | 60 #include "ui/gl/gl_implementation.h" |
| 60 #include "ui/gl/gl_surface.h" | 61 #include "ui/gl/gl_surface.h" |
| 61 #if defined(OS_MACOSX) | 62 #if defined(OS_MACOSX) |
| 62 #include "ui/surface/io_surface_support_mac.h" | 63 #include "ui/surface/io_surface_support_mac.h" |
| 63 #endif | 64 #endif |
| 64 | 65 |
| 65 #if !defined(GL_DEPTH24_STENCIL8) | 66 #if !defined(GL_DEPTH24_STENCIL8) |
| 66 #define GL_DEPTH24_STENCIL8 0x88F0 | 67 #define GL_DEPTH24_STENCIL8 0x88F0 |
| 67 #endif | 68 #endif |
| (...skipping 9324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9392 return error::kNoError; | 9393 return error::kNoError; |
| 9393 } | 9394 } |
| 9394 if (!validators_->pixel_type.IsValid(type)) { | 9395 if (!validators_->pixel_type.IsValid(type)) { |
| 9395 SetGLErrorInvalidEnum("glTexSubImage2D", type, "type"); | 9396 SetGLErrorInvalidEnum("glTexSubImage2D", type, "type"); |
| 9396 return error::kNoError; | 9397 return error::kNoError; |
| 9397 } | 9398 } |
| 9398 if (pixels == NULL) { | 9399 if (pixels == NULL) { |
| 9399 return error::kOutOfBounds; | 9400 return error::kOutOfBounds; |
| 9400 } | 9401 } |
| 9401 | 9402 |
| 9402 // TODO(epenner): Do this via an async task. | 9403 // We only support async uploads to 2D textures for now. |
| 9403 DoTexSubImage2D( | 9404 if (target != GL_TEXTURE_2D) { |
| 9404 target, level, xoffset, yoffset, width, height, format, type, pixels); | 9405 SetGLErrorInvalidEnum("glTexSubImage2D", type, "type"); |
|
greggman
2012/12/05 02:23:42
s/glTexSubImage2D/glAsyncTexSubImage2DCHROMIUM/
h
epenner
2012/12/08 03:15:03
Done.
| |
| 9406 return error::kNoError; | |
| 9407 } | |
| 9408 | |
| 9409 // We only support uploads to level zero for now. | |
| 9410 if (level != 0) { | |
| 9411 SetGLError(GL_INVALID_VALUE, "glTexSubImage2D", "level != 0"); | |
| 9412 return error::kNoError; | |
| 9413 } | |
| 9414 | |
| 9415 const TextureUnit& unit = state_.texture_units[state_.active_texture_unit]; | |
| 9416 TextureManager::TextureInfo* info = unit.bound_texture_2d; | |
| 9417 | |
| 9418 // 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.
| |
| 9419 // async upload. However this clear is rarely needed anyway. | |
| 9420 GLsizei tex_width = 0; | |
| 9421 GLsizei tex_height = 0; | |
| 9422 bool ok = info->GetLevelSize(target, level, &tex_width, &tex_height); | |
| 9423 DCHECK(ok); | |
| 9424 if (xoffset != 0 || yoffset != 0 || | |
| 9425 width != tex_width || height != tex_height) { | |
| 9426 if (!texture_manager()->ClearTextureLevel(this, info, target, level)) { | |
| 9427 SetGLError(GL_OUT_OF_MEMORY, "glTexSubImage2D", "dimensions too big"); | |
| 9428 return error::kNoError; | |
| 9429 } | |
| 9430 } | |
| 9431 | |
| 9432 // TODO(epenner): The level is technically not cleared yet! | |
| 9433 // However we need to mark it as cleared to use the texture. | |
| 9434 // It looks like we need to mark as cleared in an async reply. | |
| 9435 texture_manager()->SetLevelCleared(info, target, level); | |
| 9436 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
| |
| 9437 info->AsyncTransferState(), target, level, xoffset, yoffset, | |
| 9438 width, height, format, type, pixels); | |
| 9439 | |
| 9405 return error::kNoError; | 9440 return error::kNoError; |
| 9406 } | 9441 } |
| 9407 | 9442 |
| 9408 // Include the auto-generated part of this file. We split this because it means | 9443 // Include the auto-generated part of this file. We split this because it means |
| 9409 // we can easily edit the non-auto generated parts right here in this file | 9444 // we can easily edit the non-auto generated parts right here in this file |
| 9410 // instead of having to edit some template or the code generator. | 9445 // instead of having to edit some template or the code generator. |
| 9411 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 9446 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 9412 | 9447 |
| 9413 } // namespace gles2 | 9448 } // namespace gles2 |
| 9414 } // namespace gpu | 9449 } // namespace gpu |
| OLD | NEW |