Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/debug/alias.h" | |
| 9 #include "base/memory/discardable_memory_allocator.h" | 10 #include "base/memory/discardable_memory_allocator.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" |
| (...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 938 return; | 939 return; |
| 939 } | 940 } |
| 940 | 941 |
| 941 TRACE_EVENT0("cc", "GpuImageDecodeController::DecodeImage"); | 942 TRACE_EVENT0("cc", "GpuImageDecodeController::DecodeImage"); |
| 942 | 943 |
| 943 image_data->decode.ResetData(); | 944 image_data->decode.ResetData(); |
| 944 std::unique_ptr<base::DiscardableMemory> backing_memory; | 945 std::unique_ptr<base::DiscardableMemory> backing_memory; |
| 945 { | 946 { |
| 946 base::AutoUnlock unlock(lock_); | 947 base::AutoUnlock unlock(lock_); |
| 947 | 948 |
| 949 auto image_data_size = image_data->size; | |
|
vmpstr
2016/09/16 00:07:41
nit: size_t instead of auto.
I'm guessing you don
cblume
2016/09/16 00:13:58
I plan to remove this code in short order.
I only
| |
| 950 base::debug::Alias(&image_data_size); | |
| 948 backing_memory = base::DiscardableMemoryAllocator::GetInstance() | 951 backing_memory = base::DiscardableMemoryAllocator::GetInstance() |
| 949 ->AllocateLockedDiscardableMemory(image_data->size); | 952 ->AllocateLockedDiscardableMemory(image_data->size); |
| 950 CHECK(backing_memory); | |
| 951 | 953 |
| 952 switch (image_data->mode) { | 954 switch (image_data->mode) { |
| 953 case DecodedDataMode::CPU: { | 955 case DecodedDataMode::CPU: { |
| 954 SkImageInfo image_info = CreateImageInfoForDrawImage( | 956 SkImageInfo image_info = CreateImageInfoForDrawImage( |
| 955 draw_image, image_data->upload_scale_mip_level); | 957 draw_image, image_data->upload_scale_mip_level); |
| 956 // In order to match GPU scaling quality (which uses mip-maps at high | 958 // In order to match GPU scaling quality (which uses mip-maps at high |
| 957 // quality), we want to use at most medium filter quality for the | 959 // quality), we want to use at most medium filter quality for the |
| 958 // scale. | 960 // scale. |
| 959 SkPixmap image_pixmap(image_info, backing_memory->data(), | 961 SkPixmap image_pixmap(image_info, backing_memory->data(), |
| 960 image_info.minRowBytes()); | 962 image_info.minRowBytes()); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1168 bool GpuImageDecodeController::DiscardableIsLockedForTesting( | 1170 bool GpuImageDecodeController::DiscardableIsLockedForTesting( |
| 1169 const DrawImage& image) { | 1171 const DrawImage& image) { |
| 1170 base::AutoLock lock(lock_); | 1172 base::AutoLock lock(lock_); |
| 1171 auto found = persistent_cache_.Peek(image.image()->uniqueID()); | 1173 auto found = persistent_cache_.Peek(image.image()->uniqueID()); |
| 1172 DCHECK(found != persistent_cache_.end()); | 1174 DCHECK(found != persistent_cache_.end()); |
| 1173 ImageData* image_data = found->second.get(); | 1175 ImageData* image_data = found->second.get(); |
| 1174 return image_data->decode.is_locked(); | 1176 return image_data->decode.is_locked(); |
| 1175 } | 1177 } |
| 1176 | 1178 |
| 1177 } // namespace cc | 1179 } // namespace cc |
| OLD | NEW |