Revert "Make FP optimizations helpers use SkAlphaType not GrColorType"
This reverts commit 7a538b1eeccdbe940de507af9aeaf454952c4aec.
Reason for revert: ios failures
Original change's description:
> Make FP optimizations helpers use SkAlphaType not GrColorType
>
> Change-Id: I3b7cde6e7f68192af5419fb09c7d59e7a803a4d5
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255818
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Greg Daniel <egdaniel@google.com>
TBR=egdaniel@google.com,bsalomon@google.com
Change-Id: Id41daa47fb3ccac434bb9d71a697f32e36c87367
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255835
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/gm/clockwise.cpp b/gm/clockwise.cpp
index 1f16677..6921b9b 100644
--- a/gm/clockwise.cpp
+++ b/gm/clockwise.cpp
@@ -268,8 +268,8 @@
topLeftRTC->priv().testingOnly_addDrawOp(ClockwiseTestOp::Make(ctx, false, 0));
topLeftRTC->priv().testingOnly_addDrawOp(ClockwiseTestOp::Make(ctx, true, 100));
rtc->drawTexture(GrNoClip(), sk_ref_sp(topLeftRTC->asTextureProxy()), rtcColorType,
- rtc->colorInfo().alphaType(), GrSamplerState::Filter::kNearest,
- SkBlendMode::kSrcOver, SK_PMColor4fWHITE, {0, 0, 100, 200},
+ GrSamplerState::Filter::kNearest, SkBlendMode::kSrcOver,
+ SK_PMColor4fWHITE, {0, 0, 100, 200},
{100, 0, 200, 200}, GrAA::kNo, GrQuadAAFlags::kNone,
SkCanvas::SrcRectConstraint::kStrict_SrcRectConstraint, SkMatrix::I(),
nullptr);
@@ -284,8 +284,8 @@
topLeftRTC->priv().testingOnly_addDrawOp(ClockwiseTestOp::Make(ctx, false, 0));
topLeftRTC->priv().testingOnly_addDrawOp(ClockwiseTestOp::Make(ctx, true, 100));
rtc->drawTexture(GrNoClip(), sk_ref_sp(topLeftRTC->asTextureProxy()), rtcColorType,
- rtc->colorInfo().alphaType(), GrSamplerState::Filter::kNearest,
- SkBlendMode::kSrcOver, SK_PMColor4fWHITE, {0, 0, 100, 200},
+ GrSamplerState::Filter::kNearest, SkBlendMode::kSrcOver,
+ SK_PMColor4fWHITE, {0, 0, 100, 200},
{200, 0, 300, 200}, GrAA::kNo, GrQuadAAFlags::kNone,
SkCanvas::SrcRectConstraint::kStrict_SrcRectConstraint, SkMatrix::I(),
nullptr);
diff --git a/gm/fpcoordinateoverride.cpp b/gm/fpcoordinateoverride.cpp
index 36913cc..212fd25 100644
--- a/gm/fpcoordinateoverride.cpp
+++ b/gm/fpcoordinateoverride.cpp
@@ -83,9 +83,10 @@
SkBitmap bmp;
GetResourceAsBitmap("images/mandrill_512_q075.jpg", &bmp);
GrProxyProvider* proxyProvider = ctx->priv().proxyProvider();
+ GrColorType srcColorType = SkColorTypeToGrColorType(bmp.colorType());
sk_sp<GrTextureProxy> texture = proxyProvider->createProxyFromBitmap(bmp, GrMipMapped::kNo);
- std::unique_ptr<GrFragmentProcessor> imgFP =
- GrSimpleTextureEffect::Make(texture, bmp.alphaType(), SkMatrix());
+ std::unique_ptr<GrFragmentProcessor> imgFP = GrSimpleTextureEffect::Make(texture, srcColorType,
+ SkMatrix());
auto fp = std::unique_ptr<GrFragmentProcessor>(new SampleCoordEffect(std::move(imgFP)));
GrPaint grPaint;
diff --git a/gm/image_pict.cpp b/gm/image_pict.cpp
index 023e369..08895f3 100644
--- a/gm/image_pict.cpp
+++ b/gm/image_pict.cpp
@@ -197,8 +197,8 @@
GrMipMapped mipMapped = willBeMipped ? GrMipMapped::kYes : GrMipMapped::kNo;
- return GrSurfaceProxy::Copy(
- fCtx.get(), fProxy.get(), mipMapped,
+ return GrSurfaceProxy::Copy(fCtx.get(), fProxy.get(),
+ SkColorTypeToGrColorType(info.colorType()), mipMapped,
SkIRect::MakeXYWH(origin.x(), origin.y(), info.width(), info.height()),
SkBackingFit::kExact, SkBudgeted::kYes);
}
diff --git a/gm/samplelocations.cpp b/gm/samplelocations.cpp
index b32d879..7c4bff9 100644
--- a/gm/samplelocations.cpp
+++ b/gm/samplelocations.cpp
@@ -375,12 +375,12 @@
SkMatrix::I(), SkRect::MakeWH(200, 200));
// Copy offscreen texture to canvas.
- rtc->drawTexture(GrNoClip(), sk_ref_sp(offscreenRTC->asTextureProxy()),
- offscreenRTC->colorInfo().colorType(), offscreenRTC->colorInfo().alphaType(),
- GrSamplerState::Filter::kNearest, SkBlendMode::kSrc, SK_PMColor4fWHITE,
- {0,0,200,200}, {0,0,200,200}, GrAA::kNo, GrQuadAAFlags::kNone,
- SkCanvas::SrcRectConstraint::kStrict_SrcRectConstraint, SkMatrix::I(),
- nullptr);
+ rtc->drawTexture(
+ GrNoClip(), sk_ref_sp(offscreenRTC->asTextureProxy()),
+ offscreenRTC->colorInfo().colorType(), GrSamplerState::Filter::kNearest,
+ SkBlendMode::kSrc, SK_PMColor4fWHITE, {0,0,200,200}, {0,0,200,200}, GrAA::kNo,
+ GrQuadAAFlags::kNone, SkCanvas::SrcRectConstraint::kStrict_SrcRectConstraint,
+ SkMatrix::I(), nullptr);
return skiagm::DrawResult::kOk;
}
diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp
index 72300c4..5355e2e 100644
--- a/gm/texturedomaineffect.cpp
+++ b/gm/texturedomaineffect.cpp
@@ -142,8 +142,10 @@
GrPaint grPaint;
grPaint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));
auto fp = GrTextureDomainEffect::Make(
- proxy, fBitmap.alphaType(), textureMatrices[tm],
- GrTextureDomain::MakeTexelDomain(texelDomains[d], mode), mode, fFilter);
+ proxy, SkColorTypeToGrColorType(fBitmap.colorType()),
+ textureMatrices[tm],
+ GrTextureDomain::MakeTexelDomain(texelDomains[d], mode),
+ mode, fFilter);
if (!fp) {
continue;
diff --git a/samplecode/SampleCCPRGeometry.cpp b/samplecode/SampleCCPRGeometry.cpp
index e8c6f2e..2f70ff2 100644
--- a/samplecode/SampleCCPRGeometry.cpp
+++ b/samplecode/SampleCCPRGeometry.cpp
@@ -196,7 +196,7 @@
GrPaint paint;
paint.addColorFragmentProcessor(
GrSimpleTextureEffect::Make(sk_ref_sp(ccbuff->asTextureProxy()),
- ccbuff->colorInfo().alphaType(), SkMatrix::I()));
+ ccbuff->colorInfo().colorType(), SkMatrix::I()));
paint.addColorFragmentProcessor(
skstd::make_unique<VisualizeCoverageCountFP>());
paint.setPorterDuffXPFactory(SkBlendMode::kSrcOver);
diff --git a/src/core/SkBlurMF.cpp b/src/core/SkBlurMF.cpp
index 9a4b8e2..d385af8 100644
--- a/src/core/SkBlurMF.cpp
+++ b/src/core/SkBlurMF.cpp
@@ -901,8 +901,9 @@
if (!isNormalBlur) {
GrPaint paint;
// Blend pathTexture over blurTexture.
- paint.addCoverageFragmentProcessor(
- GrSimpleTextureEffect::Make(std::move(srcProxy), srcAlphaType, SkMatrix::I()));
+ paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(std::move(srcProxy),
+ srcColorType,
+ SkMatrix::I()));
if (kInner_SkBlurStyle == fBlurStyle) {
// inner: dst = dst * src
paint.setCoverageSetOpXPFactory(SkRegion::kIntersect_Op);
diff --git a/src/core/SkGpuBlurUtils.cpp b/src/core/SkGpuBlurUtils.cpp
index c5ee947..c863908 100644
--- a/src/core/SkGpuBlurUtils.cpp
+++ b/src/core/SkGpuBlurUtils.cpp
@@ -76,7 +76,7 @@
const SkIRect& dstRect,
const SkIPoint& srcOffset,
sk_sp<GrTextureProxy> proxy,
- SkAlphaType srcAlphaType,
+ GrColorType srcColorType,
Direction direction,
int radius,
float sigma,
@@ -84,7 +84,7 @@
int bounds[2]) {
GrPaint paint;
std::unique_ptr<GrFragmentProcessor> conv(GrGaussianConvolutionFragmentProcessor::Make(
- std::move(proxy), srcAlphaType, direction, radius, sigma, mode, bounds));
+ std::move(proxy), srcColorType, direction, radius, sigma, mode, bounds));
paint.addColorFragmentProcessor(std::move(conv));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
SkMatrix localMatrix = SkMatrix::MakeTrans(-SkIntToScalar(srcOffset.x()),
@@ -152,7 +152,6 @@
static std::unique_ptr<GrRenderTargetContext> convolve_gaussian(GrRecordingContext* context,
sk_sp<GrTextureProxy> srcProxy,
GrColorType srcColorType,
- SkAlphaType srcAlphaType,
const SkIPoint& proxyOffset,
const SkIRect& srcRect,
const SkIPoint& srcOffset,
@@ -191,7 +190,7 @@
if (GrTextureDomain::kIgnore_Mode == mode) {
*contentRect = dstRect;
convolve_gaussian_1d(dstRenderTargetContext.get(), clip, dstRect, netOffset,
- std::move(srcProxy), srcAlphaType, direction, radius, sigma,
+ std::move(srcProxy), srcColorType, direction, radius, sigma,
GrTextureDomain::kIgnore_Mode, bounds);
return dstRenderTargetContext;
}
@@ -246,16 +245,16 @@
if (midRect.isEmpty()) {
// Blur radius covers srcBounds; use bounds over entire draw
convolve_gaussian_1d(dstRenderTargetContext.get(), clip, dstRect, netOffset,
- std::move(srcProxy), srcAlphaType, direction, radius, sigma, mode,
+ std::move(srcProxy), srcColorType, direction, radius, sigma, mode,
bounds);
} else {
// Draw right and left margins with bounds; middle without.
- convolve_gaussian_1d(dstRenderTargetContext.get(), clip, leftRect, netOffset, srcProxy,
- srcAlphaType, direction, radius, sigma, mode, bounds);
- convolve_gaussian_1d(dstRenderTargetContext.get(), clip, rightRect, netOffset, srcProxy,
- srcAlphaType, direction, radius, sigma, mode, bounds);
+ convolve_gaussian_1d(dstRenderTargetContext.get(), clip, leftRect, netOffset,
+ srcProxy, srcColorType, direction, radius, sigma, mode, bounds);
+ convolve_gaussian_1d(dstRenderTargetContext.get(), clip, rightRect, netOffset,
+ srcProxy, srcColorType, direction, radius, sigma, mode, bounds);
convolve_gaussian_1d(dstRenderTargetContext.get(), clip, midRect, netOffset,
- std::move(srcProxy), srcAlphaType, direction, radius, sigma,
+ std::move(srcProxy), srcColorType, direction, radius, sigma,
GrTextureDomain::kIgnore_Mode, bounds);
}
@@ -268,7 +267,6 @@
static sk_sp<GrTextureProxy> decimate(GrRecordingContext* context,
sk_sp<GrTextureProxy> srcProxy,
GrColorType srcColorType,
- SkAlphaType srcAlphaType,
const SkIPoint& proxyOffset,
SkIPoint* srcOffset,
SkIRect* contentRect,
@@ -338,7 +336,7 @@
}
domain.offset(proxyOffset.x(), proxyOffset.y());
auto fp = GrTextureDomainEffect::Make(std::move(srcProxy),
- srcAlphaType,
+ srcColorType,
SkMatrix::I(),
domain,
modeForScaling,
@@ -349,7 +347,7 @@
// back in GaussianBlur
srcOffset->set(0, 0);
} else {
- paint.addColorTextureProcessor(std::move(srcProxy), srcAlphaType, SkMatrix::I(),
+ paint.addColorTextureProcessor(std::move(srcProxy), srcColorType, SkMatrix::I(),
GrSamplerState::ClampBilerp());
}
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
@@ -393,7 +391,6 @@
}
GrColorType srcColorType = srcRenderTargetContext->colorInfo().colorType();
- SkAlphaType srcAlphaType = srcRenderTargetContext->colorInfo().alphaType();
srcRenderTargetContext = nullptr; // no longer needed
@@ -407,7 +404,7 @@
GrPaint paint;
SkRect domain = GrTextureDomain::MakeTexelDomain(localSrcBounds, GrTextureDomain::kClamp_Mode,
GrTextureDomain::kClamp_Mode);
- auto fp = GrTextureDomainEffect::Make(std::move(srcProxy), srcAlphaType, SkMatrix::I(), domain,
+ auto fp = GrTextureDomainEffect::Make(std::move(srcProxy), srcColorType, SkMatrix::I(), domain,
GrTextureDomain::kClamp_Mode,
GrSamplerState::Filter::kBilerp);
paint.addColorFragmentProcessor(std::move(fp));
@@ -429,7 +426,7 @@
std::unique_ptr<GrRenderTargetContext> GaussianBlur(GrRecordingContext* context,
sk_sp<GrTextureProxy> srcProxy,
GrColorType srcColorType,
- SkAlphaType srcAlphaType,
+ SkAlphaType srcAT,
const SkIPoint& proxyOffset,
sk_sp<SkColorSpace> colorSpace,
const SkIRect& dstBounds,
@@ -480,10 +477,9 @@
GrTextureDomain::Mode currDomainMode = mode;
if (scaleFactorX > 1 || scaleFactorY > 1) {
- srcProxy =
- decimate(context, std::move(srcProxy), srcColorType, srcAlphaType, localProxyOffset,
- &srcOffset, &localSrcBounds, scaleFactorX, scaleFactorY, radiusX, radiusY,
- currDomainMode, finalW, finalH, colorSpace);
+ srcProxy = decimate(context, std::move(srcProxy), srcColorType, localProxyOffset,
+ &srcOffset, &localSrcBounds, scaleFactorX, scaleFactorY, radiusX,
+ radiusY, currDomainMode, finalW, finalH, colorSpace);
if (!srcProxy) {
return nullptr;
}
@@ -501,9 +497,9 @@
scale_irect_roundout(&srcRect, 1.0f / scaleFactorX, 1.0f / scaleFactorY);
if (sigmaX > 0.0f) {
dstRenderTargetContext = convolve_gaussian(
- context, std::move(srcProxy), srcColorType, srcAlphaType, localProxyOffset, srcRect,
- srcOffset, Direction::kX, radiusX, sigmaX, &localSrcBounds, currDomainMode, finalW,
- finalH, colorSpace, xFit);
+ context, std::move(srcProxy), srcColorType, localProxyOffset, srcRect, srcOffset,
+ Direction::kX, radiusX, sigmaX, &localSrcBounds, currDomainMode, finalW, finalH,
+ colorSpace, xFit);
if (!dstRenderTargetContext) {
return nullptr;
}
@@ -525,9 +521,9 @@
if (sigmaY > 0.0f) {
dstRenderTargetContext = convolve_gaussian(
- context, std::move(srcProxy), srcColorType, srcAlphaType, localProxyOffset, srcRect,
- srcOffset, Direction::kY, radiusY, sigmaY, &localSrcBounds, currDomainMode, finalW,
- finalH, colorSpace, yFit);
+ context, std::move(srcProxy), srcColorType, localProxyOffset, srcRect, srcOffset,
+ Direction::kY, radiusY, sigmaY, &localSrcBounds, currDomainMode, finalW, finalH,
+ colorSpace, yFit);
if (!dstRenderTargetContext) {
return nullptr;
}
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index 7c3419a..b0bface 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -499,8 +499,9 @@
}
sk_sp<GrTextureProxy> subsetProxy(
- GrSurfaceProxy::Copy(fContext, fTextureProxy.get(), GrMipMapped::kNo, *subset,
- SkBackingFit::kExact, SkBudgeted::kYes));
+ GrSurfaceProxy::Copy(fContext, fTextureProxy.get(), fColorType,
+ GrMipMapped::kNo, *subset, SkBackingFit::kExact,
+ SkBudgeted::kYes));
if (!subsetProxy) {
return nullptr;
}
diff --git a/src/effects/imagefilters/SkAlphaThresholdFilter.cpp b/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
index c097347..a059b65 100644
--- a/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
+++ b/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
@@ -166,9 +166,10 @@
return nullptr;
}
- auto textureFP = GrSimpleTextureEffect::Make(
- std::move(inputProxy), input->alphaType(),
- SkMatrix::MakeTrans(input->subset().x(), input->subset().y()));
+ GrColorType srcColorType = SkColorTypeToGrColorType(input->colorType());
+ auto textureFP = GrSimpleTextureEffect::Make(std::move(inputProxy), srcColorType,
+ SkMatrix::MakeTrans(input->subset().x(),
+ input->subset().y()));
textureFP = GrColorSpaceXformEffect::Make(std::move(textureFP), input->getColorSpace(),
input->alphaType(), ctx.colorSpace());
if (!textureFP) {
diff --git a/src/effects/imagefilters/SkArithmeticImageFilter.cpp b/src/effects/imagefilters/SkArithmeticImageFilter.cpp
index a4306bd..2b1aaaf 100644
--- a/src/effects/imagefilters/SkArithmeticImageFilter.cpp
+++ b/src/effects/imagefilters/SkArithmeticImageFilter.cpp
@@ -353,8 +353,9 @@
SkMatrix backgroundMatrix = SkMatrix::MakeTrans(
SkIntToScalar(bgSubset.left() - backgroundOffset.fX),
SkIntToScalar(bgSubset.top() - backgroundOffset.fY));
+ GrColorType bgColorType = SkColorTypeToGrColorType(background->colorType());
bgFP = GrTextureDomainEffect::Make(
- std::move(backgroundProxy), background->alphaType(), backgroundMatrix,
+ std::move(backgroundProxy), bgColorType, backgroundMatrix,
GrTextureDomain::MakeTexelDomain(bgSubset, GrTextureDomain::kDecal_Mode),
GrTextureDomain::kDecal_Mode, GrSamplerState::Filter::kNearest);
bgFP = GrColorSpaceXformEffect::Make(std::move(bgFP), background->getColorSpace(),
@@ -370,8 +371,9 @@
SkMatrix foregroundMatrix = SkMatrix::MakeTrans(
SkIntToScalar(fgSubset.left() - foregroundOffset.fX),
SkIntToScalar(fgSubset.top() - foregroundOffset.fY));
+ GrColorType fgColorType = SkColorTypeToGrColorType(foreground->colorType());
auto foregroundFP = GrTextureDomainEffect::Make(
- std::move(foregroundProxy), foreground->alphaType(), foregroundMatrix,
+ std::move(foregroundProxy), fgColorType, foregroundMatrix,
GrTextureDomain::MakeTexelDomain(fgSubset, GrTextureDomain::kDecal_Mode),
GrTextureDomain::kDecal_Mode, GrSamplerState::Filter::kNearest);
foregroundFP = GrColorSpaceXformEffect::Make(std::move(foregroundFP),
diff --git a/src/effects/imagefilters/SkMorphologyImageFilter.cpp b/src/effects/imagefilters/SkMorphologyImageFilter.cpp
index db9062a..eb834a3 100644
--- a/src/effects/imagefilters/SkMorphologyImageFilter.cpp
+++ b/src/effects/imagefilters/SkMorphologyImageFilter.cpp
@@ -210,18 +210,20 @@
class GrMorphologyEffect : public GrFragmentProcessor {
public:
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- SkAlphaType srcAlphaType, MorphDirection dir,
+ GrColorType srcColorType,
+ MorphDirection dir,
int radius, MorphType type) {
return std::unique_ptr<GrFragmentProcessor>(
- new GrMorphologyEffect(std::move(proxy), srcAlphaType, dir, radius, type, nullptr));
+ new GrMorphologyEffect(std::move(proxy), srcColorType, dir, radius, type, nullptr));
}
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- SkAlphaType srcAlphaType, MorphDirection dir,
+ GrColorType srcColorType,
+ MorphDirection dir,
int radius, MorphType type,
const float bounds[2]) {
return std::unique_ptr<GrFragmentProcessor>(
- new GrMorphologyEffect(std::move(proxy), srcAlphaType, dir, radius, type, bounds));
+ new GrMorphologyEffect(std::move(proxy), srcColorType, dir, radius, type, bounds));
}
MorphType type() const { return fType; }
@@ -254,7 +256,7 @@
const TextureSampler& onTextureSampler(int i) const override { return fTextureSampler; }
- GrMorphologyEffect(sk_sp<GrTextureProxy>, SkAlphaType srcAlphaType, MorphDirection, int radius,
+ GrMorphologyEffect(sk_sp<GrTextureProxy>, GrColorType srcColorType, MorphDirection, int radius,
MorphType, const float range[2]);
explicit GrMorphologyEffect(const GrMorphologyEffect&);
@@ -393,12 +395,13 @@
///////////////////////////////////////////////////////////////////////////////
GrMorphologyEffect::GrMorphologyEffect(sk_sp<GrTextureProxy> proxy,
- SkAlphaType srcAlphaType,
+ GrColorType srcColorType,
MorphDirection direction,
int radius,
MorphType type,
const float range[2])
- : INHERITED(kGrMorphologyEffect_ClassID, ModulateForClampedSamplerOptFlags(srcAlphaType))
+ : INHERITED(kGrMorphologyEffect_ClassID,
+ ModulateForClampedSamplerOptFlags(srcColorType))
, fCoordTransform(proxy.get())
, fTextureSampler(std::move(proxy))
, fDirection(direction)
@@ -462,15 +465,16 @@
static const int kMaxRadius = 10;
int radius = d->fRandom->nextRangeU(1, kMaxRadius);
MorphType type = d->fRandom->nextBool() ? MorphType::kErode : MorphType::kDilate;
- auto alphaType = static_cast<SkAlphaType>(d->fRandom->nextULessThan(kLastEnum_SkAlphaType + 1));
- return GrMorphologyEffect::Make(std::move(proxy), alphaType, dir, radius, type);
+
+ return GrMorphologyEffect::Make(std::move(proxy), d->textureProxyColorType(texIdx), dir, radius,
+ type);
}
#endif
static void apply_morphology_rect(GrRenderTargetContext* renderTargetContext,
const GrClip& clip,
sk_sp<GrTextureProxy> proxy,
- SkAlphaType srcAlphaType,
+ GrColorType srcColorType,
const SkIRect& srcRect,
const SkIRect& dstRect,
int radius,
@@ -478,8 +482,9 @@
const float bounds[2],
MorphDirection direction) {
GrPaint paint;
- paint.addColorFragmentProcessor(GrMorphologyEffect::Make(std::move(proxy), srcAlphaType,
- direction, radius, morphType, bounds));
+ paint.addColorFragmentProcessor(GrMorphologyEffect::Make(std::move(proxy), srcColorType,
+ direction, radius, morphType,
+ bounds));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
renderTargetContext->fillRectToRect(clip, std::move(paint), GrAA::kNo, SkMatrix::I(),
SkRect::Make(dstRect), SkRect::Make(srcRect));
@@ -488,15 +493,15 @@
static void apply_morphology_rect_no_bounds(GrRenderTargetContext* renderTargetContext,
const GrClip& clip,
sk_sp<GrTextureProxy> proxy,
- SkAlphaType srcAlphaType,
+ GrColorType srcColorType,
const SkIRect& srcRect,
const SkIRect& dstRect,
int radius,
MorphType morphType,
MorphDirection direction) {
GrPaint paint;
- paint.addColorFragmentProcessor(
- GrMorphologyEffect::Make(std::move(proxy), srcAlphaType, direction, radius, morphType));
+ paint.addColorFragmentProcessor(GrMorphologyEffect::Make(std::move(proxy), srcColorType,
+ direction, radius, morphType));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
renderTargetContext->fillRectToRect(clip, std::move(paint), GrAA::kNo, SkMatrix::I(),
SkRect::Make(dstRect), SkRect::Make(srcRect));
@@ -505,7 +510,7 @@
static void apply_morphology_pass(GrRenderTargetContext* renderTargetContext,
const GrClip& clip,
sk_sp<GrTextureProxy> textureProxy,
- SkAlphaType srcAlphaType,
+ GrColorType srcColorType,
const SkIRect& srcRect,
const SkIRect& dstRect,
int radius,
@@ -536,16 +541,16 @@
}
if (middleSrcRect.width() <= 0) {
// radius covers srcRect; use bounds over entire draw
- apply_morphology_rect(renderTargetContext, clip, std::move(textureProxy), srcAlphaType,
+ apply_morphology_rect(renderTargetContext, clip, std::move(textureProxy), srcColorType,
srcRect, dstRect, radius, morphType, bounds, direction);
} else {
// Draw upper and lower margins with bounds; middle without.
- apply_morphology_rect(renderTargetContext, clip, textureProxy, srcAlphaType, lowerSrcRect,
- lowerDstRect, radius, morphType, bounds, direction);
- apply_morphology_rect(renderTargetContext, clip, textureProxy, srcAlphaType, upperSrcRect,
- upperDstRect, radius, morphType, bounds, direction);
+ apply_morphology_rect(renderTargetContext, clip, textureProxy, srcColorType,
+ lowerSrcRect, lowerDstRect, radius, morphType, bounds, direction);
+ apply_morphology_rect(renderTargetContext, clip, textureProxy, srcColorType,
+ upperSrcRect, upperDstRect, radius, morphType, bounds, direction);
apply_morphology_rect_no_bounds(renderTargetContext, clip, std::move(textureProxy),
- srcAlphaType, middleSrcRect, middleDstRect, radius,
+ srcColorType, middleSrcRect, middleDstRect, radius,
morphType, direction);
}
}
@@ -554,7 +559,7 @@
GrRecordingContext* context, SkSpecialImage* input, const SkIRect& rect,
MorphType morphType, SkISize radius, const SkImageFilter_Base::Context& ctx) {
sk_sp<GrTextureProxy> srcTexture(input->asTextureProxyRef(context));
- SkAlphaType srcAlphaType = input->alphaType();
+ GrColorType srcColorType = SkColorTypeToGrColorType(input->colorType());
SkASSERT(srcTexture);
sk_sp<SkColorSpace> colorSpace = ctx.refColorSpace();
GrColorType colorType = ctx.grColorType();
@@ -585,7 +590,7 @@
return nullptr;
}
- apply_morphology_pass(dstRTContext.get(), clip, std::move(srcTexture), srcAlphaType,
+ apply_morphology_pass(dstRTContext.get(), clip, std::move(srcTexture), srcColorType,
srcRect, dstRect, radius.fWidth, morphType, MorphDirection::kX);
SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom,
dstRect.width(), radius.fHeight);
@@ -594,7 +599,7 @@
dstRTContext->clear(&clearRect, clearColor, GrRenderTargetContext::CanClearFullscreen::kNo);
srcTexture = dstRTContext->asTextureProxyRef();
- srcAlphaType = dstRTContext->colorInfo().alphaType();
+ srcColorType = colorType;
srcRect = dstRect;
}
if (radius.fHeight > 0) {
@@ -614,7 +619,7 @@
return nullptr;
}
- apply_morphology_pass(dstRTContext.get(), clip, std::move(srcTexture), srcAlphaType,
+ apply_morphology_pass(dstRTContext.get(), clip, std::move(srcTexture), srcColorType,
srcRect, dstRect, radius.fHeight, morphType, MorphDirection::kY);
srcTexture = dstRTContext->asTextureProxyRef();
diff --git a/src/effects/imagefilters/SkXfermodeImageFilter.cpp b/src/effects/imagefilters/SkXfermodeImageFilter.cpp
index df4847e..14cf52f 100644
--- a/src/effects/imagefilters/SkXfermodeImageFilter.cpp
+++ b/src/effects/imagefilters/SkXfermodeImageFilter.cpp
@@ -266,10 +266,11 @@
SkMatrix bgMatrix = SkMatrix::MakeTrans(
SkIntToScalar(bgSubset.left() - backgroundOffset.fX),
SkIntToScalar(bgSubset.top() - backgroundOffset.fY));
+ GrColorType bgColorType = SkColorTypeToGrColorType(background->colorType());
bgFP = GrTextureDomainEffect::Make(
- std::move(backgroundProxy), background->alphaType(), bgMatrix,
- GrTextureDomain::MakeTexelDomain(bgSubset, GrTextureDomain::kDecal_Mode),
- GrTextureDomain::kDecal_Mode, GrSamplerState::Filter::kNearest);
+ std::move(backgroundProxy), bgColorType, bgMatrix,
+ GrTextureDomain::MakeTexelDomain(bgSubset, GrTextureDomain::kDecal_Mode),
+ GrTextureDomain::kDecal_Mode, GrSamplerState::Filter::kNearest);
bgFP = GrColorSpaceXformEffect::Make(std::move(bgFP), background->getColorSpace(),
background->alphaType(),
ctx.colorSpace());
@@ -283,8 +284,9 @@
SkMatrix fgMatrix = SkMatrix::MakeTrans(
SkIntToScalar(fgSubset.left() - foregroundOffset.fX),
SkIntToScalar(fgSubset.top() - foregroundOffset.fY));
+ GrColorType fgColorType = SkColorTypeToGrColorType(foreground->colorType());
auto foregroundFP = GrTextureDomainEffect::Make(
- std::move(foregroundProxy), foreground->alphaType(), fgMatrix,
+ std::move(foregroundProxy), fgColorType, fgMatrix,
GrTextureDomain::MakeTexelDomain(fgSubset, GrTextureDomain::kDecal_Mode),
GrTextureDomain::kDecal_Mode, GrSamplerState::Filter::kNearest);
foregroundFP = GrColorSpaceXformEffect::Make(std::move(foregroundFP),
diff --git a/src/gpu/GrAHardwareBufferImageGenerator.cpp b/src/gpu/GrAHardwareBufferImageGenerator.cpp
index dd97f03..34b9c07 100644
--- a/src/gpu/GrAHardwareBufferImageGenerator.cpp
+++ b/src/gpu/GrAHardwareBufferImageGenerator.cpp
@@ -214,8 +214,9 @@
GrMipMapped mipMapped = willNeedMipMaps ? GrMipMapped::kYes : GrMipMapped::kNo;
- return GrSurfaceProxy::Copy(context, texProxy.get(), mipMapped, subset, SkBackingFit::kExact,
- SkBudgeted::kYes);
+ GrColorType grColorType = SkColorTypeToGrColorType(this->getInfo().colorType());
+ return GrSurfaceProxy::Copy(context, texProxy.get(), grColorType, mipMapped, subset,
+ SkBackingFit::kExact, SkBudgeted::kYes);
}
bool GrAHardwareBufferImageGenerator::onIsValid(GrContext* context) const {
diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp
index 5ab6e6c..33b26e4 100644
--- a/src/gpu/GrBackendTextureImageGenerator.cpp
+++ b/src/gpu/GrBackendTextureImageGenerator.cpp
@@ -221,7 +221,7 @@
GrMipMapped mipMapped = willNeedMipMaps ? GrMipMapped::kYes : GrMipMapped::kNo;
SkIRect subset = SkIRect::MakeXYWH(origin.fX, origin.fY, info.width(), info.height());
- return GrSurfaceProxy::Copy(context, proxy.get(), mipMapped, subset, SkBackingFit::kExact,
- SkBudgeted::kYes);
+ return GrSurfaceProxy::Copy(context, proxy.get(), grColorType, mipMapped, subset,
+ SkBackingFit::kExact, SkBudgeted::kYes);
}
}
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index e3f9260..eae8224 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -38,7 +38,8 @@
const SkMatrix& viewMatrix,
const SkIRect& maskRect,
GrPaint&& paint,
- sk_sp<GrTextureProxy> mask) {
+ sk_sp<GrTextureProxy> mask,
+ GrColorType maskColorType) {
SkMatrix inverse;
if (!viewMatrix.invert(&inverse)) {
return false;
@@ -47,8 +48,8 @@
SkMatrix matrix = SkMatrix::MakeTrans(-SkIntToScalar(maskRect.fLeft),
-SkIntToScalar(maskRect.fTop));
matrix.preConcat(viewMatrix);
- paint.addCoverageFragmentProcessor(
- GrSimpleTextureEffect::Make(std::move(mask), kUnknown_SkAlphaType, matrix));
+ paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(std::move(mask), maskColorType,
+ matrix));
renderTargetContext->fillRectWithLocalMatrix(clip, std::move(paint), GrAA::kNo, SkMatrix::I(),
SkRect::Make(maskRect), inverse);
@@ -165,8 +166,8 @@
}
}
- return draw_mask(renderTargetContext, clipData, viewMatrix, drawRect, std::move(paint),
- std::move(filteredMask));
+ return draw_mask(renderTargetContext, clipData, viewMatrix, drawRect,
+ std::move(paint), std::move(filteredMask), GrColorType::kAlpha_8);
}
// Create a mask of 'shape' and return the resulting renderTargetContext
@@ -425,8 +426,9 @@
}
if (filteredMask) {
- if (draw_mask(renderTargetContext, clip, viewMatrix, maskRect, std::move(paint),
- std::move(filteredMask))) {
+ if (draw_mask(renderTargetContext, clip, viewMatrix,
+ maskRect, std::move(paint), std::move(filteredMask),
+ GrColorType::kAlpha_8)) {
// This path is completely drawn
return;
}
diff --git a/src/gpu/GrFragmentProcessor.h b/src/gpu/GrFragmentProcessor.h
index 275d471..21e27b8 100644
--- a/src/gpu/GrFragmentProcessor.h
+++ b/src/gpu/GrFragmentProcessor.h
@@ -282,17 +282,17 @@
* callers must determine on their own if the sampling uses a decal strategy in any way, in
* which case the texture may become transparent regardless of the color type.
*/
- static OptimizationFlags ModulateForSamplerOptFlags(SkAlphaType alphaType, bool samplingDecal) {
+ static OptimizationFlags ModulateForSamplerOptFlags(GrColorType colorType, bool samplingDecal) {
if (samplingDecal) {
return kCompatibleWithCoverageAsAlpha_OptimizationFlag;
} else {
- return ModulateForClampedSamplerOptFlags(alphaType);
+ return ModulateForClampedSamplerOptFlags(colorType);
}
}
// As above, but callers should somehow ensure or assert their sampler still uses clamping
- static OptimizationFlags ModulateForClampedSamplerOptFlags(SkAlphaType alphaType) {
- if (alphaType == kOpaque_SkAlphaType) {
+ static OptimizationFlags ModulateForClampedSamplerOptFlags(GrColorType colorType) {
+ if (!GrColorTypeHasAlpha(colorType)) {
return kCompatibleWithCoverageAsAlpha_OptimizationFlag |
kPreservesOpaqueInput_OptimizationFlag;
} else {
diff --git a/src/gpu/GrPaint.cpp b/src/gpu/GrPaint.cpp
index cb8d479..bc7f538 100644
--- a/src/gpu/GrPaint.cpp
+++ b/src/gpu/GrPaint.cpp
@@ -35,10 +35,16 @@
this->setXPFactory(GrCoverageSetOpXPFactory::Get(regionOp, invertCoverage));
}
-void GrPaint::addColorTextureProcessor(sk_sp<GrTextureProxy> proxy, SkAlphaType alphaType,
+void GrPaint::addColorTextureProcessor(sk_sp<GrTextureProxy> proxy, GrColorType srcColorType,
+ const SkMatrix& matrix) {
+ this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(std::move(proxy), srcColorType,
+ matrix));
+}
+
+void GrPaint::addColorTextureProcessor(sk_sp<GrTextureProxy> proxy, GrColorType srcColorType,
const SkMatrix& matrix, const GrSamplerState& samplerState) {
- this->addColorFragmentProcessor(
- GrSimpleTextureEffect::Make(std::move(proxy), alphaType, matrix, samplerState));
+ this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(std::move(proxy), srcColorType,
+ matrix, samplerState));
}
bool GrPaint::isConstantBlendedColor(SkPMColor4f* constantColor) const {
diff --git a/src/gpu/GrPaint.h b/src/gpu/GrPaint.h
index a13dc82..c2520b0 100644
--- a/src/gpu/GrPaint.h
+++ b/src/gpu/GrPaint.h
@@ -81,8 +81,9 @@
* Helpers for adding color or coverage effects that sample a texture. The matrix is applied
* to the src space position to compute texture coordinates.
*/
- void addColorTextureProcessor(sk_sp<GrTextureProxy>, SkAlphaType, const SkMatrix&,
- const GrSamplerState& = GrSamplerState::ClampBilerp());
+ void addColorTextureProcessor(sk_sp<GrTextureProxy>, GrColorType srcColorType, const SkMatrix&);
+ void addColorTextureProcessor(sk_sp<GrTextureProxy>, GrColorType srcColorType, const SkMatrix&,
+ const GrSamplerState&);
int numColorFragmentProcessors() const { return fColorFragmentProcessors.count(); }
int numCoverageFragmentProcessors() const { return fCoverageFragmentProcessors.count(); }
diff --git a/src/gpu/GrProcessorUnitTest.h b/src/gpu/GrProcessorUnitTest.h
index d10f5c1..56afcc5 100644
--- a/src/gpu/GrProcessorUnitTest.h
+++ b/src/gpu/GrProcessorUnitTest.h
@@ -52,11 +52,16 @@
GrProcessorTestData(SkRandom* random,
GrContext* context,
const GrRenderTargetContext* renderTargetContext,
- sk_sp<GrTextureProxy> proxies[2])
- : fRandom(random), fRenderTargetContext(renderTargetContext), fContext(context) {
+ sk_sp<GrTextureProxy> proxies[2],
+ GrColorType proxyColorTypes[2])
+ : fRandom(random)
+ , fRenderTargetContext(renderTargetContext)
+ , fContext(context) {
SkASSERT(proxies[0] && proxies[1]);
fProxies[0] = proxies[0];
fProxies[1] = proxies[1];
+ fProxyColorTypes[0] = proxyColorTypes[0];
+ fProxyColorTypes[1] = proxyColorTypes[1];
fArena = std::unique_ptr<SkArenaAlloc>(new SkArenaAlloc(1000));
}
@@ -69,11 +74,13 @@
GrProxyProvider* proxyProvider();
const GrCaps* caps();
sk_sp<GrTextureProxy> textureProxy(int index) { return fProxies[index]; }
+ GrColorType textureProxyColorType(int index) { return fProxyColorTypes[index]; }
SkArenaAlloc* allocator() { return fArena.get(); }
private:
GrContext* fContext;
sk_sp<GrTextureProxy> fProxies[2];
+ GrColorType fProxyColorTypes[2];
std::unique_ptr<SkArenaAlloc> fArena;
};
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index 2265f04..244b39b 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -611,7 +611,7 @@
void GrRenderTargetContext::drawTexturedQuad(const GrClip& clip,
GrSurfaceProxyView proxyView,
- SkAlphaType srcAlphaType,
+ GrColorType srcColorType,
sk_sp<GrColorSpaceXform> textureXform,
GrSamplerState::Filter filter,
const SkPMColor4f& color,
@@ -647,11 +647,11 @@
: GrTextureOp::Saturate::kNo;
// Use the provided domain, although hypothetically we could detect that the cropped local
// quad is sufficiently inside the domain and the constraint could be dropped.
- this->addDrawOp(
- finalClip,
- GrTextureOp::Make(fContext, std::move(proxyView), srcAlphaType,
- std::move(textureXform), filter, color, saturate, blendMode,
- aaType, edgeFlags, croppedDeviceQuad, croppedLocalQuad, domain));
+ this->addDrawOp(finalClip,
+ GrTextureOp::Make(fContext, std::move(proxyView), srcColorType,
+ std::move(textureXform), filter, color, saturate,
+ blendMode, aaType, edgeFlags, croppedDeviceQuad,
+ croppedLocalQuad, domain));
}
}
@@ -899,7 +899,7 @@
const SkRect* domain = constraint == SkCanvas::kStrict_SrcRectConstraint
? &set[i].fSrcRect : nullptr;
- this->drawTexturedQuad(clip, set[i].fProxyView, set[i].fSrcAlphaType, texXform, filter,
+ this->drawTexturedQuad(clip, set[i].fProxyView, set[i].fSrcColorType, texXform, filter,
{alpha, alpha, alpha, alpha}, mode, aa, set[i].fAAFlags, quad,
srcQuad, domain);
}
@@ -1590,6 +1590,7 @@
// If the src is not texturable first try to make a copy to a texture.
if (!texProxy) {
texProxy = GrSurfaceProxy::Copy(fContext, fRenderTargetProxy.get(),
+ this->colorInfo().colorType(),
GrMipMapped::kNo, srcRect, SkBackingFit::kApprox,
SkBudgeted::kNo);
if (!texProxy) {
@@ -1607,8 +1608,8 @@
return;
}
tempRTC->drawTexture(GrNoClip(), std::move(texProxy), this->colorInfo().colorType(),
- this->colorInfo().alphaType(), GrSamplerState::Filter::kNearest,
- SkBlendMode::kSrc, SK_PMColor4fWHITE, srcRectToDraw,
+ GrSamplerState::Filter::kNearest, SkBlendMode::kSrc,
+ SK_PMColor4fWHITE, srcRectToDraw,
SkRect::MakeWH(srcRect.width(), srcRect.height()), GrAA::kNo,
GrQuadAAFlags::kNone, SkCanvas::kFast_SrcRectConstraint,
SkMatrix::I(), std::move(xform));
@@ -1818,8 +1819,8 @@
return;
}
tempRTC->drawTexture(GrNoClip(), std::move(texProxy), this->colorInfo().colorType(),
- this->colorInfo().alphaType(), GrSamplerState::Filter::kNearest,
- SkBlendMode::kSrc, SK_PMColor4fWHITE, srcRectToDraw,
+ GrSamplerState::Filter::kNearest, SkBlendMode::kSrc,
+ SK_PMColor4fWHITE, srcRectToDraw,
SkRect::MakeWH(srcRect.width(), srcRect.height()), GrAA::kNo,
GrQuadAAFlags::kNone, SkCanvas::kFast_SrcRectConstraint,
SkMatrix::I(), std::move(xform));
@@ -1832,6 +1833,8 @@
callback(context, nullptr);
return;
}
+ GrColorType srcColorType = tempRTC ? tempRTC->colorInfo().colorType()
+ : this->colorInfo().colorType();
auto yRTC = direct->priv().makeDeferredRenderTargetContextWithFallback(
SkBackingFit::kApprox, dstSize.width(), dstSize.height(), GrColorType::kAlpha_8,
@@ -1864,7 +1867,7 @@
std::fill_n(yM, 15, 0.f);
std::copy_n(baseM + 0, 5, yM + 15);
GrPaint yPaint;
- yPaint.addColorTextureProcessor(srcProxy, this->colorInfo().alphaType(), texMatrix);
+ yPaint.addColorTextureProcessor(srcProxy, srcColorType, texMatrix);
auto yFP = GrColorMatrixFragmentProcessor::Make(yM, false, true, false);
yPaint.addColorFragmentProcessor(std::move(yFP));
yPaint.setPorterDuffXPFactory(SkBlendMode::kSrc);
@@ -1883,7 +1886,7 @@
std::fill_n(uM, 15, 0.f);
std::copy_n(baseM + 5, 5, uM + 15);
GrPaint uPaint;
- uPaint.addColorTextureProcessor(srcProxy, this->colorInfo().alphaType(), texMatrix,
+ uPaint.addColorTextureProcessor(srcProxy, srcColorType, texMatrix,
GrSamplerState::ClampBilerp());
auto uFP = GrColorMatrixFragmentProcessor::Make(uM, false, true, false);
uPaint.addColorFragmentProcessor(std::move(uFP));
@@ -1902,7 +1905,7 @@
std::fill_n(vM, 15, 0.f);
std::copy_n(baseM + 10, 5, vM + 15);
GrPaint vPaint;
- vPaint.addColorTextureProcessor(srcProxy, this->colorInfo().alphaType(), texMatrix,
+ vPaint.addColorTextureProcessor(srcProxy, srcColorType, texMatrix,
GrSamplerState::ClampBilerp());
auto vFP = GrColorMatrixFragmentProcessor::Make(vM, false, true, false);
vPaint.addColorFragmentProcessor(std::move(vFP));
@@ -2406,9 +2409,9 @@
dstOffset = {copyRect.fLeft, copyRect.fTop};
fit = SkBackingFit::kApprox;
}
- sk_sp<GrTextureProxy> newProxy =
- GrSurfaceProxy::Copy(fContext, fRenderTargetProxy.get(), GrMipMapped::kNo, copyRect,
- fit, SkBudgeted::kYes, restrictions.fRectsMustMatch);
+ sk_sp<GrTextureProxy> newProxy = GrSurfaceProxy::Copy(
+ fContext, fRenderTargetProxy.get(), this->colorInfo().colorType(), GrMipMapped::kNo,
+ copyRect, fit, SkBudgeted::kYes, restrictions.fRectsMustMatch);
SkASSERT(newProxy);
dstProxyView->setProxyView({std::move(newProxy), this->origin(), this->textureSwizzle()});
@@ -2416,8 +2419,8 @@
return true;
}
-bool GrRenderTargetContext::blitTexture(GrTextureProxy* src, const SkIRect& srcRect,
- const SkIPoint& dstPoint) {
+bool GrRenderTargetContext::blitTexture(GrTextureProxy* src, GrColorType srcColorType,
+ const SkIRect& srcRect, const SkIPoint& dstPoint) {
SkIRect clippedSrcRect;
SkIPoint clippedDstPoint;
if (!GrClipSrcRectAndDstPoint(this->asSurfaceProxy()->dimensions(), src->dimensions(), srcRect,
@@ -2427,7 +2430,7 @@
GrPaint paint;
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
- auto fp = GrSimpleTextureEffect::Make(sk_ref_sp(src), kUnknown_SkAlphaType, SkMatrix::I());
+ auto fp = GrSimpleTextureEffect::Make(sk_ref_sp(src), srcColorType, SkMatrix::I());
if (!fp) {
return false;
}
@@ -2440,3 +2443,4 @@
SkRect::Make(clippedSrcRect));
return true;
}
+
diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h
index ef34f40..9b0b662 100644
--- a/src/gpu/GrRenderTargetContext.h
+++ b/src/gpu/GrRenderTargetContext.h
@@ -196,16 +196,16 @@
* device space.
*/
void drawTexture(const GrClip& clip, sk_sp<GrTextureProxy> proxy, GrColorType srcColorType,
- SkAlphaType srcAlphaType, GrSamplerState::Filter filter, SkBlendMode mode,
- const SkPMColor4f& color, const SkRect& srcRect, const SkRect& dstRect,
- GrAA aa, GrQuadAAFlags edgeAA, SkCanvas::SrcRectConstraint constraint,
- const SkMatrix& viewMatrix, sk_sp<GrColorSpaceXform> texXform) {
+ GrSamplerState::Filter filter, SkBlendMode mode, const SkPMColor4f& color,
+ const SkRect& srcRect, const SkRect& dstRect, GrAA aa, GrQuadAAFlags edgeAA,
+ SkCanvas::SrcRectConstraint constraint, const SkMatrix& viewMatrix,
+ sk_sp<GrColorSpaceXform> texXform) {
const SkRect* domain = constraint == SkCanvas::kStrict_SrcRectConstraint ?
&srcRect : nullptr;
GrSurfaceOrigin origin = proxy->origin();
const GrSwizzle& swizzle = proxy->textureSwizzle();
GrSurfaceProxyView proxyView(std::move(proxy), origin, swizzle);
- this->drawTexturedQuad(clip, std::move(proxyView), srcAlphaType, std::move(texXform),
+ this->drawTexturedQuad(clip, std::move(proxyView), srcColorType, std::move(texXform),
filter, color, mode, aa, edgeAA,
GrQuad::MakeFromRect(dstRect, viewMatrix), GrQuad(srcRect), domain);
}
@@ -217,15 +217,14 @@
* provided, the strict src rect constraint is applied using 'domain'.
*/
void drawTextureQuad(const GrClip& clip, sk_sp<GrTextureProxy> proxy, GrColorType srcColorType,
- SkAlphaType srcAlphaType, GrSamplerState::Filter filter, SkBlendMode mode,
- const SkPMColor4f& color, const SkPoint srcQuad[4],
- const SkPoint dstQuad[4], GrAA aa, GrQuadAAFlags edgeAA,
- const SkRect* domain, const SkMatrix& viewMatrix,
+ GrSamplerState::Filter filter, SkBlendMode mode, const SkPMColor4f& color,
+ const SkPoint srcQuad[4], const SkPoint dstQuad[4], GrAA aa,
+ GrQuadAAFlags edgeAA, const SkRect* domain, const SkMatrix& viewMatrix,
sk_sp<GrColorSpaceXform> texXform) {
GrSurfaceOrigin origin = proxy->origin();
const GrSwizzle& swizzle = proxy->textureSwizzle();
GrSurfaceProxyView proxyView(std::move(proxy), origin, swizzle);
- this->drawTexturedQuad(clip, std::move(proxyView), srcAlphaType, std::move(texXform),
+ this->drawTexturedQuad(clip, std::move(proxyView), srcColorType, std::move(texXform),
filter, color, mode, aa, edgeAA,
GrQuad::MakeFromSkQuad(dstQuad, viewMatrix),
GrQuad::MakeFromSkQuad(srcQuad, SkMatrix::I()), domain);
@@ -234,7 +233,7 @@
/** Used with drawTextureSet */
struct TextureSetEntry {
GrSurfaceProxyView fProxyView;
- SkAlphaType fSrcAlphaType;
+ GrColorType fSrcColorType;
SkRect fSrcRect;
SkRect fDstRect;
const SkPoint* fDstClipQuad; // Must be null, or point to an array of 4 points
@@ -443,7 +442,8 @@
* of the srcRect. The srcRect and dstRect are clipped to the bounds of the src and dst surfaces
* respectively.
*/
- bool blitTexture(GrTextureProxy* src, const SkIRect& srcRect, const SkIPoint& dstPoint);
+ bool blitTexture(GrTextureProxy* src, GrColorType srcColorType, const SkIRect& srcRect,
+ const SkIPoint& dstPoint);
/**
* Adds the necessary signal and wait semaphores and adds the passed in SkDrawable to the
@@ -552,6 +552,15 @@
friend class GrFillRectOp; // for access to addDrawOp
friend class GrTextureOp; // for access to addDrawOp
+#if GR_TEST_UTILS
+ // for a unit test
+ friend void test_draw_op(GrContext*,
+ GrRenderTargetContext*,
+ std::unique_ptr<GrFragmentProcessor>,
+ sk_sp<GrTextureProxy>,
+ GrColorType);
+#endif
+
GrRenderTargetContext(GrRecordingContext*, sk_sp<GrRenderTargetProxy>, GrColorType,
GrSurfaceOrigin, GrSwizzle texSwizzle, GrSwizzle outSwizzle,
sk_sp<SkColorSpace>, const SkSurfaceProps*, bool managedOpsTask = true);
@@ -605,7 +614,7 @@
// Like drawFilledQuad but does not require using a GrPaint or FP for texturing
void drawTexturedQuad(const GrClip& clip,
GrSurfaceProxyView proxyView,
- SkAlphaType alphaType,
+ GrColorType srcColorType,
sk_sp<GrColorSpaceXform> textureXform,
GrSamplerState::Filter filter,
const SkPMColor4f& color,
diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp
index e4ae6c0..4245e9e 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/GrSoftwarePathRenderer.cpp
@@ -144,6 +144,7 @@
void GrSoftwarePathRenderer::DrawToTargetWithShapeMask(
sk_sp<GrTextureProxy> proxy,
+ GrColorType srcColorType,
GrRenderTargetContext* renderTargetContext,
GrPaint&& paint,
const GrUserStencilSettings& userStencilSettings,
@@ -165,7 +166,7 @@
SkIntToScalar(-textureOriginInDeviceSpace.fY));
maskMatrix.preConcat(viewMatrix);
paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(
- std::move(proxy), kPremul_SkAlphaType, maskMatrix, GrSamplerState::Filter::kNearest));
+ std::move(proxy), srcColorType, maskMatrix, GrSamplerState::Filter::kNearest));
DrawNonAARect(renderTargetContext, std::move(paint), userStencilSettings, clip, SkMatrix::I(),
dstRect, invert);
}
@@ -385,9 +386,10 @@
*args.fUserStencilSettings, *args.fClip, *args.fViewMatrix, devClipBounds,
unclippedDevShapeBounds);
}
- DrawToTargetWithShapeMask(std::move(proxy), args.fRenderTargetContext, std::move(args.fPaint),
- *args.fUserStencilSettings, *args.fClip, *args.fViewMatrix,
- SkIPoint{boundsForMask->fLeft, boundsForMask->fTop}, *boundsForMask);
+ DrawToTargetWithShapeMask(
+ std::move(proxy), GrColorType::kAlpha_8, args.fRenderTargetContext,
+ std::move(args.fPaint), *args.fUserStencilSettings, *args.fClip, *args.fViewMatrix,
+ SkIPoint{boundsForMask->fLeft, boundsForMask->fTop}, *boundsForMask);
return true;
}
diff --git a/src/gpu/GrSoftwarePathRenderer.h b/src/gpu/GrSoftwarePathRenderer.h
index a510c7b..d407791 100644
--- a/src/gpu/GrSoftwarePathRenderer.h
+++ b/src/gpu/GrSoftwarePathRenderer.h
@@ -52,6 +52,7 @@
// space. The 'viewMatrix' will be used to ensure the correct local coords are provided to
// any fragment processors in the paint.
static void DrawToTargetWithShapeMask(sk_sp<GrTextureProxy> proxy,
+ GrColorType srcColorType,
GrRenderTargetContext* renderTargetContext,
GrPaint&& paint,
const GrUserStencilSettings& userStencilSettings,
diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp
index f8f2399..8d4708d 100644
--- a/src/gpu/GrSurfaceContext.cpp
+++ b/src/gpu/GrSurfaceContext.cpp
@@ -151,7 +151,7 @@
if (canvas2DFastPath) {
fp = direct->priv().createPMToUPMEffect(
GrSimpleTextureEffect::Make(sk_ref_sp(srcProxy->asTextureProxy()),
- this->colorInfo().alphaType(), SkMatrix::I()));
+ this->colorInfo().colorType(), SkMatrix::I()));
if (dstInfo.colorType() == GrColorType::kBGRA_8888) {
fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), GrSwizzle::BGRA());
dstInfo = dstInfo.makeColorType(GrColorType::kRGBA_8888);
@@ -162,7 +162,7 @@
dstInfo = dstInfo.makeAlphaType(kPremul_SkAlphaType);
} else {
fp = GrSimpleTextureEffect::Make(sk_ref_sp(srcProxy->asTextureProxy()),
- this->colorInfo().alphaType(), SkMatrix::I());
+ this->colorInfo().colorType(), SkMatrix::I());
}
if (!fp) {
return false;
@@ -345,14 +345,15 @@
if (this->asRenderTargetContext()) {
std::unique_ptr<GrFragmentProcessor> fp;
if (canvas2DFastPath) {
- fp = direct->priv().createUPMToPMEffect(GrSimpleTextureEffect::Make(
- std::move(tempProxy), alphaType, SkMatrix::I()));
+ fp = direct->priv().createUPMToPMEffect(
+ GrSimpleTextureEffect::Make(std::move(tempProxy), colorType,
+ SkMatrix::I()));
// Important: check the original src color type here!
if (origSrcInfo.colorType() == GrColorType::kBGRA_8888) {
fp = GrFragmentProcessor::SwizzleOutput(std::move(fp), GrSwizzle::BGRA());
}
} else {
- fp = GrSimpleTextureEffect::Make(std::move(tempProxy), alphaType, SkMatrix::I());
+ fp = GrSimpleTextureEffect::Make(std::move(tempProxy), colorType, SkMatrix::I());
}
if (!fp) {
return false;
@@ -461,10 +462,10 @@
sk_sp<GrTextureProxy> texProxy = sk_ref_sp(this->asTextureProxy());
SkCanvas::SrcRectConstraint constraint = SkCanvas::kStrict_SrcRectConstraint;
GrColorType srcColorType = this->colorInfo().colorType();
- SkAlphaType srcAlphaType = this->colorInfo().alphaType();
if (!texProxy) {
- texProxy = GrSurfaceProxy::Copy(fContext, this->asSurfaceProxy(), GrMipMapped::kNo, srcRect,
- SkBackingFit::kApprox, SkBudgeted::kNo);
+ texProxy = GrSurfaceProxy::Copy(fContext, this->asSurfaceProxy(), srcColorType,
+ GrMipMapped::kNo, srcRect, SkBackingFit::kApprox,
+ SkBudgeted::kNo);
if (!texProxy) {
return nullptr;
}
@@ -498,7 +499,8 @@
if (rescaleGamma == SkSurface::kLinear && this->colorInfo().colorSpace() &&
!this->colorInfo().colorSpace()->gammaIsLinear()) {
auto cs = this->colorInfo().colorSpace()->makeLinearGamma();
- auto xform = GrColorSpaceXform::Make(this->colorInfo().colorSpace(), srcAlphaType, cs.get(),
+ auto xform = GrColorSpaceXform::Make(this->colorInfo().colorSpace(),
+ this->colorInfo().alphaType(), cs.get(),
kPremul_SkAlphaType);
// We'll fall back to kRGBA_8888 if half float not supported.
auto linearRTC = fContext->priv().makeDeferredRenderTargetContextWithFallback(
@@ -507,11 +509,10 @@
if (!linearRTC) {
return nullptr;
}
- linearRTC->drawTexture(GrNoClip(), texProxy, srcColorType, srcAlphaType,
- GrSamplerState::Filter::kNearest, SkBlendMode::kSrc,
- SK_PMColor4fWHITE, SkRect::Make(srcRect), SkRect::MakeWH(srcW, srcH),
- GrAA::kNo, GrQuadAAFlags::kNone, constraint, SkMatrix::I(),
- std::move(xform));
+ linearRTC->drawTexture(GrNoClip(), texProxy, srcColorType, GrSamplerState::Filter::kNearest,
+ SkBlendMode::kSrc, SK_PMColor4fWHITE, SkRect::Make(srcRect),
+ SkRect::MakeWH(srcW, srcH), GrAA::kNo, GrQuadAAFlags::kNone,
+ constraint, SkMatrix::I(), std::move(xform));
texProxy = linearRTC->asTextureProxyRef();
tempA = std::move(linearRTC);
srcX = 0;
@@ -572,9 +573,10 @@
if (srcW != texProxy->width() || srcH != texProxy->height()) {
auto domain = GrTextureDomain::MakeTexelDomain(
SkIRect::MakeXYWH(srcX, srcY, srcW, srcH), GrTextureDomain::kClamp_Mode);
- fp = GrBicubicEffect::Make(texProxy, matrix, domain, dir, prevAlphaType);
+ fp = GrBicubicEffect::Make(texProxy, srcColorType, matrix, domain, dir,
+ prevAlphaType);
} else {
- fp = GrBicubicEffect::Make(texProxy, matrix, dir, prevAlphaType);
+ fp = GrBicubicEffect::Make(texProxy, srcColorType, matrix, dir, prevAlphaType);
}
if (xform) {
fp = GrColorSpaceXformEffect::Make(std::move(fp), std::move(xform));
@@ -588,8 +590,8 @@
auto filter = rescaleQuality == kNone_SkFilterQuality ? GrSamplerState::Filter::kNearest
: GrSamplerState::Filter::kBilerp;
auto srcSubset = SkRect::MakeXYWH(srcX, srcY, srcW, srcH);
- tempB->drawTexture(GrNoClip(), texProxy, srcColorType, srcAlphaType, filter,
- SkBlendMode::kSrc, SK_PMColor4fWHITE, srcSubset, dstRect, GrAA::kNo,
+ tempB->drawTexture(GrNoClip(), texProxy, srcColorType, filter, SkBlendMode::kSrc,
+ SK_PMColor4fWHITE, srcSubset, dstRect, GrAA::kNo,
GrQuadAAFlags::kNone, constraint, SkMatrix::I(), std::move(xform));
}
texProxy = tempB->asTextureProxyRef();
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index 7577811..310b91f 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -278,6 +278,7 @@
sk_sp<GrTextureProxy> GrSurfaceProxy::Copy(GrRecordingContext* context,
GrSurfaceProxy* src,
+ GrColorType srcColorType,
GrMipMapped mipMapped,
SkIRect srcRect,
SkBackingFit fit,
@@ -319,7 +320,8 @@
fit, width, height, colorType, nullptr, 1, mipMapped, src->origin(), nullptr,
budgeted);
- if (dstContext && dstContext->blitTexture(src->asTextureProxy(), srcRect, dstPoint)) {
+ if (dstContext && dstContext->blitTexture(src->asTextureProxy(), srcColorType, srcRect,
+ dstPoint)) {
return dstContext->asTextureProxyRef();
}
}
@@ -328,10 +330,11 @@
}
sk_sp<GrTextureProxy> GrSurfaceProxy::Copy(GrRecordingContext* context, GrSurfaceProxy* src,
- GrMipMapped mipMapped, SkBackingFit fit,
- SkBudgeted budgeted) {
+ GrColorType srcColorType, GrMipMapped mipMapped,
+ SkBackingFit fit, SkBudgeted budgeted) {
SkASSERT(!src->isFullyLazy());
- return Copy(context, src, mipMapped, SkIRect::MakeSize(src->dimensions()), fit, budgeted);
+ return Copy(context, src, srcColorType, mipMapped, SkIRect::MakeSize(src->dimensions()), fit,
+ budgeted);
}
#if GR_TEST_UTILS
diff --git a/src/gpu/GrSurfaceProxy.h b/src/gpu/GrSurfaceProxy.h
index f4e2d15..d835957 100644
--- a/src/gpu/GrSurfaceProxy.h
+++ b/src/gpu/GrSurfaceProxy.h
@@ -284,13 +284,15 @@
// Helper function that creates a temporary SurfaceContext to perform the copy
// The copy is is not a render target and not multisampled.
- static sk_sp<GrTextureProxy> Copy(GrRecordingContext*, GrSurfaceProxy* src, GrMipMapped,
+ static sk_sp<GrTextureProxy> Copy(GrRecordingContext*, GrSurfaceProxy* src,
+ GrColorType srcColorType, GrMipMapped,
SkIRect srcRect, SkBackingFit, SkBudgeted,
RectsMustMatch = RectsMustMatch::kNo);
// Copy the entire 'src'
- static sk_sp<GrTextureProxy> Copy(GrRecordingContext*, GrSurfaceProxy* src, GrMipMapped,
- SkBackingFit, SkBudgeted);
+ static sk_sp<GrTextureProxy> Copy(GrRecordingContext*, GrSurfaceProxy* src,
+ GrColorType srcColortype, GrMipMapped, SkBackingFit,
+ SkBudgeted);
#if GR_TEST_UTILS
int32_t testingOnly_getBackingRefCnt() const;
diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp
index 4118287..cfc2c8d 100644
--- a/src/gpu/GrTextureProducer.cpp
+++ b/src/gpu/GrTextureProducer.cpp
@@ -63,12 +63,12 @@
// This would cause us to read values from outside the subset. Surely, the caller knows
// better!
SkASSERT(copyParams.fFilter != GrSamplerState::Filter::kMipMap);
- paint.addColorFragmentProcessor(GrTextureDomainEffect::Make(
- std::move(inputProxy), kUnknown_SkAlphaType, SkMatrix::I(), domain,
- GrTextureDomain::kClamp_Mode, copyParams.fFilter));
+ paint.addColorFragmentProcessor(
+ GrTextureDomainEffect::Make(std::move(inputProxy), colorType, SkMatrix::I(), domain,
+ GrTextureDomain::kClamp_Mode, copyParams.fFilter));
} else {
GrSamplerState samplerState(GrSamplerState::WrapMode::kClamp, copyParams.fFilter);
- paint.addColorTextureProcessor(std::move(inputProxy), kUnknown_SkAlphaType, SkMatrix::I(),
+ paint.addColorTextureProcessor(std::move(inputProxy), colorType, SkMatrix::I(),
samplerState);
}
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
@@ -201,19 +201,19 @@
const GrSamplerState::Filter* filterOrNullForBicubic) {
SkASSERT(kTightCopy_DomainMode != domainMode);
bool clampToBorderSupport = fContext->priv().caps()->clampToBorderSupport();
- SkAlphaType srcAlphaType = this->alphaType();
+ GrColorType srcColorType = this->colorType();
if (filterOrNullForBicubic) {
if (kDomain_DomainMode == domainMode || (fDomainNeedsDecal && !clampToBorderSupport)) {
GrTextureDomain::Mode wrapMode = fDomainNeedsDecal ? GrTextureDomain::kDecal_Mode
: GrTextureDomain::kClamp_Mode;
- return GrTextureDomainEffect::Make(std::move(proxy), srcAlphaType, textureMatrix,
+ return GrTextureDomainEffect::Make(std::move(proxy), srcColorType, textureMatrix,
domain, wrapMode, *filterOrNullForBicubic);
} else {
GrSamplerState::WrapMode wrapMode =
fDomainNeedsDecal ? GrSamplerState::WrapMode::kClampToBorder
: GrSamplerState::WrapMode::kClamp;
GrSamplerState samplerState(wrapMode, *filterOrNullForBicubic);
- return GrSimpleTextureEffect::Make(std::move(proxy), srcAlphaType, textureMatrix,
+ return GrSimpleTextureEffect::Make(std::move(proxy), srcColorType, textureMatrix,
samplerState);
}
} else {
@@ -226,13 +226,13 @@
if (kDomain_DomainMode == domainMode || (fDomainNeedsDecal && !clampToBorderSupport)) {
GrTextureDomain::Mode wrapMode = fDomainNeedsDecal ? GrTextureDomain::kDecal_Mode
: GrTextureDomain::kClamp_Mode;
- return GrBicubicEffect::Make(std::move(proxy), textureMatrix, kClampClamp, wrapMode,
- wrapMode, kDir, srcAlphaType,
+ return GrBicubicEffect::Make(std::move(proxy), srcColorType, textureMatrix, kClampClamp,
+ wrapMode, wrapMode, kDir, this->alphaType(),
kDomain_DomainMode == domainMode ? &domain : nullptr);
} else {
- return GrBicubicEffect::Make(std::move(proxy), textureMatrix,
+ return GrBicubicEffect::Make(std::move(proxy), srcColorType, textureMatrix,
fDomainNeedsDecal ? kDecalDecal : kClampClamp, kDir,
- srcAlphaType);
+ this->alphaType());
}
}
}
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index cd3fbea..abd0237 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -230,6 +230,7 @@
SkASSERT(fRenderTargetContext->asTextureProxy());
SkAssertResult(rtc->blitTexture(fRenderTargetContext->asTextureProxy(),
+ fRenderTargetContext->colorInfo().colorType(),
SkIRect::MakeWH(this->width(), this->height()),
SkIPoint::Make(0,0)));
}
@@ -931,7 +932,7 @@
SkMatrix texMatrix = SkMatrix::MakeRectToRect(dstRect, srcRect, SkMatrix::kFill_ScaleToFit);
texMatrix.postScale(scales[0], scales[1]);
- SkAlphaType srcAlphaType = bitmap.alphaType();
+ GrColorType srcColorType = SkColorTypeToGrColorType(bitmap.colorType());
// Construct a GrPaint by setting the bitmap texture as the first effect and then configuring
// the rest from the SkPaint.
@@ -954,18 +955,20 @@
}
if (bicubic) {
static constexpr auto kDir = GrBicubicEffect::Direction::kXY;
- fp = GrBicubicEffect::Make(std::move(proxy), texMatrix, domain, kDir, srcAlphaType);
+ fp = GrBicubicEffect::Make(std::move(proxy), srcColorType, texMatrix, domain, kDir,
+ bitmap.alphaType());
} else {
- fp = GrTextureDomainEffect::Make(std::move(proxy), srcAlphaType, texMatrix, domain,
+ fp = GrTextureDomainEffect::Make(std::move(proxy), srcColorType, texMatrix, domain,
GrTextureDomain::kClamp_Mode, samplerState.filter());
}
} else if (bicubic) {
SkASSERT(GrSamplerState::Filter::kNearest == samplerState.filter());
GrSamplerState::WrapMode wrapMode[2] = {samplerState.wrapModeX(), samplerState.wrapModeY()};
static constexpr auto kDir = GrBicubicEffect::Direction::kXY;
- fp = GrBicubicEffect::Make(std::move(proxy), texMatrix, wrapMode, kDir, srcAlphaType);
+ fp = GrBicubicEffect::Make(std::move(proxy), srcColorType, texMatrix, wrapMode, kDir,
+ bitmap.alphaType());
} else {
- fp = GrSimpleTextureEffect::Make(std::move(proxy), srcAlphaType, texMatrix, samplerState);
+ fp = GrSimpleTextureEffect::Make(std::move(proxy), srcColorType, texMatrix, samplerState);
}
fp = GrColorSpaceXformEffect::Make(std::move(fp), bitmap.colorSpace(), bitmap.alphaType(),
@@ -1036,7 +1039,8 @@
tmpUnfiltered.setImageFilter(nullptr);
- auto fp = GrSimpleTextureEffect::Make(std::move(proxy), special->alphaType(), SkMatrix::I());
+ GrColorType srcColorType = SkColorTypeToGrColorType(result->colorType());
+ auto fp = GrSimpleTextureEffect::Make(std::move(proxy), srcColorType, SkMatrix::I());
fp = GrColorSpaceXformEffect::Make(std::move(fp), result->getColorSpace(), result->alphaType(),
fRenderTargetContext->colorInfo().colorSpace());
if (GrColorTypeIsAlphaOnly(SkColorTypeToGrColorType(result->colorType()))) {
@@ -1074,8 +1078,8 @@
std::unique_ptr<GrFragmentProcessor> cfp;
if (clipProxy && ctm.invert(&inverseClipMatrix)) {
GrColorType srcColorType = SkColorTypeToGrColorType(clipImage->colorType());
- cfp = GrSimpleTextureEffect::Make(std::move(clipProxy), clipImage->alphaType(),
- inverseClipMatrix, sampler);
+ cfp = GrSimpleTextureEffect::Make(std::move(clipProxy), srcColorType, inverseClipMatrix,
+ sampler);
if (srcColorType != GrColorType::kAlpha_8) {
cfp = GrFragmentProcessor::SwizzleOutput(std::move(cfp), GrSwizzle::AAAA());
}
@@ -1251,6 +1255,7 @@
// texture that matches the device contents
proxy = GrSurfaceProxy::Copy(fContext.get(),
rtc->asSurfaceProxy(),
+ rtc->colorInfo().colorType(),
GrMipMapped::kNo, // Don't auto generate mips
subset,
SkBackingFit::kApprox,
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index c3b3649..ce5c49b 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -220,15 +220,14 @@
SkPoint srcQuad[4];
GrMapRectPoints(dstRect, srcRect, dstClip, srcQuad, 4);
- rtc->drawTextureQuad(clip, std::move(proxy), srcColorInfo.colorType(),
- srcColorInfo.alphaType(), filter, paint.getBlendMode(), color, srcQuad,
- dstClip, aa, aaFlags,
+ rtc->drawTextureQuad(clip, std::move(proxy), srcColorInfo.colorType(), filter,
+ paint.getBlendMode(), color, srcQuad, dstClip, aa, aaFlags,
constraint == SkCanvas::kStrict_SrcRectConstraint ? &srcRect : nullptr,
ctm, std::move(textureXform));
} else {
- rtc->drawTexture(clip, std::move(proxy), srcColorInfo.colorType(), srcColorInfo.alphaType(),
- filter, paint.getBlendMode(), color, srcRect, dstRect, aa, aaFlags,
- constraint, ctm, std::move(textureXform));
+ rtc->drawTexture(clip, std::move(proxy), srcColorInfo.colorType(), filter,
+ paint.getBlendMode(), color, srcRect, dstRect, aa, aaFlags, constraint,
+ ctm, std::move(textureXform));
}
}
@@ -556,7 +555,7 @@
GrSurfaceOrigin origin = proxy->origin();
const GrSwizzle& swizzle = proxy->textureSwizzle();
textures[i].fProxyView = {std::move(proxy), origin, swizzle};
- textures[i].fSrcAlphaType = image->alphaType();
+ textures[i].fSrcColorType = SkColorTypeToGrColorType(image->colorType());
textures[i].fSrcRect = set[i].fSrcRect;
textures[i].fDstRect = set[i].fDstRect;
textures[i].fDstClipQuad = clip;
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 0472ee2..fcc43bd 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -132,8 +132,8 @@
if (!ctx->priv().caps()->isFormatCopyable(baseProxy->backendFormat())) {
return nullptr;
}
- return GrSurfaceProxy::Copy(ctx, baseProxy, GrMipMapped::kYes, SkBackingFit::kExact,
- SkBudgeted::kYes);
+ return GrSurfaceProxy::Copy(ctx, baseProxy, srcColorType, GrMipMapped::kYes,
+ SkBackingFit::kExact, SkBudgeted::kYes);
}
sk_sp<GrTextureProxy> GrRefCachedBitmapTextureProxy(GrRecordingContext* ctx,
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp
index d78cb74..6d7b431 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -162,13 +162,15 @@
processor.textureSampler(0).samplerState());
}
-GrBicubicEffect::GrBicubicEffect(sk_sp<GrTextureProxy> proxy, const SkMatrix& matrix,
- const SkRect& domain, const GrSamplerState::WrapMode wrapModes[2],
+GrBicubicEffect::GrBicubicEffect(sk_sp<GrTextureProxy> proxy, GrColorType srcColorType,
+ const SkMatrix& matrix, const SkRect& domain,
+ const GrSamplerState::WrapMode wrapModes[2],
GrTextureDomain::Mode modeX, GrTextureDomain::Mode modeY,
Direction direction, SkAlphaType alphaType)
: INHERITED{kGrBicubicEffect_ClassID,
ModulateForSamplerOptFlags(
- alphaType, GrTextureDomain::IsDecalSampled(wrapModes, modeX, modeY))}
+ srcColorType,
+ GrTextureDomain::IsDecalSampled(wrapModes, modeX, modeY))}
, fCoordTransform(matrix, proxy.get())
, fDomain(proxy.get(), domain, modeX, modeY)
, fTextureSampler(std::move(proxy),
@@ -225,8 +227,8 @@
direction = Direction::kXY;
break;
}
- return GrBicubicEffect::Make(d->textureProxy(texIdx), SkMatrix::I(), kClampClamp, direction,
- alphaType);
+ return GrBicubicEffect::Make(d->textureProxy(texIdx), d->textureProxyColorType(texIdx),
+ SkMatrix::I(), kClampClamp, direction, alphaType);
}
#endif
diff --git a/src/gpu/effects/GrBicubicEffect.h b/src/gpu/effects/GrBicubicEffect.h
index 71e8fcf..5e274e0 100644
--- a/src/gpu/effects/GrBicubicEffect.h
+++ b/src/gpu/effects/GrBicubicEffect.h
@@ -45,27 +45,31 @@
* Create a Mitchell filter effect with specified texture matrix with clamp wrap mode.
*/
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
+ GrColorType srcColorType,
const SkMatrix& matrix,
Direction direction,
SkAlphaType alphaType) {
static constexpr GrSamplerState::WrapMode kClampClamp[] = {
GrSamplerState::WrapMode::kClamp, GrSamplerState::WrapMode::kClamp};
- return Make(std::move(proxy), matrix, kClampClamp, GrTextureDomain::kIgnore_Mode,
- GrTextureDomain::kIgnore_Mode, direction, alphaType);
+ return Make(std::move(proxy), srcColorType, matrix, kClampClamp,
+ GrTextureDomain::kIgnore_Mode, GrTextureDomain::kIgnore_Mode, direction,
+ alphaType);
}
/**
* Create a Mitchell filter effect with specified texture matrix and x/y tile modes.
*/
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
+ GrColorType srcColorType,
const SkMatrix& matrix,
const GrSamplerState::WrapMode wrapModes[2],
Direction direction,
SkAlphaType alphaType) {
// Ignore the domain on x and y, since this factory relies solely on the wrap mode of the
// sampler to constrain texture coordinates
- return Make(std::move(proxy), matrix, wrapModes, GrTextureDomain::kIgnore_Mode,
- GrTextureDomain::kIgnore_Mode, direction, alphaType);
+ return Make(std::move(proxy), srcColorType, matrix, wrapModes,
+ GrTextureDomain::kIgnore_Mode, GrTextureDomain::kIgnore_Mode, direction,
+ alphaType);
}
/**
@@ -74,6 +78,7 @@
* override the behavior of the sampler's tile mode (e.g. clamp to border unsupported).
*/
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
+ GrColorType srcColorType,
const SkMatrix& matrix,
const GrSamplerState::WrapMode wrapModes[2],
GrTextureDomain::Mode modeX,
@@ -89,22 +94,24 @@
SkIRect::MakeSize(proxy->dimensions()), modeX, modeY);
}
return std::unique_ptr<GrFragmentProcessor>(
- new GrBicubicEffect(std::move(proxy), matrix, resolvedDomain, wrapModes, modeX,
- modeY, direction, alphaType));
+ new GrBicubicEffect(std::move(proxy), srcColorType, matrix, resolvedDomain,
+ wrapModes, modeX, modeY, direction, alphaType));
}
/**
* Create a Mitchell filter effect with a texture matrix and a domain.
*/
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
+ GrColorType srcColorType,
const SkMatrix& matrix,
const SkRect& domain,
Direction direction,
SkAlphaType alphaType) {
static const GrSamplerState::WrapMode kClampClamp[] = {
GrSamplerState::WrapMode::kClamp, GrSamplerState::WrapMode::kClamp};
- return Make(std::move(proxy), matrix, kClampClamp, GrTextureDomain::kClamp_Mode,
- GrTextureDomain::kClamp_Mode, direction, alphaType, &domain);
+ return Make(std::move(proxy), srcColorType, matrix, kClampClamp,
+ GrTextureDomain::kClamp_Mode, GrTextureDomain::kClamp_Mode, direction,
+ alphaType, &domain);
}
/**
@@ -118,9 +125,10 @@
GrSamplerState::Filter* filterMode);
private:
- GrBicubicEffect(sk_sp<GrTextureProxy>, const SkMatrix& matrix, const SkRect& domain,
- const GrSamplerState::WrapMode wrapModes[2], GrTextureDomain::Mode modeX,
- GrTextureDomain::Mode modeY, Direction direction, SkAlphaType);
+ GrBicubicEffect(sk_sp<GrTextureProxy>, GrColorType srcColorType, const SkMatrix& matrix,
+ const SkRect& domain, const GrSamplerState::WrapMode wrapModes[2],
+ GrTextureDomain::Mode modeX, GrTextureDomain::Mode modeY, Direction direction,
+ SkAlphaType alphaType);
explicit GrBicubicEffect(const GrBicubicEffect&);
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
diff --git a/src/gpu/effects/GrConfigConversionEffect.fp b/src/gpu/effects/GrConfigConversionEffect.fp
index 7338b7d..0387c3b 100644
--- a/src/gpu/effects/GrConfigConversionEffect.fp
+++ b/src/gpu/effects/GrConfigConversionEffect.fp
@@ -64,6 +64,7 @@
// calling read pixels here. Thus the pixel data will be uploaded immediately and we don't
// need to keep the pixel data alive in the proxy. Therefore the ReleaseProc is nullptr.
sk_sp<SkImage> image = SkImage::MakeFromRaster(pixmap, nullptr, nullptr);
+ GrColorType dataColorType = SkColorTypeToGrColorType(image->colorType());
sk_sp<GrTextureProxy> dataProxy = proxyProvider->createTextureProxy(std::move(image),
1,
SkBudgeted::kYes,
@@ -86,7 +87,7 @@
std::unique_ptr<GrFragmentProcessor> upmToPM(
new GrConfigConversionEffect(PMConversion::kToPremul));
- paint1.addColorTextureProcessor(dataProxy, kPremul_SkAlphaType, SkMatrix::I());
+ paint1.addColorTextureProcessor(dataProxy, dataColorType, SkMatrix::I());
paint1.addColorFragmentProcessor(pmToUPM->clone());
paint1.setPorterDuffXPFactory(SkBlendMode::kSrc);
@@ -100,16 +101,14 @@
// draw
tempRTC->discard();
- paint2.addColorTextureProcessor(readRTC->asTextureProxyRef(), kUnpremul_SkAlphaType,
- SkMatrix::I());
+ paint2.addColorTextureProcessor(readRTC->asTextureProxyRef(), kColorType, SkMatrix::I());
paint2.addColorFragmentProcessor(std::move(upmToPM));
paint2.setPorterDuffXPFactory(SkBlendMode::kSrc);
tempRTC->fillRectToRect(GrNoClip(), std::move(paint2), GrAA::kNo, SkMatrix::I(), kRect,
kRect);
- paint3.addColorTextureProcessor(tempRTC->asTextureProxyRef(), kPremul_SkAlphaType,
- SkMatrix::I());
+ paint3.addColorTextureProcessor(tempRTC->asTextureProxyRef(), kColorType, SkMatrix::I());
paint3.addColorFragmentProcessor(std::move(pmToUPM));
paint3.setPorterDuffXPFactory(SkBlendMode::kSrc);
diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
index 59bc8ce..fd70616 100644
--- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
+++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
@@ -211,15 +211,16 @@
}
GrGaussianConvolutionFragmentProcessor::GrGaussianConvolutionFragmentProcessor(
- sk_sp<GrTextureProxy> proxy,
- SkAlphaType alphaType,
- Direction direction,
- int radius,
- float gaussianSigma,
- GrTextureDomain::Mode mode,
- int bounds[2])
+ sk_sp<GrTextureProxy> proxy,
+ GrColorType srcColorType,
+ Direction direction,
+ int radius,
+ float gaussianSigma,
+ GrTextureDomain::Mode mode,
+ int bounds[2])
: INHERITED(kGrGaussianConvolutionFragmentProcessor_ClassID,
- ModulateForSamplerOptFlags(alphaType, mode == GrTextureDomain::kDecal_Mode))
+ ModulateForSamplerOptFlags(srcColorType,
+ mode == GrTextureDomain::kDecal_Mode))
, fCoordTransform(proxy.get())
, fTextureSampler(std::move(proxy))
, fRadius(radius)
@@ -297,9 +298,8 @@
int radius = d->fRandom->nextRangeU(1, kMaxKernelRadius);
float sigma = radius / 3.f;
- auto alphaType = static_cast<SkAlphaType>(d->fRandom->nextULessThan(kLastEnum_SkAlphaType + 1));
return GrGaussianConvolutionFragmentProcessor::Make(
- std::move(proxy), alphaType, dir, radius, sigma,
- static_cast<GrTextureDomain::Mode>(modeIdx), bounds);
+ std::move(proxy), d->textureProxyColorType(texIdx),
+ dir, radius, sigma, static_cast<GrTextureDomain::Mode>(modeIdx), bounds);
}
#endif
diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h
index b329b1d..843ed30 100644
--- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h
+++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h
@@ -23,14 +23,14 @@
/// Convolve with a Gaussian kernel
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- SkAlphaType alphaType,
+ GrColorType srcColorType,
Direction dir,
int halfWidth,
float gaussianSigma,
GrTextureDomain::Mode mode,
int* bounds) {
return std::unique_ptr<GrFragmentProcessor>(new GrGaussianConvolutionFragmentProcessor(
- std::move(proxy), alphaType, dir, halfWidth, gaussianSigma, mode, bounds));
+ std::move(proxy), srcColorType, dir, halfWidth, gaussianSigma, mode, bounds));
}
const float* kernel() const { return fKernel; }
@@ -72,8 +72,8 @@
private:
/// Convolve with a Gaussian kernel
- GrGaussianConvolutionFragmentProcessor(sk_sp<GrTextureProxy>, SkAlphaType alphaType, Direction,
- int halfWidth, float gaussianSigma,
+ GrGaussianConvolutionFragmentProcessor(sk_sp<GrTextureProxy>, GrColorType srcColorType,
+ Direction, int halfWidth, float gaussianSigma,
GrTextureDomain::Mode mode, int bounds[2]);
explicit GrGaussianConvolutionFragmentProcessor(const GrGaussianConvolutionFragmentProcessor&);
diff --git a/src/gpu/effects/GrSimpleTextureEffect.fp b/src/gpu/effects/GrSimpleTextureEffect.fp
index beb3850..5c30cc0 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.fp
+++ b/src/gpu/effects/GrSimpleTextureEffect.fp
@@ -9,7 +9,7 @@
in half4x4 matrix;
@constructorParams {
- SkAlphaType alphaType,
+ GrColorType srcColorType,
GrSamplerState samplerParams
}
@@ -23,34 +23,34 @@
@make {
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- SkAlphaType alphaType,
+ GrColorType srcColorType,
const SkMatrix& matrix) {
return std::unique_ptr<GrFragmentProcessor>(
- new GrSimpleTextureEffect(std::move(proxy), matrix, alphaType,
+ new GrSimpleTextureEffect(std::move(proxy), matrix, srcColorType,
GrSamplerState(GrSamplerState::WrapMode::kClamp, GrSamplerState::Filter::kNearest)));
}
/* clamp mode */
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- SkAlphaType alphaType,
+ GrColorType srcColorType,
const SkMatrix& matrix,
GrSamplerState::Filter filter) {
return std::unique_ptr<GrFragmentProcessor>(
- new GrSimpleTextureEffect(std::move(proxy), matrix, alphaType,
+ new GrSimpleTextureEffect(std::move(proxy), matrix, srcColorType,
GrSamplerState(GrSamplerState::WrapMode::kClamp, filter)));
}
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- SkAlphaType alphaType,
+ GrColorType srcColorType,
const SkMatrix& matrix,
const GrSamplerState& p) {
return std::unique_ptr<GrFragmentProcessor>(
- new GrSimpleTextureEffect(std::move(proxy), matrix, alphaType, p));
+ new GrSimpleTextureEffect(std::move(proxy), matrix, srcColorType, p));
}
}
@optimizationFlags {
- ModulateForSamplerOptFlags(alphaType,
+ ModulateForSamplerOptFlags(srcColorType,
samplerParams.wrapModeX() == GrSamplerState::WrapMode::kClampToBorder ||
samplerParams.wrapModeY() == GrSamplerState::WrapMode::kClampToBorder)
}
@@ -76,7 +76,6 @@
: GrSamplerState::Filter::kNearest);
const SkMatrix& matrix = GrTest::TestMatrix(testData->fRandom);
- auto alphaType = static_cast<SkAlphaType>(
- testData->fRandom->nextULessThan(kLastEnum_SkAlphaType + 1));
return GrSimpleTextureEffect::Make(testData->textureProxy(texIdx),
- alphaType, matrix, params);}
+ testData->textureProxyColorType(texIdx), matrix, params);
+}
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index 4bc7b1b..8bb662b 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -252,40 +252,41 @@
std::unique_ptr<GrFragmentProcessor> GrTextureDomainEffect::Make(
sk_sp<GrTextureProxy> proxy,
- SkAlphaType srcAlphaType,
+ GrColorType srcColorType,
const SkMatrix& matrix,
const SkRect& domain,
GrTextureDomain::Mode mode,
GrSamplerState::Filter filterMode) {
- return Make(std::move(proxy), srcAlphaType, matrix, domain, mode, mode,
+ return Make(std::move(proxy), srcColorType, matrix, domain, mode, mode,
GrSamplerState(GrSamplerState::WrapMode::kClamp, filterMode));
}
-std::unique_ptr<GrFragmentProcessor> GrTextureDomainEffect::Make(sk_sp<GrTextureProxy> proxy,
- SkAlphaType srcAlphaType,
- const SkMatrix& matrix,
- const SkRect& domain,
- GrTextureDomain::Mode modeX,
- GrTextureDomain::Mode modeY,
- const GrSamplerState& sampler) {
+std::unique_ptr<GrFragmentProcessor> GrTextureDomainEffect::Make(
+ sk_sp<GrTextureProxy> proxy,
+ GrColorType srcColorType,
+ const SkMatrix& matrix,
+ const SkRect& domain,
+ GrTextureDomain::Mode modeX,
+ GrTextureDomain::Mode modeY,
+ const GrSamplerState& sampler) {
// If both domain modes happen to be ignore, it would be faster to just drop the domain logic
// entirely Technically, we could also use the simple texture effect if the domain modes agree
// with the sampler modes and the proxy is the same size as the domain. It's a lot easier for
// calling code to detect these cases and handle it themselves.
return std::unique_ptr<GrFragmentProcessor>(new GrTextureDomainEffect(
- std::move(proxy), srcAlphaType, matrix, domain, modeX, modeY, sampler));
+ std::move(proxy), srcColorType, matrix, domain, modeX, modeY, sampler));
}
GrTextureDomainEffect::GrTextureDomainEffect(sk_sp<GrTextureProxy> proxy,
- SkAlphaType srcAlphaType,
+ GrColorType srcColorType,
const SkMatrix& matrix,
const SkRect& domain,
GrTextureDomain::Mode modeX,
GrTextureDomain::Mode modeY,
const GrSamplerState& sampler)
: INHERITED(kGrTextureDomainEffect_ClassID,
- ModulateForSamplerOptFlags(
- srcAlphaType, GrTextureDomain::IsDecalSampled(sampler, modeX, modeY)))
+ ModulateForSamplerOptFlags(srcColorType,
+ GrTextureDomain::IsDecalSampled(sampler, modeX, modeY)))
, fCoordTransform(matrix, proxy.get())
, fTextureDomain(proxy.get(), domain, modeX, modeY)
, fTextureSampler(std::move(proxy), sampler) {
@@ -373,16 +374,15 @@
const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom);
bool bilerp = modeX != GrTextureDomain::kRepeat_Mode && modeY != GrTextureDomain::kRepeat_Mode ?
d->fRandom->nextBool() : false;
- auto alphaType = static_cast<SkAlphaType>(d->fRandom->nextULessThan(kLastEnum_SkAlphaType + 1));
- return GrTextureDomainEffect::Make(std::move(proxy),
- alphaType,
- matrix,
- domain,
- modeX,
- modeY,
- GrSamplerState(GrSamplerState::WrapMode::kClamp,
- bilerp ? GrSamplerState::Filter::kBilerp
- : GrSamplerState::Filter::kNearest));
+ return GrTextureDomainEffect::Make(
+ std::move(proxy),
+ d->textureProxyColorType(texIdx),
+ matrix,
+ domain,
+ modeX,
+ modeY,
+ GrSamplerState(GrSamplerState::WrapMode::kClamp, bilerp ?
+ GrSamplerState::Filter::kBilerp : GrSamplerState::Filter::kNearest));
}
#endif
diff --git a/src/gpu/effects/GrTextureDomain.h b/src/gpu/effects/GrTextureDomain.h
index ff13619..96c2d20 100644
--- a/src/gpu/effects/GrTextureDomain.h
+++ b/src/gpu/effects/GrTextureDomain.h
@@ -188,14 +188,14 @@
class GrTextureDomainEffect : public GrFragmentProcessor {
public:
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy>,
- SkAlphaType srcAlphaType,
+ GrColorType srcColorType,
const SkMatrix&,
const SkRect& domain,
GrTextureDomain::Mode mode,
GrSamplerState::Filter filterMode);
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy>,
- SkAlphaType srcAlphaType,
+ GrColorType srcColorType,
const SkMatrix&,
const SkRect& domain,
GrTextureDomain::Mode modeX,
@@ -225,7 +225,7 @@
TextureSampler fTextureSampler;
GrTextureDomainEffect(sk_sp<GrTextureProxy>,
- SkAlphaType srcAlphaType,
+ GrColorType srcColorType,
const SkMatrix&,
const SkRect& domain,
GrTextureDomain::Mode modeX,
diff --git a/src/gpu/effects/generated/GrConfigConversionEffect.h b/src/gpu/effects/generated/GrConfigConversionEffect.h
index a7825c3..acbc4cc 100644
--- a/src/gpu/effects/generated/GrConfigConversionEffect.h
+++ b/src/gpu/effects/generated/GrConfigConversionEffect.h
@@ -68,6 +68,7 @@
// calling read pixels here. Thus the pixel data will be uploaded immediately and we don't
// need to keep the pixel data alive in the proxy. Therefore the ReleaseProc is nullptr.
sk_sp<SkImage> image = SkImage::MakeFromRaster(pixmap, nullptr, nullptr);
+ GrColorType dataColorType = SkColorTypeToGrColorType(image->colorType());
sk_sp<GrTextureProxy> dataProxy = proxyProvider->createTextureProxy(
std::move(image), 1, SkBudgeted::kYes, SkBackingFit::kExact);
if (!dataProxy) {
@@ -88,7 +89,7 @@
std::unique_ptr<GrFragmentProcessor> upmToPM(
new GrConfigConversionEffect(PMConversion::kToPremul));
- paint1.addColorTextureProcessor(dataProxy, kPremul_SkAlphaType, SkMatrix::I());
+ paint1.addColorTextureProcessor(dataProxy, dataColorType, SkMatrix::I());
paint1.addColorFragmentProcessor(pmToUPM->clone());
paint1.setPorterDuffXPFactory(SkBlendMode::kSrc);
@@ -102,16 +103,14 @@
// draw
tempRTC->discard();
- paint2.addColorTextureProcessor(readRTC->asTextureProxyRef(), kUnpremul_SkAlphaType,
- SkMatrix::I());
+ paint2.addColorTextureProcessor(readRTC->asTextureProxyRef(), kColorType, SkMatrix::I());
paint2.addColorFragmentProcessor(std::move(upmToPM));
paint2.setPorterDuffXPFactory(SkBlendMode::kSrc);
tempRTC->fillRectToRect(GrNoClip(), std::move(paint2), GrAA::kNo, SkMatrix::I(), kRect,
kRect);
- paint3.addColorTextureProcessor(tempRTC->asTextureProxyRef(), kPremul_SkAlphaType,
- SkMatrix::I());
+ paint3.addColorTextureProcessor(tempRTC->asTextureProxyRef(), kColorType, SkMatrix::I());
paint3.addColorFragmentProcessor(std::move(pmToUPM));
paint3.setPorterDuffXPFactory(SkBlendMode::kSrc);
diff --git a/src/gpu/effects/generated/GrSimpleTextureEffect.cpp b/src/gpu/effects/generated/GrSimpleTextureEffect.cpp
index 189edd8..279ea5d 100644
--- a/src/gpu/effects/generated/GrSimpleTextureEffect.cpp
+++ b/src/gpu/effects/generated/GrSimpleTextureEffect.cpp
@@ -85,8 +85,7 @@
: GrSamplerState::Filter::kNearest);
const SkMatrix& matrix = GrTest::TestMatrix(testData->fRandom);
- auto alphaType =
- static_cast<SkAlphaType>(testData->fRandom->nextULessThan(kLastEnum_SkAlphaType + 1));
- return GrSimpleTextureEffect::Make(testData->textureProxy(texIdx), alphaType, matrix, params);
+ return GrSimpleTextureEffect::Make(testData->textureProxy(texIdx),
+ testData->textureProxyColorType(texIdx), matrix, params);
}
#endif
diff --git a/src/gpu/effects/generated/GrSimpleTextureEffect.h b/src/gpu/effects/generated/GrSimpleTextureEffect.h
index db087eb..d70dd56 100644
--- a/src/gpu/effects/generated/GrSimpleTextureEffect.h
+++ b/src/gpu/effects/generated/GrSimpleTextureEffect.h
@@ -17,30 +17,30 @@
class GrSimpleTextureEffect : public GrFragmentProcessor {
public:
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- SkAlphaType alphaType,
+ GrColorType srcColorType,
const SkMatrix& matrix) {
return std::unique_ptr<GrFragmentProcessor>(
- new GrSimpleTextureEffect(std::move(proxy), matrix, alphaType,
+ new GrSimpleTextureEffect(std::move(proxy), matrix, srcColorType,
GrSamplerState(GrSamplerState::WrapMode::kClamp,
GrSamplerState::Filter::kNearest)));
}
/* clamp mode */
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- SkAlphaType alphaType,
+ GrColorType srcColorType,
const SkMatrix& matrix,
GrSamplerState::Filter filter) {
return std::unique_ptr<GrFragmentProcessor>(new GrSimpleTextureEffect(
- std::move(proxy), matrix, alphaType,
+ std::move(proxy), matrix, srcColorType,
GrSamplerState(GrSamplerState::WrapMode::kClamp, filter)));
}
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- SkAlphaType alphaType,
+ GrColorType srcColorType,
const SkMatrix& matrix,
const GrSamplerState& p) {
return std::unique_ptr<GrFragmentProcessor>(
- new GrSimpleTextureEffect(std::move(proxy), matrix, alphaType, p));
+ new GrSimpleTextureEffect(std::move(proxy), matrix, srcColorType, p));
}
GrSimpleTextureEffect(const GrSimpleTextureEffect& src);
std::unique_ptr<GrFragmentProcessor> clone() const override;
@@ -50,11 +50,11 @@
SkMatrix44 matrix;
private:
- GrSimpleTextureEffect(sk_sp<GrTextureProxy> image, SkMatrix44 matrix, SkAlphaType alphaType,
+ GrSimpleTextureEffect(sk_sp<GrTextureProxy> image, SkMatrix44 matrix, GrColorType srcColorType,
GrSamplerState samplerParams)
: INHERITED(kGrSimpleTextureEffect_ClassID,
(OptimizationFlags)ModulateForSamplerOptFlags(
- alphaType,
+ srcColorType,
samplerParams.wrapModeX() ==
GrSamplerState::WrapMode::kClampToBorder ||
samplerParams.wrapModeY() ==
diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp
index bf1a676..5053b11 100644
--- a/src/gpu/ops/GrTextureOp.cpp
+++ b/src/gpu/ops/GrTextureOp.cpp
@@ -948,7 +948,7 @@
std::unique_ptr<GrDrawOp> GrTextureOp::Make(GrRecordingContext* context,
GrSurfaceProxyView proxyView,
- SkAlphaType alphaType,
+ GrColorType srcColorType,
sk_sp<GrColorSpaceXform> textureXform,
GrSamplerState::Filter filter,
const SkPMColor4f& color,
@@ -984,10 +984,10 @@
// Update domain to match what GrTextureOp would do for bilerp, but don't do any
// normalization since GrTextureDomainEffect handles that and the origin.
SkRect correctedDomain = normalize_domain(filter, {1.f, 1.f, 0.f}, domain);
- fp = GrTextureDomainEffect::Make(sk_ref_sp(proxy), alphaType, SkMatrix::I(),
+ fp = GrTextureDomainEffect::Make(sk_ref_sp(proxy), srcColorType, SkMatrix::I(),
correctedDomain, GrTextureDomain::kClamp_Mode, filter);
} else {
- fp = GrSimpleTextureEffect::Make(sk_ref_sp(proxy), alphaType, SkMatrix::I(), filter);
+ fp = GrSimpleTextureEffect::Make(sk_ref_sp(proxy), srcColorType, SkMatrix::I(), filter);
}
fp = GrColorSpaceXformEffect::Make(std::move(fp), std::move(textureXform));
paint.addColorFragmentProcessor(std::move(fp));
@@ -1192,12 +1192,11 @@
GrSurfaceProxyView proxyView(
std::move(proxy), origin,
context->priv().caps()->getTextureSwizzle(format, GrColorType::kRGBA_8888));
- auto alphaType = static_cast<SkAlphaType>(random->nextULessThan(kLastEnum_SkAlphaType + 1));
- return GrTextureOp::Make(context, std::move(proxyView), alphaType, std::move(texXform), filter,
- color, saturate, SkBlendMode::kSrcOver, aaType, aaFlags,
- GrQuad::MakeFromRect(rect, viewMatrix), GrQuad(srcRect),
- useDomain ? &srcRect : nullptr);
+ return GrTextureOp::Make(context, std::move(proxyView), GrColorType::kRGBA_8888,
+ std::move(texXform), filter, color, saturate, SkBlendMode::kSrcOver,
+ aaType, aaFlags, GrQuad::MakeFromRect(rect, viewMatrix),
+ GrQuad(srcRect), useDomain ? &srcRect : nullptr);
}
#endif
diff --git a/src/gpu/ops/GrTextureOp.h b/src/gpu/ops/GrTextureOp.h
index 1622c05..600bcc8 100644
--- a/src/gpu/ops/GrTextureOp.h
+++ b/src/gpu/ops/GrTextureOp.h
@@ -42,7 +42,7 @@
*/
static std::unique_ptr<GrDrawOp> Make(GrRecordingContext*,
GrSurfaceProxyView,
- SkAlphaType srcAlphaType,
+ GrColorType srcColorType,
sk_sp<GrColorSpaceXform>,
GrSamplerState::Filter,
const SkPMColor4f&,
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 675e920..bfa4dfd 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -93,7 +93,8 @@
GrPaint paint;
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
- paint.addColorTextureProcessor(std::move(proxy), this->alphaType(), SkMatrix::I());
+ paint.addColorTextureProcessor(std::move(proxy), SkColorTypeToGrColorType(this->colorType()),
+ SkMatrix::I());
if (xform) {
paint.addColorFragmentProcessor(std::move(xform));
}
diff --git a/src/image/SkImage_GpuBase.cpp b/src/image/SkImage_GpuBase.cpp
index 6d849c9..e19109e 100644
--- a/src/image/SkImage_GpuBase.cpp
+++ b/src/image/SkImage_GpuBase.cpp
@@ -115,10 +115,11 @@
}
sk_sp<GrSurfaceProxy> proxy = this->asTextureProxyRef(context);
+ GrColorType srcColorType = SkColorTypeToGrColorType(this->colorType());
- sk_sp<GrTextureProxy> copyProxy =
- GrSurfaceProxy::Copy(context, proxy.get(), GrMipMapped::kNo, subset,
- SkBackingFit::kExact, proxy->isBudgeted());
+ sk_sp<GrTextureProxy> copyProxy = GrSurfaceProxy::Copy(
+ context, proxy.get(), srcColorType, GrMipMapped::kNo, subset, SkBackingFit::kExact,
+ proxy->isBudgeted());
if (!copyProxy) {
return nullptr;
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index 6eb3fda..623c54e 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -104,16 +104,16 @@
sk_sp<GrTextureProxy> srcProxy = rtc->asTextureProxyRef();
if (subset) {
- srcProxy = GrSurfaceProxy::Copy(ctx, rtc->asSurfaceProxy(), rtc->mipMapped(), *subset,
- SkBackingFit::kExact, budgeted);
+ srcProxy = GrSurfaceProxy::Copy(ctx, rtc->asSurfaceProxy(), rtc->colorInfo().colorType(),
+ rtc->mipMapped(), *subset, SkBackingFit::kExact, budgeted);
} else if (!srcProxy || rtc->priv().refsWrappedObjects()) {
// If the original render target is a buffer originally created by the client, then we don't
// want to ever retarget the SkSurface at another buffer we create. Force a copy now to avoid
// copy-on-write.
SkASSERT(rtc->origin() == rtc->asSurfaceProxy()->origin());
- srcProxy = GrSurfaceProxy::Copy(ctx, rtc->asSurfaceProxy(), rtc->mipMapped(),
- SkBackingFit::kExact, budgeted);
+ srcProxy = GrSurfaceProxy::Copy(ctx, rtc->asSurfaceProxy(), rtc->colorInfo().colorType(),
+ rtc->mipMapped(), SkBackingFit::kExact, budgeted);
}
const SkImageInfo info = fDevice->imageInfo();
diff --git a/src/shaders/SkImageShader.cpp b/src/shaders/SkImageShader.cpp
index 3f3cd0c..8b30f50 100755
--- a/src/shaders/SkImageShader.cpp
+++ b/src/shaders/SkImageShader.cpp
@@ -235,7 +235,7 @@
return nullptr;
}
- SkAlphaType srcAlphaType = fImage->alphaType();
+ GrColorType srcColorType = SkColorTypeToGrColorType(fImage->colorType());
lmInverse.postScale(scaleAdjust[0], scaleAdjust[1]);
@@ -244,21 +244,21 @@
// domainX and domainY will properly apply the decal effect with the texture domain used in
// the bicubic filter if clamp to border was unsupported in hardware
static constexpr auto kDir = GrBicubicEffect::Direction::kXY;
- inner = GrBicubicEffect::Make(std::move(proxy), lmInverse, wrapModes, domainX, domainY,
- kDir, srcAlphaType);
+ inner = GrBicubicEffect::Make(std::move(proxy), srcColorType, lmInverse, wrapModes, domainX,
+ domainY, kDir, fImage->alphaType());
} else {
if (domainX != GrTextureDomain::kIgnore_Mode || domainY != GrTextureDomain::kIgnore_Mode) {
SkRect domain = GrTextureDomain::MakeTexelDomain(SkIRect::MakeSize(proxy->dimensions()),
domainX, domainY);
- inner = GrTextureDomainEffect::Make(std::move(proxy), srcAlphaType, lmInverse, domain,
+ inner = GrTextureDomainEffect::Make(std::move(proxy), srcColorType, lmInverse, domain,
domainX, domainY, samplerState);
} else {
- inner = GrSimpleTextureEffect::Make(std::move(proxy), srcAlphaType, lmInverse,
+ inner = GrSimpleTextureEffect::Make(std::move(proxy), srcColorType, lmInverse,
samplerState);
}
}
- inner = GrColorSpaceXformEffect::Make(std::move(inner), fImage->colorSpace(), srcAlphaType,
- args.fDstColorInfo->colorSpace());
+ inner = GrColorSpaceXformEffect::Make(std::move(inner), fImage->colorSpace(),
+ fImage->alphaType(), args.fDstColorInfo->colorSpace());
bool isAlphaOnly = SkColorTypeIsAlphaOnly(fImage->colorType());
if (isAlphaOnly) {
diff --git a/tests/BulkRectTest.cpp b/tests/BulkRectTest.cpp
index 4060cb5..10fcb06 100644
--- a/tests/BulkRectTest.cpp
+++ b/tests/BulkRectTest.cpp
@@ -94,7 +94,7 @@
for (int i = 0; i < requestedTotNumQuads; ++i) {
set[i].fProxyView = proxyView;
- set[i].fSrcAlphaType = kPremul_SkAlphaType;
+ set[i].fSrcColorType = GrColorType::kRGBA_8888;
set[i].fSrcRect = SkRect::MakeWH(100.0f, 100.0f);
set[i].fDstRect = SkRect::MakeWH(100.5f, 100.5f); // prevent the int non-AA optimization
set[i].fDstClipQuad = nullptr;
diff --git a/tests/CopySurfaceTest.cpp b/tests/CopySurfaceTest.cpp
index c4c9af7..aba889d 100644
--- a/tests/CopySurfaceTest.cpp
+++ b/tests/CopySurfaceTest.cpp
@@ -116,7 +116,7 @@
} else if (dRenderable == GrRenderable::kYes) {
SkASSERT(dstContext->asRenderTargetContext());
result = dstContext->asRenderTargetContext()->blitTexture(
- src.get(), srcRect, dstPoint);
+ src.get(), grColorType, srcRect, dstPoint);
}
bool expectedResult = true;
diff --git a/tests/GrMipMappedTest.cpp b/tests/GrMipMappedTest.cpp
index d911dbb..6bb6afd 100644
--- a/tests/GrMipMappedTest.cpp
+++ b/tests/GrMipMappedTest.cpp
@@ -340,7 +340,7 @@
// Create a new render target and draw 'mipmapProxy' into it using the provided 'filter'.
static std::unique_ptr<GrRenderTargetContext> draw_mipmap_into_new_render_target(
GrDrawingManager* drawingManager, GrProxyProvider* proxyProvider, GrColorType colorType,
- SkAlphaType alphaType, sk_sp<GrTextureProxy> mipmapProxy, GrSamplerState::Filter filter) {
+ sk_sp<GrTextureProxy> mipmapProxy, GrSamplerState::Filter filter) {
GrSurfaceDesc desc;
desc.fWidth = 1;
desc.fHeight = 1;
@@ -350,10 +350,9 @@
GrMipMapped::kNo, SkBackingFit::kApprox, SkBudgeted::kYes, GrProtected::kNo);
auto rtc = drawingManager->makeRenderTargetContext(
std::move(renderTarget), colorType, nullptr, nullptr, true);
- rtc->drawTexture(GrNoClip(), mipmapProxy, colorType, alphaType, filter, SkBlendMode::kSrcOver,
+ rtc->drawTexture(GrNoClip(), mipmapProxy, colorType, filter, SkBlendMode::kSrcOver,
{1,1,1,1}, SkRect::MakeWH(4, 4), SkRect::MakeWH(1,1), GrAA::kYes,
- GrQuadAAFlags::kAll, SkCanvas::kFast_SrcRectConstraint, SkMatrix::I(),
- nullptr);
+ GrQuadAAFlags::kAll, SkCanvas::kFast_SrcRectConstraint, SkMatrix::I(), nullptr);
return rtc;
}
@@ -381,7 +380,6 @@
kRGBA_8888_SkColorType, GrRenderable::kYes);
GrPixelConfig config = kRGBA_8888_GrPixelConfig;
GrColorType colorType = GrColorType::kRGBA_8888;
- SkAlphaType alphaType = kPremul_SkAlphaType;
GrDrawingManager* drawingManager = context->priv().drawingManager();
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
@@ -412,8 +410,8 @@
REPORTER_ASSERT(reporter, !mipmapProxy->mipMapsAreDirty());
// Draw the dirty mipmap texture into a render target.
- auto rtc1 = draw_mipmap_into_new_render_target(drawingManager, proxyProvider, colorType,
- alphaType, mipmapProxy, Filter::kMipMap);
+ auto rtc1 = draw_mipmap_into_new_render_target(
+ drawingManager, proxyProvider, colorType, mipmapProxy, Filter::kMipMap);
// Mipmaps should have gotten marked dirty during makeClosed, then marked clean again as
// soon as a GrTextureResolveRenderTask was inserted. The way we know they were resolved is
@@ -426,8 +424,8 @@
REPORTER_ASSERT(reporter, !mipmapProxy->mipMapsAreDirty());
// Draw the now-clean mipmap texture into a second target.
- auto rtc2 = draw_mipmap_into_new_render_target(drawingManager, proxyProvider, colorType,
- alphaType, mipmapProxy, Filter::kMipMap);
+ auto rtc2 = draw_mipmap_into_new_render_target(
+ drawingManager, proxyProvider, colorType, mipmapProxy, Filter::kMipMap);
// Make sure the mipmap texture still has the same regen task.
REPORTER_ASSERT(reporter, mipmapProxy->getLastRenderTask() == initialMipmapRegenTask);
@@ -453,8 +451,8 @@
REPORTER_ASSERT(reporter, !mipmapProxy->mipMapsAreDirty());
// Draw the dirty mipmap texture into a render target, but don't do mipmap filtering.
- rtc1 = draw_mipmap_into_new_render_target(drawingManager, proxyProvider, colorType,
- alphaType, mipmapProxy, Filter::kBilerp);
+ rtc1 = draw_mipmap_into_new_render_target(
+ drawingManager, proxyProvider, colorType, mipmapProxy, Filter::kBilerp);
// Mipmaps should have gotten marked dirty during makeClosed() when adding the dependency.
// Since the last draw did not use mips, they will not have been regenerated and should
@@ -466,8 +464,8 @@
mipmapRTC->testingOnly_PeekLastOpsTask() == mipmapProxy->getLastRenderTask());
// Draw the stil-dirty mipmap texture into a second target with mipmap filtering.
- rtc2 = draw_mipmap_into_new_render_target(drawingManager, proxyProvider, colorType,
- alphaType, mipmapProxy, Filter::kMipMap);
+ rtc2 = draw_mipmap_into_new_render_target(
+ drawingManager, proxyProvider, colorType, mipmapProxy, Filter::kMipMap);
// Make sure the mipmap texture now has a new last render task that regenerates the mips,
// and that the mipmaps are now clean.
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp
index 3a1026b..0b50d85 100644
--- a/tests/GrSurfaceTest.cpp
+++ b/tests/GrSurfaceTest.cpp
@@ -606,7 +606,7 @@
GrMipMapsStatus::kNotAllocated, GrInternalSurfaceFlags ::kNone,
SkBackingFit::kExact, budgeted, GrProtected::kNo,
GrSurfaceProxy::UseAllocator::kYes);
- rtc->drawTexture(GrNoClip(), proxy, GrColorType::kRGBA_8888, kPremul_SkAlphaType,
+ rtc->drawTexture(GrNoClip(), proxy, GrColorType::kRGBA_8888,
GrSamplerState::Filter::kNearest, SkBlendMode::kSrcOver,
SkPMColor4f(), SkRect::MakeWH(w, h), SkRect::MakeWH(w, h),
GrAA::kNo, GrQuadAAFlags::kNone, SkCanvas::kFast_SrcRectConstraint,
@@ -621,10 +621,10 @@
// This time we move the proxy into the draw.
rtc->drawTexture(GrNoClip(), std::move(proxy), GrColorType::kRGBA_8888,
- kPremul_SkAlphaType, GrSamplerState::Filter::kNearest,
- SkBlendMode::kSrcOver, SkPMColor4f(), SkRect::MakeWH(w, h),
- SkRect::MakeWH(w, h), GrAA::kNo, GrQuadAAFlags::kNone,
- SkCanvas::kFast_SrcRectConstraint, SkMatrix::I(), nullptr);
+ GrSamplerState::Filter::kNearest, SkBlendMode::kSrcOver,
+ SkPMColor4f(), SkRect::MakeWH(w, h), SkRect::MakeWH(w, h),
+ GrAA::kNo, GrQuadAAFlags::kNone, SkCanvas::kFast_SrcRectConstraint,
+ SkMatrix::I(), nullptr);
REPORTER_ASSERT(reporter, idleIDs.find(2) == idleIDs.end());
context->flush();
context->priv().getGpu()->testingOnly_flushGpuAndSync();
@@ -667,7 +667,7 @@
auto proxy = context->priv().proxyProvider()->testingOnly_createWrapped(
texture, GrColorType::kRGBA_8888, kTopLeft_GrSurfaceOrigin);
rtc->drawTexture(
- GrNoClip(), proxy, GrColorType::kRGBA_8888, kPremul_SkAlphaType,
+ GrNoClip(), proxy, GrColorType::kRGBA_8888,
GrSamplerState::Filter::kNearest, SkBlendMode::kSrcOver,
SkPMColor4f(), SkRect::MakeWH(w, h), SkRect::MakeWH(w, h),
GrAA::kNo, GrQuadAAFlags::kNone,
diff --git a/tests/MtlCopySurfaceTest.mm b/tests/MtlCopySurfaceTest.mm
index cc89782..01098b7 100644
--- a/tests/MtlCopySurfaceTest.mm
+++ b/tests/MtlCopySurfaceTest.mm
@@ -46,6 +46,7 @@
kTopLeft_GrSurfaceOrigin);
sk_sp<GrTextureProxy> dstProxy = GrSurfaceProxy::Copy(context, srcProxy.get(),
+ GrColorType::kBGRA_8888,
GrMipMapped::kNo,
SkBackingFit::kExact,
SkBudgeted::kYes);
diff --git a/tests/OnFlushCallbackTest.cpp b/tests/OnFlushCallbackTest.cpp
index 62a61bb..3de06d5 100644
--- a/tests/OnFlushCallbackTest.cpp
+++ b/tests/OnFlushCallbackTest.cpp
@@ -435,7 +435,7 @@
// This creates an off-screen rendertarget whose ops which eventually pull from the atlas.
static sk_sp<GrTextureProxy> make_upstream_image(GrContext* context, AtlasObject* object, int start,
sk_sp<GrTextureProxy> atlasProxy,
- SkAlphaType atlasAlphaType) {
+ GrColorType atlasColorType) {
auto rtc = context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox,
3* kDrawnTileSize,
kDrawnTileSize,
@@ -447,7 +447,7 @@
for (int i = 0; i < 3; ++i) {
SkRect r = SkRect::MakeXYWH(i*kDrawnTileSize, 0, kDrawnTileSize, kDrawnTileSize);
- auto fp = GrSimpleTextureEffect::Make(atlasProxy, atlasAlphaType, SkMatrix::I());
+ auto fp = GrSimpleTextureEffect::Make(atlasProxy, atlasColorType, SkMatrix::I());
GrPaint paint;
paint.addColorFragmentProcessor(std::move(fp));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
@@ -545,9 +545,10 @@
sk_sp<GrTextureProxy> proxies[kNumProxies];
for (int i = 0; i < kNumProxies; ++i) {
- proxies[i] = make_upstream_image(
- context, &object, i*3,
- object.getAtlasProxy(proxyProvider, context->priv().caps()), kPremul_SkAlphaType);
+ proxies[i] = make_upstream_image(context, &object, i*3,
+ object.getAtlasProxy(proxyProvider,
+ context->priv().caps()),
+ GrColorType::kRGBA_8888);
}
static const int kFinalWidth = 6*kDrawnTileSize;
@@ -565,7 +566,7 @@
SkMatrix t = SkMatrix::MakeTrans(-i*3*kDrawnTileSize, 0);
GrPaint paint;
- auto fp = GrSimpleTextureEffect::Make(std::move(proxies[i]), kPremul_SkAlphaType, t);
+ auto fp = GrSimpleTextureEffect::Make(std::move(proxies[i]), GrColorType::kRGBA_8888, t);
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
paint.addColorFragmentProcessor(std::move(fp));
diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp
index 978f7ef..7171868 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -231,22 +231,22 @@
GrRenderTargetContext* rtc,
std::unique_ptr<GrFragmentProcessor> fp,
sk_sp<GrTextureProxy> inputDataProxy,
- SkAlphaType inputAlphaType) {
+ GrColorType inputColorType) {
GrPaint paint;
- paint.addColorTextureProcessor(std::move(inputDataProxy), inputAlphaType, SkMatrix::I());
+ paint.addColorTextureProcessor(std::move(inputDataProxy), inputColorType, SkMatrix::I());
paint.addColorFragmentProcessor(std::move(fp));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
auto op = GrFillRectOp::MakeNonAARect(context, std::move(paint), SkMatrix::I(),
SkRect::MakeWH(rtc->width(), rtc->height()));
- rtc->priv().testingOnly_addDrawOp(std::move(op));
+ rtc->addDrawOp(GrNoClip(), std::move(op));
}
// This assumes that the output buffer will be the same size as inputDataProxy
void render_fp(GrContext* context, GrRenderTargetContext* rtc, GrFragmentProcessor* fp,
- sk_sp<GrTextureProxy> inputDataProxy, SkAlphaType inputAlphaType, GrColor* buffer) {
+ sk_sp<GrTextureProxy> inputDataProxy, GrColorType inputColorType, GrColor* buffer) {
// test_draw_op needs to take ownership of an FP, so give it a clone that it can own
- test_draw_op(context, rtc, fp->clone(), inputDataProxy, inputAlphaType);
+ test_draw_op(context, rtc, fp->clone(), inputDataProxy, inputColorType);
memset(buffer, 0x0, sizeof(GrColor) * inputDataProxy->width() * inputDataProxy->height());
rtc->readPixels(SkImageInfo::Make(inputDataProxy->dimensions(), kRGBA_8888_SkColorType,
kPremul_SkAlphaType),
@@ -257,7 +257,8 @@
bool init_test_textures(GrResourceProvider* resourceProvider,
GrProxyProvider* proxyProvider,
SkRandom* random,
- sk_sp<GrTextureProxy> proxies[2]) {
+ sk_sp<GrTextureProxy> proxies[2],
+ GrColorType proxyColorTypes[2]) {
static const int kTestTextureSize = 256;
{
@@ -277,6 +278,7 @@
proxies[0] =
proxyProvider->createTextureProxy(img, 1, SkBudgeted::kYes, SkBackingFit::kExact);
proxies[0]->instantiate(resourceProvider);
+ proxyColorTypes[0] = GrColorType::kRGBA_8888;
}
{
@@ -295,6 +297,7 @@
proxies[1] =
proxyProvider->createTextureProxy(img, 1, SkBudgeted::kYes, SkBackingFit::kExact);
proxies[1]->instantiate(resourceProvider);
+ proxyColorTypes[1] = GrColorType::kAlpha_8;
}
return proxies[0] && proxies[1];
@@ -428,11 +431,12 @@
SkBackingFit::kExact, kRenderSize, kRenderSize, GrColorType::kRGBA_8888, nullptr);
sk_sp<GrTextureProxy> proxies[2];
- if (!init_test_textures(resourceProvider, proxyProvider, &random, proxies)) {
+ GrColorType proxyColorTypes[2];
+ if (!init_test_textures(resourceProvider, proxyProvider, &random, proxies, proxyColorTypes)) {
ERRORF(reporter, "Could not create test textures");
return;
}
- GrProcessorTestData testData(&random, context, rtc.get(), proxies);
+ GrProcessorTestData testData(&random, context, rtc.get(), proxies, proxyColorTypes);
// Coverage optimization uses three frames with a linearly transformed input texture. The first
// frame has no offset, second frames add .2 and .4, which should then be present as a fixed
@@ -479,14 +483,14 @@
if (fp->compatibleWithCoverageAsAlpha()) {
// 2nd and 3rd frames are only used when checking coverage optimization
- render_fp(context, rtc.get(), fp.get(), inputTexture2, kPremul_SkAlphaType,
+ render_fp(context, rtc.get(), fp.get(), inputTexture2, GrColorType::kRGBA_8888,
readData2.get());
- render_fp(context, rtc.get(), fp.get(), inputTexture3, kPremul_SkAlphaType,
+ render_fp(context, rtc.get(), fp.get(), inputTexture3, GrColorType::kRGBA_8888,
readData3.get());
}
// Draw base frame last so that rtc holds the original FP behavior if we need to
// dump the image to the log.
- render_fp(context, rtc.get(), fp.get(), inputTexture1, kPremul_SkAlphaType,
+ render_fp(context, rtc.get(), fp.get(), inputTexture1, GrColorType::kRGBA_8888,
readData1.get());
if (0) { // Useful to see what FPs are being tested.
@@ -665,11 +669,12 @@
SkBackingFit::kExact, kRenderSize, kRenderSize, GrColorType::kRGBA_8888, nullptr);
sk_sp<GrTextureProxy> proxies[2];
- if (!init_test_textures(resourceProvider, proxyProvider, &random, proxies)) {
+ GrColorType proxyColorTypes[2];
+ if (!init_test_textures(resourceProvider, proxyProvider, &random, proxies, proxyColorTypes)) {
ERRORF(reporter, "Could not create test textures");
return;
}
- GrProcessorTestData testData(&random, context, rtc.get(), proxies);
+ GrProcessorTestData testData(&random, context, rtc.get(), proxies, proxyColorTypes);
auto inputTexture = make_input_texture(proxyProvider, kRenderSize, kRenderSize, 0.0f);
std::unique_ptr<GrColor[]> readData1(new GrColor[kRenderSize * kRenderSize]);
@@ -709,11 +714,11 @@
REPORTER_ASSERT(reporter, fp->numChildProcessors() == clone->numChildProcessors());
REPORTER_ASSERT(reporter, fp->usesLocalCoords() == clone->usesLocalCoords());
// Draw with original and read back the results.
- render_fp(context, rtc.get(), fp.get(), inputTexture, kPremul_SkAlphaType,
+ render_fp(context, rtc.get(), fp.get(), inputTexture, GrColorType::kRGBA_8888,
readData1.get());
// Draw with clone and read back the results.
- render_fp(context, rtc.get(), clone.get(), inputTexture, kPremul_SkAlphaType,
+ render_fp(context, rtc.get(), clone.get(), inputTexture, GrColorType::kRGBA_8888,
readData2.get());
// Check that the results are the same.
diff --git a/tests/ProgramsTest.cpp b/tests/ProgramsTest.cpp
index d12ba0d..5225009 100644
--- a/tests/ProgramsTest.cpp
+++ b/tests/ProgramsTest.cpp
@@ -261,6 +261,7 @@
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
sk_sp<GrTextureProxy> proxies[2];
+ GrColorType proxyColorTypes[2];
// setup dummy textures
GrMipMapped mipMapped = GrMipMapped(context->priv().caps()->mipMapSupport());
@@ -276,6 +277,7 @@
kBottomLeft_GrSurfaceOrigin, mipMapped,
SkBackingFit::kExact, SkBudgeted::kNo,
GrProtected::kNo, GrInternalSurfaceFlags::kNone);
+ proxyColorTypes[0] = GrColorType::kRGBA_8888;
}
{
GrSurfaceDesc dummyDesc;
@@ -289,6 +291,7 @@
kTopLeft_GrSurfaceOrigin, mipMapped,
SkBackingFit::kExact, SkBudgeted::kNo,
GrProtected::kNo, GrInternalSurfaceFlags::kNone);
+ proxyColorTypes[1] = GrColorType::kAlpha_8;
}
if (!proxies[0] || !proxies[1]) {
@@ -296,6 +299,9 @@
return false;
}
+ // dummy scissor state
+ GrScissorState scissor;
+
SkRandom random;
static const int NUM_TESTS = 1024;
for (int t = 0; t < NUM_TESTS; t++) {
@@ -308,7 +314,8 @@
}
GrPaint paint;
- GrProcessorTestData ptd(&random, context, renderTargetContext.get(), proxies);
+ GrProcessorTestData ptd(&random, context, renderTargetContext.get(), proxies,
+ proxyColorTypes);
set_random_color_coverage_stages(&paint, &ptd, maxStages, maxLevels);
set_random_xpf(&paint, &ptd);
GrDrawRandomOp(&random, renderTargetContext.get(), std::move(paint));
@@ -333,7 +340,8 @@
for (int i = 0; i < fpFactoryCnt; ++i) {
// Since FP factories internally randomize, call each 10 times.
for (int j = 0; j < 10; ++j) {
- GrProcessorTestData ptd(&random, context, renderTargetContext.get(), proxies);
+ GrProcessorTestData ptd(&random, context, renderTargetContext.get(), proxies,
+ proxyColorTypes);
GrPaint paint;
paint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index 547ba24..886cff3 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -29,7 +29,7 @@
// skbug.com/5932
static void test_basic_draw_as_src(skiatest::Reporter* reporter, GrContext* context,
sk_sp<GrTextureProxy> rectProxy, GrColorType colorType,
- SkAlphaType alphaType, uint32_t expectedPixelValues[]) {
+ uint32_t expectedPixelValues[]) {
auto rtContext = context->priv().makeDeferredRenderTargetContext(
SkBackingFit::kExact, rectProxy->width(), rectProxy->height(), colorType, nullptr);
for (auto filter : {GrSamplerState::Filter::kNearest,
@@ -37,7 +37,7 @@
GrSamplerState::Filter::kMipMap}) {
rtContext->clear(nullptr, SkPMColor4f::FromBytes_RGBA(0xDDCCBBAA),
GrRenderTargetContext::CanClearFullscreen::kYes);
- auto fp = GrSimpleTextureEffect::Make(rectProxy, alphaType, SkMatrix::I(), filter);
+ auto fp = GrSimpleTextureEffect::Make(rectProxy, colorType, SkMatrix::I(), filter);
GrPaint paint;
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
paint.addColorFragmentProcessor(std::move(fp));
@@ -185,8 +185,7 @@
SkASSERT(rectProxy->hasRestrictedSampling());
SkASSERT(rectProxy->peekTexture()->texturePriv().hasRestrictedSampling());
- test_basic_draw_as_src(reporter, context, rectProxy, GrColorType::kRGBA_8888,
- kPremul_SkAlphaType, refPixels);
+ test_basic_draw_as_src(reporter, context, rectProxy, GrColorType::kRGBA_8888, refPixels);
// Test copy to both a texture and RT
TestCopyFromSurface(reporter, context, rectProxy.get(), GrColorType::kRGBA_8888, refPixels,
diff --git a/tests/TestUtils.cpp b/tests/TestUtils.cpp
index f7c692d..f9996dc 100644
--- a/tests/TestUtils.cpp
+++ b/tests/TestUtils.cpp
@@ -81,8 +81,9 @@
GrColorType colorType,
uint32_t expectedPixelValues[],
const char* testName) {
- sk_sp<GrTextureProxy> dstProxy = GrSurfaceProxy::Copy(context, proxy, GrMipMapped::kNo,
- SkBackingFit::kExact, SkBudgeted::kYes);
+ sk_sp<GrTextureProxy> dstProxy = GrSurfaceProxy::Copy(context, proxy, colorType,
+ GrMipMapped::kNo, SkBackingFit::kExact,
+ SkBudgeted::kYes);
SkASSERT(dstProxy);
auto dstContext = context->priv().makeWrappedSurfaceContext(std::move(dstProxy), colorType,