Flutter Engine
The Flutter Engine
Classes | Typedefs | Functions
rrect.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPoint.h"
#include "include/core/SkRRect.h"
#include "include/core/SkRect.h"
#include "include/core/SkScalar.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/core/SkTypes.h"
#include "tools/ToolUtils.h"

Go to the source code of this file.

Classes

class  RRectGM
 

Typedefs

typedef void(* InsetProc) (const SkRRect &, SkScalar dx, SkScalar dy, SkRRect *)
 

Functions

static void inset0 (const SkRRect &src, SkScalar dx, SkScalar dy, SkRRect *dst)
 
static void inset1 (const SkRRect &src, SkScalar dx, SkScalar dy, SkRRect *dst)
 
static void inset2 (const SkRRect &src, SkScalar dx, SkScalar dy, SkRRect *dst)
 
static SkScalar prop (SkScalar radius, SkScalar newSize, SkScalar oldSize)
 
static void inset3 (const SkRRect &src, SkScalar dx, SkScalar dy, SkRRect *dst)
 
static void draw_rrect_color (SkCanvas *canvas, const SkRRect &rrect)
 
static void drawrr (SkCanvas *canvas, const SkRRect &rrect, InsetProc proc)
 

Typedef Documentation

◆ InsetProc

typedef void(* InsetProc) (const SkRRect &, SkScalar dx, SkScalar dy, SkRRect *)

Definition at line 21 of file rrect.cpp.

Function Documentation

◆ draw_rrect_color()

static void draw_rrect_color ( SkCanvas canvas,
const SkRRect rrect 
)
static

Definition at line 107 of file rrect.cpp.

107 {
109 paint.setAntiAlias(true);
111
112 if (rrect.isRect()) {
113 paint.setColor(SK_ColorRED);
114 } else if (rrect.isOval()) {
115 paint.setColor(ToolUtils::color_to_565(0xFF008800));
116 } else if (rrect.isSimple()) {
117 paint.setColor(SK_ColorBLUE);
118 } else {
119 paint.setColor(SK_ColorBLACK);
120 }
121 canvas->drawRRect(rrect, paint);
122}
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
void drawRRect(const SkRRect &rrect, const SkPaint &paint)
Definition: SkCanvas.cpp:1705
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
bool isOval() const
Definition: SkRRect.h:85
bool isRect() const
Definition: SkRRect.h:84
bool isSimple() const
Definition: SkRRect.h:86
const Paint & paint
Definition: color_source.cc:38
SkRRect rrect
Definition: SkRecords.h:232
SkColor color_to_565(SkColor color)
Definition: ToolUtils.cpp:139

◆ drawrr()

static void drawrr ( SkCanvas canvas,
const SkRRect rrect,
InsetProc  proc 
)
static

Definition at line 124 of file rrect.cpp.

124 {
125 SkRRect rr;
126 for (SkScalar d = -30; d <= 30; d += 5) {
127 proc(rrect, d, d, &rr);
128 draw_rrect_color(canvas, rr);
129 }
130}
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition: main.cc:19
float SkScalar
Definition: extension.cpp:12
static void draw_rrect_color(SkCanvas *canvas, const SkRRect &rrect)
Definition: rrect.cpp:107

◆ inset0()

static void inset0 ( const SkRRect src,
SkScalar  dx,
SkScalar  dy,
SkRRect dst 
)
static

Definition at line 23 of file rrect.cpp.

23 {
24 SkRect r = src.rect();
25
26 r.inset(dx, dy);
27 if (r.isEmpty()) {
28 dst->setEmpty();
29 return;
30 }
31
32 SkVector radii[4];
33 for (int i = 0; i < 4; ++i) {
34 radii[i] = src.radii((SkRRect::Corner)i);
35 }
36 for (int i = 0; i < 4; ++i) {
37 radii[i].fX -= dx;
38 radii[i].fY -= dy;
39 }
40 dst->setRectRadii(r, radii);
41}
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208
dst
Definition: cp.py:12
float fX
x-axis value
Definition: SkPoint_impl.h:164
float fY
y-axis value
Definition: SkPoint_impl.h:165
void inset(float dx, float dy)
Definition: SkRect.h:1060
bool isEmpty() const
Definition: SkRect.h:693

◆ inset1()

static void inset1 ( const SkRRect src,
SkScalar  dx,
SkScalar  dy,
SkRRect dst 
)
static

Definition at line 43 of file rrect.cpp.

43 {
44 SkRect r = src.rect();
45
46 r.inset(dx, dy);
47 if (r.isEmpty()) {
48 dst->setEmpty();
49 return;
50 }
51
52 SkVector radii[4];
53 for (int i = 0; i < 4; ++i) {
54 radii[i] = src.radii((SkRRect::Corner)i);
55 }
56 dst->setRectRadii(r, radii);
57}

◆ inset2()

static void inset2 ( const SkRRect src,
SkScalar  dx,
SkScalar  dy,
SkRRect dst 
)
static

Definition at line 59 of file rrect.cpp.

59 {
60 SkRect r = src.rect();
61
62 r.inset(dx, dy);
63 if (r.isEmpty()) {
64 dst->setEmpty();
65 return;
66 }
67
68 SkVector radii[4];
69 for (int i = 0; i < 4; ++i) {
70 radii[i] = src.radii((SkRRect::Corner)i);
71 }
72 for (int i = 0; i < 4; ++i) {
73 if (radii[i].fX) {
74 radii[i].fX -= dx;
75 }
76 if (radii[i].fY) {
77 radii[i].fY -= dy;
78 }
79 }
80 dst->setRectRadii(r, radii);
81}

◆ inset3()

static void inset3 ( const SkRRect src,
SkScalar  dx,
SkScalar  dy,
SkRRect dst 
)
static

Definition at line 87 of file rrect.cpp.

87 {
88 SkRect r = src.rect();
89
90 r.inset(dx, dy);
91 if (r.isEmpty()) {
92 dst->setEmpty();
93 return;
94 }
95
96 SkVector radii[4];
97 for (int i = 0; i < 4; ++i) {
98 radii[i] = src.radii((SkRRect::Corner)i);
99 }
100 for (int i = 0; i < 4; ++i) {
101 radii[i].fX = prop(radii[i].fX, r.width(), src.rect().width());
102 radii[i].fY = prop(radii[i].fY, r.height(), src.rect().height());
103 }
104 dst->setRectRadii(r, radii);
105}
static SkScalar prop(SkScalar radius, SkScalar newSize, SkScalar oldSize)
Definition: rrect.cpp:83
constexpr float height() const
Definition: SkRect.h:769
constexpr float width() const
Definition: SkRect.h:762

◆ prop()

static SkScalar prop ( SkScalar  radius,
SkScalar  newSize,
SkScalar  oldSize 
)
static

Definition at line 83 of file rrect.cpp.

83 {
84 return newSize * radius / oldSize;
85}