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