blob: 0d472b78c6a8d4382a2849c4d0324b09d2431759 [file] [log] [blame]
Hal Canary83c2f702019-03-07 14:53:03 -05001// 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 "fiddle/examples.h"
4// HASH=2d991a231e49d1de13eeb2ba9b440e01
5REG_FIDDLE(Surface_023, 256, 256, false, 0) {
6void draw(SkCanvas* canvas) {
7 sk_sp<SkSurface> surf(SkSurface::MakeRasterN32Premul(64, 64));
8 auto surfCanvas = surf->getCanvas();
9 surfCanvas->clear(SK_ColorGREEN);
10 SkPaint paint;
11 surfCanvas->drawOval({2, 10, 58, 54}, paint);
12 SkImageInfo info = SkImageInfo::Make(64, 64, kBGRA_8888_SkColorType, kPremul_SkAlphaType);
13 SkBitmap bitmap;
14 bitmap.setInfo(info);
15 bitmap.allocPixels();
16 for (int x : { 32, -32 } ) {
17 for (int y : { 32, -32 } ) {
18 surf->readPixels(bitmap, x, y);
19 }
20 }
21 canvas->drawBitmap(bitmap, 0, 0);
22}
23} // END FIDDLE