Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Public Attributes | List of all members
FatBits Class Reference

Public Types

enum  Style { kHair_Style , kStroke_Style }
 

Public Member Functions

 FatBits ()
 
int getZoom () const
 
bool getAA () const
 
void setAA (bool aa)
 
bool getGrid () const
 
void setGrid (bool g)
 
bool getShowSkeleton () const
 
void setShowSkeleton (bool ss)
 
bool getTriangle () const
 
void setTriangle (bool ut)
 
void toggleRectAsOval ()
 
void togglePixelColors ()
 
bool getUseClip () const
 
void setUseClip (bool uc)
 
Style getStyle () const
 
void setStyle (Style s)
 
void setWHZ (int width, int height, int zoom)
 
void drawBG (SkCanvas *)
 
void drawFG (SkCanvas *)
 
void drawLine (SkCanvas *, SkPoint pts[2])
 
void drawRect (SkCanvas *canvas, SkPoint pts[2])
 
void drawTriangle (SkCanvas *canvas, SkPoint pts[3])
 

Public Attributes

float fStrokeWidth = 1
 
SkPaint::Cap fStrokeCap
 

Detailed Description

Definition at line 51 of file FatBitsSlide.cpp.

Member Enumeration Documentation

◆ Style

Enumerator
kHair_Style 
kStroke_Style 

Definition at line 95 of file FatBitsSlide.cpp.

95 {
98 };

Constructor & Destructor Documentation

◆ FatBits()

FatBits::FatBits ( )
inline

Definition at line 53 of file FatBitsSlide.cpp.

53 {
54 fAA = false;
55 fStyle = kHair_Style;
56 fGrid = false;
57 fShowSkeleton = true;
58 fUseClip = false;
59 fRectAsOval = false;
60 fUseTriangle = false;
62
63 fClipRect.setLTRB(2, 2, 11, 8);
64 }
SkPaint::Cap fStrokeCap
@ kButt_Cap
no stroke extension
Definition: SkPaint.h:334
void setLTRB(float left, float top, float right, float bottom)
Definition: SkRect.h:865

Member Function Documentation

◆ drawBG()

void FatBits::drawBG ( SkCanvas canvas)

Definition at line 192 of file FatBitsSlide.cpp.

192 {
194
195 paint.setShader(fShader);
196 canvas->drawRect(fBounds, paint);
197 paint.setShader(nullptr);
198}
void drawRect(const SkRect &rect, const SkPaint &paint)
Definition: SkCanvas.cpp:1673
const Paint & paint
Definition: color_source.cc:38

◆ drawFG()

void FatBits::drawFG ( SkCanvas canvas)

Definition at line 200 of file FatBitsSlide.cpp.

200 {
201 SkPaint inner, outer;
202
203 inner.setAntiAlias(true);
204 inner.setColor(SK_ColorBLACK);
206
207 outer.setAntiAlias(true);
208 outer.setColor(SK_ColorWHITE);
210
211 SkScalar half = SkIntToScalar(fZoom) / 2;
212 for (int iy = 0; iy < fH; ++iy) {
213 SkScalar y = SkIntToScalar(iy * fZoom) + half;
214 for (int ix = 0; ix < fW; ++ix) {
215 SkScalar x = SkIntToScalar(ix * fZoom) + half;
216
217 canvas->drawPoint(x, y, outer);
218 canvas->drawPoint(x, y, inner);
219 }
220 }
221
222 if (fUseClip) {
223 SkPaint p;
224 p.setStyle(SkPaint::kStroke_Style);
225 p.setColor(SK_ColorLTGRAY);
226 SkRect r = {
227 fClipRect.fLeft * fZoom,
228 fClipRect.fTop * fZoom,
229 fClipRect.fRight * fZoom,
230 fClipRect.fBottom * fZoom
231 };
232 canvas->drawRect(r, p);
233 }
234}
#define PIXEL_CENTER_SIZE
constexpr SkColor SK_ColorLTGRAY
Definition: SkColor.h:118
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void drawPoint(SkScalar x, SkScalar y, const SkPaint &paint)
Definition: SkCanvas.cpp:2695
void setColor(SkColor color)
Definition: SkPaint.cpp:119
void setAntiAlias(bool aa)
Definition: SkPaint.h:170
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
void setStrokeWidth(SkScalar width)
Definition: SkPaint.cpp:159
float SkScalar
Definition: extension.cpp:12
double y
double x
SkScalar fBottom
larger y-axis bounds
Definition: extension.cpp:17
SkScalar fLeft
smaller x-axis bounds
Definition: extension.cpp:14
SkScalar fRight
larger x-axis bounds
Definition: extension.cpp:16
SkScalar fTop
smaller y-axis bounds
Definition: extension.cpp:15

◆ drawLine()

void FatBits::drawLine ( SkCanvas canvas,
SkPoint  pts[2] 
)

Definition at line 259 of file FatBitsSlide.cpp.

259 {
261
262 fInverse.mapPoints(pts, 2);
263
264 if (fGrid) {
265 apply_grid(pts, 2);
266 }
267
268 erase(fMinSurface.get());
269 this->setupPaint(&paint);
270 paint.setColor(FAT_PIXEL_COLOR);
271 if (fUseClip) {
272 fMinSurface->getCanvas()->save();
273 SkRect r = fClipRect;
275 fMinSurface->getCanvas()->clipRect(r, SkClipOp::kIntersect, true);
276 }
277 fMinSurface->getCanvas()->drawLine(pts[0], pts[1], paint);
278 if (fUseClip) {
279 fMinSurface->getCanvas()->restore();
280 }
281 this->copyMinToMax();
282
283 SkCanvas* max = fMaxSurface->getCanvas();
284
285 fMatrix.mapPoints(pts, 2);
286 this->drawLineSkeleton(max, pts);
287
288 fMaxSurface->draw(canvas, 0, 0);
289}
#define FAT_PIXEL_COLOR
static SkScalar apply_grid(SkScalar x)
static void erase(SkSurface *surface)
#define SK_Scalar1
Definition: SkScalar.h:18
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
void restore()
Definition: SkCanvas.cpp:461
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
Definition: SkCanvas.cpp:2700
int save()
Definition: SkCanvas.cpp:447
void mapPoints(SkPoint dst[], const SkPoint src[], int count) const
Definition: SkMatrix.cpp:770
SkCanvas * getCanvas()
Definition: SkSurface.cpp:82
void draw(SkCanvas *canvas, SkScalar x, SkScalar y, const SkSamplingOptions &sampling, const SkPaint *paint)
Definition: SkSurface.cpp:116
T * get() const
Definition: SkRefCnt.h:303
static float max(float r, float g, float b)
Definition: hsl.cpp:49
void inset(float dx, float dy)
Definition: SkRect.h:1060

◆ drawRect()

void FatBits::drawRect ( SkCanvas canvas,
SkPoint  pts[2] 
)

Definition at line 291 of file FatBitsSlide.cpp.

291 {
293
294 fInverse.mapPoints(pts, 2);
295
296 if (fGrid) {
297 apply_grid(pts, 2);
298 }
299
300 SkRect r;
301 r.setBounds(pts, 2);
302
303 erase(fMinSurface.get());
304 this->setupPaint(&paint);
305 paint.setColor(FAT_PIXEL_COLOR);
306 {
307 SkCanvas* c = fMinSurface->getCanvas();
308 fRectAsOval ? c->drawOval(r, paint) : c->drawRect(r, paint);
309 }
310 this->copyMinToMax();
311
312 SkCanvas* max = fMaxSurface->getCanvas();
313
314 fMatrix.mapPoints(pts, 2);
315 r.setBounds(pts, 2);
316 this->drawRectSkeleton(max, r);
317
318 fMaxSurface->draw(canvas, 0, 0);
319}
void drawOval(const SkRect &oval, const SkPaint &paint)
Definition: SkCanvas.cpp:1698
void setBounds(const SkPoint pts[], int count)
Definition: SkRect.h:881

◆ drawTriangle()

void FatBits::drawTriangle ( SkCanvas canvas,
SkPoint  pts[3] 
)

Definition at line 334 of file FatBitsSlide.cpp.

334 {
336
337 fInverse.mapPoints(pts, 3);
338
339 if (fGrid) {
340 apply_grid(pts, 3);
341 }
342
343 SkPath path;
344 path.moveTo(pts[0]);
345 path.lineTo(pts[1]);
346 path.lineTo(pts[2]);
347 path.close();
348
349 erase(fMinSurface.get());
350 this->setupPaint(&paint);
351 paint.setColor(FAT_PIXEL_COLOR);
352 fMinSurface->getCanvas()->drawPath(path, paint);
353 this->copyMinToMax();
354
355 SkCanvas* max = fMaxSurface->getCanvas();
356
357 fMatrix.mapPoints(pts, 3);
358 this->drawTriangleSkeleton(max, pts);
359
360 fMaxSurface->draw(canvas, 0, 0);
361}
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
Definition: SkPath.h:59
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
Definition: switches.h:57

◆ getAA()

bool FatBits::getAA ( ) const
inline

Definition at line 68 of file FatBitsSlide.cpp.

68{ return fAA; }

◆ getGrid()

bool FatBits::getGrid ( ) const
inline

Definition at line 71 of file FatBitsSlide.cpp.

71{ return fGrid; }

◆ getShowSkeleton()

bool FatBits::getShowSkeleton ( ) const
inline

Definition at line 74 of file FatBitsSlide.cpp.

74{ return fShowSkeleton; }

◆ getStyle()

Style FatBits::getStyle ( ) const
inline

Definition at line 99 of file FatBitsSlide.cpp.

99{ return fStyle; }

◆ getTriangle()

bool FatBits::getTriangle ( ) const
inline

Definition at line 77 of file FatBitsSlide.cpp.

77{ return fUseTriangle; }

◆ getUseClip()

bool FatBits::getUseClip ( ) const
inline

Definition at line 92 of file FatBitsSlide.cpp.

92{ return fUseClip; }

◆ getZoom()

int FatBits::getZoom ( ) const
inline

Definition at line 66 of file FatBitsSlide.cpp.

66{ return fZoom; }

◆ setAA()

void FatBits::setAA ( bool  aa)
inline

Definition at line 69 of file FatBitsSlide.cpp.

69{ fAA = aa; }

◆ setGrid()

void FatBits::setGrid ( bool  g)
inline

Definition at line 72 of file FatBitsSlide.cpp.

72{ fGrid = g; }

◆ setShowSkeleton()

void FatBits::setShowSkeleton ( bool  ss)
inline

Definition at line 75 of file FatBitsSlide.cpp.

75{ fShowSkeleton = ss; }

◆ setStyle()

void FatBits::setStyle ( Style  s)
inline

Definition at line 100 of file FatBitsSlide.cpp.

100{ fStyle = s; }
struct MyStruct s

◆ setTriangle()

void FatBits::setTriangle ( bool  ut)
inline

Definition at line 78 of file FatBitsSlide.cpp.

78{ fUseTriangle = ut; }

◆ setUseClip()

void FatBits::setUseClip ( bool  uc)
inline

Definition at line 93 of file FatBitsSlide.cpp.

93{ fUseClip = uc; }

◆ setWHZ()

void FatBits::setWHZ ( int  width,
int  height,
int  zoom 
)
inline

Definition at line 102 of file FatBitsSlide.cpp.

102 {
103 fW = width;
104 fH = height;
105 fZoom = zoom;
106 fBounds.setIWH(width * zoom, height * zoom);
107 fMatrix.setScale(SkIntToScalar(zoom), SkIntToScalar(zoom));
108 fInverse.setScale(SK_Scalar1 / zoom, SK_Scalar1 / zoom);
109 fShader0 = ToolUtils::create_checkerboard_shader(0xFFDDDDDD, 0xFFFFFFFF, zoom);
111 fShader = fShader0;
112
114 fMinSurface = SkSurfaces::Raster(info);
115 info = info.makeWH(width * zoom, height * zoom);
116 fMaxSurface = SkSurfaces::Raster(info);
117 }
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
SkMatrix & setScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
Definition: SkMatrix.cpp:296
SK_API sk_sp< SkShader > Color(SkColor)
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
sk_sp< SkShader > create_checkerboard_shader(SkColor c1, SkColor c2, int size)
Definition: ToolUtils.cpp:150
int32_t height
int32_t width
static SkImageInfo MakeN32Premul(int width, int height)
void setIWH(int32_t width, int32_t height)
Definition: SkRect.h:950

◆ togglePixelColors()

void FatBits::togglePixelColors ( )
inline

Definition at line 82 of file FatBitsSlide.cpp.

82 {
83 if (fShader == fShader0) {
84 fShader = fShader1;
85 } else {
86 fShader = fShader0;
87 }
88 }

◆ toggleRectAsOval()

void FatBits::toggleRectAsOval ( )
inline

Definition at line 80 of file FatBitsSlide.cpp.

80{ fRectAsOval = !fRectAsOval; }

Member Data Documentation

◆ fStrokeCap

SkPaint::Cap FatBits::fStrokeCap

Definition at line 125 of file FatBitsSlide.cpp.

◆ fStrokeWidth

float FatBits::fStrokeWidth = 1

Definition at line 90 of file FatBitsSlide.cpp.


The documentation for this class was generated from the following file: