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" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // after a cleanup | 24 // after a cleanup |
25 fDrawTargets[i]->reset(); | 25 fDrawTargets[i]->reset(); |
26 fDrawTargets[i]->unref(); | 26 fDrawTargets[i]->unref(); |
27 } | 27 } |
28 | 28 |
29 fDrawTargets.reset(); | 29 fDrawTargets.reset(); |
30 | 30 |
31 delete fNVPRTextContext; | 31 delete fNVPRTextContext; |
32 fNVPRTextContext = nullptr; | 32 fNVPRTextContext = nullptr; |
33 | 33 |
34 for (int i = 0; i < kNumPixelGeometries; ++i) { | 34 delete fAtlasTextContext; |
35 delete fTextContexts[i][0]; | 35 fAtlasTextContext = nullptr; |
36 fTextContexts[i][0] = nullptr; | |
37 delete fTextContexts[i][1]; | |
38 fTextContexts[i][1] = nullptr; | |
39 } | |
40 | 36 |
41 delete fPathRendererChain; | 37 delete fPathRendererChain; |
42 fPathRendererChain = nullptr; | 38 fPathRendererChain = nullptr; |
43 SkSafeSetNull(fSoftwarePathRenderer); | 39 SkSafeSetNull(fSoftwarePathRenderer); |
44 } | 40 } |
45 | 41 |
46 GrDrawingManager::~GrDrawingManager() { | 42 GrDrawingManager::~GrDrawingManager() { |
47 this->cleanup(); | 43 this->cleanup(); |
48 } | 44 } |
49 | 45 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 fDrawTargets[0]->resetFlag(GrDrawTarget::kWasOutput_Flag); | 107 fDrawTargets[0]->resetFlag(GrDrawTarget::kWasOutput_Flag); |
112 } | 108 } |
113 #else | 109 #else |
114 fDrawTargets.reset(); | 110 fDrawTargets.reset(); |
115 #endif | 111 #endif |
116 | 112 |
117 fFlushState.reset(); | 113 fFlushState.reset(); |
118 fFlushing = false; | 114 fFlushing = false; |
119 } | 115 } |
120 | 116 |
121 GrTextContext* GrDrawingManager::textContext(const SkSurfaceProps& props, | 117 GrTextContext* GrDrawingManager::textContext(const SkSurfaceProps& props, GrRend
erTarget* rt) { |
122 GrRenderTarget* rt) { | |
123 if (this->abandoned()) { | 118 if (this->abandoned()) { |
124 return nullptr; | 119 return nullptr; |
125 } | 120 } |
126 | 121 |
127 SkASSERT(props.pixelGeometry() < kNumPixelGeometries); | |
128 bool useDIF = props.isUseDeviceIndependentFonts(); | 122 bool useDIF = props.isUseDeviceIndependentFonts(); |
129 | 123 |
130 if (useDIF && fContext->caps()->shaderCaps()->pathRenderingSupport() && | 124 if (useDIF && fContext->caps()->shaderCaps()->pathRenderingSupport() && |
131 rt->isStencilBufferMultisampled()) { | 125 rt->isStencilBufferMultisampled()) { |
132 GrStencilAttachment* sb = fContext->resourceProvider()->attachStencilAtt
achment(rt); | 126 GrStencilAttachment* sb = fContext->resourceProvider()->attachStencilAtt
achment(rt); |
133 if (sb) { | 127 if (sb) { |
134 if (!fNVPRTextContext) { | 128 if (!fNVPRTextContext) { |
135 fNVPRTextContext = GrStencilAndCoverTextContext::Create(fContext
, props); | 129 fNVPRTextContext = GrStencilAndCoverTextContext::Create(fContext
); |
136 } | 130 } |
137 | 131 |
138 return fNVPRTextContext; | 132 return fNVPRTextContext; |
139 } | 133 } |
140 } | 134 } |
141 | 135 |
142 if (!fTextContexts[props.pixelGeometry()][useDIF]) { | 136 if (!fAtlasTextContext) { |
143 fTextContexts[props.pixelGeometry()][useDIF] = GrAtlasTextContext::Creat
e(fContext, props); | 137 fAtlasTextContext = GrAtlasTextContext::Create(fContext); |
144 } | 138 } |
145 | 139 |
146 return fTextContexts[props.pixelGeometry()][useDIF]; | 140 return fAtlasTextContext; |
147 } | 141 } |
148 | 142 |
149 GrDrawTarget* GrDrawingManager::newDrawTarget(GrRenderTarget* rt) { | 143 GrDrawTarget* GrDrawingManager::newDrawTarget(GrRenderTarget* rt) { |
150 SkASSERT(fContext); | 144 SkASSERT(fContext); |
151 | 145 |
152 #ifndef ENABLE_MDB | 146 #ifndef ENABLE_MDB |
153 // When MDB is disabled we always just return the single drawTarget | 147 // When MDB is disabled we always just return the single drawTarget |
154 if (fDrawTargets.count()) { | 148 if (fDrawTargets.count()) { |
155 SkASSERT(fDrawTargets.count() == 1); | 149 SkASSERT(fDrawTargets.count() == 1); |
156 // In the non-MDB-world the same drawTarget gets reused for multiple ren
der targets. | 150 // In the non-MDB-world the same drawTarget gets reused for multiple ren
der targets. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 } | 191 } |
198 | 192 |
199 GrDrawContext* GrDrawingManager::drawContext(GrRenderTarget* rt, | 193 GrDrawContext* GrDrawingManager::drawContext(GrRenderTarget* rt, |
200 const SkSurfaceProps* surfaceProps)
{ | 194 const SkSurfaceProps* surfaceProps)
{ |
201 if (this->abandoned()) { | 195 if (this->abandoned()) { |
202 return nullptr; | 196 return nullptr; |
203 } | 197 } |
204 | 198 |
205 return new GrDrawContext(this, rt, surfaceProps, fContext->getAuditTrail(),
fSingleOwner); | 199 return new GrDrawContext(this, rt, surfaceProps, fContext->getAuditTrail(),
fSingleOwner); |
206 } | 200 } |
OLD | NEW |