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 // HASH=809284db136748208b3efc31cd89de29
5 REG_FIDDLE(Pixmap_writable_addr8, 256, 64, false, 0) {
draw(SkCanvas * canvas)6 void 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->drawImage(bitmap.asImage(), 0, 0);
18     *pixmap.writable_addr8(2, 2) = 0;
19 //  bitmap.installPixels(pixmap);      // uncomment to fix on GPU
20     canvas->drawImage(bitmap.asImage(), 10, 0);
21 }
22 }  // END FIDDLE
23