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

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

Issue 22824016: Fix for nested rect drawing bug (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Gussied up a bit Created 7 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 | Annotate | Revision Log
« no previous file with comments | « gyp/gmslides.gypi ('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 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 !target->getDrawState().getRenderTarget()->isMultisampled() && 1004 !target->getDrawState().getRenderTarget()->isMultisampled() &&
1005 !disable_coverage_aa_for_blend(target); 1005 !disable_coverage_aa_for_blend(target);
1006 1006
1007 if (!fOvalRenderer->drawOval(target, this, useAA, oval, stroke)) { 1007 if (!fOvalRenderer->drawOval(target, this, useAA, oval, stroke)) {
1008 SkPath path; 1008 SkPath path;
1009 path.addOval(oval); 1009 path.addOval(oval);
1010 this->internalDrawPath(target, useAA, path, stroke); 1010 this->internalDrawPath(target, useAA, path, stroke);
1011 } 1011 }
1012 } 1012 }
1013 1013
1014 namespace {
1015
1016 // Can 'path' be drawn as a pair of filled nested rectangles? 1014 // Can 'path' be drawn as a pair of filled nested rectangles?
1017 static bool is_nested_rects(GrDrawTarget* target, 1015 static bool is_nested_rects(GrDrawTarget* target,
1018 const SkPath& path, 1016 const SkPath& path,
1019 const SkStrokeRec& stroke, 1017 const SkStrokeRec& stroke,
1020 SkRect rects[2], 1018 SkRect rects[2],
1021 bool* useVertexCoverage) { 1019 bool* useVertexCoverage) {
1022 SkASSERT(stroke.isFillStyle()); 1020 SkASSERT(stroke.isFillStyle());
1023 1021
1024 if (path.isInverseFillType()) { 1022 if (path.isInverseFillType()) {
1025 return false; 1023 return false;
(...skipping 14 matching lines...) Expand all
1040 } else { 1038 } else {
1041 *useVertexCoverage = true; 1039 *useVertexCoverage = true;
1042 } 1040 }
1043 } 1041 }
1044 1042
1045 SkPath::Direction dirs[2]; 1043 SkPath::Direction dirs[2];
1046 if (!path.isNestedRects(rects, dirs)) { 1044 if (!path.isNestedRects(rects, dirs)) {
1047 return false; 1045 return false;
1048 } 1046 }
1049 1047
1050 if (SkPath::kWinding_FillType == path.getFillType()) { 1048 if (SkPath::kWinding_FillType == path.getFillType() && dirs[0] == dirs[1]) {
1051 // The two rects need to be wound opposite to each other 1049 // The two rects need to be wound opposite to each other
1052 return dirs[0] != dirs[1]; 1050 return false;
1053 } else {
1054 return true;
1055 } 1051 }
1052
1053 // Right now, nested rects where the margin is not the same width
1054 // all around do not render correctly
1055 const SkScalar* outer = rects[0].asScalars();
1056 const SkScalar* inner = rects[1].asScalars();
1057
1058 SkScalar margin = SkScalarAbs(outer[0] - inner[0]);
1059 for (int i = 1; i < 4; ++i) {
1060 SkScalar temp = SkScalarAbs(outer[i] - inner[i]);
1061 if (!SkScalarNearlyEqual(margin, temp)) {
1062 return false;
1063 }
1064 }
1065
1066 return true;
1056 } 1067 }
1057 1068
1058 };
1059
1060 void GrContext::drawPath(const GrPaint& paint, const SkPath& path, const SkStrok eRec& stroke) { 1069 void GrContext::drawPath(const GrPaint& paint, const SkPath& path, const SkStrok eRec& stroke) {
1061 1070
1062 if (path.isEmpty()) { 1071 if (path.isEmpty()) {
1063 if (path.isInverseFillType()) { 1072 if (path.isInverseFillType()) {
1064 this->drawPaint(paint); 1073 this->drawPaint(paint);
1065 } 1074 }
1066 return; 1075 return;
1067 } 1076 }
1068 1077
1069 // Note that internalDrawPath may sw-rasterize the path into a scratch textu re. 1078 // Note that internalDrawPath may sw-rasterize the path into a scratch textu re.
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
1734 return NULL; 1743 return NULL;
1735 } 1744 }
1736 } 1745 }
1737 1746
1738 /////////////////////////////////////////////////////////////////////////////// 1747 ///////////////////////////////////////////////////////////////////////////////
1739 #if GR_CACHE_STATS 1748 #if GR_CACHE_STATS
1740 void GrContext::printCacheStats() const { 1749 void GrContext::printCacheStats() const {
1741 fTextureCache->printStats(); 1750 fTextureCache->printStats();
1742 } 1751 }
1743 #endif 1752 #endif
OLDNEW
« no previous file with comments | « gyp/gmslides.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698