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

Side by Side Diff: cc/output/output_surface.cc

Issue 1230203007: Re-land: cc: Use worker context for one-copy tile initialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed output surface lost worker context handling Created 5 years, 5 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 unified diff | Download patch
« no previous file with comments | « cc/output/context_provider.h ('k') | cc/raster/gpu_tile_task_worker_pool.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/output/output_surface.h" 5 #include "cc/output/output_surface.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 resourceless_software_draw); 100 resourceless_software_draw);
101 } 101 }
102 102
103 OutputSurface::~OutputSurface() { 103 OutputSurface::~OutputSurface() {
104 if (context_provider_.get()) { 104 if (context_provider_.get()) {
105 context_provider_->SetLostContextCallback( 105 context_provider_->SetLostContextCallback(
106 ContextProvider::LostContextCallback()); 106 ContextProvider::LostContextCallback());
107 context_provider_->SetMemoryPolicyChangedCallback( 107 context_provider_->SetMemoryPolicyChangedCallback(
108 ContextProvider::MemoryPolicyChangedCallback()); 108 ContextProvider::MemoryPolicyChangedCallback());
109 } 109 }
110 if (worker_context_provider_.get()) {
111 worker_context_provider_->SetLostContextCallback(
112 ContextProvider::LostContextCallback());
113 }
114 } 110 }
115 111
116 bool OutputSurface::HasExternalStencilTest() const { 112 bool OutputSurface::HasExternalStencilTest() const {
117 return external_stencil_test_enabled_; 113 return external_stencil_test_enabled_;
118 } 114 }
119 115
120 bool OutputSurface::BindToClient(OutputSurfaceClient* client) { 116 bool OutputSurface::BindToClient(OutputSurfaceClient* client) {
121 DCHECK(client); 117 DCHECK(client);
122 client_ = client; 118 client_ = client;
123 bool success = true; 119 bool success = true;
124 120
125 if (context_provider_.get()) { 121 if (context_provider_.get()) {
126 success = context_provider_->BindToCurrentThread(); 122 success = context_provider_->BindToCurrentThread();
127 if (success) { 123 if (success) {
128 context_provider_->SetLostContextCallback(base::Bind( 124 context_provider_->SetLostContextCallback(base::Bind(
129 &OutputSurface::DidLoseOutputSurface, base::Unretained(this))); 125 &OutputSurface::DidLoseOutputSurface, base::Unretained(this)));
130 context_provider_->SetMemoryPolicyChangedCallback( 126 context_provider_->SetMemoryPolicyChangedCallback(
131 base::Bind(&OutputSurface::SetMemoryPolicy, base::Unretained(this))); 127 base::Bind(&OutputSurface::SetMemoryPolicy, base::Unretained(this)));
132 } 128 }
133 } 129 }
134 130
135 if (success && worker_context_provider_.get()) { 131 if (success && worker_context_provider_.get())
136 success = worker_context_provider_->BindToCurrentThread(); 132 success = worker_context_provider_->BindToCurrentThread();
137 if (success) {
138 worker_context_provider_->SetupLock();
139 // The destructor resets the context lost callback, so base::Unretained
140 // is safe, as long as the worker threads stop using the context before
141 // the output surface is destroyed.
142 worker_context_provider_->SetLostContextCallback(base::Bind(
143 &OutputSurface::DidLoseOutputSurface, base::Unretained(this)));
reveman 2015/07/24 22:53:54 I had to remove this to be able to share worker co
144 }
145 }
146 133
147 if (!success) 134 if (!success)
148 client_ = NULL; 135 client_ = NULL;
149 136
150 return success; 137 return success;
151 } 138 }
152 139
153 void OutputSurface::EnsureBackbuffer() { 140 void OutputSurface::EnsureBackbuffer() {
154 if (software_device_) 141 if (software_device_)
155 software_device_->EnsureBackbuffer(); 142 software_device_->EnsureBackbuffer();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 OverlayCandidateValidator* OutputSurface::GetOverlayCandidateValidator() const { 197 OverlayCandidateValidator* OutputSurface::GetOverlayCandidateValidator() const {
211 return nullptr; 198 return nullptr;
212 } 199 }
213 200
214 void OutputSurface::SetWorkerContextShouldAggressivelyFreeResources( 201 void OutputSurface::SetWorkerContextShouldAggressivelyFreeResources(
215 bool aggressively_free_resources) { 202 bool aggressively_free_resources) {
216 TRACE_EVENT1("cc", 203 TRACE_EVENT1("cc",
217 "OutputSurface::SetWorkerContextShouldAggressivelyFreeResources", 204 "OutputSurface::SetWorkerContextShouldAggressivelyFreeResources",
218 "aggressively_free_resources", aggressively_free_resources); 205 "aggressively_free_resources", aggressively_free_resources);
219 if (auto* context_provider = worker_context_provider()) { 206 if (auto* context_provider = worker_context_provider()) {
220 // The context lock must be held while accessing the worker context. 207 ContextProvider::ScopedContextLock scoped_context(context_provider);
221 base::AutoLock context_lock(*context_provider->GetLock());
222
223 // Allow context to bind to current thread.
224 context_provider->DetachFromThread();
225 208
226 if (aggressively_free_resources) { 209 if (aggressively_free_resources) {
227 context_provider->DeleteCachedResources(); 210 context_provider->DeleteCachedResources();
228 } 211 }
229 212
230 if (auto* context_support = context_provider->ContextSupport()) { 213 if (auto* context_support = context_provider->ContextSupport()) {
231 context_support->SetAggressivelyFreeResources( 214 context_support->SetAggressivelyFreeResources(
232 aggressively_free_resources); 215 aggressively_free_resources);
233 } 216 }
234
235 // Allow context to bind to other threads.
236 context_provider->DetachFromThread();
237 } 217 }
238 } 218 }
239 219
240 bool OutputSurface::SurfaceIsSuspendForRecycle() const { 220 bool OutputSurface::SurfaceIsSuspendForRecycle() const {
241 return false; 221 return false;
242 } 222 }
243 223
244 } // namespace cc 224 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/context_provider.h ('k') | cc/raster/gpu_tile_task_worker_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698