Remove GrPixelConfig from GrColorSpaceInfo.
Replace GrColorInfo with GrColorSpaceInfo. Change-Id: I7abe28203dd7f22162d68c4eee41293f483bb1aa Reviewed-on: https://skia-review.googlesource.com/c/skia/+/225036 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
effee20657
commit
bd3d8d39b3
@ -1253,6 +1253,149 @@ static constexpr uint32_t GrColorTypeComponentFlags(GrColorType ct) {
|
||||
SkUNREACHABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the encoding of channel data in a GrColorType.
|
||||
*/
|
||||
enum class GrColorTypeEncoding {
|
||||
kUnorm,
|
||||
// kSRGBUnorm,
|
||||
// kSnorm,
|
||||
kFloat,
|
||||
// kSint
|
||||
// kUint
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes a GrColorType by how many bits are used for each color component and how they are
|
||||
* encoded. Currently all the non-zero channels share a single GrColorTypeEncoding. This could be
|
||||
* expanded to store separate encodings and to indicate which bits belong to which components.
|
||||
*/
|
||||
struct GrColorTypeDesc {
|
||||
public:
|
||||
static constexpr GrColorTypeDesc MakeRGBA(int rgba, GrColorTypeEncoding e) {
|
||||
return {rgba, rgba, rgba, rgba, 0, e};
|
||||
}
|
||||
|
||||
static constexpr GrColorTypeDesc MakeRGBA(int rgb, int a, GrColorTypeEncoding e) {
|
||||
return {rgb, rgb, rgb, a, 0, e};
|
||||
}
|
||||
|
||||
static constexpr GrColorTypeDesc MakeRGB(int rgb, GrColorTypeEncoding e) {
|
||||
return {rgb, rgb, rgb, 0, 0, e};
|
||||
}
|
||||
|
||||
static constexpr GrColorTypeDesc MakeRGB(int r, int g, int b, GrColorTypeEncoding e) {
|
||||
return {r, g, b, 0, 0, e};
|
||||
}
|
||||
|
||||
static constexpr GrColorTypeDesc MakeAlpha(int a, GrColorTypeEncoding e) {
|
||||
return {0, 0, 0, a, 0, e};
|
||||
}
|
||||
|
||||
static constexpr GrColorTypeDesc MakeR(int r, GrColorTypeEncoding e) {
|
||||
return {r, 0, 0, 0, 0, e};
|
||||
}
|
||||
|
||||
static constexpr GrColorTypeDesc MakeRG(int rg, GrColorTypeEncoding e) {
|
||||
return {rg, rg, 0, 0, 0, e};
|
||||
}
|
||||
|
||||
static constexpr GrColorTypeDesc MakeGray(int grayBits, GrColorTypeEncoding e) {
|
||||
return {0, 0, 0, 0, grayBits, e};
|
||||
}
|
||||
|
||||
static constexpr GrColorTypeDesc MakeInvalid() { return {}; }
|
||||
|
||||
constexpr int r() const { return fRBits; }
|
||||
constexpr int g() const { return fGBits; }
|
||||
constexpr int b() const { return fBBits; }
|
||||
constexpr int a() const { return fABits; }
|
||||
|
||||
constexpr int gray() const { return fGrayBits; }
|
||||
|
||||
constexpr GrColorTypeEncoding encoding() const { return fEncoding; }
|
||||
|
||||
private:
|
||||
int fRBits = 0;
|
||||
int fGBits = 0;
|
||||
int fBBits = 0;
|
||||
int fABits = 0;
|
||||
int fGrayBits = 0;
|
||||
GrColorTypeEncoding fEncoding = GrColorTypeEncoding::kUnorm;
|
||||
|
||||
constexpr GrColorTypeDesc() = default;
|
||||
|
||||
constexpr GrColorTypeDesc(int r, int g, int b, int a, int gray, GrColorTypeEncoding encoding)
|
||||
: fRBits(r), fGBits(g), fBBits(b), fABits(a), fGrayBits(gray), fEncoding(encoding) {
|
||||
SkASSERT(r >= 0 && g >= 0 && b >= 0 && a >= 0 && gray >= 0);
|
||||
SkASSERT(!gray || (!r && !g && !b));
|
||||
SkASSERT(r || g || b || a || gray);
|
||||
}
|
||||
};
|
||||
|
||||
static constexpr GrColorTypeDesc GrGetColorTypeDesc(GrColorType ct) {
|
||||
switch (ct) {
|
||||
case GrColorType::kUnknown:
|
||||
return GrColorTypeDesc::MakeInvalid();
|
||||
case GrColorType::kAlpha_8:
|
||||
return GrColorTypeDesc::MakeAlpha(8, GrColorTypeEncoding::kUnorm);
|
||||
case GrColorType::kBGR_565:
|
||||
return GrColorTypeDesc::MakeRGB(5, 6, 5, GrColorTypeEncoding::kUnorm);
|
||||
case GrColorType::kABGR_4444:
|
||||
return GrColorTypeDesc::MakeRGBA(4, GrColorTypeEncoding::kUnorm);
|
||||
case GrColorType::kRGBA_8888:
|
||||
return GrColorTypeDesc::MakeRGBA(8, GrColorTypeEncoding::kUnorm);
|
||||
case GrColorType::kRGB_888x:
|
||||
return GrColorTypeDesc::MakeRGB(8, GrColorTypeEncoding::kUnorm);
|
||||
case GrColorType::kRG_88:
|
||||
return GrColorTypeDesc::MakeRG(8, GrColorTypeEncoding::kUnorm);
|
||||
case GrColorType::kBGRA_8888:
|
||||
return GrColorTypeDesc::MakeRGBA(8, GrColorTypeEncoding::kUnorm);
|
||||
case GrColorType::kRGBA_1010102:
|
||||
return GrColorTypeDesc::MakeRGBA(10, 2, GrColorTypeEncoding::kUnorm);
|
||||
case GrColorType::kGray_8:
|
||||
return GrColorTypeDesc::MakeGray(8, GrColorTypeEncoding::kUnorm);
|
||||
case GrColorType::kAlpha_F16:
|
||||
return GrColorTypeDesc::MakeAlpha(16, GrColorTypeEncoding::kFloat);
|
||||
case GrColorType::kRGBA_F16:
|
||||
return GrColorTypeDesc::MakeRGBA(16, GrColorTypeEncoding::kFloat);
|
||||
case GrColorType::kRGBA_F16_Clamped:
|
||||
return GrColorTypeDesc::MakeRGBA(16, GrColorTypeEncoding::kFloat);
|
||||
case GrColorType::kRG_F32:
|
||||
return GrColorTypeDesc::MakeRG(32, GrColorTypeEncoding::kFloat);
|
||||
case GrColorType::kRGBA_F32:
|
||||
return GrColorTypeDesc::MakeRGBA(32, GrColorTypeEncoding::kFloat);
|
||||
case GrColorType::kR_16:
|
||||
return GrColorTypeDesc::MakeR(16, GrColorTypeEncoding::kUnorm);
|
||||
case GrColorType::kRG_1616:
|
||||
return GrColorTypeDesc::MakeRG(16, GrColorTypeEncoding::kUnorm);
|
||||
case GrColorType::kRGBA_16161616:
|
||||
return GrColorTypeDesc::MakeRGBA(16, GrColorTypeEncoding::kUnorm);
|
||||
case GrColorType::kRG_F16:
|
||||
return GrColorTypeDesc::MakeRG(16, GrColorTypeEncoding::kFloat);
|
||||
}
|
||||
SkUNREACHABLE;
|
||||
}
|
||||
|
||||
static constexpr GrClampType GrColorTypeClampType(GrColorType colorType) {
|
||||
if (GrGetColorTypeDesc(colorType).encoding() == GrColorTypeEncoding::kUnorm) {
|
||||
return GrClampType::kAuto;
|
||||
}
|
||||
return GrColorType::kRGBA_F16_Clamped == colorType ? GrClampType::kManual : GrClampType::kNone;
|
||||
}
|
||||
|
||||
// Consider a color type "wider" than n if it has more than n bits for any its representable
|
||||
// channels.
|
||||
static constexpr bool GrColorTypeIsWiderThan(GrColorType colorType, int n) {
|
||||
SkASSERT(n > 0);
|
||||
auto desc = GrGetColorTypeDesc(colorType);
|
||||
return (desc.r() && desc.r() > n )||
|
||||
(desc.g() && desc.g() > n) ||
|
||||
(desc.b() && desc.b() > n) ||
|
||||
(desc.a() && desc.a() > n) ||
|
||||
(desc.gray() && desc.gray() > n);
|
||||
}
|
||||
|
||||
static constexpr bool GrColorTypeIsAlphaOnly(GrColorType ct) {
|
||||
return kAlpha_SkColorTypeComponentFlag == GrColorTypeComponentFlags(ct);
|
||||
}
|
||||
|
@ -73,8 +73,8 @@ void SkAtlasTextTarget::concat(const SkMatrix& matrix) { this->accessCTM()->preC
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static const GrColorSpaceInfo kColorSpaceInfo(GrColorType::kRGBA_8888, kPremul_SkAlphaType, nullptr,
|
||||
kRGBA_8888_GrPixelConfig);
|
||||
static const GrColorSpaceInfo kColorSpaceInfo(GrColorType::kRGBA_8888, kPremul_SkAlphaType,
|
||||
nullptr);
|
||||
static const SkSurfaceProps kProps(
|
||||
SkSurfaceProps::kUseDistanceFieldFonts_Flag, kUnknown_SkPixelGeometry);
|
||||
|
||||
|
@ -400,7 +400,7 @@ std::unique_ptr<GrFragmentProcessor> ColorTableEffect::TestCreate(GrProcessorTes
|
||||
sk_sp<SkColorSpace> colorSpace = GrTest::TestColorSpace(d->fRandom);
|
||||
auto fp = filter->asFragmentProcessor(
|
||||
d->context(), GrColorSpaceInfo(GrColorType::kRGBA_8888, kUnknown_SkAlphaType,
|
||||
std::move(colorSpace), kRGBA_8888_GrPixelConfig));
|
||||
std::move(colorSpace)));
|
||||
SkASSERT(fp);
|
||||
return fp;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
static GrColorSpaceInfo make_info(const SkBitmap& bm) {
|
||||
return GrColorSpaceInfo(SkColorTypeToGrColorType(bm.colorType()), bm.alphaType(),
|
||||
bm.refColorSpace(), SkImageInfo2GrPixelConfig(bm.info()));
|
||||
bm.refColorSpace());
|
||||
}
|
||||
|
||||
GrBitmapTextureMaker::GrBitmapTextureMaker(GrRecordingContext* context, const SkBitmap& bitmap,
|
||||
|
@ -10,13 +10,8 @@
|
||||
|
||||
GrColorSpaceInfo::GrColorSpaceInfo(GrColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
GrPixelConfig config)
|
||||
: fColorSpace(std::move(colorSpace))
|
||||
, fColorType(colorType)
|
||||
, fAlphaType(alphaType)
|
||||
, fConfig(config)
|
||||
, fInitializedColorSpaceXformFromSRGB(false) {}
|
||||
sk_sp<SkColorSpace> colorSpace)
|
||||
: fColorSpace(std::move(colorSpace)), fColorType(colorType), fAlphaType(alphaType) {}
|
||||
|
||||
GrColorSpaceXform* GrColorSpaceInfo::colorSpaceXformFromSRGB() const {
|
||||
// TODO: Make this atomic if we start accessing this on multiple threads.
|
||||
|
@ -16,7 +16,8 @@
|
||||
/** Describes the color space properties of a surface context. */
|
||||
class GrColorSpaceInfo {
|
||||
public:
|
||||
GrColorSpaceInfo(GrColorType, SkAlphaType, sk_sp<SkColorSpace>, GrPixelConfig);
|
||||
GrColorSpaceInfo() = default;
|
||||
GrColorSpaceInfo(GrColorType, SkAlphaType, sk_sp<SkColorSpace>);
|
||||
|
||||
bool isLinearlyBlended() const { return fColorSpace && fColorSpace->gammaIsLinear(); }
|
||||
|
||||
@ -31,16 +32,16 @@ public:
|
||||
GrColorType colorType() const { return fColorType; }
|
||||
SkAlphaType alphaType() const { return fAlphaType; }
|
||||
|
||||
// TODO: Remove.
|
||||
GrPixelConfig config() const { return fConfig; }
|
||||
bool isValid() const {
|
||||
return fColorType != GrColorType::kUnknown && fAlphaType != kUnknown_SkAlphaType;
|
||||
}
|
||||
|
||||
private:
|
||||
sk_sp<SkColorSpace> fColorSpace;
|
||||
mutable sk_sp<GrColorSpaceXform> fColorXformFromSRGB;
|
||||
GrColorType fColorType;
|
||||
SkAlphaType fAlphaType;
|
||||
GrPixelConfig fConfig;
|
||||
mutable bool fInitializedColorSpaceXformFromSRGB;
|
||||
GrColorType fColorType = GrColorType::kUnknown;
|
||||
SkAlphaType fAlphaType = kUnknown_SkAlphaType;
|
||||
mutable bool fInitializedColorSpaceXformFromSRGB = false;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "include/core/SkColor.h"
|
||||
#include "include/private/GrTypesPriv.h"
|
||||
#include "src/gpu/GrColorSpaceInfo.h"
|
||||
#include "src/gpu/GrSwizzle.h"
|
||||
|
||||
size_t GrCompressedDataSize(SkImage::CompressionType, int w, int h);
|
||||
@ -25,38 +26,6 @@ void GrFillInData(GrPixelConfig, int baseWidth, int baseHeight,
|
||||
|
||||
void GrFillInCompressedData(SkImage::CompressionType, int width, int height, char* dest,
|
||||
const SkColor4f& color);
|
||||
|
||||
// TODO: Replace with GrColorSpaceInfo once GrPixelConfig is excised from that type.
|
||||
class GrColorInfo {
|
||||
public:
|
||||
GrColorInfo() = default;
|
||||
|
||||
GrColorInfo(GrColorType ct, SkAlphaType at, sk_sp<SkColorSpace> cs)
|
||||
: fColorSpace(std::move(cs)), fColorType(ct), fAlphaType(at) {}
|
||||
|
||||
GrColorInfo(const GrColorInfo&) = default;
|
||||
GrColorInfo(GrColorInfo&&) = default;
|
||||
GrColorInfo& operator=(const GrColorInfo&) = default;
|
||||
GrColorInfo& operator=(GrColorInfo&&) = default;
|
||||
|
||||
GrColorType colorType() const { return fColorType; }
|
||||
|
||||
SkAlphaType alphaType() const { return fAlphaType; }
|
||||
|
||||
SkColorSpace* colorSpace() const { return fColorSpace.get(); }
|
||||
|
||||
sk_sp<SkColorSpace> refColorSpace() const { return fColorSpace; }
|
||||
|
||||
bool isValid() const {
|
||||
return fColorType != GrColorType::kUnknown && fAlphaType != kUnknown_SkAlphaType;
|
||||
}
|
||||
|
||||
private:
|
||||
sk_sp<SkColorSpace> fColorSpace;
|
||||
GrColorType fColorType = GrColorType::kUnknown;
|
||||
SkAlphaType fAlphaType = kUnknown_SkAlphaType;
|
||||
};
|
||||
|
||||
class GrPixelInfo {
|
||||
public:
|
||||
GrPixelInfo() = default;
|
||||
@ -126,7 +95,7 @@ public:
|
||||
bool isValid() const { return fColorInfo.isValid() && fWidth > 0 && fHeight > 0; }
|
||||
|
||||
private:
|
||||
GrColorInfo fColorInfo = {};
|
||||
GrColorSpaceInfo fColorInfo = {};
|
||||
int fWidth = 0;
|
||||
int fHeight = 0;
|
||||
};
|
||||
|
@ -16,8 +16,7 @@
|
||||
static GrColorSpaceInfo make_info(const SkImage*& image) {
|
||||
return GrColorSpaceInfo(SkColorTypeToGrColorType(image->colorType()),
|
||||
image->alphaType(),
|
||||
image->refColorSpace(),
|
||||
SkImageInfo2GrPixelConfig(image->imageInfo()));
|
||||
image->refColorSpace());
|
||||
}
|
||||
|
||||
GrImageTextureMaker::GrImageTextureMaker(GrRecordingContext* context, const SkImage* client,
|
||||
|
@ -147,8 +147,7 @@ GrRenderTargetContext::GrRenderTargetContext(GrRecordingContext* context,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
const SkSurfaceProps* surfaceProps,
|
||||
bool managedOpList)
|
||||
: GrSurfaceContext(context, colorType, kPremul_SkAlphaType, std::move(colorSpace),
|
||||
rtp->config())
|
||||
: GrSurfaceContext(context, colorType, kPremul_SkAlphaType, std::move(colorSpace))
|
||||
, fRenderTargetProxy(std::move(rtp))
|
||||
, fOpList(sk_ref_sp(fRenderTargetProxy->getLastRenderTargetOpList()))
|
||||
, fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps))
|
||||
@ -833,7 +832,7 @@ void GrRenderTargetContext::setNeedsStencil(bool multisampled) {
|
||||
// mixed samples.
|
||||
SkASSERT(fRenderTargetProxy->canUseMixedSamples(*this->caps()));
|
||||
numRequiredSamples = this->caps()->internalMultisampleCount(
|
||||
this->colorSpaceInfo().config());
|
||||
this->asSurfaceProxy()->config());
|
||||
}
|
||||
SkASSERT(numRequiredSamples > 0);
|
||||
|
||||
@ -2615,7 +2614,7 @@ void GrRenderTargetContext::addDrawOp(const GrClip& clip, std::unique_ptr<GrDraw
|
||||
|
||||
SkASSERT((!usesStencil && !appliedClip.hasStencilClip()) || (fNumStencilSamples > 0));
|
||||
|
||||
GrClampType clampType = GrPixelConfigClampType(this->colorSpaceInfo().config());
|
||||
GrClampType clampType = GrColorTypeClampType(this->colorSpaceInfo().colorType());
|
||||
// MIXED SAMPLES TODO: If we start using mixed samples for clips we will need to check the clip
|
||||
// here as well.
|
||||
bool hasMixedSampledCoverage = (usesHWAA && this->numSamples() <= 1);
|
||||
|
@ -34,9 +34,8 @@
|
||||
GrSurfaceContext::GrSurfaceContext(GrRecordingContext* context,
|
||||
GrColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
GrPixelConfig config)
|
||||
: fContext(context), fColorSpaceInfo(colorType, alphaType, std::move(colorSpace), config) {}
|
||||
sk_sp<SkColorSpace> colorSpace)
|
||||
: fContext(context), fColorSpaceInfo(colorType, alphaType, std::move(colorSpace)) {}
|
||||
|
||||
GrAuditTrail* GrSurfaceContext::auditTrail() {
|
||||
return fContext->priv().auditTrail();
|
||||
|
@ -99,11 +99,7 @@ public:
|
||||
protected:
|
||||
friend class GrSurfaceContextPriv;
|
||||
|
||||
GrSurfaceContext(GrRecordingContext*,
|
||||
GrColorType,
|
||||
SkAlphaType,
|
||||
sk_sp<SkColorSpace>,
|
||||
GrPixelConfig);
|
||||
GrSurfaceContext(GrRecordingContext*, GrColorType, SkAlphaType, sk_sp<SkColorSpace>);
|
||||
|
||||
GrDrawingManager* drawingManager();
|
||||
const GrDrawingManager* drawingManager() const;
|
||||
|
@ -339,8 +339,7 @@ sk_sp<GrColorSpaceXform> TestColorXform(SkRandom* random) {
|
||||
TestAsFPArgs::TestAsFPArgs(GrProcessorTestData* d)
|
||||
: fViewMatrixStorage(TestMatrix(d->fRandom))
|
||||
, fColorSpaceInfoStorage(skstd::make_unique<GrColorSpaceInfo>(
|
||||
GrColorType::kRGBA_8888, kPremul_SkAlphaType, TestColorSpace(d->fRandom),
|
||||
kRGBA_8888_GrPixelConfig))
|
||||
GrColorType::kRGBA_8888, kPremul_SkAlphaType, TestColorSpace(d->fRandom)))
|
||||
, fArgs(d->context(), &fViewMatrixStorage, kNone_SkFilterQuality,
|
||||
fColorSpaceInfoStorage.get()) {}
|
||||
|
||||
|
@ -21,11 +21,7 @@ GrTextureAdjuster::GrTextureAdjuster(GrRecordingContext* context,
|
||||
SkColorSpace* cs,
|
||||
bool useDecal)
|
||||
: INHERITED(context, original->width(), original->height(),
|
||||
GrColorSpaceInfo(colorType,
|
||||
alphaType,
|
||||
sk_ref_sp(cs),
|
||||
original->config()),
|
||||
useDecal)
|
||||
GrColorSpaceInfo(colorType, alphaType, sk_ref_sp(cs)), useDecal)
|
||||
, fOriginal(std::move(original))
|
||||
, fUniqueID(uniqueID) {}
|
||||
|
||||
|
@ -21,11 +21,7 @@ GrTextureContext::GrTextureContext(GrRecordingContext* context,
|
||||
GrColorType colorType,
|
||||
SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace)
|
||||
: GrSurfaceContext(context,
|
||||
colorType,
|
||||
alphaType,
|
||||
std::move(colorSpace),
|
||||
textureProxy->config())
|
||||
: GrSurfaceContext(context, colorType, alphaType, std::move(colorSpace))
|
||||
, fTextureProxy(std::move(textureProxy))
|
||||
, fOpList(sk_ref_sp(fTextureProxy->getLastTextureOpList())) {
|
||||
SkDEBUGCODE(this->validate();)
|
||||
|
@ -107,7 +107,7 @@ public:
|
||||
GrColorType colorType() const { return fColorSpaceInfo.colorType(); }
|
||||
SkAlphaType alphaType() const { return fColorSpaceInfo.alphaType(); }
|
||||
SkColorSpace* colorSpace() const { return fColorSpaceInfo.colorSpace(); }
|
||||
bool isAlphaOnly() const { return GrPixelConfigIsAlphaOnly(fColorSpaceInfo.config()); }
|
||||
bool isAlphaOnly() const { return GrColorTypeIsAlphaOnly(fColorSpaceInfo.colorType()); }
|
||||
bool domainNeedsDecal() const { return fDomainNeedsDecal; }
|
||||
// If the "texture" samples multiple images that have different resolutions (e.g. YUV420)
|
||||
virtual bool hasMixedResolutions() const { return false; }
|
||||
|
@ -116,10 +116,7 @@ sk_sp<SkGpuDevice> SkGpuDevice::Make(GrContext* context, SkBudgeted budgeted,
|
||||
}
|
||||
|
||||
static SkImageInfo make_info(GrRenderTargetContext* context, int w, int h, bool opaque) {
|
||||
SkColorType colorType;
|
||||
if (!GrPixelConfigToColorType(context->colorSpaceInfo().config(), &colorType)) {
|
||||
colorType = kUnknown_SkColorType;
|
||||
}
|
||||
SkColorType colorType = GrColorTypeToSkColorType(context->colorSpaceInfo().colorType());
|
||||
return SkImageInfo::Make(w, h, colorType, opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType,
|
||||
context->colorSpaceInfo().refColorSpace());
|
||||
}
|
||||
@ -183,9 +180,10 @@ sk_sp<SkSpecialImage> SkGpuDevice::filterTexture(SkSpecialImage* srcImg,
|
||||
matrix.postTranslate(SkIntToScalar(-left), SkIntToScalar(-top));
|
||||
const SkIRect clipBounds = this->devClipBounds().makeOffset(-left, -top);
|
||||
sk_sp<SkImageFilterCache> cache(this->getImageFilterCache());
|
||||
SkColorType colorType;
|
||||
if (!GrPixelConfigToColorType(fRenderTargetContext->colorSpaceInfo().config(), &colorType)) {
|
||||
colorType = kN32_SkColorType;
|
||||
SkColorType colorType =
|
||||
GrColorTypeToSkColorType(fRenderTargetContext->colorSpaceInfo().colorType());
|
||||
if (colorType == kUnknown_SkColorType) {
|
||||
colorType = kRGBA_8888_SkColorType;
|
||||
}
|
||||
SkImageFilter::OutputProperties outputProperties(
|
||||
colorType, fRenderTargetContext->colorSpaceInfo().colorSpace());
|
||||
@ -1666,20 +1664,21 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint
|
||||
SkBackingFit fit = kNever_TileUsage == cinfo.fTileUsage ? SkBackingFit::kApprox
|
||||
: SkBackingFit::kExact;
|
||||
|
||||
GrPixelConfig config = fRenderTargetContext->colorSpaceInfo().config();
|
||||
GrColorType colorType = fRenderTargetContext->colorSpaceInfo().colorType();
|
||||
const GrBackendFormat& origFormat = fRenderTargetContext->asSurfaceProxy()->backendFormat();
|
||||
GrBackendFormat format = origFormat.makeTexture2D();
|
||||
if (!format.isValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (kRGBA_1010102_GrPixelConfig == config) {
|
||||
if (colorType == GrColorType::kRGBA_1010102) {
|
||||
// If the original device is 1010102, fall back to 8888 so that we have a usable alpha
|
||||
// channel in the layer.
|
||||
config = kRGBA_8888_GrPixelConfig;
|
||||
format =
|
||||
fContext->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
|
||||
colorType = GrColorType::kRGBA_8888;
|
||||
format = fContext->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
|
||||
}
|
||||
|
||||
auto config = fContext->priv().caps()->getConfigFromBackendFormat(
|
||||
format, GrColorTypeToSkColorType(colorType));
|
||||
sk_sp<GrRenderTargetContext> rtc(fContext->priv().makeDeferredRenderTargetContext(
|
||||
format,
|
||||
fit,
|
||||
|
@ -285,43 +285,34 @@ static inline bool blend_requires_shader(const SkBlendMode mode) {
|
||||
}
|
||||
|
||||
#ifndef SK_IGNORE_GPU_DITHER
|
||||
static inline int32_t dither_range_type_for_config(GrPixelConfig dstConfig) {
|
||||
switch (dstConfig) {
|
||||
case kGray_8_GrPixelConfig:
|
||||
case kGray_8_as_Lum_GrPixelConfig:
|
||||
case kGray_8_as_Red_GrPixelConfig:
|
||||
case kRGBA_8888_GrPixelConfig:
|
||||
case kRGB_888_GrPixelConfig:
|
||||
case kRGB_888X_GrPixelConfig:
|
||||
case kRG_88_GrPixelConfig:
|
||||
case kBGRA_8888_GrPixelConfig:
|
||||
case kR_16_GrPixelConfig:
|
||||
case kRG_1616_GrPixelConfig:
|
||||
static inline int32_t dither_range_type_for_config(GrColorType dstColorType) {
|
||||
switch (dstColorType) {
|
||||
case GrColorType::kGray_8:
|
||||
case GrColorType::kRGBA_8888:
|
||||
case GrColorType::kRGB_888x:
|
||||
case GrColorType::kRG_88:
|
||||
case GrColorType::kBGRA_8888:
|
||||
case GrColorType::kR_16:
|
||||
case GrColorType::kRG_1616:
|
||||
// Experimental (for Y416 and mutant P016/P010)
|
||||
case kRGBA_16161616_GrPixelConfig:
|
||||
case kRG_half_GrPixelConfig:
|
||||
case GrColorType::kRGBA_16161616:
|
||||
case GrColorType::kRG_F16:
|
||||
return 0;
|
||||
case kRGB_565_GrPixelConfig:
|
||||
case GrColorType::kBGR_565:
|
||||
return 1;
|
||||
case kRGBA_4444_GrPixelConfig:
|
||||
case GrColorType::kABGR_4444:
|
||||
return 2;
|
||||
case kUnknown_GrPixelConfig:
|
||||
case kSRGBA_8888_GrPixelConfig:
|
||||
case kRGBA_1010102_GrPixelConfig:
|
||||
case kAlpha_half_GrPixelConfig:
|
||||
case kAlpha_half_as_Red_GrPixelConfig:
|
||||
case kRGBA_float_GrPixelConfig:
|
||||
case kRG_float_GrPixelConfig:
|
||||
case kRGBA_half_GrPixelConfig:
|
||||
case kRGBA_half_Clamped_GrPixelConfig:
|
||||
case kRGB_ETC1_GrPixelConfig:
|
||||
case kAlpha_8_GrPixelConfig:
|
||||
case kAlpha_8_as_Alpha_GrPixelConfig:
|
||||
case kAlpha_8_as_Red_GrPixelConfig:
|
||||
case GrColorType::kUnknown:
|
||||
case GrColorType::kRGBA_1010102:
|
||||
case GrColorType::kAlpha_F16:
|
||||
case GrColorType::kRGBA_F32:
|
||||
case GrColorType::kRG_F32:
|
||||
case GrColorType::kRGBA_F16:
|
||||
case GrColorType::kRGBA_F16_Clamped:
|
||||
case GrColorType::kAlpha_8:
|
||||
return -1;
|
||||
}
|
||||
SkASSERT(false);
|
||||
return 0;
|
||||
SkUNREACHABLE;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -454,10 +445,10 @@ static inline bool skpaint_to_grpaint_impl(GrRecordingContext* context,
|
||||
|
||||
#ifndef SK_IGNORE_GPU_DITHER
|
||||
// Conservative default, in case GrPixelConfigToColorType() fails.
|
||||
SkColorType ct = SkColorType::kRGB_565_SkColorType;
|
||||
GrPixelConfigToColorType(colorSpaceInfo.config(), &ct);
|
||||
if (SkPaintPriv::ShouldDither(skPaint, ct) && grPaint->numColorFragmentProcessors() > 0) {
|
||||
int32_t ditherRange = dither_range_type_for_config(colorSpaceInfo.config());
|
||||
GrColorType ct = colorSpaceInfo.colorType();
|
||||
if (SkPaintPriv::ShouldDither(skPaint, GrColorTypeToSkColorType(ct)) &&
|
||||
grPaint->numColorFragmentProcessors() > 0) {
|
||||
int32_t ditherRange = dither_range_type_for_config(ct);
|
||||
if (ditherRange >= 0) {
|
||||
static int ditherIndex = GrSkSLFP::NewIndex();
|
||||
auto ditherFP = GrSkSLFP::Make(context, ditherIndex, "Dither", SKSL_DITHER_SRC,
|
||||
|
@ -45,7 +45,7 @@ static std::unique_ptr<GrFragmentProcessor> make_textured_colorizer(const SkPMCo
|
||||
// Use 8888 or F16, depending on the destination config.
|
||||
// TODO: Use 1010102 for opaque gradients, at least if destination is 1010102?
|
||||
SkColorType colorType = kRGBA_8888_SkColorType;
|
||||
if (kLow_GrSLPrecision != GrSLSamplerPrecision(args.fDstColorSpaceInfo->config()) &&
|
||||
if (GrColorTypeIsWiderThan(args.fDstColorSpaceInfo->colorType(), 8) &&
|
||||
args.fContext->priv().caps()->isConfigTexturable(kRGBA_half_GrPixelConfig)) {
|
||||
colorType = kRGBA_F16_SkColorType;
|
||||
}
|
||||
|
@ -88,18 +88,17 @@ bool GrVkSecondaryCBDrawContext::characterize(SkSurfaceCharacterization* charact
|
||||
// We current don't support textured GrVkSecondaryCBDrawContexts.
|
||||
SkASSERT(!rtc->asTextureProxy());
|
||||
|
||||
// TODO: the addition of colorType to the surfaceContext should remove this calculation
|
||||
SkColorType ct;
|
||||
if (!GrPixelConfigToColorType(rtc->colorSpaceInfo().config(), &ct)) {
|
||||
SkColorType ct = GrColorTypeToSkColorType(rtc->colorSpaceInfo().colorType());
|
||||
if (ct == kUnknown_SkColorType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SkImageInfo ii = SkImageInfo::Make(rtc->width(), rtc->height(), ct, kPremul_SkAlphaType,
|
||||
rtc->colorSpaceInfo().refColorSpace());
|
||||
|
||||
characterization->set(ctx->threadSafeProxy(), maxResourceBytes, ii, rtc->origin(),
|
||||
rtc->colorSpaceInfo().config(), rtc->numSamples(),
|
||||
SkSurfaceCharacterization::Textureable(false),
|
||||
GrPixelConfig config = rtc->asSurfaceProxy()->config();
|
||||
characterization->set(ctx->threadSafeProxy(), maxResourceBytes, ii, rtc->origin(), config,
|
||||
rtc->numSamples(), SkSurfaceCharacterization::Textureable(false),
|
||||
SkSurfaceCharacterization::MipMapped(false),
|
||||
SkSurfaceCharacterization::UsesGLFBO0(false),
|
||||
SkSurfaceCharacterization::VulkanSecondaryCBCompatible(true),
|
||||
@ -137,19 +136,19 @@ bool GrVkSecondaryCBDrawContext::isCompatible(
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: the addition of colorType to the surfaceContext should remove this calculation
|
||||
SkColorType rtcColorType;
|
||||
if (!GrPixelConfigToColorType(rtc->colorSpaceInfo().config(), &rtcColorType)) {
|
||||
SkColorType rtColorType = GrColorTypeToSkColorType(rtc->colorSpaceInfo().colorType());
|
||||
if (rtColorType == kUnknown_SkColorType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GrPixelConfig config = rtc->asSurfaceProxy()->config();
|
||||
return characterization.contextInfo() && characterization.contextInfo()->priv().matches(ctx) &&
|
||||
characterization.cacheMaxResourceBytes() <= maxResourceBytes &&
|
||||
characterization.origin() == rtc->origin() &&
|
||||
characterization.config() == rtc->colorSpaceInfo().config() &&
|
||||
characterization.config() == config &&
|
||||
characterization.width() == rtc->width() &&
|
||||
characterization.height() == rtc->height() &&
|
||||
characterization.colorType() == rtcColorType &&
|
||||
characterization.colorType() == rtColorType &&
|
||||
characterization.sampleCount() == rtc->numSamples() &&
|
||||
SkColorSpace::Equals(characterization.colorSpace(),
|
||||
rtc->colorSpaceInfo().colorSpace()) &&
|
||||
|
@ -195,9 +195,8 @@ bool SkSurface_Gpu::onCharacterize(SkSurfaceCharacterization* characterization)
|
||||
bool mipmapped = rtc->asTextureProxy() ? GrMipMapped::kYes == rtc->asTextureProxy()->mipMapped()
|
||||
: false;
|
||||
|
||||
// TODO: the addition of colorType to the surfaceContext should remove this calculation
|
||||
SkColorType ct;
|
||||
if (!GrPixelConfigToColorType(rtc->colorSpaceInfo().config(), &ct)) {
|
||||
SkColorType ct = GrColorTypeToSkColorType(rtc->colorSpaceInfo().colorType());
|
||||
if (ct == kUnknown_SkColorType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -209,13 +208,13 @@ bool SkSurface_Gpu::onCharacterize(SkSurfaceCharacterization* characterization)
|
||||
SkImageInfo ii = SkImageInfo::Make(rtc->width(), rtc->height(), ct, kPremul_SkAlphaType,
|
||||
rtc->colorSpaceInfo().refColorSpace());
|
||||
|
||||
characterization->set(ctx->threadSafeProxy(), maxResourceBytes, ii, rtc->origin(),
|
||||
rtc->colorSpaceInfo().config(), rtc->numSamples(),
|
||||
SkSurfaceCharacterization::Textureable(SkToBool(rtc->asTextureProxy())),
|
||||
SkSurfaceCharacterization::MipMapped(mipmapped),
|
||||
SkSurfaceCharacterization::UsesGLFBO0(usesGLFBO0),
|
||||
SkSurfaceCharacterization::VulkanSecondaryCBCompatible(false),
|
||||
this->props());
|
||||
GrPixelConfig config = rtc->asSurfaceProxy()->config();
|
||||
characterization->set(
|
||||
ctx->threadSafeProxy(), maxResourceBytes, ii, rtc->origin(), config, rtc->numSamples(),
|
||||
SkSurfaceCharacterization::Textureable(SkToBool(rtc->asTextureProxy())),
|
||||
SkSurfaceCharacterization::MipMapped(mipmapped),
|
||||
SkSurfaceCharacterization::UsesGLFBO0(usesGLFBO0),
|
||||
SkSurfaceCharacterization::VulkanSecondaryCBCompatible(false), this->props());
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -295,16 +294,16 @@ bool SkSurface_Gpu::onIsCompatible(const SkSurfaceCharacterization& characteriza
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: the addition of colorType to the surfaceContext should remove this calculation
|
||||
SkColorType rtcColorType;
|
||||
if (!GrPixelConfigToColorType(rtc->colorSpaceInfo().config(), &rtcColorType)) {
|
||||
SkColorType rtcColorType = GrColorTypeToSkColorType(rtc->colorSpaceInfo().colorType());
|
||||
if (rtcColorType == kUnknown_SkColorType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GrPixelConfig config = rtc->asSurfaceProxy()->config();
|
||||
return characterization.contextInfo() && characterization.contextInfo()->priv().matches(ctx) &&
|
||||
characterization.cacheMaxResourceBytes() <= maxResourceBytes &&
|
||||
characterization.origin() == rtc->origin() &&
|
||||
characterization.config() == rtc->colorSpaceInfo().config() &&
|
||||
characterization.config() == config &&
|
||||
characterization.width() == rtc->width() &&
|
||||
characterization.height() == rtc->height() &&
|
||||
characterization.colorType() == rtcColorType &&
|
||||
|
@ -345,8 +345,10 @@ std::unique_ptr<GrFragmentProcessor> SkPictureShader::asFragmentProcessor(
|
||||
}
|
||||
|
||||
auto lm = this->totalLocalMatrix(args.fPreLocalMatrix, args.fPostLocalMatrix);
|
||||
SkColorType dstColorType = kN32_SkColorType;
|
||||
GrPixelConfigToColorType(args.fDstColorSpaceInfo->config(), &dstColorType);
|
||||
SkColorType dstColorType = GrColorTypeToSkColorType(args.fDstColorSpaceInfo->colorType());
|
||||
if (dstColorType == kUnknown_SkColorType) {
|
||||
dstColorType = kRGBA_8888_SkColorType;
|
||||
}
|
||||
sk_sp<SkShader> bitmapShader(this->refBitmapShader(*args.fViewMatrix, &lm, dstColorType,
|
||||
args.fDstColorSpaceInfo->colorSpace(),
|
||||
maxTextureSize));
|
||||
|
@ -693,8 +693,7 @@ static std::unique_ptr<GrFragmentProcessor> create_linear_gradient_processor(GrC
|
||||
SkColor colors[2] = { SK_ColorGREEN, SK_ColorBLUE };
|
||||
sk_sp<SkShader> shader = SkGradientShader::MakeLinear(
|
||||
pts, colors, nullptr, SK_ARRAY_COUNT(colors), SkTileMode::kClamp);
|
||||
GrColorSpaceInfo colorSpaceInfo(GrColorType::kRGBA_8888, kPremul_SkAlphaType, nullptr,
|
||||
kRGBA_8888_GrPixelConfig);
|
||||
GrColorSpaceInfo colorSpaceInfo(GrColorType::kRGBA_8888, kPremul_SkAlphaType, nullptr);
|
||||
GrFPArgs args(ctx, &SkMatrix::I(), SkFilterQuality::kLow_SkFilterQuality, &colorSpaceInfo);
|
||||
return as_SB(shader)->asFragmentProcessor(args);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user