2018-12-03 16:17:51 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2018 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "gm/gm.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "include/core/SkBlendMode.h"
|
|
|
|
#include "include/core/SkCanvas.h"
|
|
|
|
#include "include/core/SkImage.h"
|
|
|
|
#include "include/core/SkImageFilter.h"
|
|
|
|
#include "include/core/SkImageInfo.h"
|
|
|
|
#include "include/core/SkPaint.h"
|
|
|
|
#include "include/core/SkRect.h"
|
|
|
|
#include "include/core/SkRefCnt.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkSurface.h"
|
2019-08-02 19:21:23 +00:00
|
|
|
#include "include/effects/SkImageFilters.h"
|
2018-12-03 16:17:51 +00:00
|
|
|
|
|
|
|
DEF_SIMPLE_GM(crbug_905548, canvas, 100, 200) {
|
|
|
|
auto surface = canvas->makeSurface(SkImageInfo::MakeN32Premul(100, 100));
|
|
|
|
if (!surface) {
|
|
|
|
surface = SkSurface::MakeRaster(SkImageInfo::MakeN32Premul(100, 100));
|
|
|
|
}
|
|
|
|
surface->getCanvas()->clear(0);
|
|
|
|
surface->getCanvas()->drawCircle(50, 50, 45, SkPaint());
|
2019-08-02 19:21:23 +00:00
|
|
|
auto imageSource = SkImageFilters::Image(surface->makeImageSnapshot());
|
2018-12-03 16:17:51 +00:00
|
|
|
|
2019-08-02 19:21:23 +00:00
|
|
|
auto blurred = SkImageFilters::Blur(15, 15, imageSource);
|
|
|
|
auto eroded = SkImageFilters::Erode(0, 0, blurred);
|
2020-10-09 14:45:07 +00:00
|
|
|
auto blended = SkImageFilters::Blend(SkBlendMode::kDstOut, eroded, imageSource, nullptr);
|
2018-12-03 16:17:51 +00:00
|
|
|
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setImageFilter(blended);
|
|
|
|
canvas->drawRect(SkRect::MakeWH(100, 100), paint);
|
|
|
|
|
2019-08-02 19:21:23 +00:00
|
|
|
auto mult = SkImageFilters::Arithmetic(1, 0, 0, 0, false, eroded, imageSource, nullptr);
|
2018-12-03 16:17:51 +00:00
|
|
|
paint.setImageFilter(mult);
|
|
|
|
canvas->translate(0, 100);
|
|
|
|
canvas->drawRect(SkRect::MakeWH(100, 100), paint);
|
|
|
|
}
|