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

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

Issue 2797583002: cc: Add color space to image decode caches (Closed)
Patch Set: Remove dead code 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
« no previous file with comments | « cc/tiles/image_controller.cc ('k') | cc/tiles/software_image_decode_cache.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_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 27 matching lines...) Expand all
38 public: 38 public:
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_size_decode_ ==
49 (can_use_original_decode_ || 49 other.can_use_original_size_decode_ &&
50 target_color_space_ == other.target_color_space_ &&
51 (can_use_original_size_decode_ ||
50 (src_rect_ == other.src_rect_ && 52 (src_rect_ == other.src_rect_ &&
51 target_size_ == other.target_size_ && 53 target_size_ == other.target_size_ &&
52 filter_quality_ == other.filter_quality_)); 54 filter_quality_ == other.filter_quality_));
53 } 55 }
54 56
55 bool operator!=(const ImageDecodeCacheKey& other) const { 57 bool operator!=(const ImageDecodeCacheKey& other) const {
56 return !(*this == other); 58 return !(*this == other);
57 } 59 }
58 60
59 uint32_t image_id() const { return image_id_; } 61 uint32_t image_id() const { return image_id_; }
60 SkFilterQuality filter_quality() const { return filter_quality_; } 62 SkFilterQuality filter_quality() const { return filter_quality_; }
61 gfx::Rect src_rect() const { return src_rect_; } 63 gfx::Rect src_rect() const { return src_rect_; }
62 gfx::Size target_size() const { return target_size_; } 64 gfx::Size target_size() const { return target_size_; }
65 const gfx::ColorSpace& target_color_space() const {
66 return target_color_space_;
67 }
63 68
64 bool can_use_original_decode() const { return can_use_original_decode_; } 69 bool can_use_original_size_decode() const {
70 return can_use_original_size_decode_;
71 }
65 bool should_use_subrect() const { return should_use_subrect_; } 72 bool should_use_subrect() const { return should_use_subrect_; }
66 size_t get_hash() const { return hash_; } 73 size_t get_hash() const { return hash_; }
67 74
68 // Helper to figure out how much memory the locked image represented by this 75 // Helper to figure out how much memory the locked image represented by this
69 // key would take. 76 // key would take.
70 size_t locked_bytes() const { 77 size_t locked_bytes() const {
71 // TODO(vmpstr): Handle formats other than RGBA. 78 // TODO(vmpstr): Handle formats other than RGBA.
72 base::CheckedNumeric<size_t> result = 4; 79 base::CheckedNumeric<size_t> result = 4;
73 result *= target_size_.width(); 80 result *= target_size_.width();
74 result *= target_size_.height(); 81 result *= target_size_.height();
75 return result.ValueOrDefault(std::numeric_limits<size_t>::max()); 82 return result.ValueOrDefault(std::numeric_limits<size_t>::max());
76 } 83 }
77 84
78 std::string ToString() const; 85 std::string ToString() const;
79 86
80 private: 87 private:
81 ImageDecodeCacheKey(uint32_t image_id, 88 ImageDecodeCacheKey(uint32_t image_id,
82 const gfx::Rect& src_rect, 89 const gfx::Rect& src_rect,
83 const gfx::Size& size, 90 const gfx::Size& size,
91 const gfx::ColorSpace& target_color_space,
84 SkFilterQuality filter_quality, 92 SkFilterQuality filter_quality,
85 bool can_use_original_decode, 93 bool can_use_original_size_decode,
86 bool should_use_subrect); 94 bool should_use_subrect);
87 95
88 uint32_t image_id_; 96 uint32_t image_id_;
89 gfx::Rect src_rect_; 97 gfx::Rect src_rect_;
90 gfx::Size target_size_; 98 gfx::Size target_size_;
99 gfx::ColorSpace target_color_space_;
91 SkFilterQuality filter_quality_; 100 SkFilterQuality filter_quality_;
92 bool can_use_original_decode_; 101 bool can_use_original_size_decode_;
93 bool should_use_subrect_; 102 bool should_use_subrect_;
94 size_t hash_; 103 size_t hash_;
95 }; 104 };
96 105
97 // Hash function for the above ImageDecodeCacheKey. 106 // Hash function for the above ImageDecodeCacheKey.
98 struct ImageDecodeCacheKeyHash { 107 struct ImageDecodeCacheKeyHash {
99 size_t operator()(const ImageDecodeCacheKey& key) const { 108 size_t operator()(const ImageDecodeCacheKey& key) const {
100 return key.get_hash(); 109 return key.get_hash();
101 } 110 }
102 }; 111 };
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 ResourceFormat format_; 321 ResourceFormat format_;
313 size_t max_items_in_cache_; 322 size_t max_items_in_cache_;
314 323
315 // Used to uniquely identify DecodedImages for memory traces. 324 // Used to uniquely identify DecodedImages for memory traces.
316 base::AtomicSequenceNumber next_tracing_id_; 325 base::AtomicSequenceNumber next_tracing_id_;
317 }; 326 };
318 327
319 } // namespace cc 328 } // namespace cc
320 329
321 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CACHE_H_ 330 #endif // CC_TILES_SOFTWARE_IMAGE_DECODE_CACHE_H_
OLDNEW
« no previous file with comments | « cc/tiles/image_controller.cc ('k') | cc/tiles/software_image_decode_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698