OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
| 8 #include "GrDrawingManager.h" |
| 9 |
| 10 #include "GrContext.h" |
8 #include "GrDrawContext.h" | 11 #include "GrDrawContext.h" |
9 #include "GrDrawingManager.h" | |
10 #include "GrDrawTarget.h" | 12 #include "GrDrawTarget.h" |
11 #include "GrPathRenderingDrawContext.h" | 13 #include "GrPathRenderingDrawContext.h" |
12 #include "GrResourceProvider.h" | 14 #include "GrResourceProvider.h" |
13 #include "GrSoftwarePathRenderer.h" | 15 #include "GrSoftwarePathRenderer.h" |
14 #include "SkSurface_Gpu.h" | 16 #include "SkSurface_Gpu.h" |
15 #include "SkTTopoSort.h" | 17 #include "SkTTopoSort.h" |
16 | 18 |
17 #include "instanced/InstancedRendering.h" | 19 #include "instanced/InstancedRendering.h" |
18 | 20 |
19 #include "text/GrAtlasTextContext.h" | 21 #include "text/GrAtlasTextContext.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } | 69 } |
68 } | 70 } |
69 | 71 |
70 void GrDrawingManager::reset() { | 72 void GrDrawingManager::reset() { |
71 for (int i = 0; i < fDrawTargets.count(); ++i) { | 73 for (int i = 0; i < fDrawTargets.count(); ++i) { |
72 fDrawTargets[i]->reset(); | 74 fDrawTargets[i]->reset(); |
73 } | 75 } |
74 fFlushState.reset(); | 76 fFlushState.reset(); |
75 } | 77 } |
76 | 78 |
77 bool GrDrawingManager::flush() { | 79 void GrDrawingManager::internalFlush(GrResourceCache::FlushType type) { |
78 if (fFlushing || this->wasAbandoned()) { | 80 if (fFlushing || this->wasAbandoned()) { |
79 return false; | 81 return; |
80 } | 82 } |
81 fFlushing = true; | 83 fFlushing = true; |
82 bool flushed = false; | 84 bool flushed = false; |
83 SkDEBUGCODE(bool result =) | 85 SkDEBUGCODE(bool result =) |
84 SkTTopoSort<GrDrawTarget, GrDrawTarget::TopoSortTraits>(
&fDrawTargets); | 86 SkTTopoSort<GrDrawTarget, GrDrawTarget::TopoSortTraits>(
&fDrawTargets); |
85 SkASSERT(result); | 87 SkASSERT(result); |
86 | 88 |
87 for (int i = 0; i < fDrawTargets.count(); ++i) { | 89 for (int i = 0; i < fDrawTargets.count(); ++i) { |
88 fDrawTargets[i]->prepareBatches(&fFlushState); | 90 fDrawTargets[i]->prepareBatches(&fFlushState); |
89 } | 91 } |
(...skipping 29 matching lines...) Expand all Loading... |
119 SkASSERT(fDrawTargets.count() == 1); | 121 SkASSERT(fDrawTargets.count() == 1); |
120 // Clear out this flag so the topological sort's SkTTopoSort_CheckAllUnm
arked check | 122 // Clear out this flag so the topological sort's SkTTopoSort_CheckAllUnm
arked check |
121 // won't bark | 123 // won't bark |
122 fDrawTargets[0]->resetFlag(GrDrawTarget::kWasOutput_Flag); | 124 fDrawTargets[0]->resetFlag(GrDrawTarget::kWasOutput_Flag); |
123 } | 125 } |
124 #else | 126 #else |
125 fDrawTargets.reset(); | 127 fDrawTargets.reset(); |
126 #endif | 128 #endif |
127 | 129 |
128 fFlushState.reset(); | 130 fFlushState.reset(); |
| 131 // We always have to notify the cache when it requested a flush so it can re
set its state. |
| 132 if (flushed || type == GrResourceCache::FlushType::kCacheRequested) { |
| 133 fContext->getResourceCache()->notifyFlushOccurred(type); |
| 134 } |
129 fFlushing = false; | 135 fFlushing = false; |
130 return flushed; | |
131 } | 136 } |
132 | 137 |
133 GrDrawTarget* GrDrawingManager::newDrawTarget(GrRenderTarget* rt) { | 138 GrDrawTarget* GrDrawingManager::newDrawTarget(GrRenderTarget* rt) { |
134 SkASSERT(fContext); | 139 SkASSERT(fContext); |
135 | 140 |
136 #ifndef ENABLE_MDB | 141 #ifndef ENABLE_MDB |
137 // When MDB is disabled we always just return the single drawTarget | 142 // When MDB is disabled we always just return the single drawTarget |
138 if (fDrawTargets.count()) { | 143 if (fDrawTargets.count()) { |
139 SkASSERT(fDrawTargets.count() == 1); | 144 SkASSERT(fDrawTargets.count() == 1); |
140 // In the non-MDB-world the same drawTarget gets reused for multiple ren
der targets. | 145 // In the non-MDB-world the same drawTarget gets reused for multiple ren
der targets. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 std::move(colorSpace), s
urfaceProps, | 221 std::move(colorSpace), s
urfaceProps, |
217 fContext->getAuditTrail(
), fSingleOwner)); | 222 fContext->getAuditTrail(
), fSingleOwner)); |
218 } | 223 } |
219 } | 224 } |
220 | 225 |
221 return sk_sp<GrDrawContext>(new GrDrawContext(fContext, this, std::move(rt), | 226 return sk_sp<GrDrawContext>(new GrDrawContext(fContext, this, std::move(rt), |
222 std::move(colorSpace), surface
Props, | 227 std::move(colorSpace), surface
Props, |
223 fContext->getAuditTrail(), | 228 fContext->getAuditTrail(), |
224 fSingleOwner)); | 229 fSingleOwner)); |
225 } | 230 } |
OLD | NEW |