@@ -87,7 +87,6 @@ static GrTextureDomain::Mode to_texture_domain_mode(SkTileMode tileMode) {
87
87
}
88
88
89
89
static void convolve_gaussian_1d (GrRenderTargetContext* renderTargetContext,
90
- const GrClip& clip,
91
90
const SkIRect& dstRect,
92
91
const SkIPoint& srcOffset,
93
92
sk_sp<GrTextureProxy> proxy,
@@ -112,8 +111,8 @@ static void convolve_gaussian_1d(GrRenderTargetContext* renderTargetContext,
112
111
paint.setPorterDuffXPFactory (SkBlendMode::kSrc );
113
112
SkMatrix localMatrix = SkMatrix::MakeTrans (-SkIntToScalar (srcOffset.x ()),
114
113
-SkIntToScalar (srcOffset.y ()));
115
- renderTargetContext->fillRectWithLocalMatrix (clip , std::move (paint), GrAA::kNo , SkMatrix::I () ,
116
- SkRect::Make (dstRect), localMatrix);
114
+ renderTargetContext->fillRectWithLocalMatrix (GrNoClip () , std::move (paint), GrAA::kNo ,
115
+ SkMatrix::I (), SkRect::Make (dstRect), localMatrix);
117
116
}
118
117
119
118
static std::unique_ptr<GrRenderTargetContext> convolve_gaussian_2d (GrRecordingContext* context,
@@ -126,12 +125,11 @@ static std::unique_ptr<GrRenderTargetContext> convolve_gaussian_2d(GrRecordingCo
126
125
SkScalar sigmaX,
127
126
SkScalar sigmaY,
128
127
SkTileMode mode,
129
- int finalW,
130
- int finalH,
128
+ SkISize dstSize,
131
129
sk_sp<SkColorSpace> finalCS,
132
130
SkBackingFit dstFit) {
133
131
auto renderTargetContext = GrRenderTargetContext::Make (
134
- context, srcColorType, std::move (finalCS), dstFit, {finalW, finalH} , 1 ,
132
+ context, srcColorType, std::move (finalCS), dstFit, dstSize , 1 ,
135
133
GrMipMapped::kNo , srcProxy->isProtected (), srcProxy->origin ());
136
134
if (!renderTargetContext) {
137
135
return nullptr ;
@@ -148,10 +146,9 @@ static std::unique_ptr<GrRenderTargetContext> convolve_gaussian_2d(GrRecordingCo
148
146
sigmaX, sigmaY);
149
147
paint.addColorFragmentProcessor (std::move (conv));
150
148
paint.setPorterDuffXPFactory (SkBlendMode::kSrc );
151
- GrFixedClip clip (SkIRect::MakeWH (finalW, finalH));
152
149
153
- renderTargetContext->fillRectWithLocalMatrix (clip , std::move (paint), GrAA::kNo , SkMatrix::I () ,
154
- SkRect::MakeWH (finalW, finalH ), localMatrix);
150
+ renderTargetContext->fillRectWithLocalMatrix (GrNoClip () , std::move (paint), GrAA::kNo ,
151
+ SkMatrix::I (), SkRect::Make (dstSize ), localMatrix);
155
152
156
153
return renderTargetContext;
157
154
}
@@ -175,29 +172,22 @@ static std::unique_ptr<GrRenderTargetContext> convolve_gaussian(GrRecordingConte
175
172
float sigma,
176
173
SkIRect* contentRect,
177
174
SkTileMode mode,
178
- int finalW,
179
- int finalH,
180
175
sk_sp<SkColorSpace> finalCS,
181
176
SkBackingFit fit) {
182
- SkASSERT (srcRect.width () <= finalW && srcRect.height () <= finalH);
183
-
184
177
auto dstRenderTargetContext = GrRenderTargetContext::Make (
185
178
context, srcColorType, std::move (finalCS), fit, srcRect.size (), 1 ,
186
179
GrMipMapped::kNo , srcProxy->isProtected (), srcProxy->origin ());
187
180
if (!dstRenderTargetContext) {
188
181
return nullptr ;
189
182
}
190
183
191
- GrFixedClip clip (SkIRect::MakeWH (finalW, finalH));
192
-
193
184
SkIRect dstRect = SkIRect::MakeWH (srcRect.width (), srcRect.height ());
194
185
SkIPoint netOffset = srcOffset - proxyOffset;
195
186
if (SkTileMode::kClamp == mode && proxyOffset.isZero () &&
196
187
contentRect->contains (SkIRect::MakeSize (srcProxy->backingStoreDimensions ()))) {
197
188
*contentRect = dstRect;
198
- convolve_gaussian_1d (dstRenderTargetContext.get (), clip, dstRect, netOffset,
199
- std::move (srcProxy), srcAlphaType, direction, radius, sigma,
200
- SkTileMode::kClamp , nullptr );
189
+ convolve_gaussian_1d (dstRenderTargetContext.get (), dstRect, netOffset, std::move (srcProxy),
190
+ srcAlphaType, direction, radius, sigma, SkTileMode::kClamp , nullptr );
201
191
return dstRenderTargetContext;
202
192
}
203
193
@@ -252,18 +242,16 @@ static std::unique_ptr<GrRenderTargetContext> convolve_gaussian(GrRecordingConte
252
242
253
243
if (midRect.isEmpty ()) {
254
244
// Blur radius covers srcBounds; use bounds over entire draw
255
- convolve_gaussian_1d (dstRenderTargetContext.get (), clip, dstRect, netOffset,
256
- std::move (srcProxy), srcAlphaType, direction, radius, sigma, mode,
257
- bounds);
245
+ convolve_gaussian_1d (dstRenderTargetContext.get (), dstRect, netOffset, std::move (srcProxy),
246
+ srcAlphaType, direction, radius, sigma, mode, bounds);
258
247
} else {
259
248
// Draw right and left margins with bounds; middle without.
260
- convolve_gaussian_1d (dstRenderTargetContext.get (), clip, leftRect, netOffset, srcProxy,
249
+ convolve_gaussian_1d (dstRenderTargetContext.get (), leftRect, netOffset, srcProxy,
261
250
srcAlphaType, direction, radius, sigma, mode, bounds);
262
- convolve_gaussian_1d (dstRenderTargetContext.get (), clip, rightRect, netOffset, srcProxy,
251
+ convolve_gaussian_1d (dstRenderTargetContext.get (), rightRect, netOffset, srcProxy,
263
252
srcAlphaType, direction, radius, sigma, mode, bounds);
264
- convolve_gaussian_1d (dstRenderTargetContext.get (), clip, midRect, netOffset,
265
- std::move (srcProxy), srcAlphaType, direction, radius, sigma,
266
- SkTileMode::kClamp , nullptr );
253
+ convolve_gaussian_1d (dstRenderTargetContext.get (), midRect, netOffset, std::move (srcProxy),
254
+ srcAlphaType, direction, radius, sigma, SkTileMode::kClamp , nullptr );
267
255
}
268
256
269
257
return dstRenderTargetContext;
@@ -364,44 +352,42 @@ static sk_sp<GrTextureProxy> decimate(GrRecordingContext* context,
364
352
// Expand the contents of 'srcRenderTargetContext' to fit in 'dstII'. At this point, we are
365
353
// expanding an intermediate image, so there's no need to account for a proxy offset from the
366
354
// original input.
367
- static std::unique_ptr<GrRenderTargetContext> reexpand (
368
- GrRecordingContext* context,
369
- std::unique_ptr<GrRenderTargetContext> srcRenderTargetContext,
370
- const SkIRect& localSrcBounds,
371
- int scaleFactorX, int scaleFactorY,
372
- int finalW,
373
- int finalH,
374
- sk_sp<SkColorSpace> finalCS,
375
- SkBackingFit fit) {
376
- const SkIRect srcRect = SkIRect::MakeWH (srcRenderTargetContext->width (),
377
- srcRenderTargetContext->height ());
378
-
379
- sk_sp<GrTextureProxy> srcProxy = srcRenderTargetContext->asTextureProxyRef ();
355
+ static std::unique_ptr<GrRenderTargetContext> reexpand (GrRecordingContext* context,
356
+ std::unique_ptr<GrRenderTargetContext> src,
357
+ const SkIRect& srcBounds,
358
+ int scaleFactorX,
359
+ int scaleFactorY,
360
+ SkISize dstSize,
361
+ sk_sp<SkColorSpace> colorSpace,
362
+ SkBackingFit fit) {
363
+ const SkIRect srcRect = SkIRect::MakeWH (src->width (), src->height ());
364
+
365
+ sk_sp<GrTextureProxy> srcProxy = src->asTextureProxyRef ();
380
366
if (!srcProxy) {
381
367
return nullptr ;
382
368
}
383
369
384
- GrColorType srcColorType = srcRenderTargetContext ->colorInfo ().colorType ();
385
- SkAlphaType srcAlphaType = srcRenderTargetContext ->colorInfo ().alphaType ();
370
+ GrColorType srcColorType = src ->colorInfo ().colorType ();
371
+ SkAlphaType srcAlphaType = src ->colorInfo ().alphaType ();
386
372
387
- srcRenderTargetContext = nullptr ; // no longer needed
373
+ src. reset () ; // no longer needed
388
374
389
375
auto dstRenderTargetContext = GrRenderTargetContext::Make (
390
- context, srcColorType, std::move (finalCS ), fit, {finalW, finalH}, 1 ,
391
- GrMipMapped:: kNo , srcProxy->isProtected (), srcProxy->origin ());
376
+ context, srcColorType, std::move (colorSpace ), fit, dstSize, 1 , GrMipMapped:: kNo ,
377
+ srcProxy->isProtected (), srcProxy->origin ());
392
378
if (!dstRenderTargetContext) {
393
379
return nullptr ;
394
380
}
395
381
396
382
GrPaint paint;
397
- SkRect domain = GrTextureDomain::MakeTexelDomain (localSrcBounds , GrTextureDomain::kClamp_Mode ,
383
+ SkRect domain = GrTextureDomain::MakeTexelDomain (srcBounds , GrTextureDomain::kClamp_Mode ,
398
384
GrTextureDomain::kClamp_Mode );
399
385
auto fp = GrTextureEffect::Make (std::move (srcProxy), srcAlphaType, SkMatrix::I (),
400
386
GrSamplerState::Filter::kBilerp );
401
387
fp = GrDomainEffect::Make (std::move (fp), domain, GrTextureDomain::kClamp_Mode , true );
402
388
paint.addColorFragmentProcessor (std::move (fp));
403
389
paint.setPorterDuffXPFactory (SkBlendMode::kSrc );
404
- GrFixedClip clip (SkIRect::MakeWH (finalW, finalH ));
390
+ GrFixedClip clip (SkIRect::MakeSize (dstSize ));
405
391
406
392
// TODO: using dstII as dstRect results in some image diffs - why?
407
393
SkIRect dstRect (srcRect);
@@ -419,8 +405,6 @@ static std::unique_ptr<GrRenderTargetContext> two_pass_gaussian(GrRecordingConte
419
405
SkAlphaType srcAlphaType,
420
406
sk_sp<SkColorSpace> colorSpace,
421
407
SkIPoint proxyOffset,
422
- int finalW,
423
- int finalH,
424
408
SkIRect srcRect,
425
409
SkIPoint srcOffset,
426
410
SkIRect* srcBounds,
@@ -433,10 +417,9 @@ static std::unique_ptr<GrRenderTargetContext> two_pass_gaussian(GrRecordingConte
433
417
std::unique_ptr<GrRenderTargetContext> dstRenderTargetContext;
434
418
if (sigmaX > 0 .0f ) {
435
419
SkBackingFit xFit = sigmaY > 0 ? SkBackingFit::kApprox : fit;
436
- dstRenderTargetContext =
437
- convolve_gaussian (context, std::move (srcProxy), srcColorType, srcAlphaType,
438
- proxyOffset, srcRect, srcOffset, Direction::kX , radiusX, sigmaX,
439
- srcBounds, mode, finalW, finalH, colorSpace, xFit);
420
+ dstRenderTargetContext = convolve_gaussian (
421
+ context, std::move (srcProxy), srcColorType, srcAlphaType, proxyOffset, srcRect,
422
+ srcOffset, Direction::kX , radiusX, sigmaX, srcBounds, mode, colorSpace, xFit);
440
423
if (!dstRenderTargetContext) {
441
424
return nullptr ;
442
425
}
@@ -451,9 +434,9 @@ static std::unique_ptr<GrRenderTargetContext> two_pass_gaussian(GrRecordingConte
451
434
return dstRenderTargetContext;
452
435
}
453
436
454
- return convolve_gaussian (context, std::move (srcProxy), srcColorType, srcAlphaType,
455
- proxyOffset, srcRect, srcOffset, Direction::kY , radiusY, sigmaY,
456
- srcBounds, mode, finalW, finalH, colorSpace, fit);
437
+ return convolve_gaussian (context, std::move (srcProxy), srcColorType, srcAlphaType, proxyOffset,
438
+ srcRect, srcOffset, Direction::kY , radiusY, sigmaY, srcBounds, mode ,
439
+ colorSpace, fit);
457
440
}
458
441
459
442
namespace SkGpuBlurUtils {
@@ -474,9 +457,6 @@ std::unique_ptr<GrRenderTargetContext> GaussianBlur(GrRecordingContext* context,
474
457
475
458
TRACE_EVENT2 (" skia.gpu" , " GaussianBlur" , " sigmaX" , sigmaX, " sigmaY" , sigmaY);
476
459
477
- int finalW = dstBounds.width ();
478
- int finalH = dstBounds.height ();
479
-
480
460
int scaleFactorX, radiusX;
481
461
int scaleFactorY, radiusY;
482
462
int maxTextureSize = context->priv ().caps ()->maxTextureSize ();
@@ -494,32 +474,30 @@ std::unique_ptr<GrRenderTargetContext> GaussianBlur(GrRecordingContext* context,
494
474
// Apply the proxy offset to src bounds and offset directly
495
475
return convolve_gaussian_2d (context, std::move (srcProxy), srcColorType,
496
476
srcBounds.makeOffset (proxyOffset), srcOffset - proxyOffset,
497
- radiusX, radiusY, sigmaX, sigmaY, mode, finalW, finalH ,
477
+ radiusX, radiusY, sigmaX, sigmaY, mode, dstBounds. size () ,
498
478
colorSpace, fit);
499
479
}
500
- auto srcRect = SkIRect::MakeWH (finalW, finalH );
480
+ auto srcRect = SkIRect::MakeSize (dstBounds. size () );
501
481
return two_pass_gaussian (context, std::move (srcProxy), srcColorType, srcAlphaType,
502
- std::move (colorSpace), proxyOffset, finalW, finalH, srcRect,
503
- srcOffset, &localSrcBounds, sigmaX, sigmaY, radiusX, radiusY, mode,
504
- fit);
482
+ std::move (colorSpace), proxyOffset, srcRect, srcOffset,
483
+ &localSrcBounds, sigmaX, sigmaY, radiusX, radiusY, mode, fit);
505
484
}
506
485
507
486
srcProxy = decimate (context, std::move (srcProxy), srcColorType, srcAlphaType, proxyOffset,
508
487
&srcOffset, &localSrcBounds, scaleFactorX, scaleFactorY, mode, colorSpace);
509
488
if (!srcProxy) {
510
489
return nullptr ;
511
490
}
512
- auto srcRect = SkIRect::MakeWH (finalW, finalH );
491
+ auto srcRect = SkIRect::MakeSize (dstBounds. size () );
513
492
scale_irect_roundout (&srcRect, 1 .0f / scaleFactorX, 1 .0f / scaleFactorY);
514
- auto rtc =
515
- two_pass_gaussian (context, std::move (srcProxy), srcColorType, srcAlphaType, colorSpace,
516
- {0 , 0 }, finalW, finalH, srcRect, srcOffset, &localSrcBounds, sigmaX,
517
- sigmaY, radiusX, radiusY, mode, SkBackingFit::kApprox );
493
+ auto rtc = two_pass_gaussian (context, std::move (srcProxy), srcColorType, srcAlphaType,
494
+ colorSpace, {0 , 0 }, srcRect, srcOffset, &localSrcBounds, sigmaX,
495
+ sigmaY, radiusX, radiusY, mode, SkBackingFit::kApprox );
518
496
if (!rtc) {
519
497
return nullptr ;
520
498
}
521
- return reexpand (context, std::move (rtc), localSrcBounds, scaleFactorX, scaleFactorY, finalW,
522
- finalH , std::move (colorSpace), fit);
499
+ return reexpand (context, std::move (rtc), localSrcBounds, scaleFactorX, scaleFactorY,
500
+ dstBounds. size () , std::move (colorSpace), fit);
523
501
}
524
502
525
503
}
0 commit comments