Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 10543125: gpu: Add support for GLX_EXT_texture_from_pixmap extension. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove .gitmodules change. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 81ecee496c9c70038085eb2f2be1fe5c023cf8ab..b0907c4319b6ed04f7affdbcfb8146cc96d0942d 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -50,6 +50,7 @@
#include "gpu/command_buffer/service/texture_manager.h"
#include "gpu/command_buffer/service/vertex_attrib_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)
@@ -765,6 +766,11 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
GLsizei width,
GLsizei height);
+ // Wrapper for TexImagePixmap2DCHROMIUM.
+ void DoTexImagePixmap2DCHROMIUM(
+ GLenum target,
+ GLuint pixmap_id);
+
void DoProduceTextureCHROMIUM(GLenum target, const GLbyte* key);
void DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* key);
@@ -1261,6 +1267,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);
@@ -8802,18 +8818,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
@@ -9189,6 +9202,62 @@ void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target,
BindAndApplyTextureParameters(info);
}
+void GLES2DecoderImpl::DoTexImagePixmap2DCHROMIUM(
+ GLenum target, GLuint pixmap_id) {
+ if (target != GL_TEXTURE_2D) {
+ // This might be supported in the future.
+ SetGLError(
+ GL_INVALID_OPERATION,
+ "glTexImagePixmap2DCHROMIUM", "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,
+ "glTexImagePixmap2DCHROMIUM", "no texture bound");
+ return;
+ }
+
+ scoped_refptr<gfx::GLImage> pixmap_gl_image = info->GetLevelImage(target, 0);
+ if (pixmap_id) {
+ if (!pixmap_gl_image) {
+ pixmap_gl_image = gfx::GLImage::CreatePixmapGLImage(surface_);
+ if (!pixmap_gl_image) {
+ SetGLError(GL_INVALID_OPERATION,
+ "glTexImagePixmap2DCHROMIUM",
+ "fail to create PixmapGLImage");
+ return;
+ }
+ }
+
+ // Update GL image and bind to texture.
+ if (!pixmap_gl_image->RebindPixmap(pixmap_id)) {
+ SetGLError(GL_INVALID_OPERATION,
+ "glTexImagePixmap2DCHROMIUM",
+ "fail to bind Pixmap with the given ID");
+ return;
+ }
+
+ gfx::Size size = pixmap_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);
+ texture_manager()->SetLevelImage(info, target, 0, pixmap_gl_image);
+ } else {
+ // Release pixmap image previously bound to this texture.
+ if (pixmap_gl_image)
+ pixmap_gl_image->RebindPixmap(0);
+
+ texture_manager()->SetLevelInfo(
+ info, 0, 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
// instead of having to edit some template or the code generator.

Powered by Google App Engine
This is Rietveld 408576698