| 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 #include "GrVertexBuffer.h" | 12 #include "GrVertexBuffer.h" |
| 13 #include "batches/GrRectBatchFactory.h" |
| 13 | 14 |
| 14 //////////////////////////////////////////////////////////////////////////////// | 15 //////////////////////////////////////////////////////////////////////////////// |
| 15 bool GrSoftwarePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { | 16 bool GrSoftwarePathRenderer::onCanDrawPath(const CanDrawPathArgs& args) const { |
| 16 if (nullptr == fContext) { | 17 if (nullptr == fContext) { |
| 17 return false; | 18 return false; |
| 18 } | 19 } |
| 19 if (args.fStroke->isDashed()) { | 20 if (args.fStroke->isDashed()) { |
| 20 return false; | 21 return false; |
| 21 } | 22 } |
| 22 return true; | 23 return true; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 return false; | 59 return false; |
| 59 } | 60 } |
| 60 } else { | 61 } else { |
| 61 *devPathBounds = SkIRect::EmptyIRect(); | 62 *devPathBounds = SkIRect::EmptyIRect(); |
| 62 return false; | 63 return false; |
| 63 } | 64 } |
| 64 return true; | 65 return true; |
| 65 } | 66 } |
| 66 | 67 |
| 67 //////////////////////////////////////////////////////////////////////////////// | 68 //////////////////////////////////////////////////////////////////////////////// |
| 69 static void draw_non_aa_rect(GrDrawTarget* drawTarget, |
| 70 const GrPipelineBuilder& pipelineBuilder, |
| 71 GrColor color, |
| 72 const SkMatrix& viewMatrix, |
| 73 const SkRect& rect, |
| 74 const SkMatrix& localMatrix) { |
| 75 SkAutoTUnref<GrDrawBatch> batch(GrRectBatchFactory::CreateNonAAFill(color, v
iewMatrix, rect, |
| 76 nullptr,
&localMatrix)); |
| 77 drawTarget->drawBatch(pipelineBuilder, batch); |
| 78 } |
| 79 |
| 68 void draw_around_inv_path(GrDrawTarget* target, | 80 void draw_around_inv_path(GrDrawTarget* target, |
| 69 GrPipelineBuilder* pipelineBuilder, | 81 GrPipelineBuilder* pipelineBuilder, |
| 70 GrColor color, | 82 GrColor color, |
| 71 const SkMatrix& viewMatrix, | 83 const SkMatrix& viewMatrix, |
| 72 const SkIRect& devClipBounds, | 84 const SkIRect& devClipBounds, |
| 73 const SkIRect& devPathBounds) { | 85 const SkIRect& devPathBounds) { |
| 74 SkMatrix invert; | 86 SkMatrix invert; |
| 75 if (!viewMatrix.invert(&invert)) { | 87 if (!viewMatrix.invert(&invert)) { |
| 76 return; | 88 return; |
| 77 } | 89 } |
| 78 | 90 |
| 79 SkRect rect; | 91 SkRect rect; |
| 80 if (devClipBounds.fTop < devPathBounds.fTop) { | 92 if (devClipBounds.fTop < devPathBounds.fTop) { |
| 81 rect.iset(devClipBounds.fLeft, devClipBounds.fTop, | 93 rect.iset(devClipBounds.fLeft, devClipBounds.fTop, |
| 82 devClipBounds.fRight, devPathBounds.fTop); | 94 devClipBounds.fRight, devPathBounds.fTop); |
| 83 target->drawNonAARect(*pipelineBuilder, color, SkMatrix::I(), rect, inve
rt); | 95 draw_non_aa_rect(target, *pipelineBuilder, color, SkMatrix::I(), rect, i
nvert); |
| 84 } | 96 } |
| 85 if (devClipBounds.fLeft < devPathBounds.fLeft) { | 97 if (devClipBounds.fLeft < devPathBounds.fLeft) { |
| 86 rect.iset(devClipBounds.fLeft, devPathBounds.fTop, | 98 rect.iset(devClipBounds.fLeft, devPathBounds.fTop, |
| 87 devPathBounds.fLeft, devPathBounds.fBottom); | 99 devPathBounds.fLeft, devPathBounds.fBottom); |
| 88 target->drawNonAARect(*pipelineBuilder, color, SkMatrix::I(), rect, inve
rt); | 100 draw_non_aa_rect(target, *pipelineBuilder, color, SkMatrix::I(), rect, i
nvert); |
| 89 } | 101 } |
| 90 if (devClipBounds.fRight > devPathBounds.fRight) { | 102 if (devClipBounds.fRight > devPathBounds.fRight) { |
| 91 rect.iset(devPathBounds.fRight, devPathBounds.fTop, | 103 rect.iset(devPathBounds.fRight, devPathBounds.fTop, |
| 92 devClipBounds.fRight, devPathBounds.fBottom); | 104 devClipBounds.fRight, devPathBounds.fBottom); |
| 93 target->drawNonAARect(*pipelineBuilder, color, SkMatrix::I(), rect, inve
rt); | 105 draw_non_aa_rect(target, *pipelineBuilder, color, SkMatrix::I(), rect, i
nvert); |
| 94 } | 106 } |
| 95 if (devClipBounds.fBottom > devPathBounds.fBottom) { | 107 if (devClipBounds.fBottom > devPathBounds.fBottom) { |
| 96 rect.iset(devClipBounds.fLeft, devPathBounds.fBottom, | 108 rect.iset(devClipBounds.fLeft, devPathBounds.fBottom, |
| 97 devClipBounds.fRight, devClipBounds.fBottom); | 109 devClipBounds.fRight, devClipBounds.fBottom); |
| 98 target->drawNonAARect(*pipelineBuilder, color, SkMatrix::I(), rect, inve
rt); | 110 draw_non_aa_rect(target, *pipelineBuilder, color, SkMatrix::I(), rect, i
nvert); |
| 99 } | 111 } |
| 100 } | 112 } |
| 101 | 113 |
| 102 } | 114 } |
| 103 | 115 |
| 104 //////////////////////////////////////////////////////////////////////////////// | 116 //////////////////////////////////////////////////////////////////////////////// |
| 105 // return true on success; false on failure | 117 // return true on success; false on failure |
| 106 bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) { | 118 bool GrSoftwarePathRenderer::onDrawPath(const DrawPathArgs& args) { |
| 107 if (nullptr == fContext) { | 119 if (nullptr == fContext) { |
| 108 return false; | 120 return false; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 129 GrSWMaskHelper::DrawToTargetWithPathMask(texture, args.fTarget, args.fPipeli
neBuilder, | 141 GrSWMaskHelper::DrawToTargetWithPathMask(texture, args.fTarget, args.fPipeli
neBuilder, |
| 130 args.fColor, *args.fViewMatrix, dev
PathBounds); | 142 args.fColor, *args.fViewMatrix, dev
PathBounds); |
| 131 | 143 |
| 132 if (args.fPath->isInverseFillType()) { | 144 if (args.fPath->isInverseFillType()) { |
| 133 draw_around_inv_path(args.fTarget, args.fPipelineBuilder, args.fColor, *
args.fViewMatrix, | 145 draw_around_inv_path(args.fTarget, args.fPipelineBuilder, args.fColor, *
args.fViewMatrix, |
| 134 devClipBounds, devPathBounds); | 146 devClipBounds, devPathBounds); |
| 135 } | 147 } |
| 136 | 148 |
| 137 return true; | 149 return true; |
| 138 } | 150 } |
| OLD | NEW |