Debian Codegraph @

docs/examples/Canvas_getDeviceClipBounds.cpp

raw
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) {
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 = SkPath::Polygon(clipPoints, true);
13 canvas->save();
14 canvas->clipPath(clipPath);
15 bounds = canvas->getDeviceClipBounds();
16 SkDebugf("left:%d top:%d right:%d bottom:%d\n",
17 bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom);
18 canvas->restore();
19 canvas->scale(1.f/2, 1.f/2);
20 canvas->clipPath(clipPath);
21 bounds = canvas->getDeviceClipBounds();
22 SkDebugf("left:%d top:%d right:%d bottom:%d\n",
23 bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom);
24 }
25 } // END FIDDLE