| 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 6, | 291 6, |
| 292 MAX_QUADS, | 292 MAX_QUADS, |
| 293 4); | 293 4); |
| 294 } | 294 } |
| 295 | 295 |
| 296 return fQuadIndexBuffer; | 296 return fQuadIndexBuffer; |
| 297 } | 297 } |
| 298 | 298 |
| 299 //////////////////////////////////////////////////////////////////////////////// | 299 //////////////////////////////////////////////////////////////////////////////// |
| 300 | 300 |
| 301 bool GrGpu::setupClipAndFlushState(DrawType type, const GrDeviceCoordTexture* ds
tCopy, | 301 bool GrGpu::setupClipAndFlushState(DrawType type, |
| 302 const GrDeviceCoordTexture* dstCopy, |
| 302 GrDrawState::AutoRestoreEffects* are, | 303 GrDrawState::AutoRestoreEffects* are, |
| 304 GrDrawState::AutoRestoreStencil* ars, |
| 303 const SkRect* devBounds) { | 305 const SkRect* devBounds) { |
| 304 if (!fClipMaskManager.setupClipping(this->getClip(), are, devBounds)) { | 306 if (!fClipMaskManager.setupClipping(this->getClip(), are, ars, devBounds)) { |
| 305 return false; | 307 return false; |
| 306 } | 308 } |
| 307 | 309 |
| 308 if (!this->flushGraphicsState(type, dstCopy)) { | 310 if (!this->flushGraphicsState(type, dstCopy)) { |
| 309 return false; | 311 return false; |
| 310 } | 312 } |
| 311 | 313 |
| 312 return true; | 314 return true; |
| 313 } | 315 } |
| 314 | 316 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 337 | 339 |
| 338 void GrGpu::geometrySourceWillPop(const GeometrySrcState& restoredState) { | 340 void GrGpu::geometrySourceWillPop(const GeometrySrcState& restoredState) { |
| 339 // if popping last entry then pops are unbalanced with pushes | 341 // if popping last entry then pops are unbalanced with pushes |
| 340 SkASSERT(fGeomPoolStateStack.count() > 1); | 342 SkASSERT(fGeomPoolStateStack.count() > 1); |
| 341 fGeomPoolStateStack.pop_back(); | 343 fGeomPoolStateStack.pop_back(); |
| 342 } | 344 } |
| 343 | 345 |
| 344 void GrGpu::onDraw(const DrawInfo& info) { | 346 void GrGpu::onDraw(const DrawInfo& info) { |
| 345 this->handleDirtyContext(); | 347 this->handleDirtyContext(); |
| 346 GrDrawState::AutoRestoreEffects are; | 348 GrDrawState::AutoRestoreEffects are; |
| 349 GrDrawState::AutoRestoreStencil asr; |
| 347 if (!this->setupClipAndFlushState(PrimTypeToDrawType(info.primitiveType()), | 350 if (!this->setupClipAndFlushState(PrimTypeToDrawType(info.primitiveType()), |
| 348 info.getDstCopy(), &are, info.getDevBounds
())) { | 351 info.getDstCopy(), &are, &asr, info.getDev
Bounds())) { |
| 349 return; | 352 return; |
| 350 } | 353 } |
| 351 this->onGpuDraw(info); | 354 this->onGpuDraw(info); |
| 352 } | 355 } |
| 353 | 356 |
| 354 void GrGpu::onStencilPath(const GrPath* path, SkPath::FillType fill) { | 357 void GrGpu::onStencilPath(const GrPath* path, SkPath::FillType fill) { |
| 355 this->handleDirtyContext(); | 358 this->handleDirtyContext(); |
| 356 | 359 |
| 357 GrDrawState::AutoRestoreEffects are; | 360 GrDrawState::AutoRestoreEffects are; |
| 358 if (!this->setupClipAndFlushState(kStencilPath_DrawType, NULL, &are, NULL))
{ | 361 GrDrawState::AutoRestoreStencil asr; |
| 362 if (!this->setupClipAndFlushState(kStencilPath_DrawType, NULL, &are, &asr, N
ULL)) { |
| 359 return; | 363 return; |
| 360 } | 364 } |
| 361 | 365 |
| 362 this->pathRendering()->stencilPath(path, fill); | 366 this->pathRendering()->stencilPath(path, fill); |
| 363 } | 367 } |
| 364 | 368 |
| 365 | 369 |
| 366 void GrGpu::onDrawPath(const GrPath* path, SkPath::FillType fill, | 370 void GrGpu::onDrawPath(const GrPath* path, SkPath::FillType fill, |
| 367 const GrDeviceCoordTexture* dstCopy) { | 371 const GrDeviceCoordTexture* dstCopy) { |
| 368 this->handleDirtyContext(); | 372 this->handleDirtyContext(); |
| 369 | 373 |
| 370 drawState()->setDefaultVertexAttribs(); | 374 drawState()->setDefaultVertexAttribs(); |
| 371 | 375 |
| 372 GrDrawState::AutoRestoreEffects are; | 376 GrDrawState::AutoRestoreEffects are; |
| 373 if (!this->setupClipAndFlushState(kDrawPath_DrawType, dstCopy, &are, NULL))
{ | 377 GrDrawState::AutoRestoreStencil asr; |
| 378 if (!this->setupClipAndFlushState(kDrawPath_DrawType, dstCopy, &are, &asr, N
ULL)) { |
| 374 return; | 379 return; |
| 375 } | 380 } |
| 376 | 381 |
| 377 this->pathRendering()->drawPath(path, fill); | 382 this->pathRendering()->drawPath(path, fill); |
| 378 } | 383 } |
| 379 | 384 |
| 380 void GrGpu::onDrawPaths(const GrPathRange* pathRange, | 385 void GrGpu::onDrawPaths(const GrPathRange* pathRange, |
| 381 const uint32_t indices[], int count, | 386 const uint32_t indices[], int count, |
| 382 const float transforms[], PathTransformType transformsTy
pe, | 387 const float transforms[], PathTransformType transformsTy
pe, |
| 383 SkPath::FillType fill, const GrDeviceCoordTexture* dstCo
py) { | 388 SkPath::FillType fill, const GrDeviceCoordTexture* dstCo
py) { |
| 384 this->handleDirtyContext(); | 389 this->handleDirtyContext(); |
| 385 | 390 |
| 386 drawState()->setDefaultVertexAttribs(); | 391 drawState()->setDefaultVertexAttribs(); |
| 387 | 392 |
| 388 GrDrawState::AutoRestoreEffects are; | 393 GrDrawState::AutoRestoreEffects are; |
| 389 if (!this->setupClipAndFlushState(kDrawPaths_DrawType, dstCopy, &are, NULL))
{ | 394 GrDrawState::AutoRestoreStencil asr; |
| 395 if (!this->setupClipAndFlushState(kDrawPaths_DrawType, dstCopy, &are, &asr,
NULL)) { |
| 390 return; | 396 return; |
| 391 } | 397 } |
| 392 | 398 |
| 393 pathRange->willDrawPaths(indices, count); | 399 pathRange->willDrawPaths(indices, count); |
| 394 this->pathRendering()->drawPaths(pathRange, indices, count, transforms, tran
sformsType, fill); | 400 this->pathRendering()->drawPaths(pathRange, indices, count, transforms, tran
sformsType, fill); |
| 395 } | 401 } |
| 396 | 402 |
| 397 void GrGpu::finalizeReservedVertices() { | 403 void GrGpu::finalizeReservedVertices() { |
| 398 SkASSERT(fVertexPool); | 404 SkASSERT(fVertexPool); |
| 399 fVertexPool->unmap(); | 405 fVertexPool->unmap(); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 } | 530 } |
| 525 | 531 |
| 526 void GrGpu::releaseIndexArray() { | 532 void GrGpu::releaseIndexArray() { |
| 527 // if index source was array, we stowed data in the pool | 533 // if index source was array, we stowed data in the pool |
| 528 const GeometrySrcState& geoSrc = this->getGeomSrc(); | 534 const GeometrySrcState& geoSrc = this->getGeomSrc(); |
| 529 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); | 535 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); |
| 530 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); | 536 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); |
| 531 fIndexPool->putBack(bytes); | 537 fIndexPool->putBack(bytes); |
| 532 --fIndexPoolUseCnt; | 538 --fIndexPoolUseCnt; |
| 533 } | 539 } |
| OLD | NEW |