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 "GrAtlasTextContext.h" | 8 #include "GrAtlasTextContext.h" |
9 #include "GrDrawContext.h" | 9 #include "GrDrawContext.h" |
10 #include "GrDrawingManager.h" | 10 #include "GrDrawingManager.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 // a path renderer may be holding onto resources | 51 // a path renderer may be holding onto resources |
52 delete fPathRendererChain; | 52 delete fPathRendererChain; |
53 fPathRendererChain = nullptr; | 53 fPathRendererChain = nullptr; |
54 SkSafeSetNull(fSoftwarePathRenderer); | 54 SkSafeSetNull(fSoftwarePathRenderer); |
55 } | 55 } |
56 | 56 |
57 void GrDrawingManager::reset() { | 57 void GrDrawingManager::reset() { |
58 for (int i = 0; i < fDrawTargets.count(); ++i) { | 58 for (int i = 0; i < fDrawTargets.count(); ++i) { |
59 fDrawTargets[i]->reset(); | 59 fDrawTargets[i]->reset(); |
60 } | 60 } |
| 61 fFlushState.reset(); |
61 } | 62 } |
62 | 63 |
63 void GrDrawingManager::flush() { | 64 void GrDrawingManager::flush() { |
64 SkDEBUGCODE(bool result =) | 65 SkDEBUGCODE(bool result =) |
65 SkTTopoSort<GrDrawTarget, GrDrawTarget::TopoSortTraits>(
&fDrawTargets); | 66 SkTTopoSort<GrDrawTarget, GrDrawTarget::TopoSortTraits>(
&fDrawTargets); |
66 SkASSERT(result); | 67 SkASSERT(result); |
67 | 68 |
| 69 #if 0 |
68 for (int i = 0; i < fDrawTargets.count(); ++i) { | 70 for (int i = 0; i < fDrawTargets.count(); ++i) { |
69 //SkDEBUGCODE(fDrawTargets[i]->dump();) | 71 SkDEBUGCODE(fDrawTargets[i]->dump();) |
70 fDrawTargets[i]->flush(); | |
71 } | 72 } |
| 73 #endif |
| 74 |
| 75 for (int i = 0; i < fDrawTargets.count(); ++i) { |
| 76 fDrawTargets[i]->prepareBatches(&fFlushState); |
| 77 } |
| 78 |
| 79 // Upload all data to the GPU |
| 80 fFlushState.preIssueDraws(); |
| 81 |
| 82 for (int i = 0; i < fDrawTargets.count(); ++i) { |
| 83 fDrawTargets[i]->drawBatches(&fFlushState); |
| 84 } |
| 85 |
| 86 SkASSERT(fFlushState.lastFlushedToken() == fFlushState.currentToken()); |
72 | 87 |
73 #ifndef ENABLE_MDB | 88 #ifndef ENABLE_MDB |
74 // When MDB is disabled we keep reusing the same drawTarget | 89 // When MDB is disabled we keep reusing the same drawTarget |
75 if (fDrawTargets.count()) { | 90 if (fDrawTargets.count()) { |
76 SkASSERT(fDrawTargets.count() == 1); | 91 SkASSERT(fDrawTargets.count() == 1); |
77 fDrawTargets[0]->resetFlag(GrDrawTarget::kWasOutput_Flag); | 92 fDrawTargets[0]->resetFlag(GrDrawTarget::kWasOutput_Flag); |
78 } | 93 } |
79 #endif | 94 #endif |
| 95 |
| 96 for (int i = 0; i < fDrawTargets.count(); ++i) { |
| 97 fDrawTargets[i]->reset(); |
| 98 } |
| 99 fFlushState.reset(); |
80 } | 100 } |
81 | 101 |
82 GrTextContext* GrDrawingManager::textContext(const SkSurfaceProps& props, | 102 GrTextContext* GrDrawingManager::textContext(const SkSurfaceProps& props, |
83 GrRenderTarget* rt) { | 103 GrRenderTarget* rt) { |
84 if (this->abandoned()) { | 104 if (this->abandoned()) { |
85 return nullptr; | 105 return nullptr; |
86 } | 106 } |
87 | 107 |
88 SkASSERT(props.pixelGeometry() < kNumPixelGeometries); | 108 SkASSERT(props.pixelGeometry() < kNumPixelGeometries); |
89 bool useDIF = props.isUseDeviceIndependentFonts(); | 109 bool useDIF = props.isUseDeviceIndependentFonts(); |
(...skipping 22 matching lines...) Expand all Loading... |
112 | 132 |
113 #ifndef ENABLE_MDB | 133 #ifndef ENABLE_MDB |
114 // When MDB is disabled we always just return the single drawTarget | 134 // When MDB is disabled we always just return the single drawTarget |
115 if (fDrawTargets.count()) { | 135 if (fDrawTargets.count()) { |
116 SkASSERT(fDrawTargets.count() == 1); | 136 SkASSERT(fDrawTargets.count() == 1); |
117 // DrawingManager gets the creation ref - this ref is for the caller | 137 // DrawingManager gets the creation ref - this ref is for the caller |
118 return SkRef(fDrawTargets[0]); | 138 return SkRef(fDrawTargets[0]); |
119 } | 139 } |
120 #endif | 140 #endif |
121 | 141 |
122 GrDrawTarget* dt = new GrDrawTarget(rt, fContext->getGpu(), fContext->resour
ceProvider(), | 142 GrDrawTarget* dt = new GrDrawTarget(rt, fContext->getGpu(), fContext->resour
ceProvider()); |
123 fOptions); | |
124 | 143 |
125 *fDrawTargets.append() = dt; | 144 *fDrawTargets.append() = dt; |
126 | 145 |
127 // DrawingManager gets the creation ref - this ref is for the caller | 146 // DrawingManager gets the creation ref - this ref is for the caller |
128 return SkRef(dt); | 147 return SkRef(dt); |
129 } | 148 } |
130 | 149 |
131 /* | 150 /* |
132 * This method finds a path renderer that can draw the specified path on | 151 * This method finds a path renderer that can draw the specified path on |
133 * the provided target. | 152 * the provided target. |
(...skipping 21 matching lines...) Expand all Loading... |
155 } | 174 } |
156 | 175 |
157 GrDrawContext* GrDrawingManager::drawContext(GrRenderTarget* rt, | 176 GrDrawContext* GrDrawingManager::drawContext(GrRenderTarget* rt, |
158 const SkSurfaceProps* surfaceProps)
{ | 177 const SkSurfaceProps* surfaceProps)
{ |
159 if (this->abandoned()) { | 178 if (this->abandoned()) { |
160 return nullptr; | 179 return nullptr; |
161 } | 180 } |
162 | 181 |
163 return new GrDrawContext(this, rt, surfaceProps); | 182 return new GrDrawContext(this, rt, surfaceProps); |
164 } | 183 } |
OLD | NEW |