2 * Copyright 2012 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
9 #include "sk_tool_utils.h"
12 #include "SkSurface.h"
19 static sk_sp<SkSurface> new_surface(int width, int height) {
20 return SkSurface::MakeRasterN32Premul(width, height);
23 static void draw_pixel_centers(SkCanvas* canvas) {
25 paint.setColor(sk_tool_utils::color_to_565(0xFF0088FF));
26 paint.setAntiAlias(true);
28 for (int y = 0; y < SMALL_H; ++y) {
29 for (int x = 0; x < SMALL_W; ++x) {
30 canvas->drawCircle(x + 0.5f, y + 0.5f, 1.5f / ZOOM, paint);
35 static void draw_fatpath(SkCanvas* canvas, SkSurface* surface, const SkPath& path) {
38 surface->getCanvas()->clear(SK_ColorTRANSPARENT);
39 surface->getCanvas()->drawPath(path, paint);
40 surface->draw(canvas, 0, 0, nullptr);
42 paint.setAntiAlias(true);
43 paint.setColor(SK_ColorRED);
44 paint.setStyle(SkPaint::kStroke_Style);
45 canvas->drawPath(path, paint);
47 draw_pixel_centers(canvas);
50 DEF_SIMPLE_GM(fatpathfill, canvas,
52 SMALL_H * ZOOM * REPEAT_LOOP) {
53 auto surface(new_surface(SMALL_W, SMALL_H));
55 canvas->scale(ZOOM, ZOOM);
58 paint.setStyle(SkPaint::kStroke_Style);
59 paint.setStrokeWidth(SK_Scalar1);
61 for (int i = 0; i < REPEAT_LOOP; ++i) {
64 line.lineTo(SkIntToScalar(4 + i), 1);
65 paint.getFillPath(line, &path);
66 draw_fatpath(canvas, surface.get(), path);
68 canvas->translate(0, SMALL_H);