xref: /third_party/skia/docs/examples/Canvas_getBaseLayerSize.cpp
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/skia/docs/examples/
1cb93a386Sopenharmony_ci// Copyright 2019 Google LLC.
2cb93a386Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3cb93a386Sopenharmony_ci#include "tools/fiddle/examples.h"
4cb93a386Sopenharmony_ci// HASH=374e245d91cd729eca48fd20e631fdf3
5cb93a386Sopenharmony_ciREG_FIDDLE(Canvas_getBaseLayerSize, 256, 256, true, 0) {
6cb93a386Sopenharmony_civoid draw(SkCanvas* ) {
7cb93a386Sopenharmony_ci    SkBitmap bitmap;
8cb93a386Sopenharmony_ci    bitmap.allocPixels(SkImageInfo::MakeN32Premul(20, 30));
9cb93a386Sopenharmony_ci    SkCanvas canvas(bitmap, SkSurfaceProps(0, kUnknown_SkPixelGeometry));
10cb93a386Sopenharmony_ci    canvas.clipRect(SkRect::MakeWH(10, 40));
11cb93a386Sopenharmony_ci    SkIRect clipDeviceBounds = canvas.getDeviceClipBounds();
12cb93a386Sopenharmony_ci    if (clipDeviceBounds.isEmpty()) {
13cb93a386Sopenharmony_ci        SkDebugf("Empty clip bounds is unexpected!\n");
14cb93a386Sopenharmony_ci    }
15cb93a386Sopenharmony_ci    SkDebugf("clip=%d,%d\n", clipDeviceBounds.width(), clipDeviceBounds.height());
16cb93a386Sopenharmony_ci    SkISize baseLayerSize = canvas.getBaseLayerSize();
17cb93a386Sopenharmony_ci    SkDebugf("size=%d,%d\n", baseLayerSize.width(), baseLayerSize.height());
18cb93a386Sopenharmony_ci}
19cb93a386Sopenharmony_ci}  // END FIDDLE
20

Indexes created Thu Nov 07 10:32:03 CST 2024