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

Unified Diff: cc/output/output_surface.cc

Issue 1336733002: Re-land: cc: Implement shared worker contexts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: shutdown fix Created 5 years, 3 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 056879f49d84ba444142101690da109437208d14..6ba290c14a9d020b3e5c748583f305ee3eb6fe52 100644
--- a/cc/output/output_surface.cc
+++ b/cc/output/output_surface.cc
@@ -32,6 +32,7 @@ OutputSurface::OutputSurface(
device_scale_factor_(-1),
external_stencil_test_enabled_(false),
weak_ptr_factory_(this) {
+ client_thread_checker_.DetachFromThread();
}
OutputSurface::OutputSurface(
@@ -101,12 +102,8 @@ void OutputSurface::SetExternalDrawConstraints(
}
OutputSurface::~OutputSurface() {
- if (context_provider_.get()) {
- context_provider_->SetLostContextCallback(
- ContextProvider::LostContextCallback());
- context_provider_->SetMemoryPolicyChangedCallback(
- ContextProvider::MemoryPolicyChangedCallback());
- }
+ if (client_)
+ DetachFromClient();
}
bool OutputSurface::HasExternalStencilTest() const {
@@ -115,6 +112,8 @@ bool OutputSurface::HasExternalStencilTest() const {
bool OutputSurface::BindToClient(OutputSurfaceClient* client) {
DCHECK(client);
+ DCHECK(!client_);
+ DCHECK(CalledOnValidClientThread());
client_ = client;
bool success = true;
@@ -128,18 +127,30 @@ bool OutputSurface::BindToClient(OutputSurfaceClient* client) {
}
}
- if (success && worker_context_provider_.get()) {
- success = worker_context_provider_->BindToCurrentThread();
- if (success)
- worker_context_provider_->SetupLock();
- }
-
if (!success)
client_ = NULL;
return success;
}
+void OutputSurface::DetachFromClient() {
+ DCHECK(CalledOnValidClientThread());
+ DCHECK(client_);
+ if (context_provider_.get()) {
+ context_provider_->SetLostContextCallback(
+ ContextProvider::LostContextCallback());
+ context_provider_->SetMemoryPolicyChangedCallback(
+ ContextProvider::MemoryPolicyChangedCallback());
+ }
+ context_provider_ = nullptr;
+ client_ = nullptr;
+ weak_ptr_factory_.InvalidateWeakPtrs();
+}
+
+bool OutputSurface::CalledOnValidClientThread() {
+ return client_thread_checker_.CalledOnValidThread();
+}
+
void OutputSurface::EnsureBackbuffer() {
if (software_device_)
software_device_->EnsureBackbuffer();

Powered by Google App Engine
This is Rietveld 408576698