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

Unified Diff: ui/gfx/gl/gl_context_cgl.cc

Issue 7021014: GLContext no longer holds a pointer to a GLSurface. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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: ui/gfx/gl/gl_context_cgl.cc
===================================================================
--- ui/gfx/gl/gl_context_cgl.cc (revision 86168)
+++ ui/gfx/gl/gl_context_cgl.cc (working copy)
@@ -10,16 +10,18 @@
namespace gfx {
-GLContextCGL::GLContextCGL(GLSurfaceCGL* surface)
- : surface_(surface),
- context_(NULL) {
+GLContextCGL::GLContextCGL()
+ : context_(NULL) {
}
GLContextCGL::~GLContextCGL() {
Destroy();
}
-bool GLContextCGL::Initialize(GLContext* shared_context) {
+bool GLContextCGL::Initialize(GLContext* shared_context,
+ GLSurface* compatible_surface) {
+ DCHECK(compatible_surface);
+
CGLError res = CGLCreateContext(
static_cast<CGLPixelFormatObj>(GLSurfaceCGL::GetPixelFormat()),
shared_context ?
@@ -41,12 +43,13 @@
}
}
-bool GLContextCGL::MakeCurrent() {
- if (IsCurrent())
+bool GLContextCGL::MakeCurrent(GLSurface* surface) {
+ DCHECK(context_);
+ if (IsCurrent(surface))
return true;
if (CGLSetPBuffer(static_cast<CGLContextObj>(context_),
- static_cast<CGLPBufferObj>(surface_->GetHandle()),
+ static_cast<CGLPBufferObj>(surface->GetHandle()),
0,
0,
0) != kCGLNoError) {
@@ -64,23 +67,33 @@
return true;
}
-bool GLContextCGL::IsCurrent() {
- return CGLGetCurrentContext() == context_;
-}
+void GLContextCGL::ReleaseCurrent(GLSurface* surface) {
+ if (!IsCurrent(surface))
+ return;
-bool GLContextCGL::IsOffscreen() {
- // TODO(apatrick): remove this from GLContext interface.
- return surface_->IsOffscreen();
+ CGLSetCurrentContext(NULL);
+ CGLSetPBuffer(static_cast<CGLContextObj>(context_), NULL, 0, 0, 0);
}
-bool GLContextCGL::SwapBuffers() {
- // TODO(apatrick): remove this from GLContext interface.
- return surface_->SwapBuffers();
-}
+bool GLContextCGL::IsCurrent(GLSurface* surface) {
+ if (CGLGetCurrentContext() != context_)
+ return false;
-gfx::Size GLContextCGL::GetSize() {
- // TODO(apatrick): remove this from GLContext interface.
- return surface_->GetSize();
+ if (surface) {
+ CGLPBufferObj current_surface = NULL;
+ GLenum face;
+ GLint level;
+ GLint screen;
+ CGLGetPBuffer(static_cast<CGLContextObj>(context_),
+ &current_surface,
+ &face,
+ &level,
+ &screen);
+ if (current_surface != surface->GetHandle())
+ return false;
+ }
+
+ return true;
}
void* GLContextCGL::GetHandle() {
@@ -88,7 +101,7 @@
}
void GLContextCGL::SetSwapInterval(int interval) {
- DCHECK(IsCurrent());
+ DCHECK(IsCurrent(NULL));
NOTREACHED() << "Attempt to call SetSwapInterval on a GLContextCGL.";
}

Powered by Google App Engine
This is Rietveld 408576698