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

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

Issue 815553003: Move ViewMatrix off of drawstate (Closed) Base URL: https://skia.googlesource.com/skia.git@remove-fragment-stage
Patch Set: more cleaning 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.h » ('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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 // texels in the resampled image are copies of texels from 308 // texels in the resampled image are copies of texels from
309 // the original. 309 // the original.
310 GrTextureParams params(SkShader::kClamp_TileMode, 310 GrTextureParams params(SkShader::kClamp_TileMode,
311 filter ? GrTextureParams::kBilerp_FilterMode : 311 filter ? GrTextureParams::kBilerp_FilterMode :
312 GrTextureParams::kNone_FilterMode); 312 GrTextureParams::kNone_FilterMode);
313 drawState.addColorTextureProcessor(clampedTexture, SkMatrix::I(), params ); 313 drawState.addColorTextureProcessor(clampedTexture, SkMatrix::I(), params );
314 314
315 uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType | 315 uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType |
316 GrDefaultGeoProcFactory::kLocalCoord_GPType; 316 GrDefaultGeoProcFactory::kLocalCoord_GPType;
317 SkAutoTUnref<const GrGeometryProcessor> gp( 317 SkAutoTUnref<const GrGeometryProcessor> gp(
318 GrDefaultGeoProcFactory::Create(GrColor_WHITE, flags)); 318 GrDefaultGeoProcFactory::Create(flags, GrColor_WHITE));
319 319
320 GrDrawTarget::AutoReleaseGeometry arg(fDrawBuffer, 4, gp->getVertexStrid e(), 0); 320 GrDrawTarget::AutoReleaseGeometry arg(fDrawBuffer, 4, gp->getVertexStrid e(), 0);
321 SkASSERT(gp->getVertexStride() == 2 * sizeof(SkPoint)); 321 SkASSERT(gp->getVertexStride() == 2 * sizeof(SkPoint));
322 322
323 if (arg.succeeded()) { 323 if (arg.succeeded()) {
324 SkPoint* verts = (SkPoint*) arg.vertices(); 324 SkPoint* verts = (SkPoint*) arg.vertices();
325 verts[0].setIRectFan(0, 0, texture->width(), texture->height(), 2 * sizeof(SkPoint)); 325 verts[0].setIRectFan(0, 0, texture->width(), texture->height(), 2 * sizeof(SkPoint));
326 verts[1].setIRectFan(0, 0, 1, 1, 2 * sizeof(SkPoint)); 326 verts[1].setIRectFan(0, 0, 1, 1, 2 * sizeof(SkPoint));
327 fDrawBuffer->drawNonIndexed(&drawState, gp, kTriangleFan_GrPrimitive Type, 0, 4); 327 fDrawBuffer->drawNonIndexed(&drawState, gp, kTriangleFan_GrPrimitive Type, 0, 4);
328 } 328 }
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 533
534 void GrContext::clear(const SkIRect* rect, 534 void GrContext::clear(const SkIRect* rect,
535 const GrColor color, 535 const GrColor color,
536 bool canIgnoreRect, 536 bool canIgnoreRect,
537 GrRenderTarget* renderTarget) { 537 GrRenderTarget* renderTarget) {
538 ASSERT_OWNED_RESOURCE(renderTarget); 538 ASSERT_OWNED_RESOURCE(renderTarget);
539 SkASSERT(renderTarget); 539 SkASSERT(renderTarget);
540 540
541 AutoCheckFlush acf(this); 541 AutoCheckFlush acf(this);
542 GR_CREATE_TRACE_MARKER_CONTEXT("GrContext::clear", this); 542 GR_CREATE_TRACE_MARKER_CONTEXT("GrContext::clear", this);
543 GrDrawTarget* target = this->prepareToDraw(NULL, NULL, NULL, &acf); 543 GrDrawTarget* target = this->prepareToDraw(NULL, NULL, &acf);
544 if (NULL == target) { 544 if (NULL == target) {
545 return; 545 return;
546 } 546 }
547 target->clear(rect, color, canIgnoreRect, renderTarget); 547 target->clear(rect, color, canIgnoreRect, renderTarget);
548 } 548 }
549 549
550 void GrContext::drawPaint(const GrPaint& origPaint, const SkMatrix& viewMatrix) { 550 void GrContext::drawPaint(const GrPaint& origPaint, const SkMatrix& viewMatrix) {
551 // set rect to be big enough to fill the space, but not super-huge, so we 551 // set rect to be big enough to fill the space, but not super-huge, so we
552 // don't overflow fixed-point implementations 552 // don't overflow fixed-point implementations
553 SkRect r; 553 SkRect r;
(...skipping 22 matching lines...) Expand all
576 this->drawRect(*paint, viewMatrix, r); 576 this->drawRect(*paint, viewMatrix, r);
577 } else { 577 } else {
578 SkMatrix localMatrix; 578 SkMatrix localMatrix;
579 if (!viewMatrix.invert(&localMatrix)) { 579 if (!viewMatrix.invert(&localMatrix)) {
580 SkDebugf("Could not invert matrix\n"); 580 SkDebugf("Could not invert matrix\n");
581 return; 581 return;
582 } 582 }
583 583
584 AutoCheckFlush acf(this); 584 AutoCheckFlush acf(this);
585 GrDrawState drawState; 585 GrDrawState drawState;
586 GrDrawTarget* target = this->prepareToDraw(&drawState, paint, &SkMatrix: :I(), &acf); 586 GrDrawTarget* target = this->prepareToDraw(&drawState, paint, &acf);
587 if (NULL == target) { 587 if (NULL == target) {
588 return; 588 return;
589 } 589 }
590 590
591 GR_CREATE_TRACE_MARKER("GrContext::drawPaintWithPerspective", target); 591 GR_CREATE_TRACE_MARKER("GrContext::drawPaintWithPerspective", target);
592 target->drawRect(&drawState, paint->getColor(), r, NULL, &localMatrix); 592 target->drawRect(&drawState, paint->getColor(), SkMatrix::I(), r, NULL, &localMatrix);
593 } 593 }
594 } 594 }
595 595
596 #ifdef SK_DEVELOPER 596 #ifdef SK_DEVELOPER
597 void GrContext::dumpFontCache() const { 597 void GrContext::dumpFontCache() const {
598 fFontCache->dump(); 598 fFontCache->dump();
599 } 599 }
600 #endif 600 #endif
601 601
602 //////////////////////////////////////////////////////////////////////////////// 602 ////////////////////////////////////////////////////////////////////////////////
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 const GrStrokeInfo* strokeInfo) { 685 const GrStrokeInfo* strokeInfo) {
686 if (strokeInfo && strokeInfo->isDashed()) { 686 if (strokeInfo && strokeInfo->isDashed()) {
687 SkPath path; 687 SkPath path;
688 path.addRect(rect); 688 path.addRect(rect);
689 this->drawPath(paint, viewMatrix, path, *strokeInfo); 689 this->drawPath(paint, viewMatrix, path, *strokeInfo);
690 return; 690 return;
691 } 691 }
692 692
693 AutoCheckFlush acf(this); 693 AutoCheckFlush acf(this);
694 GrDrawState drawState; 694 GrDrawState drawState;
695 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &viewMatrix, &acf); 695 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &acf);
696 if (NULL == target) { 696 if (NULL == target) {
697 return; 697 return;
698 } 698 }
699 699
700 GR_CREATE_TRACE_MARKER("GrContext::drawRect", target); 700 GR_CREATE_TRACE_MARKER("GrContext::drawRect", target);
701 SkScalar width = NULL == strokeInfo ? -1 : strokeInfo->getStrokeRec().getWid th(); 701 SkScalar width = NULL == strokeInfo ? -1 : strokeInfo->getStrokeRec().getWid th();
702 SkMatrix matrix = drawState.getViewMatrix();
703 702
704 // Check if this is a full RT draw and can be replaced with a clear. We don' t bother checking 703 // Check if this is a full RT draw and can be replaced with a clear. We don' t bother checking
705 // cases where the RT is fully inside a stroke. 704 // cases where the RT is fully inside a stroke.
706 if (width < 0) { 705 if (width < 0) {
707 SkRect rtRect; 706 SkRect rtRect;
708 drawState.getRenderTarget()->getBoundsRect(&rtRect); 707 drawState.getRenderTarget()->getBoundsRect(&rtRect);
709 SkRect clipSpaceRTRect = rtRect; 708 SkRect clipSpaceRTRect = rtRect;
710 bool checkClip = false; 709 bool checkClip = false;
711 if (this->getClip()) { 710 if (this->getClip()) {
712 checkClip = true; 711 checkClip = true;
713 clipSpaceRTRect.offset(SkIntToScalar(this->getClip()->fOrigin.fX), 712 clipSpaceRTRect.offset(SkIntToScalar(this->getClip()->fOrigin.fX),
714 SkIntToScalar(this->getClip()->fOrigin.fY)); 713 SkIntToScalar(this->getClip()->fOrigin.fY));
715 } 714 }
716 // Does the clip contain the entire RT? 715 // Does the clip contain the entire RT?
717 if (!checkClip || target->getClip()->fClipStack->quickContains(clipSpace RTRect)) { 716 if (!checkClip || target->getClip()->fClipStack->quickContains(clipSpace RTRect)) {
718 SkMatrix invM; 717 SkMatrix invM;
719 if (!matrix.invert(&invM)) { 718 if (!viewMatrix.invert(&invM)) {
720 return; 719 return;
721 } 720 }
722 // Does the rect bound the RT? 721 // Does the rect bound the RT?
723 SkPoint srcSpaceRTQuad[4]; 722 SkPoint srcSpaceRTQuad[4];
724 invM.mapRectToQuad(srcSpaceRTQuad, rtRect); 723 invM.mapRectToQuad(srcSpaceRTQuad, rtRect);
725 if (rect_contains_inclusive(rect, srcSpaceRTQuad[0]) && 724 if (rect_contains_inclusive(rect, srcSpaceRTQuad[0]) &&
726 rect_contains_inclusive(rect, srcSpaceRTQuad[1]) && 725 rect_contains_inclusive(rect, srcSpaceRTQuad[1]) &&
727 rect_contains_inclusive(rect, srcSpaceRTQuad[2]) && 726 rect_contains_inclusive(rect, srcSpaceRTQuad[2]) &&
728 rect_contains_inclusive(rect, srcSpaceRTQuad[3])) { 727 rect_contains_inclusive(rect, srcSpaceRTQuad[3])) {
729 // Will it blend? 728 // Will it blend?
730 GrColor clearColor; 729 GrColor clearColor;
731 if (paint.isOpaqueAndConstantColor(&clearColor)) { 730 if (paint.isOpaqueAndConstantColor(&clearColor)) {
732 target->clear(NULL, clearColor, true, fRenderTarget); 731 target->clear(NULL, clearColor, true, fRenderTarget);
733 return; 732 return;
734 } 733 }
735 } 734 }
736 } 735 }
737 } 736 }
738 737
739 GrColor color = paint.getColor(); 738 GrColor color = paint.getColor();
740 SkRect devBoundRect; 739 SkRect devBoundRect;
741 bool needAA = paint.isAntiAlias() && !drawState.getRenderTarget()->isMultisa mpled(); 740 bool needAA = paint.isAntiAlias() && !drawState.getRenderTarget()->isMultisa mpled();
742 bool doAA = needAA && apply_aa_to_rect(target, &drawState, &devBoundRect, re ct, width, matrix, 741 bool doAA = needAA && apply_aa_to_rect(target, &drawState, &devBoundRect, re ct, width,
743 color); 742 viewMatrix, color);
744 743
745 if (doAA) { 744 if (doAA) {
746 SkMatrix invert;
747 if (!drawState.getViewMatrix().invert(&invert)) {
748 return;
749 }
750 GrDrawState::AutoViewMatrixRestore avmr(&drawState);
751
752 if (width >= 0) { 745 if (width >= 0) {
753 const SkStrokeRec& strokeRec = strokeInfo->getStrokeRec(); 746 const SkStrokeRec& strokeRec = strokeInfo->getStrokeRec();
754 fAARectRenderer->strokeAARect(target, 747 fAARectRenderer->strokeAARect(target,
755 &drawState, 748 &drawState,
756 color, 749 color,
757 invert, 750 viewMatrix,
758 rect, 751 rect,
759 matrix,
760 devBoundRect, 752 devBoundRect,
761 strokeRec); 753 strokeRec);
762 } else { 754 } else {
763 // filled AA rect 755 // filled AA rect
764 fAARectRenderer->fillAARect(target, &drawState, color, invert, rect, matrix, 756 fAARectRenderer->fillAARect(target,
757 &drawState,
758 color,
759 viewMatrix,
760 rect,
765 devBoundRect); 761 devBoundRect);
766 } 762 }
767 return; 763 return;
768 } 764 }
769 765
770 if (width >= 0) { 766 if (width >= 0) {
771 // TODO: consider making static vertex buffers for these cases. 767 // TODO: consider making static vertex buffers for these cases.
772 // Hairline could be done by just adding closing vertex to 768 // Hairline could be done by just adding closing vertex to
773 // unitSquareVertexBuffer() 769 // unitSquareVertexBuffer()
774 770
775 static const int worstCaseVertCount = 10; 771 static const int worstCaseVertCount = 10;
776 SkAutoTUnref<const GrGeometryProcessor> gp(GrDefaultGeoProcFactory::Crea te(color)); 772 SkAutoTUnref<const GrGeometryProcessor> gp(
773 GrDefaultGeoProcFactory::Create(GrDefaultGeoProcFactory::kPositi on_GPType,
774 color,
775 viewMatrix,
776 SkMatrix::I()));
777 GrDrawTarget::AutoReleaseGeometry geo(target, 777 GrDrawTarget::AutoReleaseGeometry geo(target,
778 worstCaseVertCount, 778 worstCaseVertCount,
779 gp->getVertexStride(), 779 gp->getVertexStride(),
780 0); 780 0);
781 SkASSERT(gp->getVertexStride() == sizeof(SkPoint)); 781 SkASSERT(gp->getVertexStride() == sizeof(SkPoint));
782 782
783 if (!geo.succeeded()) { 783 if (!geo.succeeded()) {
784 SkDebugf("Failed to get space for vertices!\n"); 784 SkDebugf("Failed to get space for vertices!\n");
785 return; 785 return;
786 } 786 }
(...skipping 13 matching lines...) Expand all
800 vertex[0].set(rect.fLeft, rect.fTop); 800 vertex[0].set(rect.fLeft, rect.fTop);
801 vertex[1].set(rect.fRight, rect.fTop); 801 vertex[1].set(rect.fRight, rect.fTop);
802 vertex[2].set(rect.fRight, rect.fBottom); 802 vertex[2].set(rect.fRight, rect.fBottom);
803 vertex[3].set(rect.fLeft, rect.fBottom); 803 vertex[3].set(rect.fLeft, rect.fBottom);
804 vertex[4].set(rect.fLeft, rect.fTop); 804 vertex[4].set(rect.fLeft, rect.fTop);
805 } 805 }
806 806
807 target->drawNonIndexed(&drawState, gp, primType, 0, vertCount); 807 target->drawNonIndexed(&drawState, gp, primType, 0, vertCount);
808 } else { 808 } else {
809 // filled BW rect 809 // filled BW rect
810 target->drawSimpleRect(&drawState, color, rect); 810 target->drawSimpleRect(&drawState, color, viewMatrix, rect);
811 } 811 }
812 } 812 }
813 813
814 void GrContext::drawNonAARectToRect(const GrPaint& paint, 814 void GrContext::drawNonAARectToRect(const GrPaint& paint,
815 const SkMatrix& viewMatrix, 815 const SkMatrix& viewMatrix,
816 const SkRect& rectToDraw, 816 const SkRect& rectToDraw,
817 const SkRect& localRect, 817 const SkRect& localRect,
818 const SkMatrix* localMatrix) { 818 const SkMatrix* localMatrix) {
819 AutoCheckFlush acf(this); 819 AutoCheckFlush acf(this);
820 GrDrawState drawState; 820 GrDrawState drawState;
821 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &viewMatrix, &acf); 821 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &acf);
822 if (NULL == target) { 822 if (NULL == target) {
823 return; 823 return;
824 } 824 }
825 825
826 GR_CREATE_TRACE_MARKER("GrContext::drawRectToRect", target); 826 GR_CREATE_TRACE_MARKER("GrContext::drawRectToRect", target);
827 827
828 target->drawRect(&drawState, paint.getColor(), rectToDraw, &localRect, local Matrix); 828 target->drawRect(&drawState, paint.getColor(), viewMatrix, rectToDraw, &loca lRect, localMatrix);
829 } 829 }
830 830
831 static const GrGeometryProcessor* set_vertex_attributes(const SkPoint* texCoords , 831 static const GrGeometryProcessor* set_vertex_attributes(const SkPoint* texCoords ,
832 const GrColor* colors, 832 const GrColor* colors,
833 int* colorOffset, 833 int* colorOffset,
834 int* texOffset, 834 int* texOffset,
835 GrColor color) { 835 GrColor color,
836 const SkMatrix& viewMatr ix) {
836 *texOffset = -1; 837 *texOffset = -1;
837 *colorOffset = -1; 838 *colorOffset = -1;
838 uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType; 839 uint32_t flags = GrDefaultGeoProcFactory::kPosition_GPType;
839 if (texCoords && colors) { 840 if (texCoords && colors) {
840 *colorOffset = sizeof(SkPoint); 841 *colorOffset = sizeof(SkPoint);
841 *texOffset = sizeof(SkPoint) + sizeof(GrColor); 842 *texOffset = sizeof(SkPoint) + sizeof(GrColor);
842 flags |= GrDefaultGeoProcFactory::kColor_GPType | 843 flags |= GrDefaultGeoProcFactory::kColor_GPType |
843 GrDefaultGeoProcFactory::kLocalCoord_GPType; 844 GrDefaultGeoProcFactory::kLocalCoord_GPType;
844 } else if (texCoords) { 845 } else if (texCoords) {
845 *texOffset = sizeof(SkPoint); 846 *texOffset = sizeof(SkPoint);
846 flags |= GrDefaultGeoProcFactory::kLocalCoord_GPType; 847 flags |= GrDefaultGeoProcFactory::kLocalCoord_GPType;
847 } else if (colors) { 848 } else if (colors) {
848 *colorOffset = sizeof(SkPoint); 849 *colorOffset = sizeof(SkPoint);
849 flags |= GrDefaultGeoProcFactory::kColor_GPType; 850 flags |= GrDefaultGeoProcFactory::kColor_GPType;
850 } 851 }
851 return GrDefaultGeoProcFactory::Create(color, flags); 852 return GrDefaultGeoProcFactory::Create(flags, color, viewMatrix, SkMatrix::I ());
852 } 853 }
853 854
854 void GrContext::drawVertices(const GrPaint& paint, 855 void GrContext::drawVertices(const GrPaint& paint,
855 const SkMatrix& viewMatrix, 856 const SkMatrix& viewMatrix,
856 GrPrimitiveType primitiveType, 857 GrPrimitiveType primitiveType,
857 int vertexCount, 858 int vertexCount,
858 const SkPoint positions[], 859 const SkPoint positions[],
859 const SkPoint texCoords[], 860 const SkPoint texCoords[],
860 const GrColor colors[], 861 const GrColor colors[],
861 const uint16_t indices[], 862 const uint16_t indices[],
862 int indexCount) { 863 int indexCount) {
863 AutoCheckFlush acf(this); 864 AutoCheckFlush acf(this);
864 GrDrawState drawState; 865 GrDrawState drawState;
865 GrDrawTarget::AutoReleaseGeometry geo; // must be inside AutoCheckFlush scop e 866 GrDrawTarget::AutoReleaseGeometry geo; // must be inside AutoCheckFlush scop e
866 867
867 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &viewMatrix, &acf); 868 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &acf);
868 if (NULL == target) { 869 if (NULL == target) {
869 return; 870 return;
870 } 871 }
871 872
872 GR_CREATE_TRACE_MARKER("GrContext::drawVertices", target); 873 GR_CREATE_TRACE_MARKER("GrContext::drawVertices", target);
873 874
874 int colorOffset = -1, texOffset = -1; 875 int colorOffset = -1, texOffset = -1;
875 SkAutoTUnref<const GrGeometryProcessor> gp( 876 SkAutoTUnref<const GrGeometryProcessor> gp(
876 set_vertex_attributes(texCoords, colors, &colorOffset, &texOffset, p aint.getColor())); 877 set_vertex_attributes(texCoords, colors, &colorOffset, &texOffset,
878 paint.getColor(), viewMatrix));
877 879
878 size_t vertexStride = gp->getVertexStride(); 880 size_t vertexStride = gp->getVertexStride();
879 SkASSERT(vertexStride == sizeof(SkPoint) + (SkToBool(texCoords) ? sizeof(SkP oint) : 0) 881 SkASSERT(vertexStride == sizeof(SkPoint) + (SkToBool(texCoords) ? sizeof(SkP oint) : 0)
880 + (SkToBool(colors) ? sizeof(GrColo r) : 0)); 882 + (SkToBool(colors) ? sizeof(GrColo r) : 0));
881 if (!geo.set(target, vertexCount, vertexStride, indexCount)) { 883 if (!geo.set(target, vertexCount, vertexStride, indexCount)) {
882 SkDebugf("Failed to get space for vertices!\n"); 884 SkDebugf("Failed to get space for vertices!\n");
883 return; 885 return;
884 } 886 }
885 void* curVertex = geo.vertices(); 887 void* curVertex = geo.vertices();
886 888
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 923
922 if (strokeInfo.isDashed()) { 924 if (strokeInfo.isDashed()) {
923 SkPath path; 925 SkPath path;
924 path.addRRect(rrect); 926 path.addRRect(rrect);
925 this->drawPath(paint, viewMatrix, path, strokeInfo); 927 this->drawPath(paint, viewMatrix, path, strokeInfo);
926 return; 928 return;
927 } 929 }
928 930
929 AutoCheckFlush acf(this); 931 AutoCheckFlush acf(this);
930 GrDrawState drawState; 932 GrDrawState drawState;
931 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &viewMatrix, &acf); 933 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &acf);
932 if (NULL == target) { 934 if (NULL == target) {
933 return; 935 return;
934 } 936 }
935 937
936 GR_CREATE_TRACE_MARKER("GrContext::drawRRect", target); 938 GR_CREATE_TRACE_MARKER("GrContext::drawRRect", target);
937 939
938 const SkStrokeRec& strokeRec = strokeInfo.getStrokeRec(); 940 const SkStrokeRec& strokeRec = strokeInfo.getStrokeRec();
939 941
940 GrColor color = paint.getColor(); 942 GrColor color = paint.getColor();
941 if (!fOvalRenderer->drawRRect(target, &drawState, color, paint.isAntiAlias() , rrect, 943 if (!fOvalRenderer->drawRRect(target, &drawState, color, viewMatrix, paint.i sAntiAlias(), rrect,
942 strokeRec)) { 944 strokeRec)) {
943 SkPath path; 945 SkPath path;
944 path.addRRect(rrect); 946 path.addRRect(rrect);
945 this->internalDrawPath(target, &drawState, viewMatrix, color, paint.isAn tiAlias(), path, 947 this->internalDrawPath(target, &drawState, viewMatrix, color, paint.isAn tiAlias(), path,
946 strokeInfo); 948 strokeInfo);
947 } 949 }
948 } 950 }
949 951
950 /////////////////////////////////////////////////////////////////////////////// 952 ///////////////////////////////////////////////////////////////////////////////
951 953
952 void GrContext::drawDRRect(const GrPaint& paint, 954 void GrContext::drawDRRect(const GrPaint& paint,
953 const SkMatrix& viewMatrix, 955 const SkMatrix& viewMatrix,
954 const SkRRect& outer, 956 const SkRRect& outer,
955 const SkRRect& inner) { 957 const SkRRect& inner) {
956 if (outer.isEmpty()) { 958 if (outer.isEmpty()) {
957 return; 959 return;
958 } 960 }
959 961
960 AutoCheckFlush acf(this); 962 AutoCheckFlush acf(this);
961 GrDrawState drawState; 963 GrDrawState drawState;
962 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &viewMatrix, &acf); 964 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &acf);
963 965
964 GR_CREATE_TRACE_MARKER("GrContext::drawDRRect", target); 966 GR_CREATE_TRACE_MARKER("GrContext::drawDRRect", target);
965 967
966 GrColor color = paint.getColor(); 968 GrColor color = paint.getColor();
967 if (!fOvalRenderer->drawDRRect(target, &drawState, color, paint.isAntiAlias( ), outer, inner)) { 969 if (!fOvalRenderer->drawDRRect(target, &drawState, color, viewMatrix, paint. isAntiAlias(), outer, inner)) {
968 SkPath path; 970 SkPath path;
969 path.addRRect(inner); 971 path.addRRect(inner);
970 path.addRRect(outer); 972 path.addRRect(outer);
971 path.setFillType(SkPath::kEvenOdd_FillType); 973 path.setFillType(SkPath::kEvenOdd_FillType);
972 974
973 GrStrokeInfo fillRec(SkStrokeRec::kFill_InitStyle); 975 GrStrokeInfo fillRec(SkStrokeRec::kFill_InitStyle);
974 this->internalDrawPath(target, &drawState, viewMatrix, color, paint.isAn tiAlias(), path, 976 this->internalDrawPath(target, &drawState, viewMatrix, color, paint.isAn tiAlias(), path,
975 fillRec); 977 fillRec);
976 } 978 }
977 } 979 }
(...skipping 10 matching lines...) Expand all
988 990
989 if (strokeInfo.isDashed()) { 991 if (strokeInfo.isDashed()) {
990 SkPath path; 992 SkPath path;
991 path.addOval(oval); 993 path.addOval(oval);
992 this->drawPath(paint, viewMatrix, path, strokeInfo); 994 this->drawPath(paint, viewMatrix, path, strokeInfo);
993 return; 995 return;
994 } 996 }
995 997
996 AutoCheckFlush acf(this); 998 AutoCheckFlush acf(this);
997 GrDrawState drawState; 999 GrDrawState drawState;
998 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &viewMatrix, &acf); 1000 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &acf);
999 if (NULL == target) { 1001 if (NULL == target) {
1000 return; 1002 return;
1001 } 1003 }
1002 1004
1003 GR_CREATE_TRACE_MARKER("GrContext::drawOval", target); 1005 GR_CREATE_TRACE_MARKER("GrContext::drawOval", target);
1004 1006
1005 const SkStrokeRec& strokeRec = strokeInfo.getStrokeRec(); 1007 const SkStrokeRec& strokeRec = strokeInfo.getStrokeRec();
1006 1008
1007 GrColor color = paint.getColor(); 1009 GrColor color = paint.getColor();
1008 if (!fOvalRenderer->drawOval(target, &drawState, color, paint.isAntiAlias(), oval, strokeRec)) { 1010 if (!fOvalRenderer->drawOval(target, &drawState, color, viewMatrix, paint.is AntiAlias(), oval,
1011 strokeRec)) {
1009 SkPath path; 1012 SkPath path;
1010 path.addOval(oval); 1013 path.addOval(oval);
1011 this->internalDrawPath(target, &drawState, viewMatrix, color, paint.isAn tiAlias(), path, 1014 this->internalDrawPath(target, &drawState, viewMatrix, color, paint.isAn tiAlias(), path,
1012 strokeInfo); 1015 strokeInfo);
1013 } 1016 }
1014 } 1017 }
1015 1018
1016 // Can 'path' be drawn as a pair of filled nested rectangles? 1019 // Can 'path' be drawn as a pair of filled nested rectangles?
1017 static bool is_nested_rects(GrDrawTarget* target, 1020 static bool is_nested_rects(GrDrawTarget* target,
1018 GrDrawState* drawState, 1021 GrDrawState* drawState,
1019 GrColor color, 1022 GrColor color,
1023 const SkMatrix& viewMatrix,
1020 const SkPath& path, 1024 const SkPath& path,
1021 const SkStrokeRec& stroke, 1025 const SkStrokeRec& stroke,
1022 SkRect rects[2]) { 1026 SkRect rects[2]) {
1023 SkASSERT(stroke.isFillStyle()); 1027 SkASSERT(stroke.isFillStyle());
1024 1028
1025 if (path.isInverseFillType()) { 1029 if (path.isInverseFillType()) {
1026 return false; 1030 return false;
1027 } 1031 }
1028 1032
1029 // TODO: this restriction could be lifted if we were willing to apply 1033 // TODO: this restriction could be lifted if we were willing to apply
1030 // the matrix to all the points individually rather than just to the rect 1034 // the matrix to all the points individually rather than just to the rect
1031 if (!drawState->getViewMatrix().preservesAxisAlignment()) { 1035 if (!viewMatrix.preservesAxisAlignment()) {
1032 return false; 1036 return false;
1033 } 1037 }
1034 1038
1035 if (!drawState->canTweakAlphaForCoverage() && 1039 if (!drawState->canTweakAlphaForCoverage() &&
1036 !drawState->canUseFracCoveragePrimProc(color, *target->caps())) { 1040 !drawState->canUseFracCoveragePrimProc(color, *target->caps())) {
1037 return false; 1041 return false;
1038 } 1042 }
1039 1043
1040 SkPath::Direction dirs[2]; 1044 SkPath::Direction dirs[2];
1041 if (!path.isNestedRects(rects, dirs)) { 1045 if (!path.isNestedRects(rects, dirs)) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 } 1085 }
1082 return; 1086 return;
1083 } 1087 }
1084 1088
1085 GrColor color = paint.getColor(); 1089 GrColor color = paint.getColor();
1086 if (strokeInfo.isDashed()) { 1090 if (strokeInfo.isDashed()) {
1087 SkPoint pts[2]; 1091 SkPoint pts[2];
1088 if (path.isLine(pts)) { 1092 if (path.isLine(pts)) {
1089 AutoCheckFlush acf(this); 1093 AutoCheckFlush acf(this);
1090 GrDrawState drawState; 1094 GrDrawState drawState;
1091 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &view Matrix, &acf); 1095 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &acf) ;
1092 if (NULL == target) { 1096 if (NULL == target) {
1093 return; 1097 return;
1094 } 1098 }
1095 1099
1096 if (GrDashingEffect::DrawDashLine(fGpu, target, &drawState, color, p ts, paint, 1100 if (GrDashingEffect::DrawDashLine(fGpu, target, &drawState, color, v iewMatrix, pts,
1097 strokeInfo)) { 1101 paint, strokeInfo)) {
1098 return; 1102 return;
1099 } 1103 }
1100 } 1104 }
1101 1105
1102 // Filter dashed path into new path with the dashing applied 1106 // Filter dashed path into new path with the dashing applied
1103 const SkPathEffect::DashInfo& info = strokeInfo.getDashInfo(); 1107 const SkPathEffect::DashInfo& info = strokeInfo.getDashInfo();
1104 SkTLazy<SkPath> effectPath; 1108 SkTLazy<SkPath> effectPath;
1105 GrStrokeInfo newStrokeInfo(strokeInfo, false); 1109 GrStrokeInfo newStrokeInfo(strokeInfo, false);
1106 SkStrokeRec* stroke = newStrokeInfo.getStrokeRecPtr(); 1110 SkStrokeRec* stroke = newStrokeInfo.getStrokeRecPtr();
1107 if (SkDashPath::FilterDashPath(effectPath.init(), path, stroke, NULL, in fo)) { 1111 if (SkDashPath::FilterDashPath(effectPath.init(), path, stroke, NULL, in fo)) {
1108 this->drawPath(paint, viewMatrix, *effectPath.get(), newStrokeInfo); 1112 this->drawPath(paint, viewMatrix, *effectPath.get(), newStrokeInfo);
1109 return; 1113 return;
1110 } 1114 }
1111 1115
1112 this->drawPath(paint, viewMatrix, path, newStrokeInfo); 1116 this->drawPath(paint, viewMatrix, path, newStrokeInfo);
1113 return; 1117 return;
1114 } 1118 }
1115 1119
1116 // Note that internalDrawPath may sw-rasterize the path into a scratch textu re. 1120 // Note that internalDrawPath may sw-rasterize the path into a scratch textu re.
1117 // Scratch textures can be recycled after they are returned to the texture 1121 // Scratch textures can be recycled after they are returned to the texture
1118 // cache. This presents a potential hazard for buffered drawing. However, 1122 // cache. This presents a potential hazard for buffered drawing. However,
1119 // the writePixels that uploads to the scratch will perform a flush so we're 1123 // the writePixels that uploads to the scratch will perform a flush so we're
1120 // OK. 1124 // OK.
1121 AutoCheckFlush acf(this); 1125 AutoCheckFlush acf(this);
1122 GrDrawState drawState; 1126 GrDrawState drawState;
1123 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &viewMatrix, &acf); 1127 GrDrawTarget* target = this->prepareToDraw(&drawState, &paint, &acf);
1124 if (NULL == target) { 1128 if (NULL == target) {
1125 return; 1129 return;
1126 } 1130 }
1127 1131
1128 GR_CREATE_TRACE_MARKER1("GrContext::drawPath", target, "Is Convex", path.isC onvex()); 1132 GR_CREATE_TRACE_MARKER1("GrContext::drawPath", target, "Is Convex", path.isC onvex());
1129 1133
1130 const SkStrokeRec& strokeRec = strokeInfo.getStrokeRec(); 1134 const SkStrokeRec& strokeRec = strokeInfo.getStrokeRec();
1131 1135
1132 bool useCoverageAA = paint.isAntiAlias() && !drawState.getRenderTarget()->is Multisampled(); 1136 bool useCoverageAA = paint.isAntiAlias() && !drawState.getRenderTarget()->is Multisampled();
1133 1137
1134 if (useCoverageAA && strokeRec.getWidth() < 0 && !path.isConvex()) { 1138 if (useCoverageAA && strokeRec.getWidth() < 0 && !path.isConvex()) {
1135 // Concave AA paths are expensive - try to avoid them for special cases 1139 // Concave AA paths are expensive - try to avoid them for special cases
1136 SkRect rects[2]; 1140 SkRect rects[2];
1137 1141
1138 if (is_nested_rects(target, &drawState, color, path, strokeRec, rects)) { 1142 if (is_nested_rects(target, &drawState, color, viewMatrix, path, strokeR ec, rects)) {
1139 SkMatrix origViewMatrix = drawState.getViewMatrix(); 1143 fAARectRenderer->fillAANestedRects(target, &drawState, color, viewMa trix,rects);
1140
1141 SkMatrix invert;
1142 if (!drawState.getViewMatrix().invert(&invert)) {
1143 return;
1144 }
1145 GrDrawState::AutoViewMatrixRestore avmr(&drawState);
1146
1147 fAARectRenderer->fillAANestedRects(target, &drawState, color, invert , rects,
1148 origViewMatrix);
1149 return; 1144 return;
1150 } 1145 }
1151 } 1146 }
1152 1147
1153 SkRect ovalRect; 1148 SkRect ovalRect;
1154 bool isOval = path.isOval(&ovalRect); 1149 bool isOval = path.isOval(&ovalRect);
1155 1150
1156 if (!isOval || path.isInverseFillType() 1151 if (!isOval || path.isInverseFillType() ||
1157 || !fOvalRenderer->drawOval(target, &drawState, color, paint.isAntiAlias (), ovalRect, 1152 !fOvalRenderer->drawOval(target, &drawState, color, viewMatrix, paint.is AntiAlias(),
1158 strokeRec)) { 1153 ovalRect, strokeRec)) {
1159 this->internalDrawPath(target, &drawState, viewMatrix, color, paint.isAn tiAlias(), path, 1154 this->internalDrawPath(target, &drawState, viewMatrix, color, paint.isAn tiAlias(), path,
1160 strokeInfo); 1155 strokeInfo);
1161 } 1156 }
1162 } 1157 }
1163 1158
1164 void GrContext::internalDrawPath(GrDrawTarget* target, 1159 void GrContext::internalDrawPath(GrDrawTarget* target,
1165 GrDrawState* drawState, 1160 GrDrawState* drawState,
1166 const SkMatrix& viewMatrix, 1161 const SkMatrix& viewMatrix,
1167 GrColor color, 1162 GrColor color,
1168 bool useAA, 1163 bool useAA,
(...skipping 15 matching lines...) Expand all
1184 1179
1185 GrPathRendererChain::DrawType type = 1180 GrPathRendererChain::DrawType type =
1186 useCoverageAA ? GrPathRendererChain::kColorAntiAlias_DrawType : 1181 useCoverageAA ? GrPathRendererChain::kColorAntiAlias_DrawType :
1187 GrPathRendererChain::kColor_DrawType; 1182 GrPathRendererChain::kColor_DrawType;
1188 1183
1189 const SkPath* pathPtr = &path; 1184 const SkPath* pathPtr = &path;
1190 SkTLazy<SkPath> tmpPath; 1185 SkTLazy<SkPath> tmpPath;
1191 SkTCopyOnFirstWrite<SkStrokeRec> stroke(strokeInfo.getStrokeRec()); 1186 SkTCopyOnFirstWrite<SkStrokeRec> stroke(strokeInfo.getStrokeRec());
1192 1187
1193 // Try a 1st time without stroking the path and without allowing the SW rend erer 1188 // Try a 1st time without stroking the path and without allowing the SW rend erer
1194 GrPathRenderer* pr = this->getPathRenderer(target, drawState, *pathPtr, *str oke, false, type); 1189 GrPathRenderer* pr = this->getPathRenderer(target, drawState, viewMatrix, *p athPtr, *stroke,
1190 false, type);
1195 1191
1196 if (NULL == pr) { 1192 if (NULL == pr) {
1197 if (!GrPathRenderer::IsStrokeHairlineOrEquivalent(*stroke, viewMatrix, N ULL)) { 1193 if (!GrPathRenderer::IsStrokeHairlineOrEquivalent(*stroke, viewMatrix, N ULL)) {
1198 // It didn't work the 1st time, so try again with the stroked path 1194 // It didn't work the 1st time, so try again with the stroked path
1199 if (stroke->applyToPath(tmpPath.init(), *pathPtr)) { 1195 if (stroke->applyToPath(tmpPath.init(), *pathPtr)) {
1200 pathPtr = tmpPath.get(); 1196 pathPtr = tmpPath.get();
1201 stroke.writable()->setFillStyle(); 1197 stroke.writable()->setFillStyle();
1202 if (pathPtr->isEmpty()) { 1198 if (pathPtr->isEmpty()) {
1203 return; 1199 return;
1204 } 1200 }
1205 } 1201 }
1206 } 1202 }
1207 1203
1208 // This time, allow SW renderer 1204 // This time, allow SW renderer
1209 pr = this->getPathRenderer(target, drawState, *pathPtr, *stroke, true, t ype); 1205 pr = this->getPathRenderer(target, drawState, viewMatrix, *pathPtr, *str oke, true, type);
1210 } 1206 }
1211 1207
1212 if (NULL == pr) { 1208 if (NULL == pr) {
1213 #ifdef SK_DEBUG 1209 #ifdef SK_DEBUG
1214 SkDebugf("Unable to find path renderer compatible with path.\n"); 1210 SkDebugf("Unable to find path renderer compatible with path.\n");
1215 #endif 1211 #endif
1216 return; 1212 return;
1217 } 1213 }
1218 1214
1219 pr->drawPath(target, drawState, color, *pathPtr, *stroke, useCoverageAA); 1215 pr->drawPath(target, drawState, color, viewMatrix, *pathPtr, *stroke, useCov erageAA);
1220 } 1216 }
1221 1217
1222 //////////////////////////////////////////////////////////////////////////////// 1218 ////////////////////////////////////////////////////////////////////////////////
1223 1219
1224 void GrContext::flush(int flagsBitfield) { 1220 void GrContext::flush(int flagsBitfield) {
1225 if (NULL == fDrawBuffer) { 1221 if (NULL == fDrawBuffer) {
1226 return; 1222 return;
1227 } 1223 }
1228 1224
1229 if (kDiscard_FlushBit & flagsBitfield) { 1225 if (kDiscard_FlushBit & flagsBitfield) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 } 1340 }
1345 1341
1346 SkMatrix matrix; 1342 SkMatrix matrix;
1347 matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top)); 1343 matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top));
1348 1344
1349 // This function can be called in the midst of drawing another object (e.g., when uploading a 1345 // This function can be called in the midst of drawing another object (e.g., when uploading a
1350 // SW-rasterized clip while issuing a draw). So we push the current geometry state before 1346 // SW-rasterized clip while issuing a draw). So we push the current geometry state before
1351 // drawing a rect to the render target. 1347 // drawing a rect to the render target.
1352 // The bracket ensures we pop the stack if we wind up flushing below. 1348 // The bracket ensures we pop the stack if we wind up flushing below.
1353 { 1349 {
1354 GrDrawTarget* drawTarget = this->prepareToDraw(NULL, NULL, NULL, NULL); 1350 GrDrawTarget* drawTarget = this->prepareToDraw(NULL, NULL, NULL);
1355 GrDrawTarget::AutoGeometryPush agp(drawTarget); 1351 GrDrawTarget::AutoGeometryPush agp(drawTarget);
1356 1352
1357 GrDrawState drawState(matrix); 1353 GrDrawState drawState;
1358 drawState.addColorProcessor(fp); 1354 drawState.addColorProcessor(fp);
1359 drawState.setRenderTarget(renderTarget); 1355 drawState.setRenderTarget(renderTarget);
1360 drawTarget->drawSimpleRect(&drawState, GrColor_WHITE,SkRect::MakeWH(SkIn tToScalar(width), 1356 drawTarget->drawSimpleRect(&drawState, GrColor_WHITE, matrix,
1361 SkIn tToScalar(height))); 1357 SkRect::MakeWH(SkIntToScalar(width), SkIntToS calar(height)));
1362 } 1358 }
1363 1359
1364 if (kFlushWrites_PixelOp & pixelOpsFlags) { 1360 if (kFlushWrites_PixelOp & pixelOpsFlags) {
1365 this->flushSurfaceWrites(surface); 1361 this->flushSurfaceWrites(surface);
1366 } 1362 }
1367 1363
1368 return true; 1364 return true;
1369 } 1365 }
1370 1366
1371 // toggles between RGBA and BGRA 1367 // toggles between RGBA and BGRA
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 // clear to the caller that a draw operation (i.e., drawSimpleRe ct) 1468 // clear to the caller that a draw operation (i.e., drawSimpleRe ct)
1473 // can be invoked in this method 1469 // can be invoked in this method
1474 { 1470 {
1475 GrDrawTarget::AutoGeometryPush agp(fDrawBuffer); 1471 GrDrawTarget::AutoGeometryPush agp(fDrawBuffer);
1476 GrDrawState drawState; 1472 GrDrawState drawState;
1477 SkASSERT(fp); 1473 SkASSERT(fp);
1478 drawState.addColorProcessor(fp); 1474 drawState.addColorProcessor(fp);
1479 1475
1480 drawState.setRenderTarget(tempTexture->asRenderTarget()); 1476 drawState.setRenderTarget(tempTexture->asRenderTarget());
1481 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToSc alar(height)); 1477 SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToSc alar(height));
1482 fDrawBuffer->drawSimpleRect(&drawState, GrColor_WHITE, rect) ; 1478 fDrawBuffer->drawSimpleRect(&drawState, GrColor_WHITE, SkMat rix::I(), rect);
1483 // we want to read back from the scratch's origin 1479 // we want to read back from the scratch's origin
1484 left = 0; 1480 left = 0;
1485 top = 0; 1481 top = 0;
1486 target = tempTexture->asRenderTarget(); 1482 target = tempTexture->asRenderTarget();
1487 } 1483 }
1488 this->flushSurfaceWrites(target); 1484 this->flushSurfaceWrites(target);
1489 } 1485 }
1490 } 1486 }
1491 } 1487 }
1492 1488
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 GrRenderTarget* rt = surface->asRenderTarget(); 1521 GrRenderTarget* rt = surface->asRenderTarget();
1526 if (fGpu && rt) { 1522 if (fGpu && rt) {
1527 fGpu->resolveRenderTarget(rt); 1523 fGpu->resolveRenderTarget(rt);
1528 } 1524 }
1529 } 1525 }
1530 1526
1531 void GrContext::discardRenderTarget(GrRenderTarget* renderTarget) { 1527 void GrContext::discardRenderTarget(GrRenderTarget* renderTarget) {
1532 SkASSERT(renderTarget); 1528 SkASSERT(renderTarget);
1533 ASSERT_OWNED_RESOURCE(renderTarget); 1529 ASSERT_OWNED_RESOURCE(renderTarget);
1534 AutoCheckFlush acf(this); 1530 AutoCheckFlush acf(this);
1535 GrDrawTarget* target = this->prepareToDraw(NULL, NULL, NULL, &acf); 1531 GrDrawTarget* target = this->prepareToDraw(NULL, NULL, &acf);
1536 if (NULL == target) { 1532 if (NULL == target) {
1537 return; 1533 return;
1538 } 1534 }
1539 target->discard(renderTarget); 1535 target->discard(renderTarget);
1540 } 1536 }
1541 1537
1542 void GrContext::copySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRe ct, 1538 void GrContext::copySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRe ct,
1543 const SkIPoint& dstPoint, uint32_t pixelOpsFlags) { 1539 const SkIPoint& dstPoint, uint32_t pixelOpsFlags) {
1544 if (NULL == src || NULL == dst) { 1540 if (NULL == src || NULL == dst) {
1545 return; 1541 return;
1546 } 1542 }
1547 ASSERT_OWNED_RESOURCE(src); 1543 ASSERT_OWNED_RESOURCE(src);
1548 ASSERT_OWNED_RESOURCE(dst); 1544 ASSERT_OWNED_RESOURCE(dst);
1549 1545
1550 // Since we're going to the draw target and not GPU, no need to check kNoFlu sh 1546 // Since we're going to the draw target and not GPU, no need to check kNoFlu sh
1551 // here. 1547 // here.
1552 1548
1553 GrDrawTarget* target = this->prepareToDraw(NULL, NULL, NULL, NULL); 1549 GrDrawTarget* target = this->prepareToDraw(NULL, NULL, NULL);
1554 if (NULL == target) { 1550 if (NULL == target) {
1555 return; 1551 return;
1556 } 1552 }
1557 target->copySurface(dst, src, srcRect, dstPoint); 1553 target->copySurface(dst, src, srcRect, dstPoint);
1558 1554
1559 if (kFlushWrites_PixelOp & pixelOpsFlags) { 1555 if (kFlushWrites_PixelOp & pixelOpsFlags) {
1560 this->flush(); 1556 this->flush();
1561 } 1557 }
1562 } 1558 }
1563 1559
1564 void GrContext::flushSurfaceWrites(GrSurface* surface) { 1560 void GrContext::flushSurfaceWrites(GrSurface* surface) {
1565 if (surface->surfacePriv().hasPendingWrite()) { 1561 if (surface->surfacePriv().hasPendingWrite()) {
1566 this->flush(); 1562 this->flush();
1567 } 1563 }
1568 } 1564 }
1569 1565
1570 GrDrawTarget* GrContext::prepareToDraw(GrDrawState* ds, 1566 GrDrawTarget* GrContext::prepareToDraw(GrDrawState* ds,
1571 const GrPaint* paint, 1567 const GrPaint* paint,
1572 const SkMatrix* viewMatrix,
1573 const AutoCheckFlush* acf) { 1568 const AutoCheckFlush* acf) {
1574 if (NULL == fGpu) { 1569 if (NULL == fGpu) {
1575 return NULL; 1570 return NULL;
1576 } 1571 }
1577 1572
1578 ASSERT_OWNED_RESOURCE(fRenderTarget.get()); 1573 ASSERT_OWNED_RESOURCE(fRenderTarget.get());
1579 if (ds) { 1574 if (ds) {
1580 SkASSERT(viewMatrix);
1581 if (paint) { 1575 if (paint) {
1582 SkASSERT(acf); 1576 SkASSERT(acf);
1583 ds->setFromPaint(*paint, *viewMatrix, fRenderTarget.get()); 1577 ds->setFromPaint(*paint, fRenderTarget.get());
1584 #if GR_DEBUG_PARTIAL_COVERAGE_CHECK 1578 #if GR_DEBUG_PARTIAL_COVERAGE_CHECK
1585 if ((paint->hasMask()) && 1579 if ((paint->hasMask()) &&
1586 !fDrawState->canUseFracCoveragePrimProc(paint.getColor(), fGpu-> caps())) { 1580 !fDrawState->canUseFracCoveragePrimProc(paint.getColor(), fGpu-> caps())) {
1587 SkDebugf("Partial pixel coverage will be incorrectly blended.\n" ); 1581 SkDebugf("Partial pixel coverage will be incorrectly blended.\n" );
1588 } 1582 }
1589 #endif 1583 #endif
1590 } else { 1584 } else {
1591 ds->reset(*viewMatrix); 1585 ds->reset();
1592 ds->setRenderTarget(fRenderTarget.get()); 1586 ds->setRenderTarget(fRenderTarget.get());
1593 } 1587 }
1594 ds->setState(GrDrawState::kClip_StateBit, fClip && !fClip->fClipStack->i sWideOpen()); 1588 ds->setState(GrDrawState::kClip_StateBit, fClip && !fClip->fClipStack->i sWideOpen());
1595 } 1589 }
1596 fDrawBuffer->setClip(fClip); 1590 fDrawBuffer->setClip(fClip);
1597 return fDrawBuffer; 1591 return fDrawBuffer;
1598 } 1592 }
1599 1593
1600 /* 1594 /*
1601 * This method finds a path renderer that can draw the specified path on 1595 * This method finds a path renderer that can draw the specified path on
1602 * the provided target. 1596 * the provided target.
1603 * Due to its expense, the software path renderer has split out so it can 1597 * Due to its expense, the software path renderer has split out so it can
1604 * can be individually allowed/disallowed via the "allowSW" boolean. 1598 * can be individually allowed/disallowed via the "allowSW" boolean.
1605 */ 1599 */
1606 GrPathRenderer* GrContext::getPathRenderer(const GrDrawTarget* target, 1600 GrPathRenderer* GrContext::getPathRenderer(const GrDrawTarget* target,
1607 const GrDrawState* drawState, 1601 const GrDrawState* drawState,
1602 const SkMatrix& viewMatrix,
1608 const SkPath& path, 1603 const SkPath& path,
1609 const SkStrokeRec& stroke, 1604 const SkStrokeRec& stroke,
1610 bool allowSW, 1605 bool allowSW,
1611 GrPathRendererChain::DrawType drawTyp e, 1606 GrPathRendererChain::DrawType drawTyp e,
1612 GrPathRendererChain::StencilSupport* stencilSupport) { 1607 GrPathRendererChain::StencilSupport* stencilSupport) {
1613 1608
1614 if (NULL == fPathRendererChain) { 1609 if (NULL == fPathRendererChain) {
1615 fPathRendererChain = SkNEW_ARGS(GrPathRendererChain, (this)); 1610 fPathRendererChain = SkNEW_ARGS(GrPathRendererChain, (this));
1616 } 1611 }
1617 1612
1618 GrPathRenderer* pr = fPathRendererChain->getPathRenderer(target, 1613 GrPathRenderer* pr = fPathRendererChain->getPathRenderer(target,
1619 drawState, 1614 drawState,
1615 viewMatrix,
1620 path, 1616 path,
1621 stroke, 1617 stroke,
1622 drawType, 1618 drawType,
1623 stencilSupport); 1619 stencilSupport);
1624 1620
1625 if (NULL == pr && allowSW) { 1621 if (NULL == pr && allowSW) {
1626 if (NULL == fSoftwarePathRenderer) { 1622 if (NULL == fSoftwarePathRenderer) {
1627 fSoftwarePathRenderer = SkNEW_ARGS(GrSoftwarePathRenderer, (this)); 1623 fSoftwarePathRenderer = SkNEW_ARGS(GrSoftwarePathRenderer, (this));
1628 } 1624 }
1629 pr = fSoftwarePathRenderer; 1625 pr = fSoftwarePathRenderer;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1667 SkNEW_ARGS(GrIndexBufferAllocPool, (fGpu, false, 1663 SkNEW_ARGS(GrIndexBufferAllocPool, (fGpu, false,
1668 DRAW_BUFFER_IBPOOL_BUFFER_SIZE, 1664 DRAW_BUFFER_IBPOOL_BUFFER_SIZE,
1669 DRAW_BUFFER_IBPOOL_PREALLOC_BUFFERS)); 1665 DRAW_BUFFER_IBPOOL_PREALLOC_BUFFERS));
1670 1666
1671 fDrawBuffer = SkNEW_ARGS(GrInOrderDrawBuffer, (fGpu, 1667 fDrawBuffer = SkNEW_ARGS(GrInOrderDrawBuffer, (fGpu,
1672 fDrawBufferVBAllocPool, 1668 fDrawBufferVBAllocPool,
1673 fDrawBufferIBAllocPool)); 1669 fDrawBufferIBAllocPool));
1674 } 1670 }
1675 1671
1676 GrDrawTarget* GrContext::getTextTarget() { 1672 GrDrawTarget* GrContext::getTextTarget() {
1677 return this->prepareToDraw(NULL, NULL, NULL, NULL); 1673 return this->prepareToDraw(NULL, NULL, NULL);
1678 } 1674 }
1679 1675
1680 const GrIndexBuffer* GrContext::getQuadIndexBuffer() const { 1676 const GrIndexBuffer* GrContext::getQuadIndexBuffer() const {
1681 return fGpu->getQuadIndexBuffer(); 1677 return fGpu->getQuadIndexBuffer();
1682 } 1678 }
1683 1679
1684 namespace { 1680 namespace {
1685 void test_pm_conversions(GrContext* ctx, int* pmToUPMValue, int* upmToPMValue) { 1681 void test_pm_conversions(GrContext* ctx, int* pmToUPMValue, int* upmToPMValue) {
1686 GrConfigConversionEffect::PMConversion pmToUPM; 1682 GrConfigConversionEffect::PMConversion pmToUPM;
1687 GrConfigConversionEffect::PMConversion upmToPM; 1683 GrConfigConversionEffect::PMConversion upmToPM;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1751 fResourceCache2->printStats(); 1747 fResourceCache2->printStats();
1752 } 1748 }
1753 #endif 1749 #endif
1754 1750
1755 #if GR_GPU_STATS 1751 #if GR_GPU_STATS
1756 const GrContext::GPUStats* GrContext::gpuStats() const { 1752 const GrContext::GPUStats* GrContext::gpuStats() const {
1757 return fGpu->gpuStats(); 1753 return fGpu->gpuStats();
1758 } 1754 }
1759 #endif 1755 #endif
1760 1756
OLDNEW
« no previous file with comments | « src/gpu/GrClipMaskManager.cpp ('k') | src/gpu/GrDefaultGeoProcFactory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698