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

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

Issue 687563008: Beginning to refactor nvpr code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: cleanup Created 6 years, 1 month 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
OLDNEW
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 10
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 info.setDevBounds(*devBounds); 520 info.setDevBounds(*devBounds);
521 } 521 }
522 // TODO: We should continue with incorrect blending. 522 // TODO: We should continue with incorrect blending.
523 if (!this->setupDstReadIfNecessary(&info)) { 523 if (!this->setupDstReadIfNecessary(&info)) {
524 return; 524 return;
525 } 525 }
526 this->onDraw(info); 526 this->onDraw(info);
527 } 527 }
528 } 528 }
529 529
530 void GrDrawTarget::stencilPath(const GrPath* path, SkPath::FillType fill) { 530 void GrDrawTarget::stencilPath(const GrPath* path, GrPathRendering::FillType fil l) {
531 // TODO: extract portions of checkDraw that are relevant to path stenciling. 531 // TODO: extract portions of checkDraw that are relevant to path stenciling.
532 SkASSERT(path); 532 SkASSERT(path);
533 SkASSERT(this->caps()->pathRenderingSupport()); 533 SkASSERT(this->caps()->pathRenderingSupport());
534 SkASSERT(!SkPath::IsInverseFillType(fill));
535 this->onStencilPath(path, fill); 534 this->onStencilPath(path, fill);
536 } 535 }
537 536
538 void GrDrawTarget::drawPath(const GrPath* path, SkPath::FillType fill) { 537 void GrDrawTarget::drawPath(const GrPath* path, GrPathRendering::FillType fill) {
539 // TODO: extract portions of checkDraw that are relevant to path rendering. 538 // TODO: extract portions of checkDraw that are relevant to path rendering.
540 SkASSERT(path); 539 SkASSERT(path);
541 SkASSERT(this->caps()->pathRenderingSupport()); 540 SkASSERT(this->caps()->pathRenderingSupport());
542 const GrDrawState* drawState = &getDrawState();
543 541
544 SkRect devBounds; 542 SkRect devBounds = path->getBounds();
545 if (SkPath::IsInverseFillType(fill)) { 543 SkMatrix viewM = this->drawState()->getViewMatrix();
546 devBounds = SkRect::MakeWH(SkIntToScalar(drawState->getRenderTarget()->w idth()),
547 SkIntToScalar(drawState->getRenderTarget()->h eight()));
548 } else {
549 devBounds = path->getBounds();
550 }
551 SkMatrix viewM = drawState->getViewMatrix();
552 viewM.mapRect(&devBounds); 544 viewM.mapRect(&devBounds);
553 545
554 GrDeviceCoordTexture dstCopy; 546 GrDeviceCoordTexture dstCopy;
555 if (!this->setupDstReadIfNecessary(&dstCopy, &devBounds)) { 547 if (!this->setupDstReadIfNecessary(&dstCopy, &devBounds)) {
556 return; 548 return;
557 } 549 }
558 550
559 this->onDrawPath(path, fill, dstCopy.texture() ? &dstCopy : NULL); 551 this->onDrawPath(path, fill, dstCopy.texture() ? &dstCopy : NULL);
560 } 552 }
561 553
562 void GrDrawTarget::drawPaths(const GrPathRange* pathRange, 554 void GrDrawTarget::drawPaths(const GrPathRange* pathRange,
563 const uint32_t indices[], int count, 555 const uint32_t indices[], int count,
564 const float transforms[], PathTransformType transfo rmsType, 556 const float transforms[], PathTransformType transfo rmsType,
565 SkPath::FillType fill) { 557 GrPathRendering::FillType fill) {
566 SkASSERT(this->caps()->pathRenderingSupport()); 558 SkASSERT(this->caps()->pathRenderingSupport());
567 SkASSERT(pathRange); 559 SkASSERT(pathRange);
568 SkASSERT(indices); 560 SkASSERT(indices);
569 SkASSERT(transforms); 561 SkASSERT(transforms);
570 562
571 // Don't compute a bounding box for setupDstReadIfNecessary(), we'll opt 563 // Don't compute a bounding box for setupDstReadIfNecessary(), we'll opt
572 // instead for it to just copy the entire dst. Realistically this is a moot 564 // instead for it to just copy the entire dst. Realistically this is a moot
573 // point, because any context that supports NV_path_rendering will also 565 // point, because any context that supports NV_path_rendering will also
574 // support NV_blend_equation_advanced. 566 // support NV_blend_equation_advanced.
575 GrDeviceCoordTexture dstCopy; 567 GrDeviceCoordTexture dstCopy;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 } 709 }
718 SkRect bounds; 710 SkRect bounds;
719 this->getDrawState().getViewMatrix().mapRect(&bounds, rect); 711 this->getDrawState().getViewMatrix().mapRect(&bounds, rect);
720 712
721 this->drawNonIndexed(kTriangleFan_GrPrimitiveType, 0, 4, &bounds); 713 this->drawNonIndexed(kTriangleFan_GrPrimitiveType, 0, 4, &bounds);
722 } 714 }
723 715
724 void GrDrawTarget::clipWillBeSet(const GrClipData* clipData) { 716 void GrDrawTarget::clipWillBeSet(const GrClipData* clipData) {
725 } 717 }
726 718
727 static const GrStencilSettings& winding_path_stencil_settings() {
728 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings,
729 kIncClamp_StencilOp,
730 kIncClamp_StencilOp,
731 kAlwaysIfInClip_StencilFunc,
732 0xFFFF, 0xFFFF, 0xFFFF);
733 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings);
734 }
735
736 static const GrStencilSettings& even_odd_path_stencil_settings() {
737 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings,
738 kInvert_StencilOp,
739 kInvert_StencilOp,
740 kAlwaysIfInClip_StencilFunc,
741 0xFFFF, 0xFFFF, 0xFFFF);
742 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings);
743 }
744
745 void GrDrawTarget::getPathStencilSettingsForFillType(SkPath::FillType fill,
746 GrStencilSettings* outStenc ilSettings) {
747
748 switch (fill) {
749 default:
750 SkFAIL("Unexpected path fill.");
751 /* fallthrough */;
752 case SkPath::kWinding_FillType:
753 case SkPath::kInverseWinding_FillType:
754 *outStencilSettings = winding_path_stencil_settings();
755 break;
756 case SkPath::kEvenOdd_FillType:
757 case SkPath::kInverseEvenOdd_FillType:
758 *outStencilSettings = even_odd_path_stencil_settings();
759 break;
760 }
761 this->getClipMaskManager()->adjustPathStencilParams(outStencilSettings);
762 }
763
764 //////////////////////////////////////////////////////////////////////////////// 719 ////////////////////////////////////////////////////////////////////////////////
765 720
766 GrDrawTarget::AutoStateRestore::AutoStateRestore() { 721 GrDrawTarget::AutoStateRestore::AutoStateRestore() {
767 fDrawTarget = NULL; 722 fDrawTarget = NULL;
768 } 723 }
769 724
770 GrDrawTarget::AutoStateRestore::AutoStateRestore(GrDrawTarget* target, 725 GrDrawTarget::AutoStateRestore::AutoStateRestore(GrDrawTarget* target,
771 ASRInit init, 726 ASRInit init,
772 const SkMatrix* vm) { 727 const SkMatrix* vm) {
773 fDrawTarget = NULL; 728 fDrawTarget = NULL;
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 1143
1189 uint32_t GrDrawTargetCaps::CreateUniqueID() { 1144 uint32_t GrDrawTargetCaps::CreateUniqueID() {
1190 static int32_t gUniqueID = SK_InvalidUniqueID; 1145 static int32_t gUniqueID = SK_InvalidUniqueID;
1191 uint32_t id; 1146 uint32_t id;
1192 do { 1147 do {
1193 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1); 1148 id = static_cast<uint32_t>(sk_atomic_inc(&gUniqueID) + 1);
1194 } while (id == SK_InvalidUniqueID); 1149 } while (id == SK_InvalidUniqueID);
1195 return id; 1150 return id;
1196 } 1151 }
1197 1152
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698