@@ -74,13 +74,6 @@ KawaseBlurDualFilter::KawaseBlurDualFilter() : BlurFilter() {
7474 mBlurEffect = std::move (blurEffect);
7575}
7676
77- static sk_sp<SkSurface> makeSurface (SkiaGpuContext* context, const SkRect& origRect, int scale) {
78- SkImageInfo scaledInfo =
79- SkImageInfo::MakeN32Premul (ceil (static_cast <float >(origRect.width ()) / scale),
80- ceil (static_cast <float >(origRect.height ()) / scale));
81- return context->createRenderTarget (scaledInfo);
82- }
83-
8477void KawaseBlurDualFilter::blurInto (const sk_sp<SkSurface>& drawSurface,
8578 const sk_sp<SkImage>& readImage, const float radius,
8679 const float alpha) const {
@@ -124,11 +117,17 @@ sk_sp<SkImage> KawaseBlurDualFilter::generate(SkiaGpuContext* context, const uin
124117 const float filterDepth = std::min (kMaxSurfaces - 1 .0f , radius * kInputScale / 2 .5f );
125118 const int filterPasses = std::min (kMaxSurfaces - 1 , static_cast <int >(ceil (filterDepth)));
126119
120+ auto makeSurface = [&](float scale) -> sk_sp<SkSurface> {
121+ const auto newW = static_cast <float >(blurRect.width () / scale);
122+ const auto newH = static_cast <float >(blurRect.height () / scale);
123+ return context->createRenderTarget (input->imageInfo ().makeWH (newW, newH));
124+ };
125+
127126 // Render into surfaces downscaled by 1x, 2x, and 4x from the initial downscale.
128127 sk_sp<SkSurface> surfaces[kMaxSurfaces ] =
129- {filterPasses >= 0 ? makeSurface (context, blurRect, 1 * kInverseInputScale ) : nullptr ,
130- filterPasses >= 1 ? makeSurface (context, blurRect, 2 * kInverseInputScale ) : nullptr ,
131- filterPasses >= 2 ? makeSurface (context, blurRect, 4 * kInverseInputScale ) : nullptr };
128+ {filterPasses >= 0 ? makeSurface (1 * kInverseInputScale ) : nullptr ,
129+ filterPasses >= 1 ? makeSurface (2 * kInverseInputScale ) : nullptr ,
130+ filterPasses >= 2 ? makeSurface (4 * kInverseInputScale ) : nullptr };
132131
133132 // These weights for scaling offsets per-pass are handpicked to look good at 1 <= radius <= 250.
134133 static const float kWeights [5 ] = {
0 commit comments