| 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 #ifndef CC_TILES_GPU_IMAGE_DECODE_CONTROLLER_H_ | 5 #ifndef CC_TILES_GPU_IMAGE_DECODE_CONTROLLER_H_ |
| 6 #define CC_TILES_GPU_IMAGE_DECODE_CONTROLLER_H_ | 6 #define CC_TILES_GPU_IMAGE_DECODE_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <unordered_map> | 9 #include <unordered_map> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 // operate in an "at-raster" mode. In this mode, there are no decode/upload | 47 // operate in an "at-raster" mode. In this mode, there are no decode/upload |
| 48 // tasks, and images are decoded/uploaded as needed, immediately before being | 48 // tasks, and images are decoded/uploaded as needed, immediately before being |
| 49 // used in raster. Cache entries for at-raster tasks are marked as such, which | 49 // used in raster. Cache entries for at-raster tasks are marked as such, which |
| 50 // prevents future tasks from taking a dependency on them and extending their | 50 // prevents future tasks from taking a dependency on them and extending their |
| 51 // lifetime longer than is necessary. | 51 // lifetime longer than is necessary. |
| 52 class CC_EXPORT GpuImageDecodeController | 52 class CC_EXPORT GpuImageDecodeController |
| 53 : public ImageDecodeController, | 53 : public ImageDecodeController, |
| 54 public base::trace_event::MemoryDumpProvider { | 54 public base::trace_event::MemoryDumpProvider { |
| 55 public: | 55 public: |
| 56 explicit GpuImageDecodeController(ContextProvider* context, | 56 explicit GpuImageDecodeController(ContextProvider* context, |
| 57 ResourceFormat decode_format); | 57 ResourceFormat decode_format, |
| 58 size_t max_gpu_image_bytes); |
| 58 ~GpuImageDecodeController() override; | 59 ~GpuImageDecodeController() override; |
| 59 | 60 |
| 60 // ImageDecodeController overrides. | 61 // ImageDecodeController overrides. |
| 61 | 62 |
| 62 // Finds the existing uploaded image for the provided DrawImage. Creates an | 63 // Finds the existing uploaded image for the provided DrawImage. Creates an |
| 63 // upload task to upload the image if an exsiting image does not exist. | 64 // upload task to upload the image if an exsiting image does not exist. |
| 64 bool GetTaskForImageAndRef(const DrawImage& image, | 65 bool GetTaskForImageAndRef(const DrawImage& image, |
| 65 const TracingInfo& tracing_info, | 66 const TracingInfo& tracing_info, |
| 66 scoped_refptr<TileTask>* task) override; | 67 scoped_refptr<TileTask>* task) override; |
| 67 void UnrefImage(const DrawImage& image) override; | 68 void UnrefImage(const DrawImage& image) override; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 std::unordered_map<uint32_t, scoped_refptr<TileTask>> | 182 std::unordered_map<uint32_t, scoped_refptr<TileTask>> |
| 182 pending_image_upload_tasks_; | 183 pending_image_upload_tasks_; |
| 183 std::unordered_map<uint32_t, scoped_refptr<TileTask>> | 184 std::unordered_map<uint32_t, scoped_refptr<TileTask>> |
| 184 pending_image_decode_tasks_; | 185 pending_image_decode_tasks_; |
| 185 | 186 |
| 186 ImageDataMRUCache image_data_; | 187 ImageDataMRUCache image_data_; |
| 187 | 188 |
| 188 size_t cached_items_limit_; | 189 size_t cached_items_limit_; |
| 189 size_t cached_bytes_limit_; | 190 size_t cached_bytes_limit_; |
| 190 size_t bytes_used_; | 191 size_t bytes_used_; |
| 192 const size_t max_gpu_image_bytes_; |
| 191 | 193 |
| 192 // We can't release GPU backed SkImages without holding the context lock, | 194 // We can't release GPU backed SkImages without holding the context lock, |
| 193 // so we add them to this list and defer deletion until the next time the lock | 195 // so we add them to this list and defer deletion until the next time the lock |
| 194 // is held. | 196 // is held. |
| 195 std::vector<sk_sp<SkImage>> images_pending_deletion_; | 197 std::vector<sk_sp<SkImage>> images_pending_deletion_; |
| 196 }; | 198 }; |
| 197 | 199 |
| 198 } // namespace cc | 200 } // namespace cc |
| 199 | 201 |
| 200 #endif // CC_TILES_GPU_IMAGE_DECODE_CONTROLLER_H_ | 202 #endif // CC_TILES_GPU_IMAGE_DECODE_CONTROLLER_H_ |
| OLD | NEW |