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

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

Issue 466873002: Use combined color/coverage attribute when possible in aa rect renderer. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 4 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/GrAARectRenderer.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 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 verts[2].set(rect.fRight - rad, rect.fTop + rad); 719 verts[2].set(rect.fRight - rad, rect.fTop + rad);
720 verts[3].set(rect.fRight + rad, rect.fTop - rad); 720 verts[3].set(rect.fRight + rad, rect.fTop - rad);
721 verts[4].set(rect.fRight - rad, rect.fBottom - rad); 721 verts[4].set(rect.fRight - rad, rect.fBottom - rad);
722 verts[5].set(rect.fRight + rad, rect.fBottom + rad); 722 verts[5].set(rect.fRight + rad, rect.fBottom + rad);
723 verts[6].set(rect.fLeft + rad, rect.fBottom - rad); 723 verts[6].set(rect.fLeft + rad, rect.fBottom - rad);
724 verts[7].set(rect.fLeft - rad, rect.fBottom + rad); 724 verts[7].set(rect.fLeft - rad, rect.fBottom + rad);
725 verts[8] = verts[0]; 725 verts[8] = verts[0];
726 verts[9] = verts[1]; 726 verts[9] = verts[1];
727 } 727 }
728 728
729 static inline bool is_irect(const SkRect& r) {
730 return SkScalarIsInt(r.fLeft) && SkScalarIsInt(r.fTop) &&
731 SkScalarIsInt(r.fRight) && SkScalarIsInt(r.fBottom);
732 }
733
729 static bool apply_aa_to_rect(GrDrawTarget* target, 734 static bool apply_aa_to_rect(GrDrawTarget* target,
730 const SkRect& rect, 735 const SkRect& rect,
731 SkScalar strokeWidth, 736 SkScalar strokeWidth,
732 const SkMatrix& combinedMatrix, 737 const SkMatrix& combinedMatrix,
733 SkRect* devBoundRect) { 738 SkRect* devBoundRect) {
734 if (!target->getDrawState().canTweakAlphaForCoverage() && 739 if (!target->getDrawState().canTweakAlphaForCoverage() &&
735 target->shouldDisableCoverageAAForBlend()) { 740 target->shouldDisableCoverageAAForBlend()) {
736 #ifdef SK_DEBUG 741 #ifdef SK_DEBUG
737 //GrPrintf("Turning off AA to correctly apply blend.\n"); 742 //GrPrintf("Turning off AA to correctly apply blend.\n");
738 #endif 743 #endif
(...skipping 13 matching lines...) Expand all
752 757
753 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT) 758 #if defined(SHADER_AA_FILL_RECT) || !defined(IGNORE_ROT_AA_RECT_OPT)
754 } else { 759 } else {
755 if (!combinedMatrix.preservesRightAngles()) { 760 if (!combinedMatrix.preservesRightAngles()) {
756 return false; 761 return false;
757 } 762 }
758 } 763 }
759 #endif 764 #endif
760 765
761 combinedMatrix.mapRect(devBoundRect, rect); 766 combinedMatrix.mapRect(devBoundRect, rect);
767 if (strokeWidth < 0) {
768 return !is_irect(*devBoundRect);
769 }
762 770
763 return true; 771 return true;
764 } 772 }
765 773
766 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po int) { 774 static inline bool rect_contains_inclusive(const SkRect& rect, const SkPoint& po int) {
767 return point.fX >= rect.fLeft && point.fX <= rect.fRight && 775 return point.fX >= rect.fLeft && point.fX <= rect.fRight &&
768 point.fY >= rect.fTop && point.fY <= rect.fBottom; 776 point.fY >= rect.fTop && point.fY <= rect.fBottom;
769 } 777 }
770 778
771 void GrContext::drawRect(const GrPaint& paint, 779 void GrContext::drawRect(const GrPaint& paint,
(...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 fDrawBuffer->removeGpuTraceMarker(marker); 1931 fDrawBuffer->removeGpuTraceMarker(marker);
1924 } 1932 }
1925 } 1933 }
1926 1934
1927 /////////////////////////////////////////////////////////////////////////////// 1935 ///////////////////////////////////////////////////////////////////////////////
1928 #if GR_CACHE_STATS 1936 #if GR_CACHE_STATS
1929 void GrContext::printCacheStats() const { 1937 void GrContext::printCacheStats() const {
1930 fResourceCache->printStats(); 1938 fResourceCache->printStats();
1931 } 1939 }
1932 #endif 1940 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrAARectRenderer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698