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 | 9 |
10 #include "GrGpu.h" | 10 #include "GrGpu.h" |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 } | 268 } |
269 | 269 |
270 return fQuadIndexBuffer; | 270 return fQuadIndexBuffer; |
271 } | 271 } |
272 | 272 |
273 //////////////////////////////////////////////////////////////////////////////// | 273 //////////////////////////////////////////////////////////////////////////////// |
274 | 274 |
275 bool GrGpu::setupClipAndFlushState(DrawType type, | 275 bool GrGpu::setupClipAndFlushState(DrawType type, |
276 const GrDeviceCoordTexture* dstCopy, | 276 const GrDeviceCoordTexture* dstCopy, |
277 const SkRect* devBounds, | 277 const SkRect* devBounds, |
278 GrDrawState::AutoRestoreEffects* are) { | 278 GrDrawState::AutoRestoreEffects* are, |
| 279 GrDrawState::AutoRestoreStencil* ars) { |
279 GrClipMaskManager::ScissorState scissorState; | 280 GrClipMaskManager::ScissorState scissorState; |
280 GrDrawState::AutoRestoreStencil ars; | |
281 if (!fClipMaskManager.setupClipping(this->getClip(), | 281 if (!fClipMaskManager.setupClipping(this->getClip(), |
282 devBounds, | 282 devBounds, |
283 are, | 283 are, |
284 &ars, | 284 ars, |
285 &scissorState)) { | 285 &scissorState)) { |
286 return false; | 286 return false; |
287 } | 287 } |
288 | 288 |
289 if (!this->flushGraphicsState(type, scissorState, dstCopy)) { | 289 if (!this->flushGraphicsState(type, scissorState, dstCopy)) { |
290 return false; | 290 return false; |
291 } | 291 } |
292 | 292 |
293 return true; | 293 return true; |
294 } | 294 } |
(...skipping 23 matching lines...) Expand all Loading... |
318 | 318 |
319 void GrGpu::geometrySourceWillPop(const GeometrySrcState& restoredState) { | 319 void GrGpu::geometrySourceWillPop(const GeometrySrcState& restoredState) { |
320 // if popping last entry then pops are unbalanced with pushes | 320 // if popping last entry then pops are unbalanced with pushes |
321 SkASSERT(fGeomPoolStateStack.count() > 1); | 321 SkASSERT(fGeomPoolStateStack.count() > 1); |
322 fGeomPoolStateStack.pop_back(); | 322 fGeomPoolStateStack.pop_back(); |
323 } | 323 } |
324 | 324 |
325 void GrGpu::onDraw(const DrawInfo& info) { | 325 void GrGpu::onDraw(const DrawInfo& info) { |
326 this->handleDirtyContext(); | 326 this->handleDirtyContext(); |
327 GrDrawState::AutoRestoreEffects are; | 327 GrDrawState::AutoRestoreEffects are; |
| 328 GrDrawState::AutoRestoreStencil ars; |
328 if (!this->setupClipAndFlushState(PrimTypeToDrawType(info.primitiveType()), | 329 if (!this->setupClipAndFlushState(PrimTypeToDrawType(info.primitiveType()), |
329 info.getDstCopy(), | 330 info.getDstCopy(), |
330 info.getDevBounds(), | 331 info.getDevBounds(), |
331 &are)) { | 332 &are, |
| 333 &ars)) { |
332 return; | 334 return; |
333 } | 335 } |
334 this->onGpuDraw(info); | 336 this->onGpuDraw(info); |
335 } | 337 } |
336 | 338 |
337 void GrGpu::onStencilPath(const GrPath* path, SkPath::FillType fill) { | 339 |
| 340 // TODO hack |
| 341 static const GrStencilSettings& winding_path_stencil_settings() { |
| 342 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings, |
| 343 kIncClamp_StencilOp, |
| 344 kIncClamp_StencilOp, |
| 345 kAlwaysIfInClip_StencilFunc, |
| 346 0xFFFF, 0xFFFF, 0xFFFF); |
| 347 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings); |
| 348 } |
| 349 |
| 350 static const GrStencilSettings& even_odd_path_stencil_settings() { |
| 351 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings, |
| 352 kInvert_StencilOp, |
| 353 kInvert_StencilOp, |
| 354 kAlwaysIfInClip_StencilFunc, |
| 355 0xFFFF, 0xFFFF, 0xFFFF); |
| 356 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings); |
| 357 } |
| 358 |
| 359 static void get_path_stencil_settings_for_filltype(GrPathRendering::FillType fil
l, |
| 360 GrStencilSettings* outStencil
Settings) { |
| 361 |
| 362 switch (fill) { |
| 363 default: |
| 364 SkFAIL("Unexpected path fill."); |
| 365 case GrPathRendering::kWinding_FillType: |
| 366 *outStencilSettings = winding_path_stencil_settings(); |
| 367 break; |
| 368 case GrPathRendering::kEvenOdd_FillType: |
| 369 *outStencilSettings = even_odd_path_stencil_settings(); |
| 370 break; |
| 371 } |
| 372 } |
| 373 |
| 374 void GrGpu::onStencilPath(const GrPath* path, GrPathRendering::FillType fill) { |
338 this->handleDirtyContext(); | 375 this->handleDirtyContext(); |
339 | 376 |
340 GrDrawState::AutoRestoreEffects are; | 377 GrDrawState::AutoRestoreEffects are; |
341 if (!this->setupClipAndFlushState(kStencilPath_DrawType, NULL, NULL, &are))
{ | 378 GrDrawState::AutoRestoreStencil ars; |
| 379 if (!this->setupClipAndFlushState(kStencilPath_DrawType, NULL, NULL, &are, &
ars)) { |
342 return; | 380 return; |
343 } | 381 } |
344 | 382 |
345 this->pathRendering()->stencilPath(path, fill); | 383 GrStencilSettings stencilSettings; |
| 384 get_path_stencil_settings_for_filltype(fill, &stencilSettings); |
| 385 fClipMaskManager.adjustPathStencilParams(&stencilSettings); |
| 386 |
| 387 this->pathRendering()->stencilPath(path, stencilSettings); |
346 } | 388 } |
347 | 389 |
348 | 390 |
349 void GrGpu::onDrawPath(const GrPath* path, SkPath::FillType fill, | 391 void GrGpu::onDrawPath(const GrPath* path, GrPathRendering::FillType fill, |
350 const GrDeviceCoordTexture* dstCopy) { | 392 const GrDeviceCoordTexture* dstCopy) { |
351 this->handleDirtyContext(); | 393 this->handleDirtyContext(); |
352 | 394 |
353 drawState()->setDefaultVertexAttribs(); | 395 drawState()->setDefaultVertexAttribs(); |
354 | 396 |
355 GrDrawState::AutoRestoreEffects are; | 397 GrDrawState::AutoRestoreEffects are; |
356 if (!this->setupClipAndFlushState(kDrawPath_DrawType, dstCopy, NULL, &are))
{ | 398 GrDrawState::AutoRestoreStencil ars; |
| 399 if (!this->setupClipAndFlushState(kDrawPath_DrawType, dstCopy, NULL, &are, &
ars)) { |
357 return; | 400 return; |
358 } | 401 } |
359 | 402 |
360 this->pathRendering()->drawPath(path, fill); | 403 GrStencilSettings stencilSettings; |
| 404 get_path_stencil_settings_for_filltype(fill, &stencilSettings); |
| 405 fClipMaskManager.adjustPathStencilParams(&stencilSettings); |
| 406 |
| 407 this->pathRendering()->drawPath(path, stencilSettings); |
361 } | 408 } |
362 | 409 |
363 void GrGpu::onDrawPaths(const GrPathRange* pathRange, | 410 void GrGpu::onDrawPaths(const GrPathRange* pathRange, |
364 const uint32_t indices[], int count, | 411 const uint32_t indices[], int count, |
365 const float transforms[], PathTransformType transformsTy
pe, | 412 const float transforms[], PathTransformType transformsTy
pe, |
366 SkPath::FillType fill, const GrDeviceCoordTexture* dstCo
py) { | 413 GrPathRendering::FillType fill, const GrDeviceCoordTextu
re* dstCopy) { |
367 this->handleDirtyContext(); | 414 this->handleDirtyContext(); |
368 | 415 |
369 drawState()->setDefaultVertexAttribs(); | 416 drawState()->setDefaultVertexAttribs(); |
370 | 417 |
371 GrDrawState::AutoRestoreEffects are; | 418 GrDrawState::AutoRestoreEffects are; |
372 if (!this->setupClipAndFlushState(kDrawPaths_DrawType, dstCopy, NULL, &are))
{ | 419 GrDrawState::AutoRestoreStencil ars; |
| 420 if (!this->setupClipAndFlushState(kDrawPaths_DrawType, dstCopy, NULL, &are,
&ars)) { |
373 return; | 421 return; |
374 } | 422 } |
375 | 423 |
| 424 GrStencilSettings stencilSettings; |
| 425 get_path_stencil_settings_for_filltype(fill, &stencilSettings); |
| 426 fClipMaskManager.adjustPathStencilParams(&stencilSettings); |
| 427 |
376 pathRange->willDrawPaths(indices, count); | 428 pathRange->willDrawPaths(indices, count); |
377 this->pathRendering()->drawPaths(pathRange, indices, count, transforms, tran
sformsType, fill); | 429 this->pathRendering()->drawPaths(pathRange, indices, count, transforms, tran
sformsType, |
| 430 stencilSettings); |
378 } | 431 } |
379 | 432 |
380 void GrGpu::finalizeReservedVertices() { | 433 void GrGpu::finalizeReservedVertices() { |
381 SkASSERT(fVertexPool); | 434 SkASSERT(fVertexPool); |
382 fVertexPool->unmap(); | 435 fVertexPool->unmap(); |
383 } | 436 } |
384 | 437 |
385 void GrGpu::finalizeReservedIndices() { | 438 void GrGpu::finalizeReservedIndices() { |
386 SkASSERT(fIndexPool); | 439 SkASSERT(fIndexPool); |
387 fIndexPool->unmap(); | 440 fIndexPool->unmap(); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 } | 560 } |
508 | 561 |
509 void GrGpu::releaseIndexArray() { | 562 void GrGpu::releaseIndexArray() { |
510 // if index source was array, we stowed data in the pool | 563 // if index source was array, we stowed data in the pool |
511 const GeometrySrcState& geoSrc = this->getGeomSrc(); | 564 const GeometrySrcState& geoSrc = this->getGeomSrc(); |
512 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); | 565 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); |
513 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); | 566 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); |
514 fIndexPool->putBack(bytes); | 567 fIndexPool->putBack(bytes); |
515 --fIndexPoolUseCnt; | 568 --fIndexPoolUseCnt; |
516 } | 569 } |
OLD | NEW |