Flutter Engine
The Flutter Engine
crbug_1313579.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2022 Google LLC
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/gm.h"
11#include "include/core/SkRect.h"
13
14// SkiaRenderer can wind up specifying near-integer scale-and-translate matrices on SkCanvas before
15// applying a backdrop blur image filter via saveLayer() with an integer clip, crop rect, and
16// SaveLayerRec bounds. Round-out is used to determine the bounds of the input image needed in IFs.
17// This could cause an extra row/column of pixels to be included in the blur. When that row/column
18// is significantly different in color than the intended blur content and the radius is large then
19// clamp mode blur creates a very noticeable color bleed artifact.
20DEF_SIMPLE_GM(crbug_1313579, canvas, 110, 110) {
21 static constexpr auto kBGRect = SkIRect{0, 0, 100, 100};
22
23 sk_sp<SkImageFilter> backdrop_filter =
24 SkImageFilters::Blur(50.f, 50.f, SkTileMode::kClamp, nullptr, kBGRect);
25
26 SkMatrix m;
27
28 canvas->clear(SK_ColorGREEN);
29
30 m.setAll(0.999999f, 0, 4.99999f,
31 0, 0.999999f, 4.99999f,
32 0, 0, 1);
33 canvas->concat(m);
34 canvas->clipIRect(kBGRect);
35 canvas->clear(SK_ColorWHITE);
36 canvas->saveLayer(SkCanvas::SaveLayerRec(nullptr, nullptr, backdrop_filter.get(), 0));
37 canvas->restore();
38}
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
static sk_sp< SkImageFilter > Blur(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
T * get() const
Definition: SkRefCnt.h:303
DEF_SIMPLE_GM(crbug_1313579, canvas, 110, 110)
Definition: SkRect.h:32