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 "GrBatchTest.h" | 9 #include "GrBatchTest.h" |
10 #include "GrColor.h" | 10 #include "GrColor.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "batches/GrDrawAtlasBatch.h" | 21 #include "batches/GrDrawAtlasBatch.h" |
22 #include "batches/GrDrawVerticesBatch.h" | 22 #include "batches/GrDrawVerticesBatch.h" |
23 #include "batches/GrRectBatchFactory.h" | 23 #include "batches/GrRectBatchFactory.h" |
24 #include "batches/GrNinePatch.h" // TODO Factory | 24 #include "batches/GrNinePatch.h" // TODO Factory |
25 | 25 |
26 #include "text/GrAtlasTextContext.h" | 26 #include "text/GrAtlasTextContext.h" |
27 #include "text/GrStencilAndCoverTextContext.h" | 27 #include "text/GrStencilAndCoverTextContext.h" |
28 | 28 |
29 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fDrawingM
anager->getContext()) | 29 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fDrawingM
anager->getContext()) |
30 #define ASSERT_SINGLE_OWNER \ | 30 #define ASSERT_SINGLE_OWNER \ |
31 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(&fSingleOwner);) | 31 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fSingleOwner);) |
32 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; } | 32 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; } |
33 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fa
lse; } | 33 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fa
lse; } |
34 #define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return nu
llptr; } | 34 #define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return nu
llptr; } |
35 | 35 |
36 class AutoCheckFlush { | 36 class AutoCheckFlush { |
37 public: | 37 public: |
38 AutoCheckFlush(GrDrawingManager* drawingManager) : fDrawingManager(drawingMa
nager) { | 38 AutoCheckFlush(GrDrawingManager* drawingManager) : fDrawingManager(drawingMa
nager) { |
39 SkASSERT(fDrawingManager); | 39 SkASSERT(fDrawingManager); |
40 } | 40 } |
41 ~AutoCheckFlush() { fDrawingManager->getContext()->flushIfNecessary(); } | 41 ~AutoCheckFlush() { fDrawingManager->getContext()->flushIfNecessary(); } |
42 | 42 |
43 private: | 43 private: |
44 GrDrawingManager* fDrawingManager; | 44 GrDrawingManager* fDrawingManager; |
45 }; | 45 }; |
46 | 46 |
47 // In MDB mode the reffing of the 'getLastDrawTarget' call's result allows in-pr
ogress | 47 // In MDB mode the reffing of the 'getLastDrawTarget' call's result allows in-pr
ogress |
48 // drawTargets to be picked up and added to by drawContexts lower in the call | 48 // drawTargets to be picked up and added to by drawContexts lower in the call |
49 // stack. When this occurs with a closed drawTarget, a new one will be allocated | 49 // stack. When this occurs with a closed drawTarget, a new one will be allocated |
50 // when the drawContext attempts to use it (via getDrawTarget). | 50 // when the drawContext attempts to use it (via getDrawTarget). |
51 GrDrawContext::GrDrawContext(GrDrawingManager* drawingMgr, | 51 GrDrawContext::GrDrawContext(GrDrawingManager* drawingMgr, |
52 GrRenderTarget* rt, | 52 GrRenderTarget* rt, |
53 const SkSurfaceProps* surfaceProps) | 53 const SkSurfaceProps* surfaceProps, |
| 54 GrSingleOwner* singleOwner) |
54 : fDrawingManager(drawingMgr) | 55 : fDrawingManager(drawingMgr) |
55 , fRenderTarget(rt) | 56 , fRenderTarget(rt) |
56 , fDrawTarget(SkSafeRef(rt->getLastDrawTarget())) | 57 , fDrawTarget(SkSafeRef(rt->getLastDrawTarget())) |
57 , fTextContext(nullptr) | 58 , fTextContext(nullptr) |
58 , fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps)) { | 59 , fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps)) |
| 60 , fSingleOwner(singleOwner) { |
59 SkDEBUGCODE(this->validate();) | 61 SkDEBUGCODE(this->validate();) |
60 } | 62 } |
61 | 63 |
62 #ifdef SK_DEBUG | 64 #ifdef SK_DEBUG |
63 void GrDrawContext::validate() const { | 65 void GrDrawContext::validate() const { |
64 SkASSERT(fRenderTarget); | 66 SkASSERT(fRenderTarget); |
65 ASSERT_OWNED_RESOURCE(fRenderTarget); | 67 ASSERT_OWNED_RESOURCE(fRenderTarget); |
66 | 68 |
67 if (fDrawTarget && !fDrawTarget->isClosed()) { | 69 if (fDrawTarget && !fDrawTarget->isClosed()) { |
68 SkASSERT(fRenderTarget->getLastDrawTarget() == fDrawTarget); | 70 SkASSERT(fRenderTarget->getLastDrawTarget() == fDrawTarget); |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 pr->drawPath(args); | 825 pr->drawPath(args); |
824 } | 826 } |
825 | 827 |
826 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b
atch) { | 828 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b
atch) { |
827 ASSERT_SINGLE_OWNER | 829 ASSERT_SINGLE_OWNER |
828 RETURN_IF_ABANDONED | 830 RETURN_IF_ABANDONED |
829 SkDEBUGCODE(this->validate();) | 831 SkDEBUGCODE(this->validate();) |
830 | 832 |
831 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); | 833 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); |
832 } | 834 } |
OLD | NEW |