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 REG_FIDDLE(Bitmap_setImmutable, 256, 256, true, 0) { draw(SkCanvas * canvas)5void draw(SkCanvas* canvas) { 6 SkBitmap bitmap; 7 bitmap.setInfo(SkImageInfo::MakeN32(4, 4, kPremul_SkAlphaType)); 8 bitmap.allocPixels(); 9 SkCanvas offscreen(bitmap); 10 SkDebugf("draw white\n"); 11 offscreen.clear(SK_ColorWHITE); 12 bitmap.setImmutable(); 13 SkDebugf("draw black\n"); 14 // Triggers assert if SK_DEBUG is true, runs fine otherwise. 15 // offscreen.clear(SK_ColorBLACK); 16 } 17 } // END FIDDLE 18