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

Unified Diff: chrome/browser/renderer_host/accelerated_surface_container_touch.cc

Issue 7552039: Vend common GL context (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with ToT Created 9 years, 4 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: chrome/browser/renderer_host/accelerated_surface_container_touch.cc
diff --git a/chrome/browser/renderer_host/accelerated_surface_container_touch.cc b/chrome/browser/renderer_host/accelerated_surface_container_touch.cc
index e3a523764530992ed1d289a76bdf9b2503842c9d..56db1f81797a90e3e9d8d81754cafaf6e5a2dda5 100644
--- a/chrome/browser/renderer_host/accelerated_surface_container_touch.cc
+++ b/chrome/browser/renderer_host/accelerated_surface_container_touch.cc
@@ -10,11 +10,12 @@
#include "base/memory/scoped_ptr.h"
#include "third_party/angle/include/EGL/egl.h"
#include "third_party/angle/include/EGL/eglext.h"
+#include "ui/gfx/compositor/compositor_gl.h"
#include "ui/gfx/gl/gl_bindings.h"
#include "ui/gfx/gl/gl_implementation.h"
#include "ui/gfx/gl/gl_surface_egl.h"
-#include "ui/gfx/rect.h"
#include "ui/gfx/gl/gl_surface_glx.h"
+#include "ui/gfx/rect.h"
#include "ui/gfx/transform.h"
namespace {
@@ -22,35 +23,37 @@ namespace {
class AcceleratedSurfaceContainerTouchEGL
: public AcceleratedSurfaceContainerTouch {
public:
- AcceleratedSurfaceContainerTouchEGL(ui::CompositorGL* compositor,
- const gfx::Size& size,
+ AcceleratedSurfaceContainerTouchEGL(const gfx::Size& size,
uint64 surface_handle);
// TextureGL implementation
virtual void Draw(const ui::TextureDrawParams& params,
- const gfx::Rect& clip_bounds_in_texture) OVERRIDE;
+ const gfx::Rect& clip_bounds_in_texture,
+ const gfx::Size& surface_size) OVERRIDE;
private:
~AcceleratedSurfaceContainerTouchEGL();
void* image_;
+
DISALLOW_COPY_AND_ASSIGN(AcceleratedSurfaceContainerTouchEGL);
};
class AcceleratedSurfaceContainerTouchGLX
: public AcceleratedSurfaceContainerTouch {
public:
- AcceleratedSurfaceContainerTouchGLX(ui::CompositorGL* compositor,
- const gfx::Size& size,
+ AcceleratedSurfaceContainerTouchGLX(const gfx::Size& size,
uint64 surface_handle);
// TextureGL implementation
virtual void Draw(const ui::TextureDrawParams& params,
- const gfx::Rect& clip_bounds_in_texture) OVERRIDE;
+ const gfx::Rect& clip_bounds_in_texture,
+ const gfx::Size& surface_size) OVERRIDE;
private:
~AcceleratedSurfaceContainerTouchGLX();
XID pixmap_;
XID glx_pixmap_;
+
DISALLOW_COPY_AND_ASSIGN(AcceleratedSurfaceContainerTouchGLX);
};
@@ -62,12 +65,13 @@ class ScopedPtrXFree {
};
AcceleratedSurfaceContainerTouchEGL::AcceleratedSurfaceContainerTouchEGL(
- ui::CompositorGL* compositor,
const gfx::Size& size,
uint64 surface_handle)
- : AcceleratedSurfaceContainerTouch(compositor, size),
+ : AcceleratedSurfaceContainerTouch(size),
image_(NULL) {
- compositor_->MakeCurrent();
+ ui::SharedResources* instance = ui::SharedResources::GetInstance();
+ DCHECK(instance);
+ instance->MakeSharedContextCurrent();
image_ = eglCreateImageKHR(
gfx::GLSurfaceEGL::GetHardwareDisplay(), EGL_NO_CONTEXT,
@@ -84,14 +88,20 @@ AcceleratedSurfaceContainerTouchEGL::AcceleratedSurfaceContainerTouchEGL(
}
AcceleratedSurfaceContainerTouchEGL::~AcceleratedSurfaceContainerTouchEGL() {
+ ui::SharedResources* instance = ui::SharedResources::GetInstance();
+ DCHECK(instance);
+ instance->MakeSharedContextCurrent();
+
eglDestroyImageKHR(gfx::GLSurfaceEGL::GetHardwareDisplay(), image_);
glFlush();
}
void AcceleratedSurfaceContainerTouchEGL::Draw(
const ui::TextureDrawParams& params,
- const gfx::Rect& clip_bounds_in_texture) {
- DCHECK(compositor_->program_no_swizzle());
+ const gfx::Rect& clip_bounds_in_texture,
+ const gfx::Size& surface_size) {
+ ui::SharedResources* instance = ui::SharedResources::GetInstance();
+ DCHECK(instance);
ui::TextureDrawParams modified_params = params;
@@ -103,18 +113,22 @@ void AcceleratedSurfaceContainerTouchEGL::Draw(
modified_params.transform = flipped;
- DrawInternal(*compositor_->program_no_swizzle(),
+ DrawInternal(*instance->program_no_swizzle(),
modified_params,
- clip_bounds_in_texture);
+ clip_bounds_in_texture,
+ surface_size);
}
AcceleratedSurfaceContainerTouchGLX::AcceleratedSurfaceContainerTouchGLX(
- ui::CompositorGL* compositor,
const gfx::Size& size,
uint64 surface_handle)
- : AcceleratedSurfaceContainerTouch(compositor, size),
+ : AcceleratedSurfaceContainerTouch(size),
pixmap_(0),
glx_pixmap_(0) {
+ ui::SharedResources* instance = ui::SharedResources::GetInstance();
+ DCHECK(instance);
+ instance->MakeSharedContextCurrent();
+
// Create pixmap from window.
Display* dpy = gfx::GLSurfaceGLX::GetDisplay();
int event_base, error_base;
@@ -186,7 +200,6 @@ AcceleratedSurfaceContainerTouchGLX::AcceleratedSurfaceContainerTouchGLX(
dpy, fbconfigs.get()[config], pixmap_, pixmapAttribs);
// Create texture.
- compositor_->MakeCurrent();
glGenTextures(1, &texture_id_);
glBindTexture(GL_TEXTURE_2D, texture_id_);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -196,6 +209,10 @@ AcceleratedSurfaceContainerTouchGLX::AcceleratedSurfaceContainerTouchGLX(
}
AcceleratedSurfaceContainerTouchGLX::~AcceleratedSurfaceContainerTouchGLX() {
+ ui::SharedResources* instance = ui::SharedResources::GetInstance();
+ DCHECK(instance);
+ instance->MakeSharedContextCurrent();
+
Display* dpy = gfx::GLSurfaceGLX::GetDisplay();
if (glx_pixmap_)
glXDestroyGLXPixmap(dpy, glx_pixmap_);
@@ -205,40 +222,39 @@ AcceleratedSurfaceContainerTouchGLX::~AcceleratedSurfaceContainerTouchGLX() {
void AcceleratedSurfaceContainerTouchGLX::Draw(
const ui::TextureDrawParams& params,
- const gfx::Rect& clip_bounds_in_texture) {
- DCHECK(compositor_->program_no_swizzle());
+ const gfx::Rect& clip_bounds_in_texture,
+ const gfx::Size& surface_size) {
+ ui::SharedResources* instance = ui::SharedResources::GetInstance();
+ DCHECK(instance);
+
Display* dpy = gfx::GLSurfaceGLX::GetDisplay();
glBindTexture(GL_TEXTURE_2D, texture_id_);
glXBindTexImageEXT(dpy, glx_pixmap_, GLX_FRONT_LEFT_EXT, NULL);
- DrawInternal(*compositor_->program_no_swizzle(),
+ DrawInternal(*instance->program_no_swizzle(),
params,
- clip_bounds_in_texture);
+ clip_bounds_in_texture,
+ surface_size);
glXReleaseTexImageEXT(dpy, glx_pixmap_, GLX_FRONT_LEFT_EXT);
}
} // namespace
AcceleratedSurfaceContainerTouch::AcceleratedSurfaceContainerTouch(
- ui::CompositorGL* compositor,
- const gfx::Size& size) :
- TextureGL(compositor, size) {
+ const gfx::Size& size) : TextureGL(size) {
}
// static
AcceleratedSurfaceContainerTouch*
AcceleratedSurfaceContainerTouch::CreateAcceleratedSurfaceContainer(
- ui::CompositorGL* compositor,
const gfx::Size& size,
uint64 surface_handle) {
switch (gfx::GetGLImplementation()) {
case gfx::kGLImplementationDesktopGL:
- return new AcceleratedSurfaceContainerTouchGLX(compositor,
- size,
+ return new AcceleratedSurfaceContainerTouchGLX(size,
surface_handle);
case gfx::kGLImplementationEGLGLES2:
- return new AcceleratedSurfaceContainerTouchEGL(compositor,
- size,
+ return new AcceleratedSurfaceContainerTouchEGL(size,
surface_handle);
default:
NOTREACHED();

Powered by Google App Engine
This is Rietveld 408576698