Flutter Engine
The Flutter Engine
Classes | Functions
aaclip.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkBlendMode.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPathBuilder.h"
#include "include/core/SkRect.h"
#include "include/core/SkScalar.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "src/core/SkCanvasPriv.h"
#include "tools/ToolUtils.h"

Go to the source code of this file.

Classes

class  ClipCubicGM
 

Functions

static void draw (SkCanvas *canvas, SkRect &target, int x, int y)
 
static void draw_square (SkCanvas *canvas, int x, int y)
 
static void draw_column (SkCanvas *canvas, int x, int y)
 
static void draw_bar (SkCanvas *canvas, int x, int y)
 
static void draw_rect_tests (SkCanvas *canvas)
 
 DEF_SIMPLE_GM (aaclip, canvas, 240, 120)
 

Function Documentation

◆ DEF_SIMPLE_GM()

DEF_SIMPLE_GM ( aaclip  ,
canvas  ,
240  ,
120   
)

Test a set of clipping problems discovered while writing blitAntiRect, and test all the code paths through the clipping blitters. Each region should show as a blue center surrounded by a 2px green border, with no red.

Definition at line 77 of file aaclip.cpp.

77 {
78 // Initial pixel-boundary-aligned draw
79 draw_rect_tests(canvas);
80
81 // Repeat 4x with .2, .4, .6, .8 px offsets
82 canvas->translate(SK_Scalar1 / 5, SK_Scalar1 / 5);
83 canvas->translate(SkIntToScalar(50), 0);
84 draw_rect_tests(canvas);
85
86 canvas->translate(SK_Scalar1 / 5, SK_Scalar1 / 5);
87 canvas->translate(SkIntToScalar(50), 0);
88 draw_rect_tests(canvas);
89
90 canvas->translate(SK_Scalar1 / 5, SK_Scalar1 / 5);
91 canvas->translate(SkIntToScalar(50), 0);
92 draw_rect_tests(canvas);
93
94 canvas->translate(SK_Scalar1 / 5, SK_Scalar1 / 5);
95 canvas->translate(SkIntToScalar(50), 0);
96 draw_rect_tests(canvas);
97}
#define SK_Scalar1
Definition: SkScalar.h:18
#define SkIntToScalar(x)
Definition: SkScalar.h:57
static void draw_rect_tests(SkCanvas *canvas)
Definition: aaclip.cpp:65

◆ draw()

static void draw ( SkCanvas canvas,
SkRect target,
int  x,
int  y 
)
static

Draw a 2px border around the target, then red behind the target; set the clip to match the target, then draw >> the target in blue.

Definition at line 27 of file aaclip.cpp.

27 {
28 SkPaint borderPaint;
29 borderPaint.setColor(SkColorSetRGB(0x0, 0xDD, 0x0));
30 borderPaint.setAntiAlias(true);
31 SkPaint backgroundPaint;
32 backgroundPaint.setColor(SkColorSetRGB(0xDD, 0x0, 0x0));
33 backgroundPaint.setAntiAlias(true);
34 SkPaint foregroundPaint;
35 foregroundPaint.setColor(SkColorSetRGB(0x0, 0x0, 0xDD));
36 foregroundPaint.setAntiAlias(true);
37
38 canvas->save();
40 target.inset(SkIntToScalar(-2), SkIntToScalar(-2));
41 canvas->drawRect(target, borderPaint);
43 canvas->drawRect(target, backgroundPaint);
44 canvas->clipRect(target, true);
45 target.inset(SkIntToScalar(-4), SkIntToScalar(-4));
46 canvas->drawRect(target, foregroundPaint);
47 canvas->restore();
48}
#define SkColorSetRGB(r, g, b)
Definition: SkColor.h:57
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
int save()
Definition: SkCanvas.cpp:447
void setColor(SkColor color)
Definition: SkPaint.cpp:119
void setAntiAlias(bool aa)
Definition: SkPaint.h:170
uint32_t * target
double y
double x

◆ draw_bar()

static void draw_bar ( SkCanvas canvas,
int  x,
int  y 
)
static

Definition at line 60 of file aaclip.cpp.

60 {
62 draw(canvas, target, x, y);
63}
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609

◆ draw_column()

static void draw_column ( SkCanvas canvas,
int  x,
int  y 
)
static

Definition at line 55 of file aaclip.cpp.

55 {
57 draw(canvas, target, x, y);
58}

◆ draw_rect_tests()

static void draw_rect_tests ( SkCanvas canvas)
static

Definition at line 65 of file aaclip.cpp.

65 {
66 draw_square(canvas, 10, 10);
67 draw_column(canvas, 30, 10);
68 draw_bar(canvas, 10, 30);
69}
static void draw_column(SkCanvas *canvas, int x, int y)
Definition: aaclip.cpp:55
static void draw_square(SkCanvas *canvas, int x, int y)
Definition: aaclip.cpp:50
static void draw_bar(SkCanvas *canvas, int x, int y)
Definition: aaclip.cpp:60

◆ draw_square()

static void draw_square ( SkCanvas canvas,
int  x,
int  y 
)
static

Definition at line 50 of file aaclip.cpp.

50 {
52 draw(canvas, target, x, y);
53}