33 auto canvas = surf->getCanvas();
38 SkPoint pt = { wScalar / 2, hScalar / 2 };
40 SkScalar radius = 3 * std::max(wScalar, hScalar);
61 for (
int i = 0; i < 4; ++i) {
68 canvas->drawRect(rect,
paint);
69 rect.inset(wScalar / 8, hScalar / 8);
76 paint.setShader(
nullptr);
78 constexpr char kTxt[] =
"Skia";
79 SkPoint texPos = { wScalar / 17, hScalar / 2 + font.getSize() / 2.5f };
87 return surf->makeImageSnapshot();
114 auto emplace_back = [](std::vector<Clip>& clips) -> Clip& {
115 clips.emplace_back();
128 for (
int i = 0; i < 6; ++i) {
139 emplace_back(fClips).setPath(hexagon.
snapshot());
149 rotM.
setRotate(23.f, rect.centerX(), rect.centerY());
150 emplace_back(fClips).setPath(
SkPath::Rect(rect).makeTransform(rotM));
165 constexpr char kTxt[] =
"Clip Me!";
173 for (
int doLayer = 0; doLayer <= testLayers; ++doLayer) {
174 for (
const Clip&
clip : fClips) {
176 for (
int aa = 0; aa < 2; ++aa) {
192 for (
int aa = 0; aa < 2; ++aa) {
196 clipOutlinePaint.
setColor(0x50505050);
211 canvas->
drawPath(closedClipPath, clipOutlinePaint);
213 canvas->
scale(1.f, 1.8f);
215 0, 1.5f * font.getSize(), font, txtPaint);
237 Clip () : fClipType(kNone_ClipType) {}
242 canvas->
clipPath(fPathBuilder.snapshot(), op, aa);
253 SkPath asClosedPath()
const {
266 void setPath(
const SkPath& path) {
267 fClipType = kPath_ClipType;
271 void setRect(
const SkRect& rect) {
272 fClipType = kRect_ClipType;
274 fPathBuilder.
reset();
277 ClipType getType()
const {
return fClipType; }
279 void getBounds(
SkRect* bounds)
const {
282 *
bounds = fPathBuilder.computeBounds();
299 std::vector<Clip> fClips;
302 using INHERITED =
GM;
305DEF_GM(
return new ConvexPolyClip;)
@ kOpaque_SkAlphaType
pixel is opaque
#define SkDEBUGFAIL(message)
constexpr SkColor SK_ColorLTGRAY
constexpr SkColor SK_ColorBLACK
constexpr SkColor SK_ColorWHITE
constexpr SkColor SK_ColorDKGRAY
@ kUTF8
uses bytes to represent UTF-8 or ASCII
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
#define SkScalarSin(radians)
#define SkScalarCeilToInt(x)
#define SkScalarCos(radians)
static constexpr bool SkToBool(const T &x)
static SkScalar center(float pos0, float pos1)
int saveLayer(const SkRect *bounds, const SkPaint *paint)
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
void drawSimpleText(const void *text, size_t byteLength, SkTextEncoding encoding, SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint)
void translate(SkScalar dx, SkScalar dy)
virtual SkISize getBaseLayerSize() const
void clipPath(const SkPath &path, SkClipOp op, bool doAntiAlias)
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
void drawPath(const SkPath &path, const SkPaint &paint)
void scale(SkScalar sx, SkScalar sy)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
static sk_sp< SkShader > MakeRadial(const SkPoint ¢er, SkScalar radius, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
SkMatrix & postScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
SkMatrix & setScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
SkMatrix & setRotate(SkScalar degrees, SkScalar px, SkScalar py)
static const SkMatrix & I()
SkMatrix & preTranslate(SkScalar dx, SkScalar dy)
void setStyle(Style style)
void setColor(SkColor color)
void setAntiAlias(bool aa)
@ kStroke_Style
set to stroke geometry
void setStrokeWidth(SkScalar width)
SkPathBuilder & lineTo(SkPoint pt)
SkPathBuilder & moveTo(SkPoint pt)
static SkPath Rect(const SkRect &, SkPathDirection=SkPathDirection::kCW, unsigned startIndex=0)
const SkRect & getBounds() const
static SkPath Polygon(const SkPoint pts[], int count, bool isClosed, SkPathFillType=SkPathFillType::kWinding, bool isVolatile=false)
SkPath makeTransform(const SkMatrix &m, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
void reset(T *ptr=nullptr)
SkISize getISize() override
void onDraw(SkCanvas *canvas) override
SkString getName() const override
void onOnceBeforeDraw() override
bool runAsBench() const override
GM(SkColor backgroundColor=SK_ColorWHITE)
static sk_sp< SkImage > make_img()
Optional< SkRect > bounds
sk_sp< SkBlender > blender SkRect rect
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
static constexpr SkISize Make(int32_t w, int32_t h)
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)
void scale(float scale, SkPoint *dst) const
static SkRect MakeIWH(int w, int h)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
static constexpr SkRect MakeWH(float w, float h)
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)