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

Unified Diff: cc/output/output_surface.cc

Issue 916723002: cc: Add threaded GPU rasterization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Implement ContextProviderInProcess::DetachFromThread(). Created 5 years, 10 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: cc/output/output_surface.cc
diff --git a/cc/output/output_surface.cc b/cc/output/output_surface.cc
index 7a0218b0b66abed092b440937a661a3bdebf6f7f..b1a2b9a4647121746fcd342a22d5f2be7d9cd24c 100644
--- a/cc/output/output_surface.cc
+++ b/cc/output/output_surface.cc
@@ -134,21 +134,33 @@ bool OutputSurface::BindToClient(OutputSurfaceClient* client) {
}
bool OutputSurface::InitializeAndSetContext3d(
- scoped_refptr<ContextProvider> context_provider) {
+ scoped_refptr<ContextProvider> context_provider,
+ scoped_refptr<ContextProvider> worker_context_provider) {
DCHECK(!context_provider_.get());
DCHECK(context_provider.get());
DCHECK(client_);
- bool success = false;
- if (context_provider->BindToCurrentThread()) {
+ bool success = context_provider->BindToCurrentThread();
+ if (success) {
context_provider_ = context_provider;
SetUpContext3d();
- client_->DeferredInitialize();
- success = true;
+ }
+ if (success && worker_context_provider.get()) {
+ success = worker_context_provider->BindToCurrentThread();
+ if (success) {
+ worker_context_provider_ = worker_context_provider;
+ // The destructor resets the context lost callback, so base::Unretained
+ // is safe, as long as the worker threads stop using the context before
+ // the output surface is destroyed.
+ worker_context_provider_->SetLostContextCallback(base::Bind(
+ &OutputSurface::DidLoseOutputSurface, base::Unretained(this)));
+ }
}
if (!success)
ResetContext3d();
+ else
+ client_->DeferredInitialize();
return success;
}

Powered by Google App Engine
This is Rietveld 408576698