| OLD | NEW |
| 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 bool resourceless_software_draw) { | 183 bool resourceless_software_draw) { |
| 184 client_->SetExternalDrawConstraints(transform, | 184 client_->SetExternalDrawConstraints(transform, |
| 185 viewport, | 185 viewport, |
| 186 clip, | 186 clip, |
| 187 viewport_rect_for_tile_priority, | 187 viewport_rect_for_tile_priority, |
| 188 transform_for_tile_priority, | 188 transform_for_tile_priority, |
| 189 resourceless_software_draw); | 189 resourceless_software_draw); |
| 190 } | 190 } |
| 191 | 191 |
| 192 OutputSurface::~OutputSurface() { | 192 OutputSurface::~OutputSurface() { |
| 193 // Unregister any dump provider. Safe to call (no-op) if we have not yet | |
| 194 // registered. | |
| 195 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( | |
| 196 this); | |
| 197 | |
| 198 if (client_) | 193 if (client_) |
| 199 DetachFromClientInternal(); | 194 DetachFromClientInternal(); |
| 200 } | 195 } |
| 201 | 196 |
| 202 bool OutputSurface::HasExternalStencilTest() const { | 197 bool OutputSurface::HasExternalStencilTest() const { |
| 203 return external_stencil_test_enabled_; | 198 return external_stencil_test_enabled_; |
| 204 } | 199 } |
| 205 | 200 |
| 206 bool OutputSurface::BindToClient(OutputSurfaceClient* client) { | 201 bool OutputSurface::BindToClient(OutputSurfaceClient* client) { |
| 207 DCHECK(client_thread_checker_.CalledOnValidThread()); | 202 DCHECK(client_thread_checker_.CalledOnValidThread()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 219 base::Bind(&OutputSurface::SetMemoryPolicy, base::Unretained(this))); | 214 base::Bind(&OutputSurface::SetMemoryPolicy, base::Unretained(this))); |
| 220 } | 215 } |
| 221 } | 216 } |
| 222 | 217 |
| 223 if (!success) | 218 if (!success) |
| 224 client_ = NULL; | 219 client_ = NULL; |
| 225 | 220 |
| 226 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview). | 221 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview). |
| 227 // Don't register a dump provider in these cases. | 222 // Don't register a dump provider in these cases. |
| 228 // TODO(ericrk): Get this working in Android Webview. crbug.com/517156 | 223 // TODO(ericrk): Get this working in Android Webview. crbug.com/517156 |
| 229 if (base::ThreadTaskRunnerHandle::IsSet()) { | 224 if (client_ && base::ThreadTaskRunnerHandle::IsSet()) { |
| 230 // Now that we are on the context thread, register a dump provider with this | 225 // Now that we are on the context thread, register a dump provider with this |
| 231 // thread's task runner. This will overwrite any previous dump provider | 226 // thread's task runner. This will overwrite any previous dump provider |
| 232 // registered. | 227 // registered. |
| 233 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( | 228 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( |
| 234 this, base::ThreadTaskRunnerHandle::Get()); | 229 this, base::ThreadTaskRunnerHandle::Get()); |
| 235 } | 230 } |
| 236 | 231 |
| 237 return success; | 232 return success; |
| 238 } | 233 } |
| 239 | 234 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 gr_context->dumpMemoryStatistics(&trace_memory_dump); | 339 gr_context->dumpMemoryStatistics(&trace_memory_dump); |
| 345 } | 340 } |
| 346 } | 341 } |
| 347 | 342 |
| 348 return true; | 343 return true; |
| 349 } | 344 } |
| 350 | 345 |
| 351 void OutputSurface::DetachFromClientInternal() { | 346 void OutputSurface::DetachFromClientInternal() { |
| 352 DCHECK(client_thread_checker_.CalledOnValidThread()); | 347 DCHECK(client_thread_checker_.CalledOnValidThread()); |
| 353 DCHECK(client_); | 348 DCHECK(client_); |
| 349 |
| 350 // Unregister any dump provider. Safe to call (no-op) if we have not yet |
| 351 // registered. |
| 352 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( |
| 353 this); |
| 354 |
| 354 if (context_provider_.get()) { | 355 if (context_provider_.get()) { |
| 355 context_provider_->SetLostContextCallback( | 356 context_provider_->SetLostContextCallback( |
| 356 ContextProvider::LostContextCallback()); | 357 ContextProvider::LostContextCallback()); |
| 357 context_provider_->SetMemoryPolicyChangedCallback( | 358 context_provider_->SetMemoryPolicyChangedCallback( |
| 358 ContextProvider::MemoryPolicyChangedCallback()); | 359 ContextProvider::MemoryPolicyChangedCallback()); |
| 359 } | 360 } |
| 360 context_provider_ = nullptr; | 361 context_provider_ = nullptr; |
| 361 client_ = nullptr; | 362 client_ = nullptr; |
| 362 weak_ptr_factory_.InvalidateWeakPtrs(); | 363 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 363 } | 364 } |
| 364 | 365 |
| 365 } // namespace cc | 366 } // namespace cc |
| OLD | NEW |