summaryrefslogtreecommitdiffstats
path: root/ui/gfx
diff options
context:
space:
mode:
authorbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-11 19:09:51 +0000
committerbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-11 19:09:51 +0000
commiteca11a358bfe19b8f9dd97d32e0cc3cefd51be43 (patch)
tree830a88b432b3438e59978f33e68ddd617cd83e8c /ui/gfx
parent42060ffcd7e24250678b8389814232e1a5b3fc0a (diff)
downloadchromium_src-eca11a358bfe19b8f9dd97d32e0cc3cefd51be43.zip
chromium_src-eca11a358bfe19b8f9dd97d32e0cc3cefd51be43.tar.gz
chromium_src-eca11a358bfe19b8f9dd97d32e0cc3cefd51be43.tar.bz2
Use ScopedMakeCurrent
Then we don't have to think about switching contexts on the display path. BUG=None TEST=None Review URL: http://codereview.chromium.org/8463018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109667 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx')
-rw-r--r--ui/gfx/compositor/compositor.h7
-rw-r--r--ui/gfx/compositor/compositor_cc.cc8
-rw-r--r--ui/gfx/compositor/compositor_cc.h3
-rw-r--r--ui/gfx/compositor/compositor_gl.cc13
-rw-r--r--ui/gfx/compositor/compositor_gl.h6
5 files changed, 20 insertions, 17 deletions
diff --git a/ui/gfx/compositor/compositor.h b/ui/gfx/compositor/compositor.h
index 9343975..bbf09d0 100644
--- a/ui/gfx/compositor/compositor.h
+++ b/ui/gfx/compositor/compositor.h
@@ -18,6 +18,7 @@ class SkCanvas;
namespace gfx {
class Point;
class Rect;
+class ScopedMakeCurrent;
}
namespace ui {
@@ -28,7 +29,11 @@ class Layer;
class SharedResources {
public:
virtual ~SharedResources() {}
- virtual bool MakeSharedContextCurrent() = 0;
+
+ // Creates an instance of ScopedMakeCurrent.
+ // Note: Caller is responsible for managing lifetime of returned pointer.
+ virtual gfx::ScopedMakeCurrent* GetScopedMakeCurrent() = 0;
+
virtual void* GetDisplay() = 0;
};
diff --git a/ui/gfx/compositor/compositor_cc.cc b/ui/gfx/compositor/compositor_cc.cc
index 6649f38..8f50f4c 100644
--- a/ui/gfx/compositor/compositor_cc.cc
+++ b/ui/gfx/compositor/compositor_cc.cc
@@ -11,6 +11,7 @@
#include "ui/gfx/gl/gl_context.h"
#include "ui/gfx/gl/gl_surface.h"
#include "ui/gfx/gl/gl_implementation.h"
+#include "ui/gfx/gl/scoped_make_current.h"
#include "webkit/glue/webthread_impl.h"
#include "webkit/gpu/webgraphicscontext3d_in_process_impl.h"
@@ -81,9 +82,12 @@ void SharedResourcesCC::Destroy() {
initialized_ = false;
}
-bool SharedResourcesCC::MakeSharedContextCurrent() {
+gfx::ScopedMakeCurrent* SharedResourcesCC::GetScopedMakeCurrent() {
DCHECK(initialized_);
- return context_->MakeCurrent(surface_.get());
+ if (initialized_)
+ return new gfx::ScopedMakeCurrent(context_.get(), surface_.get());
+ else
+ return NULL;
}
void* SharedResourcesCC::GetDisplay() {
diff --git a/ui/gfx/compositor/compositor_cc.h b/ui/gfx/compositor/compositor_cc.h
index 7c4e4d8..b3117e1 100644
--- a/ui/gfx/compositor/compositor_cc.h
+++ b/ui/gfx/compositor/compositor_cc.h
@@ -30,7 +30,8 @@ class COMPOSITOR_EXPORT SharedResourcesCC
public:
static SharedResourcesCC* GetInstance();
- virtual bool MakeSharedContextCurrent();
+ virtual gfx::ScopedMakeCurrent* GetScopedMakeCurrent() OVERRIDE;
+
virtual void* GetDisplay();
gfx::GLShareGroup* GetShareGroup();
diff --git a/ui/gfx/compositor/compositor_gl.cc b/ui/gfx/compositor/compositor_gl.cc
index 078556b..4134687 100644
--- a/ui/gfx/compositor/compositor_gl.cc
+++ b/ui/gfx/compositor/compositor_gl.cc
@@ -342,15 +342,12 @@ void SharedResourcesGL::Destroy() {
initialized_ = false;
}
-bool SharedResourcesGL::MakeSharedContextCurrent() {
- if (!initialized_)
- return false;
- else
- return context_->MakeCurrent(surface_.get());
-}
-
gfx::ScopedMakeCurrent* SharedResourcesGL::GetScopedMakeCurrent() {
- return new gfx::ScopedMakeCurrent(context_.get(), surface_.get());
+ DCHECK(initialized_);
+ if (initialized_)
+ return new gfx::ScopedMakeCurrent(context_.get(), surface_.get());
+ else
+ return NULL;
}
scoped_refptr<gfx::GLContext> SharedResourcesGL::CreateContext(
diff --git a/ui/gfx/compositor/compositor_gl.h b/ui/gfx/compositor/compositor_gl.h
index 871f7aa..94475dc 100644
--- a/ui/gfx/compositor/compositor_gl.h
+++ b/ui/gfx/compositor/compositor_gl.h
@@ -31,11 +31,7 @@ class COMPOSITOR_EXPORT SharedResourcesGL : public SharedResources {
public:
static SharedResourcesGL* GetInstance();
- virtual bool MakeSharedContextCurrent();
-
- // Creates an instance of ScopedMakeCurrent.
- // Note: Caller is responsible for managing lifetime of returned pointer.
- gfx::ScopedMakeCurrent* GetScopedMakeCurrent();
+ virtual gfx::ScopedMakeCurrent* GetScopedMakeCurrent() OVERRIDE;
// Creates a context that shares the resources hosted by this singleton.
scoped_refptr<gfx::GLContext> CreateContext(gfx::GLSurface* surface);