Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: src/gpu/GrInOrderDrawBuffer.cpp

Issue 22686002: Implement path cover with nv_path_rendering (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Omission with non-inverted path bounds fixed Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 "GrInOrderDrawBuffer.h" 8 #include "GrInOrderDrawBuffer.h"
9 9
10 #include "GrBufferAllocPool.h" 10 #include "GrBufferAllocPool.h"
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 default: 378 default:
379 GrCrash("unknown geom src type"); 379 GrCrash("unknown geom src type");
380 } 380 }
381 draw->fIndexBuffer->ref(); 381 draw->fIndexBuffer->ref();
382 } else { 382 } else {
383 draw->fIndexBuffer = NULL; 383 draw->fIndexBuffer = NULL;
384 } 384 }
385 } 385 }
386 386
387 GrInOrderDrawBuffer::StencilPath::StencilPath() : fStroke(SkStrokeRec::kFill_Ini tStyle) {} 387 GrInOrderDrawBuffer::StencilPath::StencilPath() : fStroke(SkStrokeRec::kFill_Ini tStyle) {}
388 GrInOrderDrawBuffer::FillPath::FillPath() : fStroke(SkStrokeRec::kFill_InitStyle ) {}
388 389
389 void GrInOrderDrawBuffer::onStencilPath(const GrPath* path, const SkStrokeRec& s troke, 390 void GrInOrderDrawBuffer::onStencilPath(const GrPath* path, const SkStrokeRec& s troke,
390 SkPath::FillType fill) { 391 SkPath::FillType fill) {
391 if (this->needsNewClip()) { 392 if (this->needsNewClip()) {
392 this->recordClip(); 393 this->recordClip();
393 } 394 }
394 // Only compare the subset of GrDrawState relevant to path stenciling? 395 // Only compare the subset of GrDrawState relevant to path stenciling?
395 if (this->needsNewState()) { 396 if (this->needsNewState()) {
396 this->recordState(); 397 this->recordState();
397 } 398 }
398 StencilPath* sp = this->recordStencilPath(); 399 StencilPath* sp = this->recordStencilPath();
399 sp->fPath.reset(path); 400 sp->fPath.reset(path);
400 path->ref(); 401 path->ref();
401 sp->fFill = fill; 402 sp->fFill = fill;
402 sp->fStroke = stroke; 403 sp->fStroke = stroke;
403 } 404 }
404 405
406 void GrInOrderDrawBuffer::onFillPath(const GrPath* path, const SkStrokeRec& stro ke,
407 SkPath::FillType fill) {
408 if (this->needsNewClip()) {
409 this->recordClip();
410 }
411 // TODO: Only compare the subset of GrDrawState relevant to path covering?
412 if (this->needsNewState()) {
413 this->recordState();
414 }
415 FillPath* cp = this->recordFillPath();
416 cp->fPath.reset(path);
417 path->ref();
418 cp->fFill = fill;
419 cp->fStroke = stroke;
420 }
421
405 void GrInOrderDrawBuffer::clear(const SkIRect* rect, GrColor color, GrRenderTarg et* renderTarget) { 422 void GrInOrderDrawBuffer::clear(const SkIRect* rect, GrColor color, GrRenderTarg et* renderTarget) {
406 SkIRect r; 423 SkIRect r;
407 if (NULL == renderTarget) { 424 if (NULL == renderTarget) {
408 renderTarget = this->drawState()->getRenderTarget(); 425 renderTarget = this->drawState()->getRenderTarget();
409 SkASSERT(NULL != renderTarget); 426 SkASSERT(NULL != renderTarget);
410 } 427 }
411 if (NULL == rect) { 428 if (NULL == rect) {
412 // We could do something smart and remove previous draws and clears to 429 // We could do something smart and remove previous draws and clears to
413 // the current render target. If we get that smart we have to make sure 430 // the current render target. If we get that smart we have to make sure
414 // those draws aren't read before this clear (render-to-texture). 431 // those draws aren't read before this clear (render-to-texture).
(...skipping 14 matching lines...) Expand all
429 int numDraws = fDraws.count(); 446 int numDraws = fDraws.count();
430 for (int d = 0; d < numDraws; ++d) { 447 for (int d = 0; d < numDraws; ++d) {
431 // we always have a VB, but not always an IB 448 // we always have a VB, but not always an IB
432 SkASSERT(NULL != fDraws[d].fVertexBuffer); 449 SkASSERT(NULL != fDraws[d].fVertexBuffer);
433 fDraws[d].fVertexBuffer->unref(); 450 fDraws[d].fVertexBuffer->unref();
434 SkSafeUnref(fDraws[d].fIndexBuffer); 451 SkSafeUnref(fDraws[d].fIndexBuffer);
435 } 452 }
436 fCmds.reset(); 453 fCmds.reset();
437 fDraws.reset(); 454 fDraws.reset();
438 fStencilPaths.reset(); 455 fStencilPaths.reset();
456 fFillPaths.reset();
439 fStates.reset(); 457 fStates.reset();
440 fClears.reset(); 458 fClears.reset();
441 fVertexPool.reset(); 459 fVertexPool.reset();
442 fIndexPool.reset(); 460 fIndexPool.reset();
443 fClips.reset(); 461 fClips.reset();
444 fClipOrigins.reset(); 462 fClipOrigins.reset();
445 fCopySurfaces.reset(); 463 fCopySurfaces.reset();
446 fClipSet = true; 464 fClipSet = true;
447 } 465 }
448 466
(...skipping 24 matching lines...) Expand all
473 prevDrawState->ref(); 491 prevDrawState->ref();
474 fDstGpu->setDrawState(&playbackState); 492 fDstGpu->setDrawState(&playbackState);
475 493
476 GrClipData clipData; 494 GrClipData clipData;
477 495
478 int currState = 0; 496 int currState = 0;
479 int currClip = 0; 497 int currClip = 0;
480 int currClear = 0; 498 int currClear = 0;
481 int currDraw = 0; 499 int currDraw = 0;
482 int currStencilPath = 0; 500 int currStencilPath = 0;
501 int currFillPath = 0;
483 int currCopySurface = 0; 502 int currCopySurface = 0;
484 503
485 for (int c = 0; c < numCmds; ++c) { 504 for (int c = 0; c < numCmds; ++c) {
486 switch (fCmds[c]) { 505 switch (fCmds[c]) {
487 case kDraw_Cmd: { 506 case kDraw_Cmd: {
488 const DrawRecord& draw = fDraws[currDraw]; 507 const DrawRecord& draw = fDraws[currDraw];
489 fDstGpu->setVertexSourceToBuffer(draw.fVertexBuffer); 508 fDstGpu->setVertexSourceToBuffer(draw.fVertexBuffer);
490 if (draw.isIndexed()) { 509 if (draw.isIndexed()) {
491 fDstGpu->setIndexSourceToBuffer(draw.fIndexBuffer); 510 fDstGpu->setIndexSourceToBuffer(draw.fIndexBuffer);
492 } 511 }
493 fDstGpu->executeDraw(draw); 512 fDstGpu->executeDraw(draw);
494 513
495 ++currDraw; 514 ++currDraw;
496 break; 515 break;
497 } 516 }
498 case kStencilPath_Cmd: { 517 case kStencilPath_Cmd: {
499 const StencilPath& sp = fStencilPaths[currStencilPath]; 518 const StencilPath& sp = fStencilPaths[currStencilPath];
500 fDstGpu->stencilPath(sp.fPath.get(), sp.fStroke, sp.fFill); 519 fDstGpu->stencilPath(sp.fPath.get(), sp.fStroke, sp.fFill);
501 ++currStencilPath; 520 ++currStencilPath;
502 break; 521 break;
503 } 522 }
523 case kFillPath_Cmd: {
524 const FillPath& cp = fFillPaths[currFillPath];
525 fDstGpu->fillPath(cp.fPath.get(), cp.fStroke, cp.fFill);
526 ++currFillPath;
527 break;
528 }
504 case kSetState_Cmd: 529 case kSetState_Cmd:
505 fStates[currState].restoreTo(&playbackState); 530 fStates[currState].restoreTo(&playbackState);
506 ++currState; 531 ++currState;
507 break; 532 break;
508 case kSetClip_Cmd: 533 case kSetClip_Cmd:
509 clipData.fClipStack = &fClips[currClip]; 534 clipData.fClipStack = &fClips[currClip];
510 clipData.fOrigin = fClipOrigins[currClip]; 535 clipData.fOrigin = fClipOrigins[currClip];
511 fDstGpu->setClip(&clipData); 536 fDstGpu->setClip(&clipData);
512 ++currClip; 537 ++currClip;
513 break; 538 break;
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 GrInOrderDrawBuffer::DrawRecord* GrInOrderDrawBuffer::recordDraw(const DrawInfo& info) { 829 GrInOrderDrawBuffer::DrawRecord* GrInOrderDrawBuffer::recordDraw(const DrawInfo& info) {
805 fCmds.push_back(kDraw_Cmd); 830 fCmds.push_back(kDraw_Cmd);
806 return &fDraws.push_back(info); 831 return &fDraws.push_back(info);
807 } 832 }
808 833
809 GrInOrderDrawBuffer::StencilPath* GrInOrderDrawBuffer::recordStencilPath() { 834 GrInOrderDrawBuffer::StencilPath* GrInOrderDrawBuffer::recordStencilPath() {
810 fCmds.push_back(kStencilPath_Cmd); 835 fCmds.push_back(kStencilPath_Cmd);
811 return &fStencilPaths.push_back(); 836 return &fStencilPaths.push_back();
812 } 837 }
813 838
839 GrInOrderDrawBuffer::FillPath* GrInOrderDrawBuffer::recordFillPath() {
840 fCmds.push_back(kFillPath_Cmd);
841 return &fFillPaths.push_back();
842 }
843
814 GrInOrderDrawBuffer::Clear* GrInOrderDrawBuffer::recordClear() { 844 GrInOrderDrawBuffer::Clear* GrInOrderDrawBuffer::recordClear() {
815 fCmds.push_back(kClear_Cmd); 845 fCmds.push_back(kClear_Cmd);
816 return &fClears.push_back(); 846 return &fClears.push_back();
817 } 847 }
818 848
819 GrInOrderDrawBuffer::CopySurface* GrInOrderDrawBuffer::recordCopySurface() { 849 GrInOrderDrawBuffer::CopySurface* GrInOrderDrawBuffer::recordCopySurface() {
820 fCmds.push_back(kCopySurface_Cmd); 850 fCmds.push_back(kCopySurface_Cmd);
821 return &fCopySurfaces.push_back(); 851 return &fCopySurfaces.push_back();
822 } 852 }
823 853
824 854
825 void GrInOrderDrawBuffer::clipWillBeSet(const GrClipData* newClipData) { 855 void GrInOrderDrawBuffer::clipWillBeSet(const GrClipData* newClipData) {
826 INHERITED::clipWillBeSet(newClipData); 856 INHERITED::clipWillBeSet(newClipData);
827 fClipSet = true; 857 fClipSet = true;
828 fClipProxyState = kUnknown_ClipProxyState; 858 fClipProxyState = kUnknown_ClipProxyState;
829 } 859 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698