1cb93a386Sopenharmony_ci// Copyright 2020 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_ciREG_FIDDLE(no_gpu_blur, 256, 256, false, 0) { 5cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) { 6cb93a386Sopenharmony_ci SkBitmap alpha, bitmap; 7cb93a386Sopenharmony_ci bitmap.allocN32Pixels(100, 100); 8cb93a386Sopenharmony_ci SkCanvas offscreen(bitmap); 9cb93a386Sopenharmony_ci offscreen.clear(0); 10cb93a386Sopenharmony_ci SkPaint paint; 11cb93a386Sopenharmony_ci paint.setAntiAlias(true); 12cb93a386Sopenharmony_ci paint.setColor(SK_ColorBLUE); 13cb93a386Sopenharmony_ci paint.setStyle(SkPaint::kStroke_Style); 14cb93a386Sopenharmony_ci paint.setStrokeWidth(20); 15cb93a386Sopenharmony_ci offscreen.drawCircle(50, 50, 39, paint); 16cb93a386Sopenharmony_ci offscreen.flush(); 17cb93a386Sopenharmony_ci paint.setMaskFilter(SkMaskFilter::MakeBlur(kOuter_SkBlurStyle, 3)); 18cb93a386Sopenharmony_ci SkIPoint offset; 19cb93a386Sopenharmony_ci bitmap.extractAlpha(&alpha, &paint, nullptr, &offset); 20cb93a386Sopenharmony_ci paint.setColor(SK_ColorRED); 21cb93a386Sopenharmony_ci canvas->drawImage(bitmap.asImage(), 0, -offset.fY, SkSamplingOptions(), &paint); 22cb93a386Sopenharmony_ci canvas->drawImage(alpha.asImage(), 100 + offset.fX, 0, SkSamplingOptions(), &paint); 23cb93a386Sopenharmony_ci} 24cb93a386Sopenharmony_ci} // END FIDDLE 25