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 #include "GrDrawContext.h" | 8 #include "GrDrawContext.h" |
9 #include "GrDrawingManager.h" | 9 #include "GrDrawingManager.h" |
10 #include "GrDrawTarget.h" | 10 #include "GrDrawTarget.h" |
| 11 #include "GrPathRenderingDrawContext.h" |
11 #include "GrResourceProvider.h" | 12 #include "GrResourceProvider.h" |
12 #include "GrSoftwarePathRenderer.h" | 13 #include "GrSoftwarePathRenderer.h" |
13 #include "SkTTopoSort.h" | 14 #include "SkTTopoSort.h" |
14 | 15 |
15 #include "text/GrAtlasTextContext.h" | 16 #include "text/GrAtlasTextContext.h" |
16 #include "text/GrStencilAndCoverTextContext.h" | 17 #include "text/GrStencilAndCoverTextContext.h" |
17 | 18 |
18 void GrDrawingManager::cleanup() { | 19 void GrDrawingManager::cleanup() { |
19 for (int i = 0; i < fDrawTargets.count(); ++i) { | 20 for (int i = 0; i < fDrawTargets.count(); ++i) { |
20 fDrawTargets[i]->makeClosed(); // no drawTarget should receive a new co
mmand after this | 21 fDrawTargets[i]->makeClosed(); // no drawTarget should receive a new co
mmand after this |
21 fDrawTargets[i]->clearRT(); | 22 fDrawTargets[i]->clearRT(); |
22 | 23 |
23 // We shouldn't need to do this, but it turns out some clients still hol
d onto drawtargets | 24 // We shouldn't need to do this, but it turns out some clients still hol
d onto drawtargets |
24 // after a cleanup | 25 // after a cleanup |
25 fDrawTargets[i]->reset(); | 26 fDrawTargets[i]->reset(); |
26 fDrawTargets[i]->unref(); | 27 fDrawTargets[i]->unref(); |
27 } | 28 } |
28 | 29 |
29 fDrawTargets.reset(); | 30 fDrawTargets.reset(); |
30 | 31 |
31 delete fNVPRTextContext; | |
32 fNVPRTextContext = nullptr; | |
33 | |
34 delete fAtlasTextContext; | |
35 fAtlasTextContext = nullptr; | |
36 | |
37 delete fPathRendererChain; | 32 delete fPathRendererChain; |
38 fPathRendererChain = nullptr; | 33 fPathRendererChain = nullptr; |
39 SkSafeSetNull(fSoftwarePathRenderer); | 34 SkSafeSetNull(fSoftwarePathRenderer); |
40 } | 35 } |
41 | 36 |
42 GrDrawingManager::~GrDrawingManager() { | 37 GrDrawingManager::~GrDrawingManager() { |
43 this->cleanup(); | 38 this->cleanup(); |
44 } | 39 } |
45 | 40 |
46 void GrDrawingManager::abandon() { | 41 void GrDrawingManager::abandon() { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 fDrawTargets[0]->resetFlag(GrDrawTarget::kWasOutput_Flag); | 102 fDrawTargets[0]->resetFlag(GrDrawTarget::kWasOutput_Flag); |
108 } | 103 } |
109 #else | 104 #else |
110 fDrawTargets.reset(); | 105 fDrawTargets.reset(); |
111 #endif | 106 #endif |
112 | 107 |
113 fFlushState.reset(); | 108 fFlushState.reset(); |
114 fFlushing = false; | 109 fFlushing = false; |
115 } | 110 } |
116 | 111 |
117 GrTextContext* GrDrawingManager::textContext(const SkSurfaceProps& props, GrRend
erTarget* rt) { | |
118 if (this->abandoned()) { | |
119 return nullptr; | |
120 } | |
121 | |
122 bool useDIF = props.isUseDeviceIndependentFonts(); | |
123 | |
124 if (useDIF && fContext->caps()->shaderCaps()->pathRenderingSupport() && | |
125 rt->isStencilBufferMultisampled()) { | |
126 GrStencilAttachment* sb = fContext->resourceProvider()->attachStencilAtt
achment(rt); | |
127 if (sb) { | |
128 if (!fNVPRTextContext) { | |
129 fNVPRTextContext = GrStencilAndCoverTextContext::Create(); | |
130 } | |
131 | |
132 return fNVPRTextContext; | |
133 } | |
134 } | |
135 | |
136 if (!fAtlasTextContext) { | |
137 fAtlasTextContext = GrAtlasTextContext::Create(); | |
138 } | |
139 | |
140 return fAtlasTextContext; | |
141 } | |
142 | |
143 GrDrawTarget* GrDrawingManager::newDrawTarget(GrRenderTarget* rt) { | 112 GrDrawTarget* GrDrawingManager::newDrawTarget(GrRenderTarget* rt) { |
144 SkASSERT(fContext); | 113 SkASSERT(fContext); |
145 | 114 |
146 #ifndef ENABLE_MDB | 115 #ifndef ENABLE_MDB |
147 // When MDB is disabled we always just return the single drawTarget | 116 // When MDB is disabled we always just return the single drawTarget |
148 if (fDrawTargets.count()) { | 117 if (fDrawTargets.count()) { |
149 SkASSERT(fDrawTargets.count() == 1); | 118 SkASSERT(fDrawTargets.count() == 1); |
150 // In the non-MDB-world the same drawTarget gets reused for multiple ren
der targets. | 119 // In the non-MDB-world the same drawTarget gets reused for multiple ren
der targets. |
151 // Update this pointer so all the asserts are happy | 120 // Update this pointer so all the asserts are happy |
152 rt->setLastDrawTarget(fDrawTargets[0]); | 121 rt->setLastDrawTarget(fDrawTargets[0]); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 158 |
190 return pr; | 159 return pr; |
191 } | 160 } |
192 | 161 |
193 GrDrawContext* GrDrawingManager::drawContext(GrRenderTarget* rt, | 162 GrDrawContext* GrDrawingManager::drawContext(GrRenderTarget* rt, |
194 const SkSurfaceProps* surfaceProps)
{ | 163 const SkSurfaceProps* surfaceProps)
{ |
195 if (this->abandoned()) { | 164 if (this->abandoned()) { |
196 return nullptr; | 165 return nullptr; |
197 } | 166 } |
198 | 167 |
| 168 |
| 169 bool useDIF = false; |
| 170 if (surfaceProps) { |
| 171 useDIF = surfaceProps->isUseDeviceIndependentFonts(); |
| 172 } |
| 173 |
| 174 if (useDIF && fContext->caps()->shaderCaps()->pathRenderingSupport() && |
| 175 rt->isStencilBufferMultisampled()) { |
| 176 GrStencilAttachment* sb = fContext->resourceProvider()->attachStencilAtt
achment(rt); |
| 177 if (sb) { |
| 178 return new GrPathRenderingDrawContext(fContext, this, rt, surfacePro
ps, |
| 179 fContext->getAuditTrail(), fSi
ngleOwner); |
| 180 } |
| 181 } |
| 182 |
199 return new GrDrawContext(fContext, this, rt, surfaceProps, fContext->getAudi
tTrail(), | 183 return new GrDrawContext(fContext, this, rt, surfaceProps, fContext->getAudi
tTrail(), |
200 fSingleOwner); | 184 fSingleOwner); |
201 } | 185 } |
OLD | NEW |