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 GrPathRendering::FillType fillType, | 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 GrRenderTargetProxy* rtp, |
29 const GrPath* path) { | 29 const GrPath* path) { |
30 return new GrStencilPathBatch(viewMatrix, useHWAA, fillType, hasStencilC
lip, | 30 return new GrStencilPathBatch(viewMatrix, useHWAA, fillType, hasStencilC
lip, |
31 numStencilBits, scissor, renderTarget, pat
h); | 31 numStencilBits, scissor, rtp, path); |
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()-
>uniqueID(); } | 36 uint32_t renderTargetUniqueID() const override { return fRenderTargetProxy.g
et()->uniqueID(); } |
37 GrRenderTarget* renderTarget() const override { return fRenderTarget.get();
} | 37 GrRenderTargetProxy* rtp() const override { return fRenderTargetProxy.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 string.append(INHERITED::dumpInfo()); | 42 string.append(INHERITED::dumpInfo()); |
43 return string; | 43 return string; |
44 } | 44 } |
45 | 45 |
46 private: | 46 private: |
47 GrStencilPathBatch(const SkMatrix& viewMatrix, | 47 GrStencilPathBatch(const SkMatrix& viewMatrix, |
48 bool useHWAA, | 48 bool useHWAA, |
49 GrPathRendering::FillType fillType, | 49 GrPathRendering::FillType fillType, |
50 bool hasStencilClip, | 50 bool hasStencilClip, |
51 int numStencilBits, | 51 int numStencilBits, |
52 const GrScissorState& scissor, | 52 const GrScissorState& scissor, |
53 GrRenderTarget* renderTarget, | 53 GrRenderTargetProxy* rtp, |
54 const GrPath* path) | 54 const GrPath* path) |
55 : INHERITED(ClassID()) | 55 : INHERITED(ClassID()) |
56 , fViewMatrix(viewMatrix) | 56 , fViewMatrix(viewMatrix) |
57 , fUseHWAA(useHWAA) | 57 , fUseHWAA(useHWAA) |
58 , fStencil(GrPathRendering::GetStencilPassSettings(fillType), hasStencilClip
, numStencilBits) | 58 , fStencil(GrPathRendering::GetStencilPassSettings(fillType), hasStencilClip
, numStencilBits) |
59 , fScissor(scissor) | 59 , fScissor(scissor) |
60 , fRenderTarget(renderTarget) | 60 , fRenderTargetProxy(rtp) |
61 , fPath(path) { | 61 , fPath(path) { |
62 this->setBounds(path->getBounds(), HasAABloat::kNo, IsZeroArea::kNo); | 62 this->setBounds(path->getBounds(), HasAABloat::kNo, IsZeroArea::kNo); |
63 } | 63 } |
64 | 64 |
65 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return f
alse; } | 65 bool onCombineIfPossible(GrBatch* t, const GrCaps& caps) override { return f
alse; } |
66 | 66 |
67 void onPrepare(GrBatchFlushState*) override {} | 67 void onPrepare(GrBatchFlushState*) override {} |
68 | 68 |
69 void onDraw(GrBatchFlushState* state, const SkRect& bounds) override { | 69 void onDraw(GrBatchFlushState* state, const SkRect& bounds) override { |
70 GrPathRendering::StencilPathArgs args(fUseHWAA, fRenderTarget.get(), &fV
iewMatrix, | 70 GrTextureProvider* prov = state->gpu()->getContext()->textureProvider(); |
| 71 GrRenderTarget* renderTarget = fRenderTargetProxy.get()->instantiate(pro
v); |
| 72 GrPathRendering::StencilPathArgs args(fUseHWAA, renderTarget, &fViewMatr
ix, |
71 &fScissor, &fStencil); | 73 &fScissor, &fStencil); |
72 state->gpu()->pathRendering()->stencilPath(args, fPath.get()); | 74 state->gpu()->pathRendering()->stencilPath(args, fPath.get()); |
73 } | 75 } |
74 | 76 |
75 SkMatrix fViewMatrix; | 77 SkMatrix fViewMatrix; |
76 bool fUseHWAA; | 78 bool fUseHWAA; |
77 GrStencilSettings fStencil; | 79 GrStencilSettings fStencil; |
78 GrScissorState fScissor; | 80 GrScissorState fScissor; |
79 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; | 81 // GrPendingIOResource<GrRenderTargetProxy, kWrite_GrIOType> fRenderTargetPro
xy; |
80 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; | 82 sk_sp<GrRenderTargetProxy> fRenderTargetProxy
; |
| 83 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; |
81 | 84 |
82 typedef GrBatch INHERITED; | 85 typedef GrBatch INHERITED; |
83 }; | 86 }; |
84 | 87 |
85 #endif | 88 #endif |
OLD | NEW |