Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
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) {
67 SkPath line, path;
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)
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint)
@ kStroke_Style
set to stroke geometry
Definition SkPaint.h:194
const Paint & paint
VkSurfaceKHR surface
Definition main.cc:49
static sk_sp< SkSurface > new_surface(int width, int height)
static void draw_fatpath(SkCanvas *canvas, SkSurface *surface, const SkPath &path)
#define SMALL_W
#define SMALL_H
#define REPEAT_LOOP
#define ZOOM
static void draw_pixel_centers(SkCanvas *canvas)
#define DEF_SIMPLE_GM(NAME, CANVAS, W, H)
Definition gm.h:50
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)
SK_API bool FillPathWithPaint(const SkPath &src, const SkPaint &paint, SkPath *dst, const SkRect *cullRect, SkScalar resScale=1)
int32_t height
int32_t width
static SkImageInfo MakeN32Premul(int width, int height)