blob: 21aa6bceefc1e5d1d3371dbf0418b33fccace35b [file] [log] [blame]
Hal Canary6c8422c2020-01-10 15:22:09 -05001// Copyright 2020 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"
4REG_FIDDLE(no_gpu_blur, 256, 256, false, 0) {
5void draw(SkCanvas* canvas) {
6 SkBitmap alpha, bitmap;
7 bitmap.allocN32Pixels(100, 100);
8 SkCanvas offscreen(bitmap);
9 offscreen.clear(0);
10 SkPaint paint;
11 paint.setAntiAlias(true);
12 paint.setColor(SK_ColorBLUE);
13 paint.setStyle(SkPaint::kStroke_Style);
14 paint.setStrokeWidth(20);
15 offscreen.drawCircle(50, 50, 39, paint);
16 offscreen.flush();
17 paint.setMaskFilter(SkMaskFilter::MakeBlur(kOuter_SkBlurStyle, 3));
18 SkIPoint offset;
19 bitmap.extractAlpha(&alpha, &paint, nullptr, &offset);
20 paint.setColor(SK_ColorRED);
Mike Reedecdd9792021-01-27 20:39:22 -050021 canvas->drawImage(bitmap.asImage(), 0, -offset.fY, SkSamplingOptions(), &paint);
22 canvas->drawImage(alpha.asImage(), 100 + offset.fX, 0, SkSamplingOptions(), &paint);
Hal Canary6c8422c2020-01-10 15:22:09 -050023}
24} // END FIDDLE