OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrDrawTarget.h" | 9 #include "GrDrawTarget.h" |
10 | 10 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 batch->unref(); | 217 batch->unref(); |
218 } | 218 } |
219 | 219 |
220 void GrDrawTarget::drawPath(const GrPipelineBuilder& pipelineBuilder, | 220 void GrDrawTarget::drawPath(const GrPipelineBuilder& pipelineBuilder, |
221 const GrPathProcessor* pathProc, | 221 const GrPathProcessor* pathProc, |
222 const GrPath* path, | 222 const GrPath* path, |
223 GrPathRendering::FillType fill) { | 223 GrPathRendering::FillType fill) { |
224 SkASSERT(path); | 224 SkASSERT(path); |
225 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); | 225 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); |
226 | 226 |
227 GrDrawPathBatch* batch = GrDrawPathBatch::Create(pathProc, path); | 227 GrDrawPathBatchBase* batch = GrDrawPathBatch::Create(pathProc, path); |
| 228 this->drawPathBatch(pipelineBuilder, batch, fill); |
| 229 batch->unref(); |
| 230 } |
228 | 231 |
| 232 void GrDrawTarget::drawPathsFromRange(const GrPipelineBuilder& pipelineBuilder, |
| 233 const GrPathProcessor* pathProc, |
| 234 GrPathRangeDraw* draw, |
| 235 GrPathRendering::FillType fill) { |
| 236 GrDrawPathBatchBase* batch = GrDrawPathRangeBatch::Create(pathProc, draw); |
| 237 this->drawPathBatch(pipelineBuilder, batch, fill); |
| 238 batch->unref(); |
| 239 } |
| 240 |
| 241 void GrDrawTarget::drawPathBatch(const GrPipelineBuilder& pipelineBuilder, |
| 242 GrDrawPathBatchBase* batch, |
| 243 GrPathRendering::FillType fill) { |
229 // This looks like drawBatch() but there is an added wrinkle that stencil se
ttings get inserted | 244 // This looks like drawBatch() but there is an added wrinkle that stencil se
ttings get inserted |
230 // after setupClip() but before onDrawBatch(). TODO: Figure out a better mod
el for handling | 245 // after setupClip() but before onDrawBatch(). TODO: Figure out a better mod
el for handling |
231 // stencil settings WRT interactions between pipeline(builder), clipmaskmana
ger, and batches. | 246 // stencil settings WRT interactions between pipeline(builder), clipmaskmana
ger, and batches. |
232 | 247 |
233 GrScissorState scissorState; | 248 GrScissorState scissorState; |
234 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; | 249 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; |
235 GrPipelineBuilder::AutoRestoreStencil ars; | 250 GrPipelineBuilder::AutoRestoreStencil ars; |
236 if (!this->setupClip(pipelineBuilder, &arfps, &ars, &scissorState, &batch->b
ounds())) { | 251 if (!this->setupClip(pipelineBuilder, &arfps, &ars, &scissorState, &batch->b
ounds())) { |
237 return; | 252 return; |
238 } | 253 } |
239 | 254 |
240 // Ensure the render target has a stencil buffer and get the stencil setting
s. | 255 // Ensure the render target has a stencil buffer and get the stencil setting
s. |
241 GrStencilSettings stencilSettings; | 256 GrStencilSettings stencilSettings; |
242 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); | 257 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); |
243 GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment(); | 258 GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment(); |
244 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); | 259 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); |
245 batch->setStencilSettings(stencilSettings); | 260 batch->setStencilSettings(stencilSettings); |
246 | 261 |
247 // Don't compute a bounding box for dst copy texture, we'll opt | 262 GrDrawTarget::PipelineInfo pipelineInfo(&pipelineBuilder, &scissorState, bat
ch, |
248 // instead for it to just copy the entire dst. Realistically this is a moot | 263 &batch->bounds(), this); |
249 // point, because any context that supports NV_path_rendering will also | |
250 // support NV_blend_equation_advanced. | |
251 GrDrawTarget::PipelineInfo pipelineInfo(&pipelineBuilder, &scissorState, bat
ch, nullptr, this); | |
252 | 264 |
253 if (!pipelineInfo.valid()) { | 265 if (!pipelineInfo.valid()) { |
254 return; | 266 return; |
255 } | 267 } |
256 if (!batch->installPipeline(pipelineInfo.pipelineCreateArgs())) { | 268 if (!batch->installPipeline(pipelineInfo.pipelineCreateArgs())) { |
257 return; | 269 return; |
258 } | 270 } |
259 | 271 |
260 this->onDrawBatch(batch); | 272 this->onDrawBatch(batch); |
261 batch->unref(); | |
262 } | |
263 | |
264 void GrDrawTarget::drawPaths(const GrPipelineBuilder& pipelineBuilder, | |
265 const GrPathProcessor* pathProc, | |
266 const GrPathRange* pathRange, | |
267 const void* indices, | |
268 PathIndexType indexType, | |
269 const float transformValues[], | |
270 PathTransformType transformType, | |
271 int count, | |
272 GrPathRendering::FillType fill) { | |
273 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); | |
274 SkASSERT(pathRange); | |
275 SkASSERT(indices); | |
276 SkASSERT(0 == reinterpret_cast<intptr_t>(indices) % | |
277 GrPathRange::PathIndexSizeInBytes(indexType)); | |
278 SkASSERT(transformValues); | |
279 | |
280 // Setup clip | |
281 GrScissorState scissorState; | |
282 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; | |
283 GrPipelineBuilder::AutoRestoreStencil ars; | |
284 if (!this->setupClip(pipelineBuilder, &arfps, &ars, &scissorState, nullptr))
{ | |
285 return; | |
286 } | |
287 | |
288 // set stencil settings for path | |
289 GrStencilSettings stencilSettings; | |
290 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); | |
291 GrStencilAttachment* sb = rt->renderTargetPriv().attachStencilAttachment(); | |
292 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); | |
293 | |
294 // Don't compute a bounding box for dst copy texture, we'll opt | |
295 // instead for it to just copy the entire dst. Realistically this is a moot | |
296 // point, because any context that supports NV_path_rendering will also | |
297 // support NV_blend_equation_advanced. | |
298 GrDrawTarget::PipelineInfo pipelineInfo(&pipelineBuilder, &scissorState, pat
hProc, nullptr, this); | |
299 if (!pipelineInfo.valid()) { | |
300 return; | |
301 } | |
302 | |
303 this->onDrawPaths(pathProc, pathRange, indices, indexType, transformValues, | |
304 transformType, count, stencilSettings, pipelineInfo); | |
305 } | 273 } |
306 | 274 |
307 void GrDrawTarget::drawNonAARect(const GrPipelineBuilder& pipelineBuilder, | 275 void GrDrawTarget::drawNonAARect(const GrPipelineBuilder& pipelineBuilder, |
308 GrColor color, | 276 GrColor color, |
309 const SkMatrix& viewMatrix, | 277 const SkMatrix& viewMatrix, |
310 const SkRect& rect) { | 278 const SkRect& rect) { |
311 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(color, vi
ewMatrix, rect, | 279 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(color, vi
ewMatrix, rect, |
312 nullptr,
nullptr)); | 280 nullptr,
nullptr)); |
313 this->drawBatch(pipelineBuilder, batch); | 281 this->drawBatch(pipelineBuilder, batch); |
314 } | 282 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 if (batch) { | 367 if (batch) { |
400 this->onDrawBatch(batch); | 368 this->onDrawBatch(batch); |
401 batch->unref(); | 369 batch->unref(); |
402 } | 370 } |
403 } | 371 } |
404 | 372 |
405 /////////////////////////////////////////////////////////////////////////////// | 373 /////////////////////////////////////////////////////////////////////////////// |
406 | 374 |
407 GrDrawTarget::PipelineInfo::PipelineInfo(const GrPipelineBuilder* pipelineBuilde
r, | 375 GrDrawTarget::PipelineInfo::PipelineInfo(const GrPipelineBuilder* pipelineBuilde
r, |
408 const GrScissorState* scissor, | 376 const GrScissorState* scissor, |
409 const GrPrimitiveProcessor* primProc, | |
410 const SkRect* devBounds, | |
411 GrDrawTarget* target) { | |
412 fArgs.fPipelineBuilder = pipelineBuilder; | |
413 fArgs.fCaps = target->caps(); | |
414 fArgs.fScissor = scissor; | |
415 fArgs.fColorPOI = fArgs.fPipelineBuilder->colorProcInfo(primProc); | |
416 fArgs.fCoveragePOI = fArgs.fPipelineBuilder->coverageProcInfo(primProc); | |
417 if (!target->setupDstReadIfNecessary(*fArgs.fPipelineBuilder, fArgs.fColorPO
I, | |
418 fArgs.fCoveragePOI, &fArgs.fDstTexture,
devBounds)) { | |
419 fArgs.fPipelineBuilder = nullptr; | |
420 } | |
421 } | |
422 | |
423 GrDrawTarget::PipelineInfo::PipelineInfo(const GrPipelineBuilder* pipelineBuilde
r, | |
424 const GrScissorState* scissor, | |
425 const GrDrawBatch* batch, | 377 const GrDrawBatch* batch, |
426 const SkRect* devBounds, | 378 const SkRect* devBounds, |
427 GrDrawTarget* target) { | 379 GrDrawTarget* target) { |
428 fArgs.fPipelineBuilder = pipelineBuilder; | 380 fArgs.fPipelineBuilder = pipelineBuilder; |
429 fArgs.fCaps = target->caps(); | 381 fArgs.fCaps = target->caps(); |
430 fArgs.fScissor = scissor; | 382 fArgs.fScissor = scissor; |
431 fArgs.fColorPOI = fArgs.fPipelineBuilder->colorProcInfo(batch); | 383 fArgs.fColorPOI = fArgs.fPipelineBuilder->colorProcInfo(batch); |
432 fArgs.fCoveragePOI = fArgs.fPipelineBuilder->coverageProcInfo(batch); | 384 fArgs.fCoveragePOI = fArgs.fPipelineBuilder->coverageProcInfo(batch); |
433 if (!target->setupDstReadIfNecessary(*fArgs.fPipelineBuilder, fArgs.fColorPO
I, | 385 if (!target->setupDstReadIfNecessary(*fArgs.fPipelineBuilder, fArgs.fColorPO
I, |
434 fArgs.fCoveragePOI, &fArgs.fDstTexture,
devBounds)) { | 386 fArgs.fCoveragePOI, &fArgs.fDstTexture,
devBounds)) { |
(...skipping 25 matching lines...) Expand all Loading... |
460 // The clip mask manager can rebuild all its clip masks so just | 412 // The clip mask manager can rebuild all its clip masks so just |
461 // get rid of them all. | 413 // get rid of them all. |
462 fClipMaskManager->purgeResources(); | 414 fClipMaskManager->purgeResources(); |
463 }; | 415 }; |
464 | 416 |
465 void GrClipTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { | 417 void GrClipTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { |
466 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); | 418 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); |
467 this->onDrawBatch(batch); | 419 this->onDrawBatch(batch); |
468 batch->unref(); | 420 batch->unref(); |
469 } | 421 } |
OLD | NEW |