summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-31 21:53:38 +0000
committerrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-31 21:53:38 +0000
commit0b7a2fff445beb2c5de1e2a632540a4107e00708 (patch)
tree759f7a9d489b6bf44c9f5de081d7bf335233028d /ui
parent72ab1b792dbddfb680490153984b1865b725d8f4 (diff)
downloadchromium_src-0b7a2fff445beb2c5de1e2a632540a4107e00708.zip
chromium_src-0b7a2fff445beb2c5de1e2a632540a4107e00708.tar.gz
chromium_src-0b7a2fff445beb2c5de1e2a632540a4107e00708.tar.bz2
Revert 87371 - Broke Compile - Support for glSetSurfaceCHROMIUM.
This command allows a previously created GPU surface to be made current for a command buffer. There are no surfaces registered at this point so this command is currently a no-op. Review URL: http://codereview.chromium.org/7077001 TBR=apatrick@chromium.org Review URL: http://codereview.chromium.org/7027008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87373 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/gfx/compositor/compositor_gl.cc16
-rw-r--r--ui/gfx/gl/gl_context.cc6
-rw-r--r--ui/gfx/gl/gl_context.h15
-rw-r--r--ui/gfx/gl/gl_context_linux.cc17
-rw-r--r--ui/gfx/gl/gl_context_mac.cc13
-rw-r--r--ui/gfx/gl/gl_context_win.cc17
-rw-r--r--ui/gfx/gl/gl_surface.h14
-rw-r--r--ui/gfx/gl/gl_surface_linux.cc32
-rw-r--r--ui/gfx/gl/gl_surface_mac.cc24
-rw-r--r--ui/gfx/gl/gl_surface_win.cc32
-rw-r--r--ui/gfx/surface/accelerated_surface_mac.cc10
-rw-r--r--ui/gfx/surface/accelerated_surface_mac.h4
12 files changed, 87 insertions, 113 deletions
diff --git a/ui/gfx/compositor/compositor_gl.cc b/ui/gfx/compositor/compositor_gl.cc
index 7e6e297..cacf54b 100644
--- a/ui/gfx/compositor/compositor_gl.cc
+++ b/ui/gfx/compositor/compositor_gl.cc
@@ -71,8 +71,8 @@ class CompositorGL : public Compositor {
bool InitShaders();
// The GL context used for compositing.
- scoped_refptr<gfx::GLSurface> gl_surface_;
- scoped_refptr<gfx::GLContext> gl_context_;
+ scoped_ptr<gfx::GLSurface> gl_surface_;
+ scoped_ptr<gfx::GLContext> gl_context_;
gfx::Size size_;
// Shader program, attributes and uniforms.
@@ -205,8 +205,8 @@ void TextureGL::Draw(const ui::Transform& transform) {
CompositorGL::CompositorGL(gfx::AcceleratedWidget widget)
: started_(false) {
- gl_surface_ = gfx::GLSurface::CreateViewGLSurface(widget);
- gl_context_ = gfx::GLContext::CreateGLContext(NULL, gl_surface_.get());
+ gl_surface_.reset(gfx::GLSurface::CreateViewGLSurface(widget));
+ gl_context_.reset(gfx::GLContext::CreateGLContext(NULL, gl_surface_.get())),
gl_context_->MakeCurrent(gl_surface_.get());
if (!InitShaders())
LOG(ERROR) << "Unable to initialize shaders (context = "
@@ -372,8 +372,8 @@ class CompositorGL : public Compositor {
void RestoreTransform() OVERRIDE;
// The GL context used for compositing.
- scoped_refptr<gfx::GLSurface> gl_surface_;
- scoped_refptr<gfx::GLContext> gl_context_;
+ scoped_ptr<gfx::GLSurface> gl_surface_;
+ scoped_ptr<gfx::GLContext> gl_context_;
// Keep track of whether compositing has started or not.
bool started_;
@@ -383,8 +383,8 @@ class CompositorGL : public Compositor {
CompositorGL::CompositorGL(gfx::AcceleratedWidget widget)
: started_(false) {
- gl_surface_ = gfx::GLSurface::CreateViewGLSurface(widget);
- gl_context_ = gfx::GLContext::CreateGLContext(NULL, gl_surface_.get());
+ gl_surface_.reset(gfx::GLSurface::CreateViewGLSurface(widget));
+ gl_context_.reset(gfx::GLContext::CreateGLContext(NULL, gl_surface_.get()));
}
void CompositorGL::NotifyStart() {
diff --git a/ui/gfx/gl/gl_context.cc b/ui/gfx/gl/gl_context.cc
index 9cf1e40..6391dc5 100644
--- a/ui/gfx/gl/gl_context.cc
+++ b/ui/gfx/gl/gl_context.cc
@@ -13,12 +13,6 @@
namespace gfx {
-GLContext::GLContext() {
-}
-
-GLContext::~GLContext() {
-}
-
std::string GLContext::GetExtensions() {
DCHECK(IsCurrent(NULL));
const char* ext = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
diff --git a/ui/gfx/gl/gl_context.h b/ui/gfx/gl/gl_context.h
index 77f167f..45b944c 100644
--- a/ui/gfx/gl/gl_context.h
+++ b/ui/gfx/gl/gl_context.h
@@ -9,16 +9,16 @@
#include <string>
#include "base/basictypes.h"
-#include "base/memory/ref_counted.h"
namespace gfx {
class GLSurface;
// Encapsulates an OpenGL context, hiding platform specific management.
-class GLContext : public base::RefCounted<GLContext> {
+class GLContext {
public:
- GLContext();
+ GLContext() {}
+ virtual ~GLContext() {}
// Initializes the GL context to be compatible with the given surface. The GL
// context can be made with other surface's of the same type. The compatible
@@ -56,17 +56,12 @@ class GLContext : public base::RefCounted<GLContext> {
// Create a GL context that is compatible with the given surface.
// |share_context|, if non-NULL, is a context which the
// internally created OpenGL context shares textures and other resources.
- static scoped_refptr<GLContext> CreateGLContext(
- GLContext* shared_context,
- GLSurface* compatible_surface);
+ static GLContext* CreateGLContext(GLContext* shared_context,
+ GLSurface* compatible_surface);
static bool LosesAllContextsOnContextLost();
- protected:
- virtual ~GLContext();
-
private:
- friend class base::RefCounted<GLContext>;
DISALLOW_COPY_AND_ASSIGN(GLContext);
};
diff --git a/ui/gfx/gl/gl_context_linux.cc b/ui/gfx/gl/gl_context_linux.cc
index 8cf2eeb..b68ed183 100644
--- a/ui/gfx/gl/gl_context_linux.cc
+++ b/ui/gfx/gl/gl_context_linux.cc
@@ -20,30 +20,29 @@
namespace gfx {
-scoped_refptr<GLContext> GLContext::CreateGLContext(
- GLContext* shared_context,
- GLSurface* compatible_surface) {
+GLContext* GLContext::CreateGLContext(GLContext* shared_context,
+ GLSurface* compatible_surface) {
switch (GetGLImplementation()) {
case kGLImplementationOSMesaGL: {
- scoped_refptr<GLContext> context(new GLContextOSMesa);
+ scoped_ptr<GLContextOSMesa> context(new GLContextOSMesa);
if (!context->Initialize(shared_context, compatible_surface))
return NULL;
- return context;
+ return context.release();
}
case kGLImplementationEGLGLES2: {
- scoped_refptr<GLContext> context(new GLContextEGL);
+ scoped_ptr<GLContextEGL> context(new GLContextEGL);
if (!context->Initialize(shared_context, compatible_surface))
return NULL;
- return context;
+ return context.release();
}
case kGLImplementationDesktopGL: {
- scoped_refptr<GLContext> context(new GLContextGLX);
+ scoped_ptr<GLContextGLX> context(new GLContextGLX);
if (!context->Initialize(shared_context, compatible_surface))
return NULL;
- return context;
+ return context.release();
}
case kGLImplementationMockGL:
return new GLContextStub;
diff --git a/ui/gfx/gl/gl_context_mac.cc b/ui/gfx/gl/gl_context_mac.cc
index 482d93d..5627d2c 100644
--- a/ui/gfx/gl/gl_context_mac.cc
+++ b/ui/gfx/gl/gl_context_mac.cc
@@ -16,23 +16,22 @@
namespace gfx {
-scoped_refptr<GLContext> GLContext::CreateGLContext(
- GLContext* shared_context,
- GLSurface* compatible_surface) {
+GLContext* GLContext::CreateGLContext(GLContext* shared_context,
+ GLSurface* compatible_surface) {
switch (GetGLImplementation()) {
case kGLImplementationDesktopGL: {
- scoped_refptr<GLContext> context(new GLContextCGL);
+ scoped_ptr<GLContextCGL> context(new GLContextCGL);
if (!context->Initialize(shared_context, compatible_surface))
return NULL;
- return context;
+ return context.release();
}
case kGLImplementationOSMesaGL: {
- scoped_refptr<GLContext> context(new GLContextOSMesa);
+ scoped_ptr<GLContextOSMesa> context(new GLContextOSMesa);
if (!context->Initialize(shared_context, compatible_surface))
return NULL;
- return context;
+ return context.release();
}
case kGLImplementationMockGL:
return new GLContextStub;
diff --git a/ui/gfx/gl/gl_context_win.cc b/ui/gfx/gl/gl_context_win.cc
index c9f90706..90bca79 100644
--- a/ui/gfx/gl/gl_context_win.cc
+++ b/ui/gfx/gl/gl_context_win.cc
@@ -20,30 +20,29 @@
namespace gfx {
-scoped_refptr<GLContext> GLContext::CreateGLContext(
- GLContext* shared_context,
- GLSurface* compatible_surface) {
+GLContext* GLContext::CreateGLContext(GLContext* shared_context,
+ GLSurface* compatible_surface) {
switch (GetGLImplementation()) {
case kGLImplementationOSMesaGL: {
- scoped_refptr<GLContext> context(new GLContextOSMesa);
+ scoped_ptr<GLContextOSMesa> context(new GLContextOSMesa);
if (!context->Initialize(shared_context, compatible_surface))
return NULL;
- return context;
+ return context.release();
}
case kGLImplementationEGLGLES2: {
- scoped_refptr<GLContext> context(new GLContextEGL);
+ scoped_ptr<GLContextEGL> context(new GLContextEGL);
if (!context->Initialize(shared_context, compatible_surface))
return NULL;
- return context;
+ return context.release();
}
case kGLImplementationDesktopGL: {
- scoped_refptr<GLContext> context(new GLContextWGL);
+ scoped_ptr<GLContextWGL> context(new GLContextWGL);
if (!context->Initialize(shared_context, compatible_surface))
return NULL;
- return context;
+ return context.release();
}
case kGLImplementationMockGL:
return new GLContextStub;
diff --git a/ui/gfx/gl/gl_surface.h b/ui/gfx/gl/gl_surface.h
index 513f37d..9c1dcc4 100644
--- a/ui/gfx/gl/gl_surface.h
+++ b/ui/gfx/gl/gl_surface.h
@@ -6,7 +6,6 @@
#define UI_GFX_GL_GL_SURFACE_H_
#pragma once
-#include "base/memory/ref_counted.h"
#include "build/build_config.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/size.h"
@@ -15,9 +14,10 @@ namespace gfx {
// Encapsulates a surface that can be rendered to with GL, hiding platform
// specific management.
-class GLSurface : public base::RefCounted<GLSurface> {
+class GLSurface {
public:
GLSurface();
+ virtual ~GLSurface();
// (Re)create the surface. TODO(apatrick): This is an ugly hack to allow the
// EGL surface associated to be recreated without destroying the associated
@@ -49,19 +49,13 @@ class GLSurface : public base::RefCounted<GLSurface> {
#if !defined(OS_MACOSX)
// Create a GL surface that renders directly to a view.
- static scoped_refptr<GLSurface> CreateViewGLSurface(
- gfx::PluginWindowHandle window);
+ static GLSurface* CreateViewGLSurface(gfx::PluginWindowHandle window);
#endif
// Create a GL surface used for offscreen rendering.
- static scoped_refptr<GLSurface> CreateOffscreenGLSurface(
- const gfx::Size& size);
-
- protected:
- virtual ~GLSurface();
+ static GLSurface* CreateOffscreenGLSurface(const gfx::Size& size);
private:
- friend class base::RefCounted<GLSurface>;
DISALLOW_COPY_AND_ASSIGN(GLSurface);
};
diff --git a/ui/gfx/gl/gl_surface_linux.cc b/ui/gfx/gl/gl_surface_linux.cc
index fe96989..26c1631 100644
--- a/ui/gfx/gl/gl_surface_linux.cc
+++ b/ui/gfx/gl/gl_surface_linux.cc
@@ -243,32 +243,31 @@ bool NativeViewGLSurfaceOSMesa::UpdateSize() {
return true;
}
-scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
- gfx::PluginWindowHandle window) {
+GLSurface* GLSurface::CreateViewGLSurface(gfx::PluginWindowHandle window) {
switch (GetGLImplementation()) {
case kGLImplementationOSMesaGL: {
- scoped_refptr<GLSurface> surface(
+ scoped_ptr<NativeViewGLSurfaceOSMesa> surface(
new NativeViewGLSurfaceOSMesa(window));
if (!surface->Initialize())
return NULL;
- return surface;
+ return surface.release();
}
case kGLImplementationEGLGLES2: {
- scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceEGL(
+ scoped_ptr<NativeViewGLSurfaceEGL> surface(new NativeViewGLSurfaceEGL(
window));
if (!surface->Initialize())
return NULL;
- return surface;
+ return surface.release();
}
case kGLImplementationDesktopGL: {
- scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceGLX(
+ scoped_ptr<NativeViewGLSurfaceGLX> surface(new NativeViewGLSurfaceGLX(
window));
if (!surface->Initialize())
return NULL;
- return surface;
+ return surface.release();
}
case kGLImplementationMockGL:
return new GLSurfaceStub;
@@ -278,30 +277,29 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
}
}
-scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface(
- const gfx::Size& size) {
+GLSurface* GLSurface::CreateOffscreenGLSurface(const gfx::Size& size) {
switch (GetGLImplementation()) {
case kGLImplementationOSMesaGL: {
- scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(OSMESA_RGBA,
- size));
+ scoped_ptr<GLSurfaceOSMesa> surface(new GLSurfaceOSMesa(OSMESA_RGBA,
+ size));
if (!surface->Initialize())
return NULL;
- return surface;
+ return surface.release();
}
case kGLImplementationEGLGLES2: {
- scoped_refptr<GLSurface> surface(new PbufferGLSurfaceEGL(size));
+ scoped_ptr<PbufferGLSurfaceEGL> surface(new PbufferGLSurfaceEGL(size));
if (!surface->Initialize())
return NULL;
- return surface;
+ return surface.release();
}
case kGLImplementationDesktopGL: {
- scoped_refptr<GLSurface> surface(new PbufferGLSurfaceGLX(size));
+ scoped_ptr<PbufferGLSurfaceGLX> surface(new PbufferGLSurfaceGLX(size));
if (!surface->Initialize())
return NULL;
- return surface;
+ return surface.release();
}
case kGLImplementationMockGL:
return new GLSurfaceStub;
diff --git a/ui/gfx/gl/gl_surface_mac.cc b/ui/gfx/gl/gl_surface_mac.cc
index 2367679..bb08ef8 100644
--- a/ui/gfx/gl/gl_surface_mac.cc
+++ b/ui/gfx/gl/gl_surface_mac.cc
@@ -50,24 +50,23 @@ bool GLSurface::InitializeOneOff() {
// TODO(apatrick): support ViewGLSurface on mac.
#if 0
-scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
- gfx::PluginWindowHandle window) {
+GLSurface* GLSurface::CreateViewGLSurface(gfx::PluginWindowHandle window) {
switch (GetGLImplementation()) {
case kGLImplementationOSMesaGL: {
- scoped_refptr<GLSurface> surface(
+ scoped_ptr<NativeViewGLSurfaceOSMesa> surface(
new NativeViewGLSurfaceOSMesa(window));
if (!surface->Initialize())
return NULL;
- return surface;
+ return surface.release();
}
case kGLImplementationDesktopGL: {
- scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceCGL(
+ scoped_ptr<NativeViewGLSurfaceCGL> surface(new NativeViewGLSurfaceCGL(
window));
if (!surface->Initialize())
return NULL;
- return surface;
+ return surface.release();
}
case kGLImplementationMockGL:
return new GLSurfaceStub;
@@ -78,23 +77,22 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
}
#endif
-scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface(
- const gfx::Size& size) {
+GLSurface* GLSurface::CreateOffscreenGLSurface(const gfx::Size& size) {
switch (GetGLImplementation()) {
case kGLImplementationOSMesaGL: {
- scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(OSMESA_RGBA,
- size));
+ scoped_ptr<GLSurfaceOSMesa> surface(new GLSurfaceOSMesa(OSMESA_RGBA,
+ size));
if (!surface->Initialize())
return NULL;
- return surface;
+ return surface.release();
}
case kGLImplementationDesktopGL: {
- scoped_refptr<GLSurface> surface(new PbufferGLSurfaceCGL(size));
+ scoped_ptr<PbufferGLSurfaceCGL> surface(new PbufferGLSurfaceCGL(size));
if (!surface->Initialize())
return NULL;
- return surface;
+ return surface.release();
}
case kGLImplementationMockGL:
return new GLSurfaceStub;
diff --git a/ui/gfx/gl/gl_surface_win.cc b/ui/gfx/gl/gl_surface_win.cc
index 6b3ea8c..594a263 100644
--- a/ui/gfx/gl/gl_surface_win.cc
+++ b/ui/gfx/gl/gl_surface_win.cc
@@ -167,32 +167,31 @@ void NativeViewGLSurfaceOSMesa::UpdateSize() {
Resize(window_size);
}
-scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
- gfx::PluginWindowHandle window) {
+GLSurface* GLSurface::CreateViewGLSurface(gfx::PluginWindowHandle window) {
switch (GetGLImplementation()) {
case kGLImplementationOSMesaGL: {
- scoped_refptr<GLSurface> surface(
+ scoped_ptr<NativeViewGLSurfaceOSMesa> surface(
new NativeViewGLSurfaceOSMesa(window));
if (!surface->Initialize())
return NULL;
- return surface;
+ return surface.release();
}
case kGLImplementationEGLGLES2: {
- scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceEGL(
+ scoped_ptr<NativeViewGLSurfaceEGL> surface(new NativeViewGLSurfaceEGL(
window));
if (!surface->Initialize())
return NULL;
- return surface;
+ return surface.release();
}
case kGLImplementationDesktopGL: {
- scoped_refptr<GLSurface> surface(new NativeViewGLSurfaceWGL(
+ scoped_ptr<NativeViewGLSurfaceWGL> surface(new NativeViewGLSurfaceWGL(
window));
if (!surface->Initialize())
return NULL;
- return surface;
+ return surface.release();
}
case kGLImplementationMockGL:
return new GLSurfaceStub;
@@ -202,30 +201,29 @@ scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface(
}
}
-scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface(
- const gfx::Size& size) {
+GLSurface* GLSurface::CreateOffscreenGLSurface(const gfx::Size& size) {
switch (GetGLImplementation()) {
case kGLImplementationOSMesaGL: {
- scoped_refptr<GLSurface> surface(new GLSurfaceOSMesa(OSMESA_RGBA,
- size));
+ scoped_ptr<GLSurfaceOSMesa> surface(new GLSurfaceOSMesa(OSMESA_RGBA,
+ size));
if (!surface->Initialize())
return NULL;
- return surface;
+ return surface.release();
}
case kGLImplementationEGLGLES2: {
- scoped_refptr<GLSurface> surface(new PbufferGLSurfaceEGL(size));
+ scoped_ptr<PbufferGLSurfaceEGL> surface(new PbufferGLSurfaceEGL(size));
if (!surface->Initialize())
return NULL;
- return surface;
+ return surface.release();
}
case kGLImplementationDesktopGL: {
- scoped_refptr<GLSurface> surface(new PbufferGLSurfaceWGL(size));
+ scoped_ptr<PbufferGLSurfaceWGL> surface(new PbufferGLSurfaceWGL(size));
if (!surface->Initialize())
return NULL;
- return surface;
+ return surface.release();
}
case kGLImplementationMockGL:
return new GLSurfaceStub;
diff --git a/ui/gfx/surface/accelerated_surface_mac.cc b/ui/gfx/surface/accelerated_surface_mac.cc
index ce2f7a0..a749c46 100644
--- a/ui/gfx/surface/accelerated_surface_mac.cc
+++ b/ui/gfx/surface/accelerated_surface_mac.cc
@@ -35,14 +35,14 @@ bool AcceleratedSurface::Initialize(gfx::GLContext* share_context,
if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL)
return false;
- gl_surface_ = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1));
+ gl_surface_.reset(gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1)));
if (!gl_surface_.get()) {
Destroy();
return false;
}
- gl_context_ = gfx::GLContext::CreateGLContext(share_context,
- gl_surface_.get());
+ gl_context_.reset(gfx::GLContext::CreateGLContext(share_context,
+ gl_surface_.get()));
if (!gl_context_.get()) {
Destroy();
return false;
@@ -66,8 +66,8 @@ void AcceleratedSurface::Destroy() {
}
transport_dib_.reset();
- gl_context_ = NULL;
- gl_surface_ = NULL;
+ gl_context_.reset();
+ gl_surface_.reset();
}
// Call after making changes to the surface which require a visual update.
diff --git a/ui/gfx/surface/accelerated_surface_mac.h b/ui/gfx/surface/accelerated_surface_mac.h
index d9ee833..13bec9b 100644
--- a/ui/gfx/surface/accelerated_surface_mac.h
+++ b/ui/gfx/surface/accelerated_surface_mac.h
@@ -129,8 +129,8 @@ class AcceleratedSurface {
// speaking, we do not need to allocate a GL context all of the
// time. We only need one if (a) we are using the IOSurface code
// path, or (b) if we are allocating an FBO internally.
- scoped_refptr<gfx::GLSurface> gl_surface_;
- scoped_refptr<gfx::GLContext> gl_context_;
+ scoped_ptr<gfx::GLSurface> gl_surface_;
+ scoped_ptr<gfx::GLContext> gl_context_;
// Either |io_surface_| or |transport_dib_| is a valid pointer, but not both.
// |io_surface_| is non-NULL if the IOSurface APIs are supported (Mac OS X
// 10.6 and later).