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

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder.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: gpu/command_buffer/service/gles2_cmd_decoder.cc
===================================================================
--- gpu/command_buffer/service/gles2_cmd_decoder.cc (revision 86168)
+++ gpu/command_buffer/service/gles2_cmd_decoder.cc (working copy)
@@ -38,6 +38,7 @@
#include "gpu/GLES2/gles2_command_buffer.h"
#include "ui/gfx/gl/gl_context.h"
#include "ui/gfx/gl/gl_implementation.h"
+#include "ui/gfx/gl/gl_surface.h"
#if !defined(GL_DEPTH24_STENCIL8)
#define GL_DEPTH24_STENCIL8 0x88F0
@@ -671,7 +672,8 @@
virtual const char* GetCommandName(unsigned int command_id) const;
// Overridden from GLES2Decoder.
- virtual bool Initialize(gfx::GLContext* context,
+ virtual bool Initialize(gfx::GLSurface* surface,
+ gfx::GLContext* context,
const gfx::Size& size,
const DisallowedExtensions& disallowed_extensions,
const char* allowed_extensions,
@@ -684,6 +686,7 @@
virtual bool MakeCurrent();
virtual GLES2Util* GetGLES2Util() { return &util_; }
virtual gfx::GLContext* GetGLContext() { return context_.get(); }
+ virtual gfx::GLSurface* GetGLSurface() { return surface_.get(); }
virtual ContextGroup* GetContextGroup() { return group_.get(); }
virtual void SetResizeCallback(Callback1<gfx::Size>::Type* callback);
@@ -1337,6 +1340,7 @@
#undef GLES2_CMD_OP
// The GL context this decoder renders to on behalf of the client.
+ scoped_ptr<gfx::GLSurface> surface_;
scoped_ptr<gfx::GLContext> context_;
// The ContextGroup for this decoder uses to track resources.
@@ -1827,6 +1831,7 @@
}
bool GLES2DecoderImpl::Initialize(
+ gfx::GLSurface* surface,
gfx::GLContext* context,
const gfx::Size& size,
const DisallowedExtensions& disallowed_extensions,
@@ -1837,6 +1842,11 @@
DCHECK(context);
DCHECK(!context_.get());
+ // Take ownership of the GLSurface. TODO(apatrick): the decoder should not
+ // own the surface. It should be possible to freely switch the surface the
+ // context renders to.
+ surface_.reset(surface);
+
// Take ownership of the GLContext.
context_.reset(context);
@@ -1895,7 +1905,7 @@
glActiveTexture(GL_TEXTURE0);
CHECK_GL_ERROR();
- if (context_->IsOffscreen()) {
+ if (surface_->IsOffscreen()) {
ContextCreationAttribParser attrib_parser;
if (!attrib_parser.Parse(attribs))
return false;
@@ -2203,7 +2213,7 @@
// } // anonymous namespace
bool GLES2DecoderImpl::MakeCurrent() {
- return context_.get() ? context_->MakeCurrent() : false;
+ return context_.get() ? context_->MakeCurrent(surface_.get()) : false;
}
void GLES2DecoderImpl::RestoreCurrentRenderbufferBindings() {
@@ -2274,7 +2284,7 @@
} else if (offscreen_target_frame_buffer_.get()) {
return offscreen_size_;
} else {
- return context_->GetSize();
+ return surface_->GetSize();
}
}
@@ -2768,7 +2778,7 @@
}
info->MarkAsValid();
} else {
- service_id = context_->GetBackingFrameBufferObject();
+ service_id = 0;
}
if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER_EXT) {
@@ -6384,7 +6394,7 @@
}
} else {
TRACE_EVENT1("gpu", "GLContext::SwapBuffers", "frame", this_frame_number);
- if (!context_->SwapBuffers()) {
+ if (!surface_->SwapBuffers()) {
LOG(ERROR) << "Context lost because SwapBuffers failed.";
return error::kLostContext;
}

Powered by Google App Engine
This is Rietveld 408576698