• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2018 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #include "gm.h"
9 
10 #include "SkArithmeticImageFilter.h"
11 #include "SkBlurImageFilter.h"
12 #include "SkImageSource.h"
13 #include "SkMorphologyImageFilter.h"
14 #include "SkSurface.h"
15 #include "SkXfermodeImageFilter.h"
16 
17 DEF_SIMPLE_GM(crbug_905548, canvas, 100, 200) {
18     auto surface = canvas->makeSurface(SkImageInfo::MakeN32Premul(100, 100));
19     if (!surface) {
20         surface = SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(100, 100));
21     }
22     surface->getCanvas()->clear(0);
23     surface->getCanvas()->drawCircle(50, 50, 45, SkPaint());
24     auto imageSource = SkImageSource::Make(surface->makeImageSnapshot());
25 
26     auto blurred = SkBlurImageFilter::Make(15, 15, imageSource);
27     auto eroded = SkErodeImageFilter::Make(0, 0, blurred);
28     auto blended = SkXfermodeImageFilter::Make(SkBlendMode::kDstOut, eroded, imageSource, nullptr);
29 
30     SkPaint paint;
31     paint.setImageFilter(blended);
32     canvas->drawRect(SkRect::MakeWH(100, 100), paint);
33 
34     auto mult = SkArithmeticImageFilter::Make(1, 0, 0, 0, false, eroded, imageSource, nullptr);
35     paint.setImageFilter(mult);
36     canvas->translate(0, 100);
37     canvas->drawRect(SkRect::MakeWH(100, 100), paint);
38 }
39