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

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

Issue 2797583002: cc: Add color space to image decode caches (Closed)
Patch Set: Fix perf test compile Created 3 years, 8 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_CACHE_H_ 5 #ifndef CC_TILES_SOFTWARE_IMAGE_DECODE_CACHE_H_
6 #define CC_TILES_SOFTWARE_IMAGE_DECODE_CACHE_H_ 6 #define CC_TILES_SOFTWARE_IMAGE_DECODE_CACHE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 28 matching lines...) Expand all
39 static ImageDecodeCacheKey FromDrawImage(const DrawImage& image); 39 static ImageDecodeCacheKey FromDrawImage(const DrawImage& image);
40 40
41 ImageDecodeCacheKey(const ImageDecodeCacheKey& other); 41 ImageDecodeCacheKey(const ImageDecodeCacheKey& other);
42 42
43 bool operator==(const ImageDecodeCacheKey& other) const { 43 bool operator==(const ImageDecodeCacheKey& other) const {
44 // The image_id always has to be the same. However, after that all original 44 // The image_id always has to be the same. However, after that all original
45 // decodes are the same, so if we can use the original decode, return true. 45 // decodes are the same, so if we can use the original decode, return true.
46 // If not, then we have to compare every field. 46 // If not, then we have to compare every field.
47 return image_id_ == other.image_id_ && 47 return image_id_ == other.image_id_ &&
48 can_use_original_decode_ == other.can_use_original_decode_ && 48 can_use_original_decode_ == other.can_use_original_decode_ &&
49 target_color_space_ == other.target_color_space_ &&
49 (can_use_original_decode_ || 50 (can_use_original_decode_ ||
50 (src_rect_ == other.src_rect_ && 51 (src_rect_ == other.src_rect_ &&
51 target_size_ == other.target_size_ && 52 target_size_ == other.target_size_ &&
52 filter_quality_ == other.filter_quality_)); 53 filter_quality_ == other.filter_quality_));
53 } 54 }
54 55
55 bool operator!=(const ImageDecodeCacheKey& other) const { 56 bool operator!=(const ImageDecodeCacheKey& other) const {
56 return !(*this == other); 57 return !(*this == other);
57 } 58 }
58 59
59 uint32_t image_id() const { return image_id_; } 60 uint32_t image_id() const { return image_id_; }
60 SkFilterQuality filter_quality() const { return filter_quality_; } 61 SkFilterQuality filter_quality() const { return filter_quality_; }
61 gfx::Rect src_rect() const { return src_rect_; } 62 gfx::Rect src_rect() const { return src_rect_; }
62 gfx::Size target_size() const { return target_size_; } 63 gfx::Size target_size() const { return target_size_; }
64 const gfx::ColorSpace& target_color_space() const {
65 return target_color_space_;
66 }
63 67
64 bool can_use_original_decode() const { return can_use_original_decode_; } 68 bool can_use_original_decode() const { return can_use_original_decode_; }
65 bool should_use_subrect() const { return should_use_subrect_; } 69 bool should_use_subrect() const { return should_use_subrect_; }
66 size_t get_hash() const { return hash_; } 70 size_t get_hash() const { return hash_; }
67 71
68 // Helper to figure out how much memory the locked image represented by this 72 // Helper to figure out how much memory the locked image represented by this
69 // key would take. 73 // key would take.
70 size_t locked_bytes() const { 74 size_t locked_bytes() const {
71 // TODO(vmpstr): Handle formats other than RGBA. 75 // TODO(vmpstr): Handle formats other than RGBA.
72 base::CheckedNumeric<size_t> result = 4; 76 base::CheckedNumeric<size_t> result = 4;
73 result *= target_size_.width(); 77 result *= target_size_.width();
74 result *= target_size_.height(); 78 result *= target_size_.height();
75 return result.ValueOrDefault(std::numeric_limits<size_t>::max()); 79 return result.ValueOrDefault(std::numeric_limits<size_t>::max());
76 } 80 }
77 81
78 std::string ToString() const; 82 std::string ToString() const;
79 83
80 private: 84 private:
81 ImageDecodeCacheKey(uint32_t image_id, 85 ImageDecodeCacheKey(uint32_t image_id,
82 const gfx::Rect& src_rect, 86 const gfx::Rect& src_rect,
83 const gfx::Size& size, 87 const gfx::Size& size,
88 const gfx::ColorSpace& target_color_space,
84 SkFilterQuality filter_quality, 89 SkFilterQuality filter_quality,
85 bool can_use_original_decode, 90 bool can_use_original_decode,
86 bool should_use_subrect); 91 bool should_use_subrect);
87 92
88 uint32_t image_id_; 93 uint32_t image_id_;
89 gfx::Rect src_rect_; 94 gfx::Rect src_rect_;
90 gfx::Size target_size_; 95 gfx::Size target_size_;
96 gfx::ColorSpace target_color_space_;
91 SkFilterQuality filter_quality_; 97 SkFilterQuality filter_quality_;
92 bool can_use_original_decode_; 98 bool can_use_original_decode_;
93 bool should_use_subrect_; 99 bool should_use_subrect_;
94 size_t hash_; 100 size_t hash_;
95 }; 101 };
96 102
97 // Hash function for the above ImageDecodeCacheKey. 103 // Hash function for the above ImageDecodeCacheKey.
98 struct ImageDecodeCacheKeyHash { 104 struct ImageDecodeCacheKeyHash {
99 size_t operator()(const ImageDecodeCacheKey& key) const { 105 size_t operator()(const ImageDecodeCacheKey& key) const {
100 return key.get_hash(); 106 return key.get_hash();
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 ResourceFormat format_; 315 ResourceFormat format_;
310 size_t max_items_in_cache_; 316 size_t max_items_in_cache_;
311 317
312 // Used to uniquely identify DecodedImages for memory traces. 318 // Used to uniquely identify DecodedImages for memory traces.
313 base::AtomicSequenceNumber next_tracing_id_; 319 base::AtomicSequenceNumber next_tracing_id_;
314 }; 320 };
315 321
316 } // namespace cc 322 } // namespace cc
317 323
318 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CACHE_H_ 324 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698