Index: gpu/command_buffer/service/gles2_cmd_decoder.cc |
=================================================================== |
--- gpu/command_buffer/service/gles2_cmd_decoder.cc (revision 133771) |
+++ gpu/command_buffer/service/gles2_cmd_decoder.cc (working copy) |
@@ -23,6 +23,7 @@ |
#include "base/memory/scoped_ptr.h" |
#include "base/memory/weak_ptr.h" |
#include "build/build_config.h" |
+#include "crypto/symmetric_key.h" |
#define GLES2_GPU_SERVICE 1 |
#include "gpu/command_buffer/common/gles2_cmd_format.h" |
#include "gpu/command_buffer/common/gles2_cmd_utils.h" |
@@ -36,6 +37,7 @@ |
#include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" |
#include "gpu/command_buffer/service/gles2_cmd_validation.h" |
#include "gpu/command_buffer/service/gpu_switches.h" |
+#include "gpu/command_buffer/service/mailbox_manager.h" |
#include "gpu/command_buffer/service/program_manager.h" |
#include "gpu/command_buffer/service/query_manager.h" |
#include "gpu/command_buffer/service/renderbuffer_manager.h" |
@@ -43,6 +45,7 @@ |
#include "gpu/command_buffer/service/shader_translator.h" |
#include "gpu/command_buffer/service/stream_texture.h" |
#include "gpu/command_buffer/service/stream_texture_manager.h" |
+#include "gpu/command_buffer/service/texture_definition.h" |
#include "gpu/command_buffer/service/texture_manager.h" |
#include "gpu/command_buffer/service/vertex_attrib_manager.h" |
#include "ui/gfx/gl/gl_context.h" |
@@ -508,6 +511,9 @@ |
// Sets DEPTH_TEST, STENCIL_TEST and color mask for the current framebuffer. |
void ApplyDirtyState(); |
+ // Reapply the texture parameters to the given texture. |
+ void BindAndApplyTextureParameters(TextureManager::TextureInfo* info); |
+ |
// These check the state of the currently bound framebuffer or the |
// backbuffer if no framebuffer is bound. |
bool BoundFramebufferHasColorAttachmentWithAlpha(); |
@@ -741,6 +747,12 @@ |
GLsizei width, |
GLsizei height); |
+ // Wrapper for SwapTexturesCHROMIUM. |
Ken Russell (switch to Gerrit)
2012/04/26 01:10:53
Wrong comment.
|
+ void DoProduceTextureCHROMIUM(GLenum target, const char* key); |
+ |
+ // Wrapper for TexKeyCHROMIUM. |
Ken Russell (switch to Gerrit)
2012/04/26 01:10:53
Wrong comment.
|
+ void DoConsumeTextureCHROMIUM(GLenum target, const char* key); |
+ |
// Creates a ProgramInfo for the given program. |
ProgramManager::ProgramInfo* CreateProgramInfo( |
GLuint client_id, GLuint service_id) { |
@@ -3263,6 +3275,15 @@ |
} |
} |
+void GLES2DecoderImpl::BindAndApplyTextureParameters( |
+ TextureManager::TextureInfo* info) { |
+ glBindTexture(info->target(), info->service_id()); |
+ glTexParameteri(info->target(), GL_TEXTURE_MIN_FILTER, info->min_filter()); |
+ glTexParameteri(info->target(), GL_TEXTURE_MAG_FILTER, info->mag_filter()); |
+ glTexParameteri(info->target(), GL_TEXTURE_WRAP_S, info->wrap_s()); |
+ glTexParameteri(info->target(), GL_TEXTURE_WRAP_T, info->wrap_t()); |
+} |
+ |
GLuint GLES2DecoderImpl::GetBackbufferServiceId() { |
return (offscreen_target_frame_buffer_.get()) ? |
offscreen_target_frame_buffer_->id() : |
@@ -8502,6 +8523,81 @@ |
} |
} |
+error::Error GLES2DecoderImpl::HandleGenMailboxCHROMIUM( |
+ uint32 immediate_data_size, const gles2::GenMailboxCHROMIUM& c) { |
+ uint32 bucket_id = static_cast<uint32>(c.bucket_id); |
+ Bucket* bucket = CreateBucket(bucket_id); |
+ crypto::SymmetricKey* key = |
+ crypto::SymmetricKey::GenerateRandomKey(crypto::SymmetricKey::AES, |
+ kMailboxSize * 8); |
+ std::string mailbox; |
+ if (!key->GetRawKey(&mailbox)) { |
+ SetGLError(GL_OUT_OF_MEMORY, |
+ "glHandleGenMailboxCHROMIUM: failed to generate mailbox"); |
+ return error::kNoError; |
+ } |
+ |
+ DCHECK(mailbox.length() == kMailboxSize); |
+ |
+ bucket->SetSize(kMailboxSize); |
+ bucket->SetData(&mailbox[0], 0, kMailboxSize); |
+ |
+ return error::kNoError; |
+} |
+ |
+void GLES2DecoderImpl::DoProduceTextureCHROMIUM(GLenum target, |
+ const char* mailbox) { |
+ TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); |
+ if (!info) { |
+ SetGLError(GL_INVALID_OPERATION, |
+ "glProduceTextureCHROMIUM: unknown texture for target"); |
+ return; |
+ } |
+ |
+ TextureDefinition* definition = texture_manager()->Save(info); |
+ if (!definition) { |
+ SetGLError(GL_INVALID_OPERATION, |
+ "glProduceTextureCHROMIUM: invalid texture"); |
+ return; |
+ } |
+ |
+ group_->mailbox_manager()->ProduceTexture( |
greggman
2012/04/26 18:09:18
I'm a little concerned that GenMailbox is optional
|
+ target, |
+ *reinterpret_cast<const MailboxName*>(mailbox), |
+ definition, |
+ texture_manager()); |
+ |
+ BindAndApplyTextureParameters(info); |
+} |
+ |
+void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target, |
+ const char* mailbox) { |
+ TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); |
+ if (!info) { |
+ SetGLError(GL_INVALID_OPERATION, |
+ "glConsumeTextureCHROMIUM: unknown texture for target"); |
+ return; |
+ } |
+ |
+ scoped_ptr<TextureDefinition> definition( |
+ group_->mailbox_manager()->ConsumeTexture( |
+ target, |
+ *reinterpret_cast<const MailboxName*>(mailbox))); |
+ if (!definition.get()) { |
+ SetGLError(GL_INVALID_OPERATION, |
+ "glConsumeTextureCHROMIUM: empty mailbox"); |
+ return; |
+ } |
+ |
+ if (!texture_manager()->Restore(info, definition.release())) { |
+ SetGLError(GL_INVALID_OPERATION, |
+ "glConsumeTextureCHROMIUM: invalid texture"); |
+ return; |
+ } |
+ |
+ BindAndApplyTextureParameters(info); |
+} |
+ |
// Include the auto-generated part of this file. We split this because it means |
// we can easily edit the non-auto generated parts right here in this file |
// instead of having to edit some template or the code generator. |