Make all the codecs default profiles based on gTreatSkColorAsSRGB.
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1893203006 Review URL: https://codereview.chromium.org/1893203006
This commit is contained in:
parent
650f9e9a26
commit
9bc22351b5
@ -413,6 +413,7 @@
|
||||
'<(skia_include_path)/private/SkFloatBits.h',
|
||||
'<(skia_include_path)/private/SkFloatingPoint.h',
|
||||
'<(skia_include_path)/private/SkGpuFenceSync.h',
|
||||
'<(skia_include_path)/private/SkImageInfoPriv.h',
|
||||
'<(skia_include_path)/private/SkMiniRecorder.h',
|
||||
'<(skia_include_path)/private/SkMutex.h',
|
||||
'<(skia_include_path)/private/SkOnce.h',
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define SkEncodedInfo_DEFINED
|
||||
|
||||
#include "SkImageInfo.h"
|
||||
#include "../private/SkImageInfoPriv.h"
|
||||
|
||||
struct SkEncodedInfo {
|
||||
public:
|
||||
@ -124,18 +125,21 @@ public:
|
||||
* closest possible match to the encoded info.
|
||||
*/
|
||||
SkImageInfo makeImageInfo(int width, int height) const {
|
||||
SkColorProfileType profileType = SkDefaultColorProfile();
|
||||
switch (fColor) {
|
||||
case kGray_Color:
|
||||
SkASSERT(kOpaque_Alpha == fAlpha);
|
||||
return SkImageInfo::Make(width, height, kGray_8_SkColorType, kOpaque_SkAlphaType);
|
||||
return SkImageInfo::Make(width, height, kGray_8_SkColorType,
|
||||
kOpaque_SkAlphaType, profileType);
|
||||
case kGrayAlpha_Color:
|
||||
SkASSERT(kOpaque_Alpha != fAlpha);
|
||||
return SkImageInfo::Make(width, height, kN32_SkColorType,
|
||||
kUnpremul_SkAlphaType);
|
||||
kUnpremul_SkAlphaType, profileType);
|
||||
case kPalette_Color: {
|
||||
SkAlphaType alphaType = (kOpaque_Alpha == fAlpha) ? kOpaque_SkAlphaType :
|
||||
kUnpremul_SkAlphaType;
|
||||
return SkImageInfo::Make(width, height, kIndex_8_SkColorType, alphaType);
|
||||
return SkImageInfo::Make(width, height, kIndex_8_SkColorType,
|
||||
alphaType, profileType);
|
||||
}
|
||||
case kRGB_Color:
|
||||
case kBGR_Color:
|
||||
@ -144,12 +148,14 @@ public:
|
||||
case kInvertedCMYK_Color:
|
||||
case kYCCK_Color:
|
||||
SkASSERT(kOpaque_Alpha == fAlpha);
|
||||
return SkImageInfo::Make(width, height, kN32_SkColorType, kOpaque_SkAlphaType);
|
||||
return SkImageInfo::Make(width, height, kN32_SkColorType,
|
||||
kOpaque_SkAlphaType, profileType);
|
||||
case kRGBA_Color:
|
||||
case kBGRA_Color:
|
||||
case kYUVA_Color:
|
||||
SkASSERT(kOpaque_Alpha != fAlpha);
|
||||
return SkImageInfo::Make(width, height, kN32_SkColorType, kUnpremul_SkAlphaType);
|
||||
return SkImageInfo::Make(width, height, kN32_SkColorType,
|
||||
kUnpremul_SkAlphaType, profileType);
|
||||
default:
|
||||
SkASSERT(false);
|
||||
return SkImageInfo::MakeUnknown();
|
||||
|
19
include/private/SkImageInfoPriv.h
Normal file
19
include/private/SkImageInfoPriv.h
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#ifndef SkImageInfoPriv_DEFINED
|
||||
#define SkImageInfoPriv_DEFINED
|
||||
|
||||
#include "SkImageInfo.h"
|
||||
|
||||
// Indicate how images and gradients should interpret colors by default.
|
||||
extern bool gDefaultProfileIsSRGB;
|
||||
|
||||
static SkColorProfileType SkDefaultColorProfile() {
|
||||
return gDefaultProfileIsSRGB ? kSRGB_SkColorProfileType : kLinear_SkColorProfileType;
|
||||
}
|
||||
|
||||
#endif // SkImageInfoPriv_DEFINED
|
@ -747,7 +747,9 @@ bool SkBitmap::extractSubset(SkBitmap* result, const SkIRect& subset) const {
|
||||
SkPixelRef* pixelRef = fPixelRef->deepCopy(this->colorType(), this->profileType(), &subset);
|
||||
if (pixelRef != nullptr) {
|
||||
SkBitmap dst;
|
||||
dst.setInfo(this->info().makeWH(subset.width(), subset.height()));
|
||||
dst.setInfo(SkImageInfo::Make(subset.width(), subset.height(),
|
||||
this->colorType(), this->alphaType(),
|
||||
this->profileType()));
|
||||
dst.setIsVolatile(this->isVolatile());
|
||||
dst.setPixelRef(pixelRef)->unref();
|
||||
SkDEBUGCODE(dst.validate());
|
||||
@ -762,7 +764,9 @@ bool SkBitmap::extractSubset(SkBitmap* result, const SkIRect& subset) const {
|
||||
SkASSERT(static_cast<unsigned>(r.fTop) < static_cast<unsigned>(this->height()));
|
||||
|
||||
SkBitmap dst;
|
||||
dst.setInfo(this->info().makeWH(r.width(), r.height()), this->rowBytes());
|
||||
dst.setInfo(SkImageInfo::Make(r.width(), r.height(),
|
||||
this->colorType(), this->alphaType(), this->profileType()),
|
||||
this->rowBytes());
|
||||
dst.setIsVolatile(this->isVolatile());
|
||||
|
||||
if (fPixelRef) {
|
||||
|
@ -45,8 +45,7 @@ bool SkBitmapProvider::validForDrawing() const {
|
||||
|
||||
SkImageInfo SkBitmapProvider::info() const {
|
||||
if (fImage) {
|
||||
SkAlphaType at = fImage->isOpaque() ? kOpaque_SkAlphaType : kPremul_SkAlphaType;
|
||||
return SkImageInfo::MakeN32(fImage->width(), fImage->height(), at);
|
||||
return as_IB(fImage)->onImageInfo();
|
||||
} else {
|
||||
return fBitmap.info();
|
||||
}
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include "SkReadBuffer.h"
|
||||
#include "SkWriteBuffer.h"
|
||||
|
||||
bool gDefaultProfileIsSRGB;
|
||||
|
||||
static bool profile_type_is_valid(SkColorProfileType profileType) {
|
||||
return (profileType >= 0) && (profileType <= kLastEnum_SkColorProfileType);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user