| 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 | |
| 21 | |
| 22 static GrBatch* Create(const SkMatrix& viewMatrix, | 20 static GrBatch* Create(const SkMatrix& viewMatrix, |
| 23 bool useHWAA, | 21 bool useHWAA, |
| 24 const GrStencilSettings& stencil, | 22 const GrStencilSettings& stencil, |
| 25 const GrScissorState& scissor, | 23 const GrScissorState& scissor, |
| 26 GrRenderTarget* renderTarget, | 24 GrRenderTarget* renderTarget, |
| 27 const GrPath* path) { | 25 const GrPath* path) { |
| 28 return new GrStencilPathBatch(viewMatrix, useHWAA, stencil, scissor, ren
derTarget, path); | 26 return new GrStencilPathBatch(viewMatrix, useHWAA, stencil, scissor, ren
derTarget, path); |
| 29 } | 27 } |
| 30 | 28 |
| 31 const char* name() const override { return "StencilPath"; } | 29 const char* name() const override { return "StencilPath"; } |
| 32 | 30 |
| 33 uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()-
>getUniqueID(); } | 31 uint32_t renderTargetUniqueID() const override { return fRenderTarget.get()-
>getUniqueID(); } |
| 34 | 32 |
| 35 SkString dumpInfo() const override { | 33 SkString dumpInfo() const override { |
| 36 SkString string; | 34 SkString string; |
| 37 string.printf("PATH: 0x%p, AA:%d", fPath.get(), fUseHWAA); | 35 string.printf("PATH: 0x%p, AA:%d", fPath.get(), fUseHWAA); |
| 38 return string; | 36 return string; |
| 39 } | 37 } |
| 40 | 38 |
| 41 private: | 39 private: |
| 42 GrStencilPathBatch(const SkMatrix& viewMatrix, | 40 GrStencilPathBatch(const SkMatrix& viewMatrix, |
| 43 bool useHWAA, | 41 bool useHWAA, |
| 44 const GrStencilSettings& stencil, | 42 const GrStencilSettings& stencil, |
| 45 const GrScissorState& scissor, | 43 const GrScissorState& scissor, |
| 46 GrRenderTarget* renderTarget, | 44 GrRenderTarget* renderTarget, |
| 47 const GrPath* path) | 45 const GrPath* path) |
| 48 : INHERITED(ClassID()) | 46 : fViewMatrix(viewMatrix) |
| 49 , fViewMatrix(viewMatrix) | |
| 50 , fUseHWAA(useHWAA) | 47 , fUseHWAA(useHWAA) |
| 51 , fStencil(stencil) | 48 , fStencil(stencil) |
| 52 , fScissor(scissor) | 49 , fScissor(scissor) |
| 53 , fRenderTarget(renderTarget) | 50 , fRenderTarget(renderTarget) |
| 54 , fPath(path) { | 51 , fPath(path) { |
| 52 this->initClassID<GrStencilPathBatch>(); |
| 55 fBounds = path->getBounds(); | 53 fBounds = path->getBounds(); |
| 56 } | 54 } |
| 57 | 55 |
| 58 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return f
alse; } | 56 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return f
alse; } |
| 59 | 57 |
| 60 void onPrepare(GrBatchFlushState*) override {} | 58 void onPrepare(GrBatchFlushState*) override {} |
| 61 | 59 |
| 62 void onDraw(GrBatchFlushState* state) override { | 60 void onDraw(GrBatchFlushState* state) override { |
| 63 GrPathRendering::StencilPathArgs args(fUseHWAA, fRenderTarget.get(), &fV
iewMatrix, | 61 GrPathRendering::StencilPathArgs args(fUseHWAA, fRenderTarget.get(), &fV
iewMatrix, |
| 64 &fScissor, &fStencil); | 62 &fScissor, &fStencil); |
| 65 state->gpu()->pathRendering()->stencilPath(args, fPath.get()); | 63 state->gpu()->pathRendering()->stencilPath(args, fPath.get()); |
| 66 } | 64 } |
| 67 | 65 |
| 68 SkMatrix fViewMatrix; | 66 SkMatrix fViewMatrix; |
| 69 bool fUseHWAA; | 67 bool fUseHWAA; |
| 70 GrStencilSettings fStencil; | 68 GrStencilSettings fStencil; |
| 71 GrScissorState fScissor; | 69 GrScissorState fScissor; |
| 72 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; | 70 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; |
| 73 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; | 71 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; |
| 74 | |
| 75 typedef GrBatch INHERITED; | |
| 76 }; | 72 }; |
| 77 | 73 |
| 78 #endif | 74 #endif |
| OLD | NEW |