diff options
author | Chris Dalton <csmartdalton@google.com> | 2018-05-22 18:58:22 -0600 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-05-23 19:56:01 +0000 |
commit | 5dd3fccb3c7d9fce2663803a1284734237d8546d (patch) | |
tree | 0d9e6c19f0d4fdd5a3dd4bf81b3bd686529c7de1 /src/gpu/ccpr/GrCCPathProcessor.h | |
parent | b3ba29c2e3a1c79db1cd810d77ec6c4001436089 (diff) |
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.
Bug: skia:
Change-Id: I83a7a8ba6c05cd1ad6b1756a987429233e69ed6c
Reviewed-on: https://skia-review.googlesource.com/129422
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/ccpr/GrCCPathProcessor.h')
-rw-r--r-- | src/gpu/ccpr/GrCCPathProcessor.h | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/gpu/ccpr/GrCCPathProcessor.h b/src/gpu/ccpr/GrCCPathProcessor.h index 47893266da..198bc60d20 100644 --- a/src/gpu/ccpr/GrCCPathProcessor.h +++ b/src/gpu/ccpr/GrCCPathProcessor.h @@ -38,13 +38,14 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 |