Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
drawregion.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "gm/gm.h"
11#include "include/core/SkRect.h"
13#include "include/core/SkSize.h"
15
16/**
17 * This is very similar to the RectGrid macrobench in Android.
18 */
19class DrawRegionGM : public skiagm::GM {
20public:
22
23protected:
24 SkString getName() const override { return SkString("drawregion"); }
25
26 SkISize getISize() override { return SkISize::Make(500, 500); }
27
28 bool runAsBench() const override {
29 return true;
30 }
31
32 void onOnceBeforeDraw() override {
33 for (int x = 50; x < 250; x+=2) {
34 for (int y = 50; y < 250; y+=2) {
35 fRegion.op({x, y, x + 1, y + 1}, SkRegion::kUnion_Op);
36 }
37 }
38 }
39
40 void onDraw(SkCanvas* canvas) override {
41 canvas->translate(10, 10);
42
45 paint.setColor(0xFFFF00FF);
46 canvas->drawRect(SkRect::MakeLTRB(50.0f, 50.0f, 250.0f, 250.0f), paint);
47
48 paint.setColor(0xFF00FFFF);
49 canvas->drawRegion(fRegion, paint);
50 }
51
53
54private:
55 using INHERITED = skiagm::GM;
56};
57DEF_GM( return new DrawRegionGM; )
SkISize getISize() override
void onDraw(SkCanvas *canvas) override
void onOnceBeforeDraw() override
SkString getName() const override
bool runAsBench() const override
SkRegion fRegion
void drawRect(const SkRect &rect, const SkPaint &paint)
void translate(SkScalar dx, SkScalar dy)
void drawRegion(const SkRegion &region, const SkPaint &paint)
@ kFill_Style
set to fill geometry
Definition SkPaint.h:193
@ kUnion_Op
target unioned with operand
Definition SkRegion.h:369
bool op(const SkIRect &rect, Op op)
Definition SkRegion.h:384
const Paint & paint
#define DEF_GM(CODE)
Definition gm.h:40
double y
double x
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
Definition SkRect.h:646