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=29b98ebf58aa9fd1edfaabf9f4490b3a
5cb93a386Sopenharmony_ciREG_FIDDLE(Canvas_writePixels, 256, 256, false, 0) {
6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) {
7cb93a386Sopenharmony_ci    SkImageInfo imageInfo = SkImageInfo::MakeN32(256, 1, kPremul_SkAlphaType);
8cb93a386Sopenharmony_ci    for (int y = 0; y < 256; ++y) {
9cb93a386Sopenharmony_ci        uint32_t pixels[256];
10cb93a386Sopenharmony_ci        for (int x = 0; x < 256; ++x) {
11cb93a386Sopenharmony_ci            pixels[x] = SkColorSetARGB(x, (x + y) % 256, x, (x - y) & 0xFF);
12cb93a386Sopenharmony_ci        }
13cb93a386Sopenharmony_ci        canvas->writePixels(imageInfo, &pixels, sizeof(pixels), 0, y);
14cb93a386Sopenharmony_ci    }
15cb93a386Sopenharmony_ci}
16cb93a386Sopenharmony_ci}  // END FIDDLE
17