| 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 |
| 185 |kNoStencil_GrTextureFlagBi
t; |
| 186 #else |
| 182 desc.fFlags = kDynamicUpdate_GrTextureFlagBit; | 187 desc.fFlags = kDynamicUpdate_GrTextureFlagBit; |
| 188 #endif |
| 183 desc.fWidth = GR_ATLAS_TEXTURE_WIDTH; | 189 desc.fWidth = GR_ATLAS_TEXTURE_WIDTH; |
| 184 desc.fHeight = GR_ATLAS_TEXTURE_HEIGHT; | 190 desc.fHeight = GR_ATLAS_TEXTURE_HEIGHT; |
| 185 desc.fConfig = fPixelConfig; | 191 desc.fConfig = fPixelConfig; |
| 186 | 192 |
| 187 fTexture = fGpu->createTexture(desc, NULL, 0); | 193 fTexture = fGpu->createTexture(desc, NULL, 0); |
| 188 if (NULL == fTexture) { | 194 if (NULL == fTexture) { |
| 189 return NULL; | 195 return NULL; |
| 190 } | 196 } |
| 191 } | 197 } |
| 192 // be sure to set texture for fast lookup | 198 // be sure to set texture for fast lookup |
| 193 newPlot->fTexture = fTexture; | 199 newPlot->fTexture = fTexture; |
| 194 | 200 |
| 195 if (!newPlot->addSubImage(width, height, image, loc)) { | 201 if (!newPlot->addSubImage(width, height, image, loc)) { |
| 196 this->freePlot(newPlot); | 202 this->freePlot(newPlot); |
| 197 return NULL; | 203 return NULL; |
| 198 } | 204 } |
| 199 | 205 |
| 200 // new plot, put at head | 206 // new plot, put at head |
| 201 newPlot->fNext = atlas->fPlots; | 207 newPlot->fNext = atlas->fPlots; |
| 202 atlas->fPlots = newPlot; | 208 atlas->fPlots = newPlot; |
| 203 | 209 |
| 204 return newPlot; | 210 return newPlot; |
| 205 } | 211 } |
| 206 | 212 |
| 207 bool GrAtlasMgr::removeUnusedPlots(GrAtlas* atlas) { | 213 bool GrAtlasMgr::removeUnusedPlots(GrAtlas* atlas) { |
| 214 |
| 208 // GrPlot** is used so that the head element can be easily | 215 // GrPlot** is used so that the head element can be easily |
| 209 // modified when the first element is deleted | 216 // modified when the first element is deleted |
| 210 GrPlot** plotRef = &atlas->fPlots; | 217 GrPlot** plotRef = &atlas->fPlots; |
| 211 GrPlot* plot = atlas->fPlots; | 218 GrPlot* plot = atlas->fPlots; |
| 212 bool removed = false; | 219 bool removed = false; |
| 213 while (NULL != plot) { | 220 while (NULL != plot) { |
| 214 if (plot->drawToken().isIssued()) { | 221 if (plot->drawToken().isIssued()) { |
| 215 *plotRef = plot->fNext; | 222 *plotRef = plot->fNext; |
| 216 this->freePlot(plot); | 223 this->freePlot(plot); |
| 217 plot = *plotRef; | 224 plot = *plotRef; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 | 260 |
| 254 plot->fRects->reset(); | 261 plot->fRects->reset(); |
| 255 plot->fNext = fFreePlots; | 262 plot->fNext = fFreePlots; |
| 256 fFreePlots = plot; | 263 fFreePlots = plot; |
| 257 | 264 |
| 258 #ifdef SK_DEBUG | 265 #ifdef SK_DEBUG |
| 259 --gCounter; | 266 --gCounter; |
| 260 // GrPrintf("~GrPlot %p [%d %d] %d\n", this, plot->fOffset.fX, plot->fOffset.
fY, gCounter); | 267 // GrPrintf("~GrPlot %p [%d %d] %d\n", this, plot->fOffset.fX, plot->fOffset.
fY, gCounter); |
| 261 #endif | 268 #endif |
| 262 } | 269 } |
| OLD | NEW |