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=102d014d7f753db2a9b9ee08893aaf11 5cb93a386Sopenharmony_ciREG_FIDDLE(Canvas_readPixels_a, 64, 64, false, 0) { 6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) { 7cb93a386Sopenharmony_ci canvas->clear(SK_ColorBLUE); 8cb93a386Sopenharmony_ci SkPaint paint; 9cb93a386Sopenharmony_ci canvas->drawCircle(32, 32, 28, paint); 10cb93a386Sopenharmony_ci SkImageInfo info = SkImageInfo::Make(64, 64, kBGRA_8888_SkColorType, kPremul_SkAlphaType); 11cb93a386Sopenharmony_ci sk_sp<SkData> data(SkData::MakeUninitialized(info.minRowBytes() * info.height())); 12cb93a386Sopenharmony_ci sk_bzero(data->writable_data(), info.minRowBytes() * info.height()); 13cb93a386Sopenharmony_ci for (int x : { 32, -32 } ) { 14cb93a386Sopenharmony_ci for (int y : { 32, -32 } ) { 15cb93a386Sopenharmony_ci canvas->readPixels(info, data->writable_data(), info.minRowBytes(), x, y); 16cb93a386Sopenharmony_ci } 17cb93a386Sopenharmony_ci } 18cb93a386Sopenharmony_ci sk_sp<SkImage> image = SkImage::MakeRasterData(info, data, info.minRowBytes()); 19cb93a386Sopenharmony_ci canvas->drawImage(image, 0, 0); 20cb93a386Sopenharmony_ci} 21cb93a386Sopenharmony_ci} // END FIDDLE 22