| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 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 "GrSoftwarePathRenderer.h" | 9 #include "GrSoftwarePathRenderer.h" |
| 10 #include "GrContext.h" | 10 #include "GrContext.h" |
| 11 #include "GrSWMaskHelper.h" | 11 #include "GrSWMaskHelper.h" |
| 12 | 12 |
| 13 //////////////////////////////////////////////////////////////////////////////// | 13 //////////////////////////////////////////////////////////////////////////////// |
| 14 bool GrSoftwarePathRenderer::canDrawPath(const SkPath&, | 14 bool GrSoftwarePathRenderer::canDrawPath(const SkStrokeRec&, |
| 15 const SkStrokeRec&, | |
| 16 const GrDrawTarget*, | 15 const GrDrawTarget*, |
| 17 bool antiAlias) const { | 16 bool antiAlias) const { |
| 18 if (!antiAlias || NULL == fContext) { | 17 if (!antiAlias || NULL == fContext) { |
| 19 // TODO: We could allow the SW path to also handle non-AA paths but | 18 // TODO: We could allow the SW path to also handle non-AA paths but |
| 20 // this would mean that GrDefaultPathRenderer would never be called | 19 // this would mean that GrDefaultPathRenderer would never be called |
| 21 // (since it appears after the SW renderer in the path renderer | 20 // (since it appears after the SW renderer in the path renderer |
| 22 // chain). Some testing would need to be done r.e. performance | 21 // chain). Some testing would need to be done r.e. performance |
| 23 // and consistency of the resulting images before removing | 22 // and consistency of the resulting images before removing |
| 24 // the "!antiAlias" clause from the above test | 23 // the "!antiAlias" clause from the above test |
| 25 return false; | 24 return false; |
| 26 } | 25 } |
| 27 | 26 |
| 28 return true; | 27 return true; |
| 29 } | 28 } |
| 30 | 29 |
| 31 GrPathRenderer::StencilSupport GrSoftwarePathRenderer::onGetStencilSupport( | 30 GrPathRenderer::StencilSupport GrSoftwarePathRenderer::onGetStencilSupport( |
| 32 const SkPath&, | |
| 33 const SkStrokeRec&, | 31 const SkStrokeRec&, |
| 34 const GrDrawTarget*) const { | 32 const GrDrawTarget*) const { |
| 35 return GrPathRenderer::kNoSupport_StencilSupport; | 33 return GrPathRenderer::kNoSupport_StencilSupport; |
| 36 } | 34 } |
| 37 | 35 |
| 38 namespace { | 36 namespace { |
| 39 | 37 |
| 40 //////////////////////////////////////////////////////////////////////////////// | 38 //////////////////////////////////////////////////////////////////////////////// |
| 41 // gets device coord bounds of path (not considering the fill) and clip. The | 39 // gets device coord bounds of path (not considering the fill) and clip. The |
| 42 // path bounds will be a subset of the clip bounds. returns false if | 40 // path bounds will be a subset of the clip bounds. returns false if |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 rect.iset(devClipBounds.fLeft, devPathBounds.fBottom, | 104 rect.iset(devClipBounds.fLeft, devPathBounds.fBottom, |
| 107 devClipBounds.fRight, devClipBounds.fBottom); | 105 devClipBounds.fRight, devClipBounds.fBottom); |
| 108 target->drawSimpleRect(rect, NULL); | 106 target->drawSimpleRect(rect, NULL); |
| 109 } | 107 } |
| 110 } | 108 } |
| 111 | 109 |
| 112 } | 110 } |
| 113 | 111 |
| 114 //////////////////////////////////////////////////////////////////////////////// | 112 //////////////////////////////////////////////////////////////////////////////// |
| 115 // return true on success; false on failure | 113 // return true on success; false on failure |
| 116 bool GrSoftwarePathRenderer::onDrawPath(const SkPath& path, | 114 bool GrSoftwarePathRenderer::onDrawPath(const SkStrokeRec& stroke, |
| 117 const SkStrokeRec& stroke, | |
| 118 GrDrawTarget* target, | 115 GrDrawTarget* target, |
| 119 bool antiAlias) { | 116 bool antiAlias) { |
| 120 | 117 |
| 121 if (NULL == fContext) { | 118 if (NULL == fContext) { |
| 122 return false; | 119 return false; |
| 123 } | 120 } |
| 124 | 121 |
| 125 GrDrawState* drawState = target->drawState(); | 122 GrDrawState* drawState = target->drawState(); |
| 126 | 123 |
| 127 SkMatrix vm = drawState->getViewMatrix(); | 124 SkMatrix vm = drawState->getViewMatrix(); |
| 128 | 125 |
| 129 SkIRect devPathBounds, devClipBounds; | 126 SkIRect devPathBounds, devClipBounds; |
| 130 if (!get_path_and_clip_bounds(target, path, vm, | 127 if (!get_path_and_clip_bounds(target, this->path(), vm, |
| 131 &devPathBounds, &devClipBounds)) { | 128 &devPathBounds, &devClipBounds)) { |
| 132 if (path.isInverseFillType()) { | 129 if (this->path().isInverseFillType()) { |
| 133 draw_around_inv_path(target, devClipBounds, devPathBounds); | 130 draw_around_inv_path(target, devClipBounds, devPathBounds); |
| 134 } | 131 } |
| 135 return true; | 132 return true; |
| 136 } | 133 } |
| 137 | 134 |
| 138 SkAutoTUnref<GrTexture> texture( | 135 SkAutoTUnref<GrTexture> texture( |
| 139 GrSWMaskHelper::DrawPathMaskToTexture(fContext, path, stroke, | 136 GrSWMaskHelper::DrawPathMaskToTexture(fContext, this->path(), stroke
, |
| 140 devPathBounds, | 137 devPathBounds, |
| 141 antiAlias, &vm)); | 138 antiAlias, &vm)); |
| 142 if (NULL == texture) { | 139 if (NULL == texture) { |
| 143 return false; | 140 return false; |
| 144 } | 141 } |
| 145 | 142 |
| 146 GrSWMaskHelper::DrawToTargetWithPathMask(texture, target, devPathBounds); | 143 GrSWMaskHelper::DrawToTargetWithPathMask(texture, target, devPathBounds); |
| 147 | 144 |
| 148 if (path.isInverseFillType()) { | 145 if (this->path().isInverseFillType()) { |
| 149 draw_around_inv_path(target, devClipBounds, devPathBounds); | 146 draw_around_inv_path(target, devClipBounds, devPathBounds); |
| 150 } | 147 } |
| 151 | 148 |
| 152 return true; | 149 return true; |
| 153 } | 150 } |
| OLD | NEW |