Reland "Remove antialiasing control from GrPaint."
This contains fixes for GLPrograms test and mixed samples rendering.
This reverts commit 419d81eed4
.
BUG=skia:
Change-Id: If8f002fbfaaaab6d1607403f2b15ccc7f1e17e87
Reviewed-on: https://skia-review.googlesource.com/5763
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
d263413a2a
commit
3944484020
@ -195,7 +195,8 @@ protected:
|
||||
sk_sp<GrDrawOp> batch = sk_make_sp<BezierCubicOrConicTestBatch>(
|
||||
gp, bounds, color, klmEqs, klmSigns[c]);
|
||||
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get());
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, GrAAType::kNone,
|
||||
batch.get());
|
||||
}
|
||||
++col;
|
||||
if (numCols == col) {
|
||||
@ -327,7 +328,8 @@ protected:
|
||||
sk_sp<GrDrawOp> batch(
|
||||
new BezierCubicOrConicTestBatch(gp, bounds, color, klmEqs, 1.f));
|
||||
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get());
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, GrAAType::kNone,
|
||||
batch.get());
|
||||
}
|
||||
++col;
|
||||
if (numCols == col) {
|
||||
@ -538,7 +540,8 @@ protected:
|
||||
|
||||
sk_sp<GrDrawOp> batch(new BezierQuadTestBatch(gp, bounds, color, DevToUV));
|
||||
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get());
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, GrAAType::kNone,
|
||||
batch.get());
|
||||
}
|
||||
++col;
|
||||
if (numCols == col) {
|
||||
|
@ -90,7 +90,8 @@ protected:
|
||||
sk_sp<GrDrawOp> batch(
|
||||
GrRectBatchFactory::CreateNonAAFill(0xff000000, SkMatrix::I(), bounds,
|
||||
nullptr, nullptr));
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get());
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, GrAAType::kNone,
|
||||
batch.get());
|
||||
}
|
||||
canvas->restore();
|
||||
x = x + fTestOffsetX;
|
||||
|
@ -112,7 +112,8 @@ protected:
|
||||
sk_sp<GrDrawOp> batch(
|
||||
GrRectBatchFactory::CreateNonAAFill(grPaint.getColor(), viewMatrix,
|
||||
renderRect, nullptr, nullptr));
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get());
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, GrAAType::kNone,
|
||||
batch.get());
|
||||
|
||||
// Draw labels for the input to the processor and the processor to the right of
|
||||
// the test rect. The input label appears above the processor label.
|
||||
|
@ -185,7 +185,8 @@ protected:
|
||||
|
||||
sk_sp<GrDrawOp> batch(new PolyBoundsBatch(p.getBounds(), 0xff000000));
|
||||
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get());
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, GrAAType::kNone,
|
||||
batch.get());
|
||||
|
||||
x += SkScalarCeilToScalar(path->getBounds().width() + kDX);
|
||||
}
|
||||
@ -224,7 +225,8 @@ protected:
|
||||
|
||||
sk_sp<GrDrawOp> batch(new PolyBoundsBatch(rect, 0xff000000));
|
||||
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get());
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, GrAAType::kNone,
|
||||
batch.get());
|
||||
|
||||
x += SkScalarCeilToScalar(rect.width() + kDX);
|
||||
}
|
||||
|
@ -118,7 +118,9 @@ protected:
|
||||
sk_sp<GrDrawOp> batch(
|
||||
GrRectBatchFactory::CreateNonAAFill(0xff000000, SkMatrix::I(),
|
||||
bounds, nullptr, nullptr));
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get());
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint,
|
||||
GrAAType::kNone,
|
||||
batch.get());
|
||||
} else {
|
||||
drew = false;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ DEF_SIMPLE_GM_BG(texdata, canvas, 2 * S, 2 * S, SK_ColorBLACK) {
|
||||
tm.postIDiv(2*S, 2*S);
|
||||
paint.addColorTextureProcessor(texture, nullptr, tm);
|
||||
|
||||
renderTargetContext->drawRect(clip, paint, vm, SkRect::MakeWH(2*S, 2*S));
|
||||
renderTargetContext->drawRect(clip, paint, GrAA::kNo, vm, SkRect::MakeWH(2*S, 2*S));
|
||||
|
||||
// now update the lower right of the texture in first pass
|
||||
// or upper right in second pass
|
||||
@ -116,7 +116,7 @@ DEF_SIMPLE_GM_BG(texdata, canvas, 2 * S, 2 * S, SK_ColorBLACK) {
|
||||
texture->writePixels(S, (i ? 0 : S), S, S,
|
||||
texture->config(), gTextureData.get(),
|
||||
4 * stride);
|
||||
renderTargetContext->drawRect(clip, paint, vm, SkRect::MakeWH(2*S, 2*S));
|
||||
renderTargetContext->drawRect(clip, paint, GrAA::kNo, vm, SkRect::MakeWH(2*S, 2*S));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -130,7 +130,8 @@ protected:
|
||||
sk_sp<GrDrawOp> batch(
|
||||
GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, viewMatrix,
|
||||
renderRect, nullptr, nullptr));
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get());
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, GrAAType::kNone,
|
||||
batch.get());
|
||||
x += renderRect.width() + kTestPad;
|
||||
}
|
||||
y += renderRect.height() + kTestPad;
|
||||
|
@ -141,7 +141,7 @@ private:
|
||||
class MaskOnlyClipBase : public GrClip {
|
||||
private:
|
||||
bool quickContains(const SkRect&) const final { return false; }
|
||||
bool isRRect(const SkRect& rtBounds, SkRRect* rr, bool* aa) const final { return false; }
|
||||
bool isRRect(const SkRect& rtBounds, SkRRect* rr, GrAA*) const final { return false; }
|
||||
void getConservativeBounds(int width, int height, SkIRect* rect, bool* iior) const final {
|
||||
rect->set(0, 0, width, height);
|
||||
if (iior) {
|
||||
@ -190,7 +190,6 @@ void WindowRectanglesMaskGM::onCoverClipStack(const SkClipStack& stack, SkCanvas
|
||||
const GrReducedClip reducedClip(stack, SkRect::Make(kCoverRect), kNumWindows);
|
||||
|
||||
GrPaint paint;
|
||||
paint.setAntiAlias(true);
|
||||
if (!rtc->isStencilBufferMultisampled()) {
|
||||
paint.setColor4f(GrColor4f(0, 0.25f, 1, 1));
|
||||
this->visualizeAlphaMask(ctx, rtc, reducedClip, paint);
|
||||
@ -217,7 +216,7 @@ void WindowRectanglesMaskGM::visualizeAlphaMask(GrContext* ctx, GrRenderTargetCo
|
||||
this->stencilCheckerboard(maskRTC.get(), true);
|
||||
maskRTC->clear(nullptr, GrColorPackA4(0xff), true);
|
||||
maskRTC->priv().drawAndStencilRect(StencilOnlyClip(), &GrUserStencilSettings::kUnused,
|
||||
SkRegion::kDifference_Op, false, false, SkMatrix::I(),
|
||||
SkRegion::kDifference_Op, false, GrAA::kNo, SkMatrix::I(),
|
||||
SkRect::MakeIWH(maskRTC->width(), maskRTC->height()));
|
||||
reducedClip.drawAlphaClipMask(maskRTC.get());
|
||||
sk_sp<GrTexture> mask(maskRTC->asTexture());
|
||||
@ -229,7 +228,7 @@ void WindowRectanglesMaskGM::visualizeAlphaMask(GrContext* ctx, GrRenderTargetCo
|
||||
// inside window rectangles or outside the scissor should still have the initial checkerboard
|
||||
// intact. (This verifies we didn't spend any time modifying those pixels in the mask.)
|
||||
AlphaOnlyClip clip(mask.get(), x, y);
|
||||
rtc->drawRect(clip, paint, SkMatrix::I(),
|
||||
rtc->drawRect(clip, paint, GrAA::kYes, SkMatrix::I(),
|
||||
SkRect::Make(SkIRect::MakeXYWH(x, y, mask->width(), mask->height())));
|
||||
}
|
||||
|
||||
@ -268,7 +267,7 @@ void WindowRectanglesMaskGM::stencilCheckerboard(GrRenderTargetContext* rtc, boo
|
||||
for (int x = (y & 1) == flip ? 0 : kMaskCheckerSize;
|
||||
x < kLayerRect.width(); x += 2 * kMaskCheckerSize) {
|
||||
SkIRect checker = SkIRect::MakeXYWH(x, y, kMaskCheckerSize, kMaskCheckerSize);
|
||||
rtc->priv().stencilRect(GrNoClip(), &kSetClip, false, SkMatrix::I(),
|
||||
rtc->priv().stencilRect(GrNoClip(), &kSetClip, GrAAType::kNone, SkMatrix::I(),
|
||||
SkRect::Make(checker));
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +129,8 @@ protected:
|
||||
sk_sp<GrDrawOp> batch(
|
||||
GrRectBatchFactory::CreateNonAAFill(GrColor_WHITE, viewMatrix,
|
||||
renderRect, nullptr, nullptr));
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get());
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, GrAAType::kNone,
|
||||
batch.get());
|
||||
}
|
||||
x += renderRect.width() + kTestPad;
|
||||
}
|
||||
@ -244,7 +245,8 @@ protected:
|
||||
grPaint.addColorFragmentProcessor(fp);
|
||||
sk_sp<GrDrawOp> batch(GrRectBatchFactory::CreateNonAAFill(
|
||||
GrColor_WHITE, viewMatrix, renderRect, nullptr, nullptr));
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get());
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, GrAAType::kNone,
|
||||
batch.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#ifndef GrClip_DEFINED
|
||||
#define GrClip_DEFINED
|
||||
|
||||
#include "GrTypes.h"
|
||||
#include "SkRect.h"
|
||||
#include "SkRRect.h"
|
||||
|
||||
@ -45,7 +46,7 @@ public:
|
||||
* @return true if the clip is equivalent to a single rrect, false otherwise.
|
||||
*
|
||||
*/
|
||||
virtual bool isRRect(const SkRect& rtBounds, SkRRect* rrect, bool* aa) const = 0;
|
||||
virtual bool isRRect(const SkRect& rtBounds, SkRRect* rrect, GrAA* aa) const = 0;
|
||||
|
||||
/**
|
||||
* This is the maximum distance that a draw may extend beyond a clip's boundary and still count
|
||||
@ -140,7 +141,7 @@ private:
|
||||
bool apply(GrContext*, GrRenderTargetContext*, bool, bool, GrAppliedClip*) const final {
|
||||
return true;
|
||||
}
|
||||
bool isRRect(const SkRect&, SkRRect*, bool*) const override { return false; }
|
||||
bool isRRect(const SkRect&, SkRRect*, GrAA*) const override { return false; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -30,10 +30,9 @@
|
||||
* The primitive color computation starts with the color specified by setColor(). This color is the
|
||||
* input to the first color stage. Each color stage feeds its output to the next color stage.
|
||||
*
|
||||
* Fractional pixel coverage follows a similar flow. The coverage is initially the value specified
|
||||
* by setCoverage(). This is input to the first coverage stage. Coverage stages are chained
|
||||
* together in the same manner as color stages. The output of the last stage is modulated by any
|
||||
* fractional coverage produced by anti-aliasing. This last step produces the final coverage, C.
|
||||
* Fractional pixel coverage follows a similar flow. The GrGeometryProcessor (specified elsewhere)
|
||||
* provides the initial coverage which is passed to the first coverage fragment processor, which
|
||||
* feeds its output to next coverage fragment processor.
|
||||
*
|
||||
* setXPFactory is used to control blending between the output color and dest. It also implements
|
||||
* the application of fractional coverage from the coverage pipeline.
|
||||
@ -57,12 +56,6 @@ public:
|
||||
*/
|
||||
GrColor getColor() const { return fColor.toGrColor(); }
|
||||
|
||||
/**
|
||||
* Should primitives be anti-aliased or not. Defaults to false.
|
||||
*/
|
||||
void setAntiAlias(bool aa) { fAntiAlias = aa; }
|
||||
bool isAntiAlias() const { return fAntiAlias; }
|
||||
|
||||
/**
|
||||
* Should shader output conversion from linear to sRGB be disabled.
|
||||
* Only relevant if the destination is sRGB. Defaults to false.
|
||||
@ -146,7 +139,6 @@ public:
|
||||
}
|
||||
|
||||
GrPaint& operator=(const GrPaint& paint) {
|
||||
fAntiAlias = paint.fAntiAlias;
|
||||
fDisableOutputConversionToSRGB = paint.fDisableOutputConversionToSRGB;
|
||||
fAllowSRGBInputs = paint.fAllowSRGBInputs;
|
||||
fUsesDistanceVectorField = paint.fUsesDistanceVectorField;
|
||||
@ -185,7 +177,6 @@ private:
|
||||
SkSTArray<4, sk_sp<GrFragmentProcessor>> fColorFragmentProcessors;
|
||||
SkSTArray<2, sk_sp<GrFragmentProcessor>> fCoverageFragmentProcessors;
|
||||
|
||||
bool fAntiAlias;
|
||||
bool fDisableOutputConversionToSRGB;
|
||||
bool fAllowSRGBInputs;
|
||||
bool fUsesDistanceVectorField;
|
||||
|
@ -90,6 +90,7 @@ public:
|
||||
/**
|
||||
* Draw the rect using a paint.
|
||||
* @param paint describes how to color pixels.
|
||||
* @param GrAA Controls whether rect is antialiased
|
||||
* @param viewMatrix transformation matrix
|
||||
* @param style The style to apply. Null means fill. Currently path effects are not
|
||||
* allowed.
|
||||
@ -97,6 +98,7 @@ public:
|
||||
*/
|
||||
void drawRect(const GrClip&,
|
||||
const GrPaint& paint,
|
||||
GrAA,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect&,
|
||||
const GrStyle* style = nullptr);
|
||||
@ -105,12 +107,14 @@ public:
|
||||
* Maps a rectangle of shader coordinates to a rectangle and fills that rectangle.
|
||||
*
|
||||
* @param paint describes how to color pixels.
|
||||
* @param GrAA Controls whether rect is antialiased
|
||||
* @param viewMatrix transformation matrix which applies to rectToDraw
|
||||
* @param rectToDraw the rectangle to draw
|
||||
* @param localRect the rectangle of shader coordinates applied to rectToDraw
|
||||
*/
|
||||
void fillRectToRect(const GrClip&,
|
||||
const GrPaint& paint,
|
||||
GrAA,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& rectToDraw,
|
||||
const SkRect& localRect);
|
||||
@ -120,6 +124,7 @@ public:
|
||||
*/
|
||||
void fillRectWithLocalMatrix(const GrClip& clip,
|
||||
const GrPaint& paint,
|
||||
GrAA,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& rect,
|
||||
const SkMatrix& localMatrix);
|
||||
@ -128,12 +133,14 @@ public:
|
||||
* Draw a roundrect using a paint.
|
||||
*
|
||||
* @param paint describes how to color pixels.
|
||||
* @param GrAA Controls whether rrect is antialiased.
|
||||
* @param viewMatrix transformation matrix
|
||||
* @param rrect the roundrect to draw
|
||||
* @param style style to apply to the rrect. Currently path effects are not allowed.
|
||||
*/
|
||||
void drawRRect(const GrClip&,
|
||||
const GrPaint&,
|
||||
GrAA,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRRect& rrect,
|
||||
const GrStyle& style);
|
||||
@ -156,17 +163,18 @@ public:
|
||||
const GrStyle& style);
|
||||
|
||||
/**
|
||||
* Shortcut for drawing an SkPath consisting of nested rrects using a paint.
|
||||
* Does not support stroking. The result is undefined if outer does not contain
|
||||
* inner.
|
||||
* Shortcut for filling a SkPath consisting of nested rrects using a paint. The result is
|
||||
* undefined if outer does not contain inner.
|
||||
*
|
||||
* @param paint describes how to color pixels.
|
||||
* @param GrAA Controls whether rrects edges are antialiased
|
||||
* @param viewMatrix transformation matrix
|
||||
* @param outer the outer roundrect
|
||||
* @param inner the inner roundrect
|
||||
*/
|
||||
void drawDRRect(const GrClip&,
|
||||
const GrPaint&,
|
||||
GrAA,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRRect& outer,
|
||||
const SkRRect& inner);
|
||||
@ -175,12 +183,14 @@ public:
|
||||
* Draws a path.
|
||||
*
|
||||
* @param paint describes how to color pixels.
|
||||
* @param GrAA Controls whether the path is antialiased.
|
||||
* @param viewMatrix transformation matrix
|
||||
* @param path the path to draw
|
||||
* @param style style to apply to the path.
|
||||
*/
|
||||
void drawPath(const GrClip&,
|
||||
const GrPaint&,
|
||||
GrAA,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkPath&,
|
||||
const GrStyle& style);
|
||||
@ -214,7 +224,8 @@ public:
|
||||
int indexCount);
|
||||
|
||||
/**
|
||||
* Draws textured sprites from an atlas with a paint.
|
||||
* Draws textured sprites from an atlas with a paint. This currently does not support AA for the
|
||||
* sprite rectangle edges.
|
||||
*
|
||||
* @param paint describes how to color pixels.
|
||||
* @param viewMatrix transformation matrix
|
||||
@ -237,11 +248,13 @@ public:
|
||||
*
|
||||
* @param paint describes how to color pixels
|
||||
* @param viewMatrix transformation matrix
|
||||
* @param aa should the rects of the region be antialiased.
|
||||
* @param region the region to be drawn
|
||||
* @param style style to apply to the region
|
||||
*/
|
||||
void drawRegion(const GrClip&,
|
||||
const GrPaint& paint,
|
||||
GrAA aa,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRegion& region,
|
||||
const GrStyle& style);
|
||||
@ -250,12 +263,14 @@ public:
|
||||
* Draws an oval.
|
||||
*
|
||||
* @param paint describes how to color pixels.
|
||||
* @param GrAA Controls whether the oval is antialiased.
|
||||
* @param viewMatrix transformation matrix
|
||||
* @param oval the bounding rect of the oval.
|
||||
* @param style style to apply to the oval. Currently path effects are not allowed.
|
||||
*/
|
||||
void drawOval(const GrClip&,
|
||||
const GrPaint& paint,
|
||||
GrAA,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& oval,
|
||||
const GrStyle& style);
|
||||
@ -263,18 +278,20 @@ public:
|
||||
* Draws a partial arc of an oval.
|
||||
*
|
||||
* @param paint describes how to color pixels.
|
||||
* @param GrGrAA Controls whether the arc is antialiased.
|
||||
* @param viewMatrix transformation matrix.
|
||||
* @param oval the bounding rect of the oval.
|
||||
* @param startAngle starting angle in degrees.
|
||||
* @param sweepAngle angle to sweep in degrees. Must be in (-360, 360)
|
||||
* @param useCenter true means that the implied path begins at the oval center, connects as a
|
||||
* line to the point indicated by the start contains the arc indicated by
|
||||
* @param useCenter true means that the implied path begins at the oval center, connects as
|
||||
* a line to the point indicated by the start contains the arc indicated by
|
||||
* the sweep angle. If false the line beginning at the center point is
|
||||
* omitted.
|
||||
* @param style style to apply to the oval.
|
||||
*/
|
||||
void drawArc(const GrClip&,
|
||||
const GrPaint& paint,
|
||||
GrAA,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& oval,
|
||||
SkScalar startAngle,
|
||||
@ -333,10 +350,6 @@ public:
|
||||
bool isUnifiedMultisampled() const { return fRenderTargetProxy->isUnifiedMultisampled(); }
|
||||
bool hasMixedSamples() const { return fRenderTargetProxy->isMixedSampled(); }
|
||||
|
||||
bool mustUseHWAA(const GrPaint& paint) const {
|
||||
return paint.isAntiAlias() && fRenderTargetProxy->isUnifiedMultisampled();
|
||||
}
|
||||
|
||||
const GrCaps* caps() const { return fContext->caps(); }
|
||||
const GrSurfaceDesc& desc() const { return fRenderTargetProxy->desc(); }
|
||||
int width() const { return fRenderTargetProxy->width(); }
|
||||
@ -392,6 +405,19 @@ protected:
|
||||
SkDEBUGCODE(void validate() const;)
|
||||
|
||||
private:
|
||||
inline GrAAType decideAAType(GrAA aa, bool allowMixedSamples = false) {
|
||||
if (GrAA::kNo == aa) {
|
||||
return GrAAType::kNone;
|
||||
}
|
||||
if (this->isUnifiedMultisampled()) {
|
||||
return GrAAType::kMSAA;
|
||||
}
|
||||
if (allowMixedSamples && this->isStencilBufferMultisampled()) {
|
||||
return GrAAType::kMixedSamples;
|
||||
}
|
||||
return GrAAType::kCoverage;
|
||||
}
|
||||
|
||||
friend class GrAtlasTextBlob; // for access to addDrawOp
|
||||
friend class GrStencilAndCoverTextContext; // for access to addDrawOp
|
||||
|
||||
@ -417,12 +443,14 @@ private:
|
||||
|
||||
bool drawFilledDRRect(const GrClip& clip,
|
||||
const GrPaint& paint,
|
||||
GrAA,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRRect& origOuter,
|
||||
const SkRRect& origInner);
|
||||
|
||||
bool drawFilledRect(const GrClip& clip,
|
||||
const GrPaint& paint,
|
||||
GrAA,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& rect,
|
||||
const GrUserStencilSettings* ss);
|
||||
@ -434,13 +462,14 @@ private:
|
||||
const SkRect* localRect,
|
||||
const SkMatrix* localMatrix,
|
||||
const GrUserStencilSettings* ss,
|
||||
bool useHWAA);
|
||||
GrAAType hwOrNoneAAType);
|
||||
|
||||
void internalDrawPath(const GrClip& clip,
|
||||
const GrPaint& paint,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkPath& path,
|
||||
const GrStyle& style);
|
||||
void internalDrawPath(const GrClip&,
|
||||
const GrPaint&,
|
||||
GrAA,
|
||||
const SkMatrix&,
|
||||
const SkPath&,
|
||||
const GrStyle&);
|
||||
|
||||
// This entry point allows the GrTextContext-derived classes to add their ops to the GrOpList.
|
||||
void addDrawOp(const GrPipelineBuilder&, const GrClip&, GrDrawOp*);
|
||||
|
@ -148,6 +148,18 @@ typedef intptr_t GrBackendContext;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Used to control antialiasing in draw calls.
|
||||
*/
|
||||
enum class GrAA {
|
||||
kYes,
|
||||
kNo
|
||||
};
|
||||
|
||||
static inline GrAA GrBoolToAA(bool aa) { return aa ? GrAA::kYes : GrAA::kNo; }
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Geometric primitives used for drawing.
|
||||
*/
|
||||
|
@ -11,6 +11,21 @@
|
||||
#include "GrTypes.h"
|
||||
#include "SkRefCnt.h"
|
||||
|
||||
/** This enum indicates the type of antialiasing to be performed. */
|
||||
enum class GrAAType {
|
||||
/** No antialiasing */
|
||||
kNone,
|
||||
/** Use fragment shader code to compute a fractional pixel coverage. */
|
||||
kCoverage,
|
||||
/** Use normal MSAA. */
|
||||
kMSAA,
|
||||
/**
|
||||
* Use "mixed samples" MSAA such that the stencil buffer is multisampled but the color buffer is
|
||||
* not.
|
||||
*/
|
||||
kMixedSamples
|
||||
};
|
||||
|
||||
/**
|
||||
* Types of shader-language-specific boxed variables we can create. (Currently only GrGLShaderVars,
|
||||
* but should be applicable to other shader languages.)
|
||||
|
@ -84,7 +84,7 @@ static void convolve_gaussian_1d(GrRenderTargetContext* renderTargetContext,
|
||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
SkMatrix localMatrix = SkMatrix::MakeTrans(-SkIntToScalar(srcOffset.x()),
|
||||
-SkIntToScalar(srcOffset.y()));
|
||||
renderTargetContext->fillRectWithLocalMatrix(clip, paint, SkMatrix::I(),
|
||||
renderTargetContext->fillRectWithLocalMatrix(clip, paint, GrAA::kNo, SkMatrix::I(),
|
||||
SkRect::Make(dstRect), localMatrix);
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ static void convolve_gaussian_2d(GrRenderTargetContext* renderTargetContext,
|
||||
true, sigmaX, sigmaY));
|
||||
paint.addColorFragmentProcessor(std::move(conv));
|
||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
renderTargetContext->fillRectWithLocalMatrix(clip, paint, SkMatrix::I(),
|
||||
renderTargetContext->fillRectWithLocalMatrix(clip, paint, GrAA::kNo, SkMatrix::I(),
|
||||
SkRect::Make(dstRect), localMatrix);
|
||||
}
|
||||
|
||||
@ -289,7 +289,7 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context,
|
||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
shrink_irect_by_2(&dstRect, i < scaleFactorX, i < scaleFactorY);
|
||||
|
||||
dstRenderTargetContext->fillRectToRect(clip, paint, SkMatrix::I(),
|
||||
dstRenderTargetContext->fillRectToRect(clip, paint, GrAA::kNo, SkMatrix::I(),
|
||||
SkRect::Make(dstRect), SkRect::Make(srcRect));
|
||||
|
||||
srcRenderTargetContext = dstRenderTargetContext;
|
||||
@ -381,7 +381,7 @@ sk_sp<GrRenderTargetContext> GaussianBlur(GrContext* context,
|
||||
SkIRect dstRect(srcRect);
|
||||
scale_irect(&dstRect, scaleFactorX, scaleFactorY);
|
||||
|
||||
dstRenderTargetContext->fillRectToRect(clip, paint, SkMatrix::I(),
|
||||
dstRenderTargetContext->fillRectToRect(clip, paint, GrAA::kNo, SkMatrix::I(),
|
||||
SkRect::Make(dstRect), SkRect::Make(srcRect));
|
||||
|
||||
srcRenderTargetContext = dstRenderTargetContext;
|
||||
|
@ -297,7 +297,7 @@ sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context,
|
||||
SkRect srcRect = SkRect::Make(bounds);
|
||||
SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
|
||||
GrFixedClip clip(dstIRect);
|
||||
renderTargetContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect);
|
||||
renderTargetContext->fillRectToRect(clip, paint, GrAA::kNo, SkMatrix::I(), dstRect, srcRect);
|
||||
|
||||
return SkSpecialImage::MakeDeferredFromGpu(context, dstIRect,
|
||||
kNeedNewImageUniqueID_SpecialImage,
|
||||
|
@ -114,7 +114,7 @@ sk_sp<GrTextureProxy> SkAlphaThresholdFilterImpl::createMaskTexture(GrContext* c
|
||||
GrFixedClip clip(SkIRect::MakeWH(bounds.width(), bounds.height()));
|
||||
while (!iter.done()) {
|
||||
SkRect rect = SkRect::Make(iter.rect());
|
||||
rtContext->drawRect(clip, grPaint, inMatrix, rect);
|
||||
rtContext->drawRect(clip, grPaint, GrAA::kNo, inMatrix, rect);
|
||||
iter.next();
|
||||
}
|
||||
|
||||
|
@ -1060,7 +1060,8 @@ bool SkBlurMaskFilterImpl::directFilterMaskGPU(GrTextureProvider* texProvider,
|
||||
return false;
|
||||
}
|
||||
|
||||
renderTargetContext->fillRectWithLocalMatrix(clip, *grp, SkMatrix::I(), rect, inverse);
|
||||
renderTargetContext->fillRectWithLocalMatrix(clip, *grp, GrAA::kNo, SkMatrix::I(), rect,
|
||||
inverse);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1103,8 +1104,7 @@ private:
|
||||
static sk_sp<GrTexture> find_or_create_rrect_blur_mask(GrContext* context,
|
||||
const SkRRect& rrectToDraw,
|
||||
const SkISize& size,
|
||||
float xformedSigma,
|
||||
bool doAA) {
|
||||
float xformedSigma) {
|
||||
static const GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
|
||||
GrUniqueKey key;
|
||||
GrUniqueKey::Builder builder(&key, kDomain, 9);
|
||||
@ -1129,10 +1129,10 @@ static sk_sp<GrTexture> find_or_create_rrect_blur_mask(GrContext* context,
|
||||
}
|
||||
|
||||
GrPaint grPaint;
|
||||
grPaint.setAntiAlias(doAA);
|
||||
|
||||
rtc->clear(nullptr, 0x0, true);
|
||||
rtc->drawRRect(GrNoClip(), grPaint, SkMatrix::I(), rrectToDraw, GrStyle::SimpleFill());
|
||||
rtc->drawRRect(GrNoClip(), grPaint, GrAA::kYes, SkMatrix::I(), rrectToDraw,
|
||||
GrStyle::SimpleFill());
|
||||
|
||||
sk_sp<GrTexture> srcTexture(rtc->asTexture());
|
||||
if (!srcTexture) {
|
||||
@ -1192,8 +1192,7 @@ sk_sp<GrFragmentProcessor> GrRRectBlurEffect::Make(GrContext* context,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sk_sp<GrTexture> mask(find_or_create_rrect_blur_mask(context, rrectToDraw, size,
|
||||
xformedSigma, true));
|
||||
sk_sp<GrTexture> mask(find_or_create_rrect_blur_mask(context, rrectToDraw, size, xformedSigma));
|
||||
if (!mask) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -1380,12 +1379,11 @@ bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context,
|
||||
|
||||
GrPaint newPaint(*grp);
|
||||
newPaint.addCoverageFragmentProcessor(std::move(fp));
|
||||
newPaint.setAntiAlias(false);
|
||||
|
||||
SkRect srcProxyRect = srcRRect.rect();
|
||||
srcProxyRect.outset(3.0f*fSigma, 3.0f*fSigma);
|
||||
|
||||
renderTargetContext->drawRect(clip, newPaint, viewMatrix, srcProxyRect);
|
||||
renderTargetContext->drawRect(clip, newPaint, GrAA::kNo, viewMatrix, srcProxyRect);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1397,7 +1395,6 @@ bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context,
|
||||
|
||||
GrPaint newPaint(*grp);
|
||||
newPaint.addCoverageFragmentProcessor(std::move(fp));
|
||||
newPaint.setAntiAlias(false);
|
||||
|
||||
if (!this->ignoreXform()) {
|
||||
SkRect srcProxyRect = srcRRect.rect();
|
||||
@ -1444,8 +1441,8 @@ bool SkBlurMaskFilterImpl::directFilterRRectMaskGPU(GrContext* context,
|
||||
proxyRect.outset(extra, extra);
|
||||
|
||||
|
||||
renderTargetContext->fillRectWithLocalMatrix(clip, newPaint, SkMatrix::I(), proxyRect,
|
||||
inverse);
|
||||
renderTargetContext->fillRectWithLocalMatrix(clip, newPaint, GrAA::kNo, SkMatrix::I(),
|
||||
proxyRect, inverse);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -1538,7 +1535,8 @@ bool SkBlurMaskFilterImpl::filterMaskGPU(GrTexture* src,
|
||||
paint.setCoverageSetOpXPFactory(SkRegion::kReplace_Op);
|
||||
}
|
||||
|
||||
renderTargetContext->drawRect(GrNoClip(), paint, SkMatrix::I(), SkRect::Make(clipRect));
|
||||
renderTargetContext->drawRect(GrNoClip(), paint, GrAA::kNo, SkMatrix::I(),
|
||||
SkRect::Make(clipRect));
|
||||
}
|
||||
|
||||
*result = renderTargetContext->asTexture().release();
|
||||
|
@ -360,7 +360,8 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffect::onFilterImage(SkSpecialImage* sou
|
||||
}
|
||||
paint.setGammaCorrect(renderTargetContext->isGammaCorrect());
|
||||
|
||||
renderTargetContext->drawRect(GrNoClip(), paint, matrix, SkRect::Make(colorBounds));
|
||||
renderTargetContext->drawRect(GrNoClip(), paint, GrAA::kNo, matrix,
|
||||
SkRect::Make(colorBounds));
|
||||
|
||||
offset->fX = bounds.left();
|
||||
offset->fY = bounds.top();
|
||||
|
@ -400,7 +400,7 @@ void SkLightingImageFilterInternal::drawRect(GrRenderTargetContext* renderTarget
|
||||
boundaryMode));
|
||||
paint.addColorFragmentProcessor(std::move(fp));
|
||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
renderTargetContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect);
|
||||
renderTargetContext->fillRectToRect(clip, paint, GrAA::kNo, SkMatrix::I(), dstRect, srcRect);
|
||||
}
|
||||
|
||||
sk_sp<SkSpecialImage> SkLightingImageFilterInternal::filterImageGPU(
|
||||
|
@ -407,7 +407,8 @@ static void apply_morphology_rect(GrTextureProvider* provider,
|
||||
paint.addColorFragmentProcessor(GrMorphologyEffect::Make(tex, direction, radius, morphType,
|
||||
bounds));
|
||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
renderTargetContext->fillRectToRect(clip, paint, SkMatrix::I(), SkRect::Make(dstRect),
|
||||
renderTargetContext->fillRectToRect(clip, paint, GrAA::kNo,
|
||||
SkMatrix::I(), SkRect::Make(dstRect),
|
||||
SkRect::Make(srcRect));
|
||||
}
|
||||
|
||||
@ -428,8 +429,8 @@ static void apply_morphology_rect_no_bounds(GrTextureProvider* provider,
|
||||
}
|
||||
paint.addColorFragmentProcessor(GrMorphologyEffect::Make(tex, direction, radius, morphType));
|
||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
renderTargetContext->fillRectToRect(clip, paint, SkMatrix::I(), SkRect::Make(dstRect),
|
||||
SkRect::Make(srcRect));
|
||||
renderTargetContext->fillRectToRect(clip, paint, GrAA::kNo, SkMatrix::I(),
|
||||
SkRect::Make(dstRect), SkRect::Make(srcRect));
|
||||
}
|
||||
|
||||
static void apply_morphology_pass(GrTextureProvider* provider,
|
||||
|
@ -252,7 +252,6 @@ bool SkShadowMaskFilterImpl::directFilterRRectMaskGPU(GrContext*,
|
||||
const SkScalar devSpaceAmbientRadius = srcSpaceAmbientRadius * scaleFactor;
|
||||
|
||||
GrPaint newPaint(*grp);
|
||||
newPaint.setAntiAlias(true);
|
||||
GrColor4f color = newPaint.getColor4f();
|
||||
color.fRGBA[3] *= fAmbientAlpha;
|
||||
newPaint.setColor4f(color);
|
||||
@ -311,7 +310,6 @@ bool SkShadowMaskFilterImpl::directFilterRRectMaskGPU(GrContext*,
|
||||
(spotShadowRRect.width() + srcSpaceSpotRadius);
|
||||
|
||||
GrPaint newPaint(*grp);
|
||||
newPaint.setAntiAlias(true);
|
||||
GrColor4f color = newPaint.getColor4f();
|
||||
color.fRGBA[3] *= fSpotAlpha;
|
||||
newPaint.setColor4f(color);
|
||||
|
@ -303,7 +303,7 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilter_Base::filterImageGPU(
|
||||
|
||||
SkMatrix matrix;
|
||||
matrix.setTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()));
|
||||
renderTargetContext->drawRect(GrNoClip(), paint, matrix, SkRect::Make(bounds));
|
||||
renderTargetContext->drawRect(GrNoClip(), paint, GrAA::kNo, matrix, SkRect::Make(bounds));
|
||||
|
||||
return SkSpecialImage::MakeDeferredFromGpu(context,
|
||||
SkIRect::MakeWH(bounds.width(), bounds.height()),
|
||||
|
@ -45,8 +45,8 @@ static bool draw_mask(GrRenderTargetContext* renderTargetContext,
|
||||
if (!viewMatrix.invert(&inverse)) {
|
||||
return false;
|
||||
}
|
||||
renderTargetContext->fillRectWithLocalMatrix(clip, *grp, SkMatrix::I(), SkRect::Make(maskRect),
|
||||
inverse);
|
||||
renderTargetContext->fillRectWithLocalMatrix(clip, *grp, GrAA::kNo, SkMatrix::I(),
|
||||
SkRect::Make(maskRect), inverse);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -98,9 +98,9 @@ static sk_sp<GrTextureProxy> create_mask_GPU(GrContext* context,
|
||||
const SkIRect& maskRect,
|
||||
const SkPath& devPath,
|
||||
SkStrokeRec::InitStyle fillOrHairline,
|
||||
bool doAA,
|
||||
GrAA aa,
|
||||
int sampleCnt) {
|
||||
if (!doAA) {
|
||||
if (GrAA::kNo == aa) {
|
||||
// Don't need MSAA if mask isn't AA
|
||||
sampleCnt = 0;
|
||||
}
|
||||
@ -115,7 +115,6 @@ static sk_sp<GrTextureProxy> create_mask_GPU(GrContext* context,
|
||||
rtContext->priv().absClear(nullptr, 0x0);
|
||||
|
||||
GrPaint tempPaint;
|
||||
tempPaint.setAntiAlias(doAA);
|
||||
tempPaint.setCoverageSetOpXPFactory(SkRegion::kReplace_Op);
|
||||
|
||||
// setup new clip
|
||||
@ -126,7 +125,7 @@ static sk_sp<GrTextureProxy> create_mask_GPU(GrContext* context,
|
||||
// the origin using tempPaint.
|
||||
SkMatrix translate;
|
||||
translate.setTranslate(-SkIntToScalar(maskRect.fLeft), -SkIntToScalar(maskRect.fTop));
|
||||
rtContext->drawPath(clip, tempPaint, translate, devPath, GrStyle(fillOrHairline));
|
||||
rtContext->drawPath(clip, tempPaint, aa, translate, devPath, GrStyle(fillOrHairline));
|
||||
return sk_ref_sp(rtContext->asDeferredTexture());
|
||||
}
|
||||
|
||||
@ -134,6 +133,7 @@ static void draw_path_with_mask_filter(GrContext* context,
|
||||
GrRenderTargetContext* renderTargetContext,
|
||||
const GrClip& clip,
|
||||
GrPaint* paint,
|
||||
GrAA aa,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkMaskFilter* maskFilter,
|
||||
const GrStyle& style,
|
||||
@ -211,7 +211,7 @@ static void draw_path_with_mask_filter(GrContext* context,
|
||||
finalIRect,
|
||||
*path,
|
||||
fillOrHairline,
|
||||
paint->isAntiAlias(),
|
||||
aa,
|
||||
renderTargetContext->numColorSamples()));
|
||||
if (maskProxy) {
|
||||
GrTexture* filtered;
|
||||
@ -242,11 +242,12 @@ void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
|
||||
const GrClip& clip,
|
||||
const SkPath& path,
|
||||
GrPaint* paint,
|
||||
GrAA aa,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkMaskFilter* mf,
|
||||
const GrStyle& style,
|
||||
bool pathIsMutable) {
|
||||
draw_path_with_mask_filter(context, renderTargetContext, clip, paint, viewMatrix, mf,
|
||||
draw_path_with_mask_filter(context, renderTargetContext, clip, paint, aa, viewMatrix, mf,
|
||||
style, &path, pathIsMutable);
|
||||
}
|
||||
|
||||
@ -290,14 +291,14 @@ void GrBlurUtils::drawPathWithMaskFilter(GrContext* context,
|
||||
if (!SkPaintToGrPaint(context, renderTargetContext, paint, viewMatrix, &grPaint)) {
|
||||
return;
|
||||
}
|
||||
|
||||
GrAA aa = GrBoolToAA(paint.isAntiAlias());
|
||||
SkMaskFilter* mf = paint.getMaskFilter();
|
||||
if (mf && !mf->asFragmentProcessor(nullptr, nullptr, viewMatrix)) {
|
||||
// The MaskFilter wasn't already handled in SkPaintToGrPaint
|
||||
draw_path_with_mask_filter(context, renderTargetContext, clip, &grPaint, viewMatrix,
|
||||
draw_path_with_mask_filter(context, renderTargetContext, clip, &grPaint, aa, viewMatrix,
|
||||
mf, style,
|
||||
path, pathIsMutable);
|
||||
} else {
|
||||
renderTargetContext->drawPath(clip, grPaint, viewMatrix, *path, style);
|
||||
renderTargetContext->drawPath(clip, grPaint, aa, viewMatrix, *path, style);
|
||||
}
|
||||
}
|
||||
|
@ -8,11 +8,13 @@
|
||||
#ifndef GrBlurUtils_DEFINED
|
||||
#define GrBlurUtils_DEFINED
|
||||
|
||||
#include "GrTypes.h"
|
||||
|
||||
class GrClip;
|
||||
class GrContext;
|
||||
class GrRenderTargetContext;
|
||||
class GrPaint;
|
||||
class GrRenderTarget;
|
||||
class GrRenderTargetContext;
|
||||
class GrStyle;
|
||||
struct SkIRect;
|
||||
class SkMaskFilter;
|
||||
@ -48,6 +50,7 @@ namespace GrBlurUtils {
|
||||
const GrClip&,
|
||||
const SkPath& path,
|
||||
GrPaint*,
|
||||
GrAA,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkMaskFilter*,
|
||||
const GrStyle&,
|
||||
|
@ -42,7 +42,7 @@ bool GrClipStackClip::quickContains(const SkRRect& rrect) const {
|
||||
SkIntToScalar(fOrigin.fY)));
|
||||
}
|
||||
|
||||
bool GrClipStackClip::isRRect(const SkRect& origRTBounds, SkRRect* rr, bool* aa) const {
|
||||
bool GrClipStackClip::isRRect(const SkRect& origRTBounds, SkRRect* rr, GrAA* aa) const {
|
||||
if (!fStack) {
|
||||
return false;
|
||||
}
|
||||
@ -54,7 +54,9 @@ bool GrClipStackClip::isRRect(const SkRect& origRTBounds, SkRRect* rr, bool* aa)
|
||||
tempRTBounds.offset(SkIntToScalar(fOrigin.fX), SkIntToScalar(fOrigin.fY));
|
||||
rtBounds = &tempRTBounds;
|
||||
}
|
||||
if (fStack->isRRect(*rtBounds, rr, aa)) {
|
||||
bool isAA;
|
||||
if (fStack->isRRect(*rtBounds, rr, &isAA)) {
|
||||
*aa = GrBoolToAA(isAA);
|
||||
if (origin) {
|
||||
rr->offset(-SkIntToScalar(fOrigin.fX), -SkIntToScalar(fOrigin.fY));
|
||||
}
|
||||
@ -132,9 +134,16 @@ bool GrClipStackClip::PathNeedsSWRenderer(GrContext* context,
|
||||
canDrawArgs.fShaderCaps = context->caps()->shaderCaps();
|
||||
canDrawArgs.fViewMatrix = &viewMatrix;
|
||||
canDrawArgs.fShape = &shape;
|
||||
canDrawArgs.fAntiAlias = element->isAA();
|
||||
if (!element->isAA()) {
|
||||
canDrawArgs.fAAType = GrAAType::kNone;
|
||||
} else if (renderTargetContext->isUnifiedMultisampled()) {
|
||||
canDrawArgs.fAAType = GrAAType::kMSAA;
|
||||
} else if (renderTargetContext->isStencilBufferMultisampled()){
|
||||
canDrawArgs.fAAType = GrAAType::kMixedSamples;
|
||||
} else {
|
||||
canDrawArgs.fAAType = GrAAType::kCoverage;
|
||||
}
|
||||
canDrawArgs.fHasUserStencilSettings = hasUserStencilSettings;
|
||||
canDrawArgs.fIsStencilBufferMSAA = renderTargetContext->isStencilBufferMultisampled();
|
||||
|
||||
// the 'false' parameter disallows use of the SW path renderer
|
||||
GrPathRenderer* pr =
|
||||
@ -450,6 +459,7 @@ sk_sp<GrTexture> GrClipStackClip::CreateSoftwareClipMask(GrTextureProvider* texP
|
||||
for (ElementList::Iter iter(reducedClip.elements()); iter.get(); iter.next()) {
|
||||
const Element* element = iter.get();
|
||||
SkClipOp op = element->getOp();
|
||||
GrAA aa = GrBoolToAA(element->isAA());
|
||||
|
||||
if (kIntersect_SkClipOp == op || kReverseDifference_SkClipOp == op) {
|
||||
// Intersect and reverse difference require modifying pixels outside of the geometry
|
||||
@ -459,25 +469,25 @@ sk_sp<GrTexture> GrClipStackClip::CreateSoftwareClipMask(GrTextureProvider* texP
|
||||
if (kReverseDifference_SkClipOp == op) {
|
||||
SkRect temp = SkRect::Make(reducedClip.ibounds());
|
||||
// invert the entire scene
|
||||
helper.drawRect(temp, SkRegion::kXOR_Op, false, 0xFF);
|
||||
helper.drawRect(temp, SkRegion::kXOR_Op, GrAA::kNo, 0xFF);
|
||||
}
|
||||
SkPath clipPath;
|
||||
element->asPath(&clipPath);
|
||||
clipPath.toggleInverseFillType();
|
||||
GrShape shape(clipPath, GrStyle::SimpleFill());
|
||||
helper.drawShape(shape, SkRegion::kReplace_Op, element->isAA(), 0x00);
|
||||
helper.drawShape(shape, SkRegion::kReplace_Op, aa, 0x00);
|
||||
continue;
|
||||
}
|
||||
|
||||
// The other ops (union, xor, diff) only affect pixels inside
|
||||
// the geometry so they can just be drawn normally
|
||||
if (Element::kRect_Type == element->getType()) {
|
||||
helper.drawRect(element->getRect(), (SkRegion::Op)op, element->isAA(), 0xFF);
|
||||
helper.drawRect(element->getRect(), (SkRegion::Op)op, aa, 0xFF);
|
||||
} else {
|
||||
SkPath path;
|
||||
element->asPath(&path);
|
||||
GrShape shape(path, GrStyle::SimpleFill());
|
||||
helper.drawShape(shape, (SkRegion::Op)op, element->isAA(), 0xFF);
|
||||
helper.drawShape(shape, (SkRegion::Op)op, aa, 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
bool apply(GrContext*, GrRenderTargetContext*, bool useHWAA, bool hasUserStencilSettings,
|
||||
GrAppliedClip* out) const final;
|
||||
|
||||
bool isRRect(const SkRect& rtBounds, SkRRect* rr, bool* aa) const override;
|
||||
bool isRRect(const SkRect& rtBounds, SkRRect* rr, GrAA* aa) const override;
|
||||
|
||||
private:
|
||||
static bool PathNeedsSWRenderer(GrContext* context,
|
||||
|
@ -366,7 +366,7 @@ bool GrContext::writeSurfacePixels(GrSurface* surface,
|
||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
paint.setAllowSRGBInputs(true);
|
||||
SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
|
||||
renderTargetContext->drawRect(GrNoClip(), paint, matrix, rect, nullptr);
|
||||
renderTargetContext->drawRect(GrNoClip(), paint, GrAA::kNo, matrix, rect, nullptr);
|
||||
|
||||
if (kFlushWrites_PixelOp & pixelOpsFlags) {
|
||||
this->flushSurfaceWrites(surface);
|
||||
@ -486,7 +486,7 @@ bool GrContext::readSurfacePixels(GrSurface* src,
|
||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
paint.setAllowSRGBInputs(true);
|
||||
SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
|
||||
tempRTC->drawRect(GrNoClip(), paint, SkMatrix::I(), rect, nullptr);
|
||||
tempRTC->drawRect(GrNoClip(), paint, GrAA::kNo, SkMatrix::I(), rect, nullptr);
|
||||
surfaceToRead.reset(tempRTC->asTexture().release());
|
||||
left = 0;
|
||||
top = 0;
|
||||
|
@ -222,8 +222,10 @@ GrPathRenderer* GrDrawingManager::getPathRenderer(const GrPathRenderer::CanDrawP
|
||||
new GrSoftwarePathRenderer(fContext->textureProvider(),
|
||||
fOptionsForPathRendererChain.fAllowPathMaskCaching);
|
||||
}
|
||||
if (fSoftwarePathRenderer->canDrawPath(args)) {
|
||||
pr = fSoftwarePathRenderer;
|
||||
}
|
||||
}
|
||||
|
||||
return pr;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ void GrFixedClip::getConservativeBounds(int w, int h, SkIRect* devResult, bool*
|
||||
}
|
||||
}
|
||||
|
||||
bool GrFixedClip::isRRect(const SkRect& rtBounds, SkRRect* rr, bool* aa) const {
|
||||
bool GrFixedClip::isRRect(const SkRect& rtBounds, SkRRect* rr, GrAA* aa) const {
|
||||
if (fWindowRectsState.enabled()) {
|
||||
return false;
|
||||
}
|
||||
@ -39,7 +39,7 @@ bool GrFixedClip::isRRect(const SkRect& rtBounds, SkRRect* rr, bool* aa) const {
|
||||
return false;
|
||||
}
|
||||
rr->setRect(rect);
|
||||
*aa = false;
|
||||
*aa = GrAA::kNo;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
|
||||
bool quickContains(const SkRect&) const override;
|
||||
void getConservativeBounds(int w, int h, SkIRect* devResult, bool* iior) const override;
|
||||
bool isRRect(const SkRect& rtBounds, SkRRect* rr, bool* aa) const override;
|
||||
bool isRRect(const SkRect& rtBounds, SkRRect* rr, GrAA*) const override;
|
||||
bool apply(GrContext*, GrRenderTargetContext*, bool, bool, GrAppliedClip* out) const override;
|
||||
|
||||
static const GrFixedClip& Disabled();
|
||||
|
@ -13,8 +13,7 @@
|
||||
#include "effects/GrSimpleTextureEffect.h"
|
||||
|
||||
GrPaint::GrPaint()
|
||||
: fAntiAlias(false)
|
||||
, fDisableOutputConversionToSRGB(false)
|
||||
: fDisableOutputConversionToSRGB(false)
|
||||
, fAllowSRGBInputs(false)
|
||||
, fUsesDistanceVectorField(false)
|
||||
, fColor(GrColor4f::OpaqueWhite()) {}
|
||||
|
@ -78,17 +78,16 @@ public:
|
||||
* fPipelineBuilder The pipelineBuilder
|
||||
* fViewMatrix The viewMatrix
|
||||
* fShape The shape to draw
|
||||
* fAntiAlias True if anti-aliasing is required.
|
||||
* fAntiAlias The type of anti aliasing required.
|
||||
*/
|
||||
struct CanDrawPathArgs {
|
||||
const GrShaderCaps* fShaderCaps;
|
||||
const SkMatrix* fViewMatrix;
|
||||
const GrShape* fShape;
|
||||
bool fAntiAlias;
|
||||
GrAAType fAAType;
|
||||
|
||||
// These next two are only used by GrStencilAndCoverPathRenderer
|
||||
bool fHasUserStencilSettings;
|
||||
bool fIsStencilBufferMSAA;
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
void validate() const {
|
||||
@ -121,7 +120,7 @@ public:
|
||||
* fColor Color to render with
|
||||
* fViewMatrix The viewMatrix
|
||||
* fShape The shape to draw
|
||||
* fAntiAlias true if anti-aliasing is required.
|
||||
* fAAtype true if anti-aliasing is required.
|
||||
* fGammaCorrect true if gamma-correct rendering is to be used.
|
||||
*/
|
||||
struct DrawPathArgs {
|
||||
@ -133,7 +132,7 @@ public:
|
||||
const GrClip* fClip;
|
||||
const SkMatrix* fViewMatrix;
|
||||
const GrShape* fShape;
|
||||
bool fAntiAlias;
|
||||
GrAAType fAAType;
|
||||
bool fGammaCorrect;
|
||||
#ifdef SK_DEBUG
|
||||
void validate() const {
|
||||
@ -159,10 +158,13 @@ public:
|
||||
canArgs.fShaderCaps = args.fResourceProvider->caps()->shaderCaps();
|
||||
canArgs.fViewMatrix = args.fViewMatrix;
|
||||
canArgs.fShape = args.fShape;
|
||||
canArgs.fAntiAlias = args.fAntiAlias;
|
||||
canArgs.fAAType = args.fAAType;
|
||||
|
||||
canArgs.fHasUserStencilSettings = !args.fUserStencilSettings->isUnused();
|
||||
canArgs.fIsStencilBufferMSAA = args.fRenderTargetContext->isStencilBufferMultisampled();
|
||||
SkASSERT(!(canArgs.fAAType == GrAAType::kMSAA &&
|
||||
!args.fRenderTargetContext->isUnifiedMultisampled()));
|
||||
SkASSERT(!(canArgs.fAAType == GrAAType::kMixedSamples &&
|
||||
!args.fRenderTargetContext->isStencilBufferMultisampled()));
|
||||
SkASSERT(this->canDrawPath(canArgs));
|
||||
if (!args.fUserStencilSettings->isUnused()) {
|
||||
SkPath path;
|
||||
@ -180,14 +182,14 @@ public:
|
||||
* fRenderTargetContext The target of the draws
|
||||
* fViewMatrix Matrix applied to the path.
|
||||
* fPath The path to draw.
|
||||
* fIsAA Is the path to be drawn AA (only set when MSAA is available)
|
||||
* fAAType The type of AA, cannot be kCoverage.
|
||||
*/
|
||||
struct StencilPathArgs {
|
||||
GrResourceProvider* fResourceProvider;
|
||||
GrRenderTargetContext* fRenderTargetContext;
|
||||
const GrClip* fClip;
|
||||
const SkMatrix* fViewMatrix;
|
||||
bool fIsAA;
|
||||
GrAAType fAAType;
|
||||
const GrShape* fShape;
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
@ -197,6 +199,7 @@ public:
|
||||
SkASSERT(fViewMatrix);
|
||||
SkASSERT(fShape);
|
||||
SkASSERT(fShape->style().isSimpleFill());
|
||||
SkASSERT(GrAAType::kCoverage != fAAType);
|
||||
SkPath path;
|
||||
fShape->asPath(&path);
|
||||
SkASSERT(!path.isInverseFillType());
|
||||
@ -283,7 +286,7 @@ private:
|
||||
drawArgs.fRenderTargetContext = args.fRenderTargetContext;
|
||||
drawArgs.fViewMatrix = args.fViewMatrix;
|
||||
drawArgs.fShape = args.fShape;
|
||||
drawArgs.fAntiAlias = false; // In this case the MSAA handles the AA so we want to draw BW
|
||||
drawArgs.fAAType = args.fAAType;
|
||||
drawArgs.fGammaCorrect = false;
|
||||
this->drawPath(drawArgs);
|
||||
}
|
||||
|
@ -15,16 +15,11 @@
|
||||
#include "batches/GrOp.h"
|
||||
#include "effects/GrPorterDuffXferProcessor.h"
|
||||
|
||||
GrPipelineBuilder::GrPipelineBuilder()
|
||||
GrPipelineBuilder::GrPipelineBuilder(const GrPaint& paint, GrAAType aaType)
|
||||
: fFlags(0x0)
|
||||
, fUserStencilSettings(&GrUserStencilSettings::kUnused)
|
||||
, fDrawFace(GrDrawFace::kBoth) {
|
||||
SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
|
||||
}
|
||||
|
||||
GrPipelineBuilder::GrPipelineBuilder(const GrPaint& paint, bool useHWAA)
|
||||
: GrPipelineBuilder() {
|
||||
SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
|
||||
|
||||
for (int i = 0; i < paint.numColorFragmentProcessors(); ++i) {
|
||||
fColorFragmentProcessors.emplace_back(SkRef(paint.getColorFragmentProcessor(i)));
|
||||
@ -36,7 +31,8 @@ GrPipelineBuilder::GrPipelineBuilder(const GrPaint& paint, bool useHWAA)
|
||||
|
||||
fXPFactory.reset(SkSafeRef(paint.getXPFactory()));
|
||||
|
||||
this->setState(GrPipelineBuilder::kHWAntialias_Flag, useHWAA);
|
||||
this->setState(GrPipelineBuilder::kHWAntialias_Flag, GrAAType::kMSAA == aaType ||
|
||||
GrAAType::kMixedSamples == aaType);
|
||||
this->setState(GrPipelineBuilder::kDisableOutputConversionToSRGB_Flag,
|
||||
paint.getDisableOutputConversionToSRGB());
|
||||
this->setState(GrPipelineBuilder::kAllowSRGBInputs_Flag,
|
||||
|
@ -29,15 +29,14 @@ class GrTexture;
|
||||
|
||||
class GrPipelineBuilder : public SkNoncopyable {
|
||||
public:
|
||||
GrPipelineBuilder();
|
||||
|
||||
// GrPipelineBuilder();
|
||||
/**
|
||||
* Initializes the GrPipelineBuilder based on a GrPaint and MSAA availability. Note
|
||||
* that GrPipelineBuilder encompasses more than GrPaint. Aspects of GrPipelineBuilder that have
|
||||
* no GrPaint equivalents are set to default values with the exception of vertex attribute state
|
||||
* which is unmodified by this function and clipping which will be enabled.
|
||||
*/
|
||||
GrPipelineBuilder(const GrPaint&, bool useHWAA = false);
|
||||
GrPipelineBuilder(const GrPaint& paint, GrAAType aaType);
|
||||
|
||||
virtual ~GrPipelineBuilder();
|
||||
|
||||
|
@ -529,8 +529,7 @@ static bool stencil_element(GrRenderTargetContext* rtc,
|
||||
const GrUserStencilSettings* ss,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkClipStack::Element* element) {
|
||||
|
||||
// TODO: Draw rrects directly here.
|
||||
GrAA aa = GrBoolToAA(element->isAA());
|
||||
switch (element->getType()) {
|
||||
case Element::kEmpty_Type:
|
||||
SkDEBUGFAIL("Should never get here with an empty element.");
|
||||
@ -538,9 +537,7 @@ static bool stencil_element(GrRenderTargetContext* rtc,
|
||||
case Element::kRect_Type:
|
||||
return rtc->priv().drawAndStencilRect(clip, ss,
|
||||
(SkRegion::Op)element->getOp(),
|
||||
element->isInverseFilled(),
|
||||
element->isAA(),
|
||||
viewMatrix,
|
||||
element->isInverseFilled(), aa, viewMatrix,
|
||||
element->getRect());
|
||||
break;
|
||||
default: {
|
||||
@ -550,11 +547,8 @@ static bool stencil_element(GrRenderTargetContext* rtc,
|
||||
path.toggleInverseFillType();
|
||||
}
|
||||
|
||||
return rtc->priv().drawAndStencilPath(clip, ss,
|
||||
(SkRegion::Op)element->getOp(),
|
||||
element->isInverseFilled(),
|
||||
element->isAA(), viewMatrix,
|
||||
path);
|
||||
return rtc->priv().drawAndStencilPath(clip, ss, (SkRegion::Op)element->getOp(),
|
||||
element->isInverseFilled(), aa, viewMatrix, path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -565,6 +559,7 @@ static bool stencil_element(GrRenderTargetContext* rtc,
|
||||
static void draw_element(GrRenderTargetContext* rtc,
|
||||
const GrClip& clip, // TODO: can this just always be WideOpen?
|
||||
const GrPaint &paint,
|
||||
GrAA aa,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkClipStack::Element* element) {
|
||||
|
||||
@ -574,7 +569,7 @@ static void draw_element(GrRenderTargetContext* rtc,
|
||||
SkDEBUGFAIL("Should never get here with an empty element.");
|
||||
break;
|
||||
case Element::kRect_Type:
|
||||
rtc->drawRect(clip, paint, viewMatrix, element->getRect());
|
||||
rtc->drawRect(clip, paint, aa, viewMatrix, element->getRect());
|
||||
break;
|
||||
default: {
|
||||
SkPath path;
|
||||
@ -583,7 +578,7 @@ static void draw_element(GrRenderTargetContext* rtc,
|
||||
path.toggleInverseFillType();
|
||||
}
|
||||
|
||||
rtc->drawPath(clip, paint, viewMatrix, path, GrStyle::SimpleFill());
|
||||
rtc->drawPath(clip, paint, aa, viewMatrix, path, GrStyle::SimpleFill());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -612,6 +607,7 @@ bool GrReducedClip::drawAlphaClipMask(GrRenderTargetContext* rtc) const {
|
||||
for (ElementList::Iter iter(fElements); iter.get(); iter.next()) {
|
||||
const Element* element = iter.get();
|
||||
SkRegion::Op op = (SkRegion::Op)element->getOp();
|
||||
GrAA aa = GrBoolToAA(element->isAA());
|
||||
bool invert = element->isInverseFilled();
|
||||
if (invert || SkRegion::kIntersect_Op == op || SkRegion::kReverseDifference_Op == op) {
|
||||
// draw directly into the result with the stencil set to make the pixels affected
|
||||
@ -639,17 +635,16 @@ bool GrReducedClip::drawAlphaClipMask(GrRenderTargetContext* rtc) const {
|
||||
GrUserStencilOp::kZero,
|
||||
0xffff>()
|
||||
);
|
||||
if (!rtc->priv().drawAndStencilRect(clip, &kDrawOutsideElement, op, !invert, false,
|
||||
if (!rtc->priv().drawAndStencilRect(clip, &kDrawOutsideElement, op, !invert, GrAA::kNo,
|
||||
translate, SkRect::Make(fIBounds))) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// all the remaining ops can just be directly draw into the accumulation buffer
|
||||
GrPaint paint;
|
||||
paint.setAntiAlias(element->isAA());
|
||||
paint.setCoverageSetOpXPFactory(op, false);
|
||||
|
||||
draw_element(rtc, clip, paint, translate, element);
|
||||
draw_element(rtc, clip, paint, aa, translate, element);
|
||||
}
|
||||
}
|
||||
|
||||
@ -676,7 +671,7 @@ private:
|
||||
void getConservativeBounds(int width, int height, SkIRect* bounds, bool* iior) const override {
|
||||
fFixedClip.getConservativeBounds(width, height, bounds, iior);
|
||||
}
|
||||
bool isRRect(const SkRect& rtBounds, SkRRect* rr, bool* aa) const override {
|
||||
bool isRRect(const SkRect& rtBounds, SkRRect* rr, GrAA*) const override {
|
||||
return false;
|
||||
}
|
||||
bool apply(GrContext* context, GrRenderTargetContext* renderTargetContext, bool useHWAA,
|
||||
@ -711,11 +706,13 @@ bool GrReducedClip::drawStencilClipMask(GrContext* context,
|
||||
SkMatrix viewMatrix;
|
||||
viewMatrix.setTranslate(SkIntToScalar(-clipOrigin.x()), SkIntToScalar(-clipOrigin.y()));
|
||||
|
||||
// walk through each clip element and perform its set op
|
||||
// with the existing clip.
|
||||
// walk through each clip element and perform its set op with the existing clip.
|
||||
for (ElementList::Iter iter(fElements); iter.get(); iter.next()) {
|
||||
const Element* element = iter.get();
|
||||
bool useHWAA = element->isAA() && renderTargetContext->isStencilBufferMultisampled();
|
||||
GrAAType aaType = GrAAType::kNone;
|
||||
if (element->isAA() && renderTargetContext->isStencilBufferMultisampled()) {
|
||||
aaType = GrAAType::kMSAA;
|
||||
}
|
||||
|
||||
bool fillInverted = false;
|
||||
|
||||
@ -742,9 +739,8 @@ bool GrReducedClip::drawStencilClipMask(GrContext* context,
|
||||
canDrawArgs.fShaderCaps = context->caps()->shaderCaps();
|
||||
canDrawArgs.fViewMatrix = &viewMatrix;
|
||||
canDrawArgs.fShape = &shape;
|
||||
canDrawArgs.fAntiAlias = false;
|
||||
canDrawArgs.fAAType = aaType;
|
||||
canDrawArgs.fHasUserStencilSettings = false;
|
||||
canDrawArgs.fIsStencilBufferMSAA = renderTargetContext->isStencilBufferMultisampled();
|
||||
|
||||
GrDrawingManager* dm = context->contextPriv().drawingManager();
|
||||
pr = dm->getPathRenderer(canDrawArgs, false,
|
||||
@ -778,14 +774,13 @@ bool GrReducedClip::drawStencilClipMask(GrContext* context,
|
||||
);
|
||||
if (Element::kRect_Type == element->getType()) {
|
||||
renderTargetContext->priv().stencilRect(stencilClip.fixedClip(), &kDrawToStencil,
|
||||
useHWAA, viewMatrix, element->getRect());
|
||||
aaType, viewMatrix, element->getRect());
|
||||
} else {
|
||||
if (!clipPath.isEmpty()) {
|
||||
GrShape shape(clipPath, GrStyle::SimpleFill());
|
||||
if (canRenderDirectToStencil) {
|
||||
GrPaint paint;
|
||||
paint.setXPFactory(GrDisableColorXPFactory::Make());
|
||||
paint.setAntiAlias(element->isAA());
|
||||
|
||||
GrPathRenderer::DrawPathArgs args;
|
||||
args.fResourceProvider = context->resourceProvider();
|
||||
@ -795,7 +790,7 @@ bool GrReducedClip::drawStencilClipMask(GrContext* context,
|
||||
args.fClip = &stencilClip.fixedClip();
|
||||
args.fViewMatrix = &viewMatrix;
|
||||
args.fShape = &shape;
|
||||
args.fAntiAlias = false;
|
||||
args.fAAType = aaType;
|
||||
args.fGammaCorrect = false;
|
||||
pr->drawPath(args);
|
||||
} else {
|
||||
@ -804,7 +799,7 @@ bool GrReducedClip::drawStencilClipMask(GrContext* context,
|
||||
args.fRenderTargetContext = renderTargetContext;
|
||||
args.fClip = &stencilClip.fixedClip();
|
||||
args.fViewMatrix = &viewMatrix;
|
||||
args.fIsAA = element->isAA();
|
||||
args.fAAType = aaType;
|
||||
args.fShape = &shape;
|
||||
pr->stencilPath(args);
|
||||
}
|
||||
@ -817,13 +812,12 @@ bool GrReducedClip::drawStencilClipMask(GrContext* context,
|
||||
for (GrUserStencilSettings const* const* pass = stencilPasses; *pass; ++pass) {
|
||||
if (drawDirectToClip) {
|
||||
if (Element::kRect_Type == element->getType()) {
|
||||
renderTargetContext->priv().stencilRect(stencilClip, *pass, useHWAA, viewMatrix,
|
||||
renderTargetContext->priv().stencilRect(stencilClip, *pass, aaType, viewMatrix,
|
||||
element->getRect());
|
||||
} else {
|
||||
GrShape shape(clipPath, GrStyle::SimpleFill());
|
||||
GrPaint paint;
|
||||
paint.setXPFactory(GrDisableColorXPFactory::Make());
|
||||
paint.setAntiAlias(element->isAA());
|
||||
GrPathRenderer::DrawPathArgs args;
|
||||
args.fResourceProvider = context->resourceProvider();
|
||||
args.fPaint = &paint;
|
||||
@ -832,14 +826,14 @@ bool GrReducedClip::drawStencilClipMask(GrContext* context,
|
||||
args.fClip = &stencilClip;
|
||||
args.fViewMatrix = &viewMatrix;
|
||||
args.fShape = &shape;
|
||||
args.fAntiAlias = false;
|
||||
args.fAAType = aaType;
|
||||
args.fGammaCorrect = false;
|
||||
pr->drawPath(args);
|
||||
}
|
||||
} else {
|
||||
// The view matrix is setup to do clip space -> stencil space translation, so
|
||||
// draw rect in clip space.
|
||||
renderTargetContext->priv().stencilRect(stencilClip, *pass, false, viewMatrix,
|
||||
renderTargetContext->priv().stencilRect(stencilClip, *pass, aaType, viewMatrix,
|
||||
SkRect::Make(fIBounds));
|
||||
}
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ void GrRenderTargetContext::internalClear(const GrFixedClip& clip,
|
||||
paint.setColor4f(GrColor4f::FromGrColor(color));
|
||||
paint.setXPFactory(GrPorterDuffXPFactory::Make(SkBlendMode::kSrc));
|
||||
|
||||
this->drawRect(clip, paint, SkMatrix::I(), SkRect::Make(clearRect));
|
||||
this->drawRect(clip, paint, GrAA::kNo, SkMatrix::I(), SkRect::Make(clearRect));
|
||||
} else if (isFull) {
|
||||
if (this->accessRenderTarget()) {
|
||||
this->getOpList()->fullClear(this->accessRenderTarget(), color);
|
||||
@ -342,7 +342,7 @@ void GrRenderTargetContext::internalClear(const GrFixedClip& clip,
|
||||
}
|
||||
|
||||
void GrRenderTargetContext::drawPaint(const GrClip& clip,
|
||||
const GrPaint& origPaint,
|
||||
const GrPaint& paint,
|
||||
const SkMatrix& viewMatrix) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
RETURN_IF_ABANDONED
|
||||
@ -353,26 +353,19 @@ void GrRenderTargetContext::drawPaint(const GrClip& clip,
|
||||
// don't overflow fixed-point implementations
|
||||
|
||||
SkRect r = fRenderTargetProxy->getBoundsRect();
|
||||
SkTCopyOnFirstWrite<GrPaint> paint(origPaint);
|
||||
|
||||
SkRRect rrect;
|
||||
bool aaRRect;
|
||||
GrAA aa;
|
||||
// Check if we can replace a clipRRect()/drawPaint() with a drawRRect(). We only do the
|
||||
// transformation for non-rect rrects. Rects caused a performance regression on an Android
|
||||
// test that needs investigation. We also skip cases where there are fragment processors
|
||||
// because they may depend on having correct local coords and this path draws in device space
|
||||
// without a local matrix.
|
||||
if (!paint->numTotalFragmentProcessors() &&
|
||||
clip.isRRect(r, &rrect, &aaRRect) && !rrect.isRect()) {
|
||||
paint.writable()->setAntiAlias(aaRRect);
|
||||
this->drawRRect(GrNoClip(), *paint, SkMatrix::I(), rrect, GrStyle::SimpleFill());
|
||||
if (!paint.numTotalFragmentProcessors() && clip.isRRect(r, &rrect, &aa) && !rrect.isRect()) {
|
||||
this->drawRRect(GrNoClip(), paint, aa, SkMatrix::I(), rrect, GrStyle::SimpleFill());
|
||||
return;
|
||||
}
|
||||
|
||||
// by definition this fills the entire clip, no need for AA
|
||||
if (paint->isAntiAlias()) {
|
||||
paint.writable()->setAntiAlias(false);
|
||||
}
|
||||
|
||||
bool isPerspective = viewMatrix.hasPerspective();
|
||||
|
||||
@ -384,7 +377,7 @@ void GrRenderTargetContext::drawPaint(const GrClip& clip,
|
||||
SkDebugf("Could not invert matrix\n");
|
||||
return;
|
||||
}
|
||||
this->drawRect(clip, *paint, viewMatrix, r);
|
||||
this->drawRect(clip, paint, GrAA::kNo, viewMatrix, r);
|
||||
} else {
|
||||
SkMatrix localMatrix;
|
||||
if (!viewMatrix.invert(&localMatrix)) {
|
||||
@ -394,8 +387,8 @@ void GrRenderTargetContext::drawPaint(const GrClip& clip,
|
||||
|
||||
AutoCheckFlush acf(fDrawingManager);
|
||||
|
||||
this->drawNonAAFilledRect(clip, *paint, SkMatrix::I(), r, nullptr, &localMatrix, nullptr,
|
||||
false /* useHWAA */);
|
||||
this->drawNonAAFilledRect(clip, paint, SkMatrix::I(), r, nullptr, &localMatrix,
|
||||
nullptr, GrAAType::kNone);
|
||||
}
|
||||
}
|
||||
|
||||
@ -408,21 +401,6 @@ static bool view_matrix_ok_for_aa_fill_rect(const SkMatrix& viewMatrix) {
|
||||
return viewMatrix.preservesRightAngles();
|
||||
}
|
||||
|
||||
static bool should_apply_coverage_aa(const GrPaint& paint, GrRenderTargetProxy* rtp,
|
||||
bool* useHWAA = nullptr) {
|
||||
if (!paint.isAntiAlias()) {
|
||||
if (useHWAA) {
|
||||
*useHWAA = false;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
if (useHWAA) {
|
||||
*useHWAA = rtp->isUnifiedMultisampled();
|
||||
}
|
||||
return !rtp->isUnifiedMultisampled();
|
||||
}
|
||||
}
|
||||
|
||||
// Attempts to crop a rect and optional local rect to the clip boundaries.
|
||||
// Returns false if the draw can be skipped entirely.
|
||||
static bool crop_filled_rect(int width, int height, const GrClip& clip,
|
||||
@ -470,6 +448,7 @@ static bool crop_filled_rect(int width, int height, const GrClip& clip,
|
||||
|
||||
bool GrRenderTargetContext::drawFilledRect(const GrClip& clip,
|
||||
const GrPaint& paint,
|
||||
GrAA aa,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& rect,
|
||||
const GrUserStencilSettings* ss) {
|
||||
@ -479,14 +458,14 @@ bool GrRenderTargetContext::drawFilledRect(const GrClip& clip,
|
||||
}
|
||||
|
||||
sk_sp<GrDrawOp> op;
|
||||
bool useHWAA;
|
||||
GrAAType aaType;
|
||||
|
||||
if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport()) {
|
||||
InstancedRendering* ir = this->getOpList()->instancedRendering();
|
||||
op.reset(ir->recordRect(croppedRect, viewMatrix, paint.getColor(), paint.isAntiAlias(),
|
||||
fInstancedPipelineInfo, &useHWAA));
|
||||
op.reset(ir->recordRect(croppedRect, viewMatrix, paint.getColor(), aa,
|
||||
fInstancedPipelineInfo, &aaType));
|
||||
if (op) {
|
||||
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
|
||||
GrPipelineBuilder pipelineBuilder(paint, aaType);
|
||||
if (ss) {
|
||||
pipelineBuilder.setUserStencil(ss);
|
||||
}
|
||||
@ -494,8 +473,8 @@ bool GrRenderTargetContext::drawFilledRect(const GrClip& clip,
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (should_apply_coverage_aa(paint, fRenderTargetProxy.get(), &useHWAA)) {
|
||||
aaType = this->decideAAType(aa);
|
||||
if (GrAAType::kCoverage == aaType) {
|
||||
// The fill path can handle rotation but not skew.
|
||||
if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
|
||||
SkRect devBoundRect;
|
||||
@ -504,7 +483,7 @@ bool GrRenderTargetContext::drawFilledRect(const GrClip& clip,
|
||||
op.reset(GrRectBatchFactory::CreateAAFill(paint, viewMatrix, rect, croppedRect,
|
||||
devBoundRect));
|
||||
if (op) {
|
||||
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
|
||||
GrPipelineBuilder pipelineBuilder(paint, aaType);
|
||||
if (ss) {
|
||||
pipelineBuilder.setUserStencil(ss);
|
||||
}
|
||||
@ -514,7 +493,7 @@ bool GrRenderTargetContext::drawFilledRect(const GrClip& clip,
|
||||
}
|
||||
} else {
|
||||
this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, nullptr, nullptr, ss,
|
||||
useHWAA);
|
||||
aaType);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -523,6 +502,7 @@ bool GrRenderTargetContext::drawFilledRect(const GrClip& clip,
|
||||
|
||||
void GrRenderTargetContext::drawRect(const GrClip& clip,
|
||||
const GrPaint& paint,
|
||||
GrAA aa,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& rect,
|
||||
const GrStyle* style) {
|
||||
@ -569,7 +549,7 @@ void GrRenderTargetContext::drawRect(const GrClip& clip,
|
||||
}
|
||||
}
|
||||
|
||||
if (this->drawFilledRect(clip, paint, viewMatrix, rect, nullptr)) {
|
||||
if (this->drawFilledRect(clip, paint, aa, viewMatrix, rect, nullptr)) {
|
||||
return;
|
||||
}
|
||||
} else if (stroke.getStyle() == SkStrokeRec::kStroke_Style ||
|
||||
@ -580,7 +560,7 @@ void GrRenderTargetContext::drawRect(const GrClip& clip,
|
||||
// TODO: Move these stroke->fill fallbacks to GrShape?
|
||||
switch (stroke.getJoin()) {
|
||||
case SkPaint::kMiter_Join:
|
||||
this->drawRect(clip, paint, viewMatrix,
|
||||
this->drawRect(clip, paint, aa, viewMatrix,
|
||||
{rect.fLeft - r, rect.fTop - r,
|
||||
rect.fRight + r, rect.fBottom + r},
|
||||
&GrStyle::SimpleFill());
|
||||
@ -589,16 +569,16 @@ void GrRenderTargetContext::drawRect(const GrClip& clip,
|
||||
// Raster draws nothing when both dimensions are empty.
|
||||
if (rect.width() || rect.height()){
|
||||
SkRRect rrect = SkRRect::MakeRectXY(rect.makeOutset(r, r), r, r);
|
||||
this->drawRRect(clip, paint, viewMatrix, rrect, GrStyle::SimpleFill());
|
||||
this->drawRRect(clip, paint, aa, viewMatrix, rrect, GrStyle::SimpleFill());
|
||||
return;
|
||||
}
|
||||
case SkPaint::kBevel_Join:
|
||||
if (!rect.width()) {
|
||||
this->drawRect(clip, paint, viewMatrix,
|
||||
this->drawRect(clip, paint, aa, viewMatrix,
|
||||
{rect.fLeft - r, rect.fTop, rect.fRight + r, rect.fBottom},
|
||||
&GrStyle::SimpleFill());
|
||||
} else {
|
||||
this->drawRect(clip, paint, viewMatrix,
|
||||
this->drawRect(clip, paint, aa, viewMatrix,
|
||||
{rect.fLeft, rect.fTop - r, rect.fRight, rect.fBottom + r},
|
||||
&GrStyle::SimpleFill());
|
||||
}
|
||||
@ -606,12 +586,12 @@ void GrRenderTargetContext::drawRect(const GrClip& clip,
|
||||
}
|
||||
}
|
||||
|
||||
bool useHWAA;
|
||||
bool snapToPixelCenters = false;
|
||||
sk_sp<GrDrawOp> op;
|
||||
|
||||
GrColor color = paint.getColor();
|
||||
if (should_apply_coverage_aa(paint, fRenderTargetProxy.get(), &useHWAA)) {
|
||||
GrAAType aaType = this->decideAAType(aa);
|
||||
if (GrAAType::kCoverage == aaType) {
|
||||
// The stroke path needs the rect to remain axis aligned (no rotation or skew).
|
||||
if (viewMatrix.rectStaysRect()) {
|
||||
op.reset(GrRectBatchFactory::CreateAAStroke(color, viewMatrix, rect, stroke));
|
||||
@ -627,7 +607,7 @@ void GrRenderTargetContext::drawRect(const GrClip& clip,
|
||||
}
|
||||
|
||||
if (op) {
|
||||
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
|
||||
GrPipelineBuilder pipelineBuilder(paint, aaType);
|
||||
|
||||
if (snapToPixelCenters) {
|
||||
pipelineBuilder.setState(GrPipelineBuilder::kSnapVerticesToPixelCenters_Flag,
|
||||
@ -642,7 +622,7 @@ void GrRenderTargetContext::drawRect(const GrClip& clip,
|
||||
SkPath path;
|
||||
path.setIsVolatile(true);
|
||||
path.addRect(rect);
|
||||
this->internalDrawPath(clip, paint, viewMatrix, path, *style);
|
||||
this->internalDrawPath(clip, paint, aa, viewMatrix, path, *style);
|
||||
}
|
||||
|
||||
int GrRenderTargetContextPriv::maxWindowRectangles() const {
|
||||
@ -666,16 +646,17 @@ void GrRenderTargetContextPriv::clearStencilClip(const GrFixedClip& clip, bool i
|
||||
}
|
||||
|
||||
void GrRenderTargetContextPriv::stencilPath(const GrClip& clip,
|
||||
bool useHWAA,
|
||||
GrAAType aaType,
|
||||
const SkMatrix& viewMatrix,
|
||||
const GrPath* path) {
|
||||
fRenderTargetContext->getOpList()->stencilPath(fRenderTargetContext, clip, useHWAA, viewMatrix,
|
||||
SkASSERT(aaType != GrAAType::kCoverage);
|
||||
fRenderTargetContext->getOpList()->stencilPath(fRenderTargetContext, clip, aaType, viewMatrix,
|
||||
path);
|
||||
}
|
||||
|
||||
void GrRenderTargetContextPriv::stencilRect(const GrClip& clip,
|
||||
const GrUserStencilSettings* ss,
|
||||
bool useHWAA,
|
||||
GrAAType aaType,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& rect) {
|
||||
ASSERT_SINGLE_OWNER_PRIV
|
||||
@ -683,22 +664,21 @@ void GrRenderTargetContextPriv::stencilRect(const GrClip& clip,
|
||||
SkDEBUGCODE(fRenderTargetContext->validate();)
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(fRenderTargetContext->fAuditTrail,
|
||||
"GrRenderTargetContext::stencilRect");
|
||||
|
||||
SkASSERT(GrAAType::kCoverage != aaType);
|
||||
AutoCheckFlush acf(fRenderTargetContext->fDrawingManager);
|
||||
|
||||
GrPaint paint;
|
||||
paint.setAntiAlias(useHWAA);
|
||||
paint.setXPFactory(GrDisableColorXPFactory::Make());
|
||||
|
||||
fRenderTargetContext->drawNonAAFilledRect(clip, paint, viewMatrix, rect, nullptr, nullptr, ss,
|
||||
useHWAA);
|
||||
aaType);
|
||||
}
|
||||
|
||||
bool GrRenderTargetContextPriv::drawAndStencilRect(const GrClip& clip,
|
||||
const GrUserStencilSettings* ss,
|
||||
SkRegion::Op op,
|
||||
bool invert,
|
||||
bool doAA,
|
||||
GrAA aa,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& rect) {
|
||||
ASSERT_SINGLE_OWNER_PRIV
|
||||
@ -710,21 +690,20 @@ bool GrRenderTargetContextPriv::drawAndStencilRect(const GrClip& clip,
|
||||
AutoCheckFlush acf(fRenderTargetContext->fDrawingManager);
|
||||
|
||||
GrPaint paint;
|
||||
paint.setAntiAlias(doAA);
|
||||
paint.setCoverageSetOpXPFactory(op, invert);
|
||||
|
||||
if (fRenderTargetContext->drawFilledRect(clip, paint, viewMatrix, rect, ss)) {
|
||||
if (fRenderTargetContext->drawFilledRect(clip, paint, aa, viewMatrix, rect, ss)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
SkPath path;
|
||||
path.setIsVolatile(true);
|
||||
path.addRect(rect);
|
||||
return this->drawAndStencilPath(clip, ss, op, invert, doAA, viewMatrix, path);
|
||||
return this->drawAndStencilPath(clip, ss, op, invert, aa, viewMatrix, path);
|
||||
}
|
||||
|
||||
void GrRenderTargetContext::fillRectToRect(const GrClip& clip,
|
||||
const GrPaint& paint,
|
||||
GrAA aa,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& rectToDraw,
|
||||
const SkRect& localRect) {
|
||||
@ -741,30 +720,30 @@ void GrRenderTargetContext::fillRectToRect(const GrClip& clip,
|
||||
}
|
||||
|
||||
AutoCheckFlush acf(fDrawingManager);
|
||||
bool useHWAA;
|
||||
GrAAType aaType;
|
||||
|
||||
if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport()) {
|
||||
InstancedRendering* ir = this->getOpList()->instancedRendering();
|
||||
sk_sp<GrDrawOp> op(ir->recordRect(croppedRect, viewMatrix, paint.getColor(),
|
||||
croppedLocalRect, paint.isAntiAlias(),
|
||||
fInstancedPipelineInfo, &useHWAA));
|
||||
croppedLocalRect, aa, fInstancedPipelineInfo, &aaType));
|
||||
if (op) {
|
||||
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
|
||||
GrPipelineBuilder pipelineBuilder(paint, aaType);
|
||||
this->getOpList()->addDrawOp(pipelineBuilder, this, clip, op.get());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!should_apply_coverage_aa(paint, fRenderTargetProxy.get(), &useHWAA)) {
|
||||
this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, &croppedLocalRect,
|
||||
nullptr, nullptr, useHWAA);
|
||||
aaType = this->decideAAType(aa);
|
||||
if (GrAAType::kCoverage != aaType) {
|
||||
this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, &croppedLocalRect, nullptr,
|
||||
nullptr, aaType);
|
||||
return;
|
||||
}
|
||||
|
||||
if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
|
||||
sk_sp<GrDrawOp> op(GrAAFillRectBatch::CreateWithLocalRect(paint.getColor(), viewMatrix,
|
||||
croppedRect, croppedLocalRect));
|
||||
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
|
||||
GrPipelineBuilder pipelineBuilder(paint, aaType);
|
||||
this->addDrawOp(pipelineBuilder, clip, op.get());
|
||||
return;
|
||||
}
|
||||
@ -779,11 +758,12 @@ void GrRenderTargetContext::fillRectToRect(const GrClip& clip,
|
||||
SkPath path;
|
||||
path.setIsVolatile(true);
|
||||
path.addRect(localRect);
|
||||
this->internalDrawPath(clip, paint, viewAndUnLocalMatrix, path, GrStyle());
|
||||
this->internalDrawPath(clip, paint, aa, viewAndUnLocalMatrix, path, GrStyle());
|
||||
}
|
||||
|
||||
void GrRenderTargetContext::fillRectWithLocalMatrix(const GrClip& clip,
|
||||
const GrPaint& paint,
|
||||
GrAA aa,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& rectToDraw,
|
||||
const SkMatrix& localMatrix) {
|
||||
@ -798,29 +778,30 @@ void GrRenderTargetContext::fillRectWithLocalMatrix(const GrClip& clip,
|
||||
}
|
||||
|
||||
AutoCheckFlush acf(fDrawingManager);
|
||||
bool useHWAA;
|
||||
GrAAType aaType;
|
||||
|
||||
if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport()) {
|
||||
InstancedRendering* ir = this->getOpList()->instancedRendering();
|
||||
sk_sp<GrDrawOp> op(ir->recordRect(croppedRect, viewMatrix, paint.getColor(), localMatrix,
|
||||
paint.isAntiAlias(), fInstancedPipelineInfo, &useHWAA));
|
||||
aa, fInstancedPipelineInfo, &aaType));
|
||||
if (op) {
|
||||
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
|
||||
GrPipelineBuilder pipelineBuilder(paint, aaType);
|
||||
this->getOpList()->addDrawOp(pipelineBuilder, this, clip, op.get());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!should_apply_coverage_aa(paint, fRenderTargetProxy.get(), &useHWAA)) {
|
||||
this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, nullptr,
|
||||
&localMatrix, nullptr, useHWAA);
|
||||
aaType = this->decideAAType(aa);
|
||||
if (GrAAType::kCoverage != aaType) {
|
||||
this->drawNonAAFilledRect(clip, paint, viewMatrix, croppedRect, nullptr, &localMatrix,
|
||||
nullptr, aaType);
|
||||
return;
|
||||
}
|
||||
|
||||
if (view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
|
||||
sk_sp<GrDrawOp> op(GrAAFillRectBatch::Create(paint.getColor(), viewMatrix, localMatrix,
|
||||
croppedRect));
|
||||
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
|
||||
GrPipelineBuilder pipelineBuilder(paint, aaType);
|
||||
this->getOpList()->addDrawOp(pipelineBuilder, this, clip, op.get());
|
||||
return;
|
||||
}
|
||||
@ -836,7 +817,7 @@ void GrRenderTargetContext::fillRectWithLocalMatrix(const GrClip& clip,
|
||||
path.setIsVolatile(true);
|
||||
path.addRect(rectToDraw);
|
||||
path.transform(localMatrix);
|
||||
this->internalDrawPath(clip, paint, viewAndUnLocalMatrix, path, GrStyle());
|
||||
this->internalDrawPath(clip, paint, aa, viewAndUnLocalMatrix, path, GrStyle());
|
||||
}
|
||||
|
||||
void GrRenderTargetContext::drawVertices(const GrClip& clip,
|
||||
@ -869,7 +850,7 @@ void GrRenderTargetContext::drawVertices(const GrClip& clip,
|
||||
positions, vertexCount, indices, indexCount, colors,
|
||||
texCoords, bounds));
|
||||
|
||||
GrPipelineBuilder pipelineBuilder(paint, this->mustUseHWAA(paint));
|
||||
GrPipelineBuilder pipelineBuilder(paint, GrAAType::kNone);
|
||||
this->getOpList()->addDrawOp(pipelineBuilder, this, clip, op.get());
|
||||
}
|
||||
|
||||
@ -892,7 +873,7 @@ void GrRenderTargetContext::drawAtlas(const GrClip& clip,
|
||||
sk_sp<GrDrawOp> op(new GrDrawAtlasBatch(paint.getColor(), viewMatrix, spriteCount, xform,
|
||||
texRect, colors));
|
||||
|
||||
GrPipelineBuilder pipelineBuilder(paint, this->mustUseHWAA(paint));
|
||||
GrPipelineBuilder pipelineBuilder(paint, GrAAType::kNone);
|
||||
this->getOpList()->addDrawOp(pipelineBuilder, this, clip, op.get());
|
||||
}
|
||||
|
||||
@ -900,6 +881,7 @@ void GrRenderTargetContext::drawAtlas(const GrClip& clip,
|
||||
|
||||
void GrRenderTargetContext::drawRRect(const GrClip& origClip,
|
||||
const GrPaint& paint,
|
||||
GrAA aa,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRRect& rrect,
|
||||
const GrStyle& style) {
|
||||
@ -928,21 +910,22 @@ void GrRenderTargetContext::drawRRect(const GrClip& origClip,
|
||||
|
||||
AutoCheckFlush acf(fDrawingManager);
|
||||
const SkStrokeRec stroke = style.strokeRec();
|
||||
bool useHWAA;
|
||||
GrAAType aaType;
|
||||
|
||||
if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport() &&
|
||||
stroke.isFillStyle()) {
|
||||
InstancedRendering* ir = this->getOpList()->instancedRendering();
|
||||
sk_sp<GrDrawOp> op(ir->recordRRect(rrect, viewMatrix, paint.getColor(), paint.isAntiAlias(),
|
||||
fInstancedPipelineInfo, &useHWAA));
|
||||
sk_sp<GrDrawOp> op(ir->recordRRect(rrect, viewMatrix, paint.getColor(), aa,
|
||||
fInstancedPipelineInfo, &aaType));
|
||||
if (op) {
|
||||
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
|
||||
GrPipelineBuilder pipelineBuilder(paint, aaType);
|
||||
this->getOpList()->addDrawOp(pipelineBuilder, this, *clip, op.get());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (should_apply_coverage_aa(paint, fRenderTargetProxy.get(), &useHWAA)) {
|
||||
aaType = this->decideAAType(aa);
|
||||
if (GrAAType::kCoverage == aaType) {
|
||||
const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
|
||||
sk_sp<GrDrawOp> op(GrOvalRenderer::CreateRRectBatch(paint.getColor(),
|
||||
paint.usesDistanceVectorField(),
|
||||
@ -951,7 +934,7 @@ void GrRenderTargetContext::drawRRect(const GrClip& origClip,
|
||||
stroke,
|
||||
shaderCaps));
|
||||
if (op) {
|
||||
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
|
||||
GrPipelineBuilder pipelineBuilder(paint, aaType);
|
||||
this->getOpList()->addDrawOp(pipelineBuilder, this, *clip, op.get());
|
||||
return;
|
||||
}
|
||||
@ -960,7 +943,7 @@ void GrRenderTargetContext::drawRRect(const GrClip& origClip,
|
||||
SkPath path;
|
||||
path.setIsVolatile(true);
|
||||
path.addRRect(rrect);
|
||||
this->internalDrawPath(*clip, paint, viewMatrix, path, style);
|
||||
this->internalDrawPath(*clip, paint, aa, viewMatrix, path, style);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -983,23 +966,8 @@ void GrRenderTargetContext::drawShadowRRect(const GrClip& clip,
|
||||
|
||||
AutoCheckFlush acf(fDrawingManager);
|
||||
const SkStrokeRec stroke = style.strokeRec();
|
||||
bool useHWAA;
|
||||
// TODO: add instancing support?
|
||||
|
||||
// TODO: add instancing support
|
||||
//if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport() &&
|
||||
// stroke.isFillStyle()) {
|
||||
// InstancedRendering* ir = this->getOpList()->instancedRendering();
|
||||
// SkAutoTUnref<GrDrawOp> op(ir->recordRRect(rrect, viewMatrix, paint.getColor(),
|
||||
// paint.isAntiAlias(), fInstancedPipelineInfo,
|
||||
// &useHWAA));
|
||||
// if (op) {
|
||||
// GrPipelineBuilder pipelineBuilder(paint, useHWAA);
|
||||
// this->getOpList()->addDrawOp(pipelineBuilder, this, *clip, op);
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
|
||||
if (should_apply_coverage_aa(paint, fRenderTargetProxy.get(), &useHWAA)) {
|
||||
const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
|
||||
sk_sp<GrDrawOp> op(CreateShadowRRectBatch(paint.getColor(),
|
||||
viewMatrix,
|
||||
@ -1008,47 +976,45 @@ void GrRenderTargetContext::drawShadowRRect(const GrClip& clip,
|
||||
stroke,
|
||||
shaderCaps));
|
||||
if (op) {
|
||||
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
|
||||
GrPipelineBuilder pipelineBuilder(paint, GrAAType::kNone);
|
||||
this->getOpList()->addDrawOp(pipelineBuilder, this, clip, op.get());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SkPath path;
|
||||
path.setIsVolatile(true);
|
||||
path.addRRect(rrect);
|
||||
this->internalDrawPath(clip, paint, viewMatrix, path, style);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool GrRenderTargetContext::drawFilledDRRect(const GrClip& clip,
|
||||
const GrPaint& paintIn,
|
||||
GrAA aa,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRRect& origOuter,
|
||||
const SkRRect& origInner) {
|
||||
SkASSERT(!origInner.isEmpty());
|
||||
SkASSERT(!origOuter.isEmpty());
|
||||
GrAAType aaType;
|
||||
|
||||
if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport()) {
|
||||
bool useHWAA;
|
||||
InstancedRendering* ir = this->getOpList()->instancedRendering();
|
||||
sk_sp<GrDrawOp> op(ir->recordDRRect(origOuter, origInner, viewMatrix, paintIn.getColor(),
|
||||
paintIn.isAntiAlias(), fInstancedPipelineInfo,
|
||||
&useHWAA));
|
||||
aa, fInstancedPipelineInfo, &aaType));
|
||||
if (op) {
|
||||
GrPipelineBuilder pipelineBuilder(paintIn, useHWAA);
|
||||
GrPipelineBuilder pipelineBuilder(paintIn, aaType);
|
||||
this->getOpList()->addDrawOp(pipelineBuilder, this, clip, op.get());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool applyAA = paintIn.isAntiAlias() && !fRenderTargetProxy->isUnifiedMultisampled();
|
||||
aaType = this->decideAAType(aa);
|
||||
|
||||
GrPrimitiveEdgeType innerEdgeType = applyAA ? kInverseFillAA_GrProcessorEdgeType :
|
||||
kInverseFillBW_GrProcessorEdgeType;
|
||||
GrPrimitiveEdgeType outerEdgeType = applyAA ? kFillAA_GrProcessorEdgeType :
|
||||
kFillBW_GrProcessorEdgeType;
|
||||
GrPrimitiveEdgeType innerEdgeType, outerEdgeType;
|
||||
if (GrAAType::kCoverage == aaType) {
|
||||
innerEdgeType = kInverseFillAA_GrProcessorEdgeType;
|
||||
outerEdgeType = kFillAA_GrProcessorEdgeType;
|
||||
} else {
|
||||
innerEdgeType = kInverseFillBW_GrProcessorEdgeType;
|
||||
outerEdgeType = kFillBW_GrProcessorEdgeType;
|
||||
}
|
||||
|
||||
SkTCopyOnFirstWrite<SkRRect> inner(origInner), outer(origOuter);
|
||||
SkMatrix inverseVM;
|
||||
@ -1067,7 +1033,6 @@ bool GrRenderTargetContext::drawFilledDRRect(const GrClip& clip,
|
||||
}
|
||||
|
||||
GrPaint grPaint(paintIn);
|
||||
grPaint.setAntiAlias(false);
|
||||
|
||||
// TODO these need to be a geometry processors
|
||||
sk_sp<GrFragmentProcessor> innerEffect(GrRRectEffect::Make(innerEdgeType, *inner));
|
||||
@ -1084,16 +1049,17 @@ bool GrRenderTargetContext::drawFilledDRRect(const GrClip& clip,
|
||||
grPaint.addCoverageFragmentProcessor(std::move(outerEffect));
|
||||
|
||||
SkRect bounds = outer->getBounds();
|
||||
if (applyAA) {
|
||||
if (GrAAType::kCoverage == aaType) {
|
||||
bounds.outset(SK_ScalarHalf, SK_ScalarHalf);
|
||||
}
|
||||
|
||||
this->fillRectWithLocalMatrix(clip, grPaint, SkMatrix::I(), bounds, inverseVM);
|
||||
this->fillRectWithLocalMatrix(clip, grPaint, GrAA::kNo, SkMatrix::I(), bounds, inverseVM);
|
||||
return true;
|
||||
}
|
||||
|
||||
void GrRenderTargetContext::drawDRRect(const GrClip& clip,
|
||||
const GrPaint& paint,
|
||||
GrAA aa,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRRect& outer,
|
||||
const SkRRect& inner) {
|
||||
@ -1107,7 +1073,7 @@ void GrRenderTargetContext::drawDRRect(const GrClip& clip,
|
||||
|
||||
AutoCheckFlush acf(fDrawingManager);
|
||||
|
||||
if (this->drawFilledDRRect(clip, paint, viewMatrix, outer, inner)) {
|
||||
if (this->drawFilledDRRect(clip, paint, aa, viewMatrix, outer, inner)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1117,7 +1083,7 @@ void GrRenderTargetContext::drawDRRect(const GrClip& clip,
|
||||
path.addRRect(outer);
|
||||
path.setFillType(SkPath::kEvenOdd_FillType);
|
||||
|
||||
this->internalDrawPath(clip, paint, viewMatrix, path, GrStyle::SimpleFill());
|
||||
this->internalDrawPath(clip, paint, aa, viewMatrix, path, GrStyle::SimpleFill());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -1128,6 +1094,7 @@ static inline bool is_int(float x) {
|
||||
|
||||
void GrRenderTargetContext::drawRegion(const GrClip& clip,
|
||||
const GrPaint& paint,
|
||||
GrAA aa,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRegion& region,
|
||||
const GrStyle& style) {
|
||||
@ -1136,28 +1103,30 @@ void GrRenderTargetContext::drawRegion(const GrClip& clip,
|
||||
SkDEBUGCODE(this->validate();)
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrRenderTargetContext::drawRegion");
|
||||
|
||||
bool needsAA = false;
|
||||
if (paint.isAntiAlias()) {
|
||||
if (GrAA::kYes == aa) {
|
||||
// GrRegionBatch performs no antialiasing but is much faster, so here we check the matrix
|
||||
// to see whether aa is really required.
|
||||
needsAA = SkToBool(viewMatrix.getType() & ~(SkMatrix::kTranslate_Mask)) ||
|
||||
!is_int(viewMatrix.getTranslateX()) ||
|
||||
!is_int(viewMatrix.getTranslateY());
|
||||
if (!SkToBool(viewMatrix.getType() & ~(SkMatrix::kTranslate_Mask)) &&
|
||||
is_int(viewMatrix.getTranslateX()) &&
|
||||
is_int(viewMatrix.getTranslateY())) {
|
||||
aa = GrAA::kNo;
|
||||
}
|
||||
}
|
||||
bool complexStyle = !style.isSimpleFill();
|
||||
if (complexStyle || needsAA) {
|
||||
if (complexStyle || GrAA::kYes == aa) {
|
||||
SkPath path;
|
||||
region.getBoundaryPath(&path);
|
||||
return this->drawPath(clip, paint, viewMatrix, path, style);
|
||||
return this->drawPath(clip, paint, aa, viewMatrix, path, style);
|
||||
}
|
||||
|
||||
sk_sp<GrDrawOp> op(GrRegionBatch::Create(paint.getColor(), viewMatrix, region));
|
||||
GrPipelineBuilder pipelineBuilder(paint, false);
|
||||
GrPipelineBuilder pipelineBuilder(paint, GrAAType::kNone);
|
||||
this->getOpList()->addDrawOp(pipelineBuilder, this, clip, op.get());
|
||||
}
|
||||
|
||||
void GrRenderTargetContext::drawOval(const GrClip& clip,
|
||||
const GrPaint& paint,
|
||||
GrAA aa,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& oval,
|
||||
const GrStyle& style) {
|
||||
@ -1174,21 +1143,22 @@ void GrRenderTargetContext::drawOval(const GrClip& clip,
|
||||
|
||||
AutoCheckFlush acf(fDrawingManager);
|
||||
const SkStrokeRec& stroke = style.strokeRec();
|
||||
bool useHWAA;
|
||||
GrAAType aaType;
|
||||
|
||||
if (GrCaps::InstancedSupport::kNone != fContext->caps()->instancedSupport() &&
|
||||
stroke.isFillStyle()) {
|
||||
InstancedRendering* ir = this->getOpList()->instancedRendering();
|
||||
sk_sp<GrDrawOp> op(ir->recordOval(oval, viewMatrix, paint.getColor(), paint.isAntiAlias(),
|
||||
fInstancedPipelineInfo, &useHWAA));
|
||||
sk_sp<GrDrawOp> op(ir->recordOval(oval, viewMatrix, paint.getColor(), aa,
|
||||
fInstancedPipelineInfo, &aaType));
|
||||
if (op) {
|
||||
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
|
||||
GrPipelineBuilder pipelineBuilder(paint, aaType);
|
||||
this->getOpList()->addDrawOp(pipelineBuilder, this, clip, op.get());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (should_apply_coverage_aa(paint, fRenderTargetProxy.get(), &useHWAA)) {
|
||||
aaType = this->decideAAType(aa);
|
||||
if (GrAAType::kCoverage == aaType) {
|
||||
const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
|
||||
sk_sp<GrDrawOp> op(GrOvalRenderer::CreateOvalBatch(paint.getColor(),
|
||||
viewMatrix,
|
||||
@ -1196,7 +1166,7 @@ void GrRenderTargetContext::drawOval(const GrClip& clip,
|
||||
stroke,
|
||||
shaderCaps));
|
||||
if (op) {
|
||||
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
|
||||
GrPipelineBuilder pipelineBuilder(paint, aaType);
|
||||
this->getOpList()->addDrawOp(pipelineBuilder, this, clip, op.get());
|
||||
return;
|
||||
}
|
||||
@ -1205,19 +1175,20 @@ void GrRenderTargetContext::drawOval(const GrClip& clip,
|
||||
SkPath path;
|
||||
path.setIsVolatile(true);
|
||||
path.addOval(oval);
|
||||
this->internalDrawPath(clip, paint, viewMatrix, path, style);
|
||||
this->internalDrawPath(clip, paint, aa, viewMatrix, path, style);
|
||||
}
|
||||
|
||||
void GrRenderTargetContext::drawArc(const GrClip& clip,
|
||||
const GrPaint& paint,
|
||||
GrAA aa,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& oval,
|
||||
SkScalar startAngle,
|
||||
SkScalar sweepAngle,
|
||||
bool useCenter,
|
||||
const GrStyle& style) {
|
||||
bool useHWAA;
|
||||
if (should_apply_coverage_aa(paint, fRenderTargetProxy.get(), &useHWAA)) {
|
||||
GrAAType aaType = this->decideAAType(aa);
|
||||
if (GrAAType::kCoverage == aaType) {
|
||||
const GrShaderCaps* shaderCaps = fContext->caps()->shaderCaps();
|
||||
sk_sp<GrDrawOp> op(GrOvalRenderer::CreateArcBatch(paint.getColor(),
|
||||
viewMatrix,
|
||||
@ -1228,7 +1199,7 @@ void GrRenderTargetContext::drawArc(const GrClip& clip,
|
||||
style,
|
||||
shaderCaps));
|
||||
if (op) {
|
||||
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
|
||||
GrPipelineBuilder pipelineBuilder(paint, aaType);
|
||||
this->getOpList()->addDrawOp(pipelineBuilder, this, clip, op.get());
|
||||
return;
|
||||
}
|
||||
@ -1236,8 +1207,7 @@ void GrRenderTargetContext::drawArc(const GrClip& clip,
|
||||
SkPath path;
|
||||
SkPathPriv::CreateDrawArcPath(&path, oval, startAngle, sweepAngle, useCenter,
|
||||
style.isSimpleFill());
|
||||
this->internalDrawPath(clip, paint, viewMatrix, path, style);
|
||||
return;
|
||||
this->internalDrawPath(clip, paint, aa, viewMatrix, path, style);
|
||||
}
|
||||
|
||||
void GrRenderTargetContext::drawImageLattice(const GrClip& clip,
|
||||
@ -1257,7 +1227,7 @@ void GrRenderTargetContext::drawImageLattice(const GrClip& clip,
|
||||
sk_sp<GrDrawOp> op(GrNinePatch::CreateNonAA(paint.getColor(), viewMatrix, imageWidth,
|
||||
imageHeight, std::move(iter), dst));
|
||||
|
||||
GrPipelineBuilder pipelineBuilder(paint, this->mustUseHWAA(paint));
|
||||
GrPipelineBuilder pipelineBuilder(paint, GrAAType::kNone);
|
||||
this->getOpList()->addDrawOp(pipelineBuilder, this, clip, op.get());
|
||||
}
|
||||
|
||||
@ -1286,11 +1256,12 @@ void GrRenderTargetContext::drawNonAAFilledRect(const GrClip& clip,
|
||||
const SkRect* localRect,
|
||||
const SkMatrix* localMatrix,
|
||||
const GrUserStencilSettings* ss,
|
||||
bool useHWAA) {
|
||||
SkASSERT(!useHWAA || this->isStencilBufferMultisampled());
|
||||
GrAAType hwOrNoneAAType) {
|
||||
SkASSERT(GrAAType::kCoverage != hwOrNoneAAType);
|
||||
SkASSERT(hwOrNoneAAType == GrAAType::kNone || this->isStencilBufferMultisampled());
|
||||
sk_sp<GrDrawOp> op( GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewMatrix, rect,
|
||||
localRect, localMatrix));
|
||||
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
|
||||
GrPipelineBuilder pipelineBuilder(paint, hwOrNoneAAType);
|
||||
if (ss) {
|
||||
pipelineBuilder.setUserStencil(ss);
|
||||
}
|
||||
@ -1392,6 +1363,7 @@ static bool fills_as_nested_rects(const SkMatrix& viewMatrix, const SkPath& path
|
||||
|
||||
void GrRenderTargetContext::drawPath(const GrClip& clip,
|
||||
const GrPaint& paint,
|
||||
GrAA aa,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkPath& path,
|
||||
const GrStyle& style) {
|
||||
@ -1409,9 +1381,8 @@ void GrRenderTargetContext::drawPath(const GrClip& clip,
|
||||
|
||||
AutoCheckFlush acf(fDrawingManager);
|
||||
|
||||
bool useHWAA;
|
||||
if (should_apply_coverage_aa(paint, fRenderTargetProxy.get(), &useHWAA) &&
|
||||
!style.pathEffect()) {
|
||||
GrAAType aaType = this->decideAAType(aa);
|
||||
if (GrAAType::kCoverage == aaType && !style.pathEffect()) {
|
||||
if (style.isSimpleFill() && !path.isConvex()) {
|
||||
// Concave AA paths are expensive - try to avoid them for special cases
|
||||
SkRect rects[2];
|
||||
@ -1420,7 +1391,7 @@ void GrRenderTargetContext::drawPath(const GrClip& clip,
|
||||
sk_sp<GrDrawOp> op(GrRectBatchFactory::CreateAAFillNestedRects(
|
||||
paint.getColor(), viewMatrix, rects));
|
||||
if (op) {
|
||||
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
|
||||
GrPipelineBuilder pipelineBuilder(paint, aaType);
|
||||
this->getOpList()->addDrawOp(pipelineBuilder, this, clip, op.get());
|
||||
}
|
||||
return;
|
||||
@ -1437,7 +1408,7 @@ void GrRenderTargetContext::drawPath(const GrClip& clip,
|
||||
style.strokeRec(),
|
||||
shaderCaps));
|
||||
if (op) {
|
||||
GrPipelineBuilder pipelineBuilder(paint, useHWAA);
|
||||
GrPipelineBuilder pipelineBuilder(paint, aaType);
|
||||
this->getOpList()->addDrawOp(pipelineBuilder, this, clip, op.get());
|
||||
return;
|
||||
}
|
||||
@ -1449,23 +1420,24 @@ void GrRenderTargetContext::drawPath(const GrClip& clip,
|
||||
// cache. This presents a potential hazard for buffered drawing. However,
|
||||
// the writePixels that uploads to the scratch will perform a flush so we're
|
||||
// OK.
|
||||
this->internalDrawPath(clip, paint, viewMatrix, path, style);
|
||||
this->internalDrawPath(clip, paint, aa, viewMatrix, path, style);
|
||||
}
|
||||
|
||||
bool GrRenderTargetContextPriv::drawAndStencilPath(const GrClip& clip,
|
||||
const GrUserStencilSettings* ss,
|
||||
SkRegion::Op op,
|
||||
bool invert,
|
||||
bool doAA,
|
||||
GrAA aa,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkPath& path) {
|
||||
ASSERT_SINGLE_OWNER_PRIV
|
||||
RETURN_FALSE_IF_ABANDONED_PRIV
|
||||
SkDEBUGCODE(fRenderTargetContext->validate();)
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(fRenderTargetContext->fAuditTrail, "GrRenderTargetContext::drawPath");
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(fRenderTargetContext->fAuditTrail,
|
||||
"GrRenderTargetContextPriv::drawAndStencilPath");
|
||||
|
||||
if (path.isEmpty() && path.isInverseFillType()) {
|
||||
this->drawAndStencilRect(clip, ss, op, invert, false, SkMatrix::I(),
|
||||
this->drawAndStencilRect(clip, ss, op, invert, GrAA::kNo, SkMatrix::I(),
|
||||
SkRect::MakeIWH(fRenderTargetContext->width(),
|
||||
fRenderTargetContext->height()));
|
||||
return true;
|
||||
@ -1477,12 +1449,11 @@ bool GrRenderTargetContextPriv::drawAndStencilPath(const GrClip& clip,
|
||||
// the src color (either the input alpha or in the frag shader) to implement
|
||||
// aa. If we have some future driver-mojo path AA that can do the right
|
||||
// thing WRT to the blend then we'll need some query on the PR.
|
||||
bool useCoverageAA = doAA && !fRenderTargetContext->isUnifiedMultisampled();
|
||||
GrAAType aaType = fRenderTargetContext->decideAAType(aa);
|
||||
bool hasUserStencilSettings = !ss->isUnused();
|
||||
bool isStencilBufferMSAA = fRenderTargetContext->isStencilBufferMultisampled();
|
||||
|
||||
const GrPathRendererChain::DrawType type =
|
||||
useCoverageAA ? GrPathRendererChain::kColorAntiAlias_DrawType
|
||||
const GrPathRendererChain::DrawType type = (GrAAType::kCoverage == aaType)
|
||||
? GrPathRendererChain::kColorAntiAlias_DrawType
|
||||
: GrPathRendererChain::kColor_DrawType;
|
||||
|
||||
GrShape shape(path, GrStyle::SimpleFill());
|
||||
@ -1491,9 +1462,8 @@ bool GrRenderTargetContextPriv::drawAndStencilPath(const GrClip& clip,
|
||||
fRenderTargetContext->fDrawingManager->getContext()->caps()->shaderCaps();
|
||||
canDrawArgs.fViewMatrix = &viewMatrix;
|
||||
canDrawArgs.fShape = &shape;
|
||||
canDrawArgs.fAntiAlias = useCoverageAA;
|
||||
canDrawArgs.fAAType = aaType;
|
||||
canDrawArgs.fHasUserStencilSettings = hasUserStencilSettings;
|
||||
canDrawArgs.fIsStencilBufferMSAA = isStencilBufferMSAA;
|
||||
|
||||
// Don't allow the SW renderer
|
||||
GrPathRenderer* pr = fRenderTargetContext->fDrawingManager->getPathRenderer(canDrawArgs, false,
|
||||
@ -1514,7 +1484,7 @@ bool GrRenderTargetContextPriv::drawAndStencilPath(const GrClip& clip,
|
||||
args.fClip = &clip;
|
||||
args.fViewMatrix = &viewMatrix;
|
||||
args.fShape = &shape;
|
||||
args.fAntiAlias = useCoverageAA;
|
||||
args.fAAType = aaType;
|
||||
args.fGammaCorrect = fRenderTargetContext->isGammaCorrect();
|
||||
pr->drawPath(args);
|
||||
return true;
|
||||
@ -1534,35 +1504,43 @@ SkBudgeted GrRenderTargetContextPriv::isBudgeted() const {
|
||||
|
||||
void GrRenderTargetContext::internalDrawPath(const GrClip& clip,
|
||||
const GrPaint& paint,
|
||||
GrAA aa,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkPath& path,
|
||||
const GrStyle& style) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
RETURN_IF_ABANDONED
|
||||
SkASSERT(!path.isEmpty());
|
||||
GrShape shape;
|
||||
|
||||
bool useCoverageAA = should_apply_coverage_aa(paint, fRenderTargetProxy.get());
|
||||
constexpr bool kHasUserStencilSettings = false;
|
||||
bool isStencilBufferMSAA = this->isStencilBufferMultisampled();
|
||||
|
||||
const GrPathRendererChain::DrawType type =
|
||||
useCoverageAA ? GrPathRendererChain::kColorAntiAlias_DrawType
|
||||
: GrPathRendererChain::kColor_DrawType;
|
||||
|
||||
GrShape shape(path, style);
|
||||
if (shape.isEmpty()) {
|
||||
return;
|
||||
GrAAType aaType = this->decideAAType(aa, /*allowMixedSamples*/ true);
|
||||
if (style.isSimpleHairline() && aaType == GrAAType::kMixedSamples) {
|
||||
// NVPR cannot handle hairlines, so this will would get picked up by a different stencil and
|
||||
// cover path renderer (i.e. default path renderer). The hairline renderer produces much
|
||||
// smoother hairlines than MSAA.
|
||||
aaType = GrAAType::kCoverage;
|
||||
}
|
||||
GrPathRenderer::CanDrawPathArgs canDrawArgs;
|
||||
canDrawArgs.fShaderCaps = fDrawingManager->getContext()->caps()->shaderCaps();
|
||||
canDrawArgs.fViewMatrix = &viewMatrix;
|
||||
canDrawArgs.fShape = &shape;
|
||||
canDrawArgs.fAntiAlias = useCoverageAA;
|
||||
canDrawArgs.fHasUserStencilSettings = kHasUserStencilSettings;
|
||||
canDrawArgs.fIsStencilBufferMSAA = isStencilBufferMSAA;
|
||||
canDrawArgs.fHasUserStencilSettings = false;
|
||||
|
||||
GrPathRenderer* pr;
|
||||
do {
|
||||
const GrPathRendererChain::DrawType type = GrAAType::kCoverage == aaType
|
||||
? GrPathRendererChain::kColorAntiAlias_DrawType
|
||||
: GrPathRendererChain::kColor_DrawType;
|
||||
|
||||
shape = GrShape(path, style);
|
||||
if (shape.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
canDrawArgs.fAAType = aaType;
|
||||
|
||||
// Try a 1st time without applying any of the style to the geometry (and barring sw)
|
||||
GrPathRenderer* pr = fDrawingManager->getPathRenderer(canDrawArgs, false, type);
|
||||
pr = fDrawingManager->getPathRenderer(canDrawArgs, false, type);
|
||||
SkScalar styleScale = GrStyle::MatrixToScaleFactor(viewMatrix);
|
||||
|
||||
if (!pr && shape.style().pathEffect()) {
|
||||
@ -1583,6 +1561,14 @@ void GrRenderTargetContext::internalDrawPath(const GrClip& clip,
|
||||
// This time, allow SW renderer
|
||||
pr = fDrawingManager->getPathRenderer(canDrawArgs, true, type);
|
||||
}
|
||||
if (!pr && (aaType == GrAAType::kMixedSamples || aaType == GrAAType::kMSAA)) {
|
||||
// There are exceptional cases where we may wind up falling back to coverage based AA
|
||||
// when the target is MSAA (e.g. through disabling path renderers via GrContextOptions).
|
||||
aaType = GrAAType::kCoverage;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} while(true);
|
||||
|
||||
if (!pr) {
|
||||
#ifdef SK_DEBUG
|
||||
@ -1598,8 +1584,8 @@ void GrRenderTargetContext::internalDrawPath(const GrClip& clip,
|
||||
args.fRenderTargetContext = this;
|
||||
args.fClip = &clip;
|
||||
args.fViewMatrix = &viewMatrix;
|
||||
args.fShape = canDrawArgs.fShape;
|
||||
args.fAntiAlias = useCoverageAA;
|
||||
args.fShape = &shape;
|
||||
args.fAAType = aaType;
|
||||
args.fGammaCorrect = this->isGammaCorrect();
|
||||
pr->drawPath(args);
|
||||
}
|
||||
|
@ -66,28 +66,33 @@ public:
|
||||
|
||||
void stencilRect(const GrClip& clip,
|
||||
const GrUserStencilSettings* ss,
|
||||
bool useHWAA,
|
||||
GrAAType,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect& rect);
|
||||
|
||||
void stencilPath(const GrClip&,
|
||||
bool useHWAA,
|
||||
const SkMatrix& viewMatrix,
|
||||
const GrPath*);
|
||||
void stencilPath(const GrClip&, GrAAType, const SkMatrix& viewMatrix, const GrPath*);
|
||||
|
||||
/**
|
||||
* Draws a rect, either AA or not, and touches the stencil buffer with the user stencil settings
|
||||
* for each color sample written.
|
||||
*/
|
||||
bool drawAndStencilRect(const GrClip&,
|
||||
const GrUserStencilSettings*,
|
||||
SkRegion::Op op,
|
||||
bool invert,
|
||||
bool doAA,
|
||||
GrAA,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkRect&);
|
||||
|
||||
/**
|
||||
* Draws a path, either AA or not, and touches the stencil buffer with the user stencil settings
|
||||
* for each color sample written.
|
||||
*/
|
||||
bool drawAndStencilPath(const GrClip&,
|
||||
const GrUserStencilSettings*,
|
||||
SkRegion::Op op,
|
||||
bool invert,
|
||||
bool doAA,
|
||||
GrAA,
|
||||
const SkMatrix& viewMatrix,
|
||||
const SkPath&);
|
||||
|
||||
@ -104,6 +109,7 @@ public:
|
||||
}
|
||||
|
||||
void testingOnly_drawBatch(const GrPaint&,
|
||||
GrAAType,
|
||||
GrDrawOp* batch,
|
||||
const GrUserStencilSettings* = nullptr,
|
||||
bool snapToCenters = false);
|
||||
|
@ -351,9 +351,10 @@ void GrRenderTargetOpList::addDrawOp(const GrPipelineBuilder& pipelineBuilder,
|
||||
|
||||
void GrRenderTargetOpList::stencilPath(GrRenderTargetContext* renderTargetContext,
|
||||
const GrClip& clip,
|
||||
bool useHWAA,
|
||||
GrAAType aaType,
|
||||
const SkMatrix& viewMatrix,
|
||||
const GrPath* path) {
|
||||
bool useHWAA = (aaType == GrAAType::kMSAA || aaType == GrAAType::kMixedSamples);
|
||||
// TODO: extract portions of checkDraw that are relevant to path stenciling.
|
||||
SkASSERT(path);
|
||||
SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport());
|
||||
|
@ -95,7 +95,7 @@ public:
|
||||
*/
|
||||
void stencilPath(GrRenderTargetContext*,
|
||||
const GrClip&,
|
||||
bool useHWAA,
|
||||
GrAAType aa,
|
||||
const SkMatrix& viewMatrix,
|
||||
const GrPath*);
|
||||
|
||||
|
@ -38,12 +38,11 @@ static SkBlendMode op_to_mode(SkRegion::Op op) {
|
||||
/**
|
||||
* Draw a single rect element of the clip stack into the accumulation bitmap
|
||||
*/
|
||||
void GrSWMaskHelper::drawRect(const SkRect& rect, SkRegion::Op op,
|
||||
bool antiAlias, uint8_t alpha) {
|
||||
void GrSWMaskHelper::drawRect(const SkRect& rect, SkRegion::Op op, GrAA aa, uint8_t alpha) {
|
||||
SkPaint paint;
|
||||
|
||||
paint.setBlendMode(op_to_mode(op));
|
||||
paint.setAntiAlias(antiAlias);
|
||||
paint.setAntiAlias(GrAA::kYes == aa);
|
||||
paint.setColor(SkColorSetARGB(alpha, alpha, alpha, alpha));
|
||||
|
||||
fDraw.drawRect(rect, paint);
|
||||
@ -52,12 +51,11 @@ void GrSWMaskHelper::drawRect(const SkRect& rect, SkRegion::Op op,
|
||||
/**
|
||||
* Draw a single path element of the clip stack into the accumulation bitmap
|
||||
*/
|
||||
void GrSWMaskHelper::drawShape(const GrShape& shape, SkRegion::Op op, bool antiAlias,
|
||||
uint8_t alpha) {
|
||||
void GrSWMaskHelper::drawShape(const GrShape& shape, SkRegion::Op op, GrAA aa, uint8_t alpha) {
|
||||
SkPaint paint;
|
||||
paint.setPathEffect(sk_ref_sp(shape.style().pathEffect()));
|
||||
shape.style().strokeRec().applyToPaint(&paint);
|
||||
paint.setAntiAlias(antiAlias);
|
||||
paint.setAntiAlias(GrAA::kYes == aa);
|
||||
|
||||
SkPath path;
|
||||
shape.asPath(&path);
|
||||
@ -141,7 +139,7 @@ void GrSWMaskHelper::toSDF(unsigned char* sdf) {
|
||||
GrTexture* GrSWMaskHelper::DrawShapeMaskToTexture(GrTextureProvider* texProvider,
|
||||
const GrShape& shape,
|
||||
const SkIRect& resultBounds,
|
||||
bool antiAlias,
|
||||
GrAA aa,
|
||||
TextureType textureType,
|
||||
const SkMatrix* matrix) {
|
||||
GrSWMaskHelper helper(texProvider);
|
||||
@ -150,7 +148,7 @@ GrTexture* GrSWMaskHelper::DrawShapeMaskToTexture(GrTextureProvider* texProvider
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
helper.drawShape(shape, SkRegion::kReplace_Op, antiAlias, 0xFF);
|
||||
helper.drawShape(shape, SkRegion::kReplace_Op, aa, 0xFF);
|
||||
|
||||
GrTexture* texture(helper.createTexture(textureType));
|
||||
if (!texture) {
|
||||
@ -185,7 +183,7 @@ void GrSWMaskHelper::DrawToTargetWithShapeMask(GrTexture* texture,
|
||||
maskMatrix.preTranslate(SkIntToScalar(-textureOriginInDeviceSpace.fX),
|
||||
SkIntToScalar(-textureOriginInDeviceSpace.fY));
|
||||
maskMatrix.preConcat(viewMatrix);
|
||||
GrPipelineBuilder pipelineBuilder(paint, renderTargetContext->mustUseHWAA(paint));
|
||||
GrPipelineBuilder pipelineBuilder(paint, GrAAType::kNone);
|
||||
pipelineBuilder.setUserStencil(&userStencilSettings);
|
||||
|
||||
pipelineBuilder.addCoverageFragmentProcessor(
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define GrSWMaskHelper_DEFINED
|
||||
|
||||
#include "GrColor.h"
|
||||
#include "GrRenderTargetContext.h"
|
||||
#include "GrTextureProvider.h"
|
||||
#include "SkAutoPixmapStorage.h"
|
||||
#include "SkBitmap.h"
|
||||
@ -51,10 +52,10 @@ public:
|
||||
bool init(const SkIRect& resultBounds, const SkMatrix* matrix);
|
||||
|
||||
// Draw a single rect into the accumulation bitmap using the specified op
|
||||
void drawRect(const SkRect& rect, SkRegion::Op op, bool antiAlias, uint8_t alpha);
|
||||
void drawRect(const SkRect& rect, SkRegion::Op op, GrAA, uint8_t alpha);
|
||||
|
||||
// Draw a single path into the accumuation bitmap using the specified op
|
||||
void drawShape(const GrShape&, SkRegion::Op op, bool antiAlias, uint8_t alpha);
|
||||
void drawShape(const GrShape&, SkRegion::Op op, GrAA, uint8_t alpha);
|
||||
|
||||
// Move the mask generation results from the internal bitmap to the gpu.
|
||||
void toTexture(GrTexture* texture);
|
||||
@ -67,7 +68,6 @@ public:
|
||||
fPixels.erase(SkColorSetARGB(alpha, 0xFF, 0xFF, 0xFF));
|
||||
}
|
||||
|
||||
|
||||
enum class TextureType {
|
||||
kExactFit,
|
||||
kApproximateFit
|
||||
@ -78,7 +78,7 @@ public:
|
||||
static GrTexture* DrawShapeMaskToTexture(GrTextureProvider*,
|
||||
const GrShape&,
|
||||
const SkIRect& resultBounds,
|
||||
bool antiAlias,
|
||||
GrAA,
|
||||
TextureType,
|
||||
const SkMatrix* matrix);
|
||||
|
||||
|
@ -18,7 +18,8 @@
|
||||
bool GrSoftwarePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
|
||||
// Pass on any style that applies. The caller will apply the style if a suitable renderer is
|
||||
// not found and try again with the new GrShape.
|
||||
return !args.fShape->style().applies() && SkToBool(fTexProvider);
|
||||
return !args.fShape->style().applies() && SkToBool(fTexProvider) &&
|
||||
(args.fAAType == GrAAType::kCoverage || args.fAAType == GrAAType::kNone);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -71,9 +72,8 @@ void GrSoftwarePathRenderer::DrawNonAARect(GrRenderTargetContext* renderTargetCo
|
||||
viewMatrix, rect,
|
||||
nullptr, &localMatrix));
|
||||
|
||||
GrPipelineBuilder pipelineBuilder(paint, renderTargetContext->mustUseHWAA(paint));
|
||||
GrPipelineBuilder pipelineBuilder(paint, GrAAType::kNone);
|
||||
pipelineBuilder.setUserStencil(&userStencilSettings);
|
||||
|
||||
renderTargetContext->addDrawOp(pipelineBuilder, clip, batch.get());
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
// To prevent overloading the cache with entries during animations we limit the cache of masks
|
||||
// to cases where the matrix preserves axis alignment.
|
||||
bool useCache = fAllowCaching && !inverseFilled && args.fViewMatrix->preservesAxisAlignment() &&
|
||||
args.fShape->hasUnstyledKey() && args.fAntiAlias;
|
||||
args.fShape->hasUnstyledKey() && GrAAType::kCoverage == args.fAAType;
|
||||
|
||||
if (!get_shape_and_clip_bounds(args.fRenderTargetContext->width(),
|
||||
args.fRenderTargetContext->height(),
|
||||
@ -193,6 +193,8 @@ bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
builder[3] = SkFloat2Bits(ky);
|
||||
builder[4] = fracX | (fracY >> 8);
|
||||
args.fShape->writeUnstyledKey(&builder[5]);
|
||||
// FIXME: Doesn't the key need to consider whether we're using AA or not? In practice that
|
||||
// should always be true, though.
|
||||
}
|
||||
|
||||
sk_sp<GrTexture> texture;
|
||||
@ -202,8 +204,9 @@ bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
if (!texture) {
|
||||
GrSWMaskHelper::TextureType type = useCache ? GrSWMaskHelper::TextureType::kExactFit
|
||||
: GrSWMaskHelper::TextureType::kApproximateFit;
|
||||
GrAA aa = GrAAType::kCoverage == args.fAAType ? GrAA::kYes : GrAA::kNo;
|
||||
texture.reset(GrSWMaskHelper::DrawShapeMaskToTexture(fTexProvider, *args.fShape,
|
||||
*boundsForMask, args.fAntiAlias,
|
||||
*boundsForMask, aa,
|
||||
type, args.fViewMatrix));
|
||||
if (!texture) {
|
||||
return false;
|
||||
@ -212,13 +215,11 @@ bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
texture->resourcePriv().setUniqueKey(maskKey);
|
||||
}
|
||||
}
|
||||
|
||||
GrSWMaskHelper::DrawToTargetWithShapeMask(texture.get(), args.fRenderTargetContext,
|
||||
*args.fPaint, *args.fUserStencilSettings,
|
||||
*args.fClip, *args.fViewMatrix,
|
||||
SkIPoint {boundsForMask->fLeft, boundsForMask->fTop},
|
||||
*boundsForMask);
|
||||
|
||||
if (inverseFilled) {
|
||||
DrawAroundInvPath(args.fRenderTargetContext, *args.fPaint, *args.fUserStencilSettings,
|
||||
*args.fClip,
|
||||
|
@ -69,7 +69,7 @@ GrTexture* GrTextureProducer::CopyOnGpu(GrTexture* inputTexture, const SkIRect*
|
||||
}
|
||||
|
||||
SkRect dstRect = SkRect::MakeIWH(copyParams.fWidth, copyParams.fHeight);
|
||||
copyRTC->fillRectToRect(GrNoClip(), paint, SkMatrix::I(), dstRect, localRect);
|
||||
copyRTC->fillRectToRect(GrNoClip(), paint, GrAA::kNo, SkMatrix::I(), dstRect, localRect);
|
||||
return copyRTC->asTexture().release();
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ static bool convert_texture(GrTexture* src, GrRenderTargetContext* dst, int dstW
|
||||
GrPaint paint;
|
||||
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
paint.addColorFragmentProcessor(std::move(fp));
|
||||
dst->drawRect(GrNoClip(), paint, SkMatrix::I(), SkRect::MakeIWH(dstW, dstH));
|
||||
dst->drawRect(GrNoClip(), paint, GrAA::kNo, SkMatrix::I(), SkRect::MakeIWH(dstW, dstH));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ sk_sp<GrTexture> GrYUVProvider::refAsTexture(GrContext* ctx,
|
||||
const SkRect r = SkRect::MakeIWH(yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY].fWidth,
|
||||
yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight);
|
||||
|
||||
renderTargetContext->drawRect(GrNoClip(), paint, SkMatrix::I(), r);
|
||||
renderTargetContext->drawRect(GrNoClip(), paint, GrAA::kNo, SkMatrix::I(), r);
|
||||
|
||||
return renderTargetContext->asTexture();
|
||||
}
|
||||
|
@ -342,7 +342,8 @@ void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode,
|
||||
path.setIsVolatile(true);
|
||||
path.moveTo(pts[0]);
|
||||
path.lineTo(pts[1]);
|
||||
fRenderTargetContext->drawPath(fClip, grPaint, *draw.fMatrix, path, style);
|
||||
fRenderTargetContext->drawPath(fClip, grPaint, GrBoolToAA(paint.isAntiAlias()),
|
||||
*draw.fMatrix, path, style);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -418,13 +419,13 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, const SkPaint
|
||||
}
|
||||
|
||||
GrStyle style(paint);
|
||||
fRenderTargetContext->drawRect(fClip, grPaint, *draw.fMatrix, rect, &style);
|
||||
fRenderTargetContext->drawRect(fClip, grPaint, GrBoolToAA(paint.isAntiAlias()), *draw.fMatrix,
|
||||
rect, &style);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rrect,
|
||||
const SkPaint& paint) {
|
||||
void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rrect, const SkPaint& paint) {
|
||||
ASSERT_SINGLE_OWNER
|
||||
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "drawRRect", fContext.get());
|
||||
CHECK_SHOULD_DRAW(draw);
|
||||
@ -483,7 +484,8 @@ void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rrect,
|
||||
|
||||
SkASSERT(!style.pathEffect());
|
||||
|
||||
fRenderTargetContext->drawRRect(fClip, grPaint, *draw.fMatrix, rrect, style);
|
||||
fRenderTargetContext->drawRRect(fClip, grPaint, GrBoolToAA(paint.isAntiAlias()), *draw.fMatrix,
|
||||
rrect, style);
|
||||
}
|
||||
|
||||
|
||||
@ -510,7 +512,8 @@ void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer,
|
||||
return;
|
||||
}
|
||||
|
||||
fRenderTargetContext->drawDRRect(fClip, grPaint, *draw.fMatrix, outer, inner);
|
||||
fRenderTargetContext->drawDRRect(fClip, grPaint, GrBoolToAA(paint.isAntiAlias()),
|
||||
*draw.fMatrix, outer, inner);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -542,7 +545,8 @@ void SkGpuDevice::drawRegion(const SkDraw& draw, const SkRegion& region, const S
|
||||
return;
|
||||
}
|
||||
|
||||
fRenderTargetContext->drawRegion(fClip, grPaint, *draw.fMatrix, region, GrStyle(paint));
|
||||
fRenderTargetContext->drawRegion(fClip, grPaint, GrBoolToAA(paint.isAntiAlias()), *draw.fMatrix,
|
||||
region, GrStyle(paint));
|
||||
}
|
||||
|
||||
void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint& paint) {
|
||||
@ -571,7 +575,8 @@ void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint
|
||||
return;
|
||||
}
|
||||
|
||||
fRenderTargetContext->drawOval(fClip, grPaint, *draw.fMatrix, oval, GrStyle(paint));
|
||||
fRenderTargetContext->drawOval(fClip, grPaint, GrBoolToAA(paint.isAntiAlias()), *draw.fMatrix,
|
||||
oval, GrStyle(paint));
|
||||
}
|
||||
|
||||
void SkGpuDevice::drawArc(const SkDraw& draw, const SkRect& oval, SkScalar startAngle,
|
||||
@ -590,8 +595,8 @@ void SkGpuDevice::drawArc(const SkDraw& draw, const SkRect& oval, SkScalar start
|
||||
return;
|
||||
}
|
||||
|
||||
fRenderTargetContext->drawArc(fClip, grPaint, *draw.fMatrix, oval, startAngle, sweepAngle,
|
||||
useCenter, GrStyle(paint));
|
||||
fRenderTargetContext->drawArc(fClip, grPaint, GrBoolToAA(paint.isAntiAlias()), *draw.fMatrix,
|
||||
oval, startAngle, sweepAngle, useCenter, GrStyle(paint));
|
||||
}
|
||||
|
||||
#include "SkMaskFilter.h"
|
||||
@ -647,7 +652,9 @@ void SkGpuDevice::drawStrokedLine(const SkPoint points[2],
|
||||
return;
|
||||
}
|
||||
|
||||
fRenderTargetContext->fillRectWithLocalMatrix(fClip, grPaint, m, rect, local);
|
||||
fRenderTargetContext->fillRectWithLocalMatrix(fClip, grPaint,
|
||||
GrBoolToAA(newPaint.isAntiAlias()), m, rect,
|
||||
local);
|
||||
}
|
||||
|
||||
void SkGpuDevice::drawPath(const SkDraw& draw, const SkPath& origSrcPath,
|
||||
@ -1097,7 +1104,10 @@ void SkGpuDevice::drawBitmapTile(const SkBitmap& bitmap,
|
||||
return;
|
||||
}
|
||||
|
||||
fRenderTargetContext->drawRect(fClip, grPaint, viewMatrix, dstRect);
|
||||
// Coverage-based AA would cause seams between tiles.
|
||||
GrAA aa = GrBoolToAA(paint.isAntiAlias() &&
|
||||
fRenderTargetContext->isStencilBufferMultisampled());
|
||||
fRenderTargetContext->drawRect(fClip, grPaint, aa, viewMatrix, dstRect);
|
||||
}
|
||||
|
||||
void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,
|
||||
@ -1192,6 +1202,7 @@ void SkGpuDevice::drawSpecial(const SkDraw& draw,
|
||||
|
||||
fRenderTargetContext->fillRectToRect(fClip,
|
||||
grPaint,
|
||||
GrBoolToAA(paint.isAntiAlias()),
|
||||
SkMatrix::I(),
|
||||
SkRect::Make(SkIRect::MakeXYWH(left + offset.fX,
|
||||
top + offset.fY,
|
||||
|
@ -213,15 +213,15 @@ void SkGpuDevice::drawTextureProducerImpl(GrTextureProducer* producer,
|
||||
fp, producer->isAlphaOnly(), &grPaint)) {
|
||||
return;
|
||||
}
|
||||
|
||||
GrAA aa = GrBoolToAA(paint.isAntiAlias());
|
||||
if (canUseTextureCoordsAsLocalCoords) {
|
||||
fRenderTargetContext->fillRectToRect(clip, grPaint, viewMatrix, clippedDstRect,
|
||||
fRenderTargetContext->fillRectToRect(clip, grPaint, aa, viewMatrix, clippedDstRect,
|
||||
clippedSrcRect);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mf) {
|
||||
fRenderTargetContext->drawRect(clip, grPaint, viewMatrix, clippedDstRect);
|
||||
fRenderTargetContext->drawRect(clip, grPaint, aa, viewMatrix, clippedDstRect);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -247,6 +247,6 @@ void SkGpuDevice::drawTextureProducerImpl(GrTextureProducer* producer,
|
||||
rectPath.addRect(clippedDstRect);
|
||||
rectPath.setIsVolatile(true);
|
||||
GrBlurUtils::drawPathWithMaskFilter(this->context(), fRenderTargetContext.get(), fClip,
|
||||
rectPath, &grPaint, viewMatrix, mf, GrStyle::SimpleFill(),
|
||||
true);
|
||||
rectPath, &grPaint, aa, viewMatrix, mf,
|
||||
GrStyle::SimpleFill(), true);
|
||||
}
|
||||
|
@ -558,7 +558,6 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context,
|
||||
SkBlendMode* primColorMode,
|
||||
bool primitiveIsSrc,
|
||||
GrPaint* grPaint) {
|
||||
grPaint->setAntiAlias(skPaint.isAntiAlias());
|
||||
grPaint->setAllowSRGBInputs(rtc->isGammaCorrect());
|
||||
|
||||
// Convert SkPaint color to 4f format, including optional linearizing and gamut conversion.
|
||||
|
@ -672,7 +672,7 @@ sk_sp<GrGeometryProcessor> QuadEdgeEffect::TestCreate(GrProcessorTestData* d) {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool GrAAConvexPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
|
||||
return (args.fShaderCaps->shaderDerivativeSupport() && args.fAntiAlias &&
|
||||
return (args.fShaderCaps->shaderDerivativeSupport() && (GrAAType::kCoverage == args.fAAType) &&
|
||||
args.fShape->style().isSimpleFill() && !args.fShape->inverseFilled() &&
|
||||
args.fShape->knownToBeConvex());
|
||||
}
|
||||
@ -1002,7 +1002,7 @@ bool GrAAConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
|
||||
sk_sp<GrDrawOp> batch(new AAConvexPathBatch(args.fPaint->getColor(), *args.fViewMatrix, path));
|
||||
|
||||
GrPipelineBuilder pipelineBuilder(*args.fPaint);
|
||||
GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fAAType);
|
||||
pipelineBuilder.setUserStencil(args.fUserStencilSettings);
|
||||
|
||||
args.fRenderTargetContext->addDrawOp(pipelineBuilder, *args.fClip, batch.get());
|
||||
|
@ -90,8 +90,8 @@ bool GrAADistanceFieldPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) c
|
||||
if (!args.fShape->style().isSimpleFill()) {
|
||||
return false;
|
||||
}
|
||||
// This does non-inverse antialiased fills.
|
||||
if (!args.fAntiAlias) {
|
||||
// This does non-inverse coverage-based antialiased fills.
|
||||
if (GrAAType::kCoverage != args.fAAType) {
|
||||
return false;
|
||||
}
|
||||
// TODO: Support inverse fill
|
||||
@ -128,7 +128,6 @@ public:
|
||||
|
||||
AADistanceFieldPathBatch(GrColor color,
|
||||
const GrShape& shape,
|
||||
bool antiAlias,
|
||||
const SkMatrix& viewMatrix,
|
||||
GrBatchAtlas* atlas,
|
||||
ShapeCache* shapeCache, ShapeDataList* shapeList,
|
||||
@ -136,7 +135,7 @@ public:
|
||||
: INHERITED(ClassID()) {
|
||||
SkASSERT(shape.hasUnstyledKey());
|
||||
fBatch.fViewMatrix = viewMatrix;
|
||||
fGeoData.emplace_back(Geometry{color, shape, antiAlias});
|
||||
fGeoData.emplace_back(Geometry{color, shape});
|
||||
|
||||
fAtlas = atlas;
|
||||
fShapeCache = shapeCache;
|
||||
@ -157,7 +156,7 @@ public:
|
||||
SkString dumpInfo() const override {
|
||||
SkString string;
|
||||
for (const auto& geo : fGeoData) {
|
||||
string.appendf("Color: 0x%08x AA:%d\n", geo.fColor, geo.fAntiAlias);
|
||||
string.appendf("Color: 0x%08x\n", geo.fColor);
|
||||
}
|
||||
string.append(DumpPipelineInfo(*this->pipeline()));
|
||||
string.append(INHERITED::dumpInfo());
|
||||
@ -274,7 +273,6 @@ private:
|
||||
atlas,
|
||||
shapeData,
|
||||
args.fShape,
|
||||
args.fAntiAlias,
|
||||
desiredDimension,
|
||||
scale)) {
|
||||
delete shapeData;
|
||||
@ -300,8 +298,8 @@ private:
|
||||
}
|
||||
|
||||
bool addPathToAtlas(GrMeshDrawOp::Target* target, FlushInfo* flushInfo, GrBatchAtlas* atlas,
|
||||
ShapeData* shapeData, const GrShape& shape, bool antiAlias,
|
||||
uint32_t dimension, SkScalar scale) const {
|
||||
ShapeData* shapeData, const GrShape& shape, uint32_t dimension,
|
||||
SkScalar scale) const {
|
||||
const SkRect& bounds = shape.bounds();
|
||||
|
||||
// generate bounding rect for bitmap draw
|
||||
@ -348,7 +346,7 @@ private:
|
||||
// rasterize path
|
||||
SkPaint paint;
|
||||
paint.setStyle(SkPaint::kFill_Style);
|
||||
paint.setAntiAlias(antiAlias);
|
||||
paint.setAntiAlias(true);
|
||||
|
||||
SkDraw draw;
|
||||
sk_bzero(&draw, sizeof(draw));
|
||||
@ -502,7 +500,6 @@ private:
|
||||
struct Geometry {
|
||||
GrColor fColor;
|
||||
GrShape fShape;
|
||||
bool fAntiAlias;
|
||||
};
|
||||
|
||||
BatchTracker fBatch;
|
||||
@ -518,8 +515,6 @@ private:
|
||||
bool GrAADistanceFieldPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(args.fRenderTargetContext->auditTrail(),
|
||||
"GrAADistanceFieldPathRenderer::onDrawPath");
|
||||
SkASSERT(!args.fRenderTargetContext->isUnifiedMultisampled());
|
||||
SkASSERT(args.fShape->style().isSimpleFill());
|
||||
|
||||
// we've already bailed on inverse filled paths, so this is safe
|
||||
SkASSERT(!args.fShape->isEmpty());
|
||||
@ -536,11 +531,10 @@ bool GrAADistanceFieldPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
}
|
||||
|
||||
sk_sp<GrDrawOp> batch(new AADistanceFieldPathBatch(args.fPaint->getColor(),
|
||||
*args.fShape,
|
||||
args.fAntiAlias, *args.fViewMatrix,
|
||||
*args.fShape, *args.fViewMatrix,
|
||||
fAtlas.get(), &fShapeCache, &fShapeList,
|
||||
args.fGammaCorrect));
|
||||
GrPipelineBuilder pipelineBuilder(*args.fPaint);
|
||||
GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fAAType);
|
||||
pipelineBuilder.setUserStencil(args.fUserStencilSettings);
|
||||
|
||||
args.fRenderTargetContext->addDrawOp(pipelineBuilder, *args.fClip, batch.get());
|
||||
@ -614,11 +608,9 @@ DRAW_BATCH_TEST_DEFINE(AADistanceFieldPathBatch) {
|
||||
|
||||
// This path renderer only allows fill styles.
|
||||
GrShape shape(GrTest::TestPath(random), GrStyle::SimpleFill());
|
||||
bool antiAlias = random->nextBool();
|
||||
|
||||
return new AADistanceFieldPathBatch(color,
|
||||
shape,
|
||||
antiAlias,
|
||||
viewMatrix,
|
||||
gTestStruct.fAtlas.get(),
|
||||
&gTestStruct.fShapeCache,
|
||||
|
@ -617,7 +617,7 @@ static void add_line(const SkPoint p[2],
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool GrAAHairLinePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
|
||||
if (!args.fAntiAlias) {
|
||||
if (GrAAType::kCoverage != args.fAAType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -981,7 +981,7 @@ bool GrAAHairLinePathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
*args.fViewMatrix, path,
|
||||
args.fShape->style(), devClipBounds));
|
||||
|
||||
GrPipelineBuilder pipelineBuilder(*args.fPaint);
|
||||
GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fAAType);
|
||||
pipelineBuilder.setUserStencil(args.fUserStencilSettings);
|
||||
args.fRenderTargetContext->addDrawOp(pipelineBuilder, *args.fClip, batch.get());
|
||||
|
||||
|
@ -37,7 +37,7 @@ GrAALinearizingConvexPathRenderer::GrAALinearizingConvexPathRenderer() {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool GrAALinearizingConvexPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
|
||||
if (!args.fAntiAlias) {
|
||||
if (GrAAType::kCoverage != args.fAAType) {
|
||||
return false;
|
||||
}
|
||||
if (!args.fShape->knownToBeConvex()) {
|
||||
@ -361,7 +361,7 @@ bool GrAALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
stroke.getStyle(),
|
||||
join, miterLimit));
|
||||
|
||||
GrPipelineBuilder pipelineBuilder(*args.fPaint);
|
||||
GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fAAType);
|
||||
pipelineBuilder.setUserStencil(args.fUserStencilSettings);
|
||||
|
||||
args.fRenderTargetContext->addDrawOp(pipelineBuilder, *args.fClip, batch.get());
|
||||
|
@ -16,6 +16,9 @@ bool GrDashLinePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
|
||||
SkPoint pts[2];
|
||||
bool inverted;
|
||||
if (args.fShape->style().isDashed() && args.fShape->asLine(pts, &inverted)) {
|
||||
if (args.fAAType == GrAAType::kMixedSamples) {
|
||||
return false;
|
||||
}
|
||||
// We should never have an inverse dashed case.
|
||||
SkASSERT(!inverted);
|
||||
return GrDashingEffect::CanDrawDashLine(pts, args.fShape->style(), *args.fViewMatrix);
|
||||
@ -26,16 +29,19 @@ bool GrDashLinePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
|
||||
bool GrDashLinePathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(args.fRenderTargetContext->auditTrail(),
|
||||
"GrDashLinePathRenderer::onDrawPath");
|
||||
bool useHWAA = args.fRenderTargetContext->isUnifiedMultisampled();
|
||||
GrDashingEffect::AAMode aaMode;
|
||||
if (useHWAA) {
|
||||
// We ignore args.fAntiAlias here and force anti aliasing when using MSAA. Otherwise,
|
||||
GrDashingEffect::AAMode aaMode = GrDashingEffect::AAMode::kNone;
|
||||
switch (args.fAAType) {
|
||||
case GrAAType::kNone:
|
||||
break;
|
||||
case GrAAType::kCoverage:
|
||||
case GrAAType::kMixedSamples:
|
||||
aaMode = GrDashingEffect::AAMode::kCoverage;
|
||||
break;
|
||||
case GrAAType::kMSAA:
|
||||
// In this mode we will use aa between dashes but the outer border uses MSAA. Otherwise,
|
||||
// we can wind up with external edges antialiased and internal edges unantialiased.
|
||||
aaMode = GrDashingEffect::AAMode::kCoverageWithMSAA;
|
||||
} else if (args.fAntiAlias) {
|
||||
aaMode = GrDashingEffect::AAMode::kCoverage;
|
||||
} else {
|
||||
aaMode = GrDashingEffect::AAMode::kNone;
|
||||
break;
|
||||
}
|
||||
SkPoint pts[2];
|
||||
SkAssertResult(args.fShape->asLine(pts, nullptr));
|
||||
@ -48,7 +54,7 @@ bool GrDashLinePathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GrPipelineBuilder pipelineBuilder(*args.fPaint, useHWAA);
|
||||
GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fAAType);
|
||||
pipelineBuilder.setUserStencil(args.fUserStencilSettings);
|
||||
|
||||
args.fRenderTargetContext->addDrawOp(pipelineBuilder, *args.fClip, batch.get());
|
||||
|
@ -424,11 +424,13 @@ private:
|
||||
|
||||
bool GrDefaultPathRenderer::internalDrawPath(GrRenderTargetContext* renderTargetContext,
|
||||
const GrPaint& paint,
|
||||
GrAAType aaType,
|
||||
const GrUserStencilSettings& userStencilSettings,
|
||||
const GrClip& clip,
|
||||
const SkMatrix& viewMatrix,
|
||||
const GrShape& shape,
|
||||
bool stencilOnly) {
|
||||
SkASSERT(GrAAType::kCoverage != aaType);
|
||||
SkPath path;
|
||||
shape.asPath(&path);
|
||||
|
||||
@ -567,23 +569,20 @@ bool GrDefaultPathRenderer::internalDrawPath(GrRenderTargetContext* renderTarget
|
||||
&localMatrix));
|
||||
|
||||
SkASSERT(GrDrawFace::kBoth == drawFace[p]);
|
||||
GrPipelineBuilder pipelineBuilder(paint, renderTargetContext->mustUseHWAA(paint));
|
||||
GrPipelineBuilder pipelineBuilder(paint, aaType);
|
||||
pipelineBuilder.setDrawFace(drawFace[p]);
|
||||
pipelineBuilder.setUserStencil(passes[p]);
|
||||
|
||||
renderTargetContext->addDrawOp(pipelineBuilder, clip, batch.get());
|
||||
} else {
|
||||
sk_sp<GrDrawOp> batch(new DefaultPathBatch(paint.getColor(), path, srcSpaceTol,
|
||||
newCoverage, viewMatrix, isHairline,
|
||||
devBounds));
|
||||
|
||||
GrPipelineBuilder pipelineBuilder(paint, renderTargetContext->mustUseHWAA(paint));
|
||||
GrPipelineBuilder pipelineBuilder(paint, aaType);
|
||||
pipelineBuilder.setDrawFace(drawFace[p]);
|
||||
pipelineBuilder.setUserStencil(passes[p]);
|
||||
if (passCount > 1) {
|
||||
pipelineBuilder.setDisableColorXPFactory();
|
||||
}
|
||||
|
||||
renderTargetContext->addDrawOp(pipelineBuilder, clip, batch.get());
|
||||
}
|
||||
}
|
||||
@ -591,8 +590,8 @@ bool GrDefaultPathRenderer::internalDrawPath(GrRenderTargetContext* renderTarget
|
||||
}
|
||||
|
||||
bool GrDefaultPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
|
||||
// this class can draw any path with any simple fill style but doesn't do any anti-aliasing.
|
||||
return !args.fAntiAlias &&
|
||||
// This can draw any path with any simple fill style but doesn't do coverage-based antialiasing.
|
||||
return GrAAType::kCoverage != args.fAAType &&
|
||||
(args.fShape->style().isSimpleFill() ||
|
||||
IsStrokeHairlineOrEquivalent(args.fShape->style(), *args.fViewMatrix, nullptr));
|
||||
}
|
||||
@ -602,6 +601,7 @@ bool GrDefaultPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
"GrDefaultPathRenderer::onDrawPath");
|
||||
return this->internalDrawPath(args.fRenderTargetContext,
|
||||
*args.fPaint,
|
||||
args.fAAType,
|
||||
*args.fUserStencilSettings,
|
||||
*args.fClip,
|
||||
*args.fViewMatrix,
|
||||
@ -616,10 +616,10 @@ void GrDefaultPathRenderer::onStencilPath(const StencilPathArgs& args) {
|
||||
|
||||
GrPaint paint;
|
||||
paint.setXPFactory(GrDisableColorXPFactory::Make());
|
||||
paint.setAntiAlias(args.fIsAA);
|
||||
|
||||
this->internalDrawPath(args.fRenderTargetContext, paint, GrUserStencilSettings::kUnused,
|
||||
*args.fClip, *args.fViewMatrix, *args.fShape, true);
|
||||
this->internalDrawPath(args.fRenderTargetContext, paint, args.fAAType,
|
||||
GrUserStencilSettings::kUnused, *args.fClip, *args.fViewMatrix,
|
||||
*args.fShape, true);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -32,6 +32,7 @@ private:
|
||||
|
||||
bool internalDrawPath(GrRenderTargetContext*,
|
||||
const GrPaint&,
|
||||
GrAAType,
|
||||
const GrUserStencilSettings&,
|
||||
const GrClip&,
|
||||
const SkMatrix& viewMatrix,
|
||||
|
@ -562,6 +562,7 @@ private:
|
||||
|
||||
bool GrMSAAPathRenderer::internalDrawPath(GrRenderTargetContext* renderTargetContext,
|
||||
const GrPaint& paint,
|
||||
GrAAType aaType,
|
||||
const GrUserStencilSettings& userStencilSettings,
|
||||
const GrClip& clip,
|
||||
const SkMatrix& viewMatrix,
|
||||
@ -662,7 +663,7 @@ bool GrMSAAPathRenderer::internalDrawPath(GrRenderTargetContext* renderTargetCon
|
||||
GrRectBatchFactory::CreateNonAAFill(paint.getColor(), viewM, bounds, nullptr,
|
||||
&localMatrix));
|
||||
|
||||
GrPipelineBuilder pipelineBuilder(paint, renderTargetContext->mustUseHWAA(paint));
|
||||
GrPipelineBuilder pipelineBuilder(paint, aaType);
|
||||
pipelineBuilder.setUserStencil(passes[p]);
|
||||
|
||||
renderTargetContext->addDrawOp(pipelineBuilder, clip, batch.get());
|
||||
@ -673,12 +674,11 @@ bool GrMSAAPathRenderer::internalDrawPath(GrRenderTargetContext* renderTargetCon
|
||||
return false;
|
||||
}
|
||||
|
||||
GrPipelineBuilder pipelineBuilder(paint, renderTargetContext->mustUseHWAA(paint));
|
||||
GrPipelineBuilder pipelineBuilder(paint, aaType);
|
||||
pipelineBuilder.setUserStencil(passes[p]);
|
||||
if (passCount > 1) {
|
||||
pipelineBuilder.setDisableColorXPFactory();
|
||||
}
|
||||
|
||||
renderTargetContext->addDrawOp(pipelineBuilder, clip, batch.get());
|
||||
}
|
||||
}
|
||||
@ -689,7 +689,7 @@ bool GrMSAAPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
|
||||
// This path renderer only fills and relies on MSAA for antialiasing. Stroked shapes are
|
||||
// handled by passing on the original shape and letting the caller compute the stroked shape
|
||||
// which will have a fill style.
|
||||
return args.fShape->style().isSimpleFill() && !args.fAntiAlias;
|
||||
return args.fShape->style().isSimpleFill() && (GrAAType::kCoverage != args.fAAType);
|
||||
}
|
||||
|
||||
bool GrMSAAPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
@ -704,6 +704,7 @@ bool GrMSAAPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
}
|
||||
return this->internalDrawPath(args.fRenderTargetContext,
|
||||
*args.fPaint,
|
||||
args.fAAType,
|
||||
*args.fUserStencilSettings,
|
||||
*args.fClip,
|
||||
*args.fViewMatrix,
|
||||
@ -719,10 +720,10 @@ void GrMSAAPathRenderer::onStencilPath(const StencilPathArgs& args) {
|
||||
|
||||
GrPaint paint;
|
||||
paint.setXPFactory(GrDisableColorXPFactory::Make());
|
||||
paint.setAntiAlias(args.fIsAA);
|
||||
|
||||
this->internalDrawPath(args.fRenderTargetContext, paint, GrUserStencilSettings::kUnused,
|
||||
*args.fClip, *args.fViewMatrix, *args.fShape, true);
|
||||
this->internalDrawPath(args.fRenderTargetContext, paint, args.fAAType,
|
||||
GrUserStencilSettings::kUnused, *args.fClip, *args.fViewMatrix,
|
||||
*args.fShape, true);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -23,6 +23,7 @@ private:
|
||||
|
||||
bool internalDrawPath(GrRenderTargetContext*,
|
||||
const GrPaint&,
|
||||
GrAAType,
|
||||
const GrUserStencilSettings&,
|
||||
const GrClip&,
|
||||
const SkMatrix& viewMatrix,
|
||||
|
@ -758,7 +758,7 @@ bool GrPLSPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const {
|
||||
// seams. Disable in the presence of even-odd for now.
|
||||
SkPath path;
|
||||
args.fShape->asPath(&path);
|
||||
return args.fShaderCaps->shaderDerivativeSupport() && args.fAntiAlias &&
|
||||
return args.fShaderCaps->shaderDerivativeSupport() && GrAAType::kCoverage == args.fAAType &&
|
||||
args.fShape->style().isSimpleFill() && !path.isInverseFillType() &&
|
||||
path.getFillType() == SkPath::FillType::kWinding_FillType;
|
||||
}
|
||||
@ -936,13 +936,10 @@ bool GrPLSPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
args.fShape->asPath(&path);
|
||||
|
||||
sk_sp<GrDrawOp> batch(new PLSPathBatch(args.fPaint->getColor(), path, *args.fViewMatrix));
|
||||
|
||||
GrPipelineBuilder pipelineBuilder(*args.fPaint,
|
||||
args.fRenderTargetContext->mustUseHWAA(*args.fPaint));
|
||||
GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fAAType);
|
||||
pipelineBuilder.setUserStencil(args.fUserStencilSettings);
|
||||
|
||||
args.fRenderTargetContext->addDrawOp(pipelineBuilder, *args.fClip, batch.get());
|
||||
|
||||
SkDEBUGCODE(inPLSDraw = false;)
|
||||
return true;
|
||||
|
||||
|
@ -44,11 +44,8 @@ bool GrStencilAndCoverPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) c
|
||||
if (args.fHasUserStencilSettings) {
|
||||
return false;
|
||||
}
|
||||
if (args.fAntiAlias) {
|
||||
return args.fIsStencilBufferMSAA;
|
||||
} else {
|
||||
return true; // doesn't do per-path AA, relies on the target having MSAA
|
||||
}
|
||||
// doesn't do per-path AA, relies on the target having MSAA.
|
||||
return (GrAAType::kCoverage != args.fAAType);
|
||||
}
|
||||
|
||||
static GrPath* get_gr_path(GrResourceProvider* resourceProvider, const GrShape& shape) {
|
||||
@ -80,18 +77,14 @@ static GrPath* get_gr_path(GrResourceProvider* resourceProvider, const GrShape&
|
||||
void GrStencilAndCoverPathRenderer::onStencilPath(const StencilPathArgs& args) {
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(args.fRenderTargetContext->auditTrail(),
|
||||
"GrStencilAndCoverPathRenderer::onStencilPath");
|
||||
SkASSERT(!args.fIsAA || args.fRenderTargetContext->isStencilBufferMultisampled());
|
||||
|
||||
sk_sp<GrPath> p(get_gr_path(fResourceProvider, *args.fShape));
|
||||
args.fRenderTargetContext->priv().stencilPath(*args.fClip, args.fIsAA,
|
||||
args.fRenderTargetContext->priv().stencilPath(*args.fClip, args.fAAType,
|
||||
*args.fViewMatrix, p.get());
|
||||
}
|
||||
|
||||
bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(args.fRenderTargetContext->auditTrail(),
|
||||
"GrStencilAndCoverPathRenderer::onDrawPath");
|
||||
SkASSERT(!args.fPaint->isAntiAlias() ||
|
||||
args.fRenderTargetContext->isStencilBufferMultisampled());
|
||||
SkASSERT(!args.fShape->style().strokeRec().isHairlineStyle());
|
||||
|
||||
const SkMatrix& viewMatrix = *args.fViewMatrix;
|
||||
@ -125,8 +118,8 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
nullptr, &invert));
|
||||
|
||||
// fake inverse with a stencil and cover
|
||||
args.fRenderTargetContext->priv().stencilPath(*args.fClip, args.fPaint->isAntiAlias(),
|
||||
viewMatrix, path.get());
|
||||
args.fRenderTargetContext->priv().stencilPath(*args.fClip, args.fAAType, viewMatrix,
|
||||
path.get());
|
||||
|
||||
{
|
||||
static constexpr GrUserStencilSettings kInvertedCoverPass(
|
||||
@ -141,10 +134,13 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
GrUserStencilOp::kZero,
|
||||
0xffff>()
|
||||
);
|
||||
|
||||
GrPipelineBuilder pipelineBuilder(*args.fPaint,
|
||||
args.fPaint->isAntiAlias() &&
|
||||
!args.fRenderTargetContext->hasMixedSamples());
|
||||
// We have to suppress enabling MSAA for mixed samples or we will get seams due to
|
||||
// coverage modulation along the edge where two triangles making up the rect meet.
|
||||
GrAAType coverAAType = args.fAAType;
|
||||
if (GrAAType::kMixedSamples == coverAAType) {
|
||||
coverAAType = GrAAType::kNone;
|
||||
}
|
||||
GrPipelineBuilder pipelineBuilder(*args.fPaint, coverAAType);
|
||||
pipelineBuilder.setUserStencil(&kInvertedCoverPass);
|
||||
|
||||
args.fRenderTargetContext->addDrawOp(pipelineBuilder, *args.fClip, coverBatch.get());
|
||||
@ -163,13 +159,8 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
sk_sp<GrDrawOp> batch(GrDrawPathBatch::Create(viewMatrix, args.fPaint->getColor(),
|
||||
path.get()));
|
||||
|
||||
GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fPaint->isAntiAlias());
|
||||
GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fAAType);
|
||||
pipelineBuilder.setUserStencil(&kCoverPass);
|
||||
if (args.fAntiAlias) {
|
||||
SkASSERT(args.fRenderTargetContext->isStencilBufferMultisampled());
|
||||
pipelineBuilder.enableState(GrPipelineBuilder::kHWAntialias_Flag);
|
||||
}
|
||||
|
||||
args.fRenderTargetContext->addDrawOp(pipelineBuilder, *args.fClip, batch.get());
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ bool GrTessellatingPathRenderer::onCanDrawPath(const CanDrawPathArgs& args) cons
|
||||
if (!args.fShape->style().isSimpleFill() || args.fShape->knownToBeConvex()) {
|
||||
return false;
|
||||
}
|
||||
if (args.fAntiAlias) {
|
||||
if (GrAAType::kCoverage == args.fAAType) {
|
||||
#ifdef SK_DISABLE_SCREENSPACE_TESS_AA_PATH_RENDERER
|
||||
return false;
|
||||
#else
|
||||
@ -364,14 +364,10 @@ bool GrTessellatingPathRenderer::onDrawPath(const DrawPathArgs& args) {
|
||||
*args.fShape,
|
||||
*args.fViewMatrix,
|
||||
clipBoundsI,
|
||||
args.fAntiAlias));
|
||||
|
||||
GrPipelineBuilder pipelineBuilder(*args.fPaint,
|
||||
args.fRenderTargetContext->mustUseHWAA(*args.fPaint));
|
||||
GrAAType::kCoverage == args.fAAType));
|
||||
GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fAAType);
|
||||
pipelineBuilder.setUserStencil(args.fUserStencilSettings);
|
||||
|
||||
args.fRenderTargetContext->addDrawOp(pipelineBuilder, *args.fClip, batch.get());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -237,19 +237,19 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
|
||||
paint1.addColorFragmentProcessor(std::move(pmToUPM1));
|
||||
paint1.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
|
||||
readRTC->fillRectToRect(GrNoClip(), paint1, SkMatrix::I(), kDstRect, kSrcRect);
|
||||
readRTC->fillRectToRect(GrNoClip(), paint1, GrAA::kNo, SkMatrix::I(), kDstRect, kSrcRect);
|
||||
|
||||
readRTC->asTexture()->readPixels(0, 0, kSize, kSize, kConfig, firstRead);
|
||||
|
||||
paint2.addColorFragmentProcessor(std::move(upmToPM));
|
||||
paint2.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
|
||||
tempRTC->fillRectToRect(GrNoClip(), paint2, SkMatrix::I(), kDstRect, kSrcRect);
|
||||
tempRTC->fillRectToRect(GrNoClip(), paint2, GrAA::kNo, SkMatrix::I(), kDstRect, kSrcRect);
|
||||
|
||||
paint3.addColorFragmentProcessor(std::move(pmToUPM2));
|
||||
paint3.setPorterDuffXPFactory(SkBlendMode::kSrc);
|
||||
|
||||
readRTC->fillRectToRect(GrNoClip(), paint3, SkMatrix::I(), kDstRect, kSrcRect);
|
||||
readRTC->fillRectToRect(GrNoClip(), paint3, GrAA::kNo, SkMatrix::I(), kDstRect, kSrcRect);
|
||||
|
||||
readRTC->asTexture()->readPixels(0, 0, kSize, kSize, kConfig, secondRead);
|
||||
|
||||
|
@ -22,28 +22,27 @@ InstancedRendering::InstancedRendering(GrGpu* gpu)
|
||||
}
|
||||
|
||||
GrDrawOp* InstancedRendering::recordRect(const SkRect& rect, const SkMatrix& viewMatrix,
|
||||
GrColor color, bool antialias,
|
||||
const GrInstancedPipelineInfo& info, bool* useHWAA) {
|
||||
return this->recordShape(ShapeType::kRect, rect, viewMatrix, color, rect, antialias, info,
|
||||
useHWAA);
|
||||
GrColor color, GrAA aa,
|
||||
const GrInstancedPipelineInfo& info, GrAAType* aaType) {
|
||||
return this->recordShape(ShapeType::kRect, rect, viewMatrix, color, rect, aa, info, aaType);
|
||||
}
|
||||
|
||||
GrDrawOp* InstancedRendering::recordRect(const SkRect& rect, const SkMatrix& viewMatrix,
|
||||
GrColor color, const SkRect& localRect, bool antialias,
|
||||
const GrInstancedPipelineInfo& info, bool* useHWAA) {
|
||||
return this->recordShape(ShapeType::kRect, rect, viewMatrix, color, localRect, antialias, info,
|
||||
useHWAA);
|
||||
GrColor color, const SkRect& localRect, GrAA aa,
|
||||
const GrInstancedPipelineInfo& info, GrAAType* aaType) {
|
||||
return this->recordShape(ShapeType::kRect, rect, viewMatrix, color, localRect, aa, info,
|
||||
aaType);
|
||||
}
|
||||
|
||||
GrDrawOp* InstancedRendering::recordRect(const SkRect& rect, const SkMatrix& viewMatrix,
|
||||
GrColor color, const SkMatrix& localMatrix,
|
||||
bool antialias, const GrInstancedPipelineInfo& info,
|
||||
bool* useHWAA) {
|
||||
GrAA aa, const GrInstancedPipelineInfo& info,
|
||||
GrAAType* aaType) {
|
||||
if (localMatrix.hasPerspective()) {
|
||||
return nullptr; // Perspective is not yet supported in the local matrix.
|
||||
}
|
||||
if (Batch* batch = this->recordShape(ShapeType::kRect, rect, viewMatrix, color, rect, antialias,
|
||||
info, useHWAA)) {
|
||||
if (Batch* batch = this->recordShape(ShapeType::kRect, rect, viewMatrix, color, rect, aa,
|
||||
info, aaType)) {
|
||||
batch->getSingleInstance().fInfo |= kLocalMatrix_InfoFlag;
|
||||
batch->appendParamsTexel(localMatrix.getScaleX(), localMatrix.getSkewX(),
|
||||
localMatrix.getTranslateX());
|
||||
@ -56,17 +55,16 @@ GrDrawOp* InstancedRendering::recordRect(const SkRect& rect, const SkMatrix& vie
|
||||
}
|
||||
|
||||
GrDrawOp* InstancedRendering::recordOval(const SkRect& oval, const SkMatrix& viewMatrix,
|
||||
GrColor color, bool antialias,
|
||||
const GrInstancedPipelineInfo& info, bool* useHWAA) {
|
||||
return this->recordShape(ShapeType::kOval, oval, viewMatrix, color, oval, antialias, info,
|
||||
useHWAA);
|
||||
GrColor color, GrAA aa,
|
||||
const GrInstancedPipelineInfo& info, GrAAType* aaType) {
|
||||
return this->recordShape(ShapeType::kOval, oval, viewMatrix, color, oval, aa, info, aaType);
|
||||
}
|
||||
|
||||
GrDrawOp* InstancedRendering::recordRRect(const SkRRect& rrect, const SkMatrix& viewMatrix,
|
||||
GrColor color, bool antialias,
|
||||
const GrInstancedPipelineInfo& info, bool* useHWAA) {
|
||||
GrColor color, GrAA aa,
|
||||
const GrInstancedPipelineInfo& info, GrAAType* aaType) {
|
||||
if (Batch* batch = this->recordShape(GetRRectShapeType(rrect), rrect.rect(), viewMatrix, color,
|
||||
rrect.rect(), antialias, info, useHWAA)) {
|
||||
rrect.rect(), aa, info, aaType)) {
|
||||
batch->appendRRectParams(rrect);
|
||||
return batch;
|
||||
}
|
||||
@ -75,16 +73,16 @@ GrDrawOp* InstancedRendering::recordRRect(const SkRRect& rrect, const SkMatrix&
|
||||
|
||||
GrDrawOp* InstancedRendering::recordDRRect(const SkRRect& outer, const SkRRect& inner,
|
||||
const SkMatrix& viewMatrix, GrColor color,
|
||||
bool antialias, const GrInstancedPipelineInfo& info,
|
||||
bool* useHWAA) {
|
||||
GrAA aa, const GrInstancedPipelineInfo& info,
|
||||
GrAAType* aaType) {
|
||||
if (inner.getType() > SkRRect::kSimple_Type) {
|
||||
return nullptr; // Complex inner round rects are not yet supported.
|
||||
}
|
||||
if (SkRRect::kEmpty_Type == inner.getType()) {
|
||||
return this->recordRRect(outer, viewMatrix, color, antialias, info, useHWAA);
|
||||
return this->recordRRect(outer, viewMatrix, color, aa, info, aaType);
|
||||
}
|
||||
if (Batch* batch = this->recordShape(GetRRectShapeType(outer), outer.rect(), viewMatrix, color,
|
||||
outer.rect(), antialias, info, useHWAA)) {
|
||||
outer.rect(), aa, info, aaType)) {
|
||||
batch->appendRRectParams(outer);
|
||||
ShapeType innerShapeType = GetRRectShapeType(inner);
|
||||
batch->fInfo.fInnerShapeTypes |= GetShapeFlag(innerShapeType);
|
||||
@ -99,9 +97,9 @@ GrDrawOp* InstancedRendering::recordDRRect(const SkRRect& outer, const SkRRect&
|
||||
InstancedRendering::Batch* InstancedRendering::recordShape(ShapeType type, const SkRect& bounds,
|
||||
const SkMatrix& viewMatrix,
|
||||
GrColor color, const SkRect& localRect,
|
||||
bool antialias,
|
||||
GrAA aa,
|
||||
const GrInstancedPipelineInfo& info,
|
||||
bool* useHWAA) {
|
||||
GrAAType* aaType) {
|
||||
SkASSERT(State::kRecordingDraws == fState);
|
||||
|
||||
if (info.fIsRenderingToFloat && fGpu->caps()->avoidInstancedDrawsToFPTargets()) {
|
||||
@ -109,7 +107,7 @@ InstancedRendering::Batch* InstancedRendering::recordShape(ShapeType type, const
|
||||
}
|
||||
|
||||
AntialiasMode antialiasMode;
|
||||
if (!this->selectAntialiasMode(viewMatrix, antialias, info, useHWAA, &antialiasMode)) {
|
||||
if (!this->selectAntialiasMode(viewMatrix, aa, info, aaType, &antialiasMode)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -193,27 +191,28 @@ InstancedRendering::Batch* InstancedRendering::recordShape(ShapeType type, const
|
||||
return batch;
|
||||
}
|
||||
|
||||
inline bool InstancedRendering::selectAntialiasMode(const SkMatrix& viewMatrix, bool antialias,
|
||||
inline bool InstancedRendering::selectAntialiasMode(const SkMatrix& viewMatrix, GrAA aa,
|
||||
const GrInstancedPipelineInfo& info,
|
||||
bool* useHWAA, AntialiasMode* antialiasMode) {
|
||||
GrAAType* aaType,
|
||||
AntialiasMode* antialiasMode) {
|
||||
SkASSERT(!info.fColorDisabled || info.fDrawingShapeToStencil);
|
||||
SkASSERT(!info.fIsMixedSampled || info.fIsMultisampled);
|
||||
SkASSERT(GrCaps::InstancedSupport::kNone != fGpu->caps()->instancedSupport());
|
||||
|
||||
if (!info.fIsMultisampled || fGpu->caps()->multisampleDisableSupport()) {
|
||||
if (!antialias) {
|
||||
if (GrAA::kNo == aa) {
|
||||
if (info.fDrawingShapeToStencil && !info.fCanDiscard) {
|
||||
// We can't draw to the stencil buffer without discard (or sample mask if MSAA).
|
||||
return false;
|
||||
}
|
||||
*antialiasMode = AntialiasMode::kNone;
|
||||
*useHWAA = false;
|
||||
*aaType = GrAAType::kNone;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (info.canUseCoverageAA() && viewMatrix.preservesRightAngles()) {
|
||||
*antialiasMode = AntialiasMode::kCoverage;
|
||||
*useHWAA = false;
|
||||
*aaType = GrAAType::kCoverage;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -222,12 +221,12 @@ inline bool InstancedRendering::selectAntialiasMode(const SkMatrix& viewMatrix,
|
||||
fGpu->caps()->instancedSupport() >= GrCaps::InstancedSupport::kMultisampled) {
|
||||
if (!info.fIsMixedSampled || info.fColorDisabled) {
|
||||
*antialiasMode = AntialiasMode::kMSAA;
|
||||
*useHWAA = true;
|
||||
*aaType = GrAAType::kMSAA;
|
||||
return true;
|
||||
}
|
||||
if (fGpu->caps()->instancedSupport() >= GrCaps::InstancedSupport::kMixedSampled) {
|
||||
*antialiasMode = AntialiasMode::kMixedSamples;
|
||||
*useHWAA = true;
|
||||
*aaType = GrAAType::kMixedSamples;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -46,28 +46,25 @@ public:
|
||||
* draws between beginFlush() and endFlush().
|
||||
*/
|
||||
GrDrawOp* SK_WARN_UNUSED_RESULT recordRect(const SkRect&, const SkMatrix&, GrColor,
|
||||
bool antialias, const GrInstancedPipelineInfo&,
|
||||
bool* useHWAA);
|
||||
GrAA, const GrInstancedPipelineInfo&, GrAAType*);
|
||||
|
||||
GrDrawOp* SK_WARN_UNUSED_RESULT recordRect(const SkRect&, const SkMatrix&, GrColor,
|
||||
const SkRect& localRect, bool antialias,
|
||||
const GrInstancedPipelineInfo&, bool* useHWAA);
|
||||
const SkRect& localRect, GrAA,
|
||||
const GrInstancedPipelineInfo&, GrAAType*);
|
||||
|
||||
GrDrawOp* SK_WARN_UNUSED_RESULT recordRect(const SkRect&, const SkMatrix&, GrColor,
|
||||
const SkMatrix& localMatrix, bool antialias,
|
||||
const GrInstancedPipelineInfo&, bool* useHWAA);
|
||||
const SkMatrix& localMatrix, GrAA,
|
||||
const GrInstancedPipelineInfo&, GrAAType*);
|
||||
|
||||
GrDrawOp* SK_WARN_UNUSED_RESULT recordOval(const SkRect&, const SkMatrix&, GrColor,
|
||||
bool antialias, const GrInstancedPipelineInfo&,
|
||||
bool* useHWAA);
|
||||
GrAA, const GrInstancedPipelineInfo&, GrAAType*);
|
||||
|
||||
GrDrawOp* SK_WARN_UNUSED_RESULT recordRRect(const SkRRect&, const SkMatrix&, GrColor,
|
||||
bool antialias, const GrInstancedPipelineInfo&,
|
||||
bool* useHWAA);
|
||||
GrAA, const GrInstancedPipelineInfo&, GrAAType*);
|
||||
|
||||
GrDrawOp* SK_WARN_UNUSED_RESULT recordDRRect(const SkRRect& outer, const SkRRect& inner,
|
||||
const SkMatrix&, GrColor, bool antialias,
|
||||
const GrInstancedPipelineInfo&, bool* useHWAA);
|
||||
const SkMatrix&, GrColor, GrAA,
|
||||
const GrInstancedPipelineInfo&, GrAAType*);
|
||||
|
||||
/**
|
||||
* Compiles all recorded draws into GPU buffers and allows the client to begin flushing the
|
||||
@ -182,11 +179,11 @@ private:
|
||||
|
||||
Batch* SK_WARN_UNUSED_RESULT recordShape(ShapeType, const SkRect& bounds,
|
||||
const SkMatrix& viewMatrix, GrColor,
|
||||
const SkRect& localRect, bool antialias,
|
||||
const GrInstancedPipelineInfo&, bool* requireHWAA);
|
||||
const SkRect& localRect, GrAA aa,
|
||||
const GrInstancedPipelineInfo&, GrAAType*);
|
||||
|
||||
bool selectAntialiasMode(const SkMatrix& viewMatrix, bool antialias,
|
||||
const GrInstancedPipelineInfo&, bool* useHWAA, AntialiasMode*);
|
||||
bool selectAntialiasMode(const SkMatrix& viewMatrix, GrAA aa, const GrInstancedPipelineInfo&,
|
||||
GrAAType*, AntialiasMode*);
|
||||
|
||||
virtual Batch* createBatch() = 0;
|
||||
|
||||
|
@ -42,6 +42,7 @@ enum class Attrib : uint8_t {
|
||||
};
|
||||
constexpr int kNumAttribs = 1 + (int)Attrib::kLocalRect;
|
||||
|
||||
// TODO: replace with GrAAType?
|
||||
enum class AntialiasMode : uint8_t {
|
||||
kNone,
|
||||
kCoverage,
|
||||
|
@ -323,8 +323,7 @@ void GrAtlasTextBlob::flushRun(GrRenderTargetContext* rtc, const GrPaint& grPain
|
||||
distanceAdjustTable,
|
||||
rtc->isGammaCorrect(),
|
||||
cache));
|
||||
|
||||
GrPipelineBuilder pipelineBuilder(grPaint, rtc->mustUseHWAA(grPaint));
|
||||
GrPipelineBuilder pipelineBuilder(grPaint, GrAAType::kNone);
|
||||
|
||||
rtc->addDrawOp(pipelineBuilder, clip, batch.get());
|
||||
}
|
||||
|
@ -224,10 +224,8 @@ void GrStencilAndCoverTextContext::drawTextBlob(GrContext* context, GrRenderTarg
|
||||
|
||||
TextBlob::Iter iter(blob);
|
||||
for (TextRun* run = iter.get(); run; run = iter.next()) {
|
||||
// The run's "font" overrides the anti-aliasing of the passed in paint!
|
||||
paint.setAntiAlias(run->isAntiAlias());
|
||||
run->draw(context, rtc, paint, clip, viewMatrix, props, x, y,
|
||||
clipBounds, fFallbackTextContext, skPaint);
|
||||
run->draw(context, rtc, paint, clip, viewMatrix, props, x, y, clipBounds,
|
||||
fFallbackTextContext, skPaint);
|
||||
run->releaseGlyphCache();
|
||||
}
|
||||
}
|
||||
@ -605,8 +603,9 @@ void GrStencilAndCoverTextContext::TextRun::draw(GrContext* ctx,
|
||||
const SkIRect& clipBounds,
|
||||
GrAtlasTextContext* fallbackTextContext,
|
||||
const SkPaint& originalSkPaint) const {
|
||||
GrAA runAA = this->isAntiAlias();
|
||||
SkASSERT(fInstanceData);
|
||||
SkASSERT(renderTargetContext->isStencilBufferMultisampled() || !grPaint.isAntiAlias());
|
||||
SkASSERT(renderTargetContext->isStencilBufferMultisampled() || GrAA::kNo == runAA);
|
||||
|
||||
if (fInstanceData->count()) {
|
||||
static constexpr GrUserStencilSettings kCoverPass(
|
||||
@ -640,8 +639,16 @@ void GrStencilAndCoverTextContext::TextRun::draw(GrContext* ctx,
|
||||
GrPathRendering::kWinding_FillType, glyphs.get(),
|
||||
fInstanceData.get(), bounds));
|
||||
|
||||
GrPipelineBuilder pipelineBuilder(grPaint);
|
||||
pipelineBuilder.setState(GrPipelineBuilder::kHWAntialias_Flag, grPaint.isAntiAlias());
|
||||
// The run's "font" overrides the anti-aliasing of the passed in SkPaint!
|
||||
GrAAType aaType = GrAAType::kNone;
|
||||
if (GrAA::kYes == runAA) {
|
||||
if (renderTargetContext->isUnifiedMultisampled()) {
|
||||
aaType = GrAAType::kMSAA;
|
||||
} else if (renderTargetContext->isStencilBufferMultisampled()) {
|
||||
aaType = GrAAType::kMixedSamples;
|
||||
}
|
||||
}
|
||||
GrPipelineBuilder pipelineBuilder(grPaint, aaType);
|
||||
pipelineBuilder.setUserStencil(&kCoverPass);
|
||||
|
||||
renderTargetContext->addDrawOp(pipelineBuilder, clip, batch.get());
|
||||
|
@ -88,7 +88,7 @@ private:
|
||||
|
||||
size_t computeSizeInCache() const;
|
||||
|
||||
bool isAntiAlias() const { return fFont.isAntiAlias(); }
|
||||
GrAA isAntiAlias() const { return fFont.isAntiAlias() ? GrAA::kYes : GrAA::kNo; }
|
||||
|
||||
private:
|
||||
typedef GrDrawPathRangeBatch::InstanceData InstanceData;
|
||||
|
@ -277,7 +277,7 @@ static sk_sp<SkImage> make_from_yuv_textures_copy(GrContext* ctx, SkYUVColorSpac
|
||||
|
||||
const SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
|
||||
|
||||
renderTargetContext->drawRect(GrNoClip(), paint, SkMatrix::I(), rect);
|
||||
renderTargetContext->drawRect(GrNoClip(), paint, GrAA::kNo, SkMatrix::I(), rect);
|
||||
|
||||
if (!renderTargetContext->accessRenderTarget()) {
|
||||
return nullptr;
|
||||
|
@ -53,7 +53,7 @@ static void test_far_from_origin(GrRenderTargetContext* renderTargetContext, GrP
|
||||
args.fResourceProvider = rp;
|
||||
args.fViewMatrix = &matrix;
|
||||
args.fShape = &shape;
|
||||
args.fAntiAlias = true;
|
||||
args.fAAType = GrAAType::kCoverage;
|
||||
args.fGammaCorrect = false;
|
||||
pr->drawPath(args);
|
||||
}
|
||||
|
@ -255,9 +255,6 @@ static bool set_random_state(GrPaint* paint, SkRandom* random) {
|
||||
if (random->nextBool()) {
|
||||
paint->setAllowSRGBInputs(true);
|
||||
}
|
||||
if (random->nextBool()) {
|
||||
paint->setAntiAlias(true);
|
||||
}
|
||||
return random->nextBool();
|
||||
}
|
||||
|
||||
@ -339,8 +336,13 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) {
|
||||
set_random_xpf(&grPaint, &ptd);
|
||||
bool snapToCenters = set_random_state(&grPaint, &random);
|
||||
const GrUserStencilSettings* uss = get_random_stencil(&random);
|
||||
// We don't use kHW because we will hit an assertion if the render target is not
|
||||
// multisampled
|
||||
static constexpr GrAAType kAATypes[] = {GrAAType::kNone, GrAAType::kCoverage};
|
||||
GrAAType aaType = kAATypes[random.nextULessThan(SK_ARRAY_COUNT(kAATypes))];
|
||||
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get(), uss, snapToCenters);
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, aaType, batch.get(), uss,
|
||||
snapToCenters);
|
||||
}
|
||||
// Flush everything, test passes if flush is successful(ie, no asserts are hit, no crashes)
|
||||
drawingManager->flush();
|
||||
@ -374,7 +376,8 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) {
|
||||
BlockInputFragmentProcessor::Make(std::move(fp)));
|
||||
grPaint.addColorFragmentProcessor(std::move(blockFP));
|
||||
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get());
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, GrAAType::kNone,
|
||||
batch.get());
|
||||
drawingManager->flush();
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "GrRenderTargetContext.h"
|
||||
#include "GrRenderTargetPriv.h"
|
||||
#include "GrTypesPriv.h"
|
||||
#include "GrPipelineBuilder.h"
|
||||
#include "gl/GrGLGpu.h"
|
||||
#include "gl/debug/DebugGLTestContext.h"
|
||||
@ -90,7 +91,7 @@ public:
|
||||
};
|
||||
|
||||
static GrPipeline* construct_dummy_pipeline(GrRenderTargetContext* dc, void* storage) {
|
||||
GrPipelineBuilder dummyBuilder;
|
||||
GrPipelineBuilder dummyBuilder(GrPaint(), GrAAType::kNone);
|
||||
GrScissorState dummyScissor;
|
||||
GrWindowRectsState dummyWindows;
|
||||
GrXPOverridesForBatch dummyOverrides;
|
||||
|
@ -127,7 +127,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) {
|
||||
GrPaint grPaint;
|
||||
// This one should succeed.
|
||||
batch.reset(new Batch(attribCnt));
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get());
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, GrAAType::kNone, batch.get());
|
||||
context->flush();
|
||||
#if GR_GPU_STATS
|
||||
REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 1);
|
||||
@ -136,7 +136,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) {
|
||||
context->resetGpuStats();
|
||||
// This one should fail.
|
||||
batch.reset(new Batch(attribCnt+1));
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, batch.get());
|
||||
renderTargetContext->priv().testingOnly_drawBatch(grPaint, GrAAType::kNone, batch.get());
|
||||
context->flush();
|
||||
#if GR_GPU_STATS
|
||||
REPORTER_ASSERT(reporter, context->getGpu()->stats()->numDraws() == 0);
|
||||
|
@ -136,13 +136,13 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SRGBMipMaps, reporter, ctxInfo) {
|
||||
|
||||
// 1) Draw texture to S32 surface (should generate/use sRGB mips)
|
||||
paint.setGammaCorrect(true);
|
||||
s32RenderTargetContext->drawRect(noClip, paint, SkMatrix::I(), rect);
|
||||
s32RenderTargetContext->drawRect(noClip, paint, GrAA::kNo, SkMatrix::I(), rect);
|
||||
read_and_check_pixels(reporter, s32RenderTargetContext->asTexture().get(), expectedSRGB, error,
|
||||
"first render of sRGB");
|
||||
|
||||
// 2) Draw texture to L32 surface (should generate/use linear mips)
|
||||
paint.setGammaCorrect(false);
|
||||
l32RenderTargetContext->drawRect(noClip, paint, SkMatrix::I(), rect);
|
||||
l32RenderTargetContext->drawRect(noClip, paint, GrAA::kNo, SkMatrix::I(), rect);
|
||||
|
||||
// Right now, this test only runs on GL (because Vulkan doesn't support legacy mip-mapping
|
||||
// skbug.com/5048). On GL, we may not have sRGB decode support. In that case, rendering sRGB
|
||||
@ -162,7 +162,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SRGBMipMaps, reporter, ctxInfo) {
|
||||
|
||||
// 3) Go back to sRGB
|
||||
paint.setGammaCorrect(true);
|
||||
s32RenderTargetContext->drawRect(noClip, paint, SkMatrix::I(), rect);
|
||||
s32RenderTargetContext->drawRect(noClip, paint, GrAA::kNo, SkMatrix::I(), rect);
|
||||
read_and_check_pixels(reporter, s32RenderTargetContext->asTexture().get(), expectedSRGB, error,
|
||||
"re-render as sRGB");
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ static void test_path(GrRenderTargetContext* renderTargetContext, GrResourceProv
|
||||
args.fViewMatrix = &SkMatrix::I();
|
||||
GrShape shape(path, style);
|
||||
args.fShape = &shape;
|
||||
args.fAntiAlias = false;
|
||||
args.fAAType = GrAAType::kNone;
|
||||
tess.drawPath(args);
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ void SkGpuDevice::drawTexture(GrTexture* tex, const SkRect& dst, const SkPaint&
|
||||
|
||||
grPaint.addColorTextureProcessor(tex, nullptr, textureMat);
|
||||
|
||||
fRenderTargetContext->drawRect(GrNoClip(), grPaint, mat, dst);
|
||||
fRenderTargetContext->drawRect(GrNoClip(), grPaint, GrAA::kNo, mat, dst);
|
||||
}
|
||||
|
||||
|
||||
@ -244,6 +244,7 @@ void GrResourceCache::changeTimestamp(uint32_t newTimestamp) { fTimestamp = newT
|
||||
#define RETURN_IF_ABANDONED if (fRenderTargetContext->fDrawingManager->wasAbandoned()) { return; }
|
||||
|
||||
void GrRenderTargetContextPriv::testingOnly_drawBatch(const GrPaint& paint,
|
||||
GrAAType aaType,
|
||||
GrDrawOp* batch,
|
||||
const GrUserStencilSettings* uss,
|
||||
bool snapToCenters) {
|
||||
@ -253,7 +254,7 @@ void GrRenderTargetContextPriv::testingOnly_drawBatch(const GrPaint& paint,
|
||||
GR_AUDIT_TRAIL_AUTO_FRAME(fRenderTargetContext->fAuditTrail,
|
||||
"GrRenderTargetContext::testingOnly_drawBatch");
|
||||
|
||||
GrPipelineBuilder pipelineBuilder(paint, fRenderTargetContext->mustUseHWAA(paint));
|
||||
GrPipelineBuilder pipelineBuilder(paint, aaType);
|
||||
if (uss) {
|
||||
pipelineBuilder.setUserStencil(uss);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user