Flutter Engine
The Flutter Engine
fatpathfill.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2012 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"
12#include "include/core/SkPath.h"
17#include "tools/ToolUtils.h"
18
19#define ZOOM 32
20#define SMALL_W 9
21#define SMALL_H 3
22#define REPEAT_LOOP 5
23
26}
27
28static void draw_pixel_centers(SkCanvas* canvas) {
30 paint.setColor(ToolUtils::color_to_565(0xFF0088FF));
31 paint.setAntiAlias(true);
32
33 for (int y = 0; y < SMALL_H; ++y) {
34 for (int x = 0; x < SMALL_W; ++x) {
35 canvas->drawCircle(x + 0.5f, y + 0.5f, 1.5f / ZOOM, paint);
36 }
37 }
38}
39
40static void draw_fatpath(SkCanvas* canvas, SkSurface* surface, const SkPath& path) {
42
43 surface->getCanvas()->clear(SK_ColorTRANSPARENT);
44 surface->getCanvas()->drawPath(path, paint);
45 surface->draw(canvas, 0, 0);
46
47 paint.setAntiAlias(true);
48 paint.setColor(SK_ColorRED);
50 canvas->drawPath(path, paint);
51
52 draw_pixel_centers(canvas);
53}
54
55DEF_SIMPLE_GM(fatpathfill, canvas,
56 SMALL_W * ZOOM,
59
60 canvas->scale(ZOOM, ZOOM);
61
64 paint.setStrokeWidth(SK_Scalar1);
65
66 for (int i = 0; i < REPEAT_LOOP; ++i) {
68 line.moveTo(1, 2);
69 line.lineTo(SkIntToScalar(4 + i), 1);
71 draw_fatpath(canvas, surface.get(), path);
72
73 canvas->translate(0, SMALL_H);
74 }
75}
constexpr SkColor SK_ColorTRANSPARENT
Definition: SkColor.h:99
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
#define SK_Scalar1
Definition: SkScalar.h:18
#define SkIntToScalar(x)
Definition: SkScalar.h:57
void drawPath(const SkPath &path, const SkPaint &paint)
Definition: SkCanvas.cpp:1747
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint)
Definition: SkCanvas.cpp:2707
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
Definition: SkPath.h:59
const Paint & paint
Definition: color_source.cc:38
VkSurfaceKHR surface
Definition: main.cc:49
DEF_SIMPLE_GM(fatpathfill, canvas, SMALL_W *ZOOM, SMALL_H *ZOOM *REPEAT_LOOP)
Definition: fatpathfill.cpp:55
static sk_sp< SkSurface > new_surface(int width, int height)
Definition: fatpathfill.cpp:24
static void draw_fatpath(SkCanvas *canvas, SkSurface *surface, const SkPath &path)
Definition: fatpathfill.cpp:40
#define SMALL_W
Definition: fatpathfill.cpp:20
#define SMALL_H
Definition: fatpathfill.cpp:21
#define REPEAT_LOOP
Definition: fatpathfill.cpp:22
#define ZOOM
Definition: fatpathfill.cpp:19
static void draw_pixel_centers(SkCanvas *canvas)
Definition: fatpathfill.cpp:28
double y
double x
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
SkColor color_to_565(SkColor color)
Definition: ToolUtils.cpp:139
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
SK_API bool FillPathWithPaint(const SkPath &src, const SkPaint &paint, SkPath *dst, const SkRect *cullRect, SkScalar resScale=1)
Definition: SkPathUtils.cpp:23
int32_t height
int32_t width
static SkImageInfo MakeN32Premul(int width, int height)