OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 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 "GrAARectRenderer.h" | |
10 #include "GrAtlasTextContext.h" | 9 #include "GrAtlasTextContext.h" |
11 #include "GrBatchTest.h" | 10 #include "GrBatchTest.h" |
12 #include "GrColor.h" | 11 #include "GrColor.h" |
13 #include "GrDrawContext.h" | 12 #include "GrDrawContext.h" |
14 #include "GrOvalRenderer.h" | 13 #include "GrOvalRenderer.h" |
15 #include "GrPathRenderer.h" | 14 #include "GrPathRenderer.h" |
16 #include "GrRenderTarget.h" | 15 #include "GrRenderTarget.h" |
17 #include "GrRenderTargetPriv.h" | 16 #include "GrRenderTargetPriv.h" |
18 #include "GrStencilAndCoverTextContext.h" | 17 #include "GrStencilAndCoverTextContext.h" |
19 | 18 |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 } | 300 } |
302 | 301 |
303 GrColor color = paint.getColor(); | 302 GrColor color = paint.getColor(); |
304 SkRect devBoundRect; | 303 SkRect devBoundRect; |
305 bool needAA = paint.isAntiAlias() && | 304 bool needAA = paint.isAntiAlias() && |
306 !pipelineBuilder.getRenderTarget()->isUnifiedMultisampled(); | 305 !pipelineBuilder.getRenderTarget()->isUnifiedMultisampled(); |
307 bool doAA = needAA && apply_aa_to_rect(fDrawTarget, &pipelineBuilder, &devBo
undRect, rect, | 306 bool doAA = needAA && apply_aa_to_rect(fDrawTarget, &pipelineBuilder, &devBo
undRect, rect, |
308 width, viewMatrix, color); | 307 width, viewMatrix, color); |
309 | 308 |
310 if (doAA) { | 309 if (doAA) { |
| 310 SkAutoTUnref<GrBatch> batch; |
311 if (width >= 0) { | 311 if (width >= 0) { |
312 GrAARectRenderer::StrokeAARect(fDrawTarget, | 312 batch.reset(GrRectBatchFactory::CreateStrokeAA(color, viewMatrix, re
ct, devBoundRect, |
313 pipelineBuilder, | 313 *strokeInfo)); |
314 color, | |
315 viewMatrix, | |
316 rect, | |
317 devBoundRect, | |
318 *strokeInfo); | |
319 } else { | 314 } else { |
320 // filled AA rect | 315 batch.reset(GrRectBatchFactory::CreateFillAA(color, viewMatrix, rect
, devBoundRect)); |
321 GrAARectRenderer::FillAARect(fDrawTarget, | |
322 pipelineBuilder, | |
323 color, | |
324 viewMatrix, | |
325 rect, | |
326 devBoundRect); | |
327 } | 316 } |
| 317 fDrawTarget->drawBatch(pipelineBuilder, batch); |
328 return; | 318 return; |
329 } | 319 } |
330 | 320 |
331 if (width >= 0) { | 321 if (width >= 0) { |
332 // Non-AA hairlines are snapped to pixel centers to make which pixels ar
e hit deterministic | 322 // Non-AA hairlines are snapped to pixel centers to make which pixels ar
e hit deterministic |
333 bool snapToPixelCenters = (0 == width && !rt->isUnifiedMultisampled()); | 323 bool snapToPixelCenters = (0 == width && !rt->isUnifiedMultisampled()); |
334 SkAutoTUnref<GrBatch> batch(GrRectBatchFactory::CreateStrokeBW(color, vi
ewMatrix, rect, | 324 SkAutoTUnref<GrBatch> batch(GrRectBatchFactory::CreateStrokeBW(color, vi
ewMatrix, rect, |
335 width, sn
apToPixelCenters)); | 325 width, sn
apToPixelCenters)); |
336 | 326 |
337 // Depending on sub-pixel coordinates and the particular GPU, we may los
e a corner of | 327 // Depending on sub-pixel coordinates and the particular GPU, we may los
e a corner of |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 GrPipelineBuilder pipelineBuilder(paint, rt, clip); | 685 GrPipelineBuilder pipelineBuilder(paint, rt, clip); |
696 if (!strokeInfo.isDashed()) { | 686 if (!strokeInfo.isDashed()) { |
697 bool useCoverageAA = paint.isAntiAlias() && | 687 bool useCoverageAA = paint.isAntiAlias() && |
698 !pipelineBuilder.getRenderTarget()->isUnifiedMultisampled(); | 688 !pipelineBuilder.getRenderTarget()->isUnifiedMultisampled(); |
699 | 689 |
700 if (useCoverageAA && strokeInfo.getWidth() < 0 && !path.isConvex()) { | 690 if (useCoverageAA && strokeInfo.getWidth() < 0 && !path.isConvex()) { |
701 // Concave AA paths are expensive - try to avoid them for special ca
ses | 691 // Concave AA paths are expensive - try to avoid them for special ca
ses |
702 SkRect rects[2]; | 692 SkRect rects[2]; |
703 | 693 |
704 if (is_nested_rects(viewMatrix, path, strokeInfo, rects)) { | 694 if (is_nested_rects(viewMatrix, path, strokeInfo, rects)) { |
705 GrAARectRenderer::FillAANestedRects(fDrawTarget, pipelineBuilder
, color, | 695 SkAutoTUnref<GrBatch> batch(GrRectBatchFactory::CreateFillNested
RectsAA(color, |
706 viewMatrix, rects); | 696
viewMatrix, |
| 697
rects)); |
| 698 fDrawTarget->drawBatch(pipelineBuilder, batch); |
707 return; | 699 return; |
708 } | 700 } |
709 } | 701 } |
710 SkRect ovalRect; | 702 SkRect ovalRect; |
711 bool isOval = path.isOval(&ovalRect); | 703 bool isOval = path.isOval(&ovalRect); |
712 | 704 |
713 if (isOval && !path.isInverseFillType()) { | 705 if (isOval && !path.isInverseFillType()) { |
714 if (GrOvalRenderer::DrawOval(fDrawTarget, | 706 if (GrOvalRenderer::DrawOval(fDrawTarget, |
715 pipelineBuilder, | 707 pipelineBuilder, |
716 color, | 708 color, |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 RETURN_FALSE_IF_ABANDONED | 811 RETURN_FALSE_IF_ABANDONED |
820 | 812 |
821 ASSERT_OWNED_RESOURCE(rt); | 813 ASSERT_OWNED_RESOURCE(rt); |
822 SkASSERT(rt); | 814 SkASSERT(rt); |
823 return true; | 815 return true; |
824 } | 816 } |
825 | 817 |
826 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrBatch* batch
) { | 818 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrBatch* batch
) { |
827 fDrawTarget->drawBatch(*pipelineBuilder, batch); | 819 fDrawTarget->drawBatch(*pipelineBuilder, batch); |
828 } | 820 } |
OLD | NEW |