Revert "Revert "Make FP optimizations helpers use SkAlphaType not GrColorType""
This reverts commit 078e8faa26d8b1f33a92e57f587be011150d1776.
Change-Id: I67b2970584db5a1afbf9928b77c5444947ef71a3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255897
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 2a48caf..2a2f214 100644
--- a/gm/clockwise.cpp
+++ b/gm/clockwise.cpp
@@ -253,8 +253,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,
- GrSamplerState::Filter::kNearest, SkBlendMode::kSrcOver,
- SK_PMColor4fWHITE, {0, 0, 100, 200},
+ rtc->colorInfo().alphaType(), 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);
@@ -269,8 +269,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,
- GrSamplerState::Filter::kNearest, SkBlendMode::kSrcOver,
- SK_PMColor4fWHITE, {0, 0, 100, 200},
+ rtc->colorInfo().alphaType(), 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 212fd25..36913cc 100644
--- a/gm/fpcoordinateoverride.cpp
+++ b/gm/fpcoordinateoverride.cpp
@@ -83,10 +83,9 @@
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, srcColorType,
- SkMatrix());
+ std::unique_ptr<GrFragmentProcessor> imgFP =
+ GrSimpleTextureEffect::Make(texture, bmp.alphaType(), 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 08895f3..023e369 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(),
- SkColorTypeToGrColorType(info.colorType()), mipMapped,
+ return GrSurfaceProxy::Copy(
+ fCtx.get(), fProxy.get(), 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 1c97b7f..441cda3 100644
--- a/gm/samplelocations.cpp
+++ b/gm/samplelocations.cpp
@@ -357,12 +357,12 @@
SkMatrix::I(), SkRect::MakeWH(200, 200));
// Copy offscreen texture to canvas.
- 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);
+ 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);
return skiagm::DrawResult::kOk;
}
diff --git a/gm/texturedomaineffect.cpp b/gm/texturedomaineffect.cpp
index d1c717e..924e3b5 100644
--- a/gm/texturedomaineffect.cpp
+++ b/gm/texturedomaineffect.cpp
@@ -124,10 +124,9 @@
// Repeat mode doesn't produce correct results with bilerp filtering
continue;
}
- auto ct = SkColorTypeToGrColorType(fBitmap.colorType());
SkRect domainRect = GrTextureDomain::MakeTexelDomain(texelDomains[d], mode);
auto fp1 = GrTextureDomainEffect::Make(
- proxy, ct, textureMatrices[tm], domainRect, mode, fFilter);
+ proxy, fBitmap.alphaType(), textureMatrices[tm], domainRect, mode, fFilter);
if (!fp1) {
continue;
}
diff --git a/samplecode/SampleCCPRGeometry.cpp b/samplecode/SampleCCPRGeometry.cpp
index 2f70ff2..e8c6f2e 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().colorType(), SkMatrix::I()));
+ ccbuff->colorInfo().alphaType(), 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 d385af8..9a4b8e2 100644
--- a/src/core/SkBlurMF.cpp
+++ b/src/core/SkBlurMF.cpp
@@ -901,9 +901,8 @@
if (!isNormalBlur) {
GrPaint paint;
// Blend pathTexture over blurTexture.
- paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(std::move(srcProxy),
- srcColorType,
- SkMatrix::I()));
+ paint.addCoverageFragmentProcessor(
+ GrSimpleTextureEffect::Make(std::move(srcProxy), srcAlphaType, 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 c863908..c5ee947 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,
- GrColorType srcColorType,
+ SkAlphaType srcAlphaType,
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), srcColorType, direction, radius, sigma, mode, bounds));
+ std::move(proxy), srcAlphaType, direction, radius, sigma, mode, bounds));
paint.addColorFragmentProcessor(std::move(conv));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
SkMatrix localMatrix = SkMatrix::MakeTrans(-SkIntToScalar(srcOffset.x()),
@@ -152,6 +152,7 @@
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,
@@ -190,7 +191,7 @@
if (GrTextureDomain::kIgnore_Mode == mode) {
*contentRect = dstRect;
convolve_gaussian_1d(dstRenderTargetContext.get(), clip, dstRect, netOffset,
- std::move(srcProxy), srcColorType, direction, radius, sigma,
+ std::move(srcProxy), srcAlphaType, direction, radius, sigma,
GrTextureDomain::kIgnore_Mode, bounds);
return dstRenderTargetContext;
}
@@ -245,16 +246,16 @@
if (midRect.isEmpty()) {
// Blur radius covers srcBounds; use bounds over entire draw
convolve_gaussian_1d(dstRenderTargetContext.get(), clip, dstRect, netOffset,
- std::move(srcProxy), srcColorType, direction, radius, sigma, mode,
+ std::move(srcProxy), srcAlphaType, direction, radius, sigma, mode,
bounds);
} else {
// Draw right and left margins with bounds; middle without.
- 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, 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, midRect, netOffset,
- std::move(srcProxy), srcColorType, direction, radius, sigma,
+ std::move(srcProxy), srcAlphaType, direction, radius, sigma,
GrTextureDomain::kIgnore_Mode, bounds);
}
@@ -267,6 +268,7 @@
static sk_sp<GrTextureProxy> decimate(GrRecordingContext* context,
sk_sp<GrTextureProxy> srcProxy,
GrColorType srcColorType,
+ SkAlphaType srcAlphaType,
const SkIPoint& proxyOffset,
SkIPoint* srcOffset,
SkIRect* contentRect,
@@ -336,7 +338,7 @@
}
domain.offset(proxyOffset.x(), proxyOffset.y());
auto fp = GrTextureDomainEffect::Make(std::move(srcProxy),
- srcColorType,
+ srcAlphaType,
SkMatrix::I(),
domain,
modeForScaling,
@@ -347,7 +349,7 @@
// back in GaussianBlur
srcOffset->set(0, 0);
} else {
- paint.addColorTextureProcessor(std::move(srcProxy), srcColorType, SkMatrix::I(),
+ paint.addColorTextureProcessor(std::move(srcProxy), srcAlphaType, SkMatrix::I(),
GrSamplerState::ClampBilerp());
}
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
@@ -391,6 +393,7 @@
}
GrColorType srcColorType = srcRenderTargetContext->colorInfo().colorType();
+ SkAlphaType srcAlphaType = srcRenderTargetContext->colorInfo().alphaType();
srcRenderTargetContext = nullptr; // no longer needed
@@ -404,7 +407,7 @@
GrPaint paint;
SkRect domain = GrTextureDomain::MakeTexelDomain(localSrcBounds, GrTextureDomain::kClamp_Mode,
GrTextureDomain::kClamp_Mode);
- auto fp = GrTextureDomainEffect::Make(std::move(srcProxy), srcColorType, SkMatrix::I(), domain,
+ auto fp = GrTextureDomainEffect::Make(std::move(srcProxy), srcAlphaType, SkMatrix::I(), domain,
GrTextureDomain::kClamp_Mode,
GrSamplerState::Filter::kBilerp);
paint.addColorFragmentProcessor(std::move(fp));
@@ -426,7 +429,7 @@
std::unique_ptr<GrRenderTargetContext> GaussianBlur(GrRecordingContext* context,
sk_sp<GrTextureProxy> srcProxy,
GrColorType srcColorType,
- SkAlphaType srcAT,
+ SkAlphaType srcAlphaType,
const SkIPoint& proxyOffset,
sk_sp<SkColorSpace> colorSpace,
const SkIRect& dstBounds,
@@ -477,9 +480,10 @@
GrTextureDomain::Mode currDomainMode = mode;
if (scaleFactorX > 1 || scaleFactorY > 1) {
- srcProxy = decimate(context, std::move(srcProxy), srcColorType, localProxyOffset,
- &srcOffset, &localSrcBounds, scaleFactorX, scaleFactorY, radiusX,
- radiusY, currDomainMode, finalW, finalH, colorSpace);
+ srcProxy =
+ decimate(context, std::move(srcProxy), srcColorType, srcAlphaType, localProxyOffset,
+ &srcOffset, &localSrcBounds, scaleFactorX, scaleFactorY, radiusX, radiusY,
+ currDomainMode, finalW, finalH, colorSpace);
if (!srcProxy) {
return nullptr;
}
@@ -497,9 +501,9 @@
scale_irect_roundout(&srcRect, 1.0f / scaleFactorX, 1.0f / scaleFactorY);
if (sigmaX > 0.0f) {
dstRenderTargetContext = convolve_gaussian(
- context, std::move(srcProxy), srcColorType, localProxyOffset, srcRect, srcOffset,
- Direction::kX, radiusX, sigmaX, &localSrcBounds, currDomainMode, finalW, finalH,
- colorSpace, xFit);
+ context, std::move(srcProxy), srcColorType, srcAlphaType, localProxyOffset, srcRect,
+ srcOffset, Direction::kX, radiusX, sigmaX, &localSrcBounds, currDomainMode, finalW,
+ finalH, colorSpace, xFit);
if (!dstRenderTargetContext) {
return nullptr;
}
@@ -521,9 +525,9 @@
if (sigmaY > 0.0f) {
dstRenderTargetContext = convolve_gaussian(
- context, std::move(srcProxy), srcColorType, localProxyOffset, srcRect, srcOffset,
- Direction::kY, radiusY, sigmaY, &localSrcBounds, currDomainMode, finalW, finalH,
- colorSpace, yFit);
+ context, std::move(srcProxy), srcColorType, srcAlphaType, 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 b0bface..7c3419a 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -499,9 +499,8 @@
}
sk_sp<GrTextureProxy> subsetProxy(
- GrSurfaceProxy::Copy(fContext, fTextureProxy.get(), fColorType,
- GrMipMapped::kNo, *subset, SkBackingFit::kExact,
- SkBudgeted::kYes));
+ GrSurfaceProxy::Copy(fContext, fTextureProxy.get(), 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 a059b65..c097347 100644
--- a/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
+++ b/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
@@ -166,10 +166,9 @@
return nullptr;
}
- GrColorType srcColorType = SkColorTypeToGrColorType(input->colorType());
- auto textureFP = GrSimpleTextureEffect::Make(std::move(inputProxy), srcColorType,
- SkMatrix::MakeTrans(input->subset().x(),
- input->subset().y()));
+ auto textureFP = GrSimpleTextureEffect::Make(
+ std::move(inputProxy), input->alphaType(),
+ 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 2b1aaaf..a4306bd 100644
--- a/src/effects/imagefilters/SkArithmeticImageFilter.cpp
+++ b/src/effects/imagefilters/SkArithmeticImageFilter.cpp
@@ -353,9 +353,8 @@
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), bgColorType, backgroundMatrix,
+ std::move(backgroundProxy), background->alphaType(), backgroundMatrix,
GrTextureDomain::MakeTexelDomain(bgSubset, GrTextureDomain::kDecal_Mode),
GrTextureDomain::kDecal_Mode, GrSamplerState::Filter::kNearest);
bgFP = GrColorSpaceXformEffect::Make(std::move(bgFP), background->getColorSpace(),
@@ -371,9 +370,8 @@
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), fgColorType, foregroundMatrix,
+ std::move(foregroundProxy), foreground->alphaType(), 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 eb834a3..b039089 100644
--- a/src/effects/imagefilters/SkMorphologyImageFilter.cpp
+++ b/src/effects/imagefilters/SkMorphologyImageFilter.cpp
@@ -210,20 +210,18 @@
class GrMorphologyEffect : public GrFragmentProcessor {
public:
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- GrColorType srcColorType,
- MorphDirection dir,
+ SkAlphaType srcAlphaType, MorphDirection dir,
int radius, MorphType type) {
return std::unique_ptr<GrFragmentProcessor>(
- new GrMorphologyEffect(std::move(proxy), srcColorType, dir, radius, type, nullptr));
+ new GrMorphologyEffect(std::move(proxy), srcAlphaType, dir, radius, type, nullptr));
}
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- GrColorType srcColorType,
- MorphDirection dir,
+ SkAlphaType srcAlphaType, MorphDirection dir,
int radius, MorphType type,
const float bounds[2]) {
return std::unique_ptr<GrFragmentProcessor>(
- new GrMorphologyEffect(std::move(proxy), srcColorType, dir, radius, type, bounds));
+ new GrMorphologyEffect(std::move(proxy), srcAlphaType, dir, radius, type, bounds));
}
MorphType type() const { return fType; }
@@ -256,7 +254,7 @@
const TextureSampler& onTextureSampler(int i) const override { return fTextureSampler; }
- GrMorphologyEffect(sk_sp<GrTextureProxy>, GrColorType srcColorType, MorphDirection, int radius,
+ GrMorphologyEffect(sk_sp<GrTextureProxy>, SkAlphaType srcAlphaType, MorphDirection, int radius,
MorphType, const float range[2]);
explicit GrMorphologyEffect(const GrMorphologyEffect&);
@@ -395,13 +393,12 @@
///////////////////////////////////////////////////////////////////////////////
GrMorphologyEffect::GrMorphologyEffect(sk_sp<GrTextureProxy> proxy,
- GrColorType srcColorType,
+ SkAlphaType srcAlphaType,
MorphDirection direction,
int radius,
MorphType type,
const float range[2])
- : INHERITED(kGrMorphologyEffect_ClassID,
- ModulateForClampedSamplerOptFlags(srcColorType))
+ : INHERITED(kGrMorphologyEffect_ClassID, ModulateForClampedSamplerOptFlags(srcAlphaType))
, fCoordTransform(proxy.get())
, fTextureSampler(std::move(proxy))
, fDirection(direction)
@@ -465,16 +462,16 @@
static const int kMaxRadius = 10;
int radius = d->fRandom->nextRangeU(1, kMaxRadius);
MorphType type = d->fRandom->nextBool() ? MorphType::kErode : MorphType::kDilate;
-
- return GrMorphologyEffect::Make(std::move(proxy), d->textureProxyColorType(texIdx), dir, radius,
- type);
+ auto alphaType = static_cast<SkAlphaType>(
+ d->fRandom->nextRangeU(kUnknown_SkAlphaType + 1, kLastEnum_SkAlphaType));
+ return GrMorphologyEffect::Make(std::move(proxy), alphaType, dir, radius, type);
}
#endif
static void apply_morphology_rect(GrRenderTargetContext* renderTargetContext,
const GrClip& clip,
sk_sp<GrTextureProxy> proxy,
- GrColorType srcColorType,
+ SkAlphaType srcAlphaType,
const SkIRect& srcRect,
const SkIRect& dstRect,
int radius,
@@ -482,9 +479,8 @@
const float bounds[2],
MorphDirection direction) {
GrPaint paint;
- paint.addColorFragmentProcessor(GrMorphologyEffect::Make(std::move(proxy), srcColorType,
- direction, radius, morphType,
- bounds));
+ paint.addColorFragmentProcessor(GrMorphologyEffect::Make(std::move(proxy), srcAlphaType,
+ direction, radius, morphType, bounds));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
renderTargetContext->fillRectToRect(clip, std::move(paint), GrAA::kNo, SkMatrix::I(),
SkRect::Make(dstRect), SkRect::Make(srcRect));
@@ -493,15 +489,15 @@
static void apply_morphology_rect_no_bounds(GrRenderTargetContext* renderTargetContext,
const GrClip& clip,
sk_sp<GrTextureProxy> proxy,
- GrColorType srcColorType,
+ SkAlphaType srcAlphaType,
const SkIRect& srcRect,
const SkIRect& dstRect,
int radius,
MorphType morphType,
MorphDirection direction) {
GrPaint paint;
- paint.addColorFragmentProcessor(GrMorphologyEffect::Make(std::move(proxy), srcColorType,
- direction, radius, morphType));
+ paint.addColorFragmentProcessor(
+ GrMorphologyEffect::Make(std::move(proxy), srcAlphaType, direction, radius, morphType));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
renderTargetContext->fillRectToRect(clip, std::move(paint), GrAA::kNo, SkMatrix::I(),
SkRect::Make(dstRect), SkRect::Make(srcRect));
@@ -510,7 +506,7 @@
static void apply_morphology_pass(GrRenderTargetContext* renderTargetContext,
const GrClip& clip,
sk_sp<GrTextureProxy> textureProxy,
- GrColorType srcColorType,
+ SkAlphaType srcAlphaType,
const SkIRect& srcRect,
const SkIRect& dstRect,
int radius,
@@ -541,16 +537,16 @@
}
if (middleSrcRect.width() <= 0) {
// radius covers srcRect; use bounds over entire draw
- apply_morphology_rect(renderTargetContext, clip, std::move(textureProxy), srcColorType,
+ apply_morphology_rect(renderTargetContext, clip, std::move(textureProxy), srcAlphaType,
srcRect, dstRect, radius, morphType, bounds, direction);
} else {
// Draw upper and lower margins with bounds; middle without.
- 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(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_no_bounds(renderTargetContext, clip, std::move(textureProxy),
- srcColorType, middleSrcRect, middleDstRect, radius,
+ srcAlphaType, middleSrcRect, middleDstRect, radius,
morphType, direction);
}
}
@@ -559,7 +555,7 @@
GrRecordingContext* context, SkSpecialImage* input, const SkIRect& rect,
MorphType morphType, SkISize radius, const SkImageFilter_Base::Context& ctx) {
sk_sp<GrTextureProxy> srcTexture(input->asTextureProxyRef(context));
- GrColorType srcColorType = SkColorTypeToGrColorType(input->colorType());
+ SkAlphaType srcAlphaType = input->alphaType();
SkASSERT(srcTexture);
sk_sp<SkColorSpace> colorSpace = ctx.refColorSpace();
GrColorType colorType = ctx.grColorType();
@@ -590,7 +586,7 @@
return nullptr;
}
- apply_morphology_pass(dstRTContext.get(), clip, std::move(srcTexture), srcColorType,
+ apply_morphology_pass(dstRTContext.get(), clip, std::move(srcTexture), srcAlphaType,
srcRect, dstRect, radius.fWidth, morphType, MorphDirection::kX);
SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom,
dstRect.width(), radius.fHeight);
@@ -599,7 +595,7 @@
dstRTContext->clear(&clearRect, clearColor, GrRenderTargetContext::CanClearFullscreen::kNo);
srcTexture = dstRTContext->asTextureProxyRef();
- srcColorType = colorType;
+ srcAlphaType = dstRTContext->colorInfo().alphaType();
srcRect = dstRect;
}
if (radius.fHeight > 0) {
@@ -619,7 +615,7 @@
return nullptr;
}
- apply_morphology_pass(dstRTContext.get(), clip, std::move(srcTexture), srcColorType,
+ apply_morphology_pass(dstRTContext.get(), clip, std::move(srcTexture), srcAlphaType,
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 14cf52f..df4847e 100644
--- a/src/effects/imagefilters/SkXfermodeImageFilter.cpp
+++ b/src/effects/imagefilters/SkXfermodeImageFilter.cpp
@@ -266,11 +266,10 @@
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), bgColorType, bgMatrix,
- GrTextureDomain::MakeTexelDomain(bgSubset, GrTextureDomain::kDecal_Mode),
- GrTextureDomain::kDecal_Mode, GrSamplerState::Filter::kNearest);
+ std::move(backgroundProxy), background->alphaType(), 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());
@@ -284,9 +283,8 @@
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), fgColorType, fgMatrix,
+ std::move(foregroundProxy), foreground->alphaType(), 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 34b9c07..dd97f03 100644
--- a/src/gpu/GrAHardwareBufferImageGenerator.cpp
+++ b/src/gpu/GrAHardwareBufferImageGenerator.cpp
@@ -214,9 +214,8 @@
GrMipMapped mipMapped = willNeedMipMaps ? GrMipMapped::kYes : GrMipMapped::kNo;
- GrColorType grColorType = SkColorTypeToGrColorType(this->getInfo().colorType());
- return GrSurfaceProxy::Copy(context, texProxy.get(), grColorType, mipMapped, subset,
- SkBackingFit::kExact, SkBudgeted::kYes);
+ return GrSurfaceProxy::Copy(context, texProxy.get(), 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 33b26e4..5ab6e6c 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(), grColorType, mipMapped, subset,
- SkBackingFit::kExact, SkBudgeted::kYes);
+ return GrSurfaceProxy::Copy(context, proxy.get(), mipMapped, subset, SkBackingFit::kExact,
+ SkBudgeted::kYes);
}
}
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index eae8224..e3f9260 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -38,8 +38,7 @@
const SkMatrix& viewMatrix,
const SkIRect& maskRect,
GrPaint&& paint,
- sk_sp<GrTextureProxy> mask,
- GrColorType maskColorType) {
+ sk_sp<GrTextureProxy> mask) {
SkMatrix inverse;
if (!viewMatrix.invert(&inverse)) {
return false;
@@ -48,8 +47,8 @@
SkMatrix matrix = SkMatrix::MakeTrans(-SkIntToScalar(maskRect.fLeft),
-SkIntToScalar(maskRect.fTop));
matrix.preConcat(viewMatrix);
- paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(std::move(mask), maskColorType,
- matrix));
+ paint.addCoverageFragmentProcessor(
+ GrSimpleTextureEffect::Make(std::move(mask), kUnknown_SkAlphaType, matrix));
renderTargetContext->fillRectWithLocalMatrix(clip, std::move(paint), GrAA::kNo, SkMatrix::I(),
SkRect::Make(maskRect), inverse);
@@ -166,8 +165,8 @@
}
}
- return draw_mask(renderTargetContext, clipData, viewMatrix, drawRect,
- std::move(paint), std::move(filteredMask), GrColorType::kAlpha_8);
+ return draw_mask(renderTargetContext, clipData, viewMatrix, drawRect, std::move(paint),
+ std::move(filteredMask));
}
// Create a mask of 'shape' and return the resulting renderTargetContext
@@ -426,9 +425,8 @@
}
if (filteredMask) {
- if (draw_mask(renderTargetContext, clip, viewMatrix,
- maskRect, std::move(paint), std::move(filteredMask),
- GrColorType::kAlpha_8)) {
+ if (draw_mask(renderTargetContext, clip, viewMatrix, maskRect, std::move(paint),
+ std::move(filteredMask))) {
// This path is completely drawn
return;
}
diff --git a/src/gpu/GrFragmentProcessor.h b/src/gpu/GrFragmentProcessor.h
index 21e27b8..275d471 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(GrColorType colorType, bool samplingDecal) {
+ static OptimizationFlags ModulateForSamplerOptFlags(SkAlphaType alphaType, bool samplingDecal) {
if (samplingDecal) {
return kCompatibleWithCoverageAsAlpha_OptimizationFlag;
} else {
- return ModulateForClampedSamplerOptFlags(colorType);
+ return ModulateForClampedSamplerOptFlags(alphaType);
}
}
// As above, but callers should somehow ensure or assert their sampler still uses clamping
- static OptimizationFlags ModulateForClampedSamplerOptFlags(GrColorType colorType) {
- if (!GrColorTypeHasAlpha(colorType)) {
+ static OptimizationFlags ModulateForClampedSamplerOptFlags(SkAlphaType alphaType) {
+ if (alphaType == kOpaque_SkAlphaType) {
return kCompatibleWithCoverageAsAlpha_OptimizationFlag |
kPreservesOpaqueInput_OptimizationFlag;
} else {
diff --git a/src/gpu/GrPaint.cpp b/src/gpu/GrPaint.cpp
index bc7f538..cb8d479 100644
--- a/src/gpu/GrPaint.cpp
+++ b/src/gpu/GrPaint.cpp
@@ -35,16 +35,10 @@
this->setXPFactory(GrCoverageSetOpXPFactory::Get(regionOp, invertCoverage));
}
-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,
+void GrPaint::addColorTextureProcessor(sk_sp<GrTextureProxy> proxy, SkAlphaType alphaType,
const SkMatrix& matrix, const GrSamplerState& samplerState) {
- this->addColorFragmentProcessor(GrSimpleTextureEffect::Make(std::move(proxy), srcColorType,
- matrix, samplerState));
+ this->addColorFragmentProcessor(
+ GrSimpleTextureEffect::Make(std::move(proxy), alphaType, matrix, samplerState));
}
bool GrPaint::isConstantBlendedColor(SkPMColor4f* constantColor) const {
diff --git a/src/gpu/GrPaint.h b/src/gpu/GrPaint.h
index c2520b0..a13dc82 100644
--- a/src/gpu/GrPaint.h
+++ b/src/gpu/GrPaint.h
@@ -81,9 +81,8 @@
* 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>, GrColorType srcColorType, const SkMatrix&);
- void addColorTextureProcessor(sk_sp<GrTextureProxy>, GrColorType srcColorType, const SkMatrix&,
- const GrSamplerState&);
+ void addColorTextureProcessor(sk_sp<GrTextureProxy>, SkAlphaType, const SkMatrix&,
+ const GrSamplerState& = GrSamplerState::ClampBilerp());
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 56afcc5..d10f5c1 100644
--- a/src/gpu/GrProcessorUnitTest.h
+++ b/src/gpu/GrProcessorUnitTest.h
@@ -52,16 +52,11 @@
GrProcessorTestData(SkRandom* random,
GrContext* context,
const GrRenderTargetContext* renderTargetContext,
- sk_sp<GrTextureProxy> proxies[2],
- GrColorType proxyColorTypes[2])
- : fRandom(random)
- , fRenderTargetContext(renderTargetContext)
- , fContext(context) {
+ sk_sp<GrTextureProxy> proxies[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));
}
@@ -74,13 +69,11 @@
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 bd8c894..85dbe1a 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -611,7 +611,7 @@
void GrRenderTargetContext::drawTexturedQuad(const GrClip& clip,
GrSurfaceProxyView proxyView,
- GrColorType srcColorType,
+ SkAlphaType srcAlphaType,
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), srcColorType,
- std::move(textureXform), filter, color, saturate,
- blendMode, aaType, edgeFlags, croppedDeviceQuad,
- croppedLocalQuad, domain));
+ this->addDrawOp(
+ finalClip,
+ GrTextureOp::Make(fContext, std::move(proxyView), srcAlphaType,
+ std::move(textureXform), filter, color, saturate, blendMode,
+ aaType, edgeFlags, croppedDeviceQuad, croppedLocalQuad, domain));
}
}
@@ -1558,7 +1558,6 @@
// 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) {
@@ -1576,8 +1575,8 @@
return;
}
tempRTC->drawTexture(GrNoClip(), std::move(texProxy), this->colorInfo().colorType(),
- GrSamplerState::Filter::kNearest, SkBlendMode::kSrc,
- SK_PMColor4fWHITE, srcRectToDraw,
+ this->colorInfo().alphaType(), 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));
@@ -1787,8 +1786,8 @@
return;
}
tempRTC->drawTexture(GrNoClip(), std::move(texProxy), this->colorInfo().colorType(),
- GrSamplerState::Filter::kNearest, SkBlendMode::kSrc,
- SK_PMColor4fWHITE, srcRectToDraw,
+ this->colorInfo().alphaType(), 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));
@@ -1801,8 +1800,6 @@
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,
@@ -1835,7 +1832,7 @@
std::fill_n(yM, 15, 0.f);
std::copy_n(baseM + 0, 5, yM + 15);
GrPaint yPaint;
- yPaint.addColorTextureProcessor(srcProxy, srcColorType, texMatrix);
+ yPaint.addColorTextureProcessor(srcProxy, this->colorInfo().alphaType(), texMatrix);
auto yFP = GrColorMatrixFragmentProcessor::Make(yM, false, true, false);
yPaint.addColorFragmentProcessor(std::move(yFP));
yPaint.setPorterDuffXPFactory(SkBlendMode::kSrc);
@@ -1854,7 +1851,7 @@
std::fill_n(uM, 15, 0.f);
std::copy_n(baseM + 5, 5, uM + 15);
GrPaint uPaint;
- uPaint.addColorTextureProcessor(srcProxy, srcColorType, texMatrix,
+ uPaint.addColorTextureProcessor(srcProxy, this->colorInfo().alphaType(), texMatrix,
GrSamplerState::ClampBilerp());
auto uFP = GrColorMatrixFragmentProcessor::Make(uM, false, true, false);
uPaint.addColorFragmentProcessor(std::move(uFP));
@@ -1873,7 +1870,7 @@
std::fill_n(vM, 15, 0.f);
std::copy_n(baseM + 10, 5, vM + 15);
GrPaint vPaint;
- vPaint.addColorTextureProcessor(srcProxy, srcColorType, texMatrix,
+ vPaint.addColorTextureProcessor(srcProxy, this->colorInfo().alphaType(), texMatrix,
GrSamplerState::ClampBilerp());
auto vFP = GrColorMatrixFragmentProcessor::Make(vM, false, true, false);
vPaint.addColorFragmentProcessor(std::move(vFP));
@@ -2377,9 +2374,9 @@
dstOffset = {copyRect.fLeft, copyRect.fTop};
fit = SkBackingFit::kApprox;
}
- sk_sp<GrTextureProxy> newProxy = GrSurfaceProxy::Copy(
- fContext, fRenderTargetProxy.get(), this->colorInfo().colorType(), GrMipMapped::kNo,
- copyRect, fit, SkBudgeted::kYes, restrictions.fRectsMustMatch);
+ sk_sp<GrTextureProxy> newProxy =
+ GrSurfaceProxy::Copy(fContext, fRenderTargetProxy.get(), GrMipMapped::kNo, copyRect,
+ fit, SkBudgeted::kYes, restrictions.fRectsMustMatch);
SkASSERT(newProxy);
dstProxyView->setProxyView({std::move(newProxy), this->origin(), this->textureSwizzle()});
@@ -2387,8 +2384,8 @@
return true;
}
-bool GrRenderTargetContext::blitTexture(GrTextureProxy* src, GrColorType srcColorType,
- const SkIRect& srcRect, const SkIPoint& dstPoint) {
+bool GrRenderTargetContext::blitTexture(GrTextureProxy* src, const SkIRect& srcRect,
+ const SkIPoint& dstPoint) {
SkIRect clippedSrcRect;
SkIPoint clippedDstPoint;
if (!GrClipSrcRectAndDstPoint(this->asSurfaceProxy()->dimensions(), src->dimensions(), srcRect,
@@ -2398,7 +2395,7 @@
GrPaint paint;
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
- auto fp = GrSimpleTextureEffect::Make(sk_ref_sp(src), srcColorType, SkMatrix::I());
+ auto fp = GrSimpleTextureEffect::Make(sk_ref_sp(src), kUnknown_SkAlphaType, SkMatrix::I());
if (!fp) {
return false;
}
@@ -2411,4 +2408,3 @@
SkRect::Make(clippedSrcRect));
return true;
}
-
diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h
index 9b0b662..ef34f40 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,
- 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) {
+ 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) {
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), srcColorType, std::move(texXform),
+ this->drawTexturedQuad(clip, std::move(proxyView), srcAlphaType, std::move(texXform),
filter, color, mode, aa, edgeAA,
GrQuad::MakeFromRect(dstRect, viewMatrix), GrQuad(srcRect), domain);
}
@@ -217,14 +217,15 @@
* provided, the strict src rect constraint is applied using 'domain'.
*/
void drawTextureQuad(const GrClip& clip, sk_sp<GrTextureProxy> proxy, GrColorType srcColorType,
- 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,
+ 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,
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), srcColorType, std::move(texXform),
+ this->drawTexturedQuad(clip, std::move(proxyView), srcAlphaType, std::move(texXform),
filter, color, mode, aa, edgeAA,
GrQuad::MakeFromSkQuad(dstQuad, viewMatrix),
GrQuad::MakeFromSkQuad(srcQuad, SkMatrix::I()), domain);
@@ -233,7 +234,7 @@
/** Used with drawTextureSet */
struct TextureSetEntry {
GrSurfaceProxyView fProxyView;
- GrColorType fSrcColorType;
+ SkAlphaType fSrcAlphaType;
SkRect fSrcRect;
SkRect fDstRect;
const SkPoint* fDstClipQuad; // Must be null, or point to an array of 4 points
@@ -442,8 +443,7 @@
* of the srcRect. The srcRect and dstRect are clipped to the bounds of the src and dst surfaces
* respectively.
*/
- bool blitTexture(GrTextureProxy* src, GrColorType srcColorType, const SkIRect& srcRect,
- const SkIPoint& dstPoint);
+ bool blitTexture(GrTextureProxy* src, const SkIRect& srcRect, const SkIPoint& dstPoint);
/**
* Adds the necessary signal and wait semaphores and adds the passed in SkDrawable to the
@@ -552,15 +552,6 @@
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);
@@ -614,7 +605,7 @@
// Like drawFilledQuad but does not require using a GrPaint or FP for texturing
void drawTexturedQuad(const GrClip& clip,
GrSurfaceProxyView proxyView,
- GrColorType srcColorType,
+ SkAlphaType alphaType,
sk_sp<GrColorSpaceXform> textureXform,
GrSamplerState::Filter filter,
const SkPMColor4f& color,
diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp
index 4245e9e..e4ae6c0 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/GrSoftwarePathRenderer.cpp
@@ -144,7 +144,6 @@
void GrSoftwarePathRenderer::DrawToTargetWithShapeMask(
sk_sp<GrTextureProxy> proxy,
- GrColorType srcColorType,
GrRenderTargetContext* renderTargetContext,
GrPaint&& paint,
const GrUserStencilSettings& userStencilSettings,
@@ -166,7 +165,7 @@
SkIntToScalar(-textureOriginInDeviceSpace.fY));
maskMatrix.preConcat(viewMatrix);
paint.addCoverageFragmentProcessor(GrSimpleTextureEffect::Make(
- std::move(proxy), srcColorType, maskMatrix, GrSamplerState::Filter::kNearest));
+ std::move(proxy), kPremul_SkAlphaType, maskMatrix, GrSamplerState::Filter::kNearest));
DrawNonAARect(renderTargetContext, std::move(paint), userStencilSettings, clip, SkMatrix::I(),
dstRect, invert);
}
@@ -386,10 +385,9 @@
*args.fUserStencilSettings, *args.fClip, *args.fViewMatrix, devClipBounds,
unclippedDevShapeBounds);
}
- 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);
+ DrawToTargetWithShapeMask(std::move(proxy), 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 d407791..a510c7b 100644
--- a/src/gpu/GrSoftwarePathRenderer.h
+++ b/src/gpu/GrSoftwarePathRenderer.h
@@ -52,7 +52,6 @@
// 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 8d4708d..f8f2399 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().colorType(), SkMatrix::I()));
+ this->colorInfo().alphaType(), 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().colorType(), SkMatrix::I());
+ this->colorInfo().alphaType(), SkMatrix::I());
}
if (!fp) {
return false;
@@ -345,15 +345,14 @@
if (this->asRenderTargetContext()) {
std::unique_ptr<GrFragmentProcessor> fp;
if (canvas2DFastPath) {
- fp = direct->priv().createUPMToPMEffect(
- GrSimpleTextureEffect::Make(std::move(tempProxy), colorType,
- SkMatrix::I()));
+ fp = direct->priv().createUPMToPMEffect(GrSimpleTextureEffect::Make(
+ std::move(tempProxy), alphaType, 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), colorType, SkMatrix::I());
+ fp = GrSimpleTextureEffect::Make(std::move(tempProxy), alphaType, SkMatrix::I());
}
if (!fp) {
return false;
@@ -462,10 +461,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(), srcColorType,
- GrMipMapped::kNo, srcRect, SkBackingFit::kApprox,
- SkBudgeted::kNo);
+ texProxy = GrSurfaceProxy::Copy(fContext, this->asSurfaceProxy(), GrMipMapped::kNo, srcRect,
+ SkBackingFit::kApprox, SkBudgeted::kNo);
if (!texProxy) {
return nullptr;
}
@@ -499,8 +498,7 @@
if (rescaleGamma == SkSurface::kLinear && this->colorInfo().colorSpace() &&
!this->colorInfo().colorSpace()->gammaIsLinear()) {
auto cs = this->colorInfo().colorSpace()->makeLinearGamma();
- auto xform = GrColorSpaceXform::Make(this->colorInfo().colorSpace(),
- this->colorInfo().alphaType(), cs.get(),
+ auto xform = GrColorSpaceXform::Make(this->colorInfo().colorSpace(), srcAlphaType, cs.get(),
kPremul_SkAlphaType);
// We'll fall back to kRGBA_8888 if half float not supported.
auto linearRTC = fContext->priv().makeDeferredRenderTargetContextWithFallback(
@@ -509,10 +507,11 @@
if (!linearRTC) {
return nullptr;
}
- 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));
+ 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));
texProxy = linearRTC->asTextureProxyRef();
tempA = std::move(linearRTC);
srcX = 0;
@@ -573,10 +572,9 @@
if (srcW != texProxy->width() || srcH != texProxy->height()) {
auto domain = GrTextureDomain::MakeTexelDomain(
SkIRect::MakeXYWH(srcX, srcY, srcW, srcH), GrTextureDomain::kClamp_Mode);
- fp = GrBicubicEffect::Make(texProxy, srcColorType, matrix, domain, dir,
- prevAlphaType);
+ fp = GrBicubicEffect::Make(texProxy, matrix, domain, dir, prevAlphaType);
} else {
- fp = GrBicubicEffect::Make(texProxy, srcColorType, matrix, dir, prevAlphaType);
+ fp = GrBicubicEffect::Make(texProxy, matrix, dir, prevAlphaType);
}
if (xform) {
fp = GrColorSpaceXformEffect::Make(std::move(fp), std::move(xform));
@@ -590,8 +588,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, filter, SkBlendMode::kSrc,
- SK_PMColor4fWHITE, srcSubset, dstRect, GrAA::kNo,
+ tempB->drawTexture(GrNoClip(), texProxy, srcColorType, srcAlphaType, 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 310b91f..7577811 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -278,7 +278,6 @@
sk_sp<GrTextureProxy> GrSurfaceProxy::Copy(GrRecordingContext* context,
GrSurfaceProxy* src,
- GrColorType srcColorType,
GrMipMapped mipMapped,
SkIRect srcRect,
SkBackingFit fit,
@@ -320,8 +319,7 @@
fit, width, height, colorType, nullptr, 1, mipMapped, src->origin(), nullptr,
budgeted);
- if (dstContext && dstContext->blitTexture(src->asTextureProxy(), srcColorType, srcRect,
- dstPoint)) {
+ if (dstContext && dstContext->blitTexture(src->asTextureProxy(), srcRect, dstPoint)) {
return dstContext->asTextureProxyRef();
}
}
@@ -330,11 +328,10 @@
}
sk_sp<GrTextureProxy> GrSurfaceProxy::Copy(GrRecordingContext* context, GrSurfaceProxy* src,
- GrColorType srcColorType, GrMipMapped mipMapped,
- SkBackingFit fit, SkBudgeted budgeted) {
+ GrMipMapped mipMapped, SkBackingFit fit,
+ SkBudgeted budgeted) {
SkASSERT(!src->isFullyLazy());
- return Copy(context, src, srcColorType, mipMapped, SkIRect::MakeSize(src->dimensions()), fit,
- budgeted);
+ return Copy(context, src, mipMapped, SkIRect::MakeSize(src->dimensions()), fit, budgeted);
}
#if GR_TEST_UTILS
diff --git a/src/gpu/GrSurfaceProxy.h b/src/gpu/GrSurfaceProxy.h
index d835957..f4e2d15 100644
--- a/src/gpu/GrSurfaceProxy.h
+++ b/src/gpu/GrSurfaceProxy.h
@@ -284,15 +284,13 @@
// 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,
- GrColorType srcColorType, GrMipMapped,
+ static sk_sp<GrTextureProxy> Copy(GrRecordingContext*, GrSurfaceProxy* src, GrMipMapped,
SkIRect srcRect, SkBackingFit, SkBudgeted,
RectsMustMatch = RectsMustMatch::kNo);
// Copy the entire 'src'
- static sk_sp<GrTextureProxy> Copy(GrRecordingContext*, GrSurfaceProxy* src,
- GrColorType srcColortype, GrMipMapped, SkBackingFit,
- SkBudgeted);
+ static sk_sp<GrTextureProxy> Copy(GrRecordingContext*, GrSurfaceProxy* src, 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 cfc2c8d..4118287 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), colorType, SkMatrix::I(), domain,
- GrTextureDomain::kClamp_Mode, copyParams.fFilter));
+ paint.addColorFragmentProcessor(GrTextureDomainEffect::Make(
+ std::move(inputProxy), kUnknown_SkAlphaType, SkMatrix::I(), domain,
+ GrTextureDomain::kClamp_Mode, copyParams.fFilter));
} else {
GrSamplerState samplerState(GrSamplerState::WrapMode::kClamp, copyParams.fFilter);
- paint.addColorTextureProcessor(std::move(inputProxy), colorType, SkMatrix::I(),
+ paint.addColorTextureProcessor(std::move(inputProxy), kUnknown_SkAlphaType, 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();
- GrColorType srcColorType = this->colorType();
+ SkAlphaType srcAlphaType = this->alphaType();
if (filterOrNullForBicubic) {
if (kDomain_DomainMode == domainMode || (fDomainNeedsDecal && !clampToBorderSupport)) {
GrTextureDomain::Mode wrapMode = fDomainNeedsDecal ? GrTextureDomain::kDecal_Mode
: GrTextureDomain::kClamp_Mode;
- return GrTextureDomainEffect::Make(std::move(proxy), srcColorType, textureMatrix,
+ return GrTextureDomainEffect::Make(std::move(proxy), srcAlphaType, 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), srcColorType, textureMatrix,
+ return GrSimpleTextureEffect::Make(std::move(proxy), srcAlphaType, 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), srcColorType, textureMatrix, kClampClamp,
- wrapMode, wrapMode, kDir, this->alphaType(),
+ return GrBicubicEffect::Make(std::move(proxy), textureMatrix, kClampClamp, wrapMode,
+ wrapMode, kDir, srcAlphaType,
kDomain_DomainMode == domainMode ? &domain : nullptr);
} else {
- return GrBicubicEffect::Make(std::move(proxy), srcColorType, textureMatrix,
+ return GrBicubicEffect::Make(std::move(proxy), textureMatrix,
fDomainNeedsDecal ? kDecalDecal : kClampClamp, kDir,
- this->alphaType());
+ srcAlphaType);
}
}
}
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index abd0237..cd3fbea 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -230,7 +230,6 @@
SkASSERT(fRenderTargetContext->asTextureProxy());
SkAssertResult(rtc->blitTexture(fRenderTargetContext->asTextureProxy(),
- fRenderTargetContext->colorInfo().colorType(),
SkIRect::MakeWH(this->width(), this->height()),
SkIPoint::Make(0,0)));
}
@@ -932,7 +931,7 @@
SkMatrix texMatrix = SkMatrix::MakeRectToRect(dstRect, srcRect, SkMatrix::kFill_ScaleToFit);
texMatrix.postScale(scales[0], scales[1]);
- GrColorType srcColorType = SkColorTypeToGrColorType(bitmap.colorType());
+ SkAlphaType srcAlphaType = bitmap.alphaType();
// Construct a GrPaint by setting the bitmap texture as the first effect and then configuring
// the rest from the SkPaint.
@@ -955,20 +954,18 @@
}
if (bicubic) {
static constexpr auto kDir = GrBicubicEffect::Direction::kXY;
- fp = GrBicubicEffect::Make(std::move(proxy), srcColorType, texMatrix, domain, kDir,
- bitmap.alphaType());
+ fp = GrBicubicEffect::Make(std::move(proxy), texMatrix, domain, kDir, srcAlphaType);
} else {
- fp = GrTextureDomainEffect::Make(std::move(proxy), srcColorType, texMatrix, domain,
+ fp = GrTextureDomainEffect::Make(std::move(proxy), srcAlphaType, 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), srcColorType, texMatrix, wrapMode, kDir,
- bitmap.alphaType());
+ fp = GrBicubicEffect::Make(std::move(proxy), texMatrix, wrapMode, kDir, srcAlphaType);
} else {
- fp = GrSimpleTextureEffect::Make(std::move(proxy), srcColorType, texMatrix, samplerState);
+ fp = GrSimpleTextureEffect::Make(std::move(proxy), srcAlphaType, texMatrix, samplerState);
}
fp = GrColorSpaceXformEffect::Make(std::move(fp), bitmap.colorSpace(), bitmap.alphaType(),
@@ -1039,8 +1036,7 @@
tmpUnfiltered.setImageFilter(nullptr);
- GrColorType srcColorType = SkColorTypeToGrColorType(result->colorType());
- auto fp = GrSimpleTextureEffect::Make(std::move(proxy), srcColorType, SkMatrix::I());
+ auto fp = GrSimpleTextureEffect::Make(std::move(proxy), special->alphaType(), SkMatrix::I());
fp = GrColorSpaceXformEffect::Make(std::move(fp), result->getColorSpace(), result->alphaType(),
fRenderTargetContext->colorInfo().colorSpace());
if (GrColorTypeIsAlphaOnly(SkColorTypeToGrColorType(result->colorType()))) {
@@ -1078,8 +1074,8 @@
std::unique_ptr<GrFragmentProcessor> cfp;
if (clipProxy && ctm.invert(&inverseClipMatrix)) {
GrColorType srcColorType = SkColorTypeToGrColorType(clipImage->colorType());
- cfp = GrSimpleTextureEffect::Make(std::move(clipProxy), srcColorType, inverseClipMatrix,
- sampler);
+ cfp = GrSimpleTextureEffect::Make(std::move(clipProxy), clipImage->alphaType(),
+ inverseClipMatrix, sampler);
if (srcColorType != GrColorType::kAlpha_8) {
cfp = GrFragmentProcessor::SwizzleOutput(std::move(cfp), GrSwizzle::AAAA());
}
@@ -1255,7 +1251,6 @@
// 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 ce5c49b..c3b3649 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -220,14 +220,15 @@
SkPoint srcQuad[4];
GrMapRectPoints(dstRect, srcRect, dstClip, srcQuad, 4);
- rtc->drawTextureQuad(clip, std::move(proxy), srcColorInfo.colorType(), filter,
- paint.getBlendMode(), color, srcQuad, dstClip, aa, aaFlags,
+ rtc->drawTextureQuad(clip, std::move(proxy), srcColorInfo.colorType(),
+ srcColorInfo.alphaType(), 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(), filter,
- paint.getBlendMode(), color, srcRect, dstRect, aa, aaFlags, constraint,
- ctm, std::move(textureXform));
+ rtc->drawTexture(clip, std::move(proxy), srcColorInfo.colorType(), srcColorInfo.alphaType(),
+ filter, paint.getBlendMode(), color, srcRect, dstRect, aa, aaFlags,
+ constraint, ctm, std::move(textureXform));
}
}
@@ -555,7 +556,7 @@
GrSurfaceOrigin origin = proxy->origin();
const GrSwizzle& swizzle = proxy->textureSwizzle();
textures[i].fProxyView = {std::move(proxy), origin, swizzle};
- textures[i].fSrcColorType = SkColorTypeToGrColorType(image->colorType());
+ textures[i].fSrcAlphaType = image->alphaType();
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 fcc43bd..0472ee2 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, srcColorType, GrMipMapped::kYes,
- SkBackingFit::kExact, SkBudgeted::kYes);
+ return GrSurfaceProxy::Copy(ctx, baseProxy, 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 6d7b431..d78cb74 100644
--- a/src/gpu/effects/GrBicubicEffect.cpp
+++ b/src/gpu/effects/GrBicubicEffect.cpp
@@ -162,15 +162,13 @@
processor.textureSampler(0).samplerState());
}
-GrBicubicEffect::GrBicubicEffect(sk_sp<GrTextureProxy> proxy, GrColorType srcColorType,
- const SkMatrix& matrix, const SkRect& domain,
- const GrSamplerState::WrapMode wrapModes[2],
+GrBicubicEffect::GrBicubicEffect(sk_sp<GrTextureProxy> proxy, 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(
- srcColorType,
- GrTextureDomain::IsDecalSampled(wrapModes, modeX, modeY))}
+ alphaType, GrTextureDomain::IsDecalSampled(wrapModes, modeX, modeY))}
, fCoordTransform(matrix, proxy.get())
, fDomain(proxy.get(), domain, modeX, modeY)
, fTextureSampler(std::move(proxy),
@@ -227,8 +225,8 @@
direction = Direction::kXY;
break;
}
- return GrBicubicEffect::Make(d->textureProxy(texIdx), d->textureProxyColorType(texIdx),
- SkMatrix::I(), kClampClamp, direction, alphaType);
+ return GrBicubicEffect::Make(d->textureProxy(texIdx), SkMatrix::I(), kClampClamp, direction,
+ alphaType);
}
#endif
diff --git a/src/gpu/effects/GrBicubicEffect.h b/src/gpu/effects/GrBicubicEffect.h
index 5e274e0..71e8fcf 100644
--- a/src/gpu/effects/GrBicubicEffect.h
+++ b/src/gpu/effects/GrBicubicEffect.h
@@ -45,31 +45,27 @@
* 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), srcColorType, matrix, kClampClamp,
- GrTextureDomain::kIgnore_Mode, GrTextureDomain::kIgnore_Mode, direction,
- alphaType);
+ return Make(std::move(proxy), 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), srcColorType, matrix, wrapModes,
- GrTextureDomain::kIgnore_Mode, GrTextureDomain::kIgnore_Mode, direction,
- alphaType);
+ return Make(std::move(proxy), matrix, wrapModes, GrTextureDomain::kIgnore_Mode,
+ GrTextureDomain::kIgnore_Mode, direction, alphaType);
}
/**
@@ -78,7 +74,6 @@
* 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,
@@ -94,24 +89,22 @@
SkIRect::MakeSize(proxy->dimensions()), modeX, modeY);
}
return std::unique_ptr<GrFragmentProcessor>(
- new GrBicubicEffect(std::move(proxy), srcColorType, matrix, resolvedDomain,
- wrapModes, modeX, modeY, direction, alphaType));
+ new GrBicubicEffect(std::move(proxy), 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), srcColorType, matrix, kClampClamp,
- GrTextureDomain::kClamp_Mode, GrTextureDomain::kClamp_Mode, direction,
- alphaType, &domain);
+ return Make(std::move(proxy), matrix, kClampClamp, GrTextureDomain::kClamp_Mode,
+ GrTextureDomain::kClamp_Mode, direction, alphaType, &domain);
}
/**
@@ -125,10 +118,9 @@
GrSamplerState::Filter* filterMode);
private:
- 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);
+ GrBicubicEffect(sk_sp<GrTextureProxy>, const SkMatrix& matrix, const SkRect& domain,
+ const GrSamplerState::WrapMode wrapModes[2], GrTextureDomain::Mode modeX,
+ GrTextureDomain::Mode modeY, Direction direction, SkAlphaType);
explicit GrBicubicEffect(const GrBicubicEffect&);
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
diff --git a/src/gpu/effects/GrConfigConversionEffect.fp b/src/gpu/effects/GrConfigConversionEffect.fp
index 0387c3b..7338b7d 100644
--- a/src/gpu/effects/GrConfigConversionEffect.fp
+++ b/src/gpu/effects/GrConfigConversionEffect.fp
@@ -64,7 +64,6 @@
// 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,
@@ -87,7 +86,7 @@
std::unique_ptr<GrFragmentProcessor> upmToPM(
new GrConfigConversionEffect(PMConversion::kToPremul));
- paint1.addColorTextureProcessor(dataProxy, dataColorType, SkMatrix::I());
+ paint1.addColorTextureProcessor(dataProxy, kPremul_SkAlphaType, SkMatrix::I());
paint1.addColorFragmentProcessor(pmToUPM->clone());
paint1.setPorterDuffXPFactory(SkBlendMode::kSrc);
@@ -101,14 +100,16 @@
// draw
tempRTC->discard();
- paint2.addColorTextureProcessor(readRTC->asTextureProxyRef(), kColorType, SkMatrix::I());
+ paint2.addColorTextureProcessor(readRTC->asTextureProxyRef(), kUnpremul_SkAlphaType,
+ 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(), kColorType, SkMatrix::I());
+ paint3.addColorTextureProcessor(tempRTC->asTextureProxyRef(), kPremul_SkAlphaType,
+ 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 fd70616..dd6e7c5 100644
--- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
+++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp
@@ -211,16 +211,15 @@
}
GrGaussianConvolutionFragmentProcessor::GrGaussianConvolutionFragmentProcessor(
- sk_sp<GrTextureProxy> proxy,
- GrColorType srcColorType,
- Direction direction,
- int radius,
- float gaussianSigma,
- GrTextureDomain::Mode mode,
- int bounds[2])
+ sk_sp<GrTextureProxy> proxy,
+ SkAlphaType alphaType,
+ Direction direction,
+ int radius,
+ float gaussianSigma,
+ GrTextureDomain::Mode mode,
+ int bounds[2])
: INHERITED(kGrGaussianConvolutionFragmentProcessor_ClassID,
- ModulateForSamplerOptFlags(srcColorType,
- mode == GrTextureDomain::kDecal_Mode))
+ ModulateForSamplerOptFlags(alphaType, mode == GrTextureDomain::kDecal_Mode))
, fCoordTransform(proxy.get())
, fTextureSampler(std::move(proxy))
, fRadius(radius)
@@ -298,8 +297,10 @@
int radius = d->fRandom->nextRangeU(1, kMaxKernelRadius);
float sigma = radius / 3.f;
+ auto alphaType = static_cast<SkAlphaType>(
+ d->fRandom->nextRangeU(kUnknown_SkAlphaType + 1, kLastEnum_SkAlphaType));
return GrGaussianConvolutionFragmentProcessor::Make(
- std::move(proxy), d->textureProxyColorType(texIdx),
- dir, radius, sigma, static_cast<GrTextureDomain::Mode>(modeIdx), bounds);
+ std::move(proxy), alphaType, 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 843ed30..b329b1d 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,
- GrColorType srcColorType,
+ SkAlphaType alphaType,
Direction dir,
int halfWidth,
float gaussianSigma,
GrTextureDomain::Mode mode,
int* bounds) {
return std::unique_ptr<GrFragmentProcessor>(new GrGaussianConvolutionFragmentProcessor(
- std::move(proxy), srcColorType, dir, halfWidth, gaussianSigma, mode, bounds));
+ std::move(proxy), alphaType, 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>, GrColorType srcColorType,
- Direction, int halfWidth, float gaussianSigma,
+ GrGaussianConvolutionFragmentProcessor(sk_sp<GrTextureProxy>, SkAlphaType alphaType, 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 5c30cc0..c86af4b 100644
--- a/src/gpu/effects/GrSimpleTextureEffect.fp
+++ b/src/gpu/effects/GrSimpleTextureEffect.fp
@@ -9,7 +9,7 @@
in half4x4 matrix;
@constructorParams {
- GrColorType srcColorType,
+ SkAlphaType alphaType,
GrSamplerState samplerParams
}
@@ -23,34 +23,34 @@
@make {
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- GrColorType srcColorType,
+ SkAlphaType alphaType,
const SkMatrix& matrix) {
return std::unique_ptr<GrFragmentProcessor>(
- new GrSimpleTextureEffect(std::move(proxy), matrix, srcColorType,
+ new GrSimpleTextureEffect(std::move(proxy), matrix, alphaType,
GrSamplerState(GrSamplerState::WrapMode::kClamp, GrSamplerState::Filter::kNearest)));
}
/* clamp mode */
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- GrColorType srcColorType,
+ SkAlphaType alphaType,
const SkMatrix& matrix,
GrSamplerState::Filter filter) {
return std::unique_ptr<GrFragmentProcessor>(
- new GrSimpleTextureEffect(std::move(proxy), matrix, srcColorType,
+ new GrSimpleTextureEffect(std::move(proxy), matrix, alphaType,
GrSamplerState(GrSamplerState::WrapMode::kClamp, filter)));
}
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- GrColorType srcColorType,
+ SkAlphaType alphaType,
const SkMatrix& matrix,
const GrSamplerState& p) {
return std::unique_ptr<GrFragmentProcessor>(
- new GrSimpleTextureEffect(std::move(proxy), matrix, srcColorType, p));
+ new GrSimpleTextureEffect(std::move(proxy), matrix, alphaType, p));
}
}
@optimizationFlags {
- ModulateForSamplerOptFlags(srcColorType,
+ ModulateForSamplerOptFlags(alphaType,
samplerParams.wrapModeX() == GrSamplerState::WrapMode::kClampToBorder ||
samplerParams.wrapModeY() == GrSamplerState::WrapMode::kClampToBorder)
}
@@ -76,6 +76,7 @@
: GrSamplerState::Filter::kNearest);
const SkMatrix& matrix = GrTest::TestMatrix(testData->fRandom);
+ auto alphaType = static_cast<SkAlphaType>(
+ testData->fRandom->nextRangeU(kUnknown_SkAlphaType + 1, kLastEnum_SkAlphaType));
return GrSimpleTextureEffect::Make(testData->textureProxy(texIdx),
- testData->textureProxyColorType(texIdx), matrix, params);
-}
+ alphaType, matrix, params);}
diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp
index 8bb662b..10fa17f 100644
--- a/src/gpu/effects/GrTextureDomain.cpp
+++ b/src/gpu/effects/GrTextureDomain.cpp
@@ -252,41 +252,40 @@
std::unique_ptr<GrFragmentProcessor> GrTextureDomainEffect::Make(
sk_sp<GrTextureProxy> proxy,
- GrColorType srcColorType,
+ SkAlphaType srcAlphaType,
const SkMatrix& matrix,
const SkRect& domain,
GrTextureDomain::Mode mode,
GrSamplerState::Filter filterMode) {
- return Make(std::move(proxy), srcColorType, matrix, domain, mode, mode,
+ return Make(std::move(proxy), srcAlphaType, matrix, domain, mode, mode,
GrSamplerState(GrSamplerState::WrapMode::kClamp, filterMode));
}
-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) {
+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) {
// 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), srcColorType, matrix, domain, modeX, modeY, sampler));
+ std::move(proxy), srcAlphaType, matrix, domain, modeX, modeY, sampler));
}
GrTextureDomainEffect::GrTextureDomainEffect(sk_sp<GrTextureProxy> proxy,
- GrColorType srcColorType,
+ SkAlphaType srcAlphaType,
const SkMatrix& matrix,
const SkRect& domain,
GrTextureDomain::Mode modeX,
GrTextureDomain::Mode modeY,
const GrSamplerState& sampler)
: INHERITED(kGrTextureDomainEffect_ClassID,
- ModulateForSamplerOptFlags(srcColorType,
- GrTextureDomain::IsDecalSampled(sampler, modeX, modeY)))
+ ModulateForSamplerOptFlags(
+ srcAlphaType, GrTextureDomain::IsDecalSampled(sampler, modeX, modeY)))
, fCoordTransform(matrix, proxy.get())
, fTextureDomain(proxy.get(), domain, modeX, modeY)
, fTextureSampler(std::move(proxy), sampler) {
@@ -374,15 +373,17 @@
const SkMatrix& matrix = GrTest::TestMatrix(d->fRandom);
bool bilerp = modeX != GrTextureDomain::kRepeat_Mode && modeY != GrTextureDomain::kRepeat_Mode ?
d->fRandom->nextBool() : false;
- return GrTextureDomainEffect::Make(
- std::move(proxy),
- d->textureProxyColorType(texIdx),
- matrix,
- domain,
- modeX,
- modeY,
- GrSamplerState(GrSamplerState::WrapMode::kClamp, bilerp ?
- GrSamplerState::Filter::kBilerp : GrSamplerState::Filter::kNearest));
+ auto alphaType = static_cast<SkAlphaType>(
+ d->fRandom->nextRangeU(kUnknown_SkAlphaType + 1, kLastEnum_SkAlphaType));
+ return GrTextureDomainEffect::Make(std::move(proxy),
+ alphaType,
+ 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 96c2d20..ff13619 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>,
- GrColorType srcColorType,
+ SkAlphaType srcAlphaType,
const SkMatrix&,
const SkRect& domain,
GrTextureDomain::Mode mode,
GrSamplerState::Filter filterMode);
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy>,
- GrColorType srcColorType,
+ SkAlphaType srcAlphaType,
const SkMatrix&,
const SkRect& domain,
GrTextureDomain::Mode modeX,
@@ -225,7 +225,7 @@
TextureSampler fTextureSampler;
GrTextureDomainEffect(sk_sp<GrTextureProxy>,
- GrColorType srcColorType,
+ SkAlphaType srcAlphaType,
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 acbc4cc..a7825c3 100644
--- a/src/gpu/effects/generated/GrConfigConversionEffect.h
+++ b/src/gpu/effects/generated/GrConfigConversionEffect.h
@@ -68,7 +68,6 @@
// 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) {
@@ -89,7 +88,7 @@
std::unique_ptr<GrFragmentProcessor> upmToPM(
new GrConfigConversionEffect(PMConversion::kToPremul));
- paint1.addColorTextureProcessor(dataProxy, dataColorType, SkMatrix::I());
+ paint1.addColorTextureProcessor(dataProxy, kPremul_SkAlphaType, SkMatrix::I());
paint1.addColorFragmentProcessor(pmToUPM->clone());
paint1.setPorterDuffXPFactory(SkBlendMode::kSrc);
@@ -103,14 +102,16 @@
// draw
tempRTC->discard();
- paint2.addColorTextureProcessor(readRTC->asTextureProxyRef(), kColorType, SkMatrix::I());
+ paint2.addColorTextureProcessor(readRTC->asTextureProxyRef(), kUnpremul_SkAlphaType,
+ 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(), kColorType, SkMatrix::I());
+ paint3.addColorTextureProcessor(tempRTC->asTextureProxyRef(), kPremul_SkAlphaType,
+ 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 279ea5d..fd8362a 100644
--- a/src/gpu/effects/generated/GrSimpleTextureEffect.cpp
+++ b/src/gpu/effects/generated/GrSimpleTextureEffect.cpp
@@ -85,7 +85,8 @@
: GrSamplerState::Filter::kNearest);
const SkMatrix& matrix = GrTest::TestMatrix(testData->fRandom);
- return GrSimpleTextureEffect::Make(testData->textureProxy(texIdx),
- testData->textureProxyColorType(texIdx), matrix, params);
+ auto alphaType = static_cast<SkAlphaType>(
+ testData->fRandom->nextRangeU(kUnknown_SkAlphaType + 1, kLastEnum_SkAlphaType));
+ return GrSimpleTextureEffect::Make(testData->textureProxy(texIdx), alphaType, matrix, params);
}
#endif
diff --git a/src/gpu/effects/generated/GrSimpleTextureEffect.h b/src/gpu/effects/generated/GrSimpleTextureEffect.h
index d70dd56..db087eb 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,
- GrColorType srcColorType,
+ SkAlphaType alphaType,
const SkMatrix& matrix) {
return std::unique_ptr<GrFragmentProcessor>(
- new GrSimpleTextureEffect(std::move(proxy), matrix, srcColorType,
+ new GrSimpleTextureEffect(std::move(proxy), matrix, alphaType,
GrSamplerState(GrSamplerState::WrapMode::kClamp,
GrSamplerState::Filter::kNearest)));
}
/* clamp mode */
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- GrColorType srcColorType,
+ SkAlphaType alphaType,
const SkMatrix& matrix,
GrSamplerState::Filter filter) {
return std::unique_ptr<GrFragmentProcessor>(new GrSimpleTextureEffect(
- std::move(proxy), matrix, srcColorType,
+ std::move(proxy), matrix, alphaType,
GrSamplerState(GrSamplerState::WrapMode::kClamp, filter)));
}
static std::unique_ptr<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy,
- GrColorType srcColorType,
+ SkAlphaType alphaType,
const SkMatrix& matrix,
const GrSamplerState& p) {
return std::unique_ptr<GrFragmentProcessor>(
- new GrSimpleTextureEffect(std::move(proxy), matrix, srcColorType, p));
+ new GrSimpleTextureEffect(std::move(proxy), matrix, alphaType, 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, GrColorType srcColorType,
+ GrSimpleTextureEffect(sk_sp<GrTextureProxy> image, SkMatrix44 matrix, SkAlphaType alphaType,
GrSamplerState samplerParams)
: INHERITED(kGrSimpleTextureEffect_ClassID,
(OptimizationFlags)ModulateForSamplerOptFlags(
- srcColorType,
+ alphaType,
samplerParams.wrapModeX() ==
GrSamplerState::WrapMode::kClampToBorder ||
samplerParams.wrapModeY() ==
diff --git a/src/gpu/ops/GrShadowRRectOp.cpp b/src/gpu/ops/GrShadowRRectOp.cpp
index 6eada79..d899954 100644
--- a/src/gpu/ops/GrShadowRRectOp.cpp
+++ b/src/gpu/ops/GrShadowRRectOp.cpp
@@ -719,35 +719,42 @@
#if GR_TEST_UTILS
GR_DRAW_OP_TEST_DEFINE(ShadowRRectOp) {
- // create a similarity matrix
- SkScalar rotate = random->nextSScalar1() * 360.f;
- SkScalar translateX = random->nextSScalar1() * 1000.f;
- SkScalar translateY = random->nextSScalar1() * 1000.f;
- SkScalar scale;
+ // We may choose matrix and inset values that cause the factory to fail. We loop until we find
+ // an acceptable combination.
do {
- scale = random->nextSScalar1() * 100.f;
- } while (scale == 0);
- SkMatrix viewMatrix;
- viewMatrix.setRotate(rotate);
- viewMatrix.postTranslate(translateX, translateY);
- viewMatrix.postScale(scale, scale);
- SkScalar insetWidth = random->nextSScalar1() * 72.f;
- SkScalar blurWidth = random->nextSScalar1() * 72.f;
- bool isCircle = random->nextBool();
- // This op doesn't use a full GrPaint, just a color.
- GrColor color = paint.getColor4f().toBytes_RGBA();
- if (isCircle) {
- SkRect circle = GrTest::TestSquare(random);
- SkRRect rrect = SkRRect::MakeOval(circle);
- return GrShadowRRectOp::Make(context, color, viewMatrix, rrect, blurWidth, insetWidth);
- } else {
- SkRRect rrect;
- do {
- // This may return a rrect with elliptical corners, which we don't support.
- rrect = GrTest::TestRRectSimple(random);
- } while (!SkRRectPriv::IsSimpleCircular(rrect));
- return GrShadowRRectOp::Make(context, color, viewMatrix, rrect, blurWidth, insetWidth);
- }
+ // create a similarity matrix
+ SkScalar rotate = random->nextSScalar1() * 360.f;
+ SkScalar translateX = random->nextSScalar1() * 1000.f;
+ SkScalar translateY = random->nextSScalar1() * 1000.f;
+ SkScalar scale = random->nextSScalar1() * 100.f;
+ SkMatrix viewMatrix;
+ viewMatrix.setRotate(rotate);
+ viewMatrix.postTranslate(translateX, translateY);
+ viewMatrix.postScale(scale, scale);
+ SkScalar insetWidth = random->nextSScalar1() * 72.f;
+ SkScalar blurWidth = random->nextSScalar1() * 72.f;
+ bool isCircle = random->nextBool();
+ // This op doesn't use a full GrPaint, just a color.
+ GrColor color = paint.getColor4f().toBytes_RGBA();
+ if (isCircle) {
+ SkRect circle = GrTest::TestSquare(random);
+ SkRRect rrect = SkRRect::MakeOval(circle);
+ if (auto op = GrShadowRRectOp::Make(
+ context, color, viewMatrix, rrect, blurWidth, insetWidth)) {
+ return op;
+ }
+ } else {
+ SkRRect rrect;
+ do {
+ // This may return a rrect with elliptical corners, which will cause an assert.
+ rrect = GrTest::TestRRectSimple(random);
+ } while (!SkRRectPriv::IsSimpleCircular(rrect));
+ if (auto op = GrShadowRRectOp::Make(
+ context, color, viewMatrix, rrect, blurWidth, insetWidth)) {
+ return op;
+ }
+ }
+ } while (true);
}
#endif
diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp
index 0b687dd..2016ca7 100644
--- a/src/gpu/ops/GrTextureOp.cpp
+++ b/src/gpu/ops/GrTextureOp.cpp
@@ -943,7 +943,7 @@
std::unique_ptr<GrDrawOp> GrTextureOp::Make(GrRecordingContext* context,
GrSurfaceProxyView proxyView,
- GrColorType srcColorType,
+ SkAlphaType alphaType,
sk_sp<GrColorSpaceXform> textureXform,
GrSamplerState::Filter filter,
const SkPMColor4f& color,
@@ -979,10 +979,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), srcColorType, SkMatrix::I(),
+ fp = GrTextureDomainEffect::Make(sk_ref_sp(proxy), alphaType, SkMatrix::I(),
correctedDomain, GrTextureDomain::kClamp_Mode, filter);
} else {
- fp = GrSimpleTextureEffect::Make(sk_ref_sp(proxy), srcColorType, SkMatrix::I(), filter);
+ fp = GrSimpleTextureEffect::Make(sk_ref_sp(proxy), alphaType, SkMatrix::I(), filter);
}
fp = GrColorSpaceXformEffect::Make(std::move(fp), std::move(textureXform));
paint.addColorFragmentProcessor(std::move(fp));
@@ -1090,7 +1090,7 @@
const SkRect* domain = constraint == SkCanvas::kStrict_SrcRectConstraint
? &set[i].fSrcRect : nullptr;
- auto op = Make(context, set[i].fProxyView, set[i].fSrcColorType, textureColorSpaceXform,
+ auto op = Make(context, set[i].fProxyView, set[i].fSrcAlphaType, textureColorSpaceXform,
filter, {alpha, alpha, alpha, alpha}, saturate, blendMode, aaType,
set[i].fAAFlags, quad, srcQuad, domain);
rtc->addDrawOp(clip, std::move(op));
@@ -1224,11 +1224,13 @@
GrSurfaceProxyView proxyView(
std::move(proxy), origin,
context->priv().caps()->getTextureSwizzle(format, GrColorType::kRGBA_8888));
+ auto alphaType = static_cast<SkAlphaType>(
+ random->nextRangeU(kUnknown_SkAlphaType + 1, kLastEnum_SkAlphaType));
- 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);
+ 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);
}
#endif
diff --git a/src/gpu/ops/GrTextureOp.h b/src/gpu/ops/GrTextureOp.h
index d15d231..7fd545b 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,
- GrColorType srcColorType,
+ SkAlphaType srcAlphaType,
sk_sp<GrColorSpaceXform>,
GrSamplerState::Filter,
const SkPMColor4f&,
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index bfa4dfd..675e920 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -93,8 +93,7 @@
GrPaint paint;
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
- paint.addColorTextureProcessor(std::move(proxy), SkColorTypeToGrColorType(this->colorType()),
- SkMatrix::I());
+ paint.addColorTextureProcessor(std::move(proxy), this->alphaType(), SkMatrix::I());
if (xform) {
paint.addColorFragmentProcessor(std::move(xform));
}
diff --git a/src/image/SkImage_GpuBase.cpp b/src/image/SkImage_GpuBase.cpp
index e19109e..6d849c9 100644
--- a/src/image/SkImage_GpuBase.cpp
+++ b/src/image/SkImage_GpuBase.cpp
@@ -115,11 +115,10 @@
}
sk_sp<GrSurfaceProxy> proxy = this->asTextureProxyRef(context);
- GrColorType srcColorType = SkColorTypeToGrColorType(this->colorType());
- sk_sp<GrTextureProxy> copyProxy = GrSurfaceProxy::Copy(
- context, proxy.get(), srcColorType, GrMipMapped::kNo, subset, SkBackingFit::kExact,
- proxy->isBudgeted());
+ sk_sp<GrTextureProxy> copyProxy =
+ GrSurfaceProxy::Copy(context, proxy.get(), 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 1c45ea2..c8b35aa 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->colorInfo().colorType(),
- rtc->mipMapped(), *subset, SkBackingFit::kExact, budgeted);
+ srcProxy = GrSurfaceProxy::Copy(ctx, rtc->asSurfaceProxy(), 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->colorInfo().colorType(),
- rtc->mipMapped(), SkBackingFit::kExact, budgeted);
+ srcProxy = GrSurfaceProxy::Copy(ctx, rtc->asSurfaceProxy(), rtc->mipMapped(),
+ SkBackingFit::kExact, budgeted);
}
const SkImageInfo info = fDevice->imageInfo();
diff --git a/src/shaders/SkImageShader.cpp b/src/shaders/SkImageShader.cpp
index 8b30f50..3f3cd0c 100755
--- a/src/shaders/SkImageShader.cpp
+++ b/src/shaders/SkImageShader.cpp
@@ -235,7 +235,7 @@
return nullptr;
}
- GrColorType srcColorType = SkColorTypeToGrColorType(fImage->colorType());
+ SkAlphaType srcAlphaType = fImage->alphaType();
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), srcColorType, lmInverse, wrapModes, domainX,
- domainY, kDir, fImage->alphaType());
+ inner = GrBicubicEffect::Make(std::move(proxy), lmInverse, wrapModes, domainX, domainY,
+ kDir, srcAlphaType);
} 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), srcColorType, lmInverse, domain,
+ inner = GrTextureDomainEffect::Make(std::move(proxy), srcAlphaType, lmInverse, domain,
domainX, domainY, samplerState);
} else {
- inner = GrSimpleTextureEffect::Make(std::move(proxy), srcColorType, lmInverse,
+ inner = GrSimpleTextureEffect::Make(std::move(proxy), srcAlphaType, lmInverse,
samplerState);
}
}
- inner = GrColorSpaceXformEffect::Make(std::move(inner), fImage->colorSpace(),
- fImage->alphaType(), args.fDstColorInfo->colorSpace());
+ inner = GrColorSpaceXformEffect::Make(std::move(inner), fImage->colorSpace(), srcAlphaType,
+ args.fDstColorInfo->colorSpace());
bool isAlphaOnly = SkColorTypeIsAlphaOnly(fImage->colorType());
if (isAlphaOnly) {
diff --git a/tests/BulkRectTest.cpp b/tests/BulkRectTest.cpp
index 3fa1b19..f81c97b 100644
--- a/tests/BulkRectTest.cpp
+++ b/tests/BulkRectTest.cpp
@@ -99,7 +99,7 @@
// Alternate between two proxies to prevent op merging if the batch API was forced to submit
// one op at a time (to work, this does require that all fDstRects overlap).
set[i].fProxyView = i % 2 == 0 ? proxyViewA : proxyViewB;
- set[i].fSrcColorType = GrColorType::kRGBA_8888;
+ set[i].fSrcAlphaType = kPremul_SkAlphaType;
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 aba889d..c4c9af7 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(), grColorType, srcRect, dstPoint);
+ src.get(), srcRect, dstPoint);
}
bool expectedResult = true;
diff --git a/tests/GrMipMappedTest.cpp b/tests/GrMipMappedTest.cpp
index 6bb6afd..d911dbb 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,
- sk_sp<GrTextureProxy> mipmapProxy, GrSamplerState::Filter filter) {
+ SkAlphaType alphaType, sk_sp<GrTextureProxy> mipmapProxy, GrSamplerState::Filter filter) {
GrSurfaceDesc desc;
desc.fWidth = 1;
desc.fHeight = 1;
@@ -350,9 +350,10 @@
GrMipMapped::kNo, SkBackingFit::kApprox, SkBudgeted::kYes, GrProtected::kNo);
auto rtc = drawingManager->makeRenderTargetContext(
std::move(renderTarget), colorType, nullptr, nullptr, true);
- rtc->drawTexture(GrNoClip(), mipmapProxy, colorType, filter, SkBlendMode::kSrcOver,
+ rtc->drawTexture(GrNoClip(), mipmapProxy, colorType, alphaType, 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;
}
@@ -380,6 +381,7 @@
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();
@@ -410,8 +412,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, mipmapProxy, Filter::kMipMap);
+ auto rtc1 = draw_mipmap_into_new_render_target(drawingManager, proxyProvider, colorType,
+ alphaType, 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
@@ -424,8 +426,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, mipmapProxy, Filter::kMipMap);
+ auto rtc2 = draw_mipmap_into_new_render_target(drawingManager, proxyProvider, colorType,
+ alphaType, mipmapProxy, Filter::kMipMap);
// Make sure the mipmap texture still has the same regen task.
REPORTER_ASSERT(reporter, mipmapProxy->getLastRenderTask() == initialMipmapRegenTask);
@@ -451,8 +453,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, mipmapProxy, Filter::kBilerp);
+ rtc1 = draw_mipmap_into_new_render_target(drawingManager, proxyProvider, colorType,
+ alphaType, 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
@@ -464,8 +466,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, mipmapProxy, Filter::kMipMap);
+ rtc2 = draw_mipmap_into_new_render_target(drawingManager, proxyProvider, colorType,
+ alphaType, 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 0b50d85..3a1026b 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,
+ rtc->drawTexture(GrNoClip(), 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,
@@ -621,10 +621,10 @@
// This time we move the proxy into the draw.
rtc->drawTexture(GrNoClip(), std::move(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,
- SkMatrix::I(), nullptr);
+ 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);
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,
+ GrNoClip(), proxy, GrColorType::kRGBA_8888, kPremul_SkAlphaType,
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 01098b7..cc89782 100644
--- a/tests/MtlCopySurfaceTest.mm
+++ b/tests/MtlCopySurfaceTest.mm
@@ -46,7 +46,6 @@
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 3de06d5..62a61bb 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,
- GrColorType atlasColorType) {
+ SkAlphaType atlasAlphaType) {
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, atlasColorType, SkMatrix::I());
+ auto fp = GrSimpleTextureEffect::Make(atlasProxy, atlasAlphaType, SkMatrix::I());
GrPaint paint;
paint.addColorFragmentProcessor(std::move(fp));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
@@ -545,10 +545,9 @@
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()),
- GrColorType::kRGBA_8888);
+ proxies[i] = make_upstream_image(
+ context, &object, i*3,
+ object.getAtlasProxy(proxyProvider, context->priv().caps()), kPremul_SkAlphaType);
}
static const int kFinalWidth = 6*kDrawnTileSize;
@@ -566,7 +565,7 @@
SkMatrix t = SkMatrix::MakeTrans(-i*3*kDrawnTileSize, 0);
GrPaint paint;
- auto fp = GrSimpleTextureEffect::Make(std::move(proxies[i]), GrColorType::kRGBA_8888, t);
+ auto fp = GrSimpleTextureEffect::Make(std::move(proxies[i]), kPremul_SkAlphaType, t);
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
paint.addColorFragmentProcessor(std::move(fp));
diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp
index 7171868..978f7ef 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -231,22 +231,22 @@
GrRenderTargetContext* rtc,
std::unique_ptr<GrFragmentProcessor> fp,
sk_sp<GrTextureProxy> inputDataProxy,
- GrColorType inputColorType) {
+ SkAlphaType inputAlphaType) {
GrPaint paint;
- paint.addColorTextureProcessor(std::move(inputDataProxy), inputColorType, SkMatrix::I());
+ paint.addColorTextureProcessor(std::move(inputDataProxy), inputAlphaType, 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->addDrawOp(GrNoClip(), std::move(op));
+ rtc->priv().testingOnly_addDrawOp(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, GrColorType inputColorType, GrColor* buffer) {
+ sk_sp<GrTextureProxy> inputDataProxy, SkAlphaType inputAlphaType, 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, inputColorType);
+ test_draw_op(context, rtc, fp->clone(), inputDataProxy, inputAlphaType);
memset(buffer, 0x0, sizeof(GrColor) * inputDataProxy->width() * inputDataProxy->height());
rtc->readPixels(SkImageInfo::Make(inputDataProxy->dimensions(), kRGBA_8888_SkColorType,
kPremul_SkAlphaType),
@@ -257,8 +257,7 @@
bool init_test_textures(GrResourceProvider* resourceProvider,
GrProxyProvider* proxyProvider,
SkRandom* random,
- sk_sp<GrTextureProxy> proxies[2],
- GrColorType proxyColorTypes[2]) {
+ sk_sp<GrTextureProxy> proxies[2]) {
static const int kTestTextureSize = 256;
{
@@ -278,7 +277,6 @@
proxies[0] =
proxyProvider->createTextureProxy(img, 1, SkBudgeted::kYes, SkBackingFit::kExact);
proxies[0]->instantiate(resourceProvider);
- proxyColorTypes[0] = GrColorType::kRGBA_8888;
}
{
@@ -297,7 +295,6 @@
proxies[1] =
proxyProvider->createTextureProxy(img, 1, SkBudgeted::kYes, SkBackingFit::kExact);
proxies[1]->instantiate(resourceProvider);
- proxyColorTypes[1] = GrColorType::kAlpha_8;
}
return proxies[0] && proxies[1];
@@ -431,12 +428,11 @@
SkBackingFit::kExact, kRenderSize, kRenderSize, GrColorType::kRGBA_8888, nullptr);
sk_sp<GrTextureProxy> proxies[2];
- GrColorType proxyColorTypes[2];
- if (!init_test_textures(resourceProvider, proxyProvider, &random, proxies, proxyColorTypes)) {
+ if (!init_test_textures(resourceProvider, proxyProvider, &random, proxies)) {
ERRORF(reporter, "Could not create test textures");
return;
}
- GrProcessorTestData testData(&random, context, rtc.get(), proxies, proxyColorTypes);
+ GrProcessorTestData testData(&random, context, rtc.get(), proxies);
// 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
@@ -483,14 +479,14 @@
if (fp->compatibleWithCoverageAsAlpha()) {
// 2nd and 3rd frames are only used when checking coverage optimization
- render_fp(context, rtc.get(), fp.get(), inputTexture2, GrColorType::kRGBA_8888,
+ render_fp(context, rtc.get(), fp.get(), inputTexture2, kPremul_SkAlphaType,
readData2.get());
- render_fp(context, rtc.get(), fp.get(), inputTexture3, GrColorType::kRGBA_8888,
+ render_fp(context, rtc.get(), fp.get(), inputTexture3, kPremul_SkAlphaType,
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, GrColorType::kRGBA_8888,
+ render_fp(context, rtc.get(), fp.get(), inputTexture1, kPremul_SkAlphaType,
readData1.get());
if (0) { // Useful to see what FPs are being tested.
@@ -669,12 +665,11 @@
SkBackingFit::kExact, kRenderSize, kRenderSize, GrColorType::kRGBA_8888, nullptr);
sk_sp<GrTextureProxy> proxies[2];
- GrColorType proxyColorTypes[2];
- if (!init_test_textures(resourceProvider, proxyProvider, &random, proxies, proxyColorTypes)) {
+ if (!init_test_textures(resourceProvider, proxyProvider, &random, proxies)) {
ERRORF(reporter, "Could not create test textures");
return;
}
- GrProcessorTestData testData(&random, context, rtc.get(), proxies, proxyColorTypes);
+ GrProcessorTestData testData(&random, context, rtc.get(), proxies);
auto inputTexture = make_input_texture(proxyProvider, kRenderSize, kRenderSize, 0.0f);
std::unique_ptr<GrColor[]> readData1(new GrColor[kRenderSize * kRenderSize]);
@@ -714,11 +709,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, GrColorType::kRGBA_8888,
+ render_fp(context, rtc.get(), fp.get(), inputTexture, kPremul_SkAlphaType,
readData1.get());
// Draw with clone and read back the results.
- render_fp(context, rtc.get(), clone.get(), inputTexture, GrColorType::kRGBA_8888,
+ render_fp(context, rtc.get(), clone.get(), inputTexture, kPremul_SkAlphaType,
readData2.get());
// Check that the results are the same.
diff --git a/tests/ProgramsTest.cpp b/tests/ProgramsTest.cpp
index 5225009..d12ba0d 100644
--- a/tests/ProgramsTest.cpp
+++ b/tests/ProgramsTest.cpp
@@ -261,7 +261,6 @@
GrProxyProvider* proxyProvider = context->priv().proxyProvider();
sk_sp<GrTextureProxy> proxies[2];
- GrColorType proxyColorTypes[2];
// setup dummy textures
GrMipMapped mipMapped = GrMipMapped(context->priv().caps()->mipMapSupport());
@@ -277,7 +276,6 @@
kBottomLeft_GrSurfaceOrigin, mipMapped,
SkBackingFit::kExact, SkBudgeted::kNo,
GrProtected::kNo, GrInternalSurfaceFlags::kNone);
- proxyColorTypes[0] = GrColorType::kRGBA_8888;
}
{
GrSurfaceDesc dummyDesc;
@@ -291,7 +289,6 @@
kTopLeft_GrSurfaceOrigin, mipMapped,
SkBackingFit::kExact, SkBudgeted::kNo,
GrProtected::kNo, GrInternalSurfaceFlags::kNone);
- proxyColorTypes[1] = GrColorType::kAlpha_8;
}
if (!proxies[0] || !proxies[1]) {
@@ -299,9 +296,6 @@
return false;
}
- // dummy scissor state
- GrScissorState scissor;
-
SkRandom random;
static const int NUM_TESTS = 1024;
for (int t = 0; t < NUM_TESTS; t++) {
@@ -314,8 +308,7 @@
}
GrPaint paint;
- GrProcessorTestData ptd(&random, context, renderTargetContext.get(), proxies,
- proxyColorTypes);
+ GrProcessorTestData ptd(&random, context, renderTargetContext.get(), proxies);
set_random_color_coverage_stages(&paint, &ptd, maxStages, maxLevels);
set_random_xpf(&paint, &ptd);
GrDrawRandomOp(&random, renderTargetContext.get(), std::move(paint));
@@ -340,8 +333,7 @@
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,
- proxyColorTypes);
+ GrProcessorTestData ptd(&random, context, renderTargetContext.get(), proxies);
GrPaint paint;
paint.setXPFactory(GrPorterDuffXPFactory::Get(SkBlendMode::kSrc));
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index 886cff3..547ba24 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,
- uint32_t expectedPixelValues[]) {
+ SkAlphaType alphaType, 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, colorType, SkMatrix::I(), filter);
+ auto fp = GrSimpleTextureEffect::Make(rectProxy, alphaType, SkMatrix::I(), filter);
GrPaint paint;
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
paint.addColorFragmentProcessor(std::move(fp));
@@ -185,7 +185,8 @@
SkASSERT(rectProxy->hasRestrictedSampling());
SkASSERT(rectProxy->peekTexture()->texturePriv().hasRestrictedSampling());
- test_basic_draw_as_src(reporter, context, rectProxy, GrColorType::kRGBA_8888, refPixels);
+ test_basic_draw_as_src(reporter, context, rectProxy, GrColorType::kRGBA_8888,
+ kPremul_SkAlphaType, 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 f9996dc..f7c692d 100644
--- a/tests/TestUtils.cpp
+++ b/tests/TestUtils.cpp
@@ -81,9 +81,8 @@
GrColorType colorType,
uint32_t expectedPixelValues[],
const char* testName) {
- sk_sp<GrTextureProxy> dstProxy = GrSurfaceProxy::Copy(context, proxy, colorType,
- GrMipMapped::kNo, SkBackingFit::kExact,
- SkBudgeted::kYes);
+ sk_sp<GrTextureProxy> dstProxy = GrSurfaceProxy::Copy(context, proxy, GrMipMapped::kNo,
+ SkBackingFit::kExact, SkBudgeted::kYes);
SkASSERT(dstProxy);
auto dstContext = context->priv().makeWrappedSurfaceContext(std::move(dstProxy), colorType,