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/geometry/GrQuad.cpp b/src/gpu/geometry/GrQuad.cpp
index 78f4e3b..3df11ca 100644
--- a/src/gpu/geometry/GrQuad.cpp
+++ b/src/gpu/geometry/GrQuad.cpp
@@ -132,3 +132,14 @@
// If rect, ws must all be 1s so no need to divide
return aa_affects_rect(fX[0], fY[0], fX[3], fY[3]);
}
+
+bool GrQuad::asRect(SkRect* rect) const {
+ if (this->quadType() != Type::kAxisAligned) {
+ return false;
+ }
+
+ *rect = this->bounds();
+ // v0 at the geometric top-left is unique amongst axis-aligned vertex orders
+ // (90, 180, 270 rotations or axis flips all move v0).
+ return fX[0] == rect->fLeft && fY[0] == rect->fTop;
+}