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=a2b1e0910f37066f15ae56368775a6d8 5cb93a386Sopenharmony_ciREG_FIDDLE(Bitmap_tryAllocN32Pixels, 256, 160, false, 0) { 6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) { 7cb93a386Sopenharmony_ci SkBitmap bitmap; 8cb93a386Sopenharmony_ci if (bitmap.tryAllocN32Pixels(80, 80)) { 9cb93a386Sopenharmony_ci bitmap.eraseColor(SK_ColorTRANSPARENT); 10cb93a386Sopenharmony_ci bitmap.erase(0x7f3f7fff, SkIRect::MakeWH(50, 30)); 11cb93a386Sopenharmony_ci bitmap.erase(0x3f7fff3f, SkIRect::MakeXYWH(20, 10, 50, 30)); 12cb93a386Sopenharmony_ci bitmap.erase(0x5fff3f7f, SkIRect::MakeXYWH(40, 20, 50, 30)); 13cb93a386Sopenharmony_ci canvas->drawImage(bitmap.asImage(), 0, 0); 14cb93a386Sopenharmony_ci for (int x : { 0, 30, 60, 90 } ) { 15cb93a386Sopenharmony_ci canvas->drawImage(bitmap.asImage(), x, 70); 16cb93a386Sopenharmony_ci } 17cb93a386Sopenharmony_ci } 18cb93a386Sopenharmony_ci} 19cb93a386Sopenharmony_ci} // END FIDDLE 20