| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 if (fPlotList.head() == plot) { | 193 if (fPlotList.head() == plot) { |
| 194 return; | 194 return; |
| 195 } | 195 } |
| 196 | 196 |
| 197 fPlotList.remove(plot); | 197 fPlotList.remove(plot); |
| 198 fPlotList.addToHead(plot); | 198 fPlotList.addToHead(plot); |
| 199 }; | 199 }; |
| 200 | 200 |
| 201 GrPlot* GrAtlasMgr::addToAtlas(GrAtlas* atlas, | 201 GrPlot* GrAtlasMgr::addToAtlas(GrAtlas* atlas, |
| 202 int width, int height, const void* image, | 202 int width, int height, const void* image, |
| 203 GrIPoint16* loc) { | 203 SkIPoint16* loc) { |
| 204 // iterate through entire plot list for this atlas, see if we can find a hol
e | 204 // iterate through entire plot list for this atlas, see if we can find a hol
e |
| 205 // last one was most recently added and probably most empty | 205 // last one was most recently added and probably most empty |
| 206 for (int i = atlas->fPlots.count()-1; i >= 0; --i) { | 206 for (int i = atlas->fPlots.count()-1; i >= 0; --i) { |
| 207 GrPlot* plot = atlas->fPlots[i]; | 207 GrPlot* plot = atlas->fPlots[i]; |
| 208 if (plot->addSubImage(width, height, image, loc)) { | 208 if (plot->addSubImage(width, height, image, loc)) { |
| 209 this->moveToHead(plot); | 209 this->moveToHead(plot); |
| 210 return plot; | 210 return plot; |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 | 213 |
| (...skipping 64 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 (NULL != (plot = plotIter.get())) { | 282 while (NULL != (plot = plotIter.get())) { |
| 283 plot->uploadToTexture(); | 283 plot->uploadToTexture(); |
| 284 plotIter.next(); | 284 plotIter.next(); |
| 285 } | 285 } |
| 286 } | 286 } |
| 287 } | 287 } |
| OLD | NEW |