summaryrefslogtreecommitdiffstats
path: root/ui/gl
diff options
context:
space:
mode:
authorreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-18 15:40:59 +0000
committerreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-18 15:40:59 +0000
commitb63f1d6dc0569a970a43c5a456d38cd543eea27c (patch)
treef3dd7ee9d94aafb84caab814c189c22662c53d6a /ui/gl
parent602b5a29f74202a4c36acfedcf1562f78abfce3c (diff)
downloadchromium_src-b63f1d6dc0569a970a43c5a456d38cd543eea27c.zip
chromium_src-b63f1d6dc0569a970a43c5a456d38cd543eea27c.tar.gz
chromium_src-b63f1d6dc0569a970a43c5a456d38cd543eea27c.tar.bz2
gpu: Remove Create/DeleteImage IPC by adding an X11_PIXMAP_BUFFER GpuMemoryBuffer type.
This adds a new GpuMemoryBuffer type that can be used to create a GpuMemoryBuffer from an existing X11 pixmap. This removes Create/DeleteImage IPC and reduces complexity significantly as it allows the ImageManager to be moved to the decoder and simply track images. A new platform dependent GpuMemoryBufferFactory interface is introduced to allow this new type of buffer to be created on the GPU service side. To avoid the need for any global variables, this factory instance is also responsible for creating GLImage instances. The old factory interface used by android_webview is renamed InProcessGpuMemoryBufferFactory until it can be removed in favor of this new interface. BUG=368716 TEST=gpu_unittests, gl_tests --gtest_filter=GpuMemoryBufferTest.Lifecycle Review URL: https://codereview.chromium.org/331723003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284097 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gl')
-rw-r--r--ui/gl/BUILD.gn13
-rw-r--r--ui/gl/gl.gyp13
-rw-r--r--ui/gl/gl_image.cc10
-rw-r--r--ui/gl/gl_image.h13
-rw-r--r--ui/gl/gl_image_android.cc73
-rw-r--r--ui/gl/gl_image_android_native_buffer.cc11
-rw-r--r--ui/gl/gl_image_android_native_buffer.h4
-rw-r--r--ui/gl/gl_image_egl.cc5
-rw-r--r--ui/gl/gl_image_egl.h4
-rw-r--r--ui/gl/gl_image_glx.cc176
-rw-r--r--ui/gl/gl_image_glx.h10
-rw-r--r--ui/gl/gl_image_io_surface.cc8
-rw-r--r--ui/gl/gl_image_io_surface.h7
-rw-r--r--ui/gl/gl_image_mac.cc67
-rw-r--r--ui/gl/gl_image_memory.cc (renamed from ui/gl/gl_image_shm.cc)77
-rw-r--r--ui/gl/gl_image_memory.h (renamed from ui/gl/gl_image_shm.h)37
-rw-r--r--ui/gl/gl_image_ozone.cc47
-rw-r--r--ui/gl/gl_image_ref_counted_memory.cc37
-rw-r--r--ui/gl/gl_image_ref_counted_memory.h37
-rw-r--r--ui/gl/gl_image_shared_memory.cc58
-rw-r--r--ui/gl/gl_image_shared_memory.h34
-rw-r--r--ui/gl/gl_image_surface_texture.cc12
-rw-r--r--ui/gl/gl_image_surface_texture.h7
-rw-r--r--ui/gl/gl_image_win.cc59
-rw-r--r--ui/gl/gl_image_x11.cc67
25 files changed, 376 insertions, 510 deletions
diff --git a/ui/gl/BUILD.gn b/ui/gl/BUILD.gn
index f336311..2b9e6c5 100644
--- a/ui/gl/BUILD.gn
+++ b/ui/gl/BUILD.gn
@@ -58,13 +58,14 @@ component("gl") {
"gl_gl_api_implementation.h",
"gl_image.cc",
"gl_image.h",
- "gl_image_android.cc",
- "gl_image_mac.cc",
- "gl_image_shm.cc",
- "gl_image_shm.h",
+ "gl_image_memory.cc",
+ "gl_image_memory.h",
+ "gl_image_ref_counted_memory.cc",
+ "gl_image_ref_counted_memory.h",
+ "gl_image_shared_memory.cc",
+ "gl_image_shared_memory.h",
"gl_image_stub.cc",
"gl_image_stub.h",
- "gl_image_win.cc",
"gl_implementation.cc",
"gl_implementation.h",
"gl_implementation_android.cc",
@@ -160,7 +161,6 @@ component("gl") {
"gl_glx_api_implementation.h",
"gl_image_glx.cc",
"gl_image_glx.h",
- "gl_image_x11.cc",
"gl_implementation_x11.cc",
"gl_surface_glx.cc",
"gl_surface_glx.h",
@@ -237,7 +237,6 @@ component("gl") {
if (use_ozone) {
sources += [
"gl_context_ozone.cc",
- "gl_image_ozone.cc",
"gl_implementation_ozone.cc",
"gl_surface_ozone.cc",
]
diff --git a/ui/gl/gl.gyp b/ui/gl/gl.gyp
index 12e8f58..229b21f 100644
--- a/ui/gl/gl.gyp
+++ b/ui/gl/gl.gyp
@@ -79,15 +79,14 @@
'gl_gl_api_implementation.h',
'gl_image.cc',
'gl_image.h',
- 'gl_image_android.cc',
- 'gl_image_mac.cc',
- 'gl_image_ozone.cc',
- 'gl_image_shm.cc',
- 'gl_image_shm.h',
+ 'gl_image_memory.cc',
+ 'gl_image_memory.h',
+ 'gl_image_ref_counted_memory.cc',
+ 'gl_image_ref_counted_memory.h',
+ 'gl_image_shared_memory.cc',
+ 'gl_image_shared_memory.h',
'gl_image_stub.cc',
'gl_image_stub.h',
- 'gl_image_win.cc',
- 'gl_image_x11.cc',
'gl_implementation.cc',
'gl_implementation.h',
'gl_implementation_android.cc',
diff --git a/ui/gl/gl_image.cc b/ui/gl/gl_image.cc
index 967f53c..fe45e44 100644
--- a/ui/gl/gl_image.cc
+++ b/ui/gl/gl_image.cc
@@ -4,16 +4,16 @@
#include "ui/gl/gl_image.h"
-#include "base/logging.h"
-
namespace gfx {
-GLImage::GLImage() {}
+GLImage::GLImage() {
+}
+
+GLImage::~GLImage() {
+}
void GLImage::SetReleaseAfterUse() {
// Default no-op implementation for workaround.
}
-GLImage::~GLImage() {}
-
} // namespace gfx
diff --git a/ui/gl/gl_image.h b/ui/gl/gl_image.h
index 7798423..45303fd 100644
--- a/ui/gl/gl_image.h
+++ b/ui/gl/gl_image.h
@@ -6,15 +6,11 @@
#define UI_GL_GL_IMAGE_H_
#include "base/memory/ref_counted.h"
-#include "ui/gfx/gpu_memory_buffer.h"
-#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/size.h"
#include "ui/gl/gl_export.h"
namespace gfx {
-class GLSurface;
-
// Encapsulates an image that can be bound to a texture, hiding platform
// specific management.
class GL_EXPORT GLImage : public base::RefCounted<GLImage> {
@@ -49,15 +45,6 @@ class GL_EXPORT GLImage : public base::RefCounted<GLImage> {
// (For an Android work-around only).
virtual void SetReleaseAfterUse();
- // Create a GL image for a window.
- static scoped_refptr<GLImage> CreateGLImage(gfx::PluginWindowHandle window);
-
- // Create a GL image for a GPU Memory buffer.
- static scoped_refptr<GLImage> CreateGLImageForGpuMemoryBuffer(
- gfx::GpuMemoryBufferHandle buffer,
- gfx::Size size,
- unsigned internalformat);
-
protected:
virtual ~GLImage();
diff --git a/ui/gl/gl_image_android.cc b/ui/gl/gl_image_android.cc
deleted file mode 100644
index a619c85..0000000
--- a/ui/gl/gl_image_android.cc
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/gl/gl_image.h"
-
-#include "base/debug/trace_event.h"
-#include "ui/gl/gl_image_android_native_buffer.h"
-#include "ui/gl/gl_image_shm.h"
-#include "ui/gl/gl_image_stub.h"
-#include "ui/gl/gl_image_surface_texture.h"
-#include "ui/gl/gl_implementation.h"
-
-namespace gfx {
-
-scoped_refptr<GLImage> GLImage::CreateGLImage(gfx::PluginWindowHandle window) {
- TRACE_EVENT0("gpu", "GLImage::CreateGLImage");
- switch (GetGLImplementation()) {
- case kGLImplementationEGLGLES2:
- return NULL;
- case kGLImplementationMockGL:
- return new GLImageStub;
- default:
- NOTREACHED();
- return NULL;
- }
-}
-
-scoped_refptr<GLImage> GLImage::CreateGLImageForGpuMemoryBuffer(
- gfx::GpuMemoryBufferHandle buffer,
- gfx::Size size,
- unsigned internalformat) {
- TRACE_EVENT0("gpu", "GLImage::CreateGLImageForGpuMemoryBuffer");
- switch (GetGLImplementation()) {
- case kGLImplementationEGLGLES2:
- switch (buffer.type) {
- case SHARED_MEMORY_BUFFER: {
- scoped_refptr<GLImageShm> image(
- new GLImageShm(size, internalformat));
- if (!image->Initialize(buffer))
- return NULL;
-
- return image;
- }
- case ANDROID_NATIVE_BUFFER: {
- scoped_refptr<GLImageAndroidNativeBuffer> image(
- new GLImageAndroidNativeBuffer(size));
- if (!image->Initialize(buffer))
- return NULL;
-
- return image;
- }
- case SURFACE_TEXTURE_BUFFER: {
- scoped_refptr<GLImageSurfaceTexture> image(
- new GLImageSurfaceTexture(size));
- if (!image->Initialize(buffer))
- return NULL;
-
- return image;
- }
- default:
- NOTREACHED();
- return NULL;
- }
- case kGLImplementationMockGL:
- return new GLImageStub;
- default:
- NOTREACHED();
- return NULL;
- }
-}
-
-} // namespace gfx
diff --git a/ui/gl/gl_image_android_native_buffer.cc b/ui/gl/gl_image_android_native_buffer.cc
index 6d11497..5e311ee 100644
--- a/ui/gl/gl_image_android_native_buffer.cc
+++ b/ui/gl/gl_image_android_native_buffer.cc
@@ -9,22 +9,21 @@
namespace gfx {
-GLImageAndroidNativeBuffer::GLImageAndroidNativeBuffer(gfx::Size size)
+GLImageAndroidNativeBuffer::GLImageAndroidNativeBuffer(const gfx::Size& size)
: GLImageEGL(size),
release_after_use_(false),
in_use_(false),
target_(0),
egl_image_for_unbind_(EGL_NO_IMAGE_KHR),
- texture_id_for_unbind_(0) {}
+ texture_id_for_unbind_(0) {
+}
GLImageAndroidNativeBuffer::~GLImageAndroidNativeBuffer() { Destroy(); }
-bool GLImageAndroidNativeBuffer::Initialize(gfx::GpuMemoryBufferHandle buffer) {
- DCHECK(buffer.native_buffer);
-
+bool GLImageAndroidNativeBuffer::Initialize(EGLClientBuffer native_buffer) {
EGLint attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE};
return GLImageEGL::Initialize(
- EGL_NATIVE_BUFFER_ANDROID, buffer.native_buffer, attrs);
+ EGL_NATIVE_BUFFER_ANDROID, native_buffer, attrs);
}
void GLImageAndroidNativeBuffer::Destroy() {
diff --git a/ui/gl/gl_image_android_native_buffer.h b/ui/gl/gl_image_android_native_buffer.h
index 28fe5c1..34f99b4 100644
--- a/ui/gl/gl_image_android_native_buffer.h
+++ b/ui/gl/gl_image_android_native_buffer.h
@@ -11,9 +11,9 @@ namespace gfx {
class GL_EXPORT GLImageAndroidNativeBuffer : public GLImageEGL {
public:
- explicit GLImageAndroidNativeBuffer(gfx::Size size);
+ explicit GLImageAndroidNativeBuffer(const gfx::Size& size);
- bool Initialize(gfx::GpuMemoryBufferHandle buffer);
+ bool Initialize(EGLClientBuffer native_buffer);
// Overridden from GLImage:
virtual void Destroy() OVERRIDE;
diff --git a/ui/gl/gl_image_egl.cc b/ui/gl/gl_image_egl.cc
index 5531c8d..e52297a 100644
--- a/ui/gl/gl_image_egl.cc
+++ b/ui/gl/gl_image_egl.cc
@@ -8,8 +8,9 @@
namespace gfx {
-GLImageEGL::GLImageEGL(gfx::Size size)
- : egl_image_(EGL_NO_IMAGE_KHR), size_(size) {}
+GLImageEGL::GLImageEGL(const gfx::Size& size)
+ : egl_image_(EGL_NO_IMAGE_KHR), size_(size) {
+}
GLImageEGL::~GLImageEGL() { Destroy(); }
diff --git a/ui/gl/gl_image_egl.h b/ui/gl/gl_image_egl.h
index 1339654..3b0e4ed1 100644
--- a/ui/gl/gl_image_egl.h
+++ b/ui/gl/gl_image_egl.h
@@ -12,7 +12,7 @@ namespace gfx {
class GL_EXPORT GLImageEGL : public GLImage {
public:
- explicit GLImageEGL(gfx::Size size);
+ explicit GLImageEGL(const gfx::Size& size);
bool Initialize(EGLenum target, EGLClientBuffer buffer, const EGLint* attrs);
@@ -30,7 +30,7 @@ class GL_EXPORT GLImageEGL : public GLImage {
virtual ~GLImageEGL();
EGLImageKHR egl_image_;
- gfx::Size size_;
+ const gfx::Size size_;
private:
DISALLOW_COPY_AND_ASSIGN(GLImageEGL);
diff --git a/ui/gl/gl_image_glx.cc b/ui/gl/gl_image_glx.cc
index 4b7e883..61bd097 100644
--- a/ui/gl/gl_image_glx.cc
+++ b/ui/gl/gl_image_glx.cc
@@ -3,16 +3,13 @@
// found in the LICENSE file.
extern "C" {
-#include <X11/extensions/Xcomposite.h>
+#include <X11/Xlib.h>
}
#include "ui/gl/gl_image_glx.h"
-#include "base/basictypes.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
-#include "base/message_loop/message_loop.h"
-#include "ui/gfx/x/x11_types.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_surface_glx.h"
@@ -27,114 +24,147 @@ struct ScopedPtrXFree {
void operator()(void* x) const { ::XFree(x); }
};
-int BindToTextureFormat(int depth) {
- if (depth == 32)
- return GLX_BIND_TO_TEXTURE_RGBA_EXT;
+bool ValidFormat(unsigned internalformat) {
+ switch (internalformat) {
+ case GL_BGRA8_EXT:
+ return true;
+ default:
+ return false;
+ }
+}
+
+int TextureFormat(unsigned internalformat) {
+ switch (internalformat) {
+ case GL_BGRA8_EXT:
+ return GLX_TEXTURE_FORMAT_RGBA_EXT;
+ default:
+ NOTREACHED();
+ return 0;
+ }
+}
+
+int BindToTextureFormat(unsigned internalformat) {
+ switch (internalformat) {
+ case GL_BGRA8_EXT:
+ return GLX_BIND_TO_TEXTURE_RGBA_EXT;
+ default:
+ NOTREACHED();
+ return 0;
+ }
+}
+
+unsigned PixmapDepth(unsigned internalformat) {
+ switch (internalformat) {
+ case GL_BGRA8_EXT:
+ return 32u;
+ default:
+ NOTREACHED();
+ return 0u;
+ }
+}
+
+bool ActualPixmapGeometry(XID pixmap, gfx::Size* size, unsigned* depth) {
+ XID root_return;
+ int x_return;
+ int y_return;
+ unsigned width_return;
+ unsigned height_return;
+ unsigned border_width_return;
+ unsigned depth_return;
+ if (!XGetGeometry(gfx::GetXDisplay(),
+ pixmap,
+ &root_return,
+ &x_return,
+ &y_return,
+ &width_return,
+ &height_return,
+ &border_width_return,
+ &depth_return))
+ return false;
- return GLX_BIND_TO_TEXTURE_RGB_EXT;
+ if (size)
+ *size = gfx::Size(width_return, height_return);
+ if (depth)
+ *depth = depth_return;
+ return true;
+}
+
+unsigned ActualPixmapDepth(XID pixmap) {
+ unsigned depth;
+ if (!ActualPixmapGeometry(pixmap, NULL, &depth))
+ return -1;
+
+ return depth;
}
-int TextureFormat(int depth) {
- if (depth == 32)
- return GLX_TEXTURE_FORMAT_RGBA_EXT;
+gfx::Size ActualPixmapSize(XID pixmap) {
+ gfx::Size size;
+ if (!ActualPixmapGeometry(pixmap, &size, NULL))
+ return gfx::Size();
- return GLX_TEXTURE_FORMAT_RGB_EXT;
+ return size;
}
} // namespace anonymous
-GLImageGLX::GLImageGLX(gfx::PluginWindowHandle window)
- : display_(gfx::GetXDisplay()),
- window_(window),
- pixmap_(0),
- glx_pixmap_(0) {}
+GLImageGLX::GLImageGLX(const gfx::Size& size, unsigned internalformat)
+ : glx_pixmap_(0), size_(size), internalformat_(internalformat) {
+}
GLImageGLX::~GLImageGLX() { Destroy(); }
-bool GLImageGLX::Initialize() {
+bool GLImageGLX::Initialize(XID pixmap) {
if (!GLSurfaceGLX::IsTextureFromPixmapSupported()) {
- LOG(ERROR) << "GLX_EXT_texture_from_pixmap not supported.";
+ DVLOG(0) << "GLX_EXT_texture_from_pixmap not supported.";
return false;
}
- XWindowAttributes attributes;
- if (!XGetWindowAttributes(display_, window_, &attributes)) {
- LOG(ERROR) << "XGetWindowAttributes failed for window " << window_ << ".";
+ if (!ValidFormat(internalformat_)) {
+ DVLOG(0) << "Invalid format: " << internalformat_;
return false;
}
- XVisualInfo templ;
- templ.visualid = XVisualIDFromVisual(attributes.visual);
- int num_visinfo = 0;
- scoped_ptr<XVisualInfo, ScopedPtrXFree> visinfo(
- XGetVisualInfo(display_, VisualIDMask, &templ, &num_visinfo));
- if (!visinfo.get()) {
- LOG(ERROR) << "XGetVisualInfo failed for visual id " << templ.visualid
- << ".";
- return false;
- }
- if (!num_visinfo) {
- LOG(ERROR) << "XGetVisualInfo returned 0 elements.";
- return false;
- }
+ DCHECK_EQ(PixmapDepth(internalformat_), ActualPixmapDepth(pixmap));
+ DCHECK_EQ(size_.ToString(), ActualPixmapSize(pixmap).ToString());
int config_attribs[] = {
- static_cast<int>(GLX_VISUAL_ID), static_cast<int>(visinfo->visualid),
- GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
- GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_EXT,
- BindToTextureFormat(visinfo->depth), GL_TRUE,
+ GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
+ GLX_BIND_TO_TEXTURE_TARGETS_EXT, GLX_TEXTURE_2D_EXT,
+ BindToTextureFormat(internalformat_), GL_TRUE,
0};
int num_elements = 0;
- scoped_ptr<GLXFBConfig, ScopedPtrXFree> config(glXChooseFBConfig(
- display_, DefaultScreen(display_), config_attribs, &num_elements));
+ scoped_ptr<GLXFBConfig, ScopedPtrXFree> config(
+ glXChooseFBConfig(gfx::GetXDisplay(),
+ DefaultScreen(gfx::GetXDisplay()),
+ config_attribs,
+ &num_elements));
if (!config.get()) {
- LOG(ERROR) << "glXChooseFBConfig failed.";
+ DVLOG(0) << "glXChooseFBConfig failed.";
return false;
}
if (!num_elements) {
- LOG(ERROR) << "glXChooseFBConfig returned 0 elements.";
- return false;
- }
-
- // Create backing pixmap reference.
- pixmap_ = XCompositeNameWindowPixmap(display_, window_);
-
- XID root = 0;
- int x = 0;
- int y = 0;
- unsigned int width = 0;
- unsigned int height = 0;
- unsigned int bw = 0;
- unsigned int depth = 0;
- if (!XGetGeometry(
- display_, pixmap_, &root, &x, &y, &width, &height, &bw, &depth)) {
- LOG(ERROR) << "XGetGeometry failed for pixmap " << pixmap_ << ".";
+ DVLOG(0) << "glXChooseFBConfig returned 0 elements.";
return false;
}
int pixmap_attribs[] = {GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
- GLX_TEXTURE_FORMAT_EXT, TextureFormat(visinfo->depth),
- 0};
- glx_pixmap_ =
- glXCreatePixmap(display_, *config.get(), pixmap_, pixmap_attribs);
+ GLX_TEXTURE_FORMAT_EXT,
+ TextureFormat(internalformat_), 0};
+ glx_pixmap_ = glXCreatePixmap(
+ gfx::GetXDisplay(), *config.get(), pixmap, pixmap_attribs);
if (!glx_pixmap_) {
- LOG(ERROR) << "glXCreatePixmap failed.";
+ DVLOG(0) << "glXCreatePixmap failed.";
return false;
}
- size_ = gfx::Size(width, height);
return true;
}
void GLImageGLX::Destroy() {
if (glx_pixmap_) {
- glXDestroyGLXPixmap(display_, glx_pixmap_);
+ glXDestroyGLXPixmap(gfx::GetXDisplay(), glx_pixmap_);
glx_pixmap_ = 0;
}
- if (pixmap_) {
- XFreePixmap(display_, pixmap_);
- pixmap_ = 0;
- }
}
gfx::Size GLImageGLX::GetSize() { return size_; }
@@ -147,7 +177,7 @@ bool GLImageGLX::BindTexImage(unsigned target) {
if (target != GL_TEXTURE_2D)
return false;
- glXBindTexImageEXT(display_, glx_pixmap_, GLX_FRONT_LEFT_EXT, 0);
+ glXBindTexImageEXT(gfx::GetXDisplay(), glx_pixmap_, GLX_FRONT_LEFT_EXT, 0);
return true;
}
@@ -155,7 +185,7 @@ void GLImageGLX::ReleaseTexImage(unsigned target) {
DCHECK(glx_pixmap_);
DCHECK_EQ(static_cast<GLenum>(GL_TEXTURE_2D), target);
- glXReleaseTexImageEXT(display_, glx_pixmap_, GLX_FRONT_LEFT_EXT);
+ glXReleaseTexImageEXT(gfx::GetXDisplay(), glx_pixmap_, GLX_FRONT_LEFT_EXT);
}
} // namespace gfx
diff --git a/ui/gl/gl_image_glx.h b/ui/gl/gl_image_glx.h
index d945202..f8027e1 100644
--- a/ui/gl/gl_image_glx.h
+++ b/ui/gl/gl_image_glx.h
@@ -14,9 +14,9 @@ namespace gfx {
class GL_EXPORT GLImageGLX : public GLImage {
public:
- explicit GLImageGLX(gfx::PluginWindowHandle window);
+ GLImageGLX(const gfx::Size& size, unsigned internalformat);
- virtual bool Initialize();
+ bool Initialize(XID pixmap);
// Overridden from GLImage:
virtual void Destroy() OVERRIDE;
@@ -32,11 +32,9 @@ class GL_EXPORT GLImageGLX : public GLImage {
virtual ~GLImageGLX();
private:
- XDisplay* display_;
- gfx::PluginWindowHandle window_;
- XID pixmap_;
XID glx_pixmap_;
- gfx::Size size_;
+ const gfx::Size size_;
+ unsigned internalformat_;
DISALLOW_COPY_AND_ASSIGN(GLImageGLX);
};
diff --git a/ui/gl/gl_image_io_surface.cc b/ui/gl/gl_image_io_surface.cc
index 566b05e..cf858ab 100644
--- a/ui/gl/gl_image_io_surface.cc
+++ b/ui/gl/gl_image_io_surface.cc
@@ -12,13 +12,13 @@
namespace gfx {
-GLImageIOSurface::GLImageIOSurface(gfx::Size size)
- : size_(size) {}
+GLImageIOSurface::GLImageIOSurface(const gfx::Size& size) : size_(size) {
+}
GLImageIOSurface::~GLImageIOSurface() { Destroy(); }
-bool GLImageIOSurface::Initialize(gfx::GpuMemoryBufferHandle buffer) {
- io_surface_.reset(IOSurfaceLookup(buffer.io_surface_id));
+bool GLImageIOSurface::Initialize(const gfx::GpuMemoryBufferHandle& handle) {
+ io_surface_.reset(IOSurfaceLookup(handle.io_surface_id));
if (!io_surface_) {
LOG(ERROR) << "IOSurface lookup failed";
return false;
diff --git a/ui/gl/gl_image_io_surface.h b/ui/gl/gl_image_io_surface.h
index 7825e7d..fbc09bc 100644
--- a/ui/gl/gl_image_io_surface.h
+++ b/ui/gl/gl_image_io_surface.h
@@ -8,15 +8,16 @@
#include <IOSurface/IOSurfaceAPI.h>
#include "base/mac/scoped_cftyperef.h"
+#include "ui/gfx/gpu_memory_buffer.h"
#include "ui/gl/gl_image.h"
namespace gfx {
class GL_EXPORT GLImageIOSurface : public GLImage {
public:
- explicit GLImageIOSurface(gfx::Size size);
+ explicit GLImageIOSurface(const gfx::Size& size);
- bool Initialize(gfx::GpuMemoryBufferHandle buffer);
+ bool Initialize(const gfx::GpuMemoryBufferHandle& handle);
// Overridden from GLImage:
virtual void Destroy() OVERRIDE {}
@@ -33,7 +34,7 @@ class GL_EXPORT GLImageIOSurface : public GLImage {
private:
base::ScopedCFTypeRef<IOSurfaceRef> io_surface_;
- gfx::Size size_;
+ const gfx::Size size_;
DISALLOW_COPY_AND_ASSIGN(GLImageIOSurface);
};
diff --git a/ui/gl/gl_image_mac.cc b/ui/gl/gl_image_mac.cc
deleted file mode 100644
index a48047f..0000000
--- a/ui/gl/gl_image_mac.cc
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/gl/gl_image.h"
-
-#include "base/debug/trace_event.h"
-#include "ui/gl/gl_image_io_surface.h"
-#include "ui/gl/gl_image_shm.h"
-#include "ui/gl/gl_image_stub.h"
-#include "ui/gl/gl_implementation.h"
-
-namespace gfx {
-
-scoped_refptr<GLImage> GLImage::CreateGLImage(gfx::PluginWindowHandle window) {
- TRACE_EVENT0("gpu", "GLImage::CreateGLImage");
- switch (GetGLImplementation()) {
- case kGLImplementationOSMesaGL:
- case kGLImplementationDesktopGL:
- case kGLImplementationAppleGL:
- return NULL;
- case kGLImplementationMockGL:
- return new GLImageStub;
- default:
- NOTREACHED();
- return NULL;
- }
-}
-
-scoped_refptr<GLImage> GLImage::CreateGLImageForGpuMemoryBuffer(
- gfx::GpuMemoryBufferHandle buffer,
- gfx::Size size,
- unsigned internalformat) {
- TRACE_EVENT0("gpu", "GLImage::CreateGLImageForGpuMemoryBuffer");
- switch (GetGLImplementation()) {
- case kGLImplementationOSMesaGL:
- case kGLImplementationDesktopGL:
- case kGLImplementationAppleGL:
- switch (buffer.type) {
- case SHARED_MEMORY_BUFFER: {
- scoped_refptr<GLImageShm> image(
- new GLImageShm(size, internalformat));
- if (!image->Initialize(buffer))
- return NULL;
-
- return image;
- }
- case IO_SURFACE_BUFFER: {
- scoped_refptr<GLImageIOSurface> image(new GLImageIOSurface(size));
- if (!image->Initialize(buffer))
- return NULL;
-
- return image;
- }
- default:
- NOTREACHED();
- return NULL;
- }
- case kGLImplementationMockGL:
- return new GLImageStub;
- default:
- NOTREACHED();
- return NULL;
- }
-}
-
-} // namespace gfx
diff --git a/ui/gl/gl_image_shm.cc b/ui/gl/gl_image_memory.cc
index 75ef453..5d0f901 100644
--- a/ui/gl/gl_image_shm.cc
+++ b/ui/gl/gl_image_memory.cc
@@ -1,11 +1,12 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/gl/gl_image_shm.h"
+#include "ui/gl/gl_image_memory.h"
#include "base/debug/trace_event.h"
-#include "base/process/process_handle.h"
+#include "base/logging.h"
+#include "ui/gl/gl_bindings.h"
#include "ui/gl/scoped_binders.h"
#if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \
@@ -14,7 +15,6 @@
#endif
namespace gfx {
-
namespace {
bool ValidFormat(unsigned internalformat) {
@@ -54,7 +54,7 @@ GLenum DataType(unsigned internalformat) {
}
}
-GLenum BytesPerPixel(unsigned internalformat) {
+int BytesPerPixel(unsigned internalformat) {
switch (internalformat) {
case GL_BGRA8_EXT:
case GL_RGBA8_OES:
@@ -67,8 +67,9 @@ GLenum BytesPerPixel(unsigned internalformat) {
} // namespace
-GLImageShm::GLImageShm(gfx::Size size, unsigned internalformat)
- : size_(size),
+GLImageMemory::GLImageMemory(const gfx::Size& size, unsigned internalformat)
+ : memory_(NULL),
+ size_(size),
internalformat_(internalformat)
#if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \
defined(USE_OZONE)
@@ -79,33 +80,22 @@ GLImageShm::GLImageShm(gfx::Size size, unsigned internalformat)
{
}
-GLImageShm::~GLImageShm() { Destroy(); }
+GLImageMemory::~GLImageMemory() {
+}
-bool GLImageShm::Initialize(gfx::GpuMemoryBufferHandle buffer) {
+bool GLImageMemory::Initialize(const unsigned char* memory) {
if (!ValidFormat(internalformat_)) {
DVLOG(0) << "Invalid format: " << internalformat_;
return false;
}
- if (!base::SharedMemory::IsHandleValid(buffer.handle))
- return false;
-
- base::SharedMemory shared_memory(buffer.handle, true);
-
- // Duplicate the handle.
- base::SharedMemoryHandle duped_shared_memory_handle;
- if (!shared_memory.ShareToProcess(base::GetCurrentProcessHandle(),
- &duped_shared_memory_handle)) {
- DVLOG(0) << "Failed to duplicate shared memory handle.";
- return false;
- }
-
- shared_memory_.reset(
- new base::SharedMemory(duped_shared_memory_handle, true));
+ DCHECK(memory);
+ DCHECK(!memory_);
+ memory_ = memory;
return true;
}
-void GLImageShm::Destroy() {
+void GLImageMemory::Destroy() {
#if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \
defined(USE_OZONE)
if (egl_image_ != EGL_NO_IMAGE_KHR) {
@@ -118,24 +108,17 @@ void GLImageShm::Destroy() {
egl_texture_id_ = 0u;
}
#endif
+ memory_ = NULL;
}
-gfx::Size GLImageShm::GetSize() { return size_; }
-
-bool GLImageShm::BindTexImage(unsigned target) {
- TRACE_EVENT0("gpu", "GLImageShm::BindTexImage");
- DCHECK(shared_memory_);
- DCHECK(ValidFormat(internalformat_));
-
- size_t size = size_.GetArea() * BytesPerPixel(internalformat_);
- DCHECK(!shared_memory_->memory());
- if (!shared_memory_->Map(size)) {
- DVLOG(0) << "Failed to map shared memory.";
- return false;
- }
+gfx::Size GLImageMemory::GetSize() {
+ return size_;
+}
- DCHECK(shared_memory_->memory());
+bool GLImageMemory::BindTexImage(unsigned target) {
+ TRACE_EVENT0("gpu", "GLImageMemory::BindTexImage");
+ DCHECK(memory_);
#if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \
defined(USE_OZONE)
if (target == GL_TEXTURE_EXTERNAL_OES) {
@@ -157,7 +140,7 @@ bool GLImageShm::BindTexImage(unsigned target) {
0, // border
DataFormat(internalformat_),
DataType(internalformat_),
- shared_memory_->memory());
+ memory_);
}
EGLint attrs[] = {EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE};
@@ -182,13 +165,12 @@ bool GLImageShm::BindTexImage(unsigned target) {
size_.height(),
DataFormat(internalformat_),
DataType(internalformat_),
- shared_memory_->memory());
+ memory_);
}
glEGLImageTargetTexture2DOES(target, egl_image_);
DCHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
- shared_memory_->Unmap();
return true;
}
#endif
@@ -202,10 +184,17 @@ bool GLImageShm::BindTexImage(unsigned target) {
0, // border
DataFormat(internalformat_),
DataType(internalformat_),
- shared_memory_->memory());
+ memory_);
- shared_memory_->Unmap();
return true;
}
+bool GLImageMemory::HasValidFormat() const {
+ return ValidFormat(internalformat_);
+}
+
+size_t GLImageMemory::Bytes() const {
+ return size_.GetArea() * BytesPerPixel(internalformat_);
+}
+
} // namespace gfx
diff --git a/ui/gl/gl_image_shm.h b/ui/gl/gl_image_memory.h
index 079bab9..e91008a 100644
--- a/ui/gl/gl_image_shm.h
+++ b/ui/gl/gl_image_memory.h
@@ -1,21 +1,25 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_GL_GL_IMAGE_SHM_H_
-#define UI_GL_GL_IMAGE_SHM_H_
+#ifndef UI_GL_GL_IMAGE_MEMORY_H_
+#define UI_GL_GL_IMAGE_MEMORY_H_
-#include "base/memory/scoped_ptr.h"
-#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_image.h"
+#if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \
+ defined(USE_OZONE)
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#endif
+
namespace gfx {
-class GL_EXPORT GLImageShm : public GLImage {
+class GL_EXPORT GLImageMemory : public GLImage {
public:
- GLImageShm(gfx::Size size, unsigned internalformat);
+ GLImageMemory(const gfx::Size& size, unsigned internalformat);
- bool Initialize(gfx::GpuMemoryBufferHandle buffer);
+ bool Initialize(const unsigned char* memory);
// Overridden from GLImage:
virtual void Destroy() OVERRIDE;
@@ -28,21 +32,24 @@ class GL_EXPORT GLImageShm : public GLImage {
virtual void DidModifyTexImage() OVERRIDE {}
protected:
- virtual ~GLImageShm();
+ virtual ~GLImageMemory();
+
+ bool HasValidFormat() const;
+ size_t Bytes() const;
private:
- scoped_ptr<base::SharedMemory> shared_memory_;
- gfx::Size size_;
- unsigned internalformat_;
+ const unsigned char* memory_;
+ const gfx::Size size_;
+ const unsigned internalformat_;
#if defined(OS_WIN) || defined(USE_X11) || defined(OS_ANDROID) || \
defined(USE_OZONE)
- GLuint egl_texture_id_;
+ unsigned egl_texture_id_;
EGLImageKHR egl_image_;
#endif
- DISALLOW_COPY_AND_ASSIGN(GLImageShm);
+ DISALLOW_COPY_AND_ASSIGN(GLImageMemory);
};
} // namespace gfx
-#endif // UI_GL_GL_IMAGE_SHM_H_
+#endif // UI_GL_GL_IMAGE_MEMORY_H_
diff --git a/ui/gl/gl_image_ozone.cc b/ui/gl/gl_image_ozone.cc
deleted file mode 100644
index a1c1329..0000000
--- a/ui/gl/gl_image_ozone.cc
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/gl/gl_image.h"
-
-#include "base/debug/trace_event.h"
-#include "ui/gl/gl_image_egl.h"
-#include "ui/gl/gl_image_stub.h"
-#include "ui/gl/gl_implementation.h"
-
-namespace gfx {
-
-scoped_refptr<GLImage> GLImage::CreateGLImage(gfx::PluginWindowHandle window) {
- TRACE_EVENT0("gpu", "GLImage::CreateGLImage");
- switch (GetGLImplementation()) {
- case kGLImplementationOSMesaGL:
- return NULL;
- case kGLImplementationEGLGLES2:
- return NULL;
- case kGLImplementationMockGL:
- return new GLImageStub;
- default:
- NOTREACHED();
- return NULL;
- }
-}
-
-scoped_refptr<GLImage> GLImage::CreateGLImageForGpuMemoryBuffer(
- gfx::GpuMemoryBufferHandle buffer,
- gfx::Size size,
- unsigned internalformat) {
- TRACE_EVENT0("gpu", "GLImage::CreateGLImageForGpuMemoryBuffer");
- switch (GetGLImplementation()) {
- case kGLImplementationOSMesaGL:
- return NULL;
- case kGLImplementationEGLGLES2:
- return NULL;
- case kGLImplementationMockGL:
- return new GLImageStub;
- default:
- NOTREACHED();
- return NULL;
- }
-}
-
-} // namespace gfx
diff --git a/ui/gl/gl_image_ref_counted_memory.cc b/ui/gl/gl_image_ref_counted_memory.cc
new file mode 100644
index 0000000..5ca65d0
--- /dev/null
+++ b/ui/gl/gl_image_ref_counted_memory.cc
@@ -0,0 +1,37 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/gl/gl_image_ref_counted_memory.h"
+
+#include "base/logging.h"
+#include "base/memory/ref_counted_memory.h"
+
+namespace gfx {
+
+GLImageRefCountedMemory::GLImageRefCountedMemory(const gfx::Size& size,
+ unsigned internalformat)
+ : GLImageMemory(size, internalformat) {
+}
+
+GLImageRefCountedMemory::~GLImageRefCountedMemory() {
+ Destroy();
+}
+
+bool GLImageRefCountedMemory::Initialize(
+ base::RefCountedMemory* ref_counted_memory) {
+ if (!HasValidFormat())
+ return false;
+
+ DCHECK(!ref_counted_memory_);
+ ref_counted_memory_ = ref_counted_memory;
+ GLImageMemory::Initialize(ref_counted_memory_->front());
+ return true;
+}
+
+void GLImageRefCountedMemory::Destroy() {
+ GLImageMemory::Destroy();
+ ref_counted_memory_ = NULL;
+}
+
+} // namespace gfx
diff --git a/ui/gl/gl_image_ref_counted_memory.h b/ui/gl/gl_image_ref_counted_memory.h
new file mode 100644
index 0000000..b88c5f1
--- /dev/null
+++ b/ui/gl/gl_image_ref_counted_memory.h
@@ -0,0 +1,37 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_GL_GL_IMAGE_REF_COUNTED_MEMORY_H_
+#define UI_GL_GL_IMAGE_REF_COUNTED_MEMORY_H_
+
+#include "base/memory/ref_counted.h"
+#include "ui/gl/gl_image_memory.h"
+
+namespace base {
+class RefCountedMemory;
+}
+
+namespace gfx {
+
+class GL_EXPORT GLImageRefCountedMemory : public GLImageMemory {
+ public:
+ GLImageRefCountedMemory(const gfx::Size& size, unsigned internalformat);
+
+ bool Initialize(base::RefCountedMemory* ref_counted_memory);
+
+ // Overridden from GLImage:
+ virtual void Destroy() OVERRIDE;
+
+ protected:
+ virtual ~GLImageRefCountedMemory();
+
+ private:
+ scoped_refptr<base::RefCountedMemory> ref_counted_memory_;
+
+ DISALLOW_COPY_AND_ASSIGN(GLImageRefCountedMemory);
+};
+
+} // namespace gfx
+
+#endif // UI_GL_GL_IMAGE_REF_COUNTED_MEMORY_H_
diff --git a/ui/gl/gl_image_shared_memory.cc b/ui/gl/gl_image_shared_memory.cc
new file mode 100644
index 0000000..7c578ba
--- /dev/null
+++ b/ui/gl/gl_image_shared_memory.cc
@@ -0,0 +1,58 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/gl/gl_image_shared_memory.h"
+
+#include "base/logging.h"
+#include "base/process/process_handle.h"
+
+namespace gfx {
+
+GLImageSharedMemory::GLImageSharedMemory(const gfx::Size& size,
+ unsigned internalformat)
+ : GLImageMemory(size, internalformat) {
+}
+
+GLImageSharedMemory::~GLImageSharedMemory() {
+ Destroy();
+}
+
+bool GLImageSharedMemory::Initialize(const gfx::GpuMemoryBufferHandle& handle) {
+ if (!HasValidFormat())
+ return false;
+
+ if (!base::SharedMemory::IsHandleValid(handle.handle))
+ return false;
+
+ base::SharedMemory shared_memory(handle.handle, true);
+
+ // Duplicate the handle.
+ base::SharedMemoryHandle duped_shared_memory_handle;
+ if (!shared_memory.ShareToProcess(base::GetCurrentProcessHandle(),
+ &duped_shared_memory_handle)) {
+ DVLOG(0) << "Failed to duplicate shared memory handle.";
+ return false;
+ }
+
+ scoped_ptr<base::SharedMemory> duped_shared_memory(
+ new base::SharedMemory(duped_shared_memory_handle, true));
+
+ if (!duped_shared_memory->Map(Bytes())) {
+ DVLOG(0) << "Failed to map shared memory.";
+ return false;
+ }
+
+ DCHECK(!shared_memory_);
+ shared_memory_ = duped_shared_memory.Pass();
+ GLImageMemory::Initialize(
+ static_cast<unsigned char*>(shared_memory_->memory()));
+ return true;
+}
+
+void GLImageSharedMemory::Destroy() {
+ GLImageMemory::Destroy();
+ shared_memory_.reset();
+}
+
+} // namespace gfx
diff --git a/ui/gl/gl_image_shared_memory.h b/ui/gl/gl_image_shared_memory.h
new file mode 100644
index 0000000..011ae26
--- /dev/null
+++ b/ui/gl/gl_image_shared_memory.h
@@ -0,0 +1,34 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_GL_GL_IMAGE_SHARED_MEMORY_H_
+#define UI_GL_GL_IMAGE_SHARED_MEMORY_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "ui/gfx/gpu_memory_buffer.h"
+#include "ui/gl/gl_image_memory.h"
+
+namespace gfx {
+
+class GL_EXPORT GLImageSharedMemory : public GLImageMemory {
+ public:
+ GLImageSharedMemory(const gfx::Size& size, unsigned internalformat);
+
+ bool Initialize(const gfx::GpuMemoryBufferHandle& handle);
+
+ // Overridden from GLImage:
+ virtual void Destroy() OVERRIDE;
+
+ protected:
+ virtual ~GLImageSharedMemory();
+
+ private:
+ scoped_ptr<base::SharedMemory> shared_memory_;
+
+ DISALLOW_COPY_AND_ASSIGN(GLImageSharedMemory);
+};
+
+} // namespace gfx
+
+#endif // UI_GL_GL_IMAGE_SHARED_MEMORY_H_
diff --git a/ui/gl/gl_image_surface_texture.cc b/ui/gl/gl_image_surface_texture.cc
index 8d0a0e7..bb9fa13 100644
--- a/ui/gl/gl_image_surface_texture.cc
+++ b/ui/gl/gl_image_surface_texture.cc
@@ -10,17 +10,19 @@
namespace gfx {
-GLImageSurfaceTexture::GLImageSurfaceTexture(gfx::Size size)
- : size_(size), texture_id_(0) {}
+GLImageSurfaceTexture::GLImageSurfaceTexture(const gfx::Size& size)
+ : size_(size), texture_id_(0) {
+}
GLImageSurfaceTexture::~GLImageSurfaceTexture() { Destroy(); }
-bool GLImageSurfaceTexture::Initialize(gfx::GpuMemoryBufferHandle buffer) {
+bool GLImageSurfaceTexture::Initialize(
+ const gfx::GpuMemoryBufferHandle& handle) {
DCHECK(!surface_texture_);
surface_texture_ =
SurfaceTextureTracker::GetInstance()->AcquireSurfaceTexture(
- buffer.surface_texture_id.primary_id,
- buffer.surface_texture_id.secondary_id);
+ handle.surface_texture_id.primary_id,
+ handle.surface_texture_id.secondary_id);
return !!surface_texture_;
}
diff --git a/ui/gl/gl_image_surface_texture.h b/ui/gl/gl_image_surface_texture.h
index 0b771a3..9b179d3 100644
--- a/ui/gl/gl_image_surface_texture.h
+++ b/ui/gl/gl_image_surface_texture.h
@@ -6,6 +6,7 @@
#define UI_GL_GL_IMAGE_SURFACE_TEXTURE_H_
#include "base/memory/ref_counted.h"
+#include "ui/gfx/gpu_memory_buffer.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_image.h"
@@ -15,9 +16,9 @@ class SurfaceTexture;
class GL_EXPORT GLImageSurfaceTexture : public GLImage {
public:
- explicit GLImageSurfaceTexture(gfx::Size size);
+ explicit GLImageSurfaceTexture(const gfx::Size& size);
- bool Initialize(gfx::GpuMemoryBufferHandle buffer);
+ bool Initialize(const gfx::GpuMemoryBufferHandle& handle);
// Overridden from GLImage:
virtual void Destroy() OVERRIDE;
@@ -34,7 +35,7 @@ class GL_EXPORT GLImageSurfaceTexture : public GLImage {
private:
scoped_refptr<SurfaceTexture> surface_texture_;
- gfx::Size size_;
+ const gfx::Size size_;
GLint texture_id_;
DISALLOW_COPY_AND_ASSIGN(GLImageSurfaceTexture);
diff --git a/ui/gl/gl_image_win.cc b/ui/gl/gl_image_win.cc
deleted file mode 100644
index 1486520..0000000
--- a/ui/gl/gl_image_win.cc
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/gl/gl_image.h"
-
-#include "base/debug/trace_event.h"
-#include "ui/gl/gl_image_shm.h"
-#include "ui/gl/gl_image_stub.h"
-#include "ui/gl/gl_implementation.h"
-
-namespace gfx {
-
-scoped_refptr<GLImage> GLImage::CreateGLImage(gfx::PluginWindowHandle window) {
- TRACE_EVENT0("gpu", "GLImage::CreateGLImage");
- switch (GetGLImplementation()) {
- case kGLImplementationOSMesaGL:
- case kGLImplementationDesktopGL:
- case kGLImplementationEGLGLES2:
- return NULL;
- case kGLImplementationMockGL:
- return new GLImageStub;
- default:
- NOTREACHED();
- return NULL;
- }
-}
-
-scoped_refptr<GLImage> GLImage::CreateGLImageForGpuMemoryBuffer(
- gfx::GpuMemoryBufferHandle buffer,
- gfx::Size size,
- unsigned internalformat) {
- TRACE_EVENT0("gpu", "GLImage::CreateGLImageForGpuMemoryBuffer");
- switch (GetGLImplementation()) {
- case kGLImplementationOSMesaGL:
- case kGLImplementationDesktopGL:
- case kGLImplementationEGLGLES2:
- switch (buffer.type) {
- case SHARED_MEMORY_BUFFER: {
- scoped_refptr<GLImageShm> image(
- new GLImageShm(size, internalformat));
- if (!image->Initialize(buffer))
- return NULL;
-
- return image;
- }
- default:
- NOTREACHED();
- return NULL;
- }
- case kGLImplementationMockGL:
- return new GLImageStub;
- default:
- NOTREACHED();
- return NULL;
- }
-}
-
-} // namespace gfx
diff --git a/ui/gl/gl_image_x11.cc b/ui/gl/gl_image_x11.cc
deleted file mode 100644
index 6f7d8c6..0000000
--- a/ui/gl/gl_image_x11.cc
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/gl/gl_image.h"
-
-#include "base/debug/trace_event.h"
-#include "ui/gl/gl_image_glx.h"
-#include "ui/gl/gl_image_shm.h"
-#include "ui/gl/gl_image_stub.h"
-#include "ui/gl/gl_implementation.h"
-
-namespace gfx {
-
-scoped_refptr<GLImage> GLImage::CreateGLImage(gfx::PluginWindowHandle window) {
- TRACE_EVENT0("gpu", "GLImage::CreateGLImage");
- switch (GetGLImplementation()) {
- case kGLImplementationOSMesaGL:
- return NULL;
- case kGLImplementationDesktopGL: {
- scoped_refptr<GLImageGLX> image(new GLImageGLX(window));
- if (!image->Initialize())
- return NULL;
-
- return image;
- }
- case kGLImplementationEGLGLES2:
- return NULL;
- case kGLImplementationMockGL:
- return new GLImageStub;
- default:
- NOTREACHED();
- return NULL;
- }
-}
-
-scoped_refptr<GLImage> GLImage::CreateGLImageForGpuMemoryBuffer(
- gfx::GpuMemoryBufferHandle buffer,
- gfx::Size size,
- unsigned internalformat) {
- TRACE_EVENT0("gpu", "GLImage::CreateGLImageForGpuMemoryBuffer");
- switch (GetGLImplementation()) {
- case kGLImplementationOSMesaGL:
- case kGLImplementationDesktopGL:
- case kGLImplementationEGLGLES2:
- switch (buffer.type) {
- case SHARED_MEMORY_BUFFER: {
- scoped_refptr<GLImageShm> image(
- new GLImageShm(size, internalformat));
- if (!image->Initialize(buffer))
- return NULL;
-
- return image;
- }
- default:
- NOTREACHED();
- return NULL;
- }
- case kGLImplementationMockGL:
- return new GLImageStub;
- default:
- NOTREACHED();
- return NULL;
- }
-}
-
-} // namespace gfx