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 "GrAtlasTextContext.h" | 9 #include "GrAtlasTextContext.h" |
10 #include "GrBatchTest.h" | 10 #include "GrBatchTest.h" |
11 #include "GrColor.h" | 11 #include "GrColor.h" |
12 #include "GrDrawContext.h" | 12 #include "GrDrawContext.h" |
13 #include "GrDrawingManager.h" | 13 #include "GrDrawingManager.h" |
14 #include "GrOvalRenderer.h" | 14 #include "GrOvalRenderer.h" |
15 #include "GrPathRenderer.h" | 15 #include "GrPathRenderer.h" |
16 #include "GrRenderTarget.h" | 16 #include "GrRenderTarget.h" |
17 #include "GrRenderTargetPriv.h" | 17 #include "GrRenderTargetPriv.h" |
18 #include "GrResourceProvider.h" | 18 #include "GrResourceProvider.h" |
19 #include "GrStencilAndCoverTextContext.h" | 19 #include "GrStencilAndCoverTextContext.h" |
20 #include "SkSurfacePriv.h" | 20 #include "SkSurfacePriv.h" |
21 | 21 |
22 #include "batches/GrBatch.h" | 22 #include "batches/GrBatch.h" |
23 #include "batches/GrDrawAtlasBatch.h" | 23 #include "batches/GrDrawAtlasBatch.h" |
24 #include "batches/GrDrawVerticesBatch.h" | 24 #include "batches/GrDrawVerticesBatch.h" |
25 #include "batches/GrRectBatchFactory.h" | 25 #include "batches/GrRectBatchFactory.h" |
| 26 #include "batches/GrNinePatch.h" // TODO Factory |
26 | 27 |
27 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fDrawingM
anager->getContext()) | 28 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fDrawingM
anager->getContext()) |
28 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; } | 29 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; } |
29 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fa
lse; } | 30 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fa
lse; } |
30 #define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return nu
llptr; } | 31 #define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return nu
llptr; } |
31 | 32 |
32 class AutoCheckFlush { | 33 class AutoCheckFlush { |
33 public: | 34 public: |
34 AutoCheckFlush(GrDrawingManager* drawingManager) : fDrawingManager(drawingMa
nager) { | 35 AutoCheckFlush(GrDrawingManager* drawingManager) : fDrawingManager(drawingMa
nager) { |
35 SkASSERT(fDrawingManager); | 36 SkASSERT(fDrawingManager); |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 oval, | 562 oval, |
562 strokeInfo)) { | 563 strokeInfo)) { |
563 SkPath path; | 564 SkPath path; |
564 path.setIsVolatile(true); | 565 path.setIsVolatile(true); |
565 path.addOval(oval); | 566 path.addOval(oval); |
566 this->internalDrawPath(&pipelineBuilder, viewMatrix, color, | 567 this->internalDrawPath(&pipelineBuilder, viewMatrix, color, |
567 paint.isAntiAlias(), path, strokeInfo); | 568 paint.isAntiAlias(), path, strokeInfo); |
568 } | 569 } |
569 } | 570 } |
570 | 571 |
| 572 void GrDrawContext::drawImageNine(const GrClip& clip, |
| 573 const GrPaint& paint, |
| 574 const SkMatrix& viewMatrix, |
| 575 int imageWidth, |
| 576 int imageHeight, |
| 577 const SkIRect& center, |
| 578 const SkRect& dst) { |
| 579 RETURN_IF_ABANDONED |
| 580 SkDEBUGCODE(this->validate();) |
| 581 |
| 582 AutoCheckFlush acf(fDrawingManager); |
| 583 |
| 584 SkAutoTUnref<GrDrawBatch> batch(GrNinePatch::CreateNonAA(paint.getColor(), v
iewMatrix, |
| 585 imageWidth, imageHe
ight, |
| 586 center, dst)); |
| 587 |
| 588 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); |
| 589 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); |
| 590 } |
| 591 |
| 592 |
571 // Can 'path' be drawn as a pair of filled nested rectangles? | 593 // Can 'path' be drawn as a pair of filled nested rectangles? |
572 static bool is_nested_rects(const SkMatrix& viewMatrix, | 594 static bool is_nested_rects(const SkMatrix& viewMatrix, |
573 const SkPath& path, | 595 const SkPath& path, |
574 const SkStrokeRec& stroke, | 596 const SkStrokeRec& stroke, |
575 SkRect rects[2]) { | 597 SkRect rects[2]) { |
576 SkASSERT(stroke.isFillStyle()); | 598 SkASSERT(stroke.isFillStyle()); |
577 | 599 |
578 if (path.isInverseFillType()) { | 600 if (path.isInverseFillType()) { |
579 return false; | 601 return false; |
580 } | 602 } |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 args.fAntiAlias = useCoverageAA; | 809 args.fAntiAlias = useCoverageAA; |
788 pr->drawPath(args); | 810 pr->drawPath(args); |
789 } | 811 } |
790 | 812 |
791 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b
atch) { | 813 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b
atch) { |
792 RETURN_IF_ABANDONED | 814 RETURN_IF_ABANDONED |
793 SkDEBUGCODE(this->validate();) | 815 SkDEBUGCODE(this->validate();) |
794 | 816 |
795 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); | 817 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); |
796 } | 818 } |
OLD | NEW |