aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar brianosman <brianosman@google.com>2016-06-16 11:10:03 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-06-16 11:10:04 -0700
commit6a61a875467646f8dbc37cfecf49e12d1f475170 (patch)
treedb9b06850ce0d7f35fb9d21b14a0b1c431edb349 /src
parentdea0340cadb759932e53416a657f5ea75fee8b5f (diff)
Lots of progress on switching to SkColorSpace rather than SkColorProfileType
Fixed a bunch of code in Ganesh, as well as usage of SkColorProfileType in most of our tools (DM, SampleApp, Viewer, nanobench, skiaserve, HelloWorld). BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2069173002 Review-Url: https://codereview.chromium.org/2069173002
Diffstat (limited to 'src')
-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
6 files changed, 22 insertions, 24 deletions
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()));
}