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