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 f5d455c019b6933d643463d361f194a6071dc765..c39961ec9966b5283dad55b87ae2adeae931be0f 100644 |
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc |
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc |
@@ -38,6 +38,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/image_manager.h" |
#include "gpu/command_buffer/service/mailbox_manager.h" |
#include "gpu/command_buffer/service/memory_tracking.h" |
#include "gpu/command_buffer/service/program_manager.h" |
@@ -53,6 +54,7 @@ |
#include "gpu/command_buffer/service/vertex_attrib_manager.h" |
#include "gpu/command_buffer/service/vertex_array_manager.h" |
#include "ui/gl/gl_context.h" |
+#include "ui/gl/gl_image.h" |
#include "ui/gl/gl_implementation.h" |
#include "ui/gl/gl_surface.h" |
#if defined(OS_MACOSX) |
@@ -668,6 +670,10 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>, |
return group_->mailbox_manager(); |
} |
+ ImageManager* image_manager() { |
+ return group_->image_manager(); |
+ } |
+ |
VertexArrayManager* vertex_array_manager() { |
return vertex_array_manager_.get(); |
} |
@@ -799,6 +805,13 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>, |
void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key); |
void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key); |
+ void DoBindTexImage2DCHROMIUM( |
+ GLenum target, |
+ GLint image_id); |
+ void DoReleaseTexImage2DCHROMIUM( |
+ GLenum target, |
+ GLint image_id); |
+ |
// Creates a ProgramInfo for the given program. |
ProgramManager::ProgramInfo* CreateProgramInfo( |
GLuint client_id, GLuint service_id) { |
@@ -1319,6 +1332,16 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>, |
return info; |
} |
+ TextureManager::TextureInfo* GetTextureInfoForTargetUnlessDefault( |
+ GLenum target) { |
+ TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); |
+ if (!info) |
+ return NULL; |
+ if (info == texture_manager()->GetDefaultTextureInfo(target)) |
+ return NULL; |
+ return info; |
+ } |
+ |
GLenum GetBindTargetForSamplerType(GLenum type) { |
DCHECK(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || |
type == GL_SAMPLER_EXTERNAL_OES || type == GL_SAMPLER_2D_RECT_ARB); |
@@ -9024,18 +9047,15 @@ void GLES2DecoderImpl::DoTexImageIOSurface2DCHROMIUM( |
return; |
} |
- TextureManager::TextureInfo* info = GetTextureInfoForTarget(target); |
+ // Default target might be conceptually valid, but disallow it to avoid |
+ // accidents. |
+ TextureManager::TextureInfo* info = GetTextureInfoForTargetUnlessDefault( |
+ target); |
if (!info) { |
SetGLError(GL_INVALID_OPERATION, |
"glTexImageIOSurface2DCHROMIUM", "no rectangle texture bound"); |
return; |
} |
- if (info == texture_manager()->GetDefaultTextureInfo(target)) { |
- // Maybe this is conceptually valid, but disallow it to avoid accidents. |
- SetGLError(GL_INVALID_OPERATION, |
- "glTexImageIOSurface2DCHROMIUM", "can't bind default texture"); |
- return; |
- } |
// Look up the new IOSurface. Note that because of asynchrony |
// between processes this might fail; during live resizing the |
@@ -9433,6 +9453,88 @@ void GLES2DecoderImpl::DoPopGroupMarkerEXT(void) { |
debug_marker_manager_.PopGroup(); |
} |
+void GLES2DecoderImpl::DoBindTexImage2DCHROMIUM( |
+ GLenum target, GLint image_id) { |
+ if (target != GL_TEXTURE_2D) { |
+ // This might be supported in the future. |
+ SetGLError( |
+ GL_INVALID_OPERATION, |
+ "glBindTexImage2DCHROMIUM", "requires TEXTURE_2D target"); |
+ return; |
+ } |
+ |
+ // Default target might be conceptually valid, but disallow it to avoid |
+ // accidents. |
+ TextureManager::TextureInfo* info = GetTextureInfoForTargetUnlessDefault( |
+ target); |
+ if (!info) { |
+ SetGLError(GL_INVALID_OPERATION, |
+ "glBindTexImage2DCHROMIUM", "no texture bound"); |
+ return; |
+ } |
+ |
+ scoped_refptr<gfx::GLImage> gl_image = |
+ image_manager()->LookupImage(image_id); |
+ if (!gl_image) { |
+ SetGLError(GL_INVALID_OPERATION, |
+ "glBindTexImage2DCHROMIUM", |
+ "no image found with the given ID"); |
+ return; |
+ } |
+ |
+ if (!gl_image->BindTexImage()) { |
+ SetGLError(GL_INVALID_OPERATION, |
+ "glBindTexImage2DCHROMIUM", |
+ "fail to bind image with the given ID"); |
+ return; |
+ } |
+ |
+ gfx::Size size = gl_image->GetSize(); |
+ texture_manager()->SetLevelInfo( |
+ info, target, 0, GL_RGBA, size.width(), size.height(), 1, 0, |
+ GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, true); |
piman
2012/10/12 22:05:11
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV ?
Technically
reveman
2012/10/13 05:25:53
I don't think it has an effect but I changed to GL
|
+ texture_manager()->SetLevelImage(info, target, 0, gl_image); |
+} |
+ |
+void GLES2DecoderImpl::DoReleaseTexImage2DCHROMIUM( |
+ GLenum target, GLint image_id) { |
+ if (target != GL_TEXTURE_2D) { |
+ // This might be supported in the future. |
+ SetGLError( |
+ GL_INVALID_OPERATION, |
+ "glReleaseTexImage2DCHROMIUM", "requires TEXTURE_2D target"); |
+ return; |
+ } |
+ |
+ // Default target might be conceptually valid, but disallow it to avoid |
+ // accidents. |
+ TextureManager::TextureInfo* info = GetTextureInfoForTargetUnlessDefault( |
+ target); |
+ if (!info) { |
+ SetGLError(GL_INVALID_OPERATION, |
+ "glReleaseTexImage2DCHROMIUM", "no texture bound"); |
+ return; |
+ } |
+ |
+ scoped_refptr<gfx::GLImage> gl_image = |
+ image_manager()->LookupImage(image_id); |
+ if (!gl_image) { |
+ SetGLError(GL_INVALID_OPERATION, |
+ "glReleaseTexImage2DCHROMIUM", |
+ "no image found with the given ID"); |
+ return; |
+ } |
+ |
+ // Do nothing when image is not currently bound. |
+ if (info->GetLevelImage(target, 0) != gl_image) |
+ return; |
+ |
+ gl_image->ReleaseTexImage(); |
+ |
+ texture_manager()->SetLevelInfo( |
+ info, target, 0, GL_RGBA, 0, 0, 1, 0, |
+ GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, false); |
+} |
// 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 |