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

Unified Diff: src/core/SkMipMap.h

Issue 2029373004: respect srgb gamma when building mips (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Need to know when we're in L32 compatibility mode !!!? 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
Index: src/core/SkMipMap.h
diff --git a/src/core/SkMipMap.h b/src/core/SkMipMap.h
index 5cb4ea8ce670b30c90eec35455b65befd5c65d0c..fba6d07386eb5b25aab746137416506c32835cdc 100644
--- a/src/core/SkMipMap.h
+++ b/src/core/SkMipMap.h
@@ -12,6 +12,7 @@
#include "SkPixmap.h"
#include "SkScalar.h"
#include "SkSize.h"
+#include "SkShader.h"
class SkBitmap;
class SkDiscardableMemory;
@@ -20,8 +21,18 @@ typedef SkDiscardableMemory* (*SkDiscardableFactoryProc)(size_t bytes);
class SkMipMap : public SkCachedData {
public:
- static SkMipMap* Build(const SkPixmap& src, SkDiscardableFactoryProc);
- static SkMipMap* Build(const SkBitmap& src, SkDiscardableFactoryProc);
+ enum SrcGammaMode {
+ kIgnore_SrcGammaMode, // treat src as having linear gamma
+ kRespect_SrcGammaMode, // treat src as described by its SkColorSpace
+ };
+
+ static SkMipMap* Build(const SkPixmap& src, SrcGammaMode, SkDiscardableFactoryProc);
+ static SkMipMap* Build(const SkBitmap& src, SrcGammaMode, SkDiscardableFactoryProc);
+
+ static SrcGammaMode DeduceMode(const SkShader::ContextRec& rec) {
+ return (SkShader::ContextRec::kPMColor_DstType == rec.fPreferredDstType) ?
msarett 2016/06/03 16:54:17 We will never want to respect gamma with kPMColor_
reed1 2016/06/07 16:01:10 That is the policy I'm proposing: - if the target
+ kIgnore_SrcGammaMode : kRespect_SrcGammaMode;
+ }
// Determines how many levels a SkMipMap will have without creating that mipmap.
static int ComputeLevelCount(int baseWidth, int baseHeight);
@@ -44,10 +55,10 @@ protected:
}
private:
- Level* fLevels;
- int fCount;
+ sk_sp<SkColorSpace> fCS;
+ Level* fLevels; // managed by the baseclass, may be null due to onDataChanged.
+ int fCount;
- // we take ownership of levels, and will free it with sk_free()
SkMipMap(void* malloc, size_t size) : INHERITED(malloc, size) {}
SkMipMap(size_t size, SkDiscardableMemory* dm) : INHERITED(size, dm) {}

Powered by Google App Engine
This is Rietveld 408576698