| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 | 138 |
| 139 void GrPlot::resetRects() { | 139 void GrPlot::resetRects() { |
| 140 SkASSERT(fRects); | 140 SkASSERT(fRects); |
| 141 fRects->reset(); | 141 fRects->reset(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 /////////////////////////////////////////////////////////////////////////////// | 144 /////////////////////////////////////////////////////////////////////////////// |
| 145 | 145 |
| 146 GrAtlas::GrAtlas(GrGpu* gpu, GrPixelConfig config, GrTextureFlags flags, | 146 GrAtlas::GrAtlas(GrGpu* gpu, GrPixelConfig config, GrSurfaceFlags flags, |
| 147 const SkISize& backingTextureSize, | 147 const SkISize& backingTextureSize, |
| 148 int numPlotsX, int numPlotsY, bool batchUploads) { | 148 int numPlotsX, int numPlotsY, bool batchUploads) { |
| 149 fGpu = SkRef(gpu); | 149 fGpu = SkRef(gpu); |
| 150 fPixelConfig = config; | 150 fPixelConfig = config; |
| 151 fFlags = flags; | 151 fFlags = flags; |
| 152 fBackingTextureSize = backingTextureSize; | 152 fBackingTextureSize = backingTextureSize; |
| 153 fNumPlotsX = numPlotsX; | 153 fNumPlotsX = numPlotsX; |
| 154 fNumPlotsY = numPlotsY; | 154 fNumPlotsY = numPlotsY; |
| 155 fBatchUploads = batchUploads; | 155 fBatchUploads = batchUploads; |
| 156 fTexture = NULL; | 156 fTexture = NULL; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // client may have plots from more than one atlas, must check for ours b
efore adding | 212 // client may have plots from more than one atlas, must check for ours b
efore adding |
| 213 if (this == plot->fAtlas && plot->addSubImage(width, height, image, loc)
) { | 213 if (this == plot->fAtlas && plot->addSubImage(width, height, image, loc)
) { |
| 214 this->makeMRU(plot); | 214 this->makeMRU(plot); |
| 215 return plot; | 215 return plot; |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 | 218 |
| 219 // before we get a new plot, make sure we have a backing texture | 219 // before we get a new plot, make sure we have a backing texture |
| 220 if (NULL == fTexture) { | 220 if (NULL == fTexture) { |
| 221 // TODO: Update this to use the cache rather than directly creating a te
xture. | 221 // TODO: Update this to use the cache rather than directly creating a te
xture. |
| 222 GrTextureDesc desc; | 222 GrSurfaceDesc desc; |
| 223 desc.fFlags = fFlags | kDynamicUpdate_GrTextureFlagBit; | 223 desc.fFlags = fFlags; |
| 224 desc.fWidth = fBackingTextureSize.width(); | 224 desc.fWidth = fBackingTextureSize.width(); |
| 225 desc.fHeight = fBackingTextureSize.height(); | 225 desc.fHeight = fBackingTextureSize.height(); |
| 226 desc.fConfig = fPixelConfig; | 226 desc.fConfig = fPixelConfig; |
| 227 | 227 |
| 228 fTexture = fGpu->createTexture(desc, NULL, 0); | 228 fTexture = fGpu->createTexture(desc, NULL, 0); |
| 229 if (NULL == fTexture) { | 229 if (NULL == fTexture) { |
| 230 return NULL; | 230 return NULL; |
| 231 } | 231 } |
| 232 } | 232 } |
| 233 | 233 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 if (fBatchUploads) { | 278 if (fBatchUploads) { |
| 279 GrPlotList::Iter plotIter; | 279 GrPlotList::Iter plotIter; |
| 280 plotIter.init(fPlotList, GrPlotList::Iter::kHead_IterStart); | 280 plotIter.init(fPlotList, GrPlotList::Iter::kHead_IterStart); |
| 281 GrPlot* plot; | 281 GrPlot* plot; |
| 282 while ((plot = plotIter.get())) { | 282 while ((plot = plotIter.get())) { |
| 283 plot->uploadToTexture(); | 283 plot->uploadToTexture(); |
| 284 plotIter.next(); | 284 plotIter.next(); |
| 285 } | 285 } |
| 286 } | 286 } |
| 287 } | 287 } |
| OLD | NEW |