canvas->save();
#if 1
if (fDoPath) {
- canvas->clipPath(fClipPath, SkCanvas::kReplace_Op, fDoAA);
+ canvas->clipPath(fClipPath, kReplace_SkClipOp, fDoAA);
} else {
- canvas->clipRect(fClipRect, SkCanvas::kReplace_Op, fDoAA);
+ canvas->clipRect(fClipRect, kReplace_SkClipOp, fDoAA);
}
canvas->drawRect(fDrawRect, paint);
SkASSERT(path.isConvex());
canvas->clipPath(path,
- 0 == depth ? SkCanvas::kReplace_Op :
- SkCanvas::kIntersect_Op,
+ 0 == depth ? kReplace_SkClipOp : kIntersect_SkClipOp,
fDoAA);
if (kNestingDepth == depth) {
fuzz->next(&bl);
fuzz->next(&a, &b, &c, &d);
r = SkRect::MakeXYWH(a, b, c, d);
- cnv->clipRect(r, SkCanvas::kIntersect_Op, bl);
+ cnv->clipRect(r, kIntersect_SkClipOp, bl);
}
static void fuzz_drawPath(Fuzz* fuzz) {
bool bl;
fuzz->next(&bl);
- cnv->clipPath(path, SkCanvas::kIntersect_Op, bl);
+ cnv->clipPath(path, kIntersect_SkClipOp, bl);
}
static void fuzz_drawBitmap(Fuzz* fuzz) {
SkRect clipRect2 = SkRect::MakeLTRB(8, 8, 288, 288);
SkRRect clipRRect = SkRRect::MakeOval(clipRect2);
- canvas->clipRRect(clipRRect, SkCanvas::kDifference_Op, true);
+ canvas->clipRRect(clipRRect, kDifference_SkClipOp, true);
SkRect r = SkRect::MakeLTRB(4, 4, 292, 292);
SkRRect rr = SkRRect::MakeOval(r);
}
void onDraw(SkCanvas* canvas) override {
- SkCanvas::ClipOp ops[] = {
- SkCanvas::kDifference_Op,
- SkCanvas::kIntersect_Op,
- SkCanvas::kUnion_Op,
- SkCanvas::kXOR_Op,
- SkCanvas::kReverseDifference_Op,
- SkCanvas::kReplace_Op,
+ const SkClipOp ops[] = {
+ kDifference_SkClipOp,
+ kIntersect_SkClipOp,
+ kUnion_SkClipOp,
+ kXOR_SkClipOp,
+ kReverseDifference_SkClipOp,
+ kReplace_SkClipOp,
};
SkRect rect = SkRect::MakeLTRB(fX1 - fR, fY - fR, fX2 + fR, fY + fR);
paint.setTextSize(SkIntToScalar(20));
constexpr struct {
- SkCanvas::ClipOp fOp;
+ SkClipOp fOp;
const char* fName;
} gOps[] = { //extra spaces in names for measureText
- {SkCanvas::kIntersect_Op, "Isect "},
- {SkCanvas::kDifference_Op, "Diff " },
- {SkCanvas::kUnion_Op, "Union "},
- {SkCanvas::kXOR_Op, "Xor " },
- {SkCanvas::kReverseDifference_Op, "RDiff "}
+ {kIntersect_SkClipOp, "Isect "},
+ {kDifference_SkClipOp, "Diff " },
+ {kUnion_SkClipOp, "Union "},
+ {kXOR_SkClipOp, "Xor " },
+ {kReverseDifference_SkClipOp, "RDiff "}
};
canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
fPaths[4].addRoundRect(fRects[4], 5, 5);
fRectColors[4] = SK_ColorCYAN;
- SkCanvas::ClipOp ops[] = {
- SkCanvas::kDifference_Op,
- SkCanvas::kIntersect_Op,
- SkCanvas::kUnion_Op,
- SkCanvas::kXOR_Op,
- SkCanvas::kReverseDifference_Op,
- SkCanvas::kReplace_Op,
+ const SkClipOp ops[] = {
+ kDifference_SkClipOp,
+ kIntersect_SkClipOp,
+ kUnion_SkClipOp,
+ kXOR_SkClipOp,
+ kReverseDifference_SkClipOp,
+ kReplace_SkClipOp,
};
SkRandom r;
SkRRect fRRects[5];
SkPath fPaths[5];
SkColor fRectColors[5];
- SkCanvas::ClipOp fOps[kRows * kCols][5];
+ SkClipOp fOps[kRows * kCols][5];
SkScalar fWidth;
SkScalar fHeight;
SkScalar fTotalWidth;
paint.setTextSize(SkIntToScalar(20));
constexpr struct {
- SkCanvas::ClipOp fOp;
- const char* fName;
+ SkClipOp fOp;
+ const char* fName;
} gOps[] = {
- {SkCanvas::kIntersect_Op, "I"},
- {SkCanvas::kDifference_Op, "D" },
- {SkCanvas::kUnion_Op, "U"},
- {SkCanvas::kXOR_Op, "X" },
- {SkCanvas::kReverseDifference_Op, "R"}
+ {kIntersect_SkClipOp, "I"},
+ {kDifference_SkClipOp, "D" },
+ {kUnion_SkClipOp, "U"},
+ {kXOR_SkClipOp, "X" },
+ {kReverseDifference_SkClipOp, "R"}
};
canvas->translate(SkIntToScalar(20), SkIntToScalar(20));
SkRect rect = SkRect::MakeWH(WIDTH, HEIGHT);
tileCanvas->saveLayer(&rect, &blurPaint);
SkRRect rrect = SkRRect::MakeRectXY(rect.makeInset(20, 20), 25, 25);
- tileCanvas->clipRRect(rrect, SkCanvas::kDifference_Op, true);
+ tileCanvas->clipRRect(rrect, kDifference_SkClipOp, true);
SkPaint paint;
tileCanvas->drawRect(rect, paint);
tileCanvas->restore();
canvas->save();
}
canvas->translate(x, y);
- clip->setOnCanvas(canvas, SkCanvas::kIntersect_Op, SkToBool(aa));
+ clip->setOnCanvas(canvas, kIntersect_SkClipOp, SkToBool(aa));
canvas->drawBitmap(fBmp, 0, 0);
canvas->restore();
x += fBmp.width() + kMargin;
SkPath closedClipPath;
clip->asClosedPath(&closedClipPath);
canvas->drawPath(closedClipPath, clipOutlinePaint);
- clip->setOnCanvas(canvas, SkCanvas::kIntersect_Op, SkToBool(aa));
+ clip->setOnCanvas(canvas, kIntersect_SkClipOp, SkToBool(aa));
canvas->scale(1.f, 1.8f);
canvas->drawText(kTxt, SK_ARRAY_COUNT(kTxt)-1,
0, 1.5f * txtPaint.getTextSize(),
Clip () : fClipType(kNone_ClipType) {}
- void setOnCanvas(SkCanvas* canvas, SkCanvas::ClipOp op, bool aa) const {
+ void setOnCanvas(SkCanvas* canvas, SkClipOp op, bool aa) const {
switch (fClipType) {
case kPath_ClipType:
canvas->clipPath(fPath, op, aa);
outerClip.offset(x, y);
canvas->save();
- canvas->clipRect(outerClip, SkCanvas::kIntersect_Op);
- canvas->clipRect(innerClip, SkCanvas::kDifference_Op);
+ canvas->clipRect(outerClip, kIntersect_SkClipOp);
+ canvas->clipRect(innerClip, kDifference_SkClipOp);
SkPaint paint;
paint.setAntiAlias(true);
rect.offset(x, y);
canvas->save();
- canvas->clipRect(outerClip, SkCanvas::kIntersect_Op);
- canvas->clipRect(rect, SkCanvas::kDifference_Op);
+ canvas->clipRect(outerClip, kIntersect_SkClipOp);
+ canvas->clipRect(rect, kDifference_SkClipOp);
// move the rect to where we want the blur to appear
rect.offset(gBlurOffsets[i]);
paint.setLooper(create4Looper(-kOffsetToOutsideClip-kHalfSquareSize, 0));
canvas->save();
- canvas->clipRect(outerClip, SkCanvas::kIntersect_Op);
- canvas->clipRect(rect, SkCanvas::kDifference_Op);
+ canvas->clipRect(outerClip, kIntersect_SkClipOp);
+ canvas->clipRect(rect, kDifference_SkClipOp);
rect.offset(SkIntToScalar(kOffsetToOutsideClip+kHalfSquareSize), 0);
canvas->drawRect(rect, paint);
INHERITED::setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD));
}
- void buildRgn(SkAAClip* clip, SkCanvas::ClipOp op) {
+ void buildRgn(SkAAClip* clip, SkClipOp op) {
clip->setPath(fBasePath, nullptr, true);
SkAAClip clip2;
canvas->drawRect(fRect, paint);
}
- void drawRgnOped(SkCanvas* canvas, SkCanvas::ClipOp op, SkColor color) {
+ void drawRgnOped(SkCanvas* canvas, SkClipOp op, SkColor color) {
SkAAClip clip;
paint_rgn(canvas, clip, paint);
}
- void drawPathsOped(SkCanvas* canvas, SkCanvas::ClipOp op, SkColor color) {
+ void drawPathsOped(SkCanvas* canvas, SkClipOp op, SkColor color) {
this->drawOrig(canvas);
const struct {
SkColor fColor;
const char* fName;
- SkCanvas::ClipOp fOp;
+ SkClipOp fOp;
} gOps[] = {
- { SK_ColorBLACK, "Difference", SkCanvas::kDifference_Op },
- { SK_ColorRED, "Intersect", SkCanvas::kIntersect_Op },
- { sk_tool_utils::color_to_565(0xFF008800), "Union", SkCanvas::kUnion_Op },
- { SK_ColorGREEN, "Rev Diff", SkCanvas::kReverseDifference_Op },
- { SK_ColorYELLOW, "Replace", SkCanvas::kReplace_Op },
- { SK_ColorBLUE, "XOR", SkCanvas::kXOR_Op },
+ { SK_ColorBLACK, "Difference", kDifference_SkClipOp },
+ { SK_ColorRED, "Intersect", kIntersect_SkClipOp },
+ { sk_tool_utils::color_to_565(0xFF008800), "Union", kUnion_SkClipOp },
+ { SK_ColorGREEN, "Rev Diff", kReverseDifference_SkClipOp },
+ { SK_ColorYELLOW, "Replace", kReplace_SkClipOp },
+ { SK_ColorBLUE, "XOR", kXOR_SkClipOp },
};
SkPaint textPaint;
SkClipStack stack;
stack.clipRect(SkRect::MakeXYWH(370.75, 80.25, 149, 100), SkMatrix::I(),
- SkCanvas::kDifference_Op, false);
+ kDifference_SkClipOp, false);
stack.clipRect(SkRect::MakeXYWH(80.25, 420.75, 150, 100), SkMatrix::I(),
- SkCanvas::kDifference_Op, true);
+ kDifference_SkClipOp, true);
stack.clipRRect(SkRRect::MakeRectXY(SkRect::MakeXYWH(200, 200, 200, 200), 60, 45),
- SkMatrix::I(), SkCanvas::kDifference_Op, true);
+ SkMatrix::I(), kDifference_SkClipOp, true);
SkRRect nine;
nine.setNinePatch(SkRect::MakeXYWH(550 - 30.25 - 100, 370.75, 100, 150), 12, 35, 23, 20);
- stack.clipRRect(nine, SkMatrix::I(), SkCanvas::kDifference_Op, true);
+ stack.clipRRect(nine, SkMatrix::I(), kDifference_SkClipOp, true);
SkRRect complx;
SkVector complxRadii[4] = {{6, 4}, {8, 12}, {16, 24}, {48, 32}};
complx.setRectRadii(SkRect::MakeXYWH(80.25, 80.75, 100, 149), complxRadii);
- stack.clipRRect(complx, SkMatrix::I(), SkCanvas::kDifference_Op, false);
+ stack.clipRRect(complx, SkMatrix::I(), kDifference_SkClipOp, false);
this->onCoverClipStack(stack, canvas);
*/
class ReplayClipStackVisitor final : public SkCanvasClipVisitor {
public:
- typedef SkCanvas::ClipOp Op;
+ typedef SkClipOp Op;
ReplayClipStackVisitor(SkCanvas* canvas) : fCanvas(canvas) {}
void clipRect(const SkRect& r, Op op, bool aa) override { fCanvas->clipRect(r, op, aa); }
void clipRRect(const SkRRect& rr, Op op, bool aa) override { fCanvas->clipRRect(rr, op, aa); }
class SkSurface_Base;
class SkTextBlob;
-//#define SK_SUPPORT_LEGACY_CLIP_REGIONOPS
-
/** \class SkCanvas
A Canvas encapsulates all of the state about drawing into a device (bitmap).
};
public:
-#ifdef SK_SUPPORT_LEGACY_CLIP_REGIONOPS
- typedef SkRegion::Op ClipOp;
-
- static const ClipOp kDifference_Op = SkRegion::kDifference_Op;
- static const ClipOp kIntersect_Op = SkRegion::kIntersect_Op;
- static const ClipOp kUnion_Op = SkRegion::kUnion_Op;
- static const ClipOp kXOR_Op = SkRegion::kXOR_Op;
- static const ClipOp kReverseDifference_Op = SkRegion::kReverseDifference_Op;
- static const ClipOp kReplace_Op = SkRegion::kReplace_Op;
-#else
- typedef SkClipOp ClipOp;
-
- static const ClipOp kDifference_Op = kDifference_SkClipOp;
- static const ClipOp kIntersect_Op = kIntersect_SkClipOp;
- static const ClipOp kUnion_Op = kUnion_SkClipOp;
- static const ClipOp kXOR_Op = kXOR_SkClipOp;
- static const ClipOp kReverseDifference_Op = kReverseDifference_SkClipOp;
- static const ClipOp kReplace_Op = kReplace_SkClipOp;
-#endif
/**
* Attempt to allocate raster canvas, matching the ImageInfo, that will draw directly into the
* specified pixels. To access the pixels after drawing to them, the caller should call
* @param op The region op to apply to the current clip
* @param doAntiAlias true if the clip should be antialiased
*/
- void clipRect(const SkRect& rect, ClipOp, bool doAntiAlias);
- void clipRect(const SkRect& rect, ClipOp op) {
+ void clipRect(const SkRect& rect, SkClipOp, bool doAntiAlias);
+ void clipRect(const SkRect& rect, SkClipOp op) {
this->clipRect(rect, op, false);
}
void clipRect(const SkRect& rect, bool doAntiAlias = false) {
- this->clipRect(rect, kIntersect_Op, doAntiAlias);
+ this->clipRect(rect, kIntersect_SkClipOp, doAntiAlias);
}
/**
* @param op The region op to apply to the current clip
* @param doAntiAlias true if the clip should be antialiased
*/
- void clipRRect(const SkRRect& rrect, ClipOp op, bool doAntiAlias);
- void clipRRect(const SkRRect& rrect, ClipOp op) {
+ void clipRRect(const SkRRect& rrect, SkClipOp op, bool doAntiAlias);
+ void clipRRect(const SkRRect& rrect, SkClipOp op) {
this->clipRRect(rrect, op, false);
}
void clipRRect(const SkRRect& rrect, bool doAntiAlias = false) {
- this->clipRRect(rrect, kIntersect_Op, doAntiAlias);
+ this->clipRRect(rrect, kIntersect_SkClipOp, doAntiAlias);
}
/**
* @param op The region op to apply to the current clip
* @param doAntiAlias true if the clip should be antialiased
*/
- void clipPath(const SkPath& path, ClipOp op, bool doAntiAlias);
- void clipPath(const SkPath& path, ClipOp op) {
+ void clipPath(const SkPath& path, SkClipOp op, bool doAntiAlias);
+ void clipPath(const SkPath& path, SkClipOp op) {
this->clipPath(path, op, false);
}
void clipPath(const SkPath& path, bool doAntiAlias = false) {
- this->clipPath(path, kIntersect_Op, doAntiAlias);
+ this->clipPath(path, kIntersect_SkClipOp, doAntiAlias);
}
/** EXPERIMENTAL -- only used for testing
@param deviceRgn The region to apply to the current clip
@param op The region op to apply to the current clip
*/
- void clipRegion(const SkRegion& deviceRgn, ClipOp op = kIntersect_Op);
+ void clipRegion(const SkRegion& deviceRgn, SkClipOp op = kIntersect_SkClipOp);
/** Return true if the specified rectangle, after being transformed by the
current matrix, would lie completely outside of the current clip. Call
kSoft_ClipEdgeStyle
};
- virtual void onClipRect(const SkRect& rect, ClipOp, ClipEdgeStyle);
- virtual void onClipRRect(const SkRRect& rrect, ClipOp, ClipEdgeStyle);
- virtual void onClipPath(const SkPath& path, ClipOp, ClipEdgeStyle);
- virtual void onClipRegion(const SkRegion& deviceRgn, ClipOp);
+ virtual void onClipRect(const SkRect& rect, SkClipOp, ClipEdgeStyle);
+ virtual void onClipRRect(const SkRRect& rrect, SkClipOp, ClipEdgeStyle);
+ virtual void onClipPath(const SkPath& path, SkClipOp, ClipEdgeStyle);
+ virtual void onClipRegion(const SkRegion& deviceRgn, SkClipOp);
virtual void onDiscard();
class SkCanvasClipVisitor {
public:
virtual ~SkCanvasClipVisitor();
- virtual void clipRect(const SkRect&, SkCanvas::ClipOp, bool antialias) = 0;
- virtual void clipRRect(const SkRRect&, SkCanvas::ClipOp, bool antialias) = 0;
- virtual void clipPath(const SkPath&, SkCanvas::ClipOp, bool antialias) = 0;
+ virtual void clipRect(const SkRect&, SkClipOp, bool antialias) = 0;
+ virtual void clipRRect(const SkRRect&, SkClipOp, bool antialias) = 0;
+ virtual void clipPath(const SkPath&, SkClipOp, bool antialias) = 0;
};
#endif
static const int kTypeCnt = kLastType + 1;
Element() {
- this->initCommon(0, SkCanvas::kReplace_Op, false);
+ this->initCommon(0, kReplace_SkClipOp, false);
this->setEmpty();
}
Element(const Element&);
- Element(const SkRect& rect, SkCanvas::ClipOp op, bool doAA) {
+ Element(const SkRect& rect, SkClipOp op, bool doAA) {
this->initRect(0, rect, op, doAA);
}
- Element(const SkRRect& rrect, SkCanvas::ClipOp op, bool doAA) {
+ Element(const SkRRect& rrect, SkClipOp op, bool doAA) {
this->initRRect(0, rrect, op, doAA);
}
- Element(const SkPath& path, SkCanvas::ClipOp op, bool doAA) {
+ Element(const SkPath& path, SkClipOp op, bool doAA) {
this->initPath(0, path, op, doAA);
}
}
//!< Call if getType() is not kEmpty to get the set operation used to combine this element.
- SkCanvas::ClipOp getOp() const { return fOp; }
+ SkClipOp getOp() const { return fOp; }
//!< Call to get the element as a path, regardless of its type.
void asPath(SkPath* path) const;
void invertShapeFillType();
//!< Sets the set operation represented by the element.
- void setOp(SkCanvas::ClipOp op) { fOp = op; }
+ void setOp(SkClipOp op) { fOp = op; }
/** The GenID can be used by clip stack clients to cache representations of the clip. The
ID corresponds to the set of clip elements up to and including this element within the
SkTLazy<SkPath> fPath;
SkRRect fRRect;
int fSaveCount; // save count of stack when this element was added.
- SkCanvas::ClipOp fOp;
+ SkClipOp fOp;
Type fType;
bool fDoAA;
int fGenID;
Element(int saveCount) {
- this->initCommon(saveCount, SkCanvas::kReplace_Op, false);
+ this->initCommon(saveCount, kReplace_SkClipOp, false);
this->setEmpty();
}
- Element(int saveCount, const SkRRect& rrect, SkCanvas::ClipOp op, bool doAA) {
+ Element(int saveCount, const SkRRect& rrect, SkClipOp op, bool doAA) {
this->initRRect(saveCount, rrect, op, doAA);
}
- Element(int saveCount, const SkRect& rect, SkCanvas::ClipOp op, bool doAA) {
+ Element(int saveCount, const SkRect& rect, SkClipOp op, bool doAA) {
this->initRect(saveCount, rect, op, doAA);
}
- Element(int saveCount, const SkPath& path, SkCanvas::ClipOp op, bool doAA) {
+ Element(int saveCount, const SkPath& path, SkClipOp op, bool doAA) {
this->initPath(saveCount, path, op, doAA);
}
- void initCommon(int saveCount, SkCanvas::ClipOp op, bool doAA) {
+ void initCommon(int saveCount, SkClipOp op, bool doAA) {
fSaveCount = saveCount;
fOp = op;
fDoAA = doAA;
fGenID = kInvalidGenID;
}
- void initRect(int saveCount, const SkRect& rect, SkCanvas::ClipOp op, bool doAA) {
+ void initRect(int saveCount, const SkRect& rect, SkClipOp op, bool doAA) {
fRRect.setRect(rect);
fType = kRect_Type;
this->initCommon(saveCount, op, doAA);
}
- void initRRect(int saveCount, const SkRRect& rrect, SkCanvas::ClipOp op, bool doAA) {
+ void initRRect(int saveCount, const SkRRect& rrect, SkClipOp op, bool doAA) {
SkRRect::Type type = rrect.getType();
fRRect = rrect;
if (SkRRect::kRect_Type == type || SkRRect::kEmpty_Type == type) {
this->initCommon(saveCount, op, doAA);
}
- void initPath(int saveCount, const SkPath& path, SkCanvas::ClipOp op, bool doAA);
+ void initPath(int saveCount, const SkPath& path, SkClipOp op, bool doAA);
void setEmpty();
// All Element methods below are only used within SkClipStack.cpp
inline void checkEmpty() const;
- inline bool canBeIntersectedInPlace(int saveCount, SkCanvas::ClipOp op) const;
+ inline bool canBeIntersectedInPlace(int saveCount, SkClipOp op) const;
/* This method checks to see if two rect clips can be safely merged into one. The issue here
is that to be strictly correct all the edges of the resulting rect must have the same
anti-aliasing. */
*/
bool asPath(SkPath* path) const;
- void clipDevRect(const SkIRect& ir, SkCanvas::ClipOp op) {
+ void clipDevRect(const SkIRect& ir, SkClipOp op) {
SkRect r;
r.set(ir);
this->clipRect(r, SkMatrix::I(), op, false);
}
- void clipRect(const SkRect&, const SkMatrix& matrix, SkCanvas::ClipOp, bool doAA);
- void clipRRect(const SkRRect&, const SkMatrix& matrix, SkCanvas::ClipOp, bool doAA);
- void clipPath(const SkPath&, const SkMatrix& matrix, SkCanvas::ClipOp, bool doAA);
+ void clipRect(const SkRect&, const SkMatrix& matrix, SkClipOp, bool doAA);
+ void clipRRect(const SkRRect&, const SkMatrix& matrix, SkClipOp, bool doAA);
+ void clipPath(const SkPath&, const SkMatrix& matrix, SkClipOp, bool doAA);
// An optimized version of clipDevRect(emptyRect, kIntersect, ...)
void clipEmpty();
* Moves the iterator to the topmost element with the specified RegionOp and returns that
* element. If no clip element with that op is found, the first element is returned.
*/
- const Element* skipToTopmost(SkCanvas::ClipOp op);
+ const Element* skipToTopmost(SkClipOp op);
/**
* Restarts the iterator on a clip stack.
/**
* Process an explicit clipPath op.
*/
- void analyzeClipPath(const SkPath&, SkCanvas::ClipOp, bool doAntiAlias);
+ void analyzeClipPath(const SkPath&, SkClipOp, bool doAntiAlias);
/**
* Reset all accumulated stats.
struct ClipOpAndAA {
ClipOpAndAA() {}
- ClipOpAndAA(SkCanvas::ClipOp op, bool aa) : op(op), aa(aa) {}
- SkCanvas::ClipOp op : 31; // This really only needs to be 3, but there's no win today to do so.
+ ClipOpAndAA(SkClipOp op, bool aa) : op(op), aa(aa) {}
+ SkClipOp op : 31; // This really only needs to be 3, but there's no win today to do so.
unsigned aa : 1; // MSVC won't pack an enum with an bool, so we call this an unsigned.
};
static_assert(sizeof(ClipOpAndAA) == 4, "ClipOpAndAASize");
RECORD(ClipRegion, 0,
SkIRect devBounds;
SkRegion region;
- SkCanvas::ClipOp op);
+ SkClipOp op);
// While not strictly required, if you have an SkPaint, it's fastest to put it first.
RECORD(DrawArc, kDraw_Tag|kHasPaint_Tag,
const uint16_t indices[], int indexCount,
const SkPaint&) override;
- void onClipRect(const SkRect&, ClipOp, ClipEdgeStyle) override;
- void onClipRRect(const SkRRect&, ClipOp, ClipEdgeStyle) override;
- void onClipPath(const SkPath&, ClipOp, ClipEdgeStyle) override;
- void onClipRegion(const SkRegion&, ClipOp) override;
+ void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
+ void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
+ void onClipPath(const SkPath&, SkClipOp, ClipEdgeStyle) override;
+ void onClipRegion(const SkRegion&, SkClipOp) override;
void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
void onDrawAnnotation(const SkRect&, const char key[], SkData* value) override;
const uint16_t indices[], int indexCount,
const SkPaint&) override;
- void onClipRect(const SkRect&, ClipOp, ClipEdgeStyle) override;
- void onClipRRect(const SkRRect&, ClipOp, ClipEdgeStyle) override;
- void onClipPath(const SkPath&, ClipOp, ClipEdgeStyle) override;
- void onClipRegion(const SkRegion&, ClipOp) override;
+ void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
+ void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
+ void onClipPath(const SkPath&, SkClipOp, ClipEdgeStyle) override;
+ void onClipRegion(const SkRegion&, SkClipOp) override;
void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
const uint16_t indices[], int indexCount,
const SkPaint&) override;
- void onClipRect(const SkRect&, ClipOp, ClipEdgeStyle) override;
- void onClipRRect(const SkRRect&, ClipOp, ClipEdgeStyle) override;
- void onClipPath(const SkPath&, ClipOp, ClipEdgeStyle) override;
- void onClipRegion(const SkRegion&, ClipOp) override;
+ void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
+ void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
+ void onClipPath(const SkPath&, SkClipOp, ClipEdgeStyle) override;
+ void onClipRegion(const SkRegion&, SkClipOp) override;
void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
void onDrawAnnotation(const SkRect&, const char[], SkData*) override;
if (fUseClip) {
canvas->drawColor(0xFFFF88FF);
- canvas->clipPath(fClipPath, SkCanvas::kIntersect_Op, true);
+ canvas->clipPath(fClipPath, kIntersect_SkClipOp, true);
}
// Install a flags filter proxy canvas if needed
canvas->save();
for (size_t i = 0; i < SK_ARRAY_COUNT(gProc); ++i) {
canvas->save();
- canvas->clipPath(clipPath, SkCanvas::kIntersect_Op, SkToBool(aa));
+ canvas->clipPath(clipPath, kIntersect_SkClipOp, SkToBool(aa));
// canvas->drawColor(SK_ColorWHITE);
gProc[i](canvas, SkToBool(aa));
canvas->restore();
canvas->drawPath(clipB, paint);
static const struct {
- SkCanvas::ClipOp fOp;
- const char* fName;
+ SkClipOp fOp;
+ const char* fName;
} gOps[] = { //extra spaces in names for measureText
- {SkCanvas::kIntersect_Op, "Isect "},
- {SkCanvas::kDifference_Op, "Diff " },
- {SkCanvas::kUnion_Op, "Union "},
- {SkCanvas::kXOR_Op, "Xor " },
- {SkCanvas::kReverseDifference_Op, "RDiff "}
+ {kIntersect_SkClipOp, "Isect "},
+ {kDifference_SkClipOp, "Diff " },
+ {kUnion_SkClipOp, "Union "},
+ {kXOR_SkClipOp, "Xor " },
+ {kReverseDifference_SkClipOp, "RDiff "}
};
canvas->translate(0, SkIntToScalar(40));
fMinSurface->getCanvas()->save();
SkRect r = fClipRect;
r.inset(SK_Scalar1/3, SK_Scalar1/3);
- fMinSurface->getCanvas()->clipRect(r, SkCanvas::kIntersect_Op, true);
+ fMinSurface->getCanvas()->clipRect(r, kIntersect_SkClipOp, true);
}
fMinSurface->getCanvas()->drawLine(pts[0].fX, pts[0].fY, pts[1].fX, pts[1].fY, paint);
if (fUseClip) {
SkRect r = { 100, 100, 356, 356 };
SkPath clipPath;
clipPath.addRoundRect(r, SkIntToScalar(5), SkIntToScalar(5));
- canvas->clipPath(clipPath, SkCanvas::kIntersect_Op, SkToBool(1));
+ canvas->clipPath(clipPath, kIntersect_SkClipOp, true);
text = "Scaled = 0";
}
canvas->drawBitmap( fBM, 100, 100, &paint );
m.postTranslate(fCenter.x(), fCenter.y());
path.transform(m);
- canvas->clipPath(path, SkCanvas::kIntersect_Op, true);
+ canvas->clipPath(path, kIntersect_SkClipOp, true);
const SkRect bounds = path.getBounds();
SkPaint paint;
bool next() {
if (fMultiDeviceCS && fDevice) {
// remove the previous device's bounds
- fMultiDeviceCS->clipDevRect(compute_device_bounds(fDevice), SkCanvas::kDifference_Op);
+ fMultiDeviceCS->clipDevRect(compute_device_bounds(fDevice), kDifference_SkClipOp);
}
// skip over recs with empty clips
if (BoundsAffectsClip(saveLayerFlags)) {
// Simplify the current clips since they will be applied properly during restore()
- fClipStack->clipDevRect(ir, kReplace_Op);
+ fClipStack->clipDevRect(ir, kReplace_SkClipOp);
fMCRec->fRasterClip.setRect(ir);
fDeviceClipBounds = qr_clip_bounds(ir);
}
//////////////////////////////////////////////////////////////////////////////
-void SkCanvas::clipRect(const SkRect& rect, ClipOp op, bool doAA) {
+void SkCanvas::clipRect(const SkRect& rect, SkClipOp op, bool doAA) {
this->checkForDeferredSave();
ClipEdgeStyle edgeStyle = doAA ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle;
this->onClipRect(rect, op, edgeStyle);
}
-void SkCanvas::onClipRect(const SkRect& rect, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkCanvas::onClipRect(const SkRect& rect, SkClipOp op, ClipEdgeStyle edgeStyle) {
const bool isAA = kSoft_ClipEdgeStyle == edgeStyle;
AutoValidateClip avc(this);
fClipStack->clipRect(rect, fMCRec->fMatrix, op, isAA);
fDeviceClipBounds = qr_clip_bounds(fMCRec->fRasterClip.getBounds());
}
-void SkCanvas::clipRRect(const SkRRect& rrect, ClipOp op, bool doAA) {
+void SkCanvas::clipRRect(const SkRRect& rrect, SkClipOp op, bool doAA) {
this->checkForDeferredSave();
ClipEdgeStyle edgeStyle = doAA ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle;
if (rrect.isRect()) {
}
}
-void SkCanvas::onClipRRect(const SkRRect& rrect, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkCanvas::onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle edgeStyle) {
AutoValidateClip avc(this);
fDeviceCMDirty = true;
return;
}
-void SkCanvas::clipPath(const SkPath& path, ClipOp op, bool doAA) {
+void SkCanvas::clipPath(const SkPath& path, SkClipOp op, bool doAA) {
this->checkForDeferredSave();
ClipEdgeStyle edgeStyle = doAA ? kSoft_ClipEdgeStyle : kHard_ClipEdgeStyle;
this->onClipPath(path, op, edgeStyle);
}
-void SkCanvas::onClipPath(const SkPath& path, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkCanvas::onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle edgeStyle) {
AutoValidateClip avc(this);
fDeviceCMDirty = true;
isAA = getClipStack()->asPath(&tempPath);
rasterClipPath = &tempPath;
matrix = &SkMatrix::I();
- op = kReplace_Op;
+ op = kReplace_SkClipOp;
}
fMCRec->fRasterClip.op(*rasterClipPath, *matrix, this->getTopLayerBounds(), (SkRegion::Op)op,
isAA);
fDeviceClipBounds = qr_clip_bounds(fMCRec->fRasterClip.getBounds());
}
-void SkCanvas::clipRegion(const SkRegion& rgn, ClipOp op) {
+void SkCanvas::clipRegion(const SkRegion& rgn, SkClipOp op) {
this->checkForDeferredSave();
this->onClipRegion(rgn, op);
}
-void SkCanvas::onClipRegion(const SkRegion& rgn, ClipOp op) {
+void SkCanvas::onClipRegion(const SkRegion& rgn, SkClipOp op) {
AutoValidateClip avc(this);
fDeviceCMDirty = true;
///////////////////////////////////////////////////////////////////////////////
-const SkCanvas::ClipOp SkCanvas::kDifference_Op;
-const SkCanvas::ClipOp SkCanvas::kIntersect_Op;
-const SkCanvas::ClipOp SkCanvas::kUnion_Op;
-const SkCanvas::ClipOp SkCanvas::kXOR_Op;
-const SkCanvas::ClipOp SkCanvas::kReverseDifference_Op;
-const SkCanvas::ClipOp SkCanvas::kReplace_Op;
-
static_assert((int)SkRegion::kDifference_Op == (int)kDifference_SkClipOp, "");
static_assert((int)SkRegion::kIntersect_Op == (int)kIntersect_SkClipOp, "");
static_assert((int)SkRegion::kUnion_Op == (int)kUnion_SkClipOp, "");
visitor->clipRect(this->getRect(), this->getOp(), this->isAA());
break;
case kEmpty_Type:
- visitor->clipRect(kEmptyRect, SkCanvas::kIntersect_Op, false);
+ visitor->clipRect(kEmptyRect, kIntersect_SkClipOp, false);
break;
}
}
}
}
-void SkClipStack::Element::initPath(int saveCount, const SkPath& path, SkCanvas::ClipOp op,
+void SkClipStack::Element::initPath(int saveCount, const SkPath& path, SkClipOp op,
bool doAA) {
if (!path.isInverseFillType()) {
SkRect r;
SkASSERT(!fPath.isValid());
}
-bool SkClipStack::Element::canBeIntersectedInPlace(int saveCount, SkCanvas::ClipOp op) const {
+bool SkClipStack::Element::canBeIntersectedInPlace(int saveCount, SkClipOp op) const {
if (kEmpty_Type == fType &&
- (SkCanvas::kDifference_Op == op || SkCanvas::kIntersect_Op == op)) {
+ (kDifference_SkClipOp == op || kIntersect_SkClipOp == op)) {
return true;
}
// Only clips within the same save/restore frame (as captured by
// the save count) can be merged
return fSaveCount == saveCount &&
- SkCanvas::kIntersect_Op == op &&
- (SkCanvas::kIntersect_Op == fOp || SkCanvas::kReplace_Op == fOp);
+ kIntersect_SkClipOp == op &&
+ (kIntersect_SkClipOp == fOp || kReplace_SkClipOp == fOp);
}
bool SkClipStack::Element::rectRectIntersectAllowed(const SkRect& newR, bool newAA) const {
fFiniteBound = this->getRect();
fFiniteBoundType = kNormal_BoundsType;
- if (SkCanvas::kReplace_Op == fOp ||
- (SkCanvas::kIntersect_Op == fOp && nullptr == prior) ||
- (SkCanvas::kIntersect_Op == fOp && prior->fIsIntersectionOfRects &&
+ if (kReplace_SkClipOp == fOp ||
+ (kIntersect_SkClipOp == fOp && nullptr == prior) ||
+ (kIntersect_SkClipOp == fOp && prior->fIsIntersectionOfRects &&
prior->rectRectIntersectAllowed(this->getRect(), fDoAA))) {
fIsIntersectionOfRects = true;
}
// Now integrate with clip with the prior clips
switch (fOp) {
- case SkCanvas::kDifference_Op:
+ case kDifference_SkClipOp:
this->combineBoundsDiff(combination, prevFinite);
break;
- case SkCanvas::kXOR_Op:
+ case kXOR_SkClipOp:
this->combineBoundsXOR(combination, prevFinite);
break;
- case SkCanvas::kUnion_Op:
+ case kUnion_SkClipOp:
this->combineBoundsUnion(combination, prevFinite);
break;
- case SkCanvas::kIntersect_Op:
+ case kIntersect_SkClipOp:
this->combineBoundsIntersection(combination, prevFinite);
break;
- case SkCanvas::kReverseDifference_Op:
+ case kReverseDifference_SkClipOp:
this->combineBoundsRevDiff(combination, prevFinite);
break;
- case SkCanvas::kReplace_Op:
+ case kReplace_SkClipOp:
// Replace just ignores everything prior
// The current clip's bound information is already filled in
// so nothing to do
break;
default:
- SkDebugf("SkCanvas::ClipOp error\n");
+ SkDebugf("SkClipOp error\n");
SkASSERT(0);
break;
}
Iter iter(*this, Iter::kTop_IterStart);
const Element* element = iter.prev();
while (element != nullptr) {
- if (SkCanvas::kIntersect_Op != element->getOp() && SkCanvas::kReplace_Op != element->getOp())
+ if (kIntersect_SkClipOp != element->getOp() && kReplace_SkClipOp != element->getOp())
return false;
if (element->isInverseFilled()) {
// Part of 'rect' could be trimmed off by the inverse-filled clip element
return false;
}
}
- if (SkCanvas::kReplace_Op == element->getOp()) {
+ if (kReplace_SkClipOp == element->getOp()) {
break;
}
element = iter.prev();
Iter iter(*this, Iter::kTop_IterStart);
const Element* element = iter.prev();
while (element != nullptr) {
- if (SkCanvas::kIntersect_Op != element->getOp() && SkCanvas::kReplace_Op != element->getOp())
+ if (kIntersect_SkClipOp != element->getOp() && kReplace_SkClipOp != element->getOp())
return false;
if (element->isInverseFilled()) {
// Part of 'rrect' could be trimmed off by the inverse-filled clip element
return false;
}
}
- if (SkCanvas::kReplace_Op == element->getOp()) {
+ if (kReplace_SkClipOp == element->getOp()) {
break;
}
element = iter.prev();
element->asPath(&operand);
}
- SkCanvas::ClipOp elementOp = element->getOp();
- if (elementOp == SkCanvas::kReplace_Op) {
+ SkClipOp elementOp = element->getOp();
+ if (elementOp == kReplace_SkClipOp) {
*path = operand;
} else {
Op(*path, operand, (SkPathOp)elementOp, path);
}
break;
}
- } else if (SkCanvas::kReplace_Op == element.getOp()) {
+ } else if (kReplace_SkClipOp == element.getOp()) {
this->restoreTo(fSaveCount - 1);
prior = (Element*) fDeque.back();
}
newElement->updateBoundAndGenID(prior);
}
-void SkClipStack::clipRRect(const SkRRect& rrect, const SkMatrix& matrix, SkCanvas::ClipOp op,
+void SkClipStack::clipRRect(const SkRRect& rrect, const SkMatrix& matrix, SkClipOp op,
bool doAA) {
SkRRect transformedRRect;
if (rrect.transform(matrix, &transformedRRect)) {
this->clipPath(path, matrix, op, doAA);
}
-void SkClipStack::clipRect(const SkRect& rect, const SkMatrix& matrix, SkCanvas::ClipOp op,
+void SkClipStack::clipRect(const SkRect& rect, const SkMatrix& matrix, SkClipOp op,
bool doAA) {
if (matrix.rectStaysRect()) {
SkRect devRect;
this->clipPath(path, matrix, op, doAA);
}
-void SkClipStack::clipPath(const SkPath& path, const SkMatrix& matrix, SkCanvas::ClipOp op,
+void SkClipStack::clipPath(const SkPath& path, const SkMatrix& matrix, SkClipOp op,
bool doAA) {
SkPath devPath;
path.transform(matrix, &devPath);
void SkClipStack::clipEmpty() {
Element* element = (Element*) fDeque.back();
- if (element && element->canBeIntersectedInPlace(fSaveCount, SkCanvas::kIntersect_Op)) {
+ if (element && element->canBeIntersectedInPlace(fSaveCount, kIntersect_SkClipOp)) {
element->setEmpty();
}
new (fDeque.push_back()) Element(fSaveCount);
return (const SkClipStack::Element*)fIter.prev();
}
-const SkClipStack::Element* SkClipStack::Iter::skipToTopmost(SkCanvas::ClipOp op) {
+const SkClipStack::Element* SkClipStack::Iter::skipToTopmost(SkClipOp op) {
if (nullptr == fStack) {
return nullptr;
back->getType() != SkClipStack::Element::kRRect_Type) {
return false;
}
- if (back->getOp() == SkCanvas::kReplace_Op) {
+ if (back->getOp() == kReplace_SkClipOp) {
*rrect = back->asRRect();
*aa = back->isAA();
return true;
}
- if (back->getOp() == SkCanvas::kIntersect_Op) {
+ if (back->getOp() == kIntersect_SkClipOp) {
SkRect backBounds;
if (!backBounds.intersect(bounds, back->asRRect().rect())) {
return false;
SkDeque::Iter iter(fDeque, SkDeque::Iter::kBack_IterStart);
SkAssertResult(static_cast<const Element*>(iter.prev()) == back);
while (const Element* prior = (const Element*)iter.prev()) {
- if ((prior->getOp() != SkCanvas::kIntersect_Op &&
- prior->getOp() != SkCanvas::kReplace_Op) ||
+ if ((prior->getOp() != kIntersect_SkClipOp &&
+ prior->getOp() != kReplace_SkClipOp) ||
!prior->contains(backBounds)) {
return false;
}
- if (prior->getOp() == SkCanvas::kReplace_Op) {
+ if (prior->getOp() == kReplace_SkClipOp) {
break;
}
}
"reverse-difference",
"replace",
};
- static_assert(0 == SkCanvas::kDifference_Op, "op_str");
- static_assert(1 == SkCanvas::kIntersect_Op, "op_str");
- static_assert(2 == SkCanvas::kUnion_Op, "op_str");
- static_assert(3 == SkCanvas::kXOR_Op, "op_str");
- static_assert(4 == SkCanvas::kReverseDifference_Op, "op_str");
- static_assert(5 == SkCanvas::kReplace_Op, "op_str");
+ static_assert(0 == kDifference_SkClipOp, "op_str");
+ static_assert(1 == kIntersect_SkClipOp, "op_str");
+ static_assert(2 == kUnion_SkClipOp, "op_str");
+ static_assert(3 == kXOR_SkClipOp, "op_str");
+ static_assert(4 == kReverseDifference_SkClipOp, "op_str");
+ static_assert(5 == kReplace_SkClipOp, "op_str");
static_assert(SK_ARRAY_COUNT(kOpStrings) == SkRegion::kOpCnt, "op_str");
SkDebugf("Type: %s, Op: %s, AA: %s, Save Count: %d\n", kTypeStrings[fType],
struct ClipPath final : Op {
static const auto kType = Type::ClipPath;
- ClipPath(const SkPath& path, SkCanvas::ClipOp op, bool aa) : path(path), op(op), aa(aa) {}
- SkPath path;
- SkCanvas::ClipOp op;
- bool aa;
+ ClipPath(const SkPath& path, SkClipOp op, bool aa) : path(path), op(op), aa(aa) {}
+ SkPath path;
+ SkClipOp op;
+ bool aa;
void draw(SkCanvas* c, const SkMatrix&) { c->clipPath(path, op, aa); }
void makeThreadsafe() { make_threadsafe(&path, nullptr); }
};
struct ClipRect final : Op {
static const auto kType = Type::ClipRect;
- ClipRect(const SkRect& rect, SkCanvas::ClipOp op, bool aa) : rect(rect), op(op), aa(aa) {}
- SkRect rect;
- SkCanvas::ClipOp op;
- bool aa;
+ ClipRect(const SkRect& rect, SkClipOp op, bool aa) : rect(rect), op(op), aa(aa) {}
+ SkRect rect;
+ SkClipOp op;
+ bool aa;
void draw(SkCanvas* c, const SkMatrix&) { c->clipRect(rect, op, aa); }
};
struct ClipRRect final : Op {
static const auto kType = Type::ClipRRect;
- ClipRRect(const SkRRect& rrect, SkCanvas::ClipOp op, bool aa) : rrect(rrect), op(op), aa(aa) {}
- SkRRect rrect;
- SkCanvas::ClipOp op;
- bool aa;
+ ClipRRect(const SkRRect& rrect, SkClipOp op, bool aa) : rrect(rrect), op(op), aa(aa) {}
+ SkRRect rrect;
+ SkClipOp op;
+ bool aa;
void draw(SkCanvas* c, const SkMatrix&) { c->clipRRect(rrect, op, aa); }
};
struct ClipRegion final : Op {
static const auto kType = Type::ClipRegion;
- ClipRegion(const SkRegion& region, SkCanvas::ClipOp op) : region(region), op(op) {}
- SkRegion region;
- SkCanvas::ClipOp op;
+ ClipRegion(const SkRegion& region, SkClipOp op) : region(region), op(op) {}
+ SkRegion region;
+ SkClipOp op;
void draw(SkCanvas* c, const SkMatrix&) { c->clipRegion(region, op); }
};
void SkLiteDL::translate(SkScalar dx, SkScalar dy) { this->push<Translate>(0, dx, dy); }
void SkLiteDL::translateZ(SkScalar dz) { this->push<TranslateZ>(0, dz); }
-void SkLiteDL::clipPath(const SkPath& path, SkCanvas::ClipOp op, bool aa) {
+void SkLiteDL::clipPath(const SkPath& path, SkClipOp op, bool aa) {
this->push<ClipPath>(0, path, op, aa);
}
-void SkLiteDL::clipRect(const SkRect& rect, SkCanvas::ClipOp op, bool aa) {
+void SkLiteDL::clipRect(const SkRect& rect, SkClipOp op, bool aa) {
this->push<ClipRect>(0, rect, op, aa);
}
-void SkLiteDL::clipRRect(const SkRRect& rrect, SkCanvas::ClipOp op, bool aa) {
+void SkLiteDL::clipRRect(const SkRRect& rrect, SkClipOp op, bool aa) {
this->push<ClipRRect>(0, rrect, op, aa);
}
-void SkLiteDL::clipRegion(const SkRegion& region, SkCanvas::ClipOp op) {
+void SkLiteDL::clipRegion(const SkRegion& region, SkClipOp op) {
this->push<ClipRegion>(0, region, op);
}
void translate(SkScalar, SkScalar);
void translateZ(SkScalar);
- void clipPath (const SkPath&, SkCanvas::ClipOp, bool aa);
- void clipRect (const SkRect&, SkCanvas::ClipOp, bool aa);
- void clipRRect (const SkRRect&, SkCanvas::ClipOp, bool aa);
- void clipRegion(const SkRegion&, SkCanvas::ClipOp);
+ void clipPath (const SkPath&, SkClipOp, bool aa);
+ void clipRect (const SkRect&, SkClipOp, bool aa);
+ void clipRRect (const SkRRect&, SkClipOp, bool aa);
+ void clipRegion(const SkRegion&, SkClipOp);
void drawPaint (const SkPaint&);
void drawPath (const SkPath&, const SkPaint&);
void SkLiteRecorder::didSetMatrix(const SkMatrix& matrix) { fDL->setMatrix(matrix); }
void SkLiteRecorder::didTranslate(SkScalar dx, SkScalar dy) { fDL->translate(dx, dy); }
-void SkLiteRecorder::onClipRect(const SkRect& rect, ClipOp op, ClipEdgeStyle style) {
+void SkLiteRecorder::onClipRect(const SkRect& rect, SkClipOp op, ClipEdgeStyle style) {
fDL->clipRect(rect, op, style==kSoft_ClipEdgeStyle);
this->INHERITED::onClipRect(rect, op, style);
}
-void SkLiteRecorder::onClipRRect(const SkRRect& rrect, ClipOp op, ClipEdgeStyle style) {
+void SkLiteRecorder::onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle style) {
fDL->clipRRect(rrect, op, style==kSoft_ClipEdgeStyle);
this->INHERITED::onClipRRect(rrect, op, style);
}
-void SkLiteRecorder::onClipPath(const SkPath& path, ClipOp op, ClipEdgeStyle style) {
+void SkLiteRecorder::onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle style) {
fDL->clipPath(path, op, style==kSoft_ClipEdgeStyle);
this->INHERITED::onClipPath(path, op, style);
}
-void SkLiteRecorder::onClipRegion(const SkRegion& region, ClipOp op) {
+void SkLiteRecorder::onClipRegion(const SkRegion& region, SkClipOp op) {
fDL->clipRegion(region, op);
this->INHERITED::onClipRegion(region, op);
}
void didSetMatrix(const SkMatrix&) override;
void didTranslate(SkScalar, SkScalar) override;
- void onClipRect (const SkRect&, ClipOp, ClipEdgeStyle) override;
- void onClipRRect (const SkRRect&, ClipOp, ClipEdgeStyle) override;
- void onClipPath (const SkPath&, ClipOp, ClipEdgeStyle) override;
- void onClipRegion(const SkRegion&, ClipOp) override;
+ void onClipRect (const SkRect&, SkClipOp, ClipEdgeStyle) override;
+ void onClipRRect (const SkRRect&, SkClipOp, ClipEdgeStyle) override;
+ void onClipPath (const SkPath&, SkClipOp, ClipEdgeStyle) override;
+ void onClipRegion(const SkRegion&, SkClipOp) override;
void onDrawPaint (const SkPaint&) override;
void onDrawPath (const SkPath&, const SkPaint&) override;
fNumSlowPaths += picture->numSlowPaths();
}
-void SkPictureGpuAnalyzer::analyzeClipPath(const SkPath& path, SkCanvas::ClipOp op, bool doAntiAlias) {
+void SkPictureGpuAnalyzer::analyzeClipPath(const SkPath& path, SkClipOp op, bool doAntiAlias) {
const SkRecords::ClipPath clipOp = {
SkIRect::MakeEmpty(), // Willie don't care.
path,
// clipparams are packed in 5 bits
// doAA:1 | clipOp:4
-static inline uint32_t ClipParams_pack(SkCanvas::ClipOp op, bool doAA) {
+static inline uint32_t ClipParams_pack(SkClipOp op, bool doAA) {
unsigned doAABit = doAA ? 1 : 0;
return (doAABit << 4) | op;
}
-static inline SkCanvas::ClipOp ClipParams_unpackRegionOp(uint32_t packed) {
- return (SkCanvas::ClipOp)(packed & 0xF);
+static inline SkClipOp ClipParams_unpackRegionOp(uint32_t packed) {
+ return (SkClipOp)(packed & 0xF);
}
static inline bool ClipParams_unpackDoAA(uint32_t packed) {
case CLIP_PATH: {
const SkPath& path = fPictureData->getPath(reader);
uint32_t packed = reader->readInt();
- SkCanvas::ClipOp clipOp = ClipParams_unpackRegionOp(packed);
+ SkClipOp clipOp = ClipParams_unpackRegionOp(packed);
bool doAA = ClipParams_unpackDoAA(packed);
size_t offsetToRestore = reader->readInt();
BREAK_ON_READ_ERROR(reader);
SkRegion region;
reader->readRegion(®ion);
uint32_t packed = reader->readInt();
- SkCanvas::ClipOp clipOp = ClipParams_unpackRegionOp(packed);
+ SkClipOp clipOp = ClipParams_unpackRegionOp(packed);
size_t offsetToRestore = reader->readInt();
BREAK_ON_READ_ERROR(reader);
SkRect rect;
reader->readRect(&rect);
uint32_t packed = reader->readInt();
- SkCanvas::ClipOp clipOp = ClipParams_unpackRegionOp(packed);
+ SkClipOp clipOp = ClipParams_unpackRegionOp(packed);
bool doAA = ClipParams_unpackDoAA(packed);
size_t offsetToRestore = reader->readInt();
BREAK_ON_READ_ERROR(reader);
SkRRect rrect;
reader->readRRect(&rrect);
uint32_t packed = reader->readInt();
- SkCanvas::ClipOp clipOp = ClipParams_unpackRegionOp(packed);
+ SkClipOp clipOp = ClipParams_unpackRegionOp(packed);
bool doAA = ClipParams_unpackDoAA(packed);
size_t offsetToRestore = reader->readInt();
BREAK_ON_READ_ERROR(reader);
#endif
}
-static bool clipOpExpands(SkCanvas::ClipOp op) {
+static bool clipOpExpands(SkClipOp op) {
switch (op) {
- case SkCanvas::kUnion_Op:
- case SkCanvas::kXOR_Op:
- case SkCanvas::kReverseDifference_Op:
- case SkCanvas::kReplace_Op:
+ case kUnion_SkClipOp:
+ case kXOR_SkClipOp:
+ case kReverseDifference_SkClipOp:
+ case kReplace_SkClipOp:
return true;
- case SkCanvas::kIntersect_Op:
- case SkCanvas::kDifference_Op:
+ case kIntersect_SkClipOp:
+ case kDifference_SkClipOp:
return false;
default:
- SkDEBUGFAIL("unknown region op");
+ SkDEBUGFAIL("unknown clipop");
return false;
}
}
this->restoreToCount(fInitialSaveCount);
}
-size_t SkPictureRecord::recordRestoreOffsetPlaceholder(ClipOp op) {
+size_t SkPictureRecord::recordRestoreOffsetPlaceholder(SkClipOp op) {
if (fRestoreOffsetStack.isEmpty()) {
return -1;
}
return offset;
}
-void SkPictureRecord::onClipRect(const SkRect& rect, SkCanvas::ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkPictureRecord::onClipRect(const SkRect& rect, SkClipOp op, ClipEdgeStyle edgeStyle) {
this->recordClipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle);
this->INHERITED::onClipRect(rect, op, edgeStyle);
}
-size_t SkPictureRecord::recordClipRect(const SkRect& rect, SkCanvas::ClipOp op, bool doAA) {
+size_t SkPictureRecord::recordClipRect(const SkRect& rect, SkClipOp op, bool doAA) {
// id + rect + clip params
size_t size = 1 * kUInt32Size + sizeof(rect) + 1 * kUInt32Size;
// recordRestoreOffsetPlaceholder doesn't always write an offset
return offset;
}
-void SkPictureRecord::onClipRRect(const SkRRect& rrect, SkCanvas::ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkPictureRecord::onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle edgeStyle) {
this->recordClipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle);
this->INHERITED::onClipRRect(rrect, op, edgeStyle);
}
-size_t SkPictureRecord::recordClipRRect(const SkRRect& rrect, SkCanvas::ClipOp op, bool doAA) {
+size_t SkPictureRecord::recordClipRRect(const SkRRect& rrect, SkClipOp op, bool doAA) {
// op + rrect + clip params
size_t size = 1 * kUInt32Size + SkRRect::kSizeInMemory + 1 * kUInt32Size;
// recordRestoreOffsetPlaceholder doesn't always write an offset
return offset;
}
-void SkPictureRecord::onClipPath(const SkPath& path, SkCanvas::ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkPictureRecord::onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle edgeStyle) {
int pathID = this->addPathToHeap(path);
this->recordClipPath(pathID, op, kSoft_ClipEdgeStyle == edgeStyle);
this->INHERITED::onClipPath(path, op, edgeStyle);
}
-size_t SkPictureRecord::recordClipPath(int pathID, SkCanvas::ClipOp op, bool doAA) {
+size_t SkPictureRecord::recordClipPath(int pathID, SkClipOp op, bool doAA) {
// op + path index + clip params
size_t size = 3 * kUInt32Size;
// recordRestoreOffsetPlaceholder doesn't always write an offset
return offset;
}
-void SkPictureRecord::onClipRegion(const SkRegion& region, ClipOp op) {
+void SkPictureRecord::onClipRegion(const SkRegion& region, SkClipOp op) {
this->recordClipRegion(region, op);
this->INHERITED::onClipRegion(region, op);
}
-size_t SkPictureRecord::recordClipRegion(const SkRegion& region, ClipOp op) {
+size_t SkPictureRecord::recordClipRegion(const SkRegion& region, SkClipOp op) {
// op + clip params + region
size_t size = 2 * kUInt32Size + region.writeToMemory(nullptr);
// recordRestoreOffsetPlaceholder doesn't always write an offset
private:
void handleOptimization(int opt);
- size_t recordRestoreOffsetPlaceholder(SkCanvas::ClipOp);
+ size_t recordRestoreOffsetPlaceholder(SkClipOp);
void fillRestoreOffsetPlaceholdersForCurrentStackLevel(uint32_t restoreOffset);
SkTDArray<int32_t> fRestoreOffsetStack;
const uint16_t indices[], int indexCount,
const SkPaint&) override;
- void onClipRect(const SkRect&, ClipOp, ClipEdgeStyle) override;
- void onClipRRect(const SkRRect&, ClipOp, ClipEdgeStyle) override;
- void onClipPath(const SkPath&, ClipOp, ClipEdgeStyle) override;
- void onClipRegion(const SkRegion&, ClipOp) override;
+ void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
+ void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
+ void onClipPath(const SkPath&, SkClipOp, ClipEdgeStyle) override;
+ void onClipRegion(const SkRegion&, SkClipOp) override;
void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
void recordConcat(const SkMatrix& matrix);
void recordTranslate(const SkMatrix& matrix);
void recordScale(const SkMatrix& matrix);
- size_t recordClipRect(const SkRect& rect, SkCanvas::ClipOp op, bool doAA);
- size_t recordClipRRect(const SkRRect& rrect, SkCanvas::ClipOp op, bool doAA);
- size_t recordClipPath(int pathID, SkCanvas::ClipOp op, bool doAA);
- size_t recordClipRegion(const SkRegion& region, SkCanvas::ClipOp op);
+ size_t recordClipRect(const SkRect& rect, SkClipOp op, bool doAA);
+ size_t recordClipRRect(const SkRRect& rrect, SkClipOp op, bool doAA);
+ size_t recordClipPath(int pathID, SkClipOp op, bool doAA);
+ size_t recordClipRegion(const SkRegion& region, SkClipOp op);
void recordSave();
void recordSaveLayer(const SaveLayerRec&);
void recordRestore(bool fillInSkips = true);
#endif
}
-void SkRecorder::onClipRect(const SkRect& rect, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkRecorder::onClipRect(const SkRect& rect, SkClipOp op, ClipEdgeStyle edgeStyle) {
INHERITED(onClipRect, rect, op, edgeStyle);
SkRecords::ClipOpAndAA opAA(op, kSoft_ClipEdgeStyle == edgeStyle);
APPEND(ClipRect, this->devBounds(), rect, opAA);
}
-void SkRecorder::onClipRRect(const SkRRect& rrect, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkRecorder::onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle edgeStyle) {
INHERITED(onClipRRect, rrect, op, edgeStyle);
SkRecords::ClipOpAndAA opAA(op, kSoft_ClipEdgeStyle == edgeStyle);
APPEND(ClipRRect, this->devBounds(), rrect, opAA);
}
-void SkRecorder::onClipPath(const SkPath& path, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkRecorder::onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle edgeStyle) {
INHERITED(onClipPath, path, op, edgeStyle);
SkRecords::ClipOpAndAA opAA(op, kSoft_ClipEdgeStyle == edgeStyle);
APPEND(ClipPath, this->devBounds(), path, opAA);
}
-void SkRecorder::onClipRegion(const SkRegion& deviceRgn, ClipOp op) {
+void SkRecorder::onClipRegion(const SkRegion& deviceRgn, SkClipOp op) {
INHERITED(onClipRegion, deviceRgn, op);
APPEND(ClipRegion, this->devBounds(), deviceRgn, op);
}
void onDrawAtlas(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[],
int count, SkBlendMode, const SkRect* cull, const SkPaint*) override;
- void onClipRect(const SkRect& rect, ClipOp, ClipEdgeStyle) override;
- void onClipRRect(const SkRRect& rrect, ClipOp, ClipEdgeStyle) override;
- void onClipPath(const SkPath& path, ClipOp, ClipEdgeStyle) override;
- void onClipRegion(const SkRegion& deviceRgn, ClipOp) override;
+ void onClipRect(const SkRect& rect, SkClipOp, ClipEdgeStyle) override;
+ void onClipRRect(const SkRRect& rrect, SkClipOp, ClipEdgeStyle) override;
+ void onClipPath(const SkPath& path, SkClipOp, ClipEdgeStyle) override;
+ void onClipRegion(const SkRegion& deviceRgn, SkClipOp) override;
void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
}
SkAutoCanvasRestore acr(canvas, true);
- canvas->clipRect(SkRect::Make(fgBounds), SkCanvas::kDifference_Op);
+ canvas->clipRect(SkRect::Make(fgBounds), kDifference_SkClipOp);
paint.setColor(0);
canvas->drawPaint(paint);
}
for (ElementList::Iter iter(reducedClip.elements()); iter.get(); iter.next()) {
const Element* element = iter.get();
- SkCanvas::ClipOp op = element->getOp();
+ SkClipOp op = element->getOp();
bool invert = element->isInverseFilled();
bool needsStencil = invert ||
- SkCanvas::kIntersect_Op == op || SkCanvas::kReverseDifference_Op == op;
+ kIntersect_SkClipOp == op || kReverseDifference_SkClipOp == op;
if (PathNeedsSWRenderer(context, hasUserStencilSettings,
renderTargetContext, translate, element, nullptr, needsStencil)) {
SkSTArray<kMaxAnalyticElements, sk_sp<GrFragmentProcessor>> fps;
ElementList::Iter iter(elements);
while (iter.get()) {
- SkCanvas::ClipOp op = iter.get()->getOp();
+ SkClipOp op = iter.get()->getOp();
bool invert;
bool skip = false;
switch (op) {
for (ElementList::Iter iter(reducedClip.elements()); iter.get(); iter.next()) {
const Element* element = iter.get();
- SkCanvas::ClipOp op = element->getOp();
+ SkClipOp op = element->getOp();
- if (SkCanvas::kIntersect_Op == op || SkCanvas::kReverseDifference_Op == op) {
+ if (kIntersect_SkClipOp == op || kReverseDifference_SkClipOp == op) {
// Intersect and reverse difference require modifying pixels outside of the geometry
// that is being "drawn". In both cases we erase all the pixels outside of the geometry
// but leave the pixels inside the geometry alone. For reverse difference we invert all
// the pixels before clearing the ones outside the geometry.
- if (SkCanvas::kReverseDifference_Op == op) {
+ if (kReverseDifference_SkClipOp == op) {
SkRect temp = SkRect::Make(reducedClip.ibounds());
// invert the entire scene
helper.drawRect(temp, SkRegion::kXOR_Op, false, 0xFF);
fHasIBounds = true;
// Implement the clip with an AA rect element.
- fElements.addToHead(stackBounds, SkCanvas::kReplace_Op, true/*doAA*/);
+ fElements.addToHead(stackBounds, kReplace_SkClipOp, true/*doAA*/);
fElementsGenID = stack.getTopmostGenID();
fRequiresAA = true;
bool isFlip = false; // does this op just flip the in/out state of every point in the bounds
switch (element->getOp()) {
- case SkCanvas::kDifference_Op:
+ case kDifference_SkClipOp:
// check if the shape subtracted either contains the entire bounds (and makes
// the clip empty) or is outside the bounds and therefore can be skipped.
if (element->isInverseFilled()) {
emsmallens = true;
}
break;
- case SkCanvas::kIntersect_Op:
+ case kIntersect_SkClipOp:
// check if the shape intersected contains the entire bounds and therefore can
// be skipped or it is outside the entire bounds and therefore makes the clip
// empty.
emsmallens = true;
}
break;
- case SkCanvas::kUnion_Op:
+ case kUnion_SkClipOp:
// If the union-ed shape contains the entire bounds then after this element
// the bounds is entirely inside the clip. If the union-ed shape is outside the
// bounds then this op can be skipped.
embiggens = true;
}
break;
- case SkCanvas::kXOR_Op:
+ case kXOR_SkClipOp:
// If the bounds is entirely inside the shape being xor-ed then the effect is
// to flip the inside/outside state of every point in the bounds. We may be
// able to take advantage of this in the forward pass. If the xor-ed shape
emsmallens = embiggens = true;
}
break;
- case SkCanvas::kReverseDifference_Op:
+ case kReverseDifference_SkClipOp:
// When the bounds is entirely within the rev-diff shape then this behaves like xor
// and reverses every point inside the bounds. If the shape is completely outside
// the bounds then we know after this element is applied that the bounds will be
}
break;
- case SkCanvas::kReplace_Op:
+ case kReplace_SkClipOp:
// Replace will always terminate our walk. We will either begin the forward walk
// at the replace op or detect here than the shape is either completely inside
// or completely outside the bounds. In this latter case it can be skipped by
// if it is a flip, change it to a bounds-filling rect
if (isFlip) {
- SkASSERT(SkCanvas::kXOR_Op == element->getOp() ||
- SkCanvas::kReverseDifference_Op == element->getOp());
- fElements.addToHead(SkRect::Make(fIBounds), SkCanvas::kReverseDifference_Op, false);
+ SkASSERT(kXOR_SkClipOp == element->getOp() ||
+ kReverseDifference_SkClipOp == element->getOp());
+ fElements.addToHead(SkRect::Make(fIBounds), kReverseDifference_SkClipOp, false);
} else {
Element* newElement = fElements.addToHead(*element);
if (newElement->isAA()) {
// Intersecting an inverse shape is the same as differencing the non-inverse shape.
// Replacing with an inverse shape is the same as setting initialState=kAllIn and
// differencing the non-inverse shape.
- bool isReplace = SkCanvas::kReplace_Op == newElement->getOp();
+ bool isReplace = kReplace_SkClipOp == newElement->getOp();
if (newElement->isInverseFilled() &&
- (SkCanvas::kIntersect_Op == newElement->getOp() || isReplace)) {
+ (kIntersect_SkClipOp == newElement->getOp() || isReplace)) {
newElement->invertShapeFillType();
- newElement->setOp(SkCanvas::kDifference_Op);
+ newElement->setOp(kDifference_SkClipOp);
if (isReplace) {
SkASSERT(InitialTriState::kAllOut == initialTriState);
initialTriState = InitialTriState::kAllIn;
while (element) {
bool skippable = false;
switch (element->getOp()) {
- case SkCanvas::kDifference_Op:
+ case kDifference_SkClipOp:
// subtracting from the empty set yields the empty set.
skippable = InitialTriState::kAllOut == initialTriState;
break;
- case SkCanvas::kIntersect_Op:
+ case kIntersect_SkClipOp:
// intersecting with the empty set yields the empty set
if (InitialTriState::kAllOut == initialTriState) {
skippable = true;
} else {
// We can clear to zero and then simply draw the clip element.
initialTriState = InitialTriState::kAllOut;
- element->setOp(SkCanvas::kReplace_Op);
+ element->setOp(kReplace_SkClipOp);
}
break;
- case SkCanvas::kUnion_Op:
+ case kUnion_SkClipOp:
if (InitialTriState::kAllIn == initialTriState) {
// unioning the infinite plane with anything is a no-op.
skippable = true;
} else {
// unioning the empty set with a shape is the shape.
- element->setOp(SkCanvas::kReplace_Op);
+ element->setOp(kReplace_SkClipOp);
}
break;
- case SkCanvas::kXOR_Op:
+ case kXOR_SkClipOp:
if (InitialTriState::kAllOut == initialTriState) {
// xor could be changed to diff in the kAllIn case, not sure it's a win.
- element->setOp(SkCanvas::kReplace_Op);
+ element->setOp(kReplace_SkClipOp);
}
break;
- case SkCanvas::kReverseDifference_Op:
+ case kReverseDifference_SkClipOp:
if (InitialTriState::kAllIn == initialTriState) {
// subtracting the whole plane will yield the empty set.
skippable = true;
if (skippable) {
initialTriState = InitialTriState::kAllIn;
} else {
- element->setOp(SkCanvas::kReplace_Op);
+ element->setOp(kReplace_SkClipOp);
}
}
break;
- case SkCanvas::kReplace_Op:
+ case kReplace_SkClipOp:
skippable = false; // we would have skipped it in the backwards walk if we
// could've.
break;
fInitialState = static_cast<GrReducedClip::InitialState>(initialTriState);
}
-static bool element_is_pure_subtract(SkCanvas::ClipOp op) {
+static bool element_is_pure_subtract(SkClipOp op) {
SkASSERT(op >= 0);
- return op <= SkCanvas::kIntersect_Op;
+ return op <= kIntersect_SkClipOp;
- GR_STATIC_ASSERT(0 == SkCanvas::kDifference_Op);
- GR_STATIC_ASSERT(1 == SkCanvas::kIntersect_Op);
+ GR_STATIC_ASSERT(0 == kDifference_SkClipOp);
+ GR_STATIC_ASSERT(1 == kIntersect_SkClipOp);
}
void GrReducedClip::addInteriorWindowRectangles(int maxWindowRectangles) {
ElementList::Iter iter(fElements, ElementList::Iter::kTail_IterStart);
for (; iter.get() && element_is_pure_subtract(iter.get()->getOp()); iter.prev()) {
const Element* element = iter.get();
- if (SkCanvas::kDifference_Op != element->getOp()) {
+ if (kDifference_SkClipOp != element->getOp()) {
continue;
}
* we intercept all clip calls to ensure that the clip stays BW (i.e. never antialiased), since
* an antialiased clip won't build a SkRegion (it builds SkAAClip).
*/
-void SkPDFCanvas::onClipRect(const SkRect& rect, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkPDFCanvas::onClipRect(const SkRect& rect, SkClipOp op, ClipEdgeStyle edgeStyle) {
this->INHERITED::onClipRect(rect, op, kHard_ClipEdgeStyle);
}
-void SkPDFCanvas::onClipRRect(const SkRRect& rrect, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkPDFCanvas::onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle edgeStyle) {
this->INHERITED::onClipRRect(rrect, op, kHard_ClipEdgeStyle);
}
-void SkPDFCanvas::onClipPath(const SkPath& path, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkPDFCanvas::onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle edgeStyle) {
this->INHERITED::onClipPath(path, op, kHard_ClipEdgeStyle);
}
~SkPDFCanvas();
protected:
- void onClipRect(const SkRect&, ClipOp, ClipEdgeStyle) override;
- void onClipRRect(const SkRRect&, ClipOp, ClipEdgeStyle) override;
- void onClipPath(const SkPath&, ClipOp, ClipEdgeStyle) override;
+ void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
+ void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
+ void onClipPath(const SkPath&, SkClipOp, ClipEdgeStyle) override;
void onDrawBitmapNine(const SkBitmap&, const SkIRect&, const SkRect&,
const SkPaint*) override;
static_assert(SkRegion::kReverseDifference_Op == (int)kReverseDifference_SkPathOp,
"region_pathop_mismatch");
-static SkPathOp region_op_to_pathops_op(SkCanvas::ClipOp op) {
+static SkPathOp region_op_to_pathops_op(SkClipOp op) {
SkASSERT(op >= 0);
- SkASSERT(op <= SkCanvas::kReverseDifference_Op);
+ SkASSERT(op <= kReverseDifference_SkClipOp);
return (SkPathOp)op;
}
}
entryPath.transform(transform);
- if (SkCanvas::kReplace_Op == clipEntry->getOp()) {
+ if (kReplace_SkClipOp == clipEntry->getOp()) {
*outClipPath = entryPath;
} else {
SkPathOp op = region_op_to_pathops_op(clipEntry->getOp());
synthesizedClipStack = fExistingClipStack;
SkPath clipPath;
clipRegion.getBoundaryPath(&clipPath);
- synthesizedClipStack.clipPath(clipPath, SkMatrix::I(), SkCanvas::kReplace_Op, false);
+ synthesizedClipStack.clipPath(clipPath, SkMatrix::I(), kReplace_SkClipOp, false);
clipStack = &synthesizedClipStack;
}
}
this->INHERITED::didSetMatrix(matrix);
}
-void SkPipeCanvas::onClipRect(const SkRect& rect, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkPipeCanvas::onClipRect(const SkRect& rect, SkClipOp op, ClipEdgeStyle edgeStyle) {
fStream->write32(pack_verb(SkPipeVerb::kClipRect, ((unsigned)op << 1) | edgeStyle));
fStream->write(&rect, 4 * sizeof(SkScalar));
this->INHERITED::onClipRect(rect, op, edgeStyle);
}
-void SkPipeCanvas::onClipRRect(const SkRRect& rrect, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkPipeCanvas::onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle edgeStyle) {
fStream->write32(pack_verb(SkPipeVerb::kClipRRect, ((unsigned)op << 1) | edgeStyle));
write_rrect(fStream, rrect);
this->INHERITED::onClipRRect(rrect, op, edgeStyle);
}
-void SkPipeCanvas::onClipPath(const SkPath& path, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkPipeCanvas::onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle edgeStyle) {
SkPipeWriter writer(this);
writer.write32(pack_verb(SkPipeVerb::kClipPath, ((unsigned)op << 1) | edgeStyle));
writer.writePath(path);
this->INHERITED::onClipPath(path, op, edgeStyle);
}
-void SkPipeCanvas::onClipRegion(const SkRegion& deviceRgn, ClipOp op) {
+void SkPipeCanvas::onClipRegion(const SkRegion& deviceRgn, SkClipOp op) {
SkPipeWriter writer(this);
writer.write32(pack_verb(SkPipeVerb::kClipRegion, (unsigned)op << 1));
writer.writeRegion(deviceRgn);
const uint16_t indices[], int indexCount,
const SkPaint&) override;
- void onClipRect(const SkRect&, ClipOp, ClipEdgeStyle) override;
- void onClipRRect(const SkRRect&, ClipOp, ClipEdgeStyle) override;
- void onClipPath(const SkPath&, ClipOp, ClipEdgeStyle) override;
- void onClipRegion(const SkRegion&, ClipOp) override;
+ void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
+ void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
+ void onClipPath(const SkPath&, SkClipOp, ClipEdgeStyle) override;
+ void onClipRegion(const SkRegion&, SkClipOp) override;
void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
void onDrawAnnotation(const SkRect&, const char[], SkData*) override;
static void clipRect_handler(SkPipeReader& reader, uint32_t packedVerb, SkCanvas* canvas) {
SkASSERT(SkPipeVerb::kClipRect == unpack_verb(packedVerb));
- SkCanvas::ClipOp op = (SkCanvas::ClipOp)(unpack_verb_extra(packedVerb) >> 1);
+ SkClipOp op = (SkClipOp)(unpack_verb_extra(packedVerb) >> 1);
bool isAA = unpack_verb_extra(packedVerb) & 1;
canvas->clipRect(*skip<SkRect>(reader), op, isAA);
}
static void clipRRect_handler(SkPipeReader& reader, uint32_t packedVerb, SkCanvas* canvas) {
SkASSERT(SkPipeVerb::kClipRRect == unpack_verb(packedVerb));
- SkCanvas::ClipOp op = (SkCanvas::ClipOp)(unpack_verb_extra(packedVerb) >> 1);
+ SkClipOp op = (SkClipOp)(unpack_verb_extra(packedVerb) >> 1);
bool isAA = unpack_verb_extra(packedVerb) & 1;
canvas->clipRRect(read_rrect(reader), op, isAA);
}
static void clipPath_handler(SkPipeReader& reader, uint32_t packedVerb, SkCanvas* canvas) {
SkASSERT(SkPipeVerb::kClipPath == unpack_verb(packedVerb));
- SkCanvas::ClipOp op = (SkCanvas::ClipOp)(unpack_verb_extra(packedVerb) >> 1);
+ SkClipOp op = (SkClipOp)(unpack_verb_extra(packedVerb) >> 1);
bool isAA = unpack_verb_extra(packedVerb) & 1;
SkPath path;
reader.readPath(&path);
static void clipRegion_handler(SkPipeReader& reader, uint32_t packedVerb, SkCanvas* canvas) {
SkASSERT(SkPipeVerb::kClipRegion == unpack_verb(packedVerb));
- SkCanvas::ClipOp op = (SkCanvas::ClipOp)(unpack_verb_extra(packedVerb) >> 1);
+ SkClipOp op = (SkClipOp)(unpack_verb_extra(packedVerb) >> 1);
SkRegion region;
reader.readRegion(®ion);
canvas->clipRegion(region, op);
SkClipStack adjustedClipStack;
if (srcOrNull && *srcOrNull != SkRect::Make(bm.bounds())) {
adjustedClipStack = *draw.fClipStack;
- adjustedClipStack.clipRect(dst, *draw.fMatrix, SkCanvas::kIntersect_Op,
+ adjustedClipStack.clipRect(dst, *draw.fMatrix, kIntersect_SkClipOp,
paint.isAntiAlias());
adjustedDraw.fClipStack = &adjustedClipStack;
}
this->SkCanvas::didSetMatrix(matrix);
}
-void SkCanvasStack::onClipRect(const SkRect& r, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkCanvasStack::onClipRect(const SkRect& r, SkClipOp op, ClipEdgeStyle edgeStyle) {
this->INHERITED::onClipRect(r, op, edgeStyle);
this->clipToZOrderedBounds();
}
-void SkCanvasStack::onClipRRect(const SkRRect& rr, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkCanvasStack::onClipRRect(const SkRRect& rr, SkClipOp op, ClipEdgeStyle edgeStyle) {
this->INHERITED::onClipRRect(rr, op, edgeStyle);
this->clipToZOrderedBounds();
}
-void SkCanvasStack::onClipPath(const SkPath& p, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkCanvasStack::onClipPath(const SkPath& p, SkClipOp op, ClipEdgeStyle edgeStyle) {
this->INHERITED::onClipPath(p, op, edgeStyle);
this->clipToZOrderedBounds();
}
-void SkCanvasStack::onClipRegion(const SkRegion& deviceRgn, ClipOp op) {
+void SkCanvasStack::onClipRegion(const SkRegion& deviceRgn, SkClipOp op) {
SkASSERT(fList.count() == fCanvasData.count());
for (int i = 0; i < fList.count(); ++i) {
SkRegion tempRegion;
protected:
void didSetMatrix(const SkMatrix&) override;
- void onClipRect(const SkRect&, ClipOp, ClipEdgeStyle) override;
- void onClipRRect(const SkRRect&, ClipOp, ClipEdgeStyle) override;
- void onClipPath(const SkPath&, ClipOp, ClipEdgeStyle) override;
- void onClipRegion(const SkRegion&, ClipOp) override;
+ void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
+ void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
+ void onClipPath(const SkPath&, SkClipOp, ClipEdgeStyle) override;
+ void onClipRegion(const SkRegion&, SkClipOp) override;
private:
void clipToZOrderedBounds();
bool failed() { return fFailed; }
// ClipVisitor
- void clipRect(const SkRect& rect, SkCanvas::ClipOp op, bool antialias) override {
+ void clipRect(const SkRect& rect, SkClipOp op, bool antialias) override {
fFailed |= antialias;
}
- void clipRRect(const SkRRect& rrect, SkCanvas::ClipOp op, bool antialias) override {
+ void clipRRect(const SkRRect& rrect, SkClipOp op, bool antialias) override {
fFailed |= antialias;
}
- void clipPath(const SkPath&, SkCanvas::ClipOp, bool antialias) override {
+ void clipPath(const SkPath&, SkClipOp, bool antialias) override {
fFailed |= antialias;
}
}
canvas->setMatrix(matrix);
- canvas->clipRegion(clip, SkCanvas::kReplace_Op);
+ canvas->clipRegion(clip, kReplace_SkClipOp);
}
static std::unique_ptr<SkCanvas>
case kClipRect_Type:
fCanvas->clipRect(rec.fData.fBounds);
this->INHERITED::onClipRect(rec.fData.fBounds,
- kIntersect_Op, kHard_ClipEdgeStyle);
+ kIntersect_SkClipOp, kHard_ClipEdgeStyle);
break;
case kTrans_Type:
case kScaleTrans_Type: {
this->INHERITED::didSetMatrix(matrix);
}
-void SkDeferredCanvas::onClipRect(const SkRect& rect, ClipOp op, ClipEdgeStyle edgeStyle) {
- if (kIntersect_Op == op) {
+void SkDeferredCanvas::onClipRect(const SkRect& rect, SkClipOp op, ClipEdgeStyle edgeStyle) {
+ if (kIntersect_SkClipOp == op) {
this->push_cliprect(rect);
} else {
this->flush_all();
}
}
-void SkDeferredCanvas::onClipRRect(const SkRRect& rrect, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkDeferredCanvas::onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle edgeStyle) {
this->flush_all();
fCanvas->clipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle);
this->INHERITED::onClipRRect(rrect, op, edgeStyle);
}
-void SkDeferredCanvas::onClipPath(const SkPath& path, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkDeferredCanvas::onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle edgeStyle) {
this->flush_all();
fCanvas->clipPath(path, op, kSoft_ClipEdgeStyle == edgeStyle);
this->INHERITED::onClipPath(path, op, edgeStyle);
}
-void SkDeferredCanvas::onClipRegion(const SkRegion& deviceRgn, ClipOp op) {
+void SkDeferredCanvas::onClipRegion(const SkRegion& deviceRgn, SkClipOp op) {
this->flush_all();
fCanvas->clipRegion(deviceRgn, op);
this->INHERITED::onClipRegion(deviceRgn, op);
const SkRect rects[], const SkColor colors[],
int count, SkBlendMode, const SkRect* cull, const SkPaint* paint) override;
- void onClipRect(const SkRect&, ClipOp, ClipEdgeStyle) override;
- void onClipRRect(const SkRRect&, ClipOp, ClipEdgeStyle) override;
- void onClipPath(const SkPath&, ClipOp, ClipEdgeStyle) override;
- void onClipRegion(const SkRegion&, ClipOp) override;
+ void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
+ void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
+ void onClipPath(const SkPath&, SkClipOp, ClipEdgeStyle) override;
+ void onClipRegion(const SkRegion&, SkClipOp) override;
void onDrawDrawable(SkDrawable*, const SkMatrix*) override;
void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
}
}
-static const char* toString(SkCanvas::ClipOp op) {
+static const char* toString(SkClipOp op) {
static const char* gOpNames[] = {
"DIFF", "SECT", "UNION", "XOR", "RDIFF", "REPLACE"
};
return kSoft_ClipEdgeStyle == edgeStyle ? "AA" : "BW";
}
-void SkDumpCanvas::onClipRect(const SkRect& rect, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkDumpCanvas::onClipRect(const SkRect& rect, SkClipOp op, ClipEdgeStyle edgeStyle) {
SkString str;
toString(rect, &str);
this->dump(kClip_Verb, nullptr, "clipRect(%s %s %s)", str.c_str(), toString(op),
this->INHERITED::onClipRect(rect, op, edgeStyle);
}
-void SkDumpCanvas::onClipRRect(const SkRRect& rrect, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkDumpCanvas::onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle edgeStyle) {
SkString str;
toString(rrect, &str);
this->dump(kClip_Verb, nullptr, "clipRRect(%s %s %s)", str.c_str(), toString(op),
this->INHERITED::onClipRRect(rrect, op, edgeStyle);
}
-void SkDumpCanvas::onClipPath(const SkPath& path, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkDumpCanvas::onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle edgeStyle) {
SkString str;
toString(path, &str);
this->dump(kClip_Verb, nullptr, "clipPath(%s %s %s)", str.c_str(), toString(op),
this->INHERITED::onClipPath(path, op, edgeStyle);
}
-void SkDumpCanvas::onClipRegion(const SkRegion& deviceRgn, ClipOp op) {
+void SkDumpCanvas::onClipRegion(const SkRegion& deviceRgn, SkClipOp op) {
SkString str;
toString(deviceRgn, &str);
- this->dump(kClip_Verb, nullptr, "clipRegion(%s %s)", str.c_str(),
- toString(op));
+ this->dump(kClip_Verb, nullptr, "clipRegion(%s %s)", str.c_str(), toString(op));
this->INHERITED::onClipRegion(deviceRgn, op);
}
this->INHERITED::didSetMatrix(matrix);
}
-void SkLuaCanvas::onClipRect(const SkRect& r, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkLuaCanvas::onClipRect(const SkRect& r, SkClipOp op, ClipEdgeStyle edgeStyle) {
AUTO_LUA("clipRect");
lua.pushRect(r, "rect");
lua.pushBool(kSoft_ClipEdgeStyle == edgeStyle, "aa");
this->INHERITED::onClipRect(r, op, edgeStyle);
}
-void SkLuaCanvas::onClipRRect(const SkRRect& rrect, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkLuaCanvas::onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle edgeStyle) {
AUTO_LUA("clipRRect");
lua.pushRRect(rrect, "rrect");
lua.pushBool(kSoft_ClipEdgeStyle == edgeStyle, "aa");
this->INHERITED::onClipRRect(rrect, op, edgeStyle);
}
-void SkLuaCanvas::onClipPath(const SkPath& path, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkLuaCanvas::onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle edgeStyle) {
AUTO_LUA("clipPath");
lua.pushPath(path, "path");
lua.pushBool(kSoft_ClipEdgeStyle == edgeStyle, "aa");
this->INHERITED::onClipPath(path, op, edgeStyle);
}
-void SkLuaCanvas::onClipRegion(const SkRegion& deviceRgn, ClipOp op) {
+void SkLuaCanvas::onClipRegion(const SkRegion& deviceRgn, SkClipOp op) {
AUTO_LUA("clipRegion");
this->INHERITED::onClipRegion(deviceRgn, op);
}
this->INHERITED::didSetMatrix(matrix);
}
-void SkNWayCanvas::onClipRect(const SkRect& rect, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkNWayCanvas::onClipRect(const SkRect& rect, SkClipOp op, ClipEdgeStyle edgeStyle) {
Iter iter(fList);
while (iter.next()) {
iter->clipRect(rect, op, kSoft_ClipEdgeStyle == edgeStyle);
this->INHERITED::onClipRect(rect, op, edgeStyle);
}
-void SkNWayCanvas::onClipRRect(const SkRRect& rrect, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkNWayCanvas::onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle edgeStyle) {
Iter iter(fList);
while (iter.next()) {
iter->clipRRect(rrect, op, kSoft_ClipEdgeStyle == edgeStyle);
this->INHERITED::onClipRRect(rrect, op, edgeStyle);
}
-void SkNWayCanvas::onClipPath(const SkPath& path, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkNWayCanvas::onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle edgeStyle) {
Iter iter(fList);
while (iter.next()) {
iter->clipPath(path, op, kSoft_ClipEdgeStyle == edgeStyle);
this->INHERITED::onClipPath(path, op, edgeStyle);
}
-void SkNWayCanvas::onClipRegion(const SkRegion& deviceRgn, ClipOp op) {
+void SkNWayCanvas::onClipRegion(const SkRegion& deviceRgn, SkClipOp op) {
Iter iter(fList);
while (iter.next()) {
iter->clipRegion(deviceRgn, op);
canvas->drawColor(SK_ColorBLUE);
canvas->restore();
- canvas->clipRegion(localRegion, (SkCanvas::ClipOp) clipOp);
+ canvas->clipRegion(localRegion, (SkClipOp) clipOp);
canvas->drawColor(SK_ColorBLUE);
}
SkRRect roundRect;
roundRect.setOval(SkRect::MakeWH(5, 5));
- canvas.clipRRect(roundRect, SkCanvas::kIntersect_Op, true);
+ canvas.clipRRect(roundRect, kIntersect_SkClipOp, true);
SkCanvasState* state = SkCanvasStateUtils::CaptureCanvasState(&canvas);
REPORTER_ASSERT(reporter, !state);
public:
Canvas2CanvasClipVisitor(SkCanvas* target) : fTarget(target) {}
- void clipRect(const SkRect& r, SkCanvas::ClipOp op, bool aa) override {
+ void clipRect(const SkRect& r, SkClipOp op, bool aa) override {
fTarget->clipRect(r, op, aa);
}
- void clipRRect(const SkRRect& r, SkCanvas::ClipOp op, bool aa) override {
+ void clipRRect(const SkRRect& r, SkClipOp op, bool aa) override {
fTarget->clipRRect(r, op, aa);
}
- void clipPath(const SkPath& p, SkCanvas::ClipOp op, bool aa) override {
+ void clipPath(const SkPath& p, SkClipOp op, bool aa) override {
fTarget->clipPath(p, op, aa);
}
SIMPLE_TEST_STEP(SetMatrix, setMatrix(d.fMatrix));
SIMPLE_TEST_STEP(ClipRect, clipRect(d.fRect));
SIMPLE_TEST_STEP(ClipPath, clipPath(d.fPath));
-SIMPLE_TEST_STEP(ClipRegion, clipRegion(d.fRegion, SkCanvas::kReplace_Op));
+SIMPLE_TEST_STEP(ClipRegion, clipRegion(d.fRegion, kReplace_SkClipOp));
SIMPLE_TEST_STEP(Clear, clear(d.fColor));
///////////////////////////////////////////////////////////////////////////////
// create a clip stack that will (trivially) reduce to a single rect that
// is larger than the screen
SkClipStack stack;
- stack.clipRect(clipRect, SkMatrix::I(), SkCanvas::kReplace_Op, false);
+ stack.clipRect(clipRect, SkMatrix::I(), kReplace_SkClipOp, false);
bool isIntersectionOfRects = true;
SkRect devStackBounds;
p.lineTo(7, 8);
p.lineTo(5, 9);
p.close();
- s.clipPath(p, SkMatrix::I(), SkCanvas::kIntersect_Op, doAA);
+ s.clipPath(p, SkMatrix::I(), kIntersect_SkClipOp, doAA);
s.save();
REPORTER_ASSERT(reporter, 2 == s.getSaveCount());
SkRect r = SkRect::MakeLTRB(1, 2, 3, 4);
- s.clipRect(r, SkMatrix::I(), SkCanvas::kIntersect_Op, doAA);
+ s.clipRect(r, SkMatrix::I(), kIntersect_SkClipOp, doAA);
r = SkRect::MakeLTRB(10, 11, 12, 13);
- s.clipRect(r, SkMatrix::I(), SkCanvas::kIntersect_Op, doAA);
+ s.clipRect(r, SkMatrix::I(), kIntersect_SkClipOp, doAA);
s.save();
REPORTER_ASSERT(reporter, 3 == s.getSaveCount());
r = SkRect::MakeLTRB(14, 15, 16, 17);
- s.clipRect(r, SkMatrix::I(), SkCanvas::kUnion_Op, doAA);
+ s.clipRect(r, SkMatrix::I(), kUnion_SkClipOp, doAA);
// Test that assignment works.
SkClipStack copy = s;
s.save();
REPORTER_ASSERT(reporter, 3 == s.getSaveCount());
r = SkRect::MakeLTRB(14, 15, 16, 17);
- s.clipRect(r, SkMatrix::I(), SkCanvas::kUnion_Op, doAA);
+ s.clipRect(r, SkMatrix::I(), kUnion_SkClipOp, doAA);
REPORTER_ASSERT(reporter, s == copy);
// Test that a different op on one level triggers not equal.
s.save();
REPORTER_ASSERT(reporter, 3 == s.getSaveCount());
r = SkRect::MakeLTRB(14, 15, 16, 17);
- s.clipRect(r, SkMatrix::I(), SkCanvas::kIntersect_Op, doAA);
+ s.clipRect(r, SkMatrix::I(), kIntersect_SkClipOp, doAA);
REPORTER_ASSERT(reporter, s != copy);
// Test that version constructed with rect-path rather than a rect is still considered equal.
s.save();
SkPath rp;
rp.addRect(r);
- s.clipPath(rp, SkMatrix::I(), SkCanvas::kUnion_Op, doAA);
+ s.clipPath(rp, SkMatrix::I(), kUnion_SkClipOp, doAA);
REPORTER_ASSERT(reporter, s == copy);
// Test that different rects triggers not equal.
REPORTER_ASSERT(reporter, 3 == s.getSaveCount());
r = SkRect::MakeLTRB(24, 25, 26, 27);
- s.clipRect(r, SkMatrix::I(), SkCanvas::kUnion_Op, doAA);
+ s.clipRect(r, SkMatrix::I(), kUnion_SkClipOp, doAA);
REPORTER_ASSERT(reporter, s != copy);
// Sanity check
REPORTER_ASSERT(reporter, 1 == s.getSaveCount());
p.addRect(r);
- s.clipPath(p, SkMatrix::I(), SkCanvas::kIntersect_Op, doAA);
+ s.clipPath(p, SkMatrix::I(), kIntersect_SkClipOp, doAA);
REPORTER_ASSERT(reporter, s != copy);
}
for (size_t i = 0; i < SK_ARRAY_COUNT(gRects); i++) {
// the union op will prevent these from being fused together
- stack.clipRect(gRects[i], SkMatrix::I(), SkCanvas::kUnion_Op, false);
+ stack.clipRect(gRects[i], SkMatrix::I(), kUnion_SkClipOp, false);
}
assert_count(reporter, stack, 4);
SkClipStack::Iter iter(stack, SkClipStack::Iter::kBottom_IterStart);
- element = iter.skipToTopmost(SkCanvas::kUnion_Op);
+ element = iter.skipToTopmost(kUnion_SkClipOp);
REPORTER_ASSERT(reporter, SkClipStack::Element::kRect_Type == element->getType());
REPORTER_ASSERT(reporter, element->getRect() == gRects[3]);
}
{ 10, 10, 50, 50 },
};
- static const SkCanvas::ClipOp gOps[] = {
- SkCanvas::kIntersect_Op,
- SkCanvas::kDifference_Op,
- SkCanvas::kUnion_Op,
- SkCanvas::kXOR_Op,
- SkCanvas::kReverseDifference_Op
+ static const SkClipOp gOps[] = {
+ kIntersect_SkClipOp,
+ kDifference_SkClipOp,
+ kUnion_SkClipOp,
+ kXOR_SkClipOp,
+ kReverseDifference_SkClipOp
};
SkRect rectA, rectB;
SkDEBUGFAIL("Don't call this with kEmpty.");
break;
case SkClipStack::Element::kRect_Type:
- stack.clipRect(rectA, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipRect(rectA, SkMatrix::I(), kIntersect_SkClipOp, false);
stack.clipRect(rectB, SkMatrix::I(), gOps[op], false);
break;
case SkClipStack::Element::kRRect_Type:
- stack.clipRRect(rrectA, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipRRect(rrectA, SkMatrix::I(), kIntersect_SkClipOp, false);
stack.clipRRect(rrectB, SkMatrix::I(), gOps[op], false);
break;
case SkClipStack::Element::kPath_Type:
- stack.clipPath(pathA, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipPath(pathA, SkMatrix::I(), kIntersect_SkClipOp, false);
stack.clipPath(pathB, SkMatrix::I(), gOps[op], false);
break;
}
if (SkClipStack::Element::kRect_Type == primType) {
REPORTER_ASSERT(reporter, isIntersectionOfRects ==
- (gOps[op] == SkCanvas::kIntersect_Op));
+ (gOps[op] == kIntersect_SkClipOp));
} else {
REPORTER_ASSERT(reporter, !isIntersectionOfRects);
}
clipB.addRoundRect(rectB, SkIntToScalar(5), SkIntToScalar(5));
clipB.setFillType(SkPath::kInverseEvenOdd_FillType);
- stack.clipPath(clipA, SkMatrix::I(), SkCanvas::kReplace_Op, false);
- stack.clipPath(clipB, SkMatrix::I(), SkCanvas::kUnion_Op, false);
+ stack.clipPath(clipA, SkMatrix::I(), kReplace_SkClipOp, false);
+ stack.clipPath(clipB, SkMatrix::I(), kUnion_SkClipOp, false);
REPORTER_ASSERT(reporter, stack.isWideOpen());
REPORTER_ASSERT(reporter, SkClipStack::kWideOpenGenID == stack.getTopmostGenID());
{
SkClipStack stack;
- stack.clipRect(rectA, SkMatrix::I(), SkCanvas::kUnion_Op, false);
+ stack.clipRect(rectA, SkMatrix::I(), kUnion_SkClipOp, false);
REPORTER_ASSERT(reporter, stack.isWideOpen());
REPORTER_ASSERT(reporter, SkClipStack::kWideOpenGenID == stack.getTopmostGenID());
SkRect emptyRect;
emptyRect.setEmpty();
- stack.clipRect(emptyRect, SkMatrix::I(), SkCanvas::kDifference_Op, false);
+ stack.clipRect(emptyRect, SkMatrix::I(), kDifference_SkClipOp, false);
REPORTER_ASSERT(reporter, stack.isWideOpen());
REPORTER_ASSERT(reporter, SkClipStack::kWideOpenGenID == stack.getTopmostGenID());
stack.save();
- stack.clipRect(rectA, SkMatrix::I(), SkCanvas::kReplace_Op, false);
+ stack.clipRect(rectA, SkMatrix::I(), kReplace_SkClipOp, false);
REPORTER_ASSERT(reporter, !stack.isWideOpen());
REPORTER_ASSERT(reporter, SkClipStack::kWideOpenGenID != stack.getTopmostGenID());
path.addRect(rect);
path.toggleInverseFillType();
SkClipStack stack;
- stack.clipPath(path, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipPath(path, SkMatrix::I(), kIntersect_SkClipOp, false);
SkRect bounds;
SkClipStack::BoundsType boundsType;
{
SkClipStack stack;
REPORTER_ASSERT(reporter, 0 == count(stack));
- stack.clipRect(rect, SkMatrix::I(), SkCanvas::kReplace_Op, false);
+ stack.clipRect(rect, SkMatrix::I(), kReplace_SkClipOp, false);
REPORTER_ASSERT(reporter, 1 == count(stack));
- stack.clipRect(rect, SkMatrix::I(), SkCanvas::kReplace_Op, false);
+ stack.clipRect(rect, SkMatrix::I(), kReplace_SkClipOp, false);
REPORTER_ASSERT(reporter, 1 == count(stack));
}
{
SkClipStack stack;
REPORTER_ASSERT(reporter, 0 == count(stack));
- stack.clipRect(rect, SkMatrix::I(), SkCanvas::kReplace_Op, true);
+ stack.clipRect(rect, SkMatrix::I(), kReplace_SkClipOp, true);
REPORTER_ASSERT(reporter, 1 == count(stack));
- stack.clipRect(rect, SkMatrix::I(), SkCanvas::kReplace_Op, true);
+ stack.clipRect(rect, SkMatrix::I(), kReplace_SkClipOp, true);
REPORTER_ASSERT(reporter, 1 == count(stack));
}
{
SkClipStack stack;
REPORTER_ASSERT(reporter, 0 == count(stack));
- stack.clipRect(rect, SkMatrix::I(), SkCanvas::kReplace_Op, false);
+ stack.clipRect(rect, SkMatrix::I(), kReplace_SkClipOp, false);
REPORTER_ASSERT(reporter, 1 == count(stack));
- stack.clipRect(rect, SkMatrix::I(), SkCanvas::kReplace_Op, true);
+ stack.clipRect(rect, SkMatrix::I(), kReplace_SkClipOp, true);
REPORTER_ASSERT(reporter, 1 == count(stack));
- stack.clipRect(rect, SkMatrix::I(), SkCanvas::kReplace_Op, false);
+ stack.clipRect(rect, SkMatrix::I(), kReplace_SkClipOp, false);
REPORTER_ASSERT(reporter, 1 == count(stack));
}
// Make sure replace clip rects don't collapse too much.
{
SkClipStack stack;
- stack.clipRect(rect, SkMatrix::I(), SkCanvas::kReplace_Op, false);
- stack.clipRect(rect2, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipRect(rect, SkMatrix::I(), kReplace_SkClipOp, false);
+ stack.clipRect(rect2, SkMatrix::I(), kIntersect_SkClipOp, false);
REPORTER_ASSERT(reporter, 1 == count(stack));
stack.save();
- stack.clipRect(rect, SkMatrix::I(), SkCanvas::kReplace_Op, false);
+ stack.clipRect(rect, SkMatrix::I(), kReplace_SkClipOp, false);
REPORTER_ASSERT(reporter, 2 == count(stack));
stack.getBounds(&bound, &type, &isIntersectionOfRects);
REPORTER_ASSERT(reporter, bound == rect);
REPORTER_ASSERT(reporter, 1 == count(stack));
stack.save();
- stack.clipRect(rect, SkMatrix::I(), SkCanvas::kReplace_Op, false);
- stack.clipRect(rect, SkMatrix::I(), SkCanvas::kReplace_Op, false);
+ stack.clipRect(rect, SkMatrix::I(), kReplace_SkClipOp, false);
+ stack.clipRect(rect, SkMatrix::I(), kReplace_SkClipOp, false);
REPORTER_ASSERT(reporter, 2 == count(stack));
stack.restore();
REPORTER_ASSERT(reporter, 1 == count(stack));
stack.save();
- stack.clipRect(rect, SkMatrix::I(), SkCanvas::kReplace_Op, false);
- stack.clipRect(rect2, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
- stack.clipRect(rect, SkMatrix::I(), SkCanvas::kReplace_Op, false);
+ stack.clipRect(rect, SkMatrix::I(), kReplace_SkClipOp, false);
+ stack.clipRect(rect2, SkMatrix::I(), kIntersect_SkClipOp, false);
+ stack.clipRect(rect, SkMatrix::I(), kReplace_SkClipOp, false);
REPORTER_ASSERT(reporter, 2 == count(stack));
stack.restore();
REPORTER_ASSERT(reporter, 1 == count(stack));
{
SkClipStack stack;
REPORTER_ASSERT(reporter, 0 == count(stack));
- stack.clipPath(path, SkMatrix::I(), SkCanvas::kReplace_Op, false);
+ stack.clipPath(path, SkMatrix::I(), kReplace_SkClipOp, false);
REPORTER_ASSERT(reporter, 1 == count(stack));
- stack.clipPath(path, SkMatrix::I(), SkCanvas::kReplace_Op, false);
+ stack.clipPath(path, SkMatrix::I(), kReplace_SkClipOp, false);
REPORTER_ASSERT(reporter, 1 == count(stack));
}
// Replacing rect with path.
{
SkClipStack stack;
- stack.clipRect(rect, SkMatrix::I(), SkCanvas::kReplace_Op, true);
+ stack.clipRect(rect, SkMatrix::I(), kReplace_SkClipOp, true);
REPORTER_ASSERT(reporter, 1 == count(stack));
- stack.clipPath(path, SkMatrix::I(), SkCanvas::kReplace_Op, true);
+ stack.clipPath(path, SkMatrix::I(), kReplace_SkClipOp, true);
REPORTER_ASSERT(reporter, 1 == count(stack));
}
}
{
SkClipStack stack;
- stack.clipRect(overlapLeft, SkMatrix::I(), SkCanvas::kReplace_Op, false);
+ stack.clipRect(overlapLeft, SkMatrix::I(), kReplace_SkClipOp, false);
- stack.clipRect(overlapRight, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipRect(overlapRight, SkMatrix::I(), kIntersect_SkClipOp, false);
REPORTER_ASSERT(reporter, 1 == count(stack));
{
SkClipStack stack;
- stack.clipRect(overlapLeft, SkMatrix::I(), SkCanvas::kReplace_Op, true);
+ stack.clipRect(overlapLeft, SkMatrix::I(), kReplace_SkClipOp, true);
- stack.clipRect(overlapRight, SkMatrix::I(), SkCanvas::kIntersect_Op, true);
+ stack.clipRect(overlapRight, SkMatrix::I(), kIntersect_SkClipOp, true);
REPORTER_ASSERT(reporter, 1 == count(stack));
{
SkClipStack stack;
- stack.clipRect(overlapLeft, SkMatrix::I(), SkCanvas::kReplace_Op, true);
+ stack.clipRect(overlapLeft, SkMatrix::I(), kReplace_SkClipOp, true);
- stack.clipRect(overlapRight, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipRect(overlapRight, SkMatrix::I(), kIntersect_SkClipOp, false);
REPORTER_ASSERT(reporter, 2 == count(stack));
{
SkClipStack stack;
- stack.clipRect(nestedParent, SkMatrix::I(), SkCanvas::kReplace_Op, true);
+ stack.clipRect(nestedParent, SkMatrix::I(), kReplace_SkClipOp, true);
- stack.clipRect(nestedChild, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipRect(nestedChild, SkMatrix::I(), kIntersect_SkClipOp, false);
REPORTER_ASSERT(reporter, 1 == count(stack));
{
SkClipStack stack;
- stack.clipRect(nestedParent, SkMatrix::I(), SkCanvas::kReplace_Op, false);
+ stack.clipRect(nestedParent, SkMatrix::I(), kReplace_SkClipOp, false);
- stack.clipRect(nestedChild, SkMatrix::I(), SkCanvas::kIntersect_Op, true);
+ stack.clipRect(nestedChild, SkMatrix::I(), kIntersect_SkClipOp, true);
REPORTER_ASSERT(reporter, 1 == count(stack));
{
SkClipStack stack;
- stack.clipRect(nestedChild, SkMatrix::I(), SkCanvas::kReplace_Op, false);
+ stack.clipRect(nestedChild, SkMatrix::I(), kReplace_SkClipOp, false);
- stack.clipRect(nestedParent, SkMatrix::I(), SkCanvas::kIntersect_Op, true);
+ stack.clipRect(nestedParent, SkMatrix::I(), kIntersect_SkClipOp, true);
REPORTER_ASSERT(reporter, 2 == count(stack));
{
SkClipStack stack;
- stack.clipRect(outsideRect, SkMatrix::I(), SkCanvas::kDifference_Op, false);
- // return false because quickContains currently does not care for kDifference_Op
+ stack.clipRect(outsideRect, SkMatrix::I(), kDifference_SkClipOp, false);
+ // return false because quickContains currently does not care for kDifference_SkClipOp
REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
}
// Replace Op tests
{
SkClipStack stack;
- stack.clipRect(outsideRect, SkMatrix::I(), SkCanvas::kReplace_Op, false);
+ stack.clipRect(outsideRect, SkMatrix::I(), kReplace_SkClipOp, false);
REPORTER_ASSERT(reporter, true == stack.quickContains(testRect));
}
{
SkClipStack stack;
- stack.clipRect(insideRect, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipRect(insideRect, SkMatrix::I(), kIntersect_SkClipOp, false);
stack.save(); // To prevent in-place substitution by replace OP
- stack.clipRect(outsideRect, SkMatrix::I(), SkCanvas::kReplace_Op, false);
+ stack.clipRect(outsideRect, SkMatrix::I(), kReplace_SkClipOp, false);
REPORTER_ASSERT(reporter, true == stack.quickContains(testRect));
stack.restore();
}
{
SkClipStack stack;
- stack.clipRect(outsideRect, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipRect(outsideRect, SkMatrix::I(), kIntersect_SkClipOp, false);
stack.save(); // To prevent in-place substitution by replace OP
- stack.clipRect(insideRect, SkMatrix::I(), SkCanvas::kReplace_Op, false);
+ stack.clipRect(insideRect, SkMatrix::I(), kReplace_SkClipOp, false);
REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
stack.restore();
}
// Verify proper traversal of multi-element clip
{
SkClipStack stack;
- stack.clipRect(insideRect, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipRect(insideRect, SkMatrix::I(), kIntersect_SkClipOp, false);
// Use a path for second clip to prevent in-place intersection
- stack.clipPath(outsideCircle, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipPath(outsideCircle, SkMatrix::I(), kIntersect_SkClipOp, false);
REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
}
// Intersect Op tests with rectangles
{
SkClipStack stack;
- stack.clipRect(outsideRect, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipRect(outsideRect, SkMatrix::I(), kIntersect_SkClipOp, false);
REPORTER_ASSERT(reporter, true == stack.quickContains(testRect));
}
{
SkClipStack stack;
- stack.clipRect(insideRect, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipRect(insideRect, SkMatrix::I(), kIntersect_SkClipOp, false);
REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
}
{
SkClipStack stack;
- stack.clipRect(intersectingRect, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipRect(intersectingRect, SkMatrix::I(), kIntersect_SkClipOp, false);
REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
}
{
SkClipStack stack;
- stack.clipRect(nonIntersectingRect, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipRect(nonIntersectingRect, SkMatrix::I(), kIntersect_SkClipOp, false);
REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
}
// Intersect Op tests with circle paths
{
SkClipStack stack;
- stack.clipPath(outsideCircle, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipPath(outsideCircle, SkMatrix::I(), kIntersect_SkClipOp, false);
REPORTER_ASSERT(reporter, true == stack.quickContains(testRect));
}
{
SkClipStack stack;
- stack.clipPath(insideCircle, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipPath(insideCircle, SkMatrix::I(), kIntersect_SkClipOp, false);
REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
}
{
SkClipStack stack;
- stack.clipPath(intersectingCircle, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipPath(intersectingCircle, SkMatrix::I(), kIntersect_SkClipOp, false);
REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
}
{
SkClipStack stack;
- stack.clipPath(nonIntersectingCircle, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipPath(nonIntersectingCircle, SkMatrix::I(), kIntersect_SkClipOp, false);
REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
}
SkPath path;
path.addRect(outsideRect);
path.toggleInverseFillType();
- stack.clipPath(path, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipPath(path, SkMatrix::I(), kIntersect_SkClipOp, false);
REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
}
SkPath path;
path.addRect(insideRect);
path.toggleInverseFillType();
- stack.clipPath(path, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipPath(path, SkMatrix::I(), kIntersect_SkClipOp, false);
REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
}
SkPath path;
path.addRect(intersectingRect);
path.toggleInverseFillType();
- stack.clipPath(path, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipPath(path, SkMatrix::I(), kIntersect_SkClipOp, false);
REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
}
SkPath path;
path.addRect(nonIntersectingRect);
path.toggleInverseFillType();
- stack.clipPath(path, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipPath(path, SkMatrix::I(), kIntersect_SkClipOp, false);
REPORTER_ASSERT(reporter, true == stack.quickContains(testRect));
}
SkClipStack stack;
SkPath path = outsideCircle;
path.toggleInverseFillType();
- stack.clipPath(path, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipPath(path, SkMatrix::I(), kIntersect_SkClipOp, false);
REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
}
SkClipStack stack;
SkPath path = insideCircle;
path.toggleInverseFillType();
- stack.clipPath(path, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipPath(path, SkMatrix::I(), kIntersect_SkClipOp, false);
REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
}
SkClipStack stack;
SkPath path = intersectingCircle;
path.toggleInverseFillType();
- stack.clipPath(path, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipPath(path, SkMatrix::I(), kIntersect_SkClipOp, false);
REPORTER_ASSERT(reporter, false == stack.quickContains(testRect));
}
SkClipStack stack;
SkPath path = nonIntersectingCircle;
path.toggleInverseFillType();
- stack.clipPath(path, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipPath(path, SkMatrix::I(), kIntersect_SkClipOp, false);
REPORTER_ASSERT(reporter, true == stack.quickContains(testRect));
}
}
static void test_invfill_diff_bug(skiatest::Reporter* reporter) {
SkClipStack stack;
- stack.clipRect({10, 10, 20, 20}, SkMatrix::I(), SkCanvas::kIntersect_Op, false);
+ stack.clipRect({10, 10, 20, 20}, SkMatrix::I(), kIntersect_SkClipOp, false);
SkPath path;
path.addRect({30, 10, 40, 20});
path.setFillType(SkPath::kInverseWinding_FillType);
- stack.clipPath(path, SkMatrix::I(), SkCanvas::kDifference_Op, false);
+ stack.clipPath(path, SkMatrix::I(), kDifference_SkClipOp, false);
REPORTER_ASSERT(reporter, SkClipStack::kEmptyGenID == stack.getTopmostGenID());
// reduced stack.
typedef void (*AddElementFunc) (const SkRect& rect,
bool invert,
- SkCanvas::ClipOp op,
+ SkClipOp op,
SkClipStack* stack,
bool doAA);
-static void add_round_rect(const SkRect& rect, bool invert, SkCanvas::ClipOp op, SkClipStack* stack,
+static void add_round_rect(const SkRect& rect, bool invert, SkClipOp op, SkClipStack* stack,
bool doAA) {
SkScalar rx = rect.width() / 10;
SkScalar ry = rect.height() / 20;
}
};
-static void add_rect(const SkRect& rect, bool invert, SkCanvas::ClipOp op, SkClipStack* stack,
+static void add_rect(const SkRect& rect, bool invert, SkClipOp op, SkClipStack* stack,
bool doAA) {
if (invert) {
SkPath path;
}
};
-static void add_oval(const SkRect& rect, bool invert, SkCanvas::ClipOp op, SkClipStack* stack,
+static void add_oval(const SkRect& rect, bool invert, SkClipOp op, SkClipStack* stack,
bool doAA) {
SkPath path;
path.addOval(rect);
static const SkScalar kMinElemSizeFrac = SK_Scalar1 / 5;
static const SkScalar kMaxElemSizeFrac = SK_Scalar1;
- static const SkCanvas::ClipOp kOps[] = {
- SkCanvas::kDifference_Op,
- SkCanvas::kIntersect_Op,
- SkCanvas::kUnion_Op,
- SkCanvas::kXOR_Op,
- SkCanvas::kReverseDifference_Op,
- SkCanvas::kReplace_Op,
+ static const SkClipOp kOps[] = {
+ kDifference_SkClipOp,
+ kIntersect_SkClipOp,
+ kUnion_SkClipOp,
+ kXOR_SkClipOp,
+ kReverseDifference_SkClipOp,
+ kReplace_SkClipOp,
};
// Replace operations short-circuit the optimizer. We want to make sure that we test this code
int numElems = r.nextRangeU(kMinElemsPerTest, kMaxElemsPerTest);
bool doAA = r.nextBiasedBool(kFractionAntialiased);
for (int e = 0; e < numElems; ++e) {
- SkCanvas::ClipOp op = kOps[r.nextULessThan(SK_ARRAY_COUNT(kOps))];
- if (op == SkCanvas::kReplace_Op) {
+ SkClipOp op = kOps[r.nextULessThan(SK_ARRAY_COUNT(kOps))];
+ if (op == kReplace_SkClipOp) {
if (r.nextU() % kReplaceDiv) {
--e;
continue;
SkIRect ibounds = reduced->hasIBounds() ? reduced->ibounds() : kIBounds;
// GrReducedClipStack assumes that the final result is clipped to the returned bounds
- reducedStack.clipDevRect(ibounds, SkCanvas::kIntersect_Op);
- stack.clipDevRect(ibounds, SkCanvas::kIntersect_Op);
+ reducedStack.clipDevRect(ibounds, kIntersect_SkClipOp);
+ stack.clipDevRect(ibounds, kIntersect_SkClipOp);
// convert both the original stack and reduced stack to SkRegions and see if they're equal
SkRegion region;
static void test_reduced_clip_stack_genid(skiatest::Reporter* reporter) {
{
SkClipStack stack;
- stack.clipRect(SkRect::MakeXYWH(0, 0, 100, 100), SkMatrix::I(), SkCanvas::kReplace_Op,
+ stack.clipRect(SkRect::MakeXYWH(0, 0, 100, 100), SkMatrix::I(), kReplace_SkClipOp,
true);
stack.clipRect(SkRect::MakeXYWH(0, 0, SkScalar(50.3), SkScalar(50.3)), SkMatrix::I(),
- SkCanvas::kReplace_Op, true);
+ kReplace_SkClipOp, true);
SkRect bounds = SkRect::MakeXYWH(0, 0, 100, 100);
SkAlignedSTStorage<1, GrReducedClip> storage;
// C D
stack.clipRect(SkRect::MakeXYWH(0, 0, SkScalar(25.3), SkScalar(25.3)), SkMatrix::I(),
- SkCanvas::kReplace_Op, true);
+ kReplace_SkClipOp, true);
int32_t genIDA = stack.getTopmostGenID();
stack.clipRect(SkRect::MakeXYWH(50, 0, SkScalar(25.3), SkScalar(25.3)), SkMatrix::I(),
- SkCanvas::kUnion_Op, true);
+ kUnion_SkClipOp, true);
int32_t genIDB = stack.getTopmostGenID();
stack.clipRect(SkRect::MakeXYWH(0, 50, SkScalar(25.3), SkScalar(25.3)), SkMatrix::I(),
- SkCanvas::kUnion_Op, true);
+ kUnion_SkClipOp, true);
int32_t genIDC = stack.getTopmostGenID();
stack.clipRect(SkRect::MakeXYWH(50, 50, SkScalar(25.3), SkScalar(25.3)), SkMatrix::I(),
- SkCanvas::kUnion_Op, true);
+ kUnion_SkClipOp, true);
int32_t genIDD = stack.getTopmostGenID();
static void test_reduced_clip_stack_no_aa_crash(skiatest::Reporter* reporter) {
SkClipStack stack;
- stack.clipDevRect(SkIRect::MakeXYWH(0, 0, 100, 100), SkCanvas::kReplace_Op);
- stack.clipDevRect(SkIRect::MakeXYWH(0, 0, 50, 50), SkCanvas::kReplace_Op);
+ stack.clipDevRect(SkIRect::MakeXYWH(0, 0, 100, 100), kReplace_SkClipOp);
+ stack.clipDevRect(SkIRect::MakeXYWH(0, 0, 50, 50), kReplace_SkClipOp);
SkRect bounds = SkRect::MakeXYWH(0, 0, 100, 100);
// At the time, this would crash.
// Pixel-aligned rect (iior=true).
name.printf("Pixel-aligned rect test, iter %i", i);
SkClipStack stack;
- stack.clipRect(alignedRect, SkMatrix::I(), SkCanvas::kIntersect_Op, true);
+ stack.clipRect(alignedRect, SkMatrix::I(), kIntersect_SkClipOp, true);
test_aa_query(reporter, name, stack, m, {IL, IT, IR, IB}, ClipMethod::kIgnoreClip);
test_aa_query(reporter, name, stack, m, {IL, IT-1, IR, IT}, ClipMethod::kSkipDraw);
test_aa_query(reporter, name, stack, m, {IL, IT-2, IR, IB}, ClipMethod::kScissor);
// Rect (iior=true).
name.printf("Rect test, iter %i", i);
stack.reset();
- stack.clipRect(rect, SkMatrix::I(), SkCanvas::kIntersect_Op, true);
+ stack.clipRect(rect, SkMatrix::I(), kIntersect_SkClipOp, true);
test_aa_query(reporter, name, stack, m, {L, T, R, B}, ClipMethod::kIgnoreClip);
test_aa_query(reporter, name, stack, m, {L-.1f, T, L, B}, ClipMethod::kSkipDraw);
test_aa_query(reporter, name, stack, m, {L-.1f, T, L+.1f, B}, ClipMethod::kAAElements, 1);
// Difference rect (iior=false, inside-out bounds).
name.printf("Difference rect test, iter %i", i);
stack.reset();
- stack.clipRect(rect, SkMatrix::I(), SkCanvas::kDifference_Op, true);
+ stack.clipRect(rect, SkMatrix::I(), kDifference_SkClipOp, true);
test_aa_query(reporter, name, stack, m, {L, T, R, B}, ClipMethod::kSkipDraw);
test_aa_query(reporter, name, stack, m, {L, T-.1f, R, T}, ClipMethod::kIgnoreClip);
test_aa_query(reporter, name, stack, m, {L, T-.1f, R, T+.1f}, ClipMethod::kAAElements, 1);
// Complex clip (iior=false, normal bounds).
name.printf("Complex clip test, iter %i", i);
stack.reset();
- stack.clipRect(rect, SkMatrix::I(), SkCanvas::kIntersect_Op, true);
- stack.clipRect(innerRect, SkMatrix::I(), SkCanvas::kXOR_Op, true);
+ stack.clipRect(rect, SkMatrix::I(), kIntersect_SkClipOp, true);
+ stack.clipRect(innerRect, SkMatrix::I(), kXOR_SkClipOp, true);
test_aa_query(reporter, name, stack, m, {l, t, r, b}, ClipMethod::kSkipDraw);
test_aa_query(reporter, name, stack, m, {r-.1f, t, R, b}, ClipMethod::kAAElements, 1);
test_aa_query(reporter, name, stack, m, {r-.1f, t, R+.1f, b}, ClipMethod::kAAElements, 2);
// Complex clip where outer rect is pixel aligned (iior=false, normal bounds).
name.printf("Aligned Complex clip test, iter %i", i);
stack.reset();
- stack.clipRect(alignedRect, SkMatrix::I(), SkCanvas::kIntersect_Op, true);
- stack.clipRect(innerRect, SkMatrix::I(), SkCanvas::kXOR_Op, true);
+ stack.clipRect(alignedRect, SkMatrix::I(), kIntersect_SkClipOp, true);
+ stack.clipRect(innerRect, SkMatrix::I(), kXOR_SkClipOp, true);
test_aa_query(reporter, name, stack, m, {l, t, r, b}, ClipMethod::kSkipDraw);
test_aa_query(reporter, name, stack, m, {l, b-.1f, r, IB}, ClipMethod::kAAElements, 1);
test_aa_query(reporter, name, stack, m, {l, b-.1f, r, IB+.1f}, ClipMethod::kAAElements, 1);
{ 0, 0, 75, 75 }
};
for (size_t i = 0; i < SK_ARRAY_COUNT(gRects); i++) {
- stack.clipDevRect(gRects[i], SkCanvas::kIntersect_Op);
+ stack.clipDevRect(gRects[i], kIntersect_SkClipOp);
}
// all of the above rects should have been intersected, leaving only 1 rect
REPORTER_ASSERT(reporter, element);
REPORTER_ASSERT(reporter, SkClipStack::Element::kRect_Type == element->getType());
- REPORTER_ASSERT(reporter, SkCanvas::kIntersect_Op == element->getOp());
+ REPORTER_ASSERT(reporter, kIntersect_SkClipOp == element->getOp());
REPORTER_ASSERT(reporter, element->getRect() == answer);
// now check that we only had one in our iterator
REPORTER_ASSERT(reporter, !iter.next());
SkMatrix matrix;
matrix.setRectToRect(bounds, clip, SkMatrix::kFill_ScaleToFit);
clip.outset(SkIntToScalar(kTol), SkIntToScalar(kTol));
- surface->getCanvas()->clipRect(clip, SkCanvas::kDifference_Op);
+ surface->getCanvas()->clipRect(clip, kDifference_SkClipOp);
surface->getCanvas()->concat(matrix);
SkPaint whitePaint;
whitePaint.setColor(SK_ColorWHITE);
for (int i = 0; i < 50; ++i) {
canvas->clipPath(convexClip);
canvas->clipPath(concaveClip);
- canvas->clipPath(convexClip, SkCanvas::kIntersect_Op, true);
+ canvas->clipPath(convexClip, kIntersect_SkClipOp, true);
canvas->drawRect(SkRect::MakeWH(100, 100), SkPaint());
}
}
{
const SkPath concaveClip = make_concave_path();
for (int i = 0; i < 50; ++i) {
- canvas->clipPath(concaveClip, SkCanvas::kIntersect_Op, true);
+ canvas->clipPath(concaveClip, kIntersect_SkClipOp, true);
canvas->drawRect(SkRect::MakeWH(100, 100), SkPaint());
}
}
SkRect clipRect = SkRect::MakeWH(2, 2);
SkRect drawRect = SkRect::MakeWH(10, 10);
canvas->save();
- canvas->clipRect(clipRect, SkCanvas::kReplace_Op);
+ canvas->clipRect(clipRect, kReplace_SkClipOp);
canvas->translate(1.0f, 1.0f);
SkPaint p;
p.setColor(SK_ColorGREEN);
{
SkCanvas* canvas = recorder.beginRecording(10, 10);
canvas->clipPath(path);
- canvas->clipPath(invPath, SkCanvas::kUnion_Op);
+ canvas->clipPath(invPath, kUnion_SkClipOp);
bool nonEmpty = canvas->getClipDeviceBounds(&clipBounds);
REPORTER_ASSERT(reporter, true == nonEmpty);
REPORTER_ASSERT(reporter, 0 == clipBounds.fLeft);
}
{
SkCanvas* canvas = recorder.beginRecording(10, 10);
- canvas->clipPath(path, SkCanvas::kDifference_Op);
+ canvas->clipPath(path, kDifference_SkClipOp);
bool nonEmpty = canvas->getClipDeviceBounds(&clipBounds);
REPORTER_ASSERT(reporter, true == nonEmpty);
REPORTER_ASSERT(reporter, 0 == clipBounds.fLeft);
}
{
SkCanvas* canvas = recorder.beginRecording(10, 10);
- canvas->clipPath(path, SkCanvas::kReverseDifference_Op);
+ canvas->clipPath(path, kReverseDifference_SkClipOp);
bool nonEmpty = canvas->getClipDeviceBounds(&clipBounds);
// True clip is actually empty in this case, but the best
// determination we can make using only bounds as input is that the
}
{
SkCanvas* canvas = recorder.beginRecording(10, 10);
- canvas->clipPath(path, SkCanvas::kIntersect_Op);
- canvas->clipPath(path2, SkCanvas::kXOR_Op);
+ canvas->clipPath(path, kIntersect_SkClipOp);
+ canvas->clipPath(path2, kXOR_SkClipOp);
bool nonEmpty = canvas->getClipDeviceBounds(&clipBounds);
REPORTER_ASSERT(reporter, true == nonEmpty);
REPORTER_ASSERT(reporter, 6 == clipBounds.fLeft);
, fClipCount(0){
}
- void onClipRect(const SkRect& r, ClipOp op, ClipEdgeStyle edgeStyle) override {
+ void onClipRect(const SkRect& r, SkClipOp op, ClipEdgeStyle edgeStyle) override {
fClipCount += 1;
this->INHERITED::onClipRect(r, op, edgeStyle);
}
- void onClipRRect(const SkRRect& rrect, ClipOp op, ClipEdgeStyle edgeStyle)override {
+ void onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle edgeStyle)override {
fClipCount += 1;
this->INHERITED::onClipRRect(rrect, op, edgeStyle);
}
- void onClipPath(const SkPath& path, ClipOp op, ClipEdgeStyle edgeStyle) override {
+ void onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle edgeStyle) override {
fClipCount += 1;
this->INHERITED::onClipPath(path, op, edgeStyle);
}
- void onClipRegion(const SkRegion& deviceRgn, ClipOp op) override {
+ void onClipRegion(const SkRegion& deviceRgn, SkClipOp op) override {
fClipCount += 1;
this->INHERITED::onClipRegion(deviceRgn, op);
}
SkPictureRecorder recorder;
SkCanvas* canvas = recorder.beginRecording(10, 10);
- canvas->clipRect(SkRect::MakeEmpty(), SkCanvas::kReplace_Op);
+ canvas->clipRect(SkRect::MakeEmpty(), kReplace_SkClipOp);
// The following expanding clip should not be skipped.
- canvas->clipRect(SkRect::MakeXYWH(4, 4, 3, 3), SkCanvas::kUnion_Op);
+ canvas->clipRect(SkRect::MakeXYWH(4, 4, 3, 3), kUnion_SkClipOp);
// Draw something so the optimizer doesn't just fold the world.
SkPaint p;
p.setColor(SK_ColorBLUE);
const SkPath convexClip = make_convex_path();
const SkPath concaveClip = make_concave_path();
for (int i = 0; i < 50; ++i) {
- analyzer.analyzeClipPath(convexClip, SkCanvas::kIntersect_Op, false);
- analyzer.analyzeClipPath(convexClip, SkCanvas::kIntersect_Op, true);
- analyzer.analyzeClipPath(concaveClip, SkCanvas::kIntersect_Op, false);
+ analyzer.analyzeClipPath(convexClip, kIntersect_SkClipOp, false);
+ analyzer.analyzeClipPath(convexClip, kIntersect_SkClipOp, true);
+ analyzer.analyzeClipPath(concaveClip, kIntersect_SkClipOp, false);
}
REPORTER_ASSERT(r, analyzer.suitableForGpuRasterization());
for (int i = 0; i < 50; ++i) {
- analyzer.analyzeClipPath(concaveClip, SkCanvas::kIntersect_Op, true);
+ analyzer.analyzeClipPath(concaveClip, kIntersect_SkClipOp, true);
}
REPORTER_ASSERT(r, !analyzer.suitableForGpuRasterization());
}
static void fill_src_canvas(SkCanvas* canvas) {
canvas->save();
canvas->setMatrix(SkMatrix::I());
- canvas->clipRect(DEV_RECT_S, SkCanvas::kReplace_Op);
+ canvas->clipRect(DEV_RECT_S, kReplace_SkClipOp);
SkPaint paint;
paint.setBlendMode(SkBlendMode::kSrc);
canvas->drawBitmap(make_src_bitmap(), 0, 0, &paint);
sk_sp<SkLiteDL> p { SkLiteDL::New({2,2,3,3}) };
p->save();
- p->clipRect(SkRect{2,3,4,5}, SkCanvas::kIntersect_Op, true);
+ p->clipRect(SkRect{2,3,4,5}, kIntersect_SkClipOp, true);
p->drawRect(SkRect{0,0,9,9}, SkPaint{});
p->restore();
}
rec.reset(p.get());
c->save();
- c->clipRect(SkRect{2,3,4,5}, SkCanvas::kIntersect_Op, true);
+ c->clipRect(SkRect{2,3,4,5}, kIntersect_SkClipOp, true);
c->drawRect(SkRect{0,0,9,9}, SkPaint{});
c->restore();
}
}
canvas->save();
canvas->setMatrix(SkMatrix::I());
- canvas->clipRect(DEV_RECT_S, SkCanvas::kReplace_Op);
+ canvas->clipRect(DEV_RECT_S, kReplace_SkClipOp);
SkPaint paint;
paint.setBlendMode(SkBlendMode::kSrc);
canvas->drawBitmap(bmp, 0, 0, &paint);
SkASSERT(!large.roundOut().isEmpty());
#endif
// call the base class' version to avoid adding a draw command
- this->INHERITED::onClipRect(large, kReplace_Op, kHard_ClipEdgeStyle);
+ this->INHERITED::onClipRect(large, kReplace_SkClipOp, kHard_ClipEdgeStyle);
}
SkDebugCanvas::~SkDebugCanvas() {
public:
SkDebugClipVisitor(SkCanvas* canvas) : fCanvas(canvas) {}
- void clipRect(const SkRect& r, SkCanvas::ClipOp, bool doAA) override {
+ void clipRect(const SkRect& r, SkClipOp, bool doAA) override {
SkPaint p;
p.setColor(SK_ColorRED);
p.setStyle(SkPaint::kStroke_Style);
p.setAntiAlias(doAA);
fCanvas->drawRect(r, p);
}
- void clipRRect(const SkRRect& rr, SkCanvas::ClipOp, bool doAA) override {
+ void clipRRect(const SkRRect& rr, SkClipOp, bool doAA) override {
SkPaint p;
p.setColor(SK_ColorGREEN);
p.setStyle(SkPaint::kStroke_Style);
p.setAntiAlias(doAA);
fCanvas->drawRRect(rr, p);
}
- void clipPath(const SkPath& path, SkCanvas::ClipOp, bool doAA) override {
+ void clipPath(const SkPath& path, SkClipOp, bool doAA) override {
SkPaint p;
p.setColor(SK_ColorBLUE);
p.setStyle(SkPaint::kStroke_Style);
canvas->clear(SK_ColorWHITE);
canvas->resetMatrix();
if (!windowRect.isEmpty()) {
- canvas->clipRect(windowRect, SkCanvas::kReplace_Op);
+ canvas->clipRect(windowRect, kReplace_SkClipOp);
}
this->applyUserTransform(canvas);
canvas->save();
#define LARGE_COORD 1000000000
canvas->clipRect(SkRect::MakeLTRB(-LARGE_COORD, -LARGE_COORD, LARGE_COORD, LARGE_COORD),
- SkCanvas::kReverseDifference_Op);
+ kReverseDifference_SkClipOp);
SkPaint clipPaint;
clipPaint.setColor(fClipVizColor);
canvas->drawPaint(clipPaint);
if (!windowRect.isEmpty()) {
SkRect r = windowRect;
r.outset(SK_Scalar1, SK_Scalar1);
- canvas->clipRect(r, SkCanvas::kReplace_Op);
+ canvas->clipRect(r, kReplace_SkClipOp);
}
// visualize existing clips
SkDebugClipVisitor visitor(canvas);
if (type != SkClipStack::Element::kEmpty_Type) {
element->asPath(&operand);
}
- SkCanvas::ClipOp elementOp = element->getOp();
+ SkClipOp elementOp = element->getOp();
this->addClipStackData(devPath, operand, elementOp);
- if (elementOp == SkCanvas::kReplace_Op) {
+ if (elementOp == kReplace_SkClipOp) {
devPath = operand;
} else {
Op(devPath, operand, (SkPathOp) elementOp, &devPath);
fFilterQuality = quality;
}
-void SkDebugCanvas::onClipPath(const SkPath& path, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkDebugCanvas::onClipPath(const SkPath& path, SkClipOp op, ClipEdgeStyle edgeStyle) {
this->addDrawCommand(new SkClipPathCommand(path, op, kSoft_ClipEdgeStyle == edgeStyle));
}
-void SkDebugCanvas::onClipRect(const SkRect& rect, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkDebugCanvas::onClipRect(const SkRect& rect, SkClipOp op, ClipEdgeStyle edgeStyle) {
this->addDrawCommand(new SkClipRectCommand(rect, op, kSoft_ClipEdgeStyle == edgeStyle));
}
-void SkDebugCanvas::onClipRRect(const SkRRect& rrect, ClipOp op, ClipEdgeStyle edgeStyle) {
+void SkDebugCanvas::onClipRRect(const SkRRect& rrect, SkClipOp op, ClipEdgeStyle edgeStyle) {
this->addDrawCommand(new SkClipRRectCommand(rrect, op, kSoft_ClipEdgeStyle == edgeStyle));
}
-void SkDebugCanvas::onClipRegion(const SkRegion& region, ClipOp op) {
+void SkDebugCanvas::onClipRegion(const SkRegion& region, SkClipOp op) {
this->addDrawCommand(new SkClipRegionCommand(region, op));
}
}
void SkDebugCanvas::addClipStackData(const SkPath& devPath, const SkPath& operand,
- SkCanvas::ClipOp elementOp) {
- if (elementOp == SkCanvas::kReplace_Op) {
+ SkClipOp elementOp) {
+ if (elementOp == kReplace_SkClipOp) {
if (!lastClipStackData(devPath)) {
fSaveDevPath = operand;
}
const SkPaint*, SrcRectConstraint) override;
void onDrawBitmapNine(const SkBitmap&, const SkIRect& center, const SkRect& dst,
const SkPaint*) override;
- void onClipRect(const SkRect&, ClipOp, ClipEdgeStyle) override;
- void onClipRRect(const SkRRect&, ClipOp, ClipEdgeStyle) override;
- void onClipPath(const SkPath&, ClipOp, ClipEdgeStyle) override;
- void onClipRegion(const SkRegion& region, ClipOp) override;
+ void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
+ void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
+ void onClipPath(const SkPath&, SkClipOp, ClipEdgeStyle) override;
+ void onClipRegion(const SkRegion& region, SkClipOp) override;
void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
void resetClipStackData() { fClipStackData.reset(); fCalledAddStackData = false; }
- void addClipStackData(const SkPath& devPath, const SkPath& operand, ClipOp elementOp);
+ void addClipStackData(const SkPath& devPath, const SkPath& operand, SkClipOp elementOp);
void addPathData(const SkPath& path, const char* pathName);
bool lastClipStackData(const SkPath& devPath);
void outputConicPoints(const SkPoint* pts, SkScalar weight);
return Json::Value("<unimplemented>");
}
-static Json::Value make_json_regionop(SkCanvas::ClipOp op) {
+static Json::Value make_json_regionop(SkClipOp op) {
switch (op) {
- case SkCanvas::kDifference_Op:
+ case kDifference_SkClipOp:
return Json::Value(SKDEBUGCANVAS_REGIONOP_DIFFERENCE);
- case SkCanvas::kIntersect_Op:
+ case kIntersect_SkClipOp:
return Json::Value(SKDEBUGCANVAS_REGIONOP_INTERSECT);
- case SkCanvas::kUnion_Op:
+ case kUnion_SkClipOp:
return Json::Value(SKDEBUGCANVAS_REGIONOP_UNION);
- case SkCanvas::kXOR_Op:
+ case kXOR_SkClipOp:
return Json::Value(SKDEBUGCANVAS_REGIONOP_XOR);
- case SkCanvas::kReverseDifference_Op:
+ case kReverseDifference_SkClipOp:
return Json::Value(SKDEBUGCANVAS_REGIONOP_REVERSE_DIFFERENCE);
- case SkCanvas::kReplace_Op:
+ case kReplace_SkClipOp:
return Json::Value(SKDEBUGCANVAS_REGIONOP_REPLACE);
default:
SkASSERT(false);
}
}
-SkCanvas::ClipOp get_json_clipop(Json::Value& jsonOp) {
+SkClipOp get_json_clipop(Json::Value& jsonOp) {
const char* op = jsonOp.asCString();
if (!strcmp(op, SKDEBUGCANVAS_REGIONOP_DIFFERENCE)) {
- return SkCanvas::kDifference_Op;
+ return kDifference_SkClipOp;
}
else if (!strcmp(op, SKDEBUGCANVAS_REGIONOP_INTERSECT)) {
- return SkCanvas::kIntersect_Op;
+ return kIntersect_SkClipOp;
}
else if (!strcmp(op, SKDEBUGCANVAS_REGIONOP_UNION)) {
- return SkCanvas::kUnion_Op;
+ return kUnion_SkClipOp;
}
else if (!strcmp(op, SKDEBUGCANVAS_REGIONOP_XOR)) {
- return SkCanvas::kXOR_Op;
+ return kXOR_SkClipOp;
}
else if (!strcmp(op, SKDEBUGCANVAS_REGIONOP_REVERSE_DIFFERENCE)) {
- return SkCanvas::kReverseDifference_Op;
+ return kReverseDifference_SkClipOp;
}
else if (!strcmp(op, SKDEBUGCANVAS_REGIONOP_REPLACE)) {
- return SkCanvas::kReplace_Op;
+ return kReplace_SkClipOp;
}
SkASSERT(false);
- return SkCanvas::kIntersect_Op;
+ return kIntersect_SkClipOp;
}
SkClearCommand::SkClearCommand(SkColor color) : INHERITED(kDrawClear_OpType) {
return new SkClearCommand(get_json_color(color));
}
-SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkCanvas::ClipOp op, bool doAA)
+SkClipPathCommand::SkClipPathCommand(const SkPath& path, SkClipOp op, bool doAA)
: INHERITED(kClipPath_OpType) {
fPath = path;
fOp = op;
command[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS].asBool());
}
-SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkCanvas::ClipOp op)
+SkClipRegionCommand::SkClipRegionCommand(const SkRegion& region, SkClipOp op)
: INHERITED(kClipRegion_OpType) {
fRegion = region;
fOp = op;
return nullptr;
}
-SkClipRectCommand::SkClipRectCommand(const SkRect& rect, SkCanvas::ClipOp op, bool doAA)
+SkClipRectCommand::SkClipRectCommand(const SkRect& rect, SkClipOp op, bool doAA)
: INHERITED(kClipRect_OpType) {
fRect = rect;
fOp = op;
command[SKDEBUGCANVAS_ATTRIBUTE_ANTIALIAS].asBool());
}
-SkClipRRectCommand::SkClipRRectCommand(const SkRRect& rrect, SkCanvas::ClipOp op, bool doAA)
+SkClipRRectCommand::SkClipRRectCommand(const SkRRect& rrect, SkClipOp op, bool doAA)
: INHERITED(kClipRRect_OpType) {
fRRect = rrect;
fOp = op;
class SkClipPathCommand : public SkDrawCommand {
public:
- SkClipPathCommand(const SkPath& path, SkCanvas::ClipOp op, bool doAA);
+ SkClipPathCommand(const SkPath& path, SkClipOp op, bool doAA);
void execute(SkCanvas* canvas) const override;
bool render(SkCanvas* canvas) const override;
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
static SkClipPathCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
private:
- SkPath fPath;
- SkCanvas::ClipOp fOp;
- bool fDoAA;
+ SkPath fPath;
+ SkClipOp fOp;
+ bool fDoAA;
typedef SkDrawCommand INHERITED;
};
class SkClipRegionCommand : public SkDrawCommand {
public:
- SkClipRegionCommand(const SkRegion& region, SkCanvas::ClipOp op);
+ SkClipRegionCommand(const SkRegion& region, SkClipOp op);
void execute(SkCanvas* canvas) const override;
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
static SkClipRegionCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
private:
- SkRegion fRegion;
- SkCanvas::ClipOp fOp;
+ SkRegion fRegion;
+ SkClipOp fOp;
typedef SkDrawCommand INHERITED;
};
class SkClipRectCommand : public SkDrawCommand {
public:
- SkClipRectCommand(const SkRect& rect, SkCanvas::ClipOp op, bool doAA);
+ SkClipRectCommand(const SkRect& rect, SkClipOp op, bool doAA);
void execute(SkCanvas* canvas) const override;
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
static SkClipRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
const SkRect& rect() const { return fRect; }
- SkCanvas::ClipOp op() const { return fOp; }
+ SkClipOp op() const { return fOp; }
bool doAA() const { return fDoAA; }
private:
- SkRect fRect;
- SkCanvas::ClipOp fOp;
- bool fDoAA;
+ SkRect fRect;
+ SkClipOp fOp;
+ bool fDoAA;
typedef SkDrawCommand INHERITED;
};
class SkClipRRectCommand : public SkDrawCommand {
public:
- SkClipRRectCommand(const SkRRect& rrect, SkCanvas::ClipOp op, bool doAA);
+ SkClipRRectCommand(const SkRRect& rrect, SkClipOp op, bool doAA);
void execute(SkCanvas* canvas) const override;
bool render(SkCanvas* canvas) const override;
Json::Value toJSON(UrlDataManager& urlDataManager) const override;
static SkClipRRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
const SkRRect& rrect() const { return fRRect; }
- SkCanvas::ClipOp op() const { return fOp; }
+ SkClipOp op() const { return fOp; }
bool doAA() const { return fDoAA; }
private:
- SkRRect fRRect;
- SkCanvas::ClipOp fOp;
- bool fDoAA;
+ SkRRect fRRect;
+ SkClipOp fOp;
+ bool fDoAA;
typedef SkDrawCommand INHERITED;
};
return mRRect;
}
-SkString* SkObjectParser::ClipOpToString(SkCanvas::ClipOp op) {
+SkString* SkObjectParser::ClipOpToString(SkClipOp op) {
SkString* mOp = new SkString("SkRegion::Op: ");
- if (op == SkCanvas::kDifference_Op) {
+ if (op == kDifference_SkClipOp) {
mOp->append("kDifference_Op");
- } else if (op == SkCanvas::kIntersect_Op) {
+ } else if (op == kIntersect_SkClipOp) {
mOp->append("kIntersect_Op");
- } else if (op == SkCanvas::kUnion_Op) {
+ } else if (op == kUnion_SkClipOp) {
mOp->append("kUnion_Op");
- } else if (op == SkCanvas::kXOR_Op) {
+ } else if (op == kXOR_SkClipOp) {
mOp->append("kXOR_Op");
- } else if (op == SkCanvas::kReverseDifference_Op) {
+ } else if (op == kReverseDifference_SkClipOp) {
mOp->append("kReverseDifference_Op");
- } else if (op == SkCanvas::kReplace_Op) {
+ } else if (op == kReplace_SkClipOp) {
mOp->append("kReplace_Op");
} else {
mOp->append("Unknown Type");
Returns a string representation of the SkRegion enum.
@param op SkRegion::op enum
*/
- static SkString* ClipOpToString(SkCanvas::ClipOp op);
+ static SkString* ClipOpToString(SkClipOp op);
/**
Returns a string representation of the SkRegion.