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

Unified Diff: ui/gfx/gl/gl_context_egl.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_egl.cc
===================================================================
--- ui/gfx/gl/gl_context_egl.cc (revision 86168)
+++ ui/gfx/gl/gl_context_egl.cc (working copy)
@@ -32,9 +32,8 @@
return GLContext::GetExtensions() + " " + extensions;
}
-GLContextEGL::GLContextEGL(GLSurfaceEGL* surface)
- : surface_(surface),
- context_(NULL)
+GLContextEGL::GLContextEGL()
+ : context_(NULL)
{
}
@@ -42,7 +41,9 @@
Destroy();
}
-bool GLContextEGL::Initialize(GLContext* shared_context) {
+bool GLContextEGL::Initialize(GLContext* shared_context,
+ GLSurface* compatible_surface) {
+ DCHECK(compatible_surface);
DCHECK(!context_);
static const EGLint kContextAttributes[] = {
@@ -62,18 +63,6 @@
return false;
}
- if (!MakeCurrent()) {
- LOG(ERROR) << "MakeCurrent failed.";
- Destroy();
- return false;
- }
-
- if (!InitializeCommon()) {
- LOG(ERROR) << "GLContext::InitializeCommon failed.";
- Destroy();
- return false;
- }
-
return true;
}
@@ -86,21 +75,16 @@
context_ = NULL;
}
-
- if (surface_.get()) {
- surface_->Destroy();
- surface_.reset();
- }
}
-bool GLContextEGL::MakeCurrent() {
+bool GLContextEGL::MakeCurrent(GLSurface* surface) {
DCHECK(context_);
- if (IsCurrent())
+ if (IsCurrent(surface))
return true;
if (!eglMakeCurrent(GLSurfaceEGL::GetDisplay(),
- surface_->GetHandle(),
- surface_->GetHandle(),
+ surface->GetHandle(),
+ surface->GetHandle(),
context_)) {
VLOG(1) << "eglMakeCurrent failed with error "
<< GetLastEGLErrorString();
@@ -110,8 +94,8 @@
return true;
}
-void GLContextEGL::ReleaseCurrent() {
- if (!IsCurrent())
+void GLContextEGL::ReleaseCurrent(GLSurface* surface) {
+ if (!IsCurrent(surface))
return;
eglMakeCurrent(GLSurfaceEGL::GetDisplay(),
@@ -120,38 +104,25 @@
EGL_NO_CONTEXT);
}
-bool GLContextEGL::IsCurrent() {
+bool GLContextEGL::IsCurrent(GLSurface* surface) {
DCHECK(context_);
- return context_ == eglGetCurrentContext() &&
- surface_->GetHandle() == eglGetCurrentSurface(EGL_DRAW);
-}
+ if (context_ != eglGetCurrentContext())
+ return false;
-bool GLContextEGL::IsOffscreen() {
- // TODO(apatrick): remove this from GLContext interface.
- return surface_->IsOffscreen();
-}
+ if (surface) {
+ if (surface->GetHandle() != eglGetCurrentSurface(EGL_DRAW))
+ return false;
+ }
-bool GLContextEGL::SwapBuffers() {
- // TODO(apatrick): remove this from GLContext interface.
- return surface_->SwapBuffers();
+ return true;
}
-gfx::Size GLContextEGL::GetSize() {
- // TODO(apatrick): remove this from GLContext interface.
- return surface_->GetSize();
-}
-
-GLSurface* GLContextEGL::GetSurface() {
- // TODO(apatrick): remove this from GLContext interface.
- return surface_.get();
-}
-
void* GLContextEGL::GetHandle() {
return context_;
}
void GLContextEGL::SetSwapInterval(int interval) {
- DCHECK(IsCurrent());
+ DCHECK(IsCurrent(NULL));
if (!eglSwapInterval(GLSurfaceEGL::GetDisplay(), interval)) {
LOG(ERROR) << "eglSwapInterval failed with error "
<< GetLastEGLErrorString();

Powered by Google App Engine
This is Rietveld 408576698