SkDevice::drawSpecial accepts arbitrary matrix v2
This opens up the door to render image filter results with an arbitrary
matrix, so we can skip the matrix filter DAG hack. It should also let
me simplify the handling of backdrop image filters and correctly apply
perspective to image filters.
This is essentially the same as
https://skia-review.googlesource.com/c/skia/+/317862
but not parented to the CL that experimented with SkImagePaint.
Some of the function declaration re-org that was done in its prior CL
has been directly integrated into this CL.
Bug: skia:9545
Change-Id: Iad882bd306f3a4064fe60cfc0526226287ea7e29
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/323597
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index e54cea2..88221a7 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -651,17 +651,20 @@
//////////////////////////////////////////////////////////////////////////////
-void SkGpuDevice::drawSpecial(SkSpecialImage* special, int left, int top, const SkPaint& paint) {
+void SkGpuDevice::drawSpecial(SkSpecialImage* special, const SkMatrix& localToDevice,
+ const SkPaint& paint) {
SkASSERT(!paint.getMaskFilter() && !paint.getImageFilter());
SkASSERT(special->isTextureBacked());
SkRect src = SkRect::Make(special->subset());
- SkRect dst = SkRect::MakeXYWH(left, top, special->width(), special->height());
+ SkRect dst = SkRect::MakeWH(special->width(), special->height());
SkMatrix srcToDst = SkMatrix::MakeRectToRect(src, dst, SkMatrix::kFill_ScaleToFit);
- // TODO (michaelludwig): Once drawSpecial uses arbitrary transforms between two SkGpuDevices,
- // always using kNearest may not be the right choice anymore.
- GrSamplerState sampler(GrSamplerState::WrapMode::kClamp, GrSamplerState::Filter::kNearest);
+ GrSamplerState sampler(GrSamplerState::WrapMode::kClamp,
+ paint.getFilterQuality() >= kLow_SkFilterQuality ?
+ GrSamplerState::Filter::kLinear : GrSamplerState::Filter::kNearest);
+ GrAA aa = paint.isAntiAlias() ? GrAA::kYes : GrAA::kNo;
+ GrQuadAAFlags aaFlags = paint.isAntiAlias() ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone;
GrColorInfo colorInfo(SkColorTypeToGrColorType(special->colorType()),
special->alphaType(), sk_ref_sp(special->getColorSpace()));
@@ -670,11 +673,10 @@
GrTextureAdjuster texture(fContext.get(), std::move(view), colorInfo, special->uniqueID());
// In most cases this ought to hit draw_texture since there won't be a color filter,
// alpha-only texture+shader, or a high filter quality.
- SkOverrideDeviceMatrixProvider identity(this->asMatrixProvider(), SkMatrix::I());
+ SkOverrideDeviceMatrixProvider matrixProvider(this->asMatrixProvider(), localToDevice);
draw_texture_producer(fContext.get(), fRenderTargetContext.get(), this->clip(),
- identity, paint, &texture, src, dst, nullptr, srcToDst, GrAA::kNo,
- GrQuadAAFlags::kNone, SkCanvas::kStrict_SrcRectConstraint,
- sampler, false);
+ matrixProvider, paint, &texture, src, dst, nullptr, srcToDst, aa,
+ aaFlags, SkCanvas::kStrict_SrcRectConstraint, sampler, false);
}
void SkGpuDevice::drawImageQuad(const SkImage* image, const SkRect* srcRect, const SkRect* dstRect,