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

Side by Side Diff: cc/tiles/gpu_image_decode_controller.cc

Issue 2286583002: Make cc::SoftwareImageDecodeController, cc::ResourcePool, and cc::StagingBufferPoo… (Closed)
Patch Set: Patch for landing Created 4 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 unified diff | Download patch
« no previous file with comments | « cc/tiles/gpu_image_decode_controller.h ('k') | cc/tiles/software_image_decode_controller.h » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/tiles/gpu_image_decode_controller.h" 5 #include "cc/tiles/gpu_image_decode_controller.h"
6 6
7 #include <inttypes.h> 7 #include <inttypes.h>
8 8
9 #include "base/memory/discardable_memory_allocator.h" 9 #include "base/memory/discardable_memory_allocator.h"
10 #include "base/memory/memory_coordinator_client_registry.h"
10 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
11 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
12 #include "base/numerics/safe_math.h" 13 #include "base/numerics/safe_math.h"
13 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
14 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
15 #include "base/trace_event/memory_dump_manager.h" 16 #include "base/trace_event/memory_dump_manager.h"
16 #include "cc/debug/devtools_instrumentation.h" 17 #include "cc/debug/devtools_instrumentation.h"
17 #include "cc/output/context_provider.h" 18 #include "cc/output/context_provider.h"
18 #include "cc/raster/tile_task.h" 19 #include "cc/raster/tile_task.h"
19 #include "cc/resources/resource_format_utils.h" 20 #include "cc/resources/resource_format_utils.h"
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 context->GrContext()->threadSafeProxy()); 342 context->GrContext()->threadSafeProxy());
342 } 343 }
343 344
344 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview). 345 // In certain cases, ThreadTaskRunnerHandle isn't set (Android Webview).
345 // Don't register a dump provider in these cases. 346 // Don't register a dump provider in these cases.
346 if (base::ThreadTaskRunnerHandle::IsSet()) { 347 if (base::ThreadTaskRunnerHandle::IsSet()) {
347 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( 348 base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
348 this, "cc::GpuImageDecodeController", 349 this, "cc::GpuImageDecodeController",
349 base::ThreadTaskRunnerHandle::Get()); 350 base::ThreadTaskRunnerHandle::Get());
350 } 351 }
352 // Register this component with base::MemoryCoordinatorClientRegistry.
353 base::MemoryCoordinatorClientRegistry::GetInstance()->Register(this);
351 } 354 }
352 355
353 GpuImageDecodeController::~GpuImageDecodeController() { 356 GpuImageDecodeController::~GpuImageDecodeController() {
354 // SetShouldAggressivelyFreeResources will zero our limits and free all 357 // SetShouldAggressivelyFreeResources will zero our limits and free all
355 // outstanding image memory. 358 // outstanding image memory.
356 SetShouldAggressivelyFreeResources(true); 359 SetShouldAggressivelyFreeResources(true);
357 360
358 // It is safe to unregister, even if we didn't register in the constructor. 361 // It is safe to unregister, even if we didn't register in the constructor.
359 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider( 362 base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
360 this); 363 this);
364 // Unregister this component with memory_coordinator::ClientRegistry.
365 base::MemoryCoordinatorClientRegistry::GetInstance()->Unregister(this);
361 } 366 }
362 367
363 bool GpuImageDecodeController::GetTaskForImageAndRef( 368 bool GpuImageDecodeController::GetTaskForImageAndRef(
364 const DrawImage& draw_image, 369 const DrawImage& draw_image,
365 const TracingInfo& tracing_info, 370 const TracingInfo& tracing_info,
366 scoped_refptr<TileTask>* task) { 371 scoped_refptr<TileTask>* task) {
367 TRACE_EVENT0("disabled-by-default-cc.debug", 372 TRACE_EVENT0("disabled-by-default-cc.debug",
368 "GpuImageDecodeController::GetTaskForImageAndRef"); 373 "GpuImageDecodeController::GetTaskForImageAndRef");
369 if (SkipImage(draw_image)) { 374 if (SkipImage(draw_image)) {
370 *task = nullptr; 375 *task = nullptr;
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 1172
1168 bool GpuImageDecodeController::DiscardableIsLockedForTesting( 1173 bool GpuImageDecodeController::DiscardableIsLockedForTesting(
1169 const DrawImage& image) { 1174 const DrawImage& image) {
1170 base::AutoLock lock(lock_); 1175 base::AutoLock lock(lock_);
1171 auto found = persistent_cache_.Peek(image.image()->uniqueID()); 1176 auto found = persistent_cache_.Peek(image.image()->uniqueID());
1172 DCHECK(found != persistent_cache_.end()); 1177 DCHECK(found != persistent_cache_.end());
1173 ImageData* image_data = found->second.get(); 1178 ImageData* image_data = found->second.get();
1174 return image_data->decode.is_locked(); 1179 return image_data->decode.is_locked();
1175 } 1180 }
1176 1181
1182 void GpuImageDecodeController::OnMemoryStateChange(base::MemoryState state) {
1183 switch (state) {
1184 case base::MemoryState::NORMAL:
1185 // TODO(tasak): go back to normal state.
1186 break;
1187 case base::MemoryState::THROTTLED:
1188 // TODO(tasak): make the limits of this component's caches smaller to
1189 // save memory usage.
1190 break;
1191 case base::MemoryState::SUSPENDED:
1192 // TODO(tasak): free this component's caches as much as possible before
1193 // suspending renderer.
1194 break;
1195 case base::MemoryState::UNKNOWN:
1196 // NOT_REACHED.
1197 break;
1198 }
1199 }
1200
1177 } // namespace cc 1201 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/gpu_image_decode_controller.h ('k') | cc/tiles/software_image_decode_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698