blob: 8c7aa38d7109dc49145fe03c821c9aa449d8b4b0 [file] [log] [blame]
Hal Canary87515122019-03-15 14:22:51 -04001// 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.
Mike Kleinc0bd9f92019-04-23 12:05:21 -05003#include "tools/fiddle/examples.h"
Hal Canary87515122019-03-15 14:22:51 -04004// HASH=809284db136748208b3efc31cd89de29
Hal Canarya7181e7c2019-03-18 16:06:34 -04005REG_FIDDLE(Pixmap_writable_addr8, 256, 64, false, 0) {
Hal Canary87515122019-03-15 14:22:51 -04006void draw(SkCanvas* canvas) {
7 uint8_t storage[][5] = {{ 0, 0, 64, 0, 0},
8 { 0, 128, 255, 128, 0},
9 {64, 255, 255, 255, 64},
10 { 0, 128, 255, 128, 0},
11 { 0, 0, 64, 0, 0}};
12 SkImageInfo imageInfo = SkImageInfo::Make(5, 5, kGray_8_SkColorType, kPremul_SkAlphaType);
13 SkPixmap pixmap(imageInfo, storage[0], 5);
14 SkBitmap bitmap;
15 bitmap.installPixels(pixmap);
16 canvas->scale(10, 10);
17 canvas->drawBitmap(bitmap, 0, 0);
18 *pixmap.writable_addr8(2, 2) = 0;
19// bitmap.installPixels(pixmap); // uncomment to fix on GPU
20 canvas->drawBitmap(bitmap, 10, 0);
21}
22} // END FIDDLE