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

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

Issue 2036553002: cc: Add four new histograms for gpu image decode/upload usage tracking. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | « no previous file | cc/tiles/gpu_image_decode_controller.cc » ('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 #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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 DecodedImageData(); 104 DecodedImageData();
105 ~DecodedImageData(); 105 ~DecodedImageData();
106 106
107 bool is_locked() const { return is_locked_; } 107 bool is_locked() const { return is_locked_; }
108 bool Lock(); 108 bool Lock();
109 void Unlock(); 109 void Unlock();
110 void SetLockedData(std::unique_ptr<base::DiscardableMemory> data); 110 void SetLockedData(std::unique_ptr<base::DiscardableMemory> data);
111 void ResetData(); 111 void ResetData();
112 base::DiscardableMemory* data() const { return data_.get(); } 112 base::DiscardableMemory* data() const { return data_.get(); }
113 113
114 void mark_used() { usage_stats_.used = true; }
115
114 // May be null if image not yet decoded. 116 // May be null if image not yet decoded.
115 uint32_t ref_count = 0; 117 uint32_t ref_count = 0;
116 // Set to true if the image was corrupt and could not be decoded. 118 // Set to true if the image was corrupt and could not be decoded.
117 bool decode_failure = false; 119 bool decode_failure = false;
118 120
119 private: 121 private:
122 struct UsageStats {
123 int lock_count = 1;
124 bool used = false;
125 bool first_lock_wasted = false;
126 };
127
128 void ReportUsageStats() const;
129
120 std::unique_ptr<base::DiscardableMemory> data_; 130 std::unique_ptr<base::DiscardableMemory> data_;
121 bool is_locked_ = false; 131 bool is_locked_ = false;
132 UsageStats usage_stats_;
122 }; 133 };
123 134
124 // Stores the GPU-side image and supporting fields. 135 // Stores the GPU-side image and supporting fields.
125 struct UploadedImageData { 136 struct UploadedImageData {
126 UploadedImageData(); 137 UploadedImageData();
127 ~UploadedImageData(); 138 ~UploadedImageData();
128 139
129 void SetImage(sk_sp<SkImage> image); 140 void SetImage(sk_sp<SkImage> image);
130 const sk_sp<SkImage>& image() const { return image_; } 141 const sk_sp<SkImage>& image() const { return image_; }
131 142
143 void mark_used() { usage_stats_.used = true; }
144 void notify_ref_reached_zero() {
145 if (++usage_stats_.ref_reached_zero_count == 1)
146 usage_stats_.first_ref_wasted = !usage_stats_.used;
147 }
148
132 // True if the image is counting against our memory limits. 149 // True if the image is counting against our memory limits.
133 bool budgeted = false; 150 bool budgeted = false;
134 uint32_t ref_count = 0; 151 uint32_t ref_count = 0;
135 152
136 private: 153 private:
154 struct UsageStats {
155 bool used = false;
156 bool first_ref_wasted = false;
157 int ref_reached_zero_count = 0;
158 };
159
160 void ReportUsageStats() const;
161
137 // May be null if image not yet uploaded / prepared. 162 // May be null if image not yet uploaded / prepared.
138 sk_sp<SkImage> image_; 163 sk_sp<SkImage> image_;
164 UsageStats usage_stats_;
139 }; 165 };
140 166
141 struct ImageData { 167 struct ImageData {
142 ImageData(DecodedDataMode mode, size_t size); 168 ImageData(DecodedDataMode mode, size_t size);
143 ~ImageData(); 169 ~ImageData();
144 170
145 const DecodedDataMode mode; 171 const DecodedDataMode mode;
146 const size_t size; 172 const size_t size;
147 bool is_at_raster = false; 173 bool is_at_raster = false;
148 174
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 234
209 // We can't release GPU backed SkImages without holding the context lock, 235 // We can't release GPU backed SkImages without holding the context lock,
210 // so we add them to this list and defer deletion until the next time the lock 236 // so we add them to this list and defer deletion until the next time the lock
211 // is held. 237 // is held.
212 std::vector<sk_sp<SkImage>> images_pending_deletion_; 238 std::vector<sk_sp<SkImage>> images_pending_deletion_;
213 }; 239 };
214 240
215 } // namespace cc 241 } // namespace cc
216 242
217 #endif // CC_TILES_GPU_IMAGE_DECODE_CONTROLLER_H_ 243 #endif // CC_TILES_GPU_IMAGE_DECODE_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | cc/tiles/gpu_image_decode_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698