xref: /third_party/skia/docs/examples/Surface_draw.cpp (revision cb93a386)
  • 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=0de693f4d8dd898a60be8cfba23952be
5cb93a386Sopenharmony_ciREG_FIDDLE(Surface_draw, 256, 64, false, 0) {
6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) {
7cb93a386Sopenharmony_ci    sk_sp<SkSurface> big(SkSurface::MakeRasterN32Premul(64, 64));
8cb93a386Sopenharmony_ci    sk_sp<SkSurface> lil(big->makeSurface(SkImageInfo::MakeN32(32, 32, kPremul_SkAlphaType)));
9cb93a386Sopenharmony_ci    big->getCanvas()->clear(SK_ColorRED);
10cb93a386Sopenharmony_ci    lil->getCanvas()->clear(SK_ColorBLACK);
11cb93a386Sopenharmony_ci    lil->draw(big->getCanvas(), 16, 16);
12cb93a386Sopenharmony_ci    SkPixmap pixmap;
13cb93a386Sopenharmony_ci    if (big->peekPixels(&pixmap)) {
14cb93a386Sopenharmony_ci        SkBitmap bigBits;
15cb93a386Sopenharmony_ci        bigBits.installPixels(pixmap);
16cb93a386Sopenharmony_ci        canvas->drawImage(bigBits.asImage(), 0, 0);
17cb93a386Sopenharmony_ci    }
18cb93a386Sopenharmony_ci}
19cb93a386Sopenharmony_ci}  // END FIDDLE
20

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