1 // Copyright 2019 Google LLC.
2 // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3 #include "tools/fiddle/examples.h"
4 REG_FIDDLE(Canvas_getDeviceClipBounds, 256, 256, true, 0) {
draw(SkCanvas * canvas)5 void draw(SkCanvas* canvas) {
6 SkCanvas device(256, 256);
7 canvas = &device;
8 SkIRect bounds = canvas->getDeviceClipBounds();
9 SkDebugf("left:%d top:%d right:%d bottom:%d\n",
10 bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom);
11 SkPoint clipPoints[] = {{30, 130}, {120, 130}, {120, 230} };
12 SkPath clipPath;
13 clipPath.addPoly(clipPoints, std::size(clipPoints), true);
14 canvas->save();
15 canvas->clipPath(clipPath);
16 bounds = canvas->getDeviceClipBounds();
17 SkDebugf("left:%d top:%d right:%d bottom:%d\n",
18 bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom);
19 canvas->restore();
20 canvas->scale(1.f/2, 1.f/2);
21 canvas->clipPath(clipPath);
22 bounds = canvas->getDeviceClipBounds();
23 SkDebugf("left:%d top:%d right:%d bottom:%d\n",
24 bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom);
25 }
26 } // END FIDDLE
27