Remove GrDeviceSpaceTextureDecalFragmentProcessor.
It was used to sample clip masks using device coords.
Replace with a more generic GrDeviceSpaceEffect that simply calls a
child FP with sk_FragCoord.
Also fix issue in GrQuadPerEdgeAA GP. It wouldn't setup coord transforms
at all if they are all applied in the FS (explicit coords). Moreover,
the GrGLSLGeometryProcessor::emitTransforms() helper required a valid VS
var for local coords even when all FPs use explicit coords and wouldn't
use a local coords var.
Make CPP SkSL code gen for clone copy the explicit coord status of
children.
Change-Id: Ib8bb36028354405c8012f6e91e9eb46db75d16a6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/271658
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp
index 2c5a941..66f2de8 100644
--- a/src/gpu/GrClipStackClip.cpp
+++ b/src/gpu/GrClipStackClip.cpp
@@ -5,12 +5,13 @@
* found in the LICENSE file.
*/
+#include "src/gpu/GrClipStackClip.h"
+
#include "include/private/SkTo.h"
#include "src/core/SkClipOpPriv.h"
#include "src/core/SkTaskGroup.h"
#include "src/core/SkTraceEvent.h"
#include "src/gpu/GrAppliedClip.h"
-#include "src/gpu/GrClipStackClip.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrDeferredProxyUploader.h"
#include "src/gpu/GrDrawingManager.h"
@@ -26,6 +27,7 @@
#include "src/gpu/effects/GrConvexPolyEffect.h"
#include "src/gpu/effects/GrRRectEffect.h"
#include "src/gpu/effects/GrTextureDomain.h"
+#include "src/gpu/effects/generated/GrDeviceSpaceEffect.h"
#include "src/gpu/geometry/GrShape.h"
typedef SkClipStack::Element Element;
@@ -78,11 +80,18 @@
////////////////////////////////////////////////////////////////////////////////
// set up the draw state to enable the aa clipping mask.
static std::unique_ptr<GrFragmentProcessor> create_fp_for_mask(GrSurfaceProxyView mask,
- const SkIRect& devBound) {
- SkASSERT(mask.asTextureProxy());
- SkIRect domainTexels = SkIRect::MakeWH(devBound.width(), devBound.height());
- return GrDeviceSpaceTextureDecalFragmentProcessor::Make(std::move(mask), domainTexels,
- {devBound.fLeft, devBound.fTop});
+ const SkIRect& devBound,
+ const GrCaps& caps) {
+ GrSamplerState samplerState(GrSamplerState::WrapMode::kClampToBorder,
+ GrSamplerState::Filter::kNearest);
+ auto m = SkMatrix::MakeTrans(-devBound.fLeft, -devBound.fTop);
+ auto subset = SkRect::Make(devBound.size());
+ // We scissor to devBounds. The mask's texel centers are aligned to device space
+ // pixel centers. Hence this domain of texture coordinates.
+ auto domain = subset.makeInset(0.5, 0.5);
+ auto fp = GrTextureEffect::MakeSubset(std::move(mask), kPremul_SkAlphaType, m, samplerState,
+ subset, domain, caps);
+ return GrDeviceSpaceEffect::Make(std::move(fp));
}
// Does the path in 'element' require SW rendering? If so, return true (and,
@@ -283,7 +292,8 @@
if (result) {
// The mask's top left coord should be pinned to the rounded-out top left corner of
// the clip's device space bounds.
- out->addCoverageFP(create_fp_for_mask(std::move(result), reducedClip.scissor()));
+ out->addCoverageFP(create_fp_for_mask(std::move(result), reducedClip.scissor(),
+ *context->priv().caps()));
return true;
}