summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authordhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-30 15:48:22 +0000
committerdhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-30 15:48:22 +0000
commit9f668362af799212f3345477f01540ffbc656ed1 (patch)
tree991707b5a293880d4616695071549d941bccd63b /ui
parent95f1939b70b9959bb82cc219a5dad2d0e4a8509f (diff)
downloadchromium_src-9f668362af799212f3345477f01540ffbc656ed1.zip
chromium_src-9f668362af799212f3345477f01540ffbc656ed1.tar.gz
chromium_src-9f668362af799212f3345477f01540ffbc656ed1.tar.bz2
GLContextNSView should not assume concrete type GLSurface is GLSurfaceNSView
This is follow-up from review http://codereview.chromium.org/8486020. This eliminates down-cast of GLSurface in CLContextNSView::Initialize in favor of GLSurfaceNSView::OnMakeCurrent implementation. Also, allows offscreen path in USE_AURA due to its usage in SharedResourcesCC. BUG=104390 TEST=compositor_unittests --gtest_filter=LayerWithRealCompositorTest.* R=apatrick@chromium.org Review URL: http://codereview.chromium.org/8687016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112231 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/gfx/gl/gl_context_mac.mm10
-rw-r--r--ui/gfx/gl/gl_context_nsview.mm9
-rw-r--r--ui/gfx/gl/gl_surface_nsview.h2
-rw-r--r--ui/gfx/gl/gl_surface_nsview.mm5
4 files changed, 15 insertions, 11 deletions
diff --git a/ui/gfx/gl/gl_context_mac.mm b/ui/gfx/gl/gl_context_mac.mm
index adf67aa..2fcd085 100644
--- a/ui/gfx/gl/gl_context_mac.mm
+++ b/ui/gfx/gl/gl_context_mac.mm
@@ -43,15 +43,15 @@ scoped_refptr<GLContext> GLContext::CreateGLContext(
case kGLImplementationDesktopGL: {
scoped_refptr<GLContext> context;
#if defined(USE_AURA)
- DCHECK(!compatible_surface->IsOffscreen());
- context = new GLContextNSView(share_group);
- if (!context->Initialize(compatible_surface, gpu_preference))
- return NULL;
+ if (compatible_surface->IsOffscreen())
+ context = new GLContextCGL(share_group);
+ else
+ context = new GLContextNSView(share_group);
#else
context = new GLContextCGL(share_group);
+#endif // USE_AURA
if (!context->Initialize(compatible_surface, gpu_preference))
return NULL;
-#endif // USE_AURA
return context;
}
diff --git a/ui/gfx/gl/gl_context_nsview.mm b/ui/gfx/gl/gl_context_nsview.mm
index a3aa7aa..1ad1c6d 100644
--- a/ui/gfx/gl/gl_context_nsview.mm
+++ b/ui/gfx/gl/gl_context_nsview.mm
@@ -46,9 +46,6 @@ bool GLContextNSView::Initialize(GLSurface* surface,
return false;
}
- // Allow the surface to call back when in need of |FlushBuffer|.
- static_cast<GLSurfaceNSView*>(surface)->SetGLContext(this);
-
return true;
}
@@ -64,6 +61,12 @@ bool GLContextNSView::MakeCurrent(GLSurface* surface) {
if ([view window])
[context_ setView:view];
[context_ makeCurrentContext];
+
+ if (!surface->OnMakeCurrent(this)) {
+ LOG(ERROR) << "Unable to make gl context current.";
+ return false;
+ }
+
return true;
}
diff --git a/ui/gfx/gl/gl_surface_nsview.h b/ui/gfx/gl/gl_surface_nsview.h
index 58e1344..a53eaf1 100644
--- a/ui/gfx/gl/gl_surface_nsview.h
+++ b/ui/gfx/gl/gl_surface_nsview.h
@@ -29,7 +29,7 @@ class GLSurfaceNSView : public GLSurface {
virtual void* GetHandle() OVERRIDE;
// Allow the surface to call back to context when in need of |FlushBuffer|.
- void SetGLContext(GLContextNSView* context);
+ virtual bool OnMakeCurrent(GLContext* context) OVERRIDE;
private:
// Weak. An |NSView*|.
diff --git a/ui/gfx/gl/gl_surface_nsview.mm b/ui/gfx/gl/gl_surface_nsview.mm
index 0c7f3aa..e03cb3b 100644
--- a/ui/gfx/gl/gl_surface_nsview.mm
+++ b/ui/gfx/gl/gl_surface_nsview.mm
@@ -39,8 +39,9 @@ void* GLSurfaceNSView::GetHandle() {
return view_;
}
-void GLSurfaceNSView::SetGLContext(GLContextNSView* context) {
- context_ = context;
+bool GLSurfaceNSView::OnMakeCurrent(GLContext* context) {
+ context_ = static_cast<GLContextNSView *>(context);
+ return true;
}
} // namespace gfx