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

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

Issue 14820035: Re-add isIRect test for AA rect drawing (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« src/gpu/GrAARectRenderer.cpp ('K') | « src/gpu/GrClipMaskManager.cpp ('k') | no next file » | 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 9
10 #include "GrContext.h" 10 #include "GrContext.h"
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 verts[2].set(rect.fRight - rad, rect.fTop + rad); 673 verts[2].set(rect.fRight - rad, rect.fTop + rad);
674 verts[3].set(rect.fRight + rad, rect.fTop - rad); 674 verts[3].set(rect.fRight + rad, rect.fTop - rad);
675 verts[4].set(rect.fRight - rad, rect.fBottom - rad); 675 verts[4].set(rect.fRight - rad, rect.fBottom - rad);
676 verts[5].set(rect.fRight + rad, rect.fBottom + rad); 676 verts[5].set(rect.fRight + rad, rect.fBottom + rad);
677 verts[6].set(rect.fLeft + rad, rect.fBottom - rad); 677 verts[6].set(rect.fLeft + rad, rect.fBottom - rad);
678 verts[7].set(rect.fLeft - rad, rect.fBottom + rad); 678 verts[7].set(rect.fLeft - rad, rect.fBottom + rad);
679 verts[8] = verts[0]; 679 verts[8] = verts[0];
680 verts[9] = verts[1]; 680 verts[9] = verts[1];
681 } 681 }
682 682
683 static bool isIRect(const GrRect& r) {
684 return SkScalarIsInt(r.fLeft) && SkScalarIsInt(r.fTop) &&
685 SkScalarIsInt(r.fRight) && SkScalarIsInt(r.fBottom);
686 }
687
683 static bool apply_aa_to_rect(GrDrawTarget* target, 688 static bool apply_aa_to_rect(GrDrawTarget* target,
684 const GrRect& rect, 689 const GrRect& rect,
685 SkScalar strokeWidth, 690 SkScalar strokeWidth,
686 const SkMatrix* matrix, 691 const SkMatrix* matrix,
687 SkMatrix* combinedMatrix, 692 SkMatrix* combinedMatrix,
693 GrRect* devRect,
688 bool* useVertexCoverage) { 694 bool* useVertexCoverage) {
689 // we use a simple coverage ramp to do aa on axis-aligned rects 695 // we use a simple coverage ramp to do aa on axis-aligned rects
690 // we check if the rect will be axis-aligned, and the rect won't land on 696 // we check if the rect will be axis-aligned, and the rect won't land on
691 // integer coords. 697 // integer coords.
692 698
693 // we are keeping around the "tweak the alpha" trick because 699 // we are keeping around the "tweak the alpha" trick because
694 // it is our only hope for the fixed-pipe implementation. 700 // it is our only hope for the fixed-pipe implementation.
695 // In a shader implementation we can give a separate coverage input 701 // In a shader implementation we can give a separate coverage input
696 // TODO: remove this ugliness when we drop the fixed-pipe impl 702 // TODO: remove this ugliness when we drop the fixed-pipe impl
697 *useVertexCoverage = false; 703 *useVertexCoverage = false;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 #endif 753 #endif
748 GrAssert(combinedMatrix->preservesAxisAlignment()); 754 GrAssert(combinedMatrix->preservesAxisAlignment());
749 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) 755 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT)
750 } else { 756 } else {
751 GrAssert(combinedMatrix->preservesRightAngles()); 757 GrAssert(combinedMatrix->preservesRightAngles());
752 } 758 }
753 #endif 759 #endif
754 #endif 760 #endif
755 } 761 }
756 762
757 if (0 == rect.width() || 0 == rect.height()) { 763 combinedMatrix->mapRect(devRect, rect);
758 return false; 764
765 if (strokeWidth < 0) {
766 return !isIRect(*devRect);
767 } else {
768 return true;
759 } 769 }
760
761 return true;
762 } 770 }
763 771
764 void GrContext::drawRect(const GrPaint& paint, 772 void GrContext::drawRect(const GrPaint& paint,
765 const GrRect& rect, 773 const GrRect& rect,
766 SkScalar width, 774 SkScalar width,
767 const SkMatrix* matrix) { 775 const SkMatrix* matrix) {
768 SK_TRACE_EVENT0("GrContext::drawRect"); 776 SK_TRACE_EVENT0("GrContext::drawRect");
769 777
770 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW); 778 GrDrawTarget* target = this->prepareToDraw(&paint, BUFFERED_DRAW);
771 GrDrawState::AutoStageDisable atr(fDrawState); 779 GrDrawState::AutoStageDisable atr(fDrawState);
772 780
781 GrRect devRect;
773 SkMatrix combinedMatrix; 782 SkMatrix combinedMatrix;
774 bool useVertexCoverage; 783 bool useVertexCoverage;
775 bool needAA = paint.isAntiAlias() && 784 bool needAA = paint.isAntiAlias() &&
776 !this->getRenderTarget()->isMultisampled(); 785 !this->getRenderTarget()->isMultisampled();
777 bool doAA = needAA && apply_aa_to_rect(target, rect, width, matrix, 786 bool doAA = needAA && apply_aa_to_rect(target, rect, width, matrix,
778 &combinedMatrix, 787 &combinedMatrix, &devRect,
779 &useVertexCoverage); 788 &useVertexCoverage);
780 if (doAA) { 789 if (doAA) {
781 GrDrawState::AutoDeviceCoordDraw adcd(target->drawState()); 790 GrDrawState::AutoDeviceCoordDraw adcd(target->drawState());
782 if (!adcd.succeeded()) { 791 if (!adcd.succeeded()) {
783 return; 792 return;
784 } 793 }
785 if (width >= 0) { 794 if (width >= 0) {
786 GrVec strokeSize; 795 GrVec strokeSize;
787 if (width > 0) { 796 if (width > 0) {
788 strokeSize.set(width, width); 797 strokeSize.set(width, width);
789 combinedMatrix.mapVectors(&strokeSize, 1); 798 combinedMatrix.mapVectors(&strokeSize, 1);
790 strokeSize.setAbs(strokeSize); 799 strokeSize.setAbs(strokeSize);
791 } else { 800 } else {
792 strokeSize.set(SK_Scalar1, SK_Scalar1); 801 strokeSize.set(SK_Scalar1, SK_Scalar1);
793 } 802 }
794 fAARectRenderer->strokeAARect(this->getGpu(), target, 803 fAARectRenderer->strokeAARect(this->getGpu(), target,
795 rect, combinedMatrix, 804 rect, combinedMatrix, devRect,
796 strokeSize, useVertexCoverage); 805 strokeSize, useVertexCoverage);
797 } else { 806 } else {
798 // filled AA rect 807 // filled AA rect
799 fAARectRenderer->fillAARect(this->getGpu(), target, 808 fAARectRenderer->fillAARect(this->getGpu(), target,
800 rect, combinedMatrix, 809 rect, combinedMatrix, devRect,
801 useVertexCoverage); 810 useVertexCoverage);
802 } 811 }
803 return; 812 return;
804 } 813 }
805 814
806 if (width >= 0) { 815 if (width >= 0) {
807 // TODO: consider making static vertex buffers for these cases. 816 // TODO: consider making static vertex buffers for these cases.
808 // Hairline could be done by just adding closing vertex to 817 // Hairline could be done by just adding closing vertex to
809 // unitSquareVertexBuffer() 818 // unitSquareVertexBuffer()
810 819
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
1791 return srcTexture; 1800 return srcTexture;
1792 } 1801 }
1793 } 1802 }
1794 1803
1795 /////////////////////////////////////////////////////////////////////////////// 1804 ///////////////////////////////////////////////////////////////////////////////
1796 #if GR_CACHE_STATS 1805 #if GR_CACHE_STATS
1797 void GrContext::printCacheStats() const { 1806 void GrContext::printCacheStats() const {
1798 fTextureCache->printStats(); 1807 fTextureCache->printStats();
1799 } 1808 }
1800 #endif 1809 #endif
OLDNEW
« src/gpu/GrAARectRenderer.cpp ('K') | « src/gpu/GrClipMaskManager.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698