OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 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 "GrAtlas.h" | 9 #include "GrAtlas.h" |
10 #include "GrContext.h" | 10 #include "GrContext.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 // If the above fails, then either we have no starting plot, or the current | 172 // If the above fails, then either we have no starting plot, or the current |
173 // plot list is full. Either way we need to allocate a new plot | 173 // plot list is full. Either way we need to allocate a new plot |
174 GrPlot* newPlot = this->allocPlot(); | 174 GrPlot* newPlot = this->allocPlot(); |
175 if (NULL == newPlot) { | 175 if (NULL == newPlot) { |
176 return NULL; | 176 return NULL; |
177 } | 177 } |
178 | 178 |
179 if (NULL == fTexture) { | 179 if (NULL == fTexture) { |
180 // TODO: Update this to use the cache rather than directly creating a te xture. | 180 // TODO: Update this to use the cache rather than directly creating a te xture. |
181 GrTextureDesc desc; | 181 GrTextureDesc desc; |
182 #ifdef SK_DEVELOPER | |
183 // RenderTarget so we can read the pixels to dump them | |
184 desc.fFlags = kDynamicUpdate_GrTextureFlagBit|kRenderTarget_GrTextureFla gBit; | |
bsalomon
2013/10/02 16:09:32
|kNoStencil_GrTextureFlagBit
| |
185 #else | |
182 desc.fFlags = kDynamicUpdate_GrTextureFlagBit; | 186 desc.fFlags = kDynamicUpdate_GrTextureFlagBit; |
187 #endif | |
183 desc.fWidth = GR_ATLAS_TEXTURE_WIDTH; | 188 desc.fWidth = GR_ATLAS_TEXTURE_WIDTH; |
184 desc.fHeight = GR_ATLAS_TEXTURE_HEIGHT; | 189 desc.fHeight = GR_ATLAS_TEXTURE_HEIGHT; |
185 desc.fConfig = fPixelConfig; | 190 desc.fConfig = fPixelConfig; |
186 | 191 |
187 fTexture = fGpu->createTexture(desc, NULL, 0); | 192 fTexture = fGpu->createTexture(desc, NULL, 0); |
188 if (NULL == fTexture) { | 193 if (NULL == fTexture) { |
189 return NULL; | 194 return NULL; |
190 } | 195 } |
191 } | 196 } |
192 // be sure to set texture for fast lookup | 197 // be sure to set texture for fast lookup |
193 newPlot->fTexture = fTexture; | 198 newPlot->fTexture = fTexture; |
194 | 199 |
195 if (!newPlot->addSubImage(width, height, image, loc)) { | 200 if (!newPlot->addSubImage(width, height, image, loc)) { |
196 this->freePlot(newPlot); | 201 this->freePlot(newPlot); |
197 return NULL; | 202 return NULL; |
198 } | 203 } |
199 | 204 |
200 // new plot, put at head | 205 // new plot, put at head |
201 newPlot->fNext = atlas->fPlots; | 206 newPlot->fNext = atlas->fPlots; |
202 atlas->fPlots = newPlot; | 207 atlas->fPlots = newPlot; |
203 | 208 |
204 return newPlot; | 209 return newPlot; |
205 } | 210 } |
206 | 211 |
207 bool GrAtlasMgr::removeUnusedPlots(GrAtlas* atlas) { | 212 bool GrAtlasMgr::removeUnusedPlots(GrAtlas* atlas) { |
213 | |
208 // GrPlot** is used so that the head element can be easily | 214 // GrPlot** is used so that the head element can be easily |
209 // modified when the first element is deleted | 215 // modified when the first element is deleted |
210 GrPlot** plotRef = &atlas->fPlots; | 216 GrPlot** plotRef = &atlas->fPlots; |
211 GrPlot* plot = atlas->fPlots; | 217 GrPlot* plot = atlas->fPlots; |
212 bool removed = false; | 218 bool removed = false; |
213 while (NULL != plot) { | 219 while (NULL != plot) { |
214 if (plot->drawToken().isIssued()) { | 220 if (plot->drawToken().isIssued()) { |
215 *plotRef = plot->fNext; | 221 *plotRef = plot->fNext; |
216 this->freePlot(plot); | 222 this->freePlot(plot); |
217 plot = *plotRef; | 223 plot = *plotRef; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
253 | 259 |
254 plot->fRects->reset(); | 260 plot->fRects->reset(); |
255 plot->fNext = fFreePlots; | 261 plot->fNext = fFreePlots; |
256 fFreePlots = plot; | 262 fFreePlots = plot; |
257 | 263 |
258 #ifdef SK_DEBUG | 264 #ifdef SK_DEBUG |
259 --gCounter; | 265 --gCounter; |
260 // GrPrintf("~GrPlot %p [%d %d] %d\n", this, plot->fOffset.fX, plot->fOffset. fY, gCounter); | 266 // GrPrintf("~GrPlot %p [%d %d] %d\n", this, plot->fOffset.fX, plot->fOffset. fY, gCounter); |
261 #endif | 267 #endif |
262 } | 268 } |
OLD | NEW |