aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--bench/GrMipMapBench.cpp2
-rw-r--r--bench/nanobench.cpp33
-rw-r--r--bench/nanobench.h2
-rw-r--r--dm/DM.cpp10
-rw-r--r--dm/DMSrcSink.cpp12
-rw-r--r--dm/DMSrcSink.h10
-rw-r--r--example/HelloWorld.cpp10
-rw-r--r--include/core/SkBitmap.h1
-rw-r--r--include/core/SkImageInfo.h8
-rw-r--r--include/core/SkPixelRef.h2
-rw-r--r--include/gpu/SkGr.h5
-rw-r--r--include/gpu/SkGrPixelRef.h3
-rw-r--r--include/views/SkWindow.h2
-rw-r--r--samplecode/SampleApp.cpp19
-rw-r--r--samplecode/SampleApp.h2
-rw-r--r--src/core/SkBitmap.cpp8
-rw-r--r--src/gpu/SkGpuDevice.cpp6
-rw-r--r--src/gpu/SkGr.cpp8
-rw-r--r--src/gpu/SkGrPixelRef.cpp13
-rw-r--r--src/image/SkImage_Gpu.cpp4
-rw-r--r--src/views/SkWindow.cpp7
-rw-r--r--tests/ReadPixelsTest.cpp2
-rw-r--r--tests/TestConfigParsing.cpp21
-rw-r--r--tools/flags/SkCommonFlagsConfig.cpp18
-rw-r--r--tools/flags/SkCommonFlagsConfig.h6
-rw-r--r--tools/picture_utils.cpp5
-rw-r--r--tools/skiaserve/Request.cpp14
-rw-r--r--tools/viewer/Viewer.cpp8
-rw-r--r--tools/viewer/sk_app/DisplayParams.h10
-rw-r--r--tools/viewer/sk_app/GLWindowContext.cpp4
-rw-r--r--tools/viewer/sk_app/VulkanWindowContext.cpp3
-rwxr-xr-xtools/viewer/sk_app/WindowContext.cpp4
-rw-r--r--tools/viewer/sk_app/android/GLWindowContext_android.cpp3
-rw-r--r--tools/viewer/sk_app/android/RasterWindowContext_android.cpp2
34 files changed, 137 insertions, 130 deletions
diff --git a/bench/GrMipMapBench.cpp b/bench/GrMipMapBench.cpp
index f4e05a0ac7..096256c6cc 100644
--- a/bench/GrMipMapBench.cpp
+++ b/bench/GrMipMapBench.cpp
@@ -37,7 +37,7 @@ protected:
return;
}
SkImageInfo info = SkImageInfo::Make(fW, fH, kN32_SkColorType, kPremul_SkAlphaType,
- kSRGB_SkColorProfileType);
+ SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named));
fSurface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info);
}
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index e5a63a022d..94402cc770 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -424,7 +424,7 @@ static void create_config(const SkCommandLineConfig* config, SkTArray<Config>* c
Benchmark::kGPU_Backend,
kN32_SkColorType,
kPremul_SkAlphaType,
- kLinear_SkColorProfileType,
+ nullptr,
sampleCount,
ctxType,
ctxOptions,
@@ -436,28 +436,29 @@ static void create_config(const SkCommandLineConfig* config, SkTArray<Config>* c
}
#endif
- #define CPU_CONFIG(name, backend, color, alpha, profile) \
- if (config->getTag().equals(#name)) { \
- Config config = { \
- SkString(#name), Benchmark::backend, color, alpha, profile, \
- 0, kBogusContextType, kBogusContextOptions, false \
- }; \
- configs->push_back(config); \
- return; \
+ #define CPU_CONFIG(name, backend, color, alpha, colorSpace) \
+ if (config->getTag().equals(#name)) { \
+ Config config = { \
+ SkString(#name), Benchmark::backend, color, alpha, colorSpace, \
+ 0, kBogusContextType, kBogusContextOptions, false \
+ }; \
+ configs->push_back(config); \
+ return; \
}
if (FLAGS_cpu) {
CPU_CONFIG(nonrendering, kNonRendering_Backend,
- kUnknown_SkColorType, kUnpremul_SkAlphaType, kLinear_SkColorProfileType);
+ kUnknown_SkColorType, kUnpremul_SkAlphaType, nullptr)
CPU_CONFIG(8888, kRaster_Backend,
- kN32_SkColorType, kPremul_SkAlphaType, kLinear_SkColorProfileType)
+ kN32_SkColorType, kPremul_SkAlphaType, nullptr)
CPU_CONFIG(565, kRaster_Backend,
- kRGB_565_SkColorType, kOpaque_SkAlphaType, kLinear_SkColorProfileType)
+ kRGB_565_SkColorType, kOpaque_SkAlphaType, nullptr)
+ auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
CPU_CONFIG(srgb, kRaster_Backend,
- kN32_SkColorType, kPremul_SkAlphaType, kSRGB_SkColorProfileType)
+ kN32_SkColorType, kPremul_SkAlphaType, srgbColorSpace)
CPU_CONFIG(f16, kRaster_Backend,
- kRGBA_F16_SkColorType, kPremul_SkAlphaType, kLinear_SkColorProfileType)
+ kRGBA_F16_SkColorType, kPremul_SkAlphaType, nullptr)
}
#undef CPU_CONFIG
@@ -465,7 +466,7 @@ static void create_config(const SkCommandLineConfig* config, SkTArray<Config>* c
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
if (config->getTag().equals("hwui")) {
Config config = { SkString("hwui"), Benchmark::kHWUI_Backend,
- kRGBA_8888_SkColorType, kPremul_SkAlphaType, kLinear_SkColorProfileType,
+ kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr,
0, kBogusContextType, kBogusContextOptions, false };
configs->push_back(config);
}
@@ -488,7 +489,7 @@ static Target* is_enabled(Benchmark* bench, const Config& config) {
}
SkImageInfo info = SkImageInfo::Make(bench->getSize().fX, bench->getSize().fY,
- config.color, config.alpha, config.profile);
+ config.color, config.alpha, config.colorSpace);
Target* target = nullptr;
diff --git a/bench/nanobench.h b/bench/nanobench.h
index ceab0f6c4f..ce1e33ec4f 100644
--- a/bench/nanobench.h
+++ b/bench/nanobench.h
@@ -26,7 +26,7 @@ struct Config {
Benchmark::Backend backend;
SkColorType color;
SkAlphaType alpha;
- SkColorProfileType profile;
+ sk_sp<SkColorSpace> colorSpace;
int samples;
#if SK_SUPPORT_GPU
sk_gpu_test::GrContextFactory::ContextType ctxType;
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 158d256fad..69044080b5 100644
--- a/dm/DM.cpp
+++ b/dm/DM.cpp
@@ -802,8 +802,8 @@ static Sink* create_sink(const SkCommandLineConfig* config) {
contextOptions = static_cast<GrContextFactory::ContextOptions>(
contextOptions | GrContextFactory::kEnableNVPR_ContextOptions);
}
- if (SkColorAndProfileAreGammaCorrect(gpuConfig->getColorType(),
- gpuConfig->getProfileType())) {
+ if (SkColorAndColorSpaceAreGammaCorrect(gpuConfig->getColorType(),
+ gpuConfig->getColorSpace())) {
contextOptions = static_cast<GrContextFactory::ContextOptions>(
contextOptions | GrContextFactory::kRequireSRGBSupport_ContextOptions);
}
@@ -815,7 +815,7 @@ static Sink* create_sink(const SkCommandLineConfig* config) {
}
return new GPUSink(contextType, contextOptions, gpuConfig->getSamples(),
gpuConfig->getUseDIText(), gpuConfig->getColorType(),
- gpuConfig->getProfileType(), FLAGS_gpu_threading);
+ sk_ref_sp(gpuConfig->getColorSpace()), FLAGS_gpu_threading);
}
}
#endif
@@ -827,9 +827,11 @@ static Sink* create_sink(const SkCommandLineConfig* config) {
#endif
if (FLAGS_cpu) {
+ auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
+
SINK("565", RasterSink, kRGB_565_SkColorType);
SINK("8888", RasterSink, kN32_SkColorType);
- SINK("srgb", RasterSink, kN32_SkColorType, kSRGB_SkColorProfileType);
+ SINK("srgb", RasterSink, kN32_SkColorType, srgbColorSpace);
SINK("f16", RasterSink, kRGBA_F16_SkColorType);
SINK("pdf", PDFSink);
SINK("skp", SKPSink);
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index b252290cd5..97f1e48664 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -1060,14 +1060,14 @@ GPUSink::GPUSink(GrContextFactory::ContextType ct,
int samples,
bool diText,
SkColorType colorType,
- SkColorProfileType profileType,
+ sk_sp<SkColorSpace> colorSpace,
bool threaded)
: fContextType(ct)
, fContextOptions(options)
, fSampleCount(samples)
, fUseDIText(diText)
, fColorType(colorType)
- , fProfileType(profileType)
+ , fColorSpace(std::move(colorSpace))
, fThreaded(threaded) {}
void PreAbandonGpuContextErrorHandler(SkError, void*) {}
@@ -1093,7 +1093,7 @@ Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log) co
const SkISize size = src.size();
const SkImageInfo info =
SkImageInfo::Make(size.width(), size.height(), fColorType,
- kPremul_SkAlphaType, fProfileType);
+ kPremul_SkAlphaType, fColorSpace);
#if SK_SUPPORT_GPU
GrContext* context = factory.getContextInfo(fContextType, fContextOptions).grContext();
const int maxDimension = context->caps()->maxTextureSize();
@@ -1213,9 +1213,9 @@ Error SVGSink::draw(const Src& src, SkBitmap*, SkWStream* dst, SkString*) const
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-RasterSink::RasterSink(SkColorType colorType, SkColorProfileType profileType)
+RasterSink::RasterSink(SkColorType colorType, sk_sp<SkColorSpace> colorSpace)
: fColorType(colorType)
- , fProfileType(profileType) {}
+ , fColorSpace(std::move(colorSpace)) {}
Error RasterSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString*) const {
const SkISize size = src.size();
@@ -1225,7 +1225,7 @@ Error RasterSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString*) con
SkMallocPixelRef::ZeroedPRFactory factory;
dst->allocPixels(SkImageInfo::Make(size.width(), size.height(),
- fColorType, alphaType, fProfileType),
+ fColorType, alphaType, fColorSpace),
&factory,
nullptr/*colortable*/);
SkCanvas canvas(*dst);
diff --git a/dm/DMSrcSink.h b/dm/DMSrcSink.h
index 8cb2b25bf4..a2bfbca7f3 100644
--- a/dm/DMSrcSink.h
+++ b/dm/DMSrcSink.h
@@ -281,7 +281,7 @@ class GPUSink : public Sink {
public:
GPUSink(sk_gpu_test::GrContextFactory::ContextType,
sk_gpu_test::GrContextFactory::ContextOptions,
- int samples, bool diText, SkColorType colorType, SkColorProfileType profileType,
+ int samples, bool diText, SkColorType colorType, sk_sp<SkColorSpace> colorSpace,
bool threaded);
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
@@ -294,7 +294,7 @@ private:
int fSampleCount;
bool fUseDIText;
SkColorType fColorType;
- SkColorProfileType fProfileType;
+ sk_sp<SkColorSpace> fColorSpace;
bool fThreaded;
};
@@ -318,14 +318,14 @@ public:
class RasterSink : public Sink {
public:
- explicit RasterSink(SkColorType, SkColorProfileType=kLinear_SkColorProfileType);
+ explicit RasterSink(SkColorType, sk_sp<SkColorSpace> = nullptr);
Error draw(const Src&, SkBitmap*, SkWStream*, SkString*) const override;
const char* fileExtension() const override { return "png"; }
SinkFlags flags() const override { return SinkFlags{ SinkFlags::kRaster, SinkFlags::kDirect }; }
private:
- SkColorType fColorType;
- SkColorProfileType fProfileType;
+ SkColorType fColorType;
+ sk_sp<SkColorSpace> fColorSpace;
};
class SKPSink : public Sink {
diff --git a/example/HelloWorld.cpp b/example/HelloWorld.cpp
index c2dd7d89f1..32bee5dccd 100644
--- a/example/HelloWorld.cpp
+++ b/example/HelloWorld.cpp
@@ -155,13 +155,9 @@ void HelloWorldWindow::draw(SkCanvas* canvas) {
if (snap->peekPixels(&pmap)) {
const SkImageInfo& info = pmap.info();
fRenderTarget->writePixels(0, 0, snap->width(), snap->height(),
- SkImageInfo2GrPixelConfig(info.colorType(),
- info.alphaType(),
- info.profileType(),
- *fContext->caps()),
- pmap.addr(),
- pmap.rowBytes(),
- GrContext::kFlushWrites_PixelOp);
+ SkImageInfo2GrPixelConfig(info, *fContext->caps()),
+ pmap.addr(), pmap.rowBytes(),
+ GrContext::kFlushWrites_PixelOp);
}
}
INHERITED::present();
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h
index 664686619f..b28eca817e 100644
--- a/include/core/SkBitmap.h
+++ b/include/core/SkBitmap.h
@@ -85,6 +85,7 @@ public:
int height() const { return fInfo.height(); }
SkColorType colorType() const { return fInfo.colorType(); }
SkAlphaType alphaType() const { return fInfo.alphaType(); }
+ SkColorSpace* colorSpace() const { return fInfo.colorSpace(); }
SkColorProfileType profileType() const { return fInfo.profileType(); }
/**
diff --git a/include/core/SkImageInfo.h b/include/core/SkImageInfo.h
index c0e0be13f9..f7a619f9ea 100644
--- a/include/core/SkImageInfo.h
+++ b/include/core/SkImageInfo.h
@@ -379,12 +379,14 @@ private:
///////////////////////////////////////////////////////////////////////////////
-static inline bool SkColorAndProfileAreGammaCorrect(SkColorType ct, SkColorProfileType pt) {
- return kSRGB_SkColorProfileType == pt || kRGBA_F16_SkColorType == ct;
+static inline bool SkColorAndColorSpaceAreGammaCorrect(SkColorType ct, SkColorSpace* cs) {
+ // Anything with a color-space attached is gamma-correct, as is F16.
+ // To get legacy behavior, you need to ask for non-F16, with a nullptr color space.
+ return (cs != nullptr) || kRGBA_F16_SkColorType == ct;
}
static inline bool SkImageInfoIsGammaCorrect(const SkImageInfo& info) {
- return SkColorAndProfileAreGammaCorrect(info.colorType(), info.profileType());
+ return SkColorAndColorSpaceAreGammaCorrect(info.colorType(), info.colorSpace());
}
#endif
diff --git a/include/core/SkPixelRef.h b/include/core/SkPixelRef.h
index 90e0de540d..da85863bdb 100644
--- a/include/core/SkPixelRef.h
+++ b/include/core/SkPixelRef.h
@@ -248,7 +248,7 @@ public:
* not be created with the given config), or this PixelRef does not support deep
* copies.
*/
- virtual SkPixelRef* deepCopy(SkColorType, SkColorProfileType, const SkIRect* /*subset*/) {
+ virtual SkPixelRef* deepCopy(SkColorType, SkColorSpace*, const SkIRect* /*subset*/) {
return NULL;
}
diff --git a/include/gpu/SkGr.h b/include/gpu/SkGr.h
index edfcd6d813..c5ba34403f 100644
--- a/include/gpu/SkGr.h
+++ b/include/gpu/SkGr.h
@@ -72,10 +72,11 @@ GrTexture* GrRefCachedBitmapTexture(GrContext*, const SkBitmap&, const GrTexture
SkSourceGammaTreatment);
// TODO: Move SkImageInfo2GrPixelConfig to SkGrPriv.h (requires cleanup to SkWindow its subclasses).
-GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType, SkAlphaType, SkColorProfileType, const GrCaps&);
+GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType, SkAlphaType, const SkColorSpace*,
+ const GrCaps&);
static inline GrPixelConfig SkImageInfo2GrPixelConfig(const SkImageInfo& info, const GrCaps& caps) {
- return SkImageInfo2GrPixelConfig(info.colorType(), info.alphaType(), info.profileType(), caps);
+ return SkImageInfo2GrPixelConfig(info.colorType(), info.alphaType(), info.colorSpace(), caps);
}
GrTextureParams::FilterMode GrSkFilterQualityToGrFilterMode(SkFilterQuality paintFilterQuality,
diff --git a/include/gpu/SkGrPixelRef.h b/include/gpu/SkGrPixelRef.h
index b4dbd9d73f..2bbe48fa09 100644
--- a/include/gpu/SkGrPixelRef.h
+++ b/include/gpu/SkGrPixelRef.h
@@ -50,8 +50,7 @@ public:
protected:
// overrides from SkPixelRef
bool onReadPixels(SkBitmap* dst, SkColorType, const SkIRect* subset) override;
- SkPixelRef* deepCopy(SkColorType, SkColorProfileType,
- const SkIRect* subset) override;
+ SkPixelRef* deepCopy(SkColorType, SkColorSpace*, const SkIRect* subset) override;
void onNotifyPixelsChanged() override;
private:
diff --git a/include/views/SkWindow.h b/include/views/SkWindow.h
index 341046aacc..50774849a6 100644
--- a/include/views/SkWindow.h
+++ b/include/views/SkWindow.h
@@ -52,7 +52,7 @@ public:
void resize(int width, int height);
void resize(const SkImageInfo&);
- void setColorType(SkColorType, SkColorProfileType);
+ void setColorType(SkColorType, sk_sp<SkColorSpace>);
bool isDirty() const { return !fDirtyRgn.isEmpty(); }
bool update(SkIRect* updateArea);
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 40ead7482f..b80ea44d30 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -48,17 +48,18 @@ class GrContext;
const struct {
SkColorType fColorType;
- SkColorProfileType fProfileType;
+ bool fSRGB;
const char* fName;
} gConfig[] = {
- { kN32_SkColorType, kLinear_SkColorProfileType, "L32" },
- { kN32_SkColorType, kSRGB_SkColorProfileType, "S32" },
- { kRGBA_F16_SkColorType, kLinear_SkColorProfileType, "F16" },
+ { kN32_SkColorType, false, "L32" },
+ { kN32_SkColorType, true, "S32" },
+ { kRGBA_F16_SkColorType, false, "F16" },
};
static const char* find_config_name(const SkImageInfo& info) {
for (const auto& config : gConfig) {
- if (config.fColorType == info.colorType() && config.fProfileType == info.profileType()) {
+ if (config.fColorType == info.colorType() &&
+ config.fSRGB == (info.colorSpace() != nullptr)) {
return config.fName;
}
}
@@ -1532,7 +1533,9 @@ bool SampleWindow::onEvent(const SkEvent& evt) {
return true;
}
if (SkOSMenu::FindListIndex(evt, "ColorType", &selected)) {
- this->setDeviceColorType(gConfig[selected].fColorType, gConfig[selected].fProfileType);
+ auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
+ this->setDeviceColorType(gConfig[selected].fColorType,
+ gConfig[selected].fSRGB ? srgbColorSpace : nullptr);
return true;
}
if (SkOSMenu::FindSwitchState(evt, "Slide Show", nullptr)) {
@@ -1747,8 +1750,8 @@ void SampleWindow::setDeviceType(DeviceType type) {
this->inval(nullptr);
}
-void SampleWindow::setDeviceColorType(SkColorType ct, SkColorProfileType pt) {
- this->setColorType(ct, pt);
+void SampleWindow::setDeviceColorType(SkColorType ct, sk_sp<SkColorSpace> cs) {
+ this->setColorType(ct, std::move(cs));
fDevManager->tearDownBackend(this);
fDevManager->setUpBackend(this, fMSAASampleCount, fDeepColor);
diff --git a/samplecode/SampleApp.h b/samplecode/SampleApp.h
index 371133b9a2..f4be093a66 100644
--- a/samplecode/SampleApp.h
+++ b/samplecode/SampleApp.h
@@ -116,7 +116,7 @@ public:
void draw(SkCanvas*) override;
void setDeviceType(DeviceType type);
- void setDeviceColorType(SkColorType, SkColorProfileType);
+ void setDeviceColorType(SkColorType, sk_sp<SkColorSpace>);
void toggleRendering();
void toggleSlideshow();
void toggleFPS();
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 10a7e3299c..8cb8e4d6fc 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -742,7 +742,7 @@ bool SkBitmap::extractSubset(SkBitmap* result, const SkIRect& subset) const {
if (fPixelRef->getTexture() != nullptr) {
// Do a deep copy
- SkPixelRef* pixelRef = fPixelRef->deepCopy(this->colorType(), this->profileType(), &subset);
+ SkPixelRef* pixelRef = fPixelRef->deepCopy(this->colorType(), this->colorSpace(), &subset);
if (pixelRef != nullptr) {
SkBitmap dst;
dst.setInfo(this->info().makeWH(subset.width(), subset.height()));
@@ -911,7 +911,7 @@ bool SkBitmap::copyTo(SkBitmap* dst, SkColorType dstColorType, Allocator* alloc)
bool SkBitmap::deepCopyTo(SkBitmap* dst) const {
const SkColorType dstCT = this->colorType();
- const SkColorProfileType dstPT = this->profileType();
+ SkColorSpace* dstCS = this->colorSpace();
if (!this->canCopyTo(dstCT)) {
return false;
@@ -920,10 +920,10 @@ bool SkBitmap::deepCopyTo(SkBitmap* dst) const {
// If we have a PixelRef, and it supports deep copy, use it.
// Currently supported only by texture-backed bitmaps.
if (fPixelRef) {
- SkPixelRef* pixelRef = fPixelRef->deepCopy(dstCT, dstPT, nullptr);
+ SkPixelRef* pixelRef = fPixelRef->deepCopy(dstCT, dstCS, nullptr);
if (pixelRef) {
uint32_t rowBytes;
- if (this->colorType() == dstCT && this->profileType() == dstPT) {
+ if (this->colorType() == dstCT && this->colorSpace() == dstCS) {
// Since there is no subset to pass to deepCopy, and deepCopy
// succeeded, the new pixel ref must be identical.
SkASSERT(fPixelRef->info() == pixelRef->info());
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index a894f983b5..2759a3e185 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -213,7 +213,7 @@ sk_sp<GrDrawContext> SkGpuDevice::CreateDrawContext(GrContext* context,
SkColorType ct = origInfo.colorType();
SkAlphaType at = origInfo.alphaType();
- SkColorProfileType pt = origInfo.profileType();
+ SkColorSpace* cs = origInfo.colorSpace();
if (kRGB_565_SkColorType == ct || kGray_8_SkColorType == ct) {
at = kOpaque_SkAlphaType; // force this setting
}
@@ -221,13 +221,13 @@ sk_sp<GrDrawContext> SkGpuDevice::CreateDrawContext(GrContext* context,
at = kPremul_SkAlphaType; // force this setting
}
- GrPixelConfig origConfig = SkImageInfo2GrPixelConfig(ct, at, pt, *context->caps());
+ GrPixelConfig origConfig = SkImageInfo2GrPixelConfig(ct, at, cs, *context->caps());
if (!context->caps()->isConfigRenderable(origConfig, sampleCount > 0)) {
// Fall back from whatever ct was to default of kRGBA or kBGRA which is aliased as kN32
ct = kN32_SkColorType;
}
- GrPixelConfig config = SkImageInfo2GrPixelConfig(ct, at, pt, *context->caps());
+ GrPixelConfig config = SkImageInfo2GrPixelConfig(ct, at, cs, *context->caps());
return context->newDrawContext(SkBackingFit::kExact, // Why exact?
origInfo.width(), origInfo.height(),
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index c2e284154a..45100f097b 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -243,7 +243,7 @@ GrTexture* GrUploadPixmapToTexture(GrContext* ctx, const SkPixmap& pixmap, SkBud
GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(pixmap.info(), *caps);
if (caps->srgbSupport() && !GrPixelConfigIsSRGB(desc.fConfig) &&
- kSRGB_SkColorProfileType == pixmap.info().profileType()) {
+ pixmap.info().colorSpace() && pixmap.info().colorSpace()->gammaCloseToSRGB()) {
// We were supplied sRGB as the profile type, but we don't have a suitable pixel config.
// Convert to 8888 sRGB so we can handle the data correctly. The raster backend doesn't
// handle sRGB Index8 -> sRGB 8888 correctly (yet), so lie about both the source and
@@ -418,7 +418,7 @@ GrTexture* GrRefCachedBitmapTexture(GrContext* ctx, const SkBitmap& bitmap,
// alphatype is ignore for now, but if GrPixelConfig is expanded to encompass
// alpha info, that will be considered.
-GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType, SkColorProfileType pt,
+GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType, const SkColorSpace* cs,
const GrCaps& caps) {
// We intentionally ignore profile type for non-8888 formats. Anything we can't support
// in hardware will be expanded to sRGB 8888 in GrUploadPixmapToTexture.
@@ -432,10 +432,10 @@ GrPixelConfig SkImageInfo2GrPixelConfig(SkColorType ct, SkAlphaType, SkColorProf
case kARGB_4444_SkColorType:
return kRGBA_4444_GrPixelConfig;
case kRGBA_8888_SkColorType:
- return (kSRGB_SkColorProfileType == pt && caps.srgbSupport())
+ return (caps.srgbSupport() && cs && cs->gammaCloseToSRGB())
? kSRGBA_8888_GrPixelConfig : kRGBA_8888_GrPixelConfig;
case kBGRA_8888_SkColorType:
- return (kSRGB_SkColorProfileType == pt && caps.srgbSupport())
+ return (caps.srgbSupport() && cs && cs->gammaCloseToSRGB())
? kSBGRA_8888_GrPixelConfig : kBGRA_8888_GrPixelConfig;
case kIndex_8_SkColorType:
return kIndex_8_GrPixelConfig;
diff --git a/src/gpu/SkGrPixelRef.cpp b/src/gpu/SkGrPixelRef.cpp
index df720da551..df2300369d 100644
--- a/src/gpu/SkGrPixelRef.cpp
+++ b/src/gpu/SkGrPixelRef.cpp
@@ -50,7 +50,7 @@ bool SkROLockPixelsPixelRef::onLockPixelsAreWritable() const {
///////////////////////////////////////////////////////////////////////////////
static SkGrPixelRef* copy_to_new_texture_pixelref(GrTexture* texture, SkColorType dstCT,
- SkColorProfileType dstPT, const SkIRect* subset) {
+ SkColorSpace* dstCS, const SkIRect* subset) {
if (nullptr == texture || kUnknown_SkColorType == dstCT) {
return nullptr;
}
@@ -74,7 +74,7 @@ static SkGrPixelRef* copy_to_new_texture_pixelref(GrTexture* texture, SkColorTyp
srcRect = *subset;
}
desc.fFlags = kRenderTarget_GrSurfaceFlag;
- desc.fConfig = SkImageInfo2GrPixelConfig(dstCT, kPremul_SkAlphaType, dstPT, *context->caps());
+ desc.fConfig = SkImageInfo2GrPixelConfig(dstCT, kPremul_SkAlphaType, dstCS, *context->caps());
desc.fIsMipMapped = false;
GrTexture* dst = context->textureProvider()->createTexture(desc, SkBudgeted::kNo, nullptr, 0);
@@ -89,7 +89,7 @@ static SkGrPixelRef* copy_to_new_texture_pixelref(GrTexture* texture, SkColorTyp
context->flushSurfaceWrites(dst);
SkImageInfo info = SkImageInfo::Make(desc.fWidth, desc.fHeight, dstCT, kPremul_SkAlphaType,
- dstPT);
+ sk_ref_sp(dstCS));
SkGrPixelRef* pixelRef = new SkGrPixelRef(info, dst);
SkSafeUnref(dst);
return pixelRef;
@@ -130,8 +130,7 @@ void SkGrPixelRef::onNotifyPixelsChanged() {
}
}
-SkPixelRef* SkGrPixelRef::deepCopy(SkColorType dstCT, SkColorProfileType dstPT,
- const SkIRect* subset) {
+SkPixelRef* SkGrPixelRef::deepCopy(SkColorType dstCT, SkColorSpace* dstCS, const SkIRect* subset) {
if (nullptr == fSurface) {
return nullptr;
}
@@ -142,7 +141,7 @@ SkPixelRef* SkGrPixelRef::deepCopy(SkColorType dstCT, SkColorProfileType dstPT,
// a GrTexture owned elsewhere (e.g., SkGpuDevice), and cannot live
// independently of that texture. Texture-backed pixel refs, on the other
// hand, own their GrTextures, and are thus self-contained.
- return copy_to_new_texture_pixelref(fSurface->asTexture(), dstCT, dstPT, subset);
+ return copy_to_new_texture_pixelref(fSurface->asTexture(), dstCT, dstCS, subset);
}
static bool tryAllocBitmapPixels(SkBitmap* bitmap) {
@@ -183,7 +182,7 @@ bool SkGrPixelRef::onReadPixels(SkBitmap* dst, SkColorType colorType, const SkIR
SkBitmap cachedBitmap;
cachedBitmap.setInfo(SkImageInfo::Make(bounds.width(), bounds.height(), colorType,
this->info().alphaType(),
- this->info().profileType()));
+ sk_ref_sp(this->info().colorSpace())));
// If we can't alloc the pixels, then fail
if (!tryAllocBitmapPixels(&cachedBitmap)) {
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 7f459376e7..7ce6450058 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -111,9 +111,7 @@ static void apply_premul(const SkImageInfo& info, void* pixels, size_t rowBytes)
bool SkImage_Gpu::onReadPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
int srcX, int srcY, CachingHint) const {
- GrPixelConfig config = SkImageInfo2GrPixelConfig(info.colorType(), info.alphaType(),
- info.profileType(),
- *fTexture->getContext()->caps());
+ GrPixelConfig config = SkImageInfo2GrPixelConfig(info, *fTexture->getContext()->caps());
uint32_t flags = 0;
if (kUnpremul_SkAlphaType == info.alphaType() && kPremul_SkAlphaType == fAlphaType) {
// let the GPU perform this transformation for us
diff --git a/src/views/SkWindow.cpp b/src/views/SkWindow.cpp
index d06d6bb9eb..9165c08ebe 100644
--- a/src/views/SkWindow.cpp
+++ b/src/views/SkWindow.cpp
@@ -67,15 +67,16 @@ void SkWindow::resize(int width, int height) {
this->resize(fBitmap.info().makeWH(width, height));
}
-void SkWindow::setColorType(SkColorType ct, SkColorProfileType pt) {
+void SkWindow::setColorType(SkColorType ct, sk_sp<SkColorSpace> cs) {
const SkImageInfo& info = fBitmap.info();
- this->resize(SkImageInfo::Make(info.width(), info.height(), ct, kPremul_SkAlphaType, pt));
+ this->resize(SkImageInfo::Make(info.width(), info.height(), ct, kPremul_SkAlphaType, cs));
// Set the global flag that enables or disables "legacy" mode, depending on our format.
// With sRGB 32-bit or linear FP 16, we turn on gamma-correct handling of inputs:
SkSurfaceProps props = this->getSurfaceProps();
uint32_t flags = (props.flags() & ~SkSurfaceProps::kGammaCorrect_Flag) |
- (SkColorAndProfileAreGammaCorrect(ct, pt) ? SkSurfaceProps::kGammaCorrect_Flag : 0);
+ (SkColorAndColorSpaceAreGammaCorrect(ct, cs.get())
+ ? SkSurfaceProps::kGammaCorrect_Flag : 0);
this->setSurfaceProps(SkSurfaceProps(flags, props.pixelGeometry()));
}
diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp
index a4c36ffa5d..a4dbae9eb7 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -424,7 +424,7 @@ static void test_readpixels_texture(skiatest::Reporter* reporter, GrTexture* tex
GrPixelConfig dstConfig =
SkImageInfo2GrPixelConfig(gReadPixelsConfigs[c].fColorType,
gReadPixelsConfigs[c].fAlphaType,
- kLinear_SkColorProfileType,
+ nullptr,
*texture->getContext()->caps());
uint32_t flags = 0;
if (gReadPixelsConfigs[c].fAlphaType == kUnpremul_SkAlphaType) {
diff --git a/tests/TestConfigParsing.cpp b/tests/TestConfigParsing.cpp
index 4d64cafb16..63bf120f02 100644
--- a/tests/TestConfigParsing.cpp
+++ b/tests/TestConfigParsing.cpp
@@ -46,8 +46,7 @@ DEF_TEST(ParseConfigs_Gpu, reporter) {
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseDIText() == false);
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getSamples() == 0);
REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getColorType() == kN32_SkColorType);
- REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getProfileType()
- == kLinear_SkColorProfileType);
+ REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getColorSpace() == nullptr);
#endif
}
@@ -83,6 +82,8 @@ DEF_TEST(ParseConfigs_DefaultConfigs, reporter) {
SkCommandLineConfigArray configs;
ParseConfigs(config1, &configs);
+ auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
+
REPORTER_ASSERT(reporter, configs.count() == config1.count());
for (int i = 0; i < config1.count(); ++i) {
REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i]));
@@ -118,14 +119,11 @@ DEF_TEST(ParseConfigs_DefaultConfigs, reporter) {
REPORTER_ASSERT(reporter, !configs[18]->asConfigGpu());
REPORTER_ASSERT(reporter, !configs[19]->asConfigGpu());
REPORTER_ASSERT(reporter, !configs[24]->asConfigGpu());
- REPORTER_ASSERT(reporter, configs[25]->asConfigGpu()->getColorType()
- == kRGBA_F16_SkColorType);
- REPORTER_ASSERT(reporter, configs[25]->asConfigGpu()->getProfileType()
- == kLinear_SkColorProfileType);
- REPORTER_ASSERT(reporter, configs[26]->asConfigGpu()->getColorType()
- == kN32_SkColorType);
- REPORTER_ASSERT(reporter, configs[26]->asConfigGpu()->getProfileType()
- == kSRGB_SkColorProfileType);
+ REPORTER_ASSERT(reporter, configs[25]->asConfigGpu()->getColorType() == kRGBA_F16_SkColorType);
+ REPORTER_ASSERT(reporter, configs[25]->asConfigGpu()->getColorSpace() == nullptr);
+ REPORTER_ASSERT(reporter, configs[26]->asConfigGpu()->getColorType() == kN32_SkColorType);
+ REPORTER_ASSERT(reporter, configs[26]->asConfigGpu()->getColorSpace() == srgbColorSpace.get());
+
#if SK_ANGLE
#ifdef SK_BUILD_FOR_WIN
REPORTER_ASSERT(reporter, configs[20]->asConfigGpu());
@@ -157,8 +155,7 @@ DEF_TEST(ParseConfigs_DefaultConfigs, reporter) {
REPORTER_ASSERT(reporter, configs[29]->asConfigGpu()->getUseDIText());
REPORTER_ASSERT(reporter, configs[30]->asConfigGpu());
REPORTER_ASSERT(reporter, configs[30]->asConfigGpu()->getColorType() == kN32_SkColorType);
- REPORTER_ASSERT(reporter, configs[30]->asConfigGpu()->getProfileType() ==
- kSRGB_SkColorProfileType);
+ REPORTER_ASSERT(reporter, configs[30]->asConfigGpu()->getColorSpace() == srgbColorSpace.get());
REPORTER_ASSERT(reporter, configs[31]->asConfigGpu());
REPORTER_ASSERT(reporter, configs[31]->asConfigGpu()->getSamples() == 4);
#ifdef SK_VULKAN
diff --git a/tools/flags/SkCommonFlagsConfig.cpp b/tools/flags/SkCommonFlagsConfig.cpp
index 1c7920eb55..d5c7a1d5bf 100644
--- a/tools/flags/SkCommonFlagsConfig.cpp
+++ b/tools/flags/SkCommonFlagsConfig.cpp
@@ -192,14 +192,14 @@ SkCommandLineConfig::~SkCommandLineConfig() {
SkCommandLineConfigGpu::SkCommandLineConfigGpu(
const SkString& tag, const SkTArray<SkString>& viaParts,
ContextType contextType, bool useNVPR, bool useDIText, int samples,
- SkColorType colorType, SkColorProfileType profileType)
+ SkColorType colorType, sk_sp<SkColorSpace> colorSpace)
: SkCommandLineConfig(tag, SkString("gpu"), viaParts)
, fContextType(contextType)
, fUseNVPR(useNVPR)
, fUseDIText(useDIText)
, fSamples(samples)
, fColorType(colorType)
- , fProfileType(profileType) {
+ , fColorSpace(std::move(colorSpace)) {
}
static bool parse_option_int(const SkString& value, int* outInt) {
if (value.isEmpty()) {
@@ -276,20 +276,20 @@ static bool parse_option_gpu_api(const SkString& value,
}
static bool parse_option_gpu_color(const SkString& value,
SkColorType* outColorType,
- SkColorProfileType* outProfileType) {
+ sk_sp<SkColorSpace>* outColorSpace) {
if (value.equals("8888")) {
*outColorType = kN32_SkColorType;
- *outProfileType = kLinear_SkColorProfileType;
+ *outColorSpace = nullptr;
return true;
}
if (value.equals("f16")) {
*outColorType = kRGBA_F16_SkColorType;
- *outProfileType = kLinear_SkColorProfileType;
+ *outColorSpace = nullptr;
return true;
}
if (value.equals("srgb")) {
*outColorType = kN32_SkColorType;
- *outProfileType = kSRGB_SkColorProfileType;
+ *outColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
return true;
}
return false;
@@ -309,7 +309,7 @@ SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag,
int samples = 0;
bool seenColor = false;
SkColorType colorType = kN32_SkColorType;
- SkColorProfileType profileType = kLinear_SkColorProfileType;
+ sk_sp<SkColorSpace> colorSpace = nullptr;
SkTArray<SkString> optionParts;
SkStrSplit(options.c_str(), ",", kStrict_SkStrSplitMode, &optionParts);
@@ -335,7 +335,7 @@ SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag,
valueOk = parse_option_int(value, &samples);
seenSamples = true;
} else if (key.equals("color") && !seenColor) {
- valueOk = parse_option_gpu_color(value, &colorType, &profileType);
+ valueOk = parse_option_gpu_color(value, &colorType, &colorSpace);
seenColor = true;
}
if (!valueOk) {
@@ -343,7 +343,7 @@ SkCommandLineConfigGpu* parse_command_line_config_gpu(const SkString& tag,
}
}
return new SkCommandLineConfigGpu(tag, vias, contextType, useNVPR, useDIText, samples,
- colorType, profileType);
+ colorType, colorSpace);
}
#endif
diff --git a/tools/flags/SkCommonFlagsConfig.h b/tools/flags/SkCommonFlagsConfig.h
index 5d95ef186a..dc38977cb8 100644
--- a/tools/flags/SkCommonFlagsConfig.h
+++ b/tools/flags/SkCommonFlagsConfig.h
@@ -53,14 +53,14 @@ class SkCommandLineConfigGpu : public SkCommandLineConfig {
typedef sk_gpu_test::GrContextFactory::ContextType ContextType;
SkCommandLineConfigGpu(const SkString& tag, const SkTArray<SkString>& viaParts,
ContextType contextType, bool useNVPR, bool useDIText, int samples,
- SkColorType colorType, SkColorProfileType profileType);
+ SkColorType colorType, sk_sp<SkColorSpace> colorSpace);
const SkCommandLineConfigGpu* asConfigGpu() const override { return this; }
ContextType getContextType() const { return fContextType; }
bool getUseNVPR() const { return fUseNVPR; }
bool getUseDIText() const { return fUseDIText; }
int getSamples() const { return fSamples; }
SkColorType getColorType() const { return fColorType; }
- SkColorProfileType getProfileType() const { return fProfileType; }
+ SkColorSpace* getColorSpace() const { return fColorSpace.get(); }
private:
ContextType fContextType;
@@ -68,7 +68,7 @@ class SkCommandLineConfigGpu : public SkCommandLineConfig {
bool fUseDIText;
int fSamples;
SkColorType fColorType;
- SkColorProfileType fProfileType;
+ sk_sp<SkColorSpace> fColorSpace;
};
#endif
diff --git a/tools/picture_utils.cpp b/tools/picture_utils.cpp
index 63a48ce3e1..a6803c67db 100644
--- a/tools/picture_utils.cpp
+++ b/tools/picture_utils.cpp
@@ -80,8 +80,9 @@ namespace sk_tools {
SkAutoTMalloc<uint32_t> rgba(w*h);
- if (bitmap. colorType() == kN32_SkColorType &&
- bitmap.profileType() == kSRGB_SkColorProfileType) {
+ auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
+ if (bitmap. colorType() == kN32_SkColorType &&
+ bitmap.colorSpace() == srgbColorSpace.get()) {
// These are premul sRGB 8-bit pixels in SkPMColor order.
// We want unpremul sRGB 8-bit pixels in RGBA order. We'll get there via floats.
bitmap.lockPixels();
diff --git a/tools/skiaserve/Request.cpp b/tools/skiaserve/Request.cpp
index c3eaaff387..756f70e24d 100644
--- a/tools/skiaserve/Request.cpp
+++ b/tools/skiaserve/Request.cpp
@@ -159,14 +159,14 @@ namespace {
struct ColorAndProfile {
SkColorType fColorType;
- SkColorProfileType fProfileType;
+ bool fSRGB;
bool fGammaCorrect;
};
ColorAndProfile ColorModes[] = {
- { kN32_SkColorType, kLinear_SkColorProfileType, false },
- { kN32_SkColorType, kSRGB_SkColorProfileType, true },
- { kRGBA_F16_SkColorType, kLinear_SkColorProfileType, true },
+ { kN32_SkColorType, false, false },
+ { kN32_SkColorType, true, true },
+ { kRGBA_F16_SkColorType, false, true },
};
}
@@ -174,8 +174,9 @@ ColorAndProfile ColorModes[] = {
SkSurface* Request::createCPUSurface() {
SkIRect bounds = this->getBounds();
ColorAndProfile cap = ColorModes[fColorMode];
+ auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), cap.fColorType,
- kPremul_SkAlphaType, cap.fProfileType);
+ kPremul_SkAlphaType, cap.fSRGB ? srgbColorSpace : nullptr);
uint32_t flags = cap.fGammaCorrect ? SkSurfaceProps::kGammaCorrect_Flag : 0;
SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
return SkSurface::MakeRaster(info, &props).release();
@@ -185,8 +186,9 @@ SkSurface* Request::createGPUSurface() {
GrContext* context = this->getContext();
SkIRect bounds = this->getBounds();
ColorAndProfile cap = ColorModes[fColorMode];
+ auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
SkImageInfo info = SkImageInfo::Make(bounds.width(), bounds.height(), cap.fColorType,
- kPremul_SkAlphaType, cap.fProfileType);
+ kPremul_SkAlphaType, cap.fSRGB ? srgbColorSpace : nullptr);
uint32_t flags = cap.fGammaCorrect ? SkSurfaceProps::kGammaCorrect_Flag : 0;
SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
SkSurface* surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info, 0,
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index 43697f88b8..9aec01f3ec 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -122,8 +122,8 @@ Viewer::Viewer(int argc, char** argv, void* platformData)
});
fCommands.addCommand('c', "Modes", "Toggle sRGB color mode", [this]() {
DisplayParams params = fWindow->getDisplayParams();
- params.fProfileType = (kLinear_SkColorProfileType == params.fProfileType)
- ? kSRGB_SkColorProfileType : kLinear_SkColorProfileType;
+ params.fColorSpace = (nullptr == params.fColorSpace)
+ ? SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) : nullptr;
fWindow->setDisplayParams(params);
this->updateTitle();
fWindow->inval();
@@ -266,7 +266,9 @@ Viewer::~Viewer() {
void Viewer::updateTitle() {
SkString title("Viewer: ");
title.append(fSlides[fCurrentSlide]->getName());
- if (kSRGB_SkColorProfileType == fWindow->getDisplayParams().fProfileType) {
+
+ // TODO: For now, any color-space on the window means sRGB
+ if (fWindow->getDisplayParams().fColorSpace) {
title.append(" sRGB");
}
title.append(kBackendTypeStrings[fBackendType]);
diff --git a/tools/viewer/sk_app/DisplayParams.h b/tools/viewer/sk_app/DisplayParams.h
index 8756ff0aac..b9a23f322d 100644
--- a/tools/viewer/sk_app/DisplayParams.h
+++ b/tools/viewer/sk_app/DisplayParams.h
@@ -14,14 +14,14 @@ namespace sk_app {
struct DisplayParams {
DisplayParams()
: fColorType(kN32_SkColorType)
- , fProfileType(kLinear_SkColorProfileType)
+ , fColorSpace(nullptr)
, fMSAASampleCount(0)
, fDeepColor(false) {}
- SkColorType fColorType;
- SkColorProfileType fProfileType;
- int fMSAASampleCount;
- bool fDeepColor;
+ SkColorType fColorType;
+ sk_sp<SkColorSpace> fColorSpace;
+ int fMSAASampleCount;
+ bool fDeepColor;
};
} // namespace sk_app
diff --git a/tools/viewer/sk_app/GLWindowContext.cpp b/tools/viewer/sk_app/GLWindowContext.cpp
index a491321a2a..b960da4824 100644
--- a/tools/viewer/sk_app/GLWindowContext.cpp
+++ b/tools/viewer/sk_app/GLWindowContext.cpp
@@ -47,8 +47,8 @@ void GLWindowContext::initializeContext(void* platformData, const DisplayParams&
// ... and, if we're using a 10-bit/channel FB0, it doesn't do sRGB conversion on write,
// so pretend that it's non-sRGB 8888:
fPixelConfig = fContext->caps()->srgbSupport() &&
- SkColorAndProfileAreGammaCorrect(fDisplayParams.fColorType,
- fDisplayParams.fProfileType) &&
+ SkColorAndColorSpaceAreGammaCorrect(fDisplayParams.fColorType,
+ fDisplayParams.fColorSpace.get()) &&
(fColorBits != 30) ? kSkiaGamma8888_GrPixelConfig : kSkia8888_GrPixelConfig;
}
diff --git a/tools/viewer/sk_app/VulkanWindowContext.cpp b/tools/viewer/sk_app/VulkanWindowContext.cpp
index 9bcf6ca25d..d892cd4783 100644
--- a/tools/viewer/sk_app/VulkanWindowContext.cpp
+++ b/tools/viewer/sk_app/VulkanWindowContext.cpp
@@ -173,7 +173,8 @@ bool VulkanWindowContext::createSwapchain(uint32_t width, uint32_t height,
// Pick our surface format. For now, just make sure it matches our sRGB request:
VkFormat surfaceFormat = VK_FORMAT_UNDEFINED;
VkColorSpaceKHR colorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR;
- bool wantSRGB = kSRGB_SkColorProfileType == params.fProfileType;
+ auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
+ bool wantSRGB = srgbColorSpace == params.fColorSpace;
for (uint32_t i = 0; i < surfaceFormatCount; ++i) {
GrPixelConfig config;
if (GrVkFormatToPixelConfig(surfaceFormats[i].format, &config) &&
diff --git a/tools/viewer/sk_app/WindowContext.cpp b/tools/viewer/sk_app/WindowContext.cpp
index 41bbd14576..ecac2cc004 100755
--- a/tools/viewer/sk_app/WindowContext.cpp
+++ b/tools/viewer/sk_app/WindowContext.cpp
@@ -36,7 +36,7 @@ sk_sp<SkSurface> WindowContext::createRenderSurface(sk_sp<GrRenderTarget> rt, in
SkImageInfo info = SkImageInfo::Make(fWidth, fHeight,
fDisplayParams.fColorType,
kUnknown_SkAlphaType,
- fDisplayParams.fProfileType);
+ fDisplayParams.fColorSpace);
return SkSurface::MakeRenderTarget(fContext, SkBudgeted::kNo, info,
fDisplayParams.fMSAASampleCount, &props);
} else {
@@ -52,7 +52,7 @@ void WindowContext::presentRenderSurface(sk_sp<SkSurface> renderSurface, sk_sp<G
SkImageInfo info = SkImageInfo::Make(fWidth, fHeight,
fDisplayParams.fColorType,
kUnknown_SkAlphaType,
- fDisplayParams.fProfileType);
+ fDisplayParams.fColorSpace);
SkBitmap bm;
bm.allocPixels(info);
renderSurface->getCanvas()->readPixels(&bm, 0, 0);
diff --git a/tools/viewer/sk_app/android/GLWindowContext_android.cpp b/tools/viewer/sk_app/android/GLWindowContext_android.cpp
index 79425b4115..be62ab2b68 100644
--- a/tools/viewer/sk_app/android/GLWindowContext_android.cpp
+++ b/tools/viewer/sk_app/android/GLWindowContext_android.cpp
@@ -99,7 +99,8 @@ void GLWindowContext_android::onInitializeContext(void* platformData, const Disp
EGL_NONE,
};
const EGLint* windowAttribs = nullptr;
- if (kSRGB_SkColorProfileType == params.fProfileType && majorVersion == 1 && minorVersion >= 2) {
+ auto srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
+ if (srgbColorSpace == params.fColorSpace && majorVersion == 1 && minorVersion >= 2) {
windowAttribs = srgbWindowAttribs;
}
diff --git a/tools/viewer/sk_app/android/RasterWindowContext_android.cpp b/tools/viewer/sk_app/android/RasterWindowContext_android.cpp
index 5e1e351b9a..a5f9a657fe 100644
--- a/tools/viewer/sk_app/android/RasterWindowContext_android.cpp
+++ b/tools/viewer/sk_app/android/RasterWindowContext_android.cpp
@@ -68,7 +68,7 @@ sk_sp<SkSurface> RasterWindowContext_android::getBackbufferSurface() {
SkImageInfo info = SkImageInfo::Make(fWidth, fHeight,
fDisplayParams.fColorType,
kOpaque_SkAlphaType,
- fDisplayParams.fProfileType);
+ fDisplayParams.fColorSpace);
fBackbufferSurface = SkSurface::MakeRasterDirect(
info, fBuffer.bits, fBuffer.stride * bytePerPixel, nullptr);
}