Remove GrAA parameter from drawing functions that support per-edge AA
Bug: skia:13114 Change-Id: I653ab746927abdd1491e070e2e27252bf056d233 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/526024 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
This commit is contained in:
parent
e679a08f9a
commit
027b9c0d38
@ -151,7 +151,7 @@ protected:
|
||||
SkMatrixProvider matrixProvider(view);
|
||||
GrPaint grPaint;
|
||||
SkPaintToGrPaint(context, sdc->colorInfo(), paint, matrixProvider, &grPaint);
|
||||
sdc->drawQuadSet(nullptr, std::move(grPaint), GrAA::kYes, view, batch, kRectCount);
|
||||
sdc->drawQuadSet(nullptr, std::move(grPaint), view, batch, kRectCount);
|
||||
}
|
||||
|
||||
void drawSolidColorsRef(SkCanvas* canvas) const {
|
||||
|
@ -287,7 +287,6 @@ DrawResult ClockwiseGM::onDraw(GrRecordingContext* rContext, SkCanvas* canvas, S
|
||||
SK_PMColor4fWHITE,
|
||||
{0, 0, 100, 200},
|
||||
{100, 0, 200, 200},
|
||||
GrAA::kNo,
|
||||
GrQuadAAFlags::kNone,
|
||||
SkCanvas::SrcRectConstraint::kStrict_SrcRectConstraint,
|
||||
SkMatrix::I(),
|
||||
@ -311,7 +310,6 @@ DrawResult ClockwiseGM::onDraw(GrRecordingContext* rContext, SkCanvas* canvas, S
|
||||
SK_PMColor4fWHITE,
|
||||
{0, 0, 100, 200},
|
||||
{200, 0, 300, 200},
|
||||
GrAA::kNo,
|
||||
GrQuadAAFlags::kNone,
|
||||
SkCanvas::SrcRectConstraint::kStrict_SrcRectConstraint,
|
||||
SkMatrix::I(),
|
||||
|
@ -87,7 +87,7 @@ static void draw_gradient_tiles(SkCanvas* canvas, bool alignGradients) {
|
||||
SkMatrixProvider matrixProvider(view);
|
||||
GrPaint grPaint;
|
||||
SkPaintToGrPaint(rContext, sdc->colorInfo(), paint, matrixProvider, &grPaint);
|
||||
sdc->fillRectWithEdgeAA(nullptr, std::move(grPaint), GrAA::kYes,
|
||||
sdc->fillRectWithEdgeAA(nullptr, std::move(grPaint),
|
||||
static_cast<GrQuadAAFlags>(aa), view, tile);
|
||||
} else {
|
||||
// Fallback to solid color on raster backend since the public API only has color
|
||||
|
@ -257,18 +257,13 @@ enum class GrClampType {
|
||||
/**
|
||||
* A number of rectangle/quadrilateral drawing APIs can control anti-aliasing on a per edge basis.
|
||||
* These masks specify which edges are AA'ed. The intent for this is to support tiling with seamless
|
||||
* boundaries, where the inner edges are non-AA and the outer edges are AA. Regular draws (where AA
|
||||
* is specified by GrAA) is almost equivalent to kNone or kAll, with the exception of how MSAA is
|
||||
* handled.
|
||||
* boundaries, where the inner edges are non-AA and the outer edges are AA. Regular rectangle draws
|
||||
* simply use kAll or kNone depending on if they want anti-aliasing or not.
|
||||
*
|
||||
* When tiling and there is MSAA, mixed edge rectangles are processed with MSAA, so in order for the
|
||||
* tiled edges to remain seamless, inner tiles with kNone must also be processed with MSAA. In
|
||||
* regular drawing, however, kNone should disable MSAA (if it's supported) to match the expected
|
||||
* appearance.
|
||||
*
|
||||
* Therefore, APIs that use per-edge AA flags also take a GrAA value so that they can differentiate
|
||||
* between the regular and tiling use case behaviors. Tiling operations should always pass
|
||||
* GrAA::kYes while regular options should pass GrAA based on the SkPaint's anti-alias state.
|
||||
* In APIs that support per-edge AA, GrQuadAAFlags is the only AA-control parameter that is
|
||||
* provided (compared to the typical GrAA parameter). kNone is equivalent to GrAA::kNo, and any
|
||||
* other set of edge flags would require GrAA::kYes (with rendering output dependent on how that
|
||||
* maps to GrAAType for a given SurfaceDrawContext).
|
||||
*
|
||||
* These values are identical to SkCanvas::QuadAAFlags.
|
||||
*/
|
||||
|
@ -646,7 +646,6 @@ std::unique_ptr<skgpu::v1::SurfaceDrawContext> GaussianBlur(GrRecordingContext*
|
||||
SK_PMColor4fWHITE,
|
||||
SkRect::Make(srcRect),
|
||||
SkRect::Make(dstRect),
|
||||
GrAA::kNo,
|
||||
GrQuadAAFlags::kNone,
|
||||
SkCanvas::SrcRectConstraint::kFast_SrcRectConstraint,
|
||||
SkMatrix::I(),
|
||||
|
@ -481,16 +481,21 @@ void Device::drawEdgeAAQuad(const SkRect& rect,
|
||||
grPaint.setXPFactory(SkBlendMode_AsXPFactory(mode));
|
||||
}
|
||||
|
||||
// This is exclusively meant for tiling operations, so keep AA enabled to handle MSAA seaming
|
||||
GrQuadAAFlags grAA = SkToGrQuadAAFlags(aaFlags);
|
||||
if (clip) {
|
||||
// Use fillQuadWithEdgeAA
|
||||
fSurfaceDrawContext->fillQuadWithEdgeAA(this->clip(), std::move(grPaint), GrAA::kYes, grAA,
|
||||
this->localToDevice(), clip, nullptr);
|
||||
fSurfaceDrawContext->fillQuadWithEdgeAA(this->clip(),
|
||||
std::move(grPaint),
|
||||
SkToGrQuadAAFlags(aaFlags),
|
||||
this->localToDevice(),
|
||||
clip,
|
||||
nullptr);
|
||||
} else {
|
||||
// Use fillRectWithEdgeAA to preserve mathematical properties of dst being rectangular
|
||||
fSurfaceDrawContext->fillRectWithEdgeAA(this->clip(), std::move(grPaint), GrAA::kYes, grAA,
|
||||
this->localToDevice(), rect);
|
||||
fSurfaceDrawContext->fillRectWithEdgeAA(this->clip(),
|
||||
std::move(grPaint),
|
||||
SkToGrQuadAAFlags(aaFlags),
|
||||
this->localToDevice(),
|
||||
rect);
|
||||
}
|
||||
}
|
||||
|
||||
@ -785,8 +790,7 @@ void Device::drawImageRect(const SkImage* image,
|
||||
ASSERT_SINGLE_OWNER
|
||||
GrAA aa = fSurfaceDrawContext->chooseAA(paint);
|
||||
GrQuadAAFlags aaFlags = (aa == GrAA::kYes) ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone;
|
||||
this->drawImageQuad(image, src, &dst, nullptr, aa, aaFlags, nullptr, sampling, paint,
|
||||
constraint);
|
||||
this->drawImageQuad(image, src, &dst, nullptr, aaFlags, nullptr, sampling, paint, constraint);
|
||||
}
|
||||
|
||||
void Device::drawViewLattice(GrSurfaceProxyView view,
|
||||
|
@ -349,7 +349,6 @@ void draw_texture(skgpu::v1::SurfaceDrawContext* sdc,
|
||||
const SkRect& srcRect,
|
||||
const SkRect& dstRect,
|
||||
const SkPoint dstClip[4],
|
||||
GrAA aa,
|
||||
GrQuadAAFlags aaFlags,
|
||||
SkCanvas::SrcRectConstraint constraint,
|
||||
GrSurfaceProxyView view,
|
||||
@ -365,7 +364,7 @@ void draw_texture(skgpu::v1::SurfaceDrawContext* sdc,
|
||||
if (constraint != SkCanvas::kStrict_SrcRectConstraint && !proxy->isFunctionallyExact()) {
|
||||
// Conservative estimate of how much a coord could be outset from src rect:
|
||||
// 1/2 pixel for AA and 1/2 pixel for linear filtering
|
||||
float buffer = 0.5f * (aa == GrAA::kYes) +
|
||||
float buffer = 0.5f * (aaFlags != GrQuadAAFlags::kNone) +
|
||||
0.5f * (filter == GrSamplerState::Filter::kLinear);
|
||||
SkRect safeBounds = proxy->getBoundsRect();
|
||||
safeBounds.inset(buffer, buffer);
|
||||
@ -390,7 +389,6 @@ void draw_texture(skgpu::v1::SurfaceDrawContext* sdc,
|
||||
color,
|
||||
srcQuad,
|
||||
dstClip,
|
||||
aa,
|
||||
aaFlags,
|
||||
constraint == SkCanvas::kStrict_SrcRectConstraint ? &srcRect : nullptr,
|
||||
ctm,
|
||||
@ -405,7 +403,6 @@ void draw_texture(skgpu::v1::SurfaceDrawContext* sdc,
|
||||
color,
|
||||
srcRect,
|
||||
dstRect,
|
||||
aa,
|
||||
aaFlags,
|
||||
constraint,
|
||||
ctm,
|
||||
@ -424,7 +421,6 @@ void draw_image(GrRecordingContext* rContext,
|
||||
const SkRect& dst,
|
||||
const SkPoint dstClip[4],
|
||||
const SkMatrix& srcToDst,
|
||||
GrAA aa,
|
||||
GrQuadAAFlags aaFlags,
|
||||
SkCanvas::SrcRectConstraint constraint,
|
||||
SkSamplingOptions sampling,
|
||||
@ -449,7 +445,6 @@ void draw_image(GrRecordingContext* rContext,
|
||||
src,
|
||||
dst,
|
||||
dstClip,
|
||||
aa,
|
||||
aaFlags,
|
||||
constraint,
|
||||
std::move(view),
|
||||
@ -545,10 +540,10 @@ void draw_image(GrRecordingContext* rContext,
|
||||
GrMapRectPoints(dst, src, dstClip, srcClipPoints, 4);
|
||||
srcClip = srcClipPoints;
|
||||
}
|
||||
sdc->fillQuadWithEdgeAA(clip, std::move(grPaint), aa, aaFlags, ctm, dstClip, srcClip);
|
||||
sdc->fillQuadWithEdgeAA(clip, std::move(grPaint), aaFlags, ctm, dstClip, srcClip);
|
||||
} else {
|
||||
// Provide explicit texture coords when possible, otherwise rely on texture matrix
|
||||
sdc->fillRectWithEdgeAA(clip, std::move(grPaint), aa, aaFlags, ctm, dst,
|
||||
sdc->fillRectWithEdgeAA(clip, std::move(grPaint), aaFlags, ctm, dst,
|
||||
canUseTextureCoordsAsLocalCoords ? &src : nullptr);
|
||||
}
|
||||
} else {
|
||||
@ -580,7 +575,7 @@ void draw_tiled_bitmap(GrRecordingContext* rContext,
|
||||
const SkRect& srcRect,
|
||||
const SkIRect& clippedSrcIRect,
|
||||
const SkPaint& paint,
|
||||
GrAA aa,
|
||||
GrQuadAAFlags origAAFlags,
|
||||
SkCanvas::SrcRectConstraint constraint,
|
||||
SkSamplingOptions sampling,
|
||||
SkTileMode tileMode) {
|
||||
@ -636,20 +631,18 @@ void draw_tiled_bitmap(GrRecordingContext* rContext,
|
||||
image->height() <= rContext->priv().caps()->maxTextureSize());
|
||||
|
||||
GrQuadAAFlags aaFlags = GrQuadAAFlags::kNone;
|
||||
if (aa == GrAA::kYes) {
|
||||
// If the entire bitmap was anti-aliased, turn on AA for the outside tile edges.
|
||||
if (tileR.fLeft <= srcRect.fLeft) {
|
||||
aaFlags |= GrQuadAAFlags::kLeft;
|
||||
}
|
||||
if (tileR.fRight >= srcRect.fRight) {
|
||||
aaFlags |= GrQuadAAFlags::kRight;
|
||||
}
|
||||
if (tileR.fTop <= srcRect.fTop) {
|
||||
aaFlags |= GrQuadAAFlags::kTop;
|
||||
}
|
||||
if (tileR.fBottom >= srcRect.fBottom) {
|
||||
aaFlags |= GrQuadAAFlags::kBottom;
|
||||
}
|
||||
// Preserve the original edge AA flags for the exterior tile edges.
|
||||
if (tileR.fLeft <= srcRect.fLeft && (origAAFlags & GrQuadAAFlags::kLeft)) {
|
||||
aaFlags |= GrQuadAAFlags::kLeft;
|
||||
}
|
||||
if (tileR.fRight >= srcRect.fRight && (origAAFlags & GrQuadAAFlags::kRight)) {
|
||||
aaFlags |= GrQuadAAFlags::kRight;
|
||||
}
|
||||
if (tileR.fTop <= srcRect.fTop && (origAAFlags & GrQuadAAFlags::kTop)) {
|
||||
aaFlags |= GrQuadAAFlags::kTop;
|
||||
}
|
||||
if (tileR.fBottom >= srcRect.fBottom && (origAAFlags & GrQuadAAFlags::kBottom)) {
|
||||
aaFlags |= GrQuadAAFlags::kBottom;
|
||||
}
|
||||
|
||||
// now offset it to make it "local" to our tmp bitmap
|
||||
@ -666,7 +659,6 @@ void draw_tiled_bitmap(GrRecordingContext* rContext,
|
||||
rectToDraw,
|
||||
nullptr,
|
||||
offsetSrcToDst,
|
||||
aa,
|
||||
aaFlags,
|
||||
constraint,
|
||||
sampling,
|
||||
@ -746,7 +738,6 @@ void Device::drawSpecial(SkSpecialImage* special,
|
||||
dst,
|
||||
nullptr,
|
||||
srcToDst,
|
||||
aa,
|
||||
aaFlags,
|
||||
SkCanvas::kStrict_SrcRectConstraint,
|
||||
sampling);
|
||||
@ -756,7 +747,6 @@ void Device::drawImageQuad(const SkImage* image,
|
||||
const SkRect* srcRect,
|
||||
const SkRect* dstRect,
|
||||
const SkPoint dstClip[4],
|
||||
GrAA aa,
|
||||
GrQuadAAFlags aaFlags,
|
||||
const SkMatrix* preViewMatrix,
|
||||
const SkSamplingOptions& origSampling,
|
||||
@ -826,7 +816,7 @@ void Device::drawImageQuad(const SkImage* image,
|
||||
src,
|
||||
clippedSubset,
|
||||
paint,
|
||||
aa,
|
||||
aaFlags,
|
||||
constraint,
|
||||
sampling,
|
||||
tileMode);
|
||||
@ -845,7 +835,6 @@ void Device::drawImageQuad(const SkImage* image,
|
||||
dst,
|
||||
dstClip,
|
||||
srcToDst,
|
||||
aa,
|
||||
aaFlags,
|
||||
constraint,
|
||||
sampling);
|
||||
@ -870,10 +859,9 @@ void Device::drawEdgeAAImageSet(const SkCanvas::ImageSetEntry set[], int count,
|
||||
auto paintAlpha = paint.getAlphaf();
|
||||
entryPaint.writable()->setAlphaf(paintAlpha * set[i].fAlpha);
|
||||
}
|
||||
// Always send GrAA::kYes to preserve seaming across tiling in MSAA
|
||||
this->drawImageQuad(
|
||||
set[i].fImage.get(), &set[i].fSrcRect, &set[i].fDstRect,
|
||||
set[i].fHasClip ? dstClips + dstClipIndex : nullptr, GrAA::kYes,
|
||||
set[i].fHasClip ? dstClips + dstClipIndex : nullptr,
|
||||
SkToGrQuadAAFlags(set[i].fAAFlags),
|
||||
set[i].fMatrixIndex < 0 ? nullptr : preViewMatrices + set[i].fMatrixIndex,
|
||||
sampling, *entryPaint, constraint);
|
||||
@ -903,7 +891,6 @@ void Device::drawEdgeAAImageSet(const SkCanvas::ImageSetEntry set[], int count,
|
||||
filter,
|
||||
GrSamplerState::MipmapMode::kNone,
|
||||
mode,
|
||||
GrAA::kYes,
|
||||
constraint,
|
||||
this->localToDevice(),
|
||||
std::move(textureXform));
|
||||
@ -952,7 +939,7 @@ void Device::drawEdgeAAImageSet(const SkCanvas::ImageSetEntry set[], int count,
|
||||
entryPaint.writable()->setAlphaf(paintAlpha * set[i].fAlpha);
|
||||
}
|
||||
this->drawImageQuad(
|
||||
image, &set[i].fSrcRect, &set[i].fDstRect, clip, GrAA::kYes,
|
||||
image, &set[i].fSrcRect, &set[i].fDstRect, clip,
|
||||
SkToGrQuadAAFlags(set[i].fAAFlags),
|
||||
set[i].fMatrixIndex < 0 ? nullptr : preViewMatrices + set[i].fMatrixIndex,
|
||||
sampling, *entryPaint, constraint);
|
||||
|
@ -235,7 +235,7 @@ private:
|
||||
// If not null, dstClip must be contained inside dst and will also respect the edge AA flags.
|
||||
// If 'preViewMatrix' is not null, final CTM will be this->ctm() * preViewMatrix.
|
||||
void drawImageQuad(const SkImage*, const SkRect* src, const SkRect* dst,
|
||||
const SkPoint dstClip[4], GrAA aa, GrQuadAAFlags aaFlags,
|
||||
const SkPoint dstClip[4], GrQuadAAFlags aaFlags,
|
||||
const SkMatrix* preViewMatrix, const SkSamplingOptions&,
|
||||
const SkPaint&, SkCanvas::SrcRectConstraint);
|
||||
|
||||
|
@ -416,7 +416,9 @@ enum class SurfaceDrawContext::QuadOptimization {
|
||||
};
|
||||
|
||||
SurfaceDrawContext::QuadOptimization SurfaceDrawContext::attemptQuadOptimization(
|
||||
const GrClip* clip, const GrUserStencilSettings* stencilSettings, GrAA* aa, DrawQuad* quad,
|
||||
const GrClip* clip,
|
||||
const GrUserStencilSettings* stencilSettings,
|
||||
DrawQuad* quad,
|
||||
GrPaint* paint) {
|
||||
// Optimization requirements:
|
||||
// 1. kDiscard applies when clip bounds and quad bounds do not intersect
|
||||
@ -454,17 +456,18 @@ SurfaceDrawContext::QuadOptimization SurfaceDrawContext::attemptQuadOptimization
|
||||
return QuadOptimization::kCropped;
|
||||
}
|
||||
|
||||
GrAA drawUsesAA{quad->fEdgeFlags != GrQuadAAFlags::kNone};
|
||||
auto conservativeCrop = [&]() {
|
||||
static constexpr int kLargeDrawLimit = 15000;
|
||||
// Crop the quad to the render target. This doesn't change the visual results of drawing but
|
||||
// is meant to help numerical stability for excessively large draws.
|
||||
if (drawBounds.width() > kLargeDrawLimit || drawBounds.height() > kLargeDrawLimit) {
|
||||
GrQuadUtils::CropToRect(rtRect, *aa, quad, /* compute local */ !constColor);
|
||||
GrQuadUtils::CropToRect(rtRect, drawUsesAA, quad, /* compute local */ !constColor);
|
||||
}
|
||||
};
|
||||
|
||||
bool simpleColor = !stencilSettings && constColor;
|
||||
GrClip::PreClipResult result = clip ? clip->preApply(drawBounds, *aa)
|
||||
GrClip::PreClipResult result = clip ? clip->preApply(drawBounds, drawUsesAA)
|
||||
: GrClip::PreClipResult(GrClip::Effect::kUnclipped);
|
||||
switch(result.fEffect) {
|
||||
case GrClip::Effect::kClippedOut:
|
||||
@ -479,13 +482,11 @@ SurfaceDrawContext::QuadOptimization SurfaceDrawContext::attemptQuadOptimization
|
||||
// that any geometric clipping doesn't need to change aa or edge flags (since we
|
||||
// know this is on pixel boundaries, it will draw the same regardless).
|
||||
// See skbug.com/13114 for more details.
|
||||
GrAA clipAA = (*aa == GrAA::kNo || quad->fEdgeFlags == GrQuadAAFlags::kNone) ?
|
||||
GrAA::kNo : GrAA::kYes;
|
||||
result = GrClip::PreClipResult(SkRRect::MakeRect(rtRect), clipAA);
|
||||
result = GrClip::PreClipResult(SkRRect::MakeRect(rtRect), drawUsesAA);
|
||||
}
|
||||
break;
|
||||
case GrClip::Effect::kClipped:
|
||||
if (!result.fIsRRect || (stencilSettings && result.fAA != *aa) ||
|
||||
if (!result.fIsRRect || (stencilSettings && result.fAA != drawUsesAA) ||
|
||||
(!result.fRRect.isRect() && !simpleColor)) {
|
||||
// The clip and draw state are too complicated to try and reduce
|
||||
conservativeCrop();
|
||||
@ -533,18 +534,6 @@ SurfaceDrawContext::QuadOptimization SurfaceDrawContext::attemptQuadOptimization
|
||||
}
|
||||
}
|
||||
|
||||
// else the draw and clip were combined so just update the AA to reflect combination
|
||||
if (*aa == GrAA::kNo && result.fAA == GrAA::kYes &&
|
||||
quad->fEdgeFlags != GrQuadAAFlags::kNone) {
|
||||
// The clip was anti-aliased and now the draw needs to be upgraded to AA to
|
||||
// properly reflect the smooth edge of the clip.
|
||||
*aa = GrAA::kYes;
|
||||
}
|
||||
// We intentionally do not downgrade AA here because we don't know if we need to
|
||||
// preserve MSAA (see GrQuadAAFlags docs). But later in the pipeline, the ops can
|
||||
// use GrResolveAATypeForQuad() to turn off coverage AA when all flags are off.
|
||||
// deviceQuad is exactly the intersection of original quad and clip, so it can be
|
||||
// drawn with no clip (submitted by caller)
|
||||
return QuadOptimization::kClipApplied;
|
||||
}
|
||||
} else {
|
||||
@ -571,7 +560,6 @@ SurfaceDrawContext::QuadOptimization SurfaceDrawContext::attemptQuadOptimization
|
||||
|
||||
void SurfaceDrawContext::drawFilledQuad(const GrClip* clip,
|
||||
GrPaint&& paint,
|
||||
GrAA aa,
|
||||
DrawQuad* quad,
|
||||
const GrUserStencilSettings* ss) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
@ -581,10 +569,12 @@ void SurfaceDrawContext::drawFilledQuad(const GrClip* clip,
|
||||
|
||||
AutoCheckFlush acf(this->drawingManager());
|
||||
|
||||
QuadOptimization opt = this->attemptQuadOptimization(clip, ss, &aa, quad, &paint);
|
||||
QuadOptimization opt = this->attemptQuadOptimization(clip, ss, quad, &paint);
|
||||
if (opt >= QuadOptimization::kClipApplied) {
|
||||
// These optimizations require caller to add an op themselves
|
||||
const GrClip* finalClip = opt == QuadOptimization::kClipApplied ? nullptr : clip;
|
||||
// The quad being drawn requires AA if any of its edges requires AA
|
||||
GrAA aa{quad->fEdgeFlags != GrQuadAAFlags::kNone};
|
||||
GrAAType aaType;
|
||||
if (ss) {
|
||||
aaType = (aa == GrAA::kYes) ? GrAAType::kMSAA : GrAAType::kNone;
|
||||
@ -611,13 +601,14 @@ void SurfaceDrawContext::drawTexture(const GrClip* clip,
|
||||
const SkPMColor4f& color,
|
||||
const SkRect& srcRect,
|
||||
const SkRect& dstRect,
|
||||
GrAA aa,
|
||||
GrQuadAAFlags edgeAA,
|
||||
SkCanvas::SrcRectConstraint constraint,
|
||||
const SkMatrix& viewMatrix,
|
||||
sk_sp<GrColorSpaceXform> colorSpaceXform) {
|
||||
// If we are using dmsaa then go through FillRRectOp (via fillRectToRect).
|
||||
if ((this->alwaysAntialias() || this->caps()->reducedShaderMode()) && aa == GrAA::kYes) {
|
||||
if ((this->alwaysAntialias() || this->caps()->reducedShaderMode()) &&
|
||||
edgeAA != GrQuadAAFlags::kNone) {
|
||||
|
||||
GrPaint paint;
|
||||
paint.setColor4f(color);
|
||||
std::unique_ptr<GrFragmentProcessor> fp;
|
||||
@ -645,7 +636,7 @@ void SurfaceDrawContext::drawTexture(const GrClip* clip,
|
||||
DrawQuad quad{GrQuad::MakeFromRect(dstRect, viewMatrix), GrQuad(srcRect), edgeAA};
|
||||
|
||||
this->drawTexturedQuad(clip, std::move(view), srcAlphaType, std::move(colorSpaceXform), filter,
|
||||
mm, color, blendMode, aa, &quad, subset);
|
||||
mm, color, blendMode, &quad, subset);
|
||||
}
|
||||
|
||||
void SurfaceDrawContext::drawTexturedQuad(const GrClip* clip,
|
||||
@ -656,7 +647,6 @@ void SurfaceDrawContext::drawTexturedQuad(const GrClip* clip,
|
||||
GrSamplerState::MipmapMode mm,
|
||||
const SkPMColor4f& color,
|
||||
SkBlendMode blendMode,
|
||||
GrAA aa,
|
||||
DrawQuad* quad,
|
||||
const SkRect* subset) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
@ -669,14 +659,14 @@ void SurfaceDrawContext::drawTexturedQuad(const GrClip* clip,
|
||||
|
||||
// Functionally this is very similar to drawFilledQuad except that there's no constColor to
|
||||
// enable the kSubmitted optimizations, no stencil settings support, and its a TextureOp.
|
||||
QuadOptimization opt = this->attemptQuadOptimization(clip, nullptr/*stencil*/, &aa, quad,
|
||||
QuadOptimization opt = this->attemptQuadOptimization(clip, nullptr/*stencil*/, quad,
|
||||
nullptr/*paint*/);
|
||||
|
||||
SkASSERT(opt != QuadOptimization::kSubmitted);
|
||||
if (opt != QuadOptimization::kDiscarded) {
|
||||
// And the texture op if not discarded
|
||||
// Add the texture op if not discarded
|
||||
const GrClip* finalClip = opt == QuadOptimization::kClipApplied ? nullptr : clip;
|
||||
GrAAType aaType = this->chooseAAType(aa);
|
||||
GrAAType aaType = this->chooseAAType(GrAA{quad->fEdgeFlags != GrQuadAAFlags::kNone});
|
||||
auto clampType = GrColorTypeClampType(this->colorInfo().colorType());
|
||||
auto saturate = clampType == GrClampType::kManual ? TextureOp::Saturate::kYes
|
||||
: TextureOp::Saturate::kNo;
|
||||
@ -757,7 +747,7 @@ void SurfaceDrawContext::fillRectToRect(const GrClip* clip,
|
||||
aa == GrAA::kYes) { // If aa is kNo when using dmsaa, the rect is axis aligned. Don't use
|
||||
// FillRRectOp because it might require dual source blending.
|
||||
// http://skbug.com/11756
|
||||
QuadOptimization opt = this->attemptQuadOptimization(clip, nullptr/*stencil*/, &aa, &quad,
|
||||
QuadOptimization opt = this->attemptQuadOptimization(clip, nullptr/*stencil*/, &quad,
|
||||
&paint);
|
||||
if (opt < QuadOptimization::kClipApplied) {
|
||||
// The optimization was completely handled inside attempt().
|
||||
@ -795,16 +785,15 @@ void SurfaceDrawContext::fillRectToRect(const GrClip* clip,
|
||||
}
|
||||
|
||||
assert_alive(paint);
|
||||
this->drawFilledQuad(clip, std::move(paint), aa, &quad);
|
||||
this->drawFilledQuad(clip, std::move(paint), &quad);
|
||||
}
|
||||
|
||||
void SurfaceDrawContext::drawQuadSet(const GrClip* clip,
|
||||
GrPaint&& paint,
|
||||
GrAA aa,
|
||||
const SkMatrix& viewMatrix,
|
||||
const GrQuadSetEntry quads[],
|
||||
int cnt) {
|
||||
GrAAType aaType = this->chooseAAType(aa);
|
||||
GrAAType aaType = this->chooseAAType(GrAA::kYes);
|
||||
|
||||
FillRectOp::AddFillRectOps(this, clip, fContext, std::move(paint), aaType, viewMatrix,
|
||||
quads, cnt);
|
||||
@ -917,7 +906,6 @@ void SurfaceDrawContext::drawTextureSet(const GrClip* clip,
|
||||
GrSamplerState::Filter filter,
|
||||
GrSamplerState::MipmapMode mm,
|
||||
SkBlendMode mode,
|
||||
GrAA aa,
|
||||
SkCanvas::SrcRectConstraint constraint,
|
||||
const SkMatrix& viewMatrix,
|
||||
sk_sp<GrColorSpaceXform> texXform) {
|
||||
@ -929,7 +917,7 @@ void SurfaceDrawContext::drawTextureSet(const GrClip* clip,
|
||||
// Create the minimum number of GrTextureOps needed to draw this set. Individual
|
||||
// GrTextureOps can rebind the texture between draws thus avoiding GrPaint (re)creation.
|
||||
AutoCheckFlush acf(this->drawingManager());
|
||||
GrAAType aaType = this->chooseAAType(aa);
|
||||
GrAAType aaType = this->chooseAAType(GrAA::kYes);
|
||||
auto clampType = GrColorTypeClampType(this->colorInfo().colorType());
|
||||
auto saturate = clampType == GrClampType::kManual ? TextureOp::Saturate::kYes
|
||||
: TextureOp::Saturate::kNo;
|
||||
@ -1734,7 +1722,7 @@ void SurfaceDrawContext::drawStrokedLine(const GrClip* clip,
|
||||
GrQuadAAFlags edgeAA = (aa == GrAA::kYes) ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone;
|
||||
|
||||
assert_alive(paint);
|
||||
this->fillQuadWithEdgeAA(clip, std::move(paint), aa, edgeAA, viewMatrix, corners, nullptr);
|
||||
this->fillQuadWithEdgeAA(clip, std::move(paint), edgeAA, viewMatrix, corners, nullptr);
|
||||
}
|
||||
|
||||
bool SurfaceDrawContext::drawSimpleShape(const GrClip* clip,
|
||||
|
@ -185,7 +185,7 @@ public:
|
||||
SkRect rect = SkRect::Make(bounds);
|
||||
DrawQuad quad{GrQuad::MakeFromRect(rect, SkMatrix::I()),
|
||||
GrQuad::MakeFromRect(rect, localMatrix), GrQuadAAFlags::kNone};
|
||||
this->drawFilledQuad(clip, std::move(paint), GrAA::kNo, &quad);
|
||||
this->drawFilledQuad(clip, std::move(paint), &quad);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -194,17 +194,17 @@ public:
|
||||
* This is a specialized version of fillQuadWithEdgeAA, but is kept separate since knowing
|
||||
* the geometry is a rectangle affords more optimizations.
|
||||
*/
|
||||
void fillRectWithEdgeAA(const GrClip* clip, GrPaint&& paint, GrAA aa, GrQuadAAFlags edgeAA,
|
||||
void fillRectWithEdgeAA(const GrClip* clip, GrPaint&& paint, GrQuadAAFlags edgeAA,
|
||||
const SkMatrix& viewMatrix, const SkRect& rect,
|
||||
const SkRect* optionalLocalRect = nullptr) {
|
||||
if (edgeAA == GrQuadAAFlags::kAll) {
|
||||
this->fillRectToRect(clip, std::move(paint), aa, viewMatrix, rect,
|
||||
this->fillRectToRect(clip, std::move(paint), GrAA::kYes, viewMatrix, rect,
|
||||
(optionalLocalRect) ? *optionalLocalRect : rect);
|
||||
return;
|
||||
}
|
||||
const SkRect& localRect = optionalLocalRect ? *optionalLocalRect : rect;
|
||||
DrawQuad quad{GrQuad::MakeFromRect(rect, viewMatrix), GrQuad(localRect), edgeAA};
|
||||
this->drawFilledQuad(clip, std::move(paint), aa, &quad);
|
||||
this->drawFilledQuad(clip, std::move(paint), &quad);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -219,17 +219,17 @@ public:
|
||||
* The last argument, 'optionalLocalQuad', can be null if no separate local coordinates are
|
||||
* necessary.
|
||||
*/
|
||||
void fillQuadWithEdgeAA(const GrClip* clip, GrPaint&& paint, GrAA aa, GrQuadAAFlags edgeAA,
|
||||
void fillQuadWithEdgeAA(const GrClip* clip, GrPaint&& paint, GrQuadAAFlags edgeAA,
|
||||
const SkMatrix& viewMatrix, const SkPoint points[4],
|
||||
const SkPoint optionalLocalPoints[4]) {
|
||||
const SkPoint* localPoints = optionalLocalPoints ? optionalLocalPoints : points;
|
||||
DrawQuad quad{GrQuad::MakeFromSkQuad(points, viewMatrix),
|
||||
GrQuad::MakeFromSkQuad(localPoints, SkMatrix::I()), edgeAA};
|
||||
this->drawFilledQuad(clip, std::move(paint), aa, &quad);
|
||||
this->drawFilledQuad(clip, std::move(paint), &quad);
|
||||
}
|
||||
|
||||
// TODO(michaelludwig) - remove if the bulk API is not useful for SkiaRenderer
|
||||
void drawQuadSet(const GrClip* clip, GrPaint&& paint, GrAA aa, const SkMatrix& viewMatrix,
|
||||
void drawQuadSet(const GrClip* clip, GrPaint&& paint, const SkMatrix& viewMatrix,
|
||||
const GrQuadSetEntry[], int cnt);
|
||||
|
||||
/**
|
||||
@ -247,7 +247,6 @@ public:
|
||||
const SkPMColor4f&,
|
||||
const SkRect& srcRect,
|
||||
const SkRect& dstRect,
|
||||
GrAA,
|
||||
GrQuadAAFlags,
|
||||
SkCanvas::SrcRectConstraint,
|
||||
const SkMatrix&,
|
||||
@ -269,7 +268,6 @@ public:
|
||||
const SkPMColor4f& color,
|
||||
const SkPoint srcQuad[4],
|
||||
const SkPoint dstQuad[4],
|
||||
GrAA aa,
|
||||
GrQuadAAFlags edgeAA,
|
||||
const SkRect* subset,
|
||||
const SkMatrix& viewMatrix,
|
||||
@ -277,7 +275,7 @@ public:
|
||||
DrawQuad quad{GrQuad::MakeFromSkQuad(dstQuad, viewMatrix),
|
||||
GrQuad::MakeFromSkQuad(srcQuad, SkMatrix::I()), edgeAA};
|
||||
this->drawTexturedQuad(clip, std::move(view), srcAlphaType, std::move(texXform), filter, mm,
|
||||
color, mode, aa, &quad, subset);
|
||||
color, mode, &quad, subset);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -298,7 +296,6 @@ public:
|
||||
GrSamplerState::Filter,
|
||||
GrSamplerState::MipmapMode,
|
||||
SkBlendMode mode,
|
||||
GrAA aa,
|
||||
SkCanvas::SrcRectConstraint,
|
||||
const SkMatrix& viewMatrix,
|
||||
sk_sp<GrColorSpaceXform> texXform);
|
||||
@ -559,7 +556,7 @@ public:
|
||||
DrawQuad quad{GrQuad::MakeFromRect(rect, viewMatrix),
|
||||
localMatrix ? GrQuad::MakeFromRect(rect, *localMatrix) : GrQuad(rect),
|
||||
doStencilMSAA == GrAA::kYes ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone};
|
||||
this->drawFilledQuad(clip, std::move(paint), doStencilMSAA, &quad, ss);
|
||||
this->drawFilledQuad(clip, std::move(paint), &quad, ss);
|
||||
}
|
||||
|
||||
// Fills the user stencil bits with a non-zero value at every sample inside the path. This will
|
||||
@ -663,23 +660,22 @@ private:
|
||||
// 'stencilSettings' are provided merely for decision making purposes; When non-null,
|
||||
// optimization strategies that submit special ops are avoided.
|
||||
//
|
||||
// 'aa' and 'quad' should be the original draw request on input, and will be updated as
|
||||
// 'quad' should be the original draw request on input, and will be updated as
|
||||
// appropriate depending on the returned optimization level.
|
||||
//
|
||||
// If kSubmitted is returned, the provided paint was consumed. Otherwise it is left unchanged.
|
||||
QuadOptimization attemptQuadOptimization(const GrClip* clip,
|
||||
const GrUserStencilSettings* stencilSettings,
|
||||
GrAA* aa,
|
||||
DrawQuad* quad,
|
||||
GrPaint* paint);
|
||||
|
||||
// If stencil settings, 'ss', are non-null, AA controls MSAA or no AA. If they are null, then AA
|
||||
// can choose between coverage, MSAA as per chooseAAType(). This will always attempt to apply
|
||||
// The overall AA policy is determined by the quad's edge flags: kNone is no AA, and anything
|
||||
// else uses some form of anti-aliasing. If 'ss' is non-null, that will be MSAA; otherwise it's
|
||||
// MSAA or analytic coverage per chooseAAType(). This will always attempt to apply
|
||||
// quad optimizations, so all quad/rect public APIs should rely on this function for consistent
|
||||
// clipping behavior. 'quad' will be modified in place to reflect final rendered geometry.
|
||||
void drawFilledQuad(const GrClip* clip,
|
||||
GrPaint&& paint,
|
||||
GrAA aa,
|
||||
DrawQuad* quad,
|
||||
const GrUserStencilSettings* ss = nullptr);
|
||||
|
||||
@ -693,7 +689,6 @@ private:
|
||||
GrSamplerState::MipmapMode,
|
||||
const SkPMColor4f& color,
|
||||
SkBlendMode blendMode,
|
||||
GrAA aa,
|
||||
DrawQuad* quad,
|
||||
const SkRect* subset = nullptr);
|
||||
|
||||
|
@ -402,7 +402,6 @@ static std::unique_ptr<skgpu::v1::SurfaceDrawContext> draw_mipmap_into_new_rende
|
||||
{1, 1, 1, 1},
|
||||
SkRect::MakeWH(4, 4),
|
||||
SkRect::MakeWH(1, 1),
|
||||
GrAA::kYes,
|
||||
GrQuadAAFlags::kAll,
|
||||
SkCanvas::kFast_SrcRectConstraint,
|
||||
SkMatrix::I(),
|
||||
|
@ -198,7 +198,6 @@ public:
|
||||
{1.0f, 1.0f, 1.0f, 1.0f},
|
||||
SkRect::MakeWH(wh, wh),
|
||||
SkRect::MakeWH(wh, wh),
|
||||
GrAA::kNo,
|
||||
GrQuadAAFlags::kNone,
|
||||
SkCanvas::kFast_SrcRectConstraint,
|
||||
SkMatrix::I(),
|
||||
|
Loading…
Reference in New Issue
Block a user