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

Side by Side Diff: src/core/SkBitmapCache.cpp

Issue 2029373004: respect srgb gamma when building mips (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix warning 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 | « src/core/SkBitmapCache.h ('k') | src/core/SkBitmapController.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmapCache.h" 8 #include "SkBitmapCache.h"
9 #include "SkImage.h" 9 #include "SkImage.h"
10 #include "SkResourceCache.h" 10 #include "SkResourceCache.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 223 }
224 224
225 //////////////////////////////////////////////////////////////////////////////// ////////// 225 //////////////////////////////////////////////////////////////////////////////// //////////
226 //////////////////////////////////////////////////////////////////////////////// ////////// 226 //////////////////////////////////////////////////////////////////////////////// //////////
227 227
228 namespace { 228 namespace {
229 static unsigned gMipMapKeyNamespaceLabel; 229 static unsigned gMipMapKeyNamespaceLabel;
230 230
231 struct MipMapKey : public SkResourceCache::Key { 231 struct MipMapKey : public SkResourceCache::Key {
232 public: 232 public:
233 MipMapKey(uint32_t genID, const SkIRect& bounds) : fGenID(genID), fBounds(bo unds) { 233 MipMapKey(uint32_t genID, SkSourceGammaTreatment treatment, const SkIRect& b ounds)
234 : fGenID(genID), fSrcGammaTreatment(static_cast<uint32_t>(treatment)), f Bounds(bounds)
235 {
234 this->init(&gMipMapKeyNamespaceLabel, SkMakeResourceCacheSharedIDForBitm ap(genID), 236 this->init(&gMipMapKeyNamespaceLabel, SkMakeResourceCacheSharedIDForBitm ap(genID),
235 sizeof(fGenID) + sizeof(fBounds)); 237 sizeof(fGenID) + sizeof(fSrcGammaTreatment) + sizeof(fBounds) );
236 } 238 }
237 239
238 uint32_t fGenID; 240 uint32_t fGenID;
241 uint32_t fSrcGammaTreatment;
239 SkIRect fBounds; 242 SkIRect fBounds;
240 }; 243 };
241 244
242 struct MipMapRec : public SkResourceCache::Rec { 245 struct MipMapRec : public SkResourceCache::Rec {
243 MipMapRec(const SkBitmap& src, const SkMipMap* result) 246 MipMapRec(const SkBitmap& src, SkSourceGammaTreatment treatment, const SkMip Map* result)
244 : fKey(src.getGenerationID(), get_bounds_from_bitmap(src)) 247 : fKey(src.getGenerationID(), treatment, get_bounds_from_bitmap(src))
245 , fMipMap(result) 248 , fMipMap(result)
246 { 249 {
247 fMipMap->attachToCacheAndRef(); 250 fMipMap->attachToCacheAndRef();
248 } 251 }
249 252
250 virtual ~MipMapRec() { 253 virtual ~MipMapRec() {
251 fMipMap->detachFromCacheAndUnref(); 254 fMipMap->detachFromCacheAndUnref();
252 } 255 }
253 256
254 const Key& getKey() const override { return fKey; } 257 const Key& getKey() const override { return fKey; }
(...skipping 17 matching lines...) Expand all
272 return true; 275 return true;
273 } 276 }
274 277
275 private: 278 private:
276 MipMapKey fKey; 279 MipMapKey fKey;
277 const SkMipMap* fMipMap; 280 const SkMipMap* fMipMap;
278 }; 281 };
279 } 282 }
280 283
281 const SkMipMap* SkMipMapCache::FindAndRef(const SkBitmapCacheDesc& desc, 284 const SkMipMap* SkMipMapCache::FindAndRef(const SkBitmapCacheDesc& desc,
285 SkSourceGammaTreatment treatment,
282 SkResourceCache* localCache) { 286 SkResourceCache* localCache) {
283 // Note: we ignore width/height from desc, just need id and bounds 287 // Note: we ignore width/height from desc, just need id and bounds
284 MipMapKey key(desc.fImageID, desc.fBounds); 288 MipMapKey key(desc.fImageID, treatment, desc.fBounds);
285 const SkMipMap* result; 289 const SkMipMap* result;
286 290
287 if (!CHECK_LOCAL(localCache, find, Find, key, MipMapRec::Finder, &result)) { 291 if (!CHECK_LOCAL(localCache, find, Find, key, MipMapRec::Finder, &result)) {
288 result = nullptr; 292 result = nullptr;
289 } 293 }
290 return result; 294 return result;
291 } 295 }
292 296
293 static SkResourceCache::DiscardableFactory get_fact(SkResourceCache* localCache) { 297 static SkResourceCache::DiscardableFactory get_fact(SkResourceCache* localCache) {
294 return localCache ? localCache->GetDiscardableFactory() 298 return localCache ? localCache->GetDiscardableFactory()
295 : SkResourceCache::GetDiscardableFactory(); 299 : SkResourceCache::GetDiscardableFactory();
296 } 300 }
297 301
298 const SkMipMap* SkMipMapCache::AddAndRef(const SkBitmap& src, SkResourceCache* l ocalCache) { 302 const SkMipMap* SkMipMapCache::AddAndRef(const SkBitmap& src, SkSourceGammaTreat ment treatment,
299 SkMipMap* mipmap = SkMipMap::Build(src, get_fact(localCache)); 303 SkResourceCache* localCache) {
304 SkMipMap* mipmap = SkMipMap::Build(src, treatment, get_fact(localCache));
300 if (mipmap) { 305 if (mipmap) {
301 MipMapRec* rec = new MipMapRec(src, mipmap); 306 MipMapRec* rec = new MipMapRec(src, treatment, mipmap);
302 CHECK_LOCAL(localCache, add, Add, rec); 307 CHECK_LOCAL(localCache, add, Add, rec);
303 src.pixelRef()->notifyAddedToCache(); 308 src.pixelRef()->notifyAddedToCache();
304 } 309 }
305 return mipmap; 310 return mipmap;
306 } 311 }
OLDNEW
« no previous file with comments | « src/core/SkBitmapCache.h ('k') | src/core/SkBitmapController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698