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

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

Issue 858343002: Rename GrOptDrawState to GrPipeline and GrDrawState to GrPipelineBuilder (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more nits Created 5 years, 11 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
« no previous file with comments | « src/gpu/GrClipMaskManager.cpp ('k') | src/gpu/GrDefaultGeoProcFactory.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 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 "GrContext.h" 9 #include "GrContext.h"
10 10
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 GrSurfaceDesc rtDesc = desc; 287 GrSurfaceDesc rtDesc = desc;
288 rtDesc.fFlags = rtDesc.fFlags | 288 rtDesc.fFlags = rtDesc.fFlags |
289 kRenderTarget_GrSurfaceFlag | 289 kRenderTarget_GrSurfaceFlag |
290 kNoStencil_GrSurfaceFlag; 290 kNoStencil_GrSurfaceFlag;
291 rtDesc.fWidth = GrNextPow2(desc.fWidth); 291 rtDesc.fWidth = GrNextPow2(desc.fWidth);
292 rtDesc.fHeight = GrNextPow2(desc.fHeight); 292 rtDesc.fHeight = GrNextPow2(desc.fHeight);
293 293
294 GrTexture* texture = fGpu->createTexture(rtDesc, true, NULL, 0); 294 GrTexture* texture = fGpu->createTexture(rtDesc, true, NULL, 0);
295 295
296 if (texture) { 296 if (texture) {
297 GrDrawState drawState; 297 GrPipelineBuilder pipelineBuilder;
298 drawState.setRenderTarget(texture->asRenderTarget()); 298 pipelineBuilder.setRenderTarget(texture->asRenderTarget());
299 299
300 // if filtering is not desired then we want to ensure all 300 // if filtering is not desired then we want to ensure all
301 // texels in the resampled image are copies of texels from 301 // texels in the resampled image are copies of texels from
302 // the original. 302 // the original.
303 GrTextureParams params(SkShader::kClamp_TileMode, 303 GrTextureParams params(SkShader::kClamp_TileMode,
304 filter ? GrTextureParams::kBilerp_FilterMode : 304 filter ? GrTextureParams::kBilerp_FilterMode :
305 GrTextureParams::kNone_FilterMode); 305 GrTextureParams::kNone_FilterMode);
306 drawState.addColorTextureProcessor(clampedTexture, SkMatrix::I(), params ); 306 pipelineBuilder.addColorTextureProcessor(clampedTexture, SkMatrix::I(), params);
307 307
308 uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType | 308 uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType |
309 GrDefaultGeoProcFactory::kLocalCoord_GPType; 309 GrDefaultGeoProcFactory::kLocalCoord_GPType;
310 SkAutoTUnref<const GrGeometryProcessor> gp( 310 SkAutoTUnref<const GrGeometryProcessor> gp(
311 GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE)); 311 GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE));
312 312
313 GrDrawTarget::AutoReleaseGeometry arg(fDrawBuffer, 4, gp->getVertexStrid e(), 0); 313 GrDrawTarget::AutoReleaseGeometry arg(fDrawBuffer, 4, gp->getVertexStrid e(), 0);
314 SkASSERT(gp->getVertexStride() == 2 * sizeof(SkPoint)); 314 SkASSERT(gp->getVertexStride() == 2 * sizeof(SkPoint));
315 315
316 if (arg.succeeded()) { 316 if (arg.succeeded()) {
317 SkPoint* verts = (SkPoint*) arg.vertices(); 317 SkPoint* verts = (SkPoint*) arg.vertices();
318 verts[0].setIRectFan(0, 0, texture->width(), texture->height(), 2 * sizeof(SkPoint)); 318 verts[0].setIRectFan(0, 0, texture->width(), texture->height(), 2 * sizeof(SkPoint));
319 verts[1].setIRectFan(0, 0, 1, 1, 2 * sizeof(SkPoint)); 319 verts[1].setIRectFan(0, 0, 1, 1, 2 * sizeof(SkPoint));
320 fDrawBuffer->drawNonIndexed(&drawState, gp, kTriangleFan_GrPrimitive Type, 0, 4); 320 fDrawBuffer->drawNonIndexed(&pipelineBuilder, gp, kTriangleFan_GrPri mitiveType, 0, 4);
321 } 321 }
322 } else { 322 } else {
323 // TODO: Our CPU stretch doesn't filter. But we create separate 323 // TODO: Our CPU stretch doesn't filter. But we create separate
324 // stretched textures when the texture params is either filtered or 324 // stretched textures when the texture params is either filtered or
325 // not. Either implement filtered stretch blit on CPU or just create 325 // not. Either implement filtered stretch blit on CPU or just create
326 // one when FBO case fails. 326 // one when FBO case fails.
327 327
328 rtDesc.fFlags = kNone_GrSurfaceFlags; 328 rtDesc.fFlags = kNone_GrSurfaceFlags;
329 // no longer need to clamp at min RT size. 329 // no longer need to clamp at min RT size.
330 rtDesc.fWidth = GrNextPow2(desc.fWidth); 330 rtDesc.fWidth = GrNextPow2(desc.fWidth);
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 inverse.mapRect(&r); 564 inverse.mapRect(&r);
565 this->drawRect(*paint, viewMatrix, r); 565 this->drawRect(*paint, viewMatrix, r);
566 } else { 566 } else {
567 SkMatrix localMatrix; 567 SkMatrix localMatrix;
568 if (!viewMatrix.invert(&localMatrix)) { 568 if (!viewMatrix.invert(&localMatrix)) {
569 SkDebugf("Could not invert matrix\n"); 569 SkDebugf("Could not invert matrix\n");
570 return; 570 return;
571 } 571 }
572 572
573 AutoCheckFlush acf(this); 573 AutoCheckFlush acf(this);
574 GrDrawState drawState; 574 GrPipelineBuilder pipelineBuilder;
575 GrDrawTarget* target = this->prepareToDraw(&drawState, paint, &acf); 575 GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, paint, &acf );
576 if (NULL == target) { 576 if (NULL == target) {
577 return; 577 return;
578 } 578 }
579 579
580 GR_CREATE_TRACE_MARKER("GrContext::drawPaintWithPerspective", target); 580 GR_CREATE_TRACE_MARKER("GrContext::drawPaintWithPerspective", target);
581 target->drawRect(&drawState, paint->getColor(), SkMatrix::I(), r, NULL, &localMatrix); 581 target->drawRect(&pipelineBuilder, paint->getColor(), SkMatrix::I(), r, NULL, &localMatrix);
582 } 582 }
583 } 583 }
584 584
585 #ifdef SK_DEVELOPER 585 #ifdef SK_DEVELOPER
586 void GrContext::dumpFontCache() const { 586 void GrContext::dumpFontCache() const {
587 fFontCache->dump(); 587 fFontCache->dump();
588 } 588 }
589 #endif 589 #endif
590 590
591 //////////////////////////////////////////////////////////////////////////////// 591 ////////////////////////////////////////////////////////////////////////////////
(...skipping 19 matching lines...) Expand all
611 verts[8] = verts[0]; 611 verts[8] = verts[0];
612 verts[9] = verts[1]; 612 verts[9] = verts[1];
613 } 613 }
614 614
615 static inline bool is_irect(const SkRect& r) { 615 static inline bool is_irect(const SkRect& r) {
616 return SkScalarIsInt(r.fLeft) && SkScalarIsInt(r.fTop) && 616 return SkScalarIsInt(r.fLeft) && SkScalarIsInt(r.fTop) &&
617 SkScalarIsInt(r.fRight) && SkScalarIsInt(r.fBottom); 617 SkScalarIsInt(r.fRight) && SkScalarIsInt(r.fBottom);
618 } 618 }
619 619
620 static bool apply_aa_to_rect(GrDrawTarget* target, 620 static bool apply_aa_to_rect(GrDrawTarget* target,
621 GrDrawState* ds, 621 GrPipelineBuilder* pipelineBuilder,
622 SkRect* devBoundRect, 622 SkRect* devBoundRect,
623 const SkRect& rect, 623 const SkRect& rect,
624 SkScalar strokeWidth, 624 SkScalar strokeWidth,
625 const SkMatrix& combinedMatrix, 625 const SkMatrix& combinedMatrix,
626 GrColor color) { 626 GrColor color) {
627 if (!ds->canTweakAlphaForCoverage() && !ds->canUseFracCoveragePrimProc(color , 627 if (!pipelineBuilder->canTweakAlphaForCoverage() &&
628 *targ et->caps())) { 628 !pipelineBuilder->canUseFracCoveragePrimProc(color, *target->caps())) {
629 #ifdef SK_DEBUG 629 #ifdef SK_DEBUG
630 //SkDebugf("Turning off AA to correctly apply blend.\n"); 630 //SkDebugf("Turning off AA to correctly apply blend.\n");
631 #endif 631 #endif
632 return false; 632 return false;
633 } 633 }
634 634
635 if (ds->getRenderTarget()->isMultisampled()) { 635 if (pipelineBuilder->getRenderTarget()->isMultisampled()) {
636 return false; 636 return false;
637 } 637 }
638 638
639 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) 639 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT)
640 if (strokeWidth >= 0) { 640 if (strokeWidth >= 0) {
641 #endif 641 #endif
642 if (!combinedMatrix.preservesAxisAlignment()) { 642 if (!combinedMatrix.preservesAxisAlignment()) {
643 return false; 643 return false;
644 } 644 }
645 645
(...skipping 27 matching lines...) Expand all
673 const SkRect& rect, 673 const SkRect& rect,
674 const GrStrokeInfo* strokeInfo) { 674 const GrStrokeInfo* strokeInfo) {
675 if (strokeInfo && strokeInfo->isDashed()) { 675 if (strokeInfo && strokeInfo->isDashed()) {
676 SkPath path; 676 SkPath path;
677 path.addRect(rect); 677 path.addRect(rect);
678 this->drawPath(paint, viewMatrix, path, *strokeInfo); 678 this->drawPath(paint, viewMatrix, path, *strokeInfo);
679 return; 679 return;
680 } 680 }
681 681
682 AutoCheckFlush acf(this); 682 AutoCheckFlush acf(this);
683 GrDrawState drawState; 683 GrPipelineBuilder pipelineBuilder;
684 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &acf); 684 GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, &paint, &acf);
685 if (NULL == target) { 685 if (NULL == target) {
686 return; 686 return;
687 } 687 }
688 688
689 GR_CREATE_TRACE_MARKER("GrContext::drawRect", target); 689 GR_CREATE_TRACE_MARKER("GrContext::drawRect", target);
690 SkScalar width = NULL == strokeInfo ? -1 : strokeInfo->getStrokeRec().getWid th(); 690 SkScalar width = NULL == strokeInfo ? -1 : strokeInfo->getStrokeRec().getWid th();
691 691
692 // Check if this is a full RT draw and can be replaced with a clear. We don' t bother checking 692 // Check if this is a full RT draw and can be replaced with a clear. We don' t bother checking
693 // cases where the RT is fully inside a stroke. 693 // cases where the RT is fully inside a stroke.
694 if (width < 0) { 694 if (width < 0) {
695 SkRect rtRect; 695 SkRect rtRect;
696 drawState.getRenderTarget()->getBoundsRect(&rtRect); 696 pipelineBuilder.getRenderTarget()->getBoundsRect(&rtRect);
697 SkRect clipSpaceRTRect = rtRect; 697 SkRect clipSpaceRTRect = rtRect;
698 bool checkClip = false; 698 bool checkClip = false;
699 if (this->getClip()) { 699 if (this->getClip()) {
700 checkClip = true; 700 checkClip = true;
701 clipSpaceRTRect.offset(SkIntToScalar(this->getClip()->fOrigin.fX), 701 clipSpaceRTRect.offset(SkIntToScalar(this->getClip()->fOrigin.fX),
702 SkIntToScalar(this->getClip()->fOrigin.fY)); 702 SkIntToScalar(this->getClip()->fOrigin.fY));
703 } 703 }
704 // Does the clip contain the entire RT? 704 // Does the clip contain the entire RT?
705 if (!checkClip || target->getClip()->fClipStack->quickContains(clipSpace RTRect)) { 705 if (!checkClip || target->getClip()->fClipStack->quickContains(clipSpace RTRect)) {
706 SkMatrix invM; 706 SkMatrix invM;
(...skipping 12 matching lines...) Expand all
719 if (paint.isOpaqueAndConstantColor(&clearColor)) { 719 if (paint.isOpaqueAndConstantColor(&clearColor)) {
720 target->clear(NULL, clearColor, true, fRenderTarget); 720 target->clear(NULL, clearColor, true, fRenderTarget);
721 return; 721 return;
722 } 722 }
723 } 723 }
724 } 724 }
725 } 725 }
726 726
727 GrColor color = paint.getColor(); 727 GrColor color = paint.getColor();
728 SkRect devBoundRect; 728 SkRect devBoundRect;
729 bool needAA = paint.isAntiAlias() && !drawState.getRenderTarget()->isMultisa mpled(); 729 bool needAA = paint.isAntiAlias() && !pipelineBuilder.getRenderTarget()->isM ultisampled();
730 bool doAA = needAA && apply_aa_to_rect(target, &drawState, &devBoundRect, re ct, width, 730 bool doAA = needAA && apply_aa_to_rect(target, &pipelineBuilder, &devBoundRe ct, rect, width,
731 viewMatrix, color); 731 viewMatrix, color);
732 732
733 if (doAA) { 733 if (doAA) {
734 if (width >= 0) { 734 if (width >= 0) {
735 const SkStrokeRec& strokeRec = strokeInfo->getStrokeRec(); 735 const SkStrokeRec& strokeRec = strokeInfo->getStrokeRec();
736 fAARectRenderer->strokeAARect(target, 736 fAARectRenderer->strokeAARect(target,
737 &drawState, 737 &pipelineBuilder,
738 color, 738 color,
739 viewMatrix, 739 viewMatrix,
740 rect, 740 rect,
741 devBoundRect, 741 devBoundRect,
742 strokeRec); 742 strokeRec);
743 } else { 743 } else {
744 // filled AA rect 744 // filled AA rect
745 fAARectRenderer->fillAARect(target, 745 fAARectRenderer->fillAARect(target,
746 &drawState, 746 &pipelineBuilder,
747 color, 747 color,
748 viewMatrix, 748 viewMatrix,
749 rect, 749 rect,
750 devBoundRect); 750 devBoundRect);
751 } 751 }
752 return; 752 return;
753 } 753 }
754 754
755 if (width >= 0) { 755 if (width >= 0) {
756 // TODO: consider making static vertex buffers for these cases. 756 // TODO: consider making static vertex buffers for these cases.
(...skipping 29 matching lines...) Expand all
786 // hairline 786 // hairline
787 vertCount = 5; 787 vertCount = 5;
788 primType = kLineStrip_GrPrimitiveType; 788 primType = kLineStrip_GrPrimitiveType;
789 vertex[0].set(rect.fLeft, rect.fTop); 789 vertex[0].set(rect.fLeft, rect.fTop);
790 vertex[1].set(rect.fRight, rect.fTop); 790 vertex[1].set(rect.fRight, rect.fTop);
791 vertex[2].set(rect.fRight, rect.fBottom); 791 vertex[2].set(rect.fRight, rect.fBottom);
792 vertex[3].set(rect.fLeft, rect.fBottom); 792 vertex[3].set(rect.fLeft, rect.fBottom);
793 vertex[4].set(rect.fLeft, rect.fTop); 793 vertex[4].set(rect.fLeft, rect.fTop);
794 } 794 }
795 795
796 target->drawNonIndexed(&drawState, gp, primType, 0, vertCount); 796 target->drawNonIndexed(&pipelineBuilder, gp, primType, 0, vertCount);
797 } else { 797 } else {
798 // filled BW rect 798 // filled BW rect
799 target->drawSimpleRect(&drawState, color, viewMatrix, rect); 799 target->drawSimpleRect(&pipelineBuilder, color, viewMatrix, rect);
800 } 800 }
801 } 801 }
802 802
803 void GrContext::drawNonAARectToRect(const GrPaint& paint, 803 void GrContext::drawNonAARectToRect(const GrPaint& paint,
804 const SkMatrix& viewMatrix, 804 const SkMatrix& viewMatrix,
805 const SkRect& rectToDraw, 805 const SkRect& rectToDraw,
806 const SkRect& localRect, 806 const SkRect& localRect,
807 const SkMatrix* localMatrix) { 807 const SkMatrix* localMatrix) {
808 AutoCheckFlush acf(this); 808 AutoCheckFlush acf(this);
809 GrDrawState drawState; 809 GrPipelineBuilder pipelineBuilder;
810 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &acf); 810 GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, &paint, &acf);
811 if (NULL == target) { 811 if (NULL == target) {
812 return; 812 return;
813 } 813 }
814 814
815 GR_CREATE_TRACE_MARKER("GrContext::drawRectToRect", target); 815 GR_CREATE_TRACE_MARKER("GrContext::drawRectToRect", target);
816 816
817 target->drawRect(&drawState, paint.getColor(), viewMatrix, rectToDraw, &loca lRect, localMatrix); 817 target->drawRect(&pipelineBuilder, paint.getColor(), viewMatrix, rectToDraw, &localRect,
818 localMatrix);
818 } 819 }
819 820
820 static const GrGeometryProcessor* set_vertex_attributes(const SkPoint* texCoords , 821 static const GrGeometryProcessor* set_vertex_attributes(const SkPoint* texCoords ,
821 const GrColor* colors, 822 const GrColor* colors,
822 int* colorOffset, 823 int* colorOffset,
823 int* texOffset, 824 int* texOffset,
824 GrColor color, 825 GrColor color,
825 const SkMatrix& viewMatr ix) { 826 const SkMatrix& viewMatr ix) {
826 *texOffset = -1; 827 *texOffset = -1;
827 *colorOffset = -1; 828 *colorOffset = -1;
(...skipping 16 matching lines...) Expand all
844 void GrContext::drawVertices(const GrPaint& paint, 845 void GrContext::drawVertices(const GrPaint& paint,
845 const SkMatrix& viewMatrix, 846 const SkMatrix& viewMatrix,
846 GrPrimitiveType primitiveType, 847 GrPrimitiveType primitiveType,
847 int vertexCount, 848 int vertexCount,
848 const SkPoint positions[], 849 const SkPoint positions[],
849 const SkPoint texCoords[], 850 const SkPoint texCoords[],
850 const GrColor colors[], 851 const GrColor colors[],
851 const uint16_t indices[], 852 const uint16_t indices[],
852 int indexCount) { 853 int indexCount) {
853 AutoCheckFlush acf(this); 854 AutoCheckFlush acf(this);
854 GrDrawState drawState; 855 GrPipelineBuilder pipelineBuilder;
855 GrDrawTarget::AutoReleaseGeometry geo; // must be inside AutoCheckFlush scop e 856 GrDrawTarget::AutoReleaseGeometry geo; // must be inside AutoCheckFlush scop e
856 857
857 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &acf); 858 GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, &paint, &acf);
858 if (NULL == target) { 859 if (NULL == target) {
859 return; 860 return;
860 } 861 }
861 862
862 GR_CREATE_TRACE_MARKER("GrContext::drawVertices", target); 863 GR_CREATE_TRACE_MARKER("GrContext::drawVertices", target);
863 864
864 int colorOffset = -1, texOffset = -1; 865 int colorOffset = -1, texOffset = -1;
865 SkAutoTUnref<const GrGeometryProcessor> gp( 866 SkAutoTUnref<const GrGeometryProcessor> gp(
866 set_vertex_attributes(texCoords, colors, &colorOffset, &texOffset, 867 set_vertex_attributes(texCoords, colors, &colorOffset, &texOffset,
867 paint.getColor(), viewMatrix)); 868 paint.getColor(), viewMatrix));
(...skipping 19 matching lines...) Expand all
887 curVertex = (void*)((intptr_t)curVertex + vertexStride); 888 curVertex = (void*)((intptr_t)curVertex + vertexStride);
888 } 889 }
889 890
890 // we don't currently apply offscreen AA to this path. Need improved 891 // we don't currently apply offscreen AA to this path. Need improved
891 // management of GrDrawTarget's geometry to avoid copying points per-tile. 892 // management of GrDrawTarget's geometry to avoid copying points per-tile.
892 if (indices) { 893 if (indices) {
893 uint16_t* curIndex = (uint16_t*)geo.indices(); 894 uint16_t* curIndex = (uint16_t*)geo.indices();
894 for (int i = 0; i < indexCount; ++i) { 895 for (int i = 0; i < indexCount; ++i) {
895 curIndex[i] = indices[i]; 896 curIndex[i] = indices[i];
896 } 897 }
897 target->drawIndexed(&drawState, gp, primitiveType, 0, 0, vertexCount, in dexCount); 898 target->drawIndexed(&pipelineBuilder, gp, primitiveType, 0, 0, vertexCou nt, indexCount);
898 } else { 899 } else {
899 target->drawNonIndexed(&drawState, gp, primitiveType, 0, vertexCount); 900 target->drawNonIndexed(&pipelineBuilder, gp, primitiveType, 0, vertexCou nt);
900 } 901 }
901 } 902 }
902 903
903 /////////////////////////////////////////////////////////////////////////////// 904 ///////////////////////////////////////////////////////////////////////////////
904 905
905 void GrContext::drawRRect(const GrPaint& paint, 906 void GrContext::drawRRect(const GrPaint& paint,
906 const SkMatrix& viewMatrix, 907 const SkMatrix& viewMatrix,
907 const SkRRect& rrect, 908 const SkRRect& rrect,
908 const GrStrokeInfo& strokeInfo) { 909 const GrStrokeInfo& strokeInfo) {
909 if (rrect.isEmpty()) { 910 if (rrect.isEmpty()) {
910 return; 911 return;
911 } 912 }
912 913
913 if (strokeInfo.isDashed()) { 914 if (strokeInfo.isDashed()) {
914 SkPath path; 915 SkPath path;
915 path.addRRect(rrect); 916 path.addRRect(rrect);
916 this->drawPath(paint, viewMatrix, path, strokeInfo); 917 this->drawPath(paint, viewMatrix, path, strokeInfo);
917 return; 918 return;
918 } 919 }
919 920
920 AutoCheckFlush acf(this); 921 AutoCheckFlush acf(this);
921 GrDrawState drawState; 922 GrPipelineBuilder pipelineBuilder;
922 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &acf); 923 GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, &paint, &acf);
923 if (NULL == target) { 924 if (NULL == target) {
924 return; 925 return;
925 } 926 }
926 927
927 GR_CREATE_TRACE_MARKER("GrContext::drawRRect", target); 928 GR_CREATE_TRACE_MARKER("GrContext::drawRRect", target);
928 929
929 const SkStrokeRec& strokeRec = strokeInfo.getStrokeRec(); 930 const SkStrokeRec& strokeRec = strokeInfo.getStrokeRec();
930 931
931 GrColor color = paint.getColor(); 932 GrColor color = paint.getColor();
932 if (!fOvalRenderer->drawRRect(target, &drawState, color, viewMatrix, paint.i sAntiAlias(), rrect, 933 if (!fOvalRenderer->drawRRect(target, &pipelineBuilder, color, viewMatrix, p aint.isAntiAlias(),
933 strokeRec)) { 934 rrect, strokeRec)) {
934 SkPath path; 935 SkPath path;
935 path.addRRect(rrect); 936 path.addRRect(rrect);
936 this->internalDrawPath(target, &drawState, viewMatrix, color, paint.isAn tiAlias(), path, 937 this->internalDrawPath(target, &pipelineBuilder, viewMatrix, color, pain t.isAntiAlias(),
937 strokeInfo); 938 path, strokeInfo);
938 } 939 }
939 } 940 }
940 941
941 /////////////////////////////////////////////////////////////////////////////// 942 ///////////////////////////////////////////////////////////////////////////////
942 943
943 void GrContext::drawDRRect(const GrPaint& paint, 944 void GrContext::drawDRRect(const GrPaint& paint,
944 const SkMatrix& viewMatrix, 945 const SkMatrix& viewMatrix,
945 const SkRRect& outer, 946 const SkRRect& outer,
946 const SkRRect& inner) { 947 const SkRRect& inner) {
947 if (outer.isEmpty()) { 948 if (outer.isEmpty()) {
948 return; 949 return;
949 } 950 }
950 951
951 AutoCheckFlush acf(this); 952 AutoCheckFlush acf(this);
952 GrDrawState drawState; 953 GrPipelineBuilder pipelineBuilder;
953 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &acf); 954 GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, &paint, &acf);
954 955
955 GR_CREATE_TRACE_MARKER("GrContext::drawDRRect", target); 956 GR_CREATE_TRACE_MARKER("GrContext::drawDRRect", target);
956 957
957 GrColor color = paint.getColor(); 958 GrColor color = paint.getColor();
958 if (!fOvalRenderer->drawDRRect(target, &drawState, color, viewMatrix, paint. isAntiAlias(), outer, inner)) { 959 if (!fOvalRenderer->drawDRRect(target, &pipelineBuilder, color, viewMatrix, paint.isAntiAlias(),
960 outer, inner)) {
959 SkPath path; 961 SkPath path;
960 path.addRRect(inner); 962 path.addRRect(inner);
961 path.addRRect(outer); 963 path.addRRect(outer);
962 path.setFillType(SkPath::kEvenOdd_FillType); 964 path.setFillType(SkPath::kEvenOdd_FillType);
963 965
964 GrStrokeInfo fillRec(SkStrokeRec::kFill_InitStyle); 966 GrStrokeInfo fillRec(SkStrokeRec::kFill_InitStyle);
965 this->internalDrawPath(target, &drawState, viewMatrix, color, paint.isAn tiAlias(), path, 967 this->internalDrawPath(target, &pipelineBuilder, viewMatrix, color, pain t.isAntiAlias(),
966 fillRec); 968 path, fillRec);
967 } 969 }
968 } 970 }
969 971
970 /////////////////////////////////////////////////////////////////////////////// 972 ///////////////////////////////////////////////////////////////////////////////
971 973
972 void GrContext::drawOval(const GrPaint& paint, 974 void GrContext::drawOval(const GrPaint& paint,
973 const SkMatrix& viewMatrix, 975 const SkMatrix& viewMatrix,
974 const SkRect& oval, 976 const SkRect& oval,
975 const GrStrokeInfo& strokeInfo) { 977 const GrStrokeInfo& strokeInfo) {
976 if (oval.isEmpty()) { 978 if (oval.isEmpty()) {
977 return; 979 return;
978 } 980 }
979 981
980 if (strokeInfo.isDashed()) { 982 if (strokeInfo.isDashed()) {
981 SkPath path; 983 SkPath path;
982 path.addOval(oval); 984 path.addOval(oval);
983 this->drawPath(paint, viewMatrix, path, strokeInfo); 985 this->drawPath(paint, viewMatrix, path, strokeInfo);
984 return; 986 return;
985 } 987 }
986 988
987 AutoCheckFlush acf(this); 989 AutoCheckFlush acf(this);
988 GrDrawState drawState; 990 GrPipelineBuilder pipelineBuilder;
989 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &acf); 991 GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, &paint, &acf);
990 if (NULL == target) { 992 if (NULL == target) {
991 return; 993 return;
992 } 994 }
993 995
994 GR_CREATE_TRACE_MARKER("GrContext::drawOval", target); 996 GR_CREATE_TRACE_MARKER("GrContext::drawOval", target);
995 997
996 const SkStrokeRec& strokeRec = strokeInfo.getStrokeRec(); 998 const SkStrokeRec& strokeRec = strokeInfo.getStrokeRec();
997 999
998 GrColor color = paint.getColor(); 1000 GrColor color = paint.getColor();
999 if (!fOvalRenderer->drawOval(target, &drawState, color, viewMatrix, paint.is AntiAlias(), oval, 1001 if (!fOvalRenderer->drawOval(target, &pipelineBuilder, color, viewMatrix, pa int.isAntiAlias(),
1000 strokeRec)) { 1002 oval, strokeRec)) {
1001 SkPath path; 1003 SkPath path;
1002 path.addOval(oval); 1004 path.addOval(oval);
1003 this->internalDrawPath(target, &drawState, viewMatrix, color, paint.isAn tiAlias(), path, 1005 this->internalDrawPath(target, &pipelineBuilder, viewMatrix, color, pain t.isAntiAlias(),
1004 strokeInfo); 1006 path, strokeInfo);
1005 } 1007 }
1006 } 1008 }
1007 1009
1008 // Can 'path' be drawn as a pair of filled nested rectangles? 1010 // Can 'path' be drawn as a pair of filled nested rectangles?
1009 static bool is_nested_rects(GrDrawTarget* target, 1011 static bool is_nested_rects(GrDrawTarget* target,
1010 GrDrawState* drawState, 1012 GrPipelineBuilder* pipelineBuilder,
1011 GrColor color, 1013 GrColor color,
1012 const SkMatrix& viewMatrix, 1014 const SkMatrix& viewMatrix,
1013 const SkPath& path, 1015 const SkPath& path,
1014 const SkStrokeRec& stroke, 1016 const SkStrokeRec& stroke,
1015 SkRect rects[2]) { 1017 SkRect rects[2]) {
1016 SkASSERT(stroke.isFillStyle()); 1018 SkASSERT(stroke.isFillStyle());
1017 1019
1018 if (path.isInverseFillType()) { 1020 if (path.isInverseFillType()) {
1019 return false; 1021 return false;
1020 } 1022 }
1021 1023
1022 // TODO: this restriction could be lifted if we were willing to apply 1024 // TODO: this restriction could be lifted if we were willing to apply
1023 // the matrix to all the points individually rather than just to the rect 1025 // the matrix to all the points individually rather than just to the rect
1024 if (!viewMatrix.preservesAxisAlignment()) { 1026 if (!viewMatrix.preservesAxisAlignment()) {
1025 return false; 1027 return false;
1026 } 1028 }
1027 1029
1028 if (!drawState->canTweakAlphaForCoverage() && 1030 if (!pipelineBuilder->canTweakAlphaForCoverage() &&
1029 !drawState->canUseFracCoveragePrimProc(color, *target->caps())) { 1031 !pipelineBuilder->canUseFracCoveragePrimProc(color, *target->caps())) {
1030 return false; 1032 return false;
1031 } 1033 }
1032 1034
1033 SkPath::Direction dirs[2]; 1035 SkPath::Direction dirs[2];
1034 if (!path.isNestedRects(rects, dirs)) { 1036 if (!path.isNestedRects(rects, dirs)) {
1035 return false; 1037 return false;
1036 } 1038 }
1037 1039
1038 if (SkPath::kWinding_FillType == path.getFillType() && dirs[0] == dirs[1]) { 1040 if (SkPath::kWinding_FillType == path.getFillType() && dirs[0] == dirs[1]) {
1039 // The two rects need to be wound opposite to each other 1041 // The two rects need to be wound opposite to each other
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 this->drawPaint(paint, viewMatrix); 1075 this->drawPaint(paint, viewMatrix);
1074 } 1076 }
1075 return; 1077 return;
1076 } 1078 }
1077 1079
1078 GrColor color = paint.getColor(); 1080 GrColor color = paint.getColor();
1079 if (strokeInfo.isDashed()) { 1081 if (strokeInfo.isDashed()) {
1080 SkPoint pts[2]; 1082 SkPoint pts[2];
1081 if (path.isLine(pts)) { 1083 if (path.isLine(pts)) {
1082 AutoCheckFlush acf(this); 1084 AutoCheckFlush acf(this);
1083 GrDrawState drawState; 1085 GrPipelineBuilder pipelineBuilder;
1084 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &acf) ; 1086 GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, &paint, &acf);
1085 if (NULL == target) { 1087 if (NULL == target) {
1086 return; 1088 return;
1087 } 1089 }
1088 1090
1089 if (GrDashingEffect::DrawDashLine(fGpu, target, &drawState, color, v iewMatrix, pts, 1091 if (GrDashingEffect::DrawDashLine(fGpu, target, &pipelineBuilder, co lor, viewMatrix,
1090 paint, strokeInfo)) { 1092 pts, paint, strokeInfo)) {
1091 return; 1093 return;
1092 } 1094 }
1093 } 1095 }
1094 1096
1095 // Filter dashed path into new path with the dashing applied 1097 // Filter dashed path into new path with the dashing applied
1096 const SkPathEffect::DashInfo& info = strokeInfo.getDashInfo(); 1098 const SkPathEffect::DashInfo& info = strokeInfo.getDashInfo();
1097 SkTLazy<SkPath> effectPath; 1099 SkTLazy<SkPath> effectPath;
1098 GrStrokeInfo newStrokeInfo(strokeInfo, false); 1100 GrStrokeInfo newStrokeInfo(strokeInfo, false);
1099 SkStrokeRec* stroke = newStrokeInfo.getStrokeRecPtr(); 1101 SkStrokeRec* stroke = newStrokeInfo.getStrokeRecPtr();
1100 if (SkDashPath::FilterDashPath(effectPath.init(), path, stroke, NULL, in fo)) { 1102 if (SkDashPath::FilterDashPath(effectPath.init(), path, stroke, NULL, in fo)) {
1101 this->drawPath(paint, viewMatrix, *effectPath.get(), newStrokeInfo); 1103 this->drawPath(paint, viewMatrix, *effectPath.get(), newStrokeInfo);
1102 return; 1104 return;
1103 } 1105 }
1104 1106
1105 this->drawPath(paint, viewMatrix, path, newStrokeInfo); 1107 this->drawPath(paint, viewMatrix, path, newStrokeInfo);
1106 return; 1108 return;
1107 } 1109 }
1108 1110
1109 // Note that internalDrawPath may sw-rasterize the path into a scratch textu re. 1111 // Note that internalDrawPath may sw-rasterize the path into a scratch textu re.
1110 // Scratch textures can be recycled after they are returned to the texture 1112 // Scratch textures can be recycled after they are returned to the texture
1111 // cache. This presents a potential hazard for buffered drawing. However, 1113 // cache. This presents a potential hazard for buffered drawing. However,
1112 // the writePixels that uploads to the scratch will perform a flush so we're 1114 // the writePixels that uploads to the scratch will perform a flush so we're
1113 // OK. 1115 // OK.
1114 AutoCheckFlush acf(this); 1116 AutoCheckFlush acf(this);
1115 GrDrawState drawState; 1117 GrPipelineBuilder pipelineBuilder;
1116 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &acf); 1118 GrDrawTarget* target = this->prepareToDraw(&pipelineBuilder, &paint, &acf);
1117 if (NULL == target) { 1119 if (NULL == target) {
1118 return; 1120 return;
1119 } 1121 }
1120 1122
1121 GR_CREATE_TRACE_MARKER1("GrContext::drawPath", target, "Is Convex", path.isC onvex()); 1123 GR_CREATE_TRACE_MARKER1("GrContext::drawPath", target, "Is Convex", path.isC onvex());
1122 1124
1123 const SkStrokeRec& strokeRec = strokeInfo.getStrokeRec(); 1125 const SkStrokeRec& strokeRec = strokeInfo.getStrokeRec();
1124 1126
1125 bool useCoverageAA = paint.isAntiAlias() && !drawState.getRenderTarget()->is Multisampled(); 1127 bool useCoverageAA = paint.isAntiAlias() &&
1128 !pipelineBuilder.getRenderTarget()->isMultisampled();
1126 1129
1127 if (useCoverageAA && strokeRec.getWidth() < 0 && !path.isConvex()) { 1130 if (useCoverageAA && strokeRec.getWidth() < 0 && !path.isConvex()) {
1128 // Concave AA paths are expensive - try to avoid them for special cases 1131 // Concave AA paths are expensive - try to avoid them for special cases
1129 SkRect rects[2]; 1132 SkRect rects[2];
1130 1133
1131 if (is_nested_rects(target, &drawState, color, viewMatrix, path, strokeR ec, rects)) { 1134 if (is_nested_rects(target, &pipelineBuilder, color, viewMatrix, path, s trokeRec, rects)) {
1132 fAARectRenderer->fillAANestedRects(target, &drawState, color, viewMa trix,rects); 1135 fAARectRenderer->fillAANestedRects(target, &pipelineBuilder, color, viewMatrix,rects);
1133 return; 1136 return;
1134 } 1137 }
1135 } 1138 }
1136 1139
1137 SkRect ovalRect; 1140 SkRect ovalRect;
1138 bool isOval = path.isOval(&ovalRect); 1141 bool isOval = path.isOval(&ovalRect);
1139 1142
1140 if (!isOval || path.isInverseFillType() || 1143 if (!isOval || path.isInverseFillType() ||
1141 !fOvalRenderer->drawOval(target, &drawState, color, viewMatrix, paint.is AntiAlias(), 1144 !fOvalRenderer->drawOval(target, &pipelineBuilder, color, viewMatrix, pa int.isAntiAlias(),
1142 ovalRect, strokeRec)) { 1145 ovalRect, strokeRec)) {
1143 this->internalDrawPath(target, &drawState, viewMatrix, color, paint.isAn tiAlias(), path, 1146 this->internalDrawPath(target, &pipelineBuilder, viewMatrix, color, pain t.isAntiAlias(),
1144 strokeInfo); 1147 path, strokeInfo);
1145 } 1148 }
1146 } 1149 }
1147 1150
1148 void GrContext::internalDrawPath(GrDrawTarget* target, 1151 void GrContext::internalDrawPath(GrDrawTarget* target,
1149 GrDrawState* drawState, 1152 GrPipelineBuilder* pipelineBuilder,
1150 const SkMatrix& viewMatrix, 1153 const SkMatrix& viewMatrix,
1151 GrColor color, 1154 GrColor color,
1152 bool useAA, 1155 bool useAA,
1153 const SkPath& path, 1156 const SkPath& path,
1154 const GrStrokeInfo& strokeInfo) { 1157 const GrStrokeInfo& strokeInfo) {
1155 SkASSERT(!path.isEmpty()); 1158 SkASSERT(!path.isEmpty());
1156 1159
1157 GR_CREATE_TRACE_MARKER("GrContext::internalDrawPath", target); 1160 GR_CREATE_TRACE_MARKER("GrContext::internalDrawPath", target);
1158 1161
1159 1162
1160 // An Assumption here is that path renderer would use some form of tweaking 1163 // An Assumption here is that path renderer would use some form of tweaking
1161 // the src color (either the input alpha or in the frag shader) to implement 1164 // the src color (either the input alpha or in the frag shader) to implement
1162 // aa. If we have some future driver-mojo path AA that can do the right 1165 // aa. If we have some future driver-mojo path AA that can do the right
1163 // thing WRT to the blend then we'll need some query on the PR. 1166 // thing WRT to the blend then we'll need some query on the PR.
1164 bool useCoverageAA = useAA && 1167 bool useCoverageAA = useAA &&
1165 !drawState->getRenderTarget()->isMultisampled() && 1168 !pipelineBuilder->getRenderTarget()->isMultisampled() &&
1166 drawState->canUseFracCoveragePrimProc(color, *target->caps()); 1169 pipelineBuilder->canUseFracCoveragePrimProc(color, *target->caps());
1167 1170
1168 1171
1169 GrPathRendererChain::DrawType type = 1172 GrPathRendererChain::DrawType type =
1170 useCoverageAA ? GrPathRendererChain::kColorAntiAlias_DrawType : 1173 useCoverageAA ? GrPathRendererChain::kColorAntiAlias_DrawType :
1171 GrPathRendererChain::kColor_DrawType; 1174 GrPathRendererChain::kColor_DrawType;
1172 1175
1173 const SkPath* pathPtr = &path; 1176 const SkPath* pathPtr = &path;
1174 SkTLazy<SkPath> tmpPath; 1177 SkTLazy<SkPath> tmpPath;
1175 SkTCopyOnFirstWrite<SkStrokeRec> stroke(strokeInfo.getStrokeRec()); 1178 SkTCopyOnFirstWrite<SkStrokeRec> stroke(strokeInfo.getStrokeRec());
1176 1179
1177 // Try a 1st time without stroking the path and without allowing the SW rend erer 1180 // Try a 1st time without stroking the path and without allowing the SW rend erer
1178 GrPathRenderer* pr = this->getPathRenderer(target, drawState, viewMatrix, *p athPtr, *stroke, 1181 GrPathRenderer* pr = this->getPathRenderer(target, pipelineBuilder, viewMatr ix, *pathPtr,
1179 false, type); 1182 *stroke, false, type);
1180 1183
1181 if (NULL == pr) { 1184 if (NULL == pr) {
1182 if (!GrPathRenderer::IsStrokeHairlineOrEquivalent(*stroke, viewMatrix, N ULL)) { 1185 if (!GrPathRenderer::IsStrokeHairlineOrEquivalent(*stroke, viewMatrix, N ULL)) {
1183 // It didn't work the 1st time, so try again with the stroked path 1186 // It didn't work the 1st time, so try again with the stroked path
1184 if (stroke->applyToPath(tmpPath.init(), *pathPtr)) { 1187 if (stroke->applyToPath(tmpPath.init(), *pathPtr)) {
1185 pathPtr = tmpPath.get(); 1188 pathPtr = tmpPath.get();
1186 stroke.writable()->setFillStyle(); 1189 stroke.writable()->setFillStyle();
1187 if (pathPtr->isEmpty()) { 1190 if (pathPtr->isEmpty()) {
1188 return; 1191 return;
1189 } 1192 }
1190 } 1193 }
1191 } 1194 }
1192 1195
1193 // This time, allow SW renderer 1196 // This time, allow SW renderer
1194 pr = this->getPathRenderer(target, drawState, viewMatrix, *pathPtr, *str oke, true, type); 1197 pr = this->getPathRenderer(target, pipelineBuilder, viewMatrix, *pathPtr , *stroke, true,
1198 type);
1195 } 1199 }
1196 1200
1197 if (NULL == pr) { 1201 if (NULL == pr) {
1198 #ifdef SK_DEBUG 1202 #ifdef SK_DEBUG
1199 SkDebugf("Unable to find path renderer compatible with path.\n"); 1203 SkDebugf("Unable to find path renderer compatible with path.\n");
1200 #endif 1204 #endif
1201 return; 1205 return;
1202 } 1206 }
1203 1207
1204 pr->drawPath(target, drawState, color, viewMatrix, *pathPtr, *stroke, useCov erageAA); 1208 pr->drawPath(target, pipelineBuilder, color, viewMatrix, *pathPtr, *stroke, useCoverageAA);
1205 } 1209 }
1206 1210
1207 //////////////////////////////////////////////////////////////////////////////// 1211 ////////////////////////////////////////////////////////////////////////////////
1208 1212
1209 void GrContext::flush(int flagsBitfield) { 1213 void GrContext::flush(int flagsBitfield) {
1210 if (NULL == fDrawBuffer) { 1214 if (NULL == fDrawBuffer) {
1211 return; 1215 return;
1212 } 1216 }
1213 1217
1214 if (kDiscard_FlushBit & flagsBitfield) { 1218 if (kDiscard_FlushBit & flagsBitfield) {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top)); 1336 matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top));
1333 1337
1334 // This function can be called in the midst of drawing another object (e.g., when uploading a 1338 // This function can be called in the midst of drawing another object (e.g., when uploading a
1335 // SW-rasterized clip while issuing a draw). So we push the current geometry state before 1339 // SW-rasterized clip while issuing a draw). So we push the current geometry state before
1336 // drawing a rect to the render target. 1340 // drawing a rect to the render target.
1337 // The bracket ensures we pop the stack if we wind up flushing below. 1341 // The bracket ensures we pop the stack if we wind up flushing below.
1338 { 1342 {
1339 GrDrawTarget* drawTarget = this->prepareToDraw(NULL, NULL, NULL); 1343 GrDrawTarget* drawTarget = this->prepareToDraw(NULL, NULL, NULL);
1340 GrDrawTarget::AutoGeometryPush agp(drawTarget); 1344 GrDrawTarget::AutoGeometryPush agp(drawTarget);
1341 1345
1342 GrDrawState drawState; 1346 GrPipelineBuilder pipelineBuilder;
1343 drawState.addColorProcessor(fp); 1347 pipelineBuilder.addColorProcessor(fp);
1344 drawState.setRenderTarget(renderTarget); 1348 pipelineBuilder.setRenderTarget(renderTarget);
1345 drawTarget->drawSimpleRect(&drawState, GrColor_WHITE, matrix, 1349 drawTarget->drawSimpleRect(&pipelineBuilder, GrColor_WHITE, matrix,
1346 SkRect::MakeWH(SkIntToScalar(width), SkIntToS calar(height))); 1350 SkRect::MakeWH(SkIntToScalar(width), SkIntToS calar(height)));
1347 } 1351 }
1348 1352
1349 if (kFlushWrites_PixelOp & pixelOpsFlags) { 1353 if (kFlushWrites_PixelOp & pixelOpsFlags) {
1350 this->flushSurfaceWrites(surface); 1354 this->flushSurfaceWrites(surface);
1351 } 1355 }
1352 1356
1353 return true; 1357 return true;
1354 } 1358 }
1355 1359
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 src, swapRAndB, GrConfigConversionEffect::kNone_PMCo nversion, 1455 src, swapRAndB, GrConfigConversionEffect::kNone_PMCo nversion,
1452 textureMatrix)); 1456 textureMatrix));
1453 } 1457 }
1454 swapRAndB = false; // we will handle the swap in the draw. 1458 swapRAndB = false; // we will handle the swap in the draw.
1455 1459
1456 // We protect the existing geometry here since it may not be 1460 // We protect the existing geometry here since it may not be
1457 // clear to the caller that a draw operation (i.e., drawSimpleRe ct) 1461 // clear to the caller that a draw operation (i.e., drawSimpleRe ct)
1458 // can be invoked in this method 1462 // can be invoked in this method
1459 { 1463 {
1460 GrDrawTarget::AutoGeometryPush agp(fDrawBuffer); 1464 GrDrawTarget::AutoGeometryPush agp(fDrawBuffer);
1461 GrDrawState drawState; 1465 GrPipelineBuilder pipelineBuilder;
1462 SkASSERT(fp); 1466 SkASSERT(fp);
1463 drawState.addColorProcessor(fp); 1467 pipelineBuilder.addColorProcessor(fp);
1464 1468
1465 drawState.setRenderTarget(tempTexture->asRenderTarget()); 1469 pipelineBuilder.setRenderTarget(tempTexture->asRenderTarget( ));
1466 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToSc alar(height)); 1470 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToSc alar(height));
1467 fDrawBuffer->drawSimpleRect(&drawState, GrColor_WHITE, SkMat rix::I(), rect); 1471 fDrawBuffer->drawSimpleRect(&pipelineBuilder, GrColor_WHITE, SkMatrix::I(),
1472 rect);
1468 // we want to read back from the scratch's origin 1473 // we want to read back from the scratch's origin
1469 left = 0; 1474 left = 0;
1470 top = 0; 1475 top = 0;
1471 target = tempTexture->asRenderTarget(); 1476 target = tempTexture->asRenderTarget();
1472 } 1477 }
1473 this->flushSurfaceWrites(target); 1478 this->flushSurfaceWrites(target);
1474 } 1479 }
1475 } 1480 }
1476 } 1481 }
1477 1482
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 this->flush(); 1550 this->flush();
1546 } 1551 }
1547 } 1552 }
1548 1553
1549 void GrContext::flushSurfaceWrites(GrSurface* surface) { 1554 void GrContext::flushSurfaceWrites(GrSurface* surface) {
1550 if (surface->surfacePriv().hasPendingWrite()) { 1555 if (surface->surfacePriv().hasPendingWrite()) {
1551 this->flush(); 1556 this->flush();
1552 } 1557 }
1553 } 1558 }
1554 1559
1555 GrDrawTarget* GrContext::prepareToDraw(GrDrawState* ds, 1560 GrDrawTarget* GrContext::prepareToDraw(GrPipelineBuilder* pipelineBuilder,
1556 const GrPaint* paint, 1561 const GrPaint* paint,
1557 const AutoCheckFlush* acf) { 1562 const AutoCheckFlush* acf) {
1558 if (NULL == fGpu) { 1563 if (NULL == fGpu) {
1559 return NULL; 1564 return NULL;
1560 } 1565 }
1561 1566
1562 ASSERT_OWNED_RESOURCE(fRenderTarget.get()); 1567 ASSERT_OWNED_RESOURCE(fRenderTarget.get());
1563 if (ds) { 1568 if (pipelineBuilder) {
1564 SkASSERT(paint && acf); 1569 SkASSERT(paint && acf);
1565 ds->setFromPaint(*paint, fRenderTarget.get()); 1570 pipelineBuilder->setFromPaint(*paint, fRenderTarget.get());
1566 ds->setState(GrDrawState::kClip_StateBit, fClip && !fClip->fClipStack->i sWideOpen()); 1571 pipelineBuilder->setState(GrPipelineBuilder::kClip_StateBit,
1572 fClip && !fClip->fClipStack->isWideOpen());
1567 } 1573 }
1568 fDrawBuffer->setClip(fClip); 1574 fDrawBuffer->setClip(fClip);
1569 return fDrawBuffer; 1575 return fDrawBuffer;
1570 } 1576 }
1571 1577
1572 /* 1578 /*
1573 * This method finds a path renderer that can draw the specified path on 1579 * This method finds a path renderer that can draw the specified path on
1574 * the provided target. 1580 * the provided target.
1575 * Due to its expense, the software path renderer has split out so it can 1581 * Due to its expense, the software path renderer has split out so it can
1576 * can be individually allowed/disallowed via the "allowSW" boolean. 1582 * can be individually allowed/disallowed via the "allowSW" boolean.
1577 */ 1583 */
1578 GrPathRenderer* GrContext::getPathRenderer(const GrDrawTarget* target, 1584 GrPathRenderer* GrContext::getPathRenderer(const GrDrawTarget* target,
1579 const GrDrawState* drawState, 1585 const GrPipelineBuilder* pipelineBuil der,
1580 const SkMatrix& viewMatrix, 1586 const SkMatrix& viewMatrix,
1581 const SkPath& path, 1587 const SkPath& path,
1582 const SkStrokeRec& stroke, 1588 const SkStrokeRec& stroke,
1583 bool allowSW, 1589 bool allowSW,
1584 GrPathRendererChain::DrawType drawTyp e, 1590 GrPathRendererChain::DrawType drawTyp e,
1585 GrPathRendererChain::StencilSupport* stencilSupport) { 1591 GrPathRendererChain::StencilSupport* stencilSupport) {
1586 1592
1587 if (NULL == fPathRendererChain) { 1593 if (NULL == fPathRendererChain) {
1588 fPathRendererChain = SkNEW_ARGS(GrPathRendererChain, (this)); 1594 fPathRendererChain = SkNEW_ARGS(GrPathRendererChain, (this));
1589 } 1595 }
1590 1596
1591 GrPathRenderer* pr = fPathRendererChain->getPathRenderer(target, 1597 GrPathRenderer* pr = fPathRendererChain->getPathRenderer(target,
1592 drawState, 1598 pipelineBuilder,
1593 viewMatrix, 1599 viewMatrix,
1594 path, 1600 path,
1595 stroke, 1601 stroke,
1596 drawType, 1602 drawType,
1597 stencilSupport); 1603 stencilSupport);
1598 1604
1599 if (NULL == pr && allowSW) { 1605 if (NULL == pr && allowSW) {
1600 if (NULL == fSoftwarePathRenderer) { 1606 if (NULL == fSoftwarePathRenderer) {
1601 fSoftwarePathRenderer = SkNEW_ARGS(GrSoftwarePathRenderer, (this)); 1607 fSoftwarePathRenderer = SkNEW_ARGS(GrSoftwarePathRenderer, (this));
1602 } 1608 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 fResourceCache2->printStats(); 1731 fResourceCache2->printStats();
1726 } 1732 }
1727 #endif 1733 #endif
1728 1734
1729 #if GR_GPU_STATS 1735 #if GR_GPU_STATS
1730 const GrContext::GPUStats* GrContext::gpuStats() const { 1736 const GrContext::GPUStats* GrContext::gpuStats() const {
1731 return fGpu->gpuStats(); 1737 return fGpu->gpuStats();
1732 } 1738 }
1733 #endif 1739 #endif
1734 1740
OLDNEW
« no previous file with comments | « src/gpu/GrClipMaskManager.cpp ('k') | src/gpu/GrDefaultGeoProcFactory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698