ccpr: Handle winding and even-odd in the same shader
We are already waiting for an entire texture lookup anyway. A couple
extra flops should still complete before the texture fetch. This also
gives us better batching.
TBR=bsalomon@google.com
Bug: skia:
Change-Id: I7b8e3021c8baad200af99600c9592df5ed0e46bd
Reviewed-on: https://skia-review.googlesource.com/129881
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Auto-Submit: Chris Dalton <csmartdalton@google.com>
diff --git a/src/gpu/ccpr/GrCCPathProcessor.h b/src/gpu/ccpr/GrCCPathProcessor.h
index 4789326..198bc60 100644
--- a/src/gpu/ccpr/GrCCPathProcessor.h
+++ b/src/gpu/ccpr/GrCCPathProcessor.h
@@ -38,13 +38,14 @@
static constexpr int kNumInstanceAttribs = 1 + (int)InstanceAttribs::kColor;
struct Instance {
- SkRect fDevBounds;
+ SkRect fDevBounds; // "right < left" indicates even-odd fill type.
SkRect fDevBounds45; // Bounding box in "| 1 -1 | * devCoords" space.
// | 1 1 |
std::array<int16_t, 2> fAtlasOffset;
uint32_t fColor;
- GR_STATIC_ASSERT(SK_SCALAR_IS_FLOAT);
+ void set(SkPath::FillType, const SkRect& devBounds, const SkRect& devBounds45,
+ int16_t atlasOffsetX, int16_t atlasOffsetY, uint32_t color);
};
GR_STATIC_ASSERT(4 * 10 == sizeof(Instance));
@@ -52,14 +53,13 @@
static sk_sp<const GrBuffer> FindVertexBuffer(GrOnFlushResourceProvider*);
static sk_sp<const GrBuffer> FindIndexBuffer(GrOnFlushResourceProvider*);
- GrCCPathProcessor(GrResourceProvider*, sk_sp<GrTextureProxy> atlas, SkPath::FillType,
+ GrCCPathProcessor(GrResourceProvider*, sk_sp<GrTextureProxy> atlas,
const SkMatrix& viewMatrixIfUsingLocalCoords = SkMatrix::I());
const char* name() const override { return "GrCCPathProcessor"; }
const GrSurfaceProxy* atlasProxy() const { return fAtlasAccess.proxy(); }
const GrTexture* atlas() const { return fAtlasAccess.peekTexture(); }
const SkMatrix& localMatrix() const { return fLocalMatrix; }
- SkPath::FillType fillType() const { return fFillType; }
const Attribute& getInstanceAttrib(InstanceAttribs attribID) const {
const Attribute& attrib = this->getAttrib((int)attribID);
SkASSERT(Attribute::InputRate::kPerInstance == attrib.fInputRate);
@@ -72,7 +72,7 @@
return attrib;
}
- void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
+ void getGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {}
GrGLSLPrimitiveProcessor* createGLSLInstance(const GrShaderCaps&) const override;
void drawPaths(GrOpFlushState*, const GrPipeline&, const GrBuffer* indexBuffer,
@@ -80,11 +80,25 @@
int endInstance, const SkRect& bounds) const;
private:
- const SkPath::FillType fFillType;
const TextureSampler fAtlasAccess;
SkMatrix fLocalMatrix;
typedef GrGeometryProcessor INHERITED;
};
+inline void GrCCPathProcessor::Instance::set(SkPath::FillType fillType, const SkRect& devBounds,
+ const SkRect& devBounds45, int16_t atlasOffsetX,
+ int16_t atlasOffsetY, uint32_t color) {
+ if (SkPath::kEvenOdd_FillType == fillType) {
+ // "right < left" indicates even-odd fill type.
+ fDevBounds.setLTRB(devBounds.fRight, devBounds.fTop, devBounds.fLeft, devBounds.fBottom);
+ } else {
+ SkASSERT(SkPath::kWinding_FillType == fillType);
+ fDevBounds = devBounds;
+ }
+ fDevBounds45 = devBounds45;
+ fAtlasOffset = {{atlasOffsetX, atlasOffsetY}};
+ fColor = color;
+}
+
#endif