diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-08-20 12:11:31 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-08-20 12:11:31 +0000 |
commit | 8d3c640b5aa96d6316a3e52975602b35e1a66ac7 (patch) | |
tree | df3a845fdf4653c2023d17f99f6d2a6b1dfdb039 /src | |
parent | d7ca66176fb2397b1120e945e38f8ac0fb2d0508 (diff) |
Fix for nested rect drawing bug
https://codereview.chromium.org/22824016/
git-svn-id: http://skia.googlecode.com/svn/trunk@10804 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrContext.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index b35b356b59..4bd8098218 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -1011,8 +1011,6 @@ void GrContext::drawOval(const GrPaint& paint, } } -namespace { - // Can 'path' be drawn as a pair of filled nested rectangles? static bool is_nested_rects(GrDrawTarget* target, const SkPath& path, @@ -1047,15 +1045,26 @@ static bool is_nested_rects(GrDrawTarget* target, return false; } - if (SkPath::kWinding_FillType == path.getFillType()) { + if (SkPath::kWinding_FillType == path.getFillType() && dirs[0] == dirs[1]) { // The two rects need to be wound opposite to each other - return dirs[0] != dirs[1]; - } else { - return true; + return false; } -} -}; + // Right now, nested rects where the margin is not the same width + // all around do not render correctly + const SkScalar* outer = rects[0].asScalars(); + const SkScalar* inner = rects[1].asScalars(); + + SkScalar margin = SkScalarAbs(outer[0] - inner[0]); + for (int i = 1; i < 4; ++i) { + SkScalar temp = SkScalarAbs(outer[i] - inner[i]); + if (!SkScalarNearlyEqual(margin, temp)) { + return false; + } + } + + return true; +} void GrContext::drawPath(const GrPaint& paint, const SkPath& path, const SkStrokeRec& stroke) { |