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