Add generic texture op factory.
This adds a new factory for GrTextureOp that generalizes the current
Make() and MakeQuad(). A following CL will remove those calls.
This also moves the texture-op emulation with GrFillRectOp into this
factory call. I found this to make more sense, both because it makes
op creation callsites simpler (drawTexturedQuad, drawTexture, and
drawTextureSet don't have to check the blend mode anymore). Additionally
the logic for matching the texture op shading behavior to a GrPaint
now lives inside GrTextureOp.
To allow for this, the to-be-removed existing factories have had the
blend mode added to their arguments as well.
Change-Id: Icda346cd203ae8caa7f5ed762ed4e0a214084dda
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/223924
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/ops/GrTextureOp.h b/src/gpu/ops/GrTextureOp.h
index 8061a35..2bf43b4 100644
--- a/src/gpu/ops/GrTextureOp.h
+++ b/src/gpu/ops/GrTextureOp.h
@@ -21,12 +21,29 @@
namespace GrTextureOp {
/**
- * Creates an op that draws a sub-rectangle of a texture. The passed color is modulated by the
- * texture's color. 'srcRect' specifies the rectangle of the texture to draw. 'dstRect' specifies
- * the rectangle to draw in local coords which will be transformed by 'viewMatrix' to be in device
- * space. 'viewMatrix' must be affine. If GrAAType is kCoverage then AA is applied to the edges
+ * Creates an op that draws a sub-quadrilateral of a texture. The passed color is modulated by the
+ * texture's color. 'deviceQuad' specifies the device-space coordinates to draw, using 'localQuad'
+ * to map into the proxy's texture space. If non-null, 'domain' represents the boundary for the
+ * strict src rect constraint. If GrAAType is kCoverage then AA is applied to the edges
* indicated by GrQuadAAFlags. Otherwise, GrQuadAAFlags is ignored.
+ *
+ * This is functionally very similar to GrFillRectOp::Make, except that the GrPaint has been
+ * deconstructed into the texture, filter, modulating color, and blend mode. When blend mode is
+ * src over, this will return a GrFillRectOp with a paint that samples the proxy.
*/
+std::unique_ptr<GrDrawOp> MakeGeneral(GrRecordingContext* context,
+ sk_sp<GrTextureProxy> proxy,
+ sk_sp<GrColorSpaceXform> textureXform,
+ GrSamplerState::Filter filter,
+ const SkPMColor4f& color,
+ SkBlendMode blendMode,
+ GrAAType aaType,
+ GrQuadAAFlags aaFlags,
+ const GrQuad& deviceQuad,
+ const GrQuad& localQuad,
+ const SkRect* domain = nullptr);
+
+// FIXME (michaelludwig) - To be removed
std::unique_ptr<GrDrawOp> Make(GrRecordingContext*,
sk_sp<GrTextureProxy>,
GrSamplerState::Filter,
@@ -37,11 +54,13 @@
GrQuadAAFlags,
SkCanvas::SrcRectConstraint,
const SkMatrix& viewMatrix,
- sk_sp<GrColorSpaceXform> textureXform);
+ sk_sp<GrColorSpaceXform> textureXform,
+ SkBlendMode blendMode = SkBlendMode::kSrcOver);
// Generalizes the above subrect drawing operation to draw a subquad of an image, where srcQuad
// and dstQuad correspond to srcRect and dstRect. If domain is not null, this behaves as if it
// had a strict constraint relying on the given domain.
+// FIXME (michaelludwig) - To be removed
std::unique_ptr<GrDrawOp> MakeQuad(GrRecordingContext* context,
sk_sp<GrTextureProxy>,
GrSamplerState::Filter,
@@ -52,8 +71,10 @@
GrQuadAAFlags,
const SkRect* domain,
const SkMatrix& viewMatrix,
- sk_sp<GrColorSpaceXform> textureXform);
+ sk_sp<GrColorSpaceXform> textureXform,
+ SkBlendMode blendMode = SkBlendMode::kSrcOver);
+// Unlike the single-proxy factory, this only supports src-over blending.
std::unique_ptr<GrDrawOp> MakeSet(GrRecordingContext*,
const GrRenderTargetContext::TextureSetEntry[],
int cnt,
@@ -63,10 +84,4 @@
const SkMatrix& viewMatrix,
sk_sp<GrColorSpaceXform> textureXform);
-/**
- * Returns true if bilerp texture filtering matters when rendering the src rect
- * texels to dst rect, with the given view matrix.
- */
-bool GetFilterHasEffect(const SkMatrix& viewMatrix, const SkRect& srcRect, const SkRect& dstRect);
-
}