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

Unified Diff: cc/output/output_surface.cc

Issue 15647021: Factor out cc::OutputSurface::InitializeAndSetContext3D (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
« no previous file with comments | « cc/output/output_surface.h ('k') | cc/output/output_surface_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/output_surface.cc
diff --git a/cc/output/output_surface.cc b/cc/output/output_surface.cc
index 1be41892a648a16d3ab2f6496bae61d0cc0d1f23..84d94b843edfec34473e9fc95623c51445157280 100644
--- a/cc/output/output_surface.cc
+++ b/cc/output/output_surface.cc
@@ -30,7 +30,9 @@ class OutputSurfaceCallbacks
public WebKit::WebGraphicsContext3D::WebGraphicsContextLostCallback {
public:
explicit OutputSurfaceCallbacks(OutputSurfaceClient* client)
- : client_(client) {}
+ : client_(client) {
+ DCHECK(client_);
+ }
// WK:WGC3D::WGSwapBuffersCompleteCallbackCHROMIUM implementation.
virtual void onSwapBuffersComplete() { client_->OnSwapBuffersComplete(); }
@@ -78,24 +80,60 @@ bool OutputSurface::ForcedDrawToSoftwareDevice() const {
bool OutputSurface::BindToClient(
cc::OutputSurfaceClient* client) {
DCHECK(client);
- if (context3d_ && !context3d_->makeContextCurrent())
- return false;
client_ = client;
- if (!context3d_)
- return true;
- string extensions_string = UTF16ToASCII(context3d_->getString(GL_EXTENSIONS));
+ bool success = true;
+
+ if (context3d_) {
+ success = context3d_->makeContextCurrent();
+ if (success)
+ SetContext3D(context3d_.Pass());
+ }
+
+ if (!success)
+ client_ = NULL;
+
+ return success;
+}
+
+bool OutputSurface::InitializeAndSetContext3D(
+ scoped_ptr<WebKit::WebGraphicsContext3D> context3d,
+ scoped_refptr<ContextProvider> offscreen_context_provider) {
+ DCHECK(!context3d_);
+ DCHECK(context3d);
+ DCHECK(client_);
+
+ bool success = false;
+ if (context3d->makeContextCurrent()) {
+ SetContext3D(context3d.Pass());
+ if (client_->DeferredInitialize(offscreen_context_provider))
+ success = true;
+ }
+
+ if (!success) {
+ context3d_.reset();
+ callbacks_.reset();
danakj 2013/06/07 17:32:00 nit: since the callbacks use the context3d, i thin
boliu 2013/06/07 17:34:31 Actually context3d uses callbacks, so the order is
danakj 2013/06/07 17:48:07 Oh, I'm thinking that when callbacks go away they
+ }
+
+ return success;
+}
+
+void OutputSurface::SetContext3D(
+ scoped_ptr<WebKit::WebGraphicsContext3D> context3d) {
+ DCHECK(!context3d_);
+ DCHECK(context3d);
+ DCHECK(client_);
+
+ string extensions_string = UTF16ToASCII(context3d->getString(GL_EXTENSIONS));
vector<string> extensions_list;
base::SplitString(extensions_string, ' ', &extensions_list);
set<string> extensions(extensions_list.begin(), extensions_list.end());
-
has_gl_discard_backbuffer_ =
extensions.count("GL_CHROMIUM_discard_backbuffer") > 0;
+ context3d_ = context3d.Pass();
callbacks_.reset(new OutputSurfaceCallbacks(client_));
context3d_->setSwapBuffersCompleteCallbackCHROMIUM(callbacks_.get());
context3d_->setContextLostCallback(callbacks_.get());
-
- return true;
}
void OutputSurface::SendFrameToParentCompositor(CompositorFrame* frame) {
« no previous file with comments | « cc/output/output_surface.h ('k') | cc/output/output_surface_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698