| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrStencilPathBatch_DEFINED | 8 #ifndef GrStencilPathBatch_DEFINED |
| 9 #define GrStencilPathBatch_DEFINED | 9 #define GrStencilPathBatch_DEFINED |
| 10 | 10 |
| 11 #include "GrBatch.h" | 11 #include "GrBatch.h" |
| 12 #include "GrBatchFlushState.h" | 12 #include "GrBatchFlushState.h" |
| 13 #include "GrGpu.h" | 13 #include "GrGpu.h" |
| 14 #include "GrPath.h" | 14 #include "GrPath.h" |
| 15 #include "GrPathRendering.h" | 15 #include "GrPathRendering.h" |
| 16 #include "GrRenderTarget.h" | 16 #include "GrRenderTarget.h" |
| 17 | 17 |
| 18 class GrStencilPathBatch final : public GrBatch { | 18 class GrStencilPathBatch final : public GrBatch { |
| 19 public: | 19 public: |
| 20 DEFINE_BATCH_CLASS_ID | 20 DEFINE_BATCH_CLASS_ID |
| 21 | 21 |
| 22 static GrBatch* Create(const SkMatrix& viewMatrix, | 22 static GrBatch* Create(const SkMatrix& viewMatrix, |
| 23 bool useHWAA, | 23 bool useHWAA, |
| 24 const GrUserStencilSettings& userStencil, | 24 GrPathRendering::FillType fillType, |
| 25 bool hasStencilClip, | 25 bool hasStencilClip, |
| 26 int numStencilBits, | 26 int numStencilBits, |
| 27 const GrScissorState& scissor, | 27 const GrScissorState& scissor, |
| 28 GrRenderTarget* renderTarget, | 28 GrRenderTarget* renderTarget, |
| 29 const GrPath* path) { | 29 const GrPath* path) { |
| 30 return new GrStencilPathBatch(viewMatrix, useHWAA, userStencil, hasStenc
ilClip, | 30 return new GrStencilPathBatch(viewMatrix, useHWAA, fillType, hasStencilC
lip, |
| 31 numStencilBits, scissor, renderTarget, pat
h); | 31 numStencilBits, scissor, renderTarget, pat
h); |
| 32 } | 32 } |
| 33 | 33 |
| 34 const char* name() const override { return "StencilPath"; } | 34 const char* name() const override { return "StencilPath"; } |
| 35 | 35 |
| 36 uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()-
>getUniqueID(); } | 36 uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()-
>getUniqueID(); } |
| 37 GrRenderTarget* renderTarget() const override { return fRenderTarget.get();
} | 37 GrRenderTarget* renderTarget() const override { return fRenderTarget.get();
} |
| 38 | 38 |
| 39 SkString dumpInfo() const override { | 39 SkString dumpInfo() const override { |
| 40 SkString string; | 40 SkString string; |
| 41 string.printf("PATH: 0x%p, AA:%d", fPath.get(), fUseHWAA); | 41 string.printf("PATH: 0x%p, AA:%d", fPath.get(), fUseHWAA); |
| 42 return string; | 42 return string; |
| 43 } | 43 } |
| 44 | 44 |
| 45 private: | 45 private: |
| 46 GrStencilPathBatch(const SkMatrix& viewMatrix, | 46 GrStencilPathBatch(const SkMatrix& viewMatrix, |
| 47 bool useHWAA, | 47 bool useHWAA, |
| 48 const GrUserStencilSettings& userStencil, | 48 GrPathRendering::FillType fillType, |
| 49 bool hasStencilClip, | 49 bool hasStencilClip, |
| 50 int numStencilBits, | 50 int numStencilBits, |
| 51 const GrScissorState& scissor, | 51 const GrScissorState& scissor, |
| 52 GrRenderTarget* renderTarget, | 52 GrRenderTarget* renderTarget, |
| 53 const GrPath* path) | 53 const GrPath* path) |
| 54 : INHERITED(ClassID()) | 54 : INHERITED(ClassID()) |
| 55 , fViewMatrix(viewMatrix) | 55 , fViewMatrix(viewMatrix) |
| 56 , fUseHWAA(useHWAA) | 56 , fUseHWAA(useHWAA) |
| 57 , fStencil(userStencil, hasStencilClip, numStencilBits) | 57 , fStencil(GrPathRendering::GetStencilPassSettings(fillType), hasStencilClip
, numStencilBits) |
| 58 , fScissor(scissor) | 58 , fScissor(scissor) |
| 59 , fRenderTarget(renderTarget) | 59 , fRenderTarget(renderTarget) |
| 60 , fPath(path) { | 60 , fPath(path) { |
| 61 fBounds = path->getBounds(); | 61 fBounds = path->getBounds(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return f
alse; } | 64 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return f
alse; } |
| 65 | 65 |
| 66 void onPrepare(GrBatchFlushState*) override {} | 66 void onPrepare(GrBatchFlushState*) override {} |
| 67 | 67 |
| 68 void onDraw(GrBatchFlushState* state) override { | 68 void onDraw(GrBatchFlushState* state) override { |
| 69 GrPathRendering::StencilPathArgs args(fUseHWAA, fRenderTarget.get(), &fV
iewMatrix, | 69 GrPathRendering::StencilPathArgs args(fUseHWAA, fRenderTarget.get(), &fV
iewMatrix, |
| 70 &fScissor, &fStencil); | 70 &fScissor, &fStencil); |
| 71 state->gpu()->pathRendering()->stencilPath(args, fPath.get()); | 71 state->gpu()->pathRendering()->stencilPath(args, fPath.get()); |
| 72 } | 72 } |
| 73 | 73 |
| 74 SkMatrix fViewMatrix; | 74 SkMatrix fViewMatrix; |
| 75 bool fUseHWAA; | 75 bool fUseHWAA; |
| 76 GrStencilSettings fStencil; | 76 GrStencilSettings fStencil; |
| 77 GrScissorState fScissor; | 77 GrScissorState fScissor; |
| 78 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; | 78 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; |
| 79 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; | 79 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; |
| 80 | 80 |
| 81 typedef GrBatch INHERITED; | 81 typedef GrBatch INHERITED; |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 #endif | 84 #endif |
| OLD | NEW |