| 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 30 matching lines...) Expand all Loading... |
| 41 fRects = GrRectanizer::Factory(width, height); | 41 fRects = GrRectanizer::Factory(width, height); |
| 42 fAtlasMgr = mgr; | 42 fAtlasMgr = mgr; |
| 43 fOffset.set(offX * width, offY * height); | 43 fOffset.set(offX * width, offY * height); |
| 44 fBytesPerPixel = bpp; | 44 fBytesPerPixel = bpp; |
| 45 fPlotData = NULL; | 45 fPlotData = NULL; |
| 46 fDirtyRect.setEmpty(); | 46 fDirtyRect.setEmpty(); |
| 47 fDirty = false; | 47 fDirty = false; |
| 48 fBatchUploads = batchUploads; | 48 fBatchUploads = batchUploads; |
| 49 } | 49 } |
| 50 | 50 |
| 51 static inline void adjust_for_offset(GrIPoint16* loc, const GrIPoint16& offset)
{ | 51 static inline void adjust_for_offset(SkIPoint16* loc, const SkIPoint16& offset)
{ |
| 52 loc->fX += offset.fX; | 52 loc->fX += offset.fX; |
| 53 loc->fY += offset.fY; | 53 loc->fY += offset.fY; |
| 54 } | 54 } |
| 55 | 55 |
| 56 bool GrPlot::addSubImage(int width, int height, const void* image, | 56 bool GrPlot::addSubImage(int width, int height, const void* image, |
| 57 GrIPoint16* loc) { | 57 SkIPoint16* loc) { |
| 58 float percentFull = fRects->percentFull(); | 58 float percentFull = fRects->percentFull(); |
| 59 if (!fRects->addRect(width, height, loc)) { | 59 if (!fRects->addRect(width, height, loc)) { |
| 60 return false; | 60 return false; |
| 61 } | 61 } |
| 62 | 62 |
| 63 // if batching uploads, create backing memory on first use | 63 // if batching uploads, create backing memory on first use |
| 64 // once the plot is nearly full we will revert to uploading each subimage in
dividually | 64 // once the plot is nearly full we will revert to uploading each subimage in
dividually |
| 65 int plotWidth = fRects->width(); | 65 int plotWidth = fRects->width(); |
| 66 int plotHeight = fRects->height(); | 66 int plotHeight = fRects->height(); |
| 67 if (fBatchUploads && NULL == fPlotData && 0.0f == percentFull) { | 67 if (fBatchUploads && NULL == fPlotData && 0.0f == percentFull) { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 if (fPlotList.head() == plot) { | 196 if (fPlotList.head() == plot) { |
| 197 return; | 197 return; |
| 198 } | 198 } |
| 199 | 199 |
| 200 fPlotList.remove(plot); | 200 fPlotList.remove(plot); |
| 201 fPlotList.addToHead(plot); | 201 fPlotList.addToHead(plot); |
| 202 }; | 202 }; |
| 203 | 203 |
| 204 GrPlot* GrAtlasMgr::addToAtlas(GrAtlas* atlas, | 204 GrPlot* GrAtlasMgr::addToAtlas(GrAtlas* atlas, |
| 205 int width, int height, const void* image, | 205 int width, int height, const void* image, |
| 206 GrIPoint16* loc) { | 206 SkIPoint16* loc) { |
| 207 // iterate through entire plot list for this atlas, see if we can find a hol
e | 207 // iterate through entire plot list for this atlas, see if we can find a hol
e |
| 208 // last one was most recently added and probably most empty | 208 // last one was most recently added and probably most empty |
| 209 for (int i = atlas->fPlots.count()-1; i >= 0; --i) { | 209 for (int i = atlas->fPlots.count()-1; i >= 0; --i) { |
| 210 GrPlot* plot = atlas->fPlots[i]; | 210 GrPlot* plot = atlas->fPlots[i]; |
| 211 if (plot->addSubImage(width, height, image, loc)) { | 211 if (plot->addSubImage(width, height, image, loc)) { |
| 212 this->moveToHead(plot); | 212 this->moveToHead(plot); |
| 213 return plot; | 213 return plot; |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 | 216 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 if (fBatchUploads) { | 281 if (fBatchUploads) { |
| 282 GrPlotList::Iter plotIter; | 282 GrPlotList::Iter plotIter; |
| 283 plotIter.init(fPlotList, GrPlotList::Iter::kHead_IterStart); | 283 plotIter.init(fPlotList, GrPlotList::Iter::kHead_IterStart); |
| 284 GrPlot* plot; | 284 GrPlot* plot; |
| 285 while (NULL != (plot = plotIter.get())) { | 285 while (NULL != (plot = plotIter.get())) { |
| 286 plot->uploadToTexture(); | 286 plot->uploadToTexture(); |
| 287 plotIter.next(); | 287 plotIter.next(); |
| 288 } | 288 } |
| 289 } | 289 } |
| 290 } | 290 } |
| OLD | NEW |