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

Unified Diff: cc/tiles/gpu_image_decode_cache.h

Issue 2797583002: cc: Add color space to image decode caches (Closed)
Patch Set: Review feedback, except the sk_sp bit... 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 side-by-side diff with in-line comments
Download patch
Index: cc/tiles/gpu_image_decode_cache.h
diff --git a/cc/tiles/gpu_image_decode_cache.h b/cc/tiles/gpu_image_decode_cache.h
index c80c5a9b43ccca53b1b67e760c27fc7d29e213f0..71f14e248264fd95429cee8437ed662f1a30ed43 100644
--- a/cc/tiles/gpu_image_decode_cache.h
+++ b/cc/tiles/gpu_image_decode_cache.h
@@ -232,10 +232,12 @@ class CC_EXPORT GpuImageDecodeCache
struct ImageData : public base::RefCounted<ImageData> {
ImageData(DecodedDataMode mode,
size_t size,
+ const gfx::ColorSpace& target_color_space,
const SkImage::DeferredTextureImageUsageParams& upload_params);
const DecodedDataMode mode;
const size_t size;
+ gfx::ColorSpace target_color_space;
bool is_at_raster = false;
SkImage::DeferredTextureImageUsageParams upload_params;
@@ -265,7 +267,24 @@ class CC_EXPORT GpuImageDecodeCache
// Uniquely identifies (without collisions) a specific DrawImage for use in
// the |in_use_cache_|.
- using InUseCacheKey = uint64_t;
+ struct InUseCacheKeyHash;
+ struct InUseCacheKey {
+ static InUseCacheKey FromDrawImage(const DrawImage& draw_image);
+ bool operator==(const InUseCacheKey& other) const;
+
+ private:
+ friend struct GpuImageDecodeCache::InUseCacheKeyHash;
+ explicit InUseCacheKey(const DrawImage& draw_image);
+
+ uint32_t image_id;
+ int mip_level;
+ SkFilterQuality filter_quality;
+ gfx::ColorSpace target_color_space;
+ };
+ struct InUseCacheKeyHash {
+ size_t operator()(const InUseCacheKey&) const;
+ };
+ InUseCacheKey FromDrawImage(const DrawImage& draw_image);
// All private functions should only be called while holding |lock_|. Some
// functions also require the |context_| lock. These are indicated by
@@ -337,7 +356,8 @@ class CC_EXPORT GpuImageDecodeCache
// |in_use_cache_| represents the in-use (short-lived) cache. Entries are
// cleaned up as soon as their ref count reaches zero.
- using InUseCache = std::unordered_map<InUseCacheKey, InUseCacheEntry>;
+ using InUseCache =
+ std::unordered_map<InUseCacheKey, InUseCacheEntry, InUseCacheKeyHash>;
InUseCache in_use_cache_;
size_t max_working_set_bytes_;

Powered by Google App Engine
This is Rietveld 408576698