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" 9 #include "include/core/SkCanvas.h" 10 #include "include/core/SkMatrix.h" 11 #include "include/core/SkRect.h" 12 #include "include/effects/SkImageFilters.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. 20 DEF_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); 25 sk_sp<SkImageFilter> crop = SkImageFilters::Offset(0, 0, nullptr, &kBGRect); 26 backdrop_filter = SkImageFilters::Compose( 27 crop, SkImageFilters::Compose(std::move(backdrop_filter), crop)); 28 29 SkMatrix m; 30 31 canvas->clear(SK_ColorGREEN); 32 33 m.setAll(0.999999f, 0, 4.99999f, 34 0, 0.999999f, 4.99999f, 35 0, 0, 1); 36 canvas->concat(m); 37 canvas->clipIRect(kBGRect); 38 canvas->clear(SK_ColorWHITE); 39 canvas->saveLayer(SkCanvas::SaveLayerRec(nullptr, nullptr, backdrop_filter.get(), 0)); 40 canvas->restore(); 41 } 42