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

Side by Side Diff: cc/tiles/software_image_decode_controller.h

Issue 1991363003: cc: Plumb gpu/sw image decode limits as layer tree settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
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 #ifndef CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ 5 #ifndef CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_
6 #define CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ 6 #define CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 } 96 }
97 }; 97 };
98 98
99 class CC_EXPORT SoftwareImageDecodeController 99 class CC_EXPORT SoftwareImageDecodeController
100 : public ImageDecodeController, 100 : public ImageDecodeController,
101 public base::trace_event::MemoryDumpProvider { 101 public base::trace_event::MemoryDumpProvider {
102 public: 102 public:
103 using ImageKey = ImageDecodeControllerKey; 103 using ImageKey = ImageDecodeControllerKey;
104 using ImageKeyHash = ImageDecodeControllerKeyHash; 104 using ImageKeyHash = ImageDecodeControllerKeyHash;
105 105
106 explicit SoftwareImageDecodeController(ResourceFormat format); 106 SoftwareImageDecodeController(ResourceFormat format,
107 SoftwareImageDecodeController(); 107 size_t locked_memory_limit_bytes);
108 ~SoftwareImageDecodeController() override; 108 ~SoftwareImageDecodeController() override;
109 109
110 // ImageDecodeController overrides. 110 // ImageDecodeController overrides.
111 bool GetTaskForImageAndRef(const DrawImage& image, 111 bool GetTaskForImageAndRef(const DrawImage& image,
112 const TracingInfo& tracing_info, 112 const TracingInfo& tracing_info,
113 scoped_refptr<TileTask>* task) override; 113 scoped_refptr<TileTask>* task) override;
114 void UnrefImage(const DrawImage& image) override; 114 void UnrefImage(const DrawImage& image) override;
115 DecodedDrawImage GetDecodedImageForDraw(const DrawImage& image) override; 115 DecodedDrawImage GetDecodedImageForDraw(const DrawImage& image) override;
116 void DrawWithImageFinished(const DrawImage& image, 116 void DrawWithImageFinished(const DrawImage& image,
117 const DecodedDrawImage& decoded_image) override; 117 const DecodedDrawImage& decoded_image) override;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 // MemoryBudget is a convenience class for memory bookkeeping and ensuring 170 // MemoryBudget is a convenience class for memory bookkeeping and ensuring
171 // that we don't go over the limit when pre-decoding. 171 // that we don't go over the limit when pre-decoding.
172 class MemoryBudget { 172 class MemoryBudget {
173 public: 173 public:
174 explicit MemoryBudget(size_t limit_bytes); 174 explicit MemoryBudget(size_t limit_bytes);
175 175
176 size_t AvailableMemoryBytes() const; 176 size_t AvailableMemoryBytes() const;
177 void AddUsage(size_t usage); 177 void AddUsage(size_t usage);
178 void SubtractUsage(size_t usage); 178 void SubtractUsage(size_t usage);
179 void ResetUsage(); 179 void ResetUsage();
180 size_t total_limit_bytes() const { return limit_bytes_; }
180 181
181 private: 182 private:
182 size_t GetCurrentUsageSafe() const; 183 size_t GetCurrentUsageSafe() const;
183 184
184 size_t limit_bytes_; 185 size_t limit_bytes_;
185 base::CheckedNumeric<size_t> current_usage_bytes_; 186 base::CheckedNumeric<size_t> current_usage_bytes_;
186 }; 187 };
187 188
188 using ImageMRUCache = base::HashingMRUCache<ImageKey, 189 using ImageMRUCache = base::HashingMRUCache<ImageKey,
189 std::unique_ptr<DecodedImage>, 190 std::unique_ptr<DecodedImage>,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 257
257 ResourceFormat format_; 258 ResourceFormat format_;
258 259
259 // Used to uniquely identify DecodedImages for memory traces. 260 // Used to uniquely identify DecodedImages for memory traces.
260 base::AtomicSequenceNumber next_tracing_id_; 261 base::AtomicSequenceNumber next_tracing_id_;
261 }; 262 };
262 263
263 } // namespace cc 264 } // namespace cc
264 265
265 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_ 266 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CONTROLLER_H_
OLDNEW
« no previous file with comments | « cc/tiles/gpu_image_decode_controller_unittest.cc ('k') | cc/tiles/software_image_decode_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698