| 1 |
// 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" |
| 4 |
REG_FIDDLE(no_gpu_blur, 256, 256, false, 0) { |
| 5 |
void 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 |
paint.setMaskFilter(SkMaskFilter::MakeBlur(kOuter_SkBlurStyle, 3)); |
| 17 |
SkIPoint offset; |
| 18 |
bitmap.extractAlpha(&alpha, &paint, nullptr, &offset); |
| 19 |
paint.setColor(SK_ColorRED); |
| 20 |
canvas->drawImage(bitmap.asImage(), 0, -offset.fY, SkSamplingOptions(), &paint); |
| 21 |
canvas->drawImage(alpha.asImage(), 100 + offset.fX, 0, SkSamplingOptions(), &paint); |
| 22 |
} |
| 23 |
} // END FIDDLE |