62 name.append(
"_draw_bw");
65 name.append(
"_draw_aa");
68 name.append(
"_clip_bw");
71 name.append(
"_clip_aa");
74 name.append(
"_effect");
93 paint.setAntiAlias(
true);
98 SkPoint pts[3] = {{0, 0}, {1.5f, 1}};
112 for (
int et = 0; et <= lastEdgeType; ++et) {
114 for (
int curRRect = 0; curRRect < kNumRRects; ++curRRect) {
117 if (curRRect != kNumRRects - 1) {
126 SkRRect rrect = fRRects[curRRect];
127 if (curRRect == kNumRRects - 1) {
128 canvas->
clipRect({0, 0, kTileX - 2, kTileY - 2});
136 const auto& caps = *rContext->priv().caps()->shaderCaps();
138 edgeType, rrect, caps);
148 bounds.outset(2.f, 2.f);
152 rContext, std::move(grPaint),
SkMatrix::I(), bounds));
168 if (
x > kImageWidth) {
197 for (
size_t i = 1; i < std::size(gRadii); ++i) {
202 fRRects[kNumRRects - 1].
setRectXY({9.f, 9.f, 1699.f, 1699.f}, 843.749f, 843.75f);
208 inline static constexpr int kImageWidth = 640;
209 inline static constexpr int kImageHeight = 480;
211 inline static constexpr int kTileX = 80;
212 inline static constexpr int kTileY = 40;
214 inline static constexpr int kNumSimpleCases = 7;
215 inline static constexpr int kNumComplexCases = 35;
217 static const SkVector gRadii[kNumComplexCases][4];
219 inline static constexpr int kNumRRects = kNumSimpleCases + kNumComplexCases + 1 ;
222 using INHERITED =
GM;
226const SkVector RRectGM::gRadii[kNumComplexCases][4] = {
228 { { kTileY, kTileY }, { kTileY, kTileY }, { kTileY, kTileY }, { kTileY, kTileY } },
231 { { 8, 8 }, { 32, 32 }, { 8, 8 }, { 32, 32 } },
232 { { 16, 8 }, { 8, 16 }, { 16, 8 }, { 8, 16 } },
233 { { 0, 0 }, { 16, 16 }, { 8, 8 }, { 32, 32 } },
236 { { 30, 30 }, { 0, 0 }, { 0, 0 }, { 0, 0 } },
237 { { 30, 15 }, { 0, 0 }, { 0, 0 }, { 0, 0 } },
238 { { 15, 30 }, { 0, 0 }, { 0, 0 }, { 0, 0 } },
241 { { 0, 0 }, { 30, 30 }, { 0, 0 }, { 0, 0 } },
242 { { 0, 0 }, { 30, 15 }, { 0, 0 }, { 0, 0 } },
243 { { 0, 0 }, { 15, 30 }, { 0, 0 }, { 0, 0 } },
246 { { 0, 0 }, { 0, 0 }, { 30, 30 }, { 0, 0 } },
247 { { 0, 0 }, { 0, 0 }, { 30, 15 }, { 0, 0 } },
248 { { 0, 0 }, { 0, 0 }, { 15, 30 }, { 0, 0 } },
251 { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 30, 30 } },
252 { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 30, 15 } },
253 { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 15, 30 } },
256 { { 0, 0 }, { 100, 400 }, { 0, 0 }, { 0, 0 } },
257 { { 0, 0 }, { 400, 400 }, { 0, 0 }, { 0, 0 } },
258 { { 400, 400 }, { 400, 400 }, { 400, 400 }, { 400, 400 } },
261 { { 0, 0 }, { 20, 20 }, { 20, 20 }, { 0, 0 } },
262 { { 20, 20 }, { 20, 20 }, { 0, 0 }, { 0, 0 } },
263 { { 0, 0 }, { 0, 0 }, { 20, 20 }, { 20, 20 } },
264 { { 20, 20 }, { 0, 0 }, { 0, 0 }, { 20, 20 } },
267 { { 0, 0 }, { 0.2f, 0.2f }, { 0.2f, 0.2f }, { 0, 0 } },
268 { { 0.3f, 0.3f }, { 0.3f, .3f }, { 0, 0 }, { 0, 0 } },
271 { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 15, 15 } },
272 { { 0, 0 }, { 0, 0 }, { 15, 15 }, { 0, 0 } },
273 { { 0, 0 }, { 15, 15 }, { 0, 0 }, { 0, 0 } },
274 { { 15, 15 }, { 0, 0 }, { 0, 0 }, { 0, 0 } },
277 { { 5, 7 }, { 8, 7 }, { 8, 12 }, { 5, 12 } },
278 { { 0, 7 }, { 8, 7 }, { 8, 12 }, { 0, 12 } },
281 { { 0.4f, 7 }, { 8, 7 }, { 8, 12 }, { 0.4f, 12 } },
282 { { 0.4f, 0.4f }, { 8, 0.4f }, { 8, 12 }, { 0.4f, 12 } },
283 { { 20, 0.4f }, { 18, 0.4f }, { 18, 0.4f }, { 20, 0.4f } },
284 { { 0.3f, 0.4f }, { 0.3f, 0.4f }, { 0.3f, 0.4f }, { 0.3f, 0.4f } },
300 canvas->
scale(0.5f, 0.5f);
301 canvas->translate(50.f, 50.f);
305 p.setAntiAlias(
true);
306 p.setStrokeWidth(
width);
308 p.setStrokeJoin(join);
311 canvas->translate(cx * 110.f, cy * 110.f);
312 float dx = cx % 2 ? 0.5f : 0.f;
313 float dy = cy % 2 ? 0.5f : 0.f;
318 rect.outset(25.f, 25.f);
322 float cornerScale = std::min(rect.width(), rect.height());
323 SkVector outerRadii[4] = { { 0.25f * cornerScale, 0.75f * cornerScale },
325 { 0.50f * cornerScale, 0.50f * cornerScale },
326 { 0.75f * cornerScale, 0.25f * cornerScale } };
329 SkVector strokeRadii[4] = { { 0.25f * cornerScale, 0.25f * cornerScale },
331 { 0.50f * cornerScale, 0.50f * cornerScale },
332 { 0.75f * cornerScale, 0.75f * cornerScale } };
341 canvas->drawRRect(r, p);
343 canvas->drawRect(rect, p);
352 for (
float width : {-1.f, 50.f, 30.f, 10.f, 1.f, 0.f}) {
369 canvas->translate(0.f, 50.f);
372 for (
float width : {-1.f, 50.f, 30.f, 10.f, 1.f, 0.f}) {
390 auto drawComplex = [&](
int cx,
int cy,
float width,
float stretch) {
392 p.setAntiAlias(
true);
393 p.setStrokeWidth(
width);
398 canvas->translate(cx * 110.f, cy * 110.f);
401 cx % 2 ? (40.f + stretch) : 50.f);
402 const SkVector kBigCorner{30.f, 30.f};
403 const SkVector kRectCorner{0.f, 0.f};
405 SkVector strokeRadii[4] = { cy % 2 ? kRectCorner : kBigCorner,
406 cy % 2 ? kBigCorner : kRectCorner,
407 cy % 2 ? kRectCorner : kBigCorner,
408 cy % 2 ? kBigCorner : kRectCorner };
412 canvas->drawRRect(r, p);
417 canvas->translate(0.f, -50.f);
419 for (
float width : {50.f, 30.f, 20.f, 10.f, 1.f, 0.f}) {
421 for (
float stretch: {0.f, 5.f, 10.f}) {
422 drawComplex(2*i, 2*j,
width, stretch);
423 drawComplex(2*i+1, 2*j,
width, stretch);
424 drawComplex(2*i, 2*j+1,
width, stretch);
425 drawComplex(2*i+1, 2*j+1,
width, stretch);
432 auto drawComplex2 = [&](
int cx,
int cy,
float width,
float stretch) {
434 p.setAntiAlias(
true);
435 p.setStrokeWidth(
width);
440 canvas->translate(cx * 110.f, cy * 110.f);
443 cx % 2 ? (40.f + stretch) : 50.f);
444 const SkVector kBigCorner{30.f, 30.f};
445 const SkVector kRectCorner{0.f, 0.f};
447 SkVector strokeRadii[4] = { cx % 2 ? kRectCorner : kBigCorner,
448 (cx % 2) ^ (cy % 2) ? kBigCorner : kRectCorner,
449 cx % 2 ? kBigCorner : kRectCorner,
450 (cx % 2) ^ (cy % 2) ? kRectCorner : kBigCorner };
454 canvas->drawRRect(r, p);
459 canvas->translate(0.f, 50.f);
461 for (
float width : {50.f, 30.f, 20.f, 10.f, 1.f, 0.f}) {
463 for (
float stretch: {0.f, 5.f, 10.f}) {
464 drawComplex2(2*i, 2*j,
width, stretch);
465 drawComplex2(2*i+1, 2*j,
width, stretch);
466 drawComplex2(2*i, 2*j+1,
width, stretch);
467 drawComplex2(2*i+1, 2*j+1,
width, stretch);
constexpr SkColor SK_ColorYELLOW
constexpr SkColor SK_ColorBLACK
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
void setXPFactory(const GrXPFactory *xpFactory)
void setColor4f(const SkPMColor4f &color)
void setCoverageFragmentProcessor(std::unique_ptr< GrFragmentProcessor > fp)
static const GrXPFactory * Get(SkBlendMode blendMode)
void drawRect(const SkRect &rect, const SkPaint &paint)
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
void translate(SkScalar dx, SkScalar dy)
SkMatrix getLocalToDeviceAs3x3() const
virtual GrRecordingContext * recordingContext() const
void drawRRect(const SkRRect &rrect, const SkPaint &paint)
void setMatrix(const SkM44 &matrix)
void clipRRect(const SkRRect &rrect, SkClipOp op, bool doAntiAlias)
static sk_sp< SkShader > MakeLinear(const SkPoint pts[2], const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
static SkMatrix Scale(SkScalar sx, SkScalar sy)
static const SkMatrix & I()
@ kStroke_Style
set to stroke geometry
@ kFill_Style
set to fill geometry
@ kMiter_Join
extends to miter limit
@ kBevel_Join
connects outside edges
const SkRect & rect() const
bool transform(const SkMatrix &matrix, SkRRect *dst) const
void setOval(const SkRect &oval)
void setRectRadii(const SkRect &rect, const SkVector radii[4])
void setRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
const SkRect & getBounds() const
void setRect(const SkRect &rect)
static GrOp::Owner MakeNonAARect(GrRecordingContext *, GrPaint &&, const SkMatrix &view, const SkRect &, const GrUserStencilSettings *=nullptr)
static constexpr char kErrorMsg_DrawSkippedGpuOnly[]
void onOnceBeforeDraw() override
SkISize getISize() override
DrawResult onDraw(SkCanvas *canvas, SkString *errorMsg) override
SkString getName() const override
#define DEF_SIMPLE_GM(NAME, CANVAS, W, H)
GrFPResult Make(std::unique_ptr< GrFragmentProcessor >, GrClipEdgeType, const SkRRect &, const GrShaderCaps &)
SurfaceDrawContext * TopDeviceSurfaceDrawContext(const SkCanvas *canvas)
static constexpr SkISize Make(int32_t w, int32_t h)
void scale(float scale, SkPoint *dst) const
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
bool contains(SkScalar x, SkScalar y) const
void offset(float dx, float dy)
constexpr float height() const
constexpr float width() const
static constexpr SkRect MakeWH(float w, float h)