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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkBitmapCache.h ('k') | src/core/SkBitmapController.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkBitmapCache.cpp
diff --git a/src/core/SkBitmapCache.cpp b/src/core/SkBitmapCache.cpp
index 83eec1b666b7e2b56a2cd233f87ff470274e3add..153a24748b81eb4e7c72e2097e12cbed7793fe8b 100644
--- a/src/core/SkBitmapCache.cpp
+++ b/src/core/SkBitmapCache.cpp
@@ -230,18 +230,21 @@ static unsigned gMipMapKeyNamespaceLabel;
struct MipMapKey : public SkResourceCache::Key {
public:
- MipMapKey(uint32_t genID, const SkIRect& bounds) : fGenID(genID), fBounds(bounds) {
+ MipMapKey(uint32_t genID, SkSourceGammaTreatment treatment, const SkIRect& bounds)
+ : fGenID(genID), fSrcGammaTreatment(static_cast<uint32_t>(treatment)), fBounds(bounds)
+ {
this->init(&gMipMapKeyNamespaceLabel, SkMakeResourceCacheSharedIDForBitmap(genID),
- sizeof(fGenID) + sizeof(fBounds));
+ sizeof(fGenID) + sizeof(fSrcGammaTreatment) + sizeof(fBounds));
}
uint32_t fGenID;
+ uint32_t fSrcGammaTreatment;
SkIRect fBounds;
};
struct MipMapRec : public SkResourceCache::Rec {
- MipMapRec(const SkBitmap& src, const SkMipMap* result)
- : fKey(src.getGenerationID(), get_bounds_from_bitmap(src))
+ MipMapRec(const SkBitmap& src, SkSourceGammaTreatment treatment, const SkMipMap* result)
+ : fKey(src.getGenerationID(), treatment, get_bounds_from_bitmap(src))
, fMipMap(result)
{
fMipMap->attachToCacheAndRef();
@@ -279,9 +282,10 @@ private:
}
const SkMipMap* SkMipMapCache::FindAndRef(const SkBitmapCacheDesc& desc,
+ SkSourceGammaTreatment treatment,
SkResourceCache* localCache) {
// Note: we ignore width/height from desc, just need id and bounds
- MipMapKey key(desc.fImageID, desc.fBounds);
+ MipMapKey key(desc.fImageID, treatment, desc.fBounds);
const SkMipMap* result;
if (!CHECK_LOCAL(localCache, find, Find, key, MipMapRec::Finder, &result)) {
@@ -295,10 +299,11 @@ static SkResourceCache::DiscardableFactory get_fact(SkResourceCache* localCache)
: SkResourceCache::GetDiscardableFactory();
}
-const SkMipMap* SkMipMapCache::AddAndRef(const SkBitmap& src, SkResourceCache* localCache) {
- SkMipMap* mipmap = SkMipMap::Build(src, get_fact(localCache));
+const SkMipMap* SkMipMapCache::AddAndRef(const SkBitmap& src, SkSourceGammaTreatment treatment,
+ SkResourceCache* localCache) {
+ SkMipMap* mipmap = SkMipMap::Build(src, treatment, get_fact(localCache));
if (mipmap) {
- MipMapRec* rec = new MipMapRec(src, mipmap);
+ MipMapRec* rec = new MipMapRec(src, treatment, mipmap);
CHECK_LOCAL(localCache, add, Add, rec);
src.pixelRef()->notifyAddedToCache();
}
« 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