| epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 2 | /* |
| epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2010 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 9 | #include "GrAtlas.h" |
| bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 10 | #include "GrContext.h" |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 11 | #include "GrGpu.h" |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 12 | #include "GrRectanizer.h" |
| jvanverth | 8e80d17 | 2014-06-19 12:01:10 -0700 | [diff] [blame^] | 13 | #include "GrTracing.h" |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 14 | |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 15 | /////////////////////////////////////////////////////////////////////////////// |
| 16 | |
| commit-bot@chromium.org | 67ed64e | 2013-08-05 19:42:56 +0000 | [diff] [blame] | 17 | // for testing |
| 18 | #define FONT_CACHE_STATS 0 |
| 19 | #if FONT_CACHE_STATS |
| 20 | static int g_UploadCount = 0; |
| 21 | #endif |
| 22 | |
| commit-bot@chromium.org | 7d330eb | 2013-09-27 19:39:38 +0000 | [diff] [blame] | 23 | GrPlot::GrPlot() : fDrawToken(NULL, 0) |
| commit-bot@chromium.org | 7d330eb | 2013-09-27 19:39:38 +0000 | [diff] [blame] | 24 | , fTexture(NULL) |
| commit-bot@chromium.org | 53e1e4d | 2014-04-01 16:25:11 +0000 | [diff] [blame] | 25 | , fRects(NULL) |
| commit-bot@chromium.org | 7d330eb | 2013-09-27 19:39:38 +0000 | [diff] [blame] | 26 | , fAtlasMgr(NULL) |
| 27 | , fBytesPerPixel(1) |
| commit-bot@chromium.org | 7801faa | 2014-05-14 15:14:51 +0000 | [diff] [blame] | 28 | , fDirty(false) |
| 29 | , fBatchUploads(false) |
| commit-bot@chromium.org | 7d330eb | 2013-09-27 19:39:38 +0000 | [diff] [blame] | 30 | { |
| commit-bot@chromium.org | 7d330eb | 2013-09-27 19:39:38 +0000 | [diff] [blame] | 31 | fOffset.set(0, 0); |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 32 | } |
| 33 | |
| commit-bot@chromium.org | 7d330eb | 2013-09-27 19:39:38 +0000 | [diff] [blame] | 34 | GrPlot::~GrPlot() { |
| commit-bot@chromium.org | 7801faa | 2014-05-14 15:14:51 +0000 | [diff] [blame] | 35 | SkDELETE_ARRAY(fPlotData); |
| 36 | fPlotData = NULL; |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 37 | delete fRects; |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 38 | } |
| 39 | |
| commit-bot@chromium.org | 7801faa | 2014-05-14 15:14:51 +0000 | [diff] [blame] | 40 | void GrPlot::init(GrAtlasMgr* mgr, int offX, int offY, int width, int height, size_t bpp, |
| 41 | bool batchUploads) { |
| commit-bot@chromium.org | 53e1e4d | 2014-04-01 16:25:11 +0000 | [diff] [blame] | 42 | fRects = GrRectanizer::Factory(width, height); |
| 43 | fAtlasMgr = mgr; |
| 44 | fOffset.set(offX * width, offY * height); |
| 45 | fBytesPerPixel = bpp; |
| commit-bot@chromium.org | 7801faa | 2014-05-14 15:14:51 +0000 | [diff] [blame] | 46 | fPlotData = NULL; |
| 47 | fDirtyRect.setEmpty(); |
| 48 | fDirty = false; |
| 49 | fBatchUploads = batchUploads; |
| commit-bot@chromium.org | 53e1e4d | 2014-04-01 16:25:11 +0000 | [diff] [blame] | 50 | } |
| 51 | |
| robertphillips | d537341 | 2014-06-02 10:20:14 -0700 | [diff] [blame] | 52 | static inline void adjust_for_offset(SkIPoint16* loc, const SkIPoint16& offset) { |
| commit-bot@chromium.org | 53e1e4d | 2014-04-01 16:25:11 +0000 | [diff] [blame] | 53 | loc->fX += offset.fX; |
| 54 | loc->fY += offset.fY; |
| commit-bot@chromium.org | 67ed64e | 2013-08-05 19:42:56 +0000 | [diff] [blame] | 55 | } |
| 56 | |
| commit-bot@chromium.org | 7d330eb | 2013-09-27 19:39:38 +0000 | [diff] [blame] | 57 | bool GrPlot::addSubImage(int width, int height, const void* image, |
| robertphillips | d537341 | 2014-06-02 10:20:14 -0700 | [diff] [blame] | 58 | SkIPoint16* loc) { |
| commit-bot@chromium.org | 7801faa | 2014-05-14 15:14:51 +0000 | [diff] [blame] | 59 | float percentFull = fRects->percentFull(); |
| commit-bot@chromium.org | f952924 | 2014-02-14 18:41:47 +0000 | [diff] [blame] | 60 | if (!fRects->addRect(width, height, loc)) { |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 61 | return false; |
| 62 | } |
| 63 | |
| commit-bot@chromium.org | 7801faa | 2014-05-14 15:14:51 +0000 | [diff] [blame] | 64 | // if batching uploads, create backing memory on first use |
| 65 | // once the plot is nearly full we will revert to uploading each subimage individually |
| 66 | int plotWidth = fRects->width(); |
| 67 | int plotHeight = fRects->height(); |
| 68 | if (fBatchUploads && NULL == fPlotData && 0.0f == percentFull) { |
| 69 | fPlotData = SkNEW_ARRAY(unsigned char, fBytesPerPixel*plotWidth*plotHeight); |
| 70 | memset(fPlotData, 0, fBytesPerPixel*plotWidth*plotHeight); |
| 71 | } |
| 72 | |
| 73 | // if we have backing memory, copy to the memory and set for future upload |
| 74 | if (NULL != fPlotData) { |
| 75 | const unsigned char* imagePtr = (const unsigned char*) image; |
| 76 | // point ourselves at the right starting spot |
| 77 | unsigned char* dataPtr = fPlotData; |
| 78 | dataPtr += fBytesPerPixel*plotWidth*loc->fY; |
| 79 | dataPtr += fBytesPerPixel*loc->fX; |
| 80 | // copy into the data buffer |
| 81 | for (int i = 0; i < height; ++i) { |
| 82 | memcpy(dataPtr, imagePtr, fBytesPerPixel*width); |
| 83 | dataPtr += fBytesPerPixel*plotWidth; |
| 84 | imagePtr += fBytesPerPixel*width; |
| 85 | } |
| 86 | |
| 87 | fDirtyRect.join(loc->fX, loc->fY, loc->fX + width, loc->fY + height); |
| 88 | adjust_for_offset(loc, fOffset); |
| 89 | fDirty = true; |
| 90 | // otherwise, just upload the image directly |
| 91 | } else { |
| 92 | adjust_for_offset(loc, fOffset); |
| 93 | GrContext* context = fTexture->getContext(); |
| jvanverth | 8e80d17 | 2014-06-19 12:01:10 -0700 | [diff] [blame^] | 94 | TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("skia.gpu"), "GrPlot::uploadToTexture"); |
| commit-bot@chromium.org | 7801faa | 2014-05-14 15:14:51 +0000 | [diff] [blame] | 95 | context->writeTexturePixels(fTexture, |
| 96 | loc->fX, loc->fY, width, height, |
| 97 | fTexture->config(), image, 0, |
| 98 | GrContext::kDontFlush_PixelOpsFlag); |
| 99 | } |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 100 | |
| commit-bot@chromium.org | 67ed64e | 2013-08-05 19:42:56 +0000 | [diff] [blame] | 101 | #if FONT_CACHE_STATS |
| 102 | ++g_UploadCount; |
| 103 | #endif |
| 104 | |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 105 | return true; |
| 106 | } |
| 107 | |
| commit-bot@chromium.org | 7801faa | 2014-05-14 15:14:51 +0000 | [diff] [blame] | 108 | void GrPlot::uploadToTexture() { |
| 109 | static const float kNearlyFullTolerance = 0.85f; |
| 110 | |
| 111 | // should only do this if batching is enabled |
| 112 | SkASSERT(fBatchUploads); |
| 113 | |
| 114 | if (fDirty) { |
| jvanverth | 8e80d17 | 2014-06-19 12:01:10 -0700 | [diff] [blame^] | 115 | TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("skia.gpu"), "GrPlot::uploadToTexture"); |
| commit-bot@chromium.org | 7801faa | 2014-05-14 15:14:51 +0000 | [diff] [blame] | 116 | SkASSERT(NULL != fTexture); |
| 117 | GrContext* context = fTexture->getContext(); |
| 118 | // We pass the flag that does not force a flush. We assume our caller is |
| 119 | // smart and hasn't referenced the part of the texture we're about to update |
| 120 | // since the last flush. |
| jvanverth | 8e80d17 | 2014-06-19 12:01:10 -0700 | [diff] [blame^] | 121 | size_t rowBytes = fBytesPerPixel*fRects->width(); |
| commit-bot@chromium.org | 7801faa | 2014-05-14 15:14:51 +0000 | [diff] [blame] | 122 | const unsigned char* dataPtr = fPlotData; |
| 123 | dataPtr += rowBytes*fDirtyRect.fTop; |
| 124 | dataPtr += fBytesPerPixel*fDirtyRect.fLeft; |
| 125 | context->writeTexturePixels(fTexture, |
| skia.committer@gmail.com | a1633da | 2014-05-15 03:03:58 +0000 | [diff] [blame] | 126 | fOffset.fX + fDirtyRect.fLeft, fOffset.fY + fDirtyRect.fTop, |
| commit-bot@chromium.org | 7801faa | 2014-05-14 15:14:51 +0000 | [diff] [blame] | 127 | fDirtyRect.width(), fDirtyRect.height(), |
| skia.committer@gmail.com | a1633da | 2014-05-15 03:03:58 +0000 | [diff] [blame] | 128 | fTexture->config(), dataPtr, |
| commit-bot@chromium.org | 7801faa | 2014-05-14 15:14:51 +0000 | [diff] [blame] | 129 | rowBytes, |
| 130 | GrContext::kDontFlush_PixelOpsFlag); |
| 131 | fDirtyRect.setEmpty(); |
| 132 | fDirty = false; |
| 133 | // If the Plot is nearly full, anything else we add will probably be small and one |
| 134 | // at a time, so free up the memory and after this upload any new images directly. |
| 135 | if (fRects->percentFull() > kNearlyFullTolerance) { |
| 136 | SkDELETE_ARRAY(fPlotData); |
| 137 | fPlotData = NULL; |
| 138 | } |
| 139 | } |
| 140 | } |
| 141 | |
| skia.committer@gmail.com | ade9a34 | 2014-03-04 03:02:32 +0000 | [diff] [blame] | 142 | void GrPlot::resetRects() { |
| 143 | SkASSERT(NULL != fRects); |
| 144 | fRects->reset(); |
| commit-bot@chromium.org | c9b2c88 | 2014-03-03 14:30:25 +0000 | [diff] [blame] | 145 | } |
| 146 | |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 147 | /////////////////////////////////////////////////////////////////////////////// |
| 148 | |
| skia.committer@gmail.com | c282ba8 | 2014-04-02 03:05:59 +0000 | [diff] [blame] | 149 | GrAtlasMgr::GrAtlasMgr(GrGpu* gpu, GrPixelConfig config, |
| commit-bot@chromium.org | 53e1e4d | 2014-04-01 16:25:11 +0000 | [diff] [blame] | 150 | const SkISize& backingTextureSize, |
| commit-bot@chromium.org | 7801faa | 2014-05-14 15:14:51 +0000 | [diff] [blame] | 151 | int numPlotsX, int numPlotsY, bool batchUploads) { |
| commit-bot@chromium.org | 53e1e4d | 2014-04-01 16:25:11 +0000 | [diff] [blame] | 152 | fGpu = SkRef(gpu); |
| commit-bot@chromium.org | 9529441 | 2013-09-26 15:28:40 +0000 | [diff] [blame] | 153 | fPixelConfig = config; |
| commit-bot@chromium.org | 53e1e4d | 2014-04-01 16:25:11 +0000 | [diff] [blame] | 154 | fBackingTextureSize = backingTextureSize; |
| 155 | fNumPlotsX = numPlotsX; |
| 156 | fNumPlotsY = numPlotsY; |
| commit-bot@chromium.org | 7801faa | 2014-05-14 15:14:51 +0000 | [diff] [blame] | 157 | fBatchUploads = batchUploads; |
| commit-bot@chromium.org | 3fddf0e | 2013-09-26 12:57:19 +0000 | [diff] [blame] | 158 | fTexture = NULL; |
| skia.committer@gmail.com | 50df4d0 | 2013-09-28 07:01:33 +0000 | [diff] [blame] | 159 | |
| commit-bot@chromium.org | 7801faa | 2014-05-14 15:14:51 +0000 | [diff] [blame] | 160 | int textureWidth = fBackingTextureSize.width(); |
| 161 | int textureHeight = fBackingTextureSize.height(); |
| commit-bot@chromium.org | 53e1e4d | 2014-04-01 16:25:11 +0000 | [diff] [blame] | 162 | |
| commit-bot@chromium.org | 7801faa | 2014-05-14 15:14:51 +0000 | [diff] [blame] | 163 | int plotWidth = textureWidth / fNumPlotsX; |
| 164 | int plotHeight = textureHeight / fNumPlotsY; |
| 165 | |
| 166 | SkASSERT(plotWidth * fNumPlotsX == textureWidth); |
| 167 | SkASSERT(plotHeight * fNumPlotsY == textureHeight); |
| commit-bot@chromium.org | 53e1e4d | 2014-04-01 16:25:11 +0000 | [diff] [blame] | 168 | |
| commit-bot@chromium.org | 6e7ddaa | 2014-05-30 13:55:58 +0000 | [diff] [blame] | 169 | // We currently do not support compressed atlases... |
| 170 | SkASSERT(!GrPixelConfigIsCompressed(config)); |
| 171 | |
| commit-bot@chromium.org | 7d330eb | 2013-09-27 19:39:38 +0000 | [diff] [blame] | 172 | // set up allocated plots |
| robertphillips@google.com | 8b16931 | 2013-10-15 17:47:36 +0000 | [diff] [blame] | 173 | size_t bpp = GrBytesPerPixel(fPixelConfig); |
| commit-bot@chromium.org | 53e1e4d | 2014-04-01 16:25:11 +0000 | [diff] [blame] | 174 | fPlotArray = SkNEW_ARRAY(GrPlot, (fNumPlotsX*fNumPlotsY)); |
| commit-bot@chromium.org | c9b2c88 | 2014-03-03 14:30:25 +0000 | [diff] [blame] | 175 | |
| 176 | GrPlot* currPlot = fPlotArray; |
| commit-bot@chromium.org | 53e1e4d | 2014-04-01 16:25:11 +0000 | [diff] [blame] | 177 | for (int y = numPlotsY-1; y >= 0; --y) { |
| 178 | for (int x = numPlotsX-1; x >= 0; --x) { |
| commit-bot@chromium.org | 7801faa | 2014-05-14 15:14:51 +0000 | [diff] [blame] | 179 | currPlot->init(this, x, y, plotWidth, plotHeight, bpp, batchUploads); |
| skia.committer@gmail.com | 50df4d0 | 2013-09-28 07:01:33 +0000 | [diff] [blame] | 180 | |
| commit-bot@chromium.org | c9b2c88 | 2014-03-03 14:30:25 +0000 | [diff] [blame] | 181 | // build LRU list |
| 182 | fPlotList.addToHead(currPlot); |
| commit-bot@chromium.org | 7d330eb | 2013-09-27 19:39:38 +0000 | [diff] [blame] | 183 | ++currPlot; |
| 184 | } |
| 185 | } |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | GrAtlasMgr::~GrAtlasMgr() { |
| commit-bot@chromium.org | 3fddf0e | 2013-09-26 12:57:19 +0000 | [diff] [blame] | 189 | SkSafeUnref(fTexture); |
| commit-bot@chromium.org | c9b2c88 | 2014-03-03 14:30:25 +0000 | [diff] [blame] | 190 | SkDELETE_ARRAY(fPlotArray); |
| commit-bot@chromium.org | 67ed64e | 2013-08-05 19:42:56 +0000 | [diff] [blame] | 191 | |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 192 | fGpu->unref(); |
| commit-bot@chromium.org | 67ed64e | 2013-08-05 19:42:56 +0000 | [diff] [blame] | 193 | #if FONT_CACHE_STATS |
| 194 | GrPrintf("Num uploads: %d\n", g_UploadCount); |
| 195 | #endif |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 196 | } |
| 197 | |
| commit-bot@chromium.org | c9b2c88 | 2014-03-03 14:30:25 +0000 | [diff] [blame] | 198 | void GrAtlasMgr::moveToHead(GrPlot* plot) { |
| 199 | if (fPlotList.head() == plot) { |
| 200 | return; |
| 201 | } |
| skia.committer@gmail.com | ade9a34 | 2014-03-04 03:02:32 +0000 | [diff] [blame] | 202 | |
| commit-bot@chromium.org | c9b2c88 | 2014-03-03 14:30:25 +0000 | [diff] [blame] | 203 | fPlotList.remove(plot); |
| 204 | fPlotList.addToHead(plot); |
| 205 | }; |
| 206 | |
| commit-bot@chromium.org | 7d330eb | 2013-09-27 19:39:38 +0000 | [diff] [blame] | 207 | GrPlot* GrAtlasMgr::addToAtlas(GrAtlas* atlas, |
| 208 | int width, int height, const void* image, |
| robertphillips | d537341 | 2014-06-02 10:20:14 -0700 | [diff] [blame] | 209 | SkIPoint16* loc) { |
| commit-bot@chromium.org | c9b2c88 | 2014-03-03 14:30:25 +0000 | [diff] [blame] | 210 | // iterate through entire plot list for this atlas, see if we can find a hole |
| 211 | // last one was most recently added and probably most empty |
| 212 | for (int i = atlas->fPlots.count()-1; i >= 0; --i) { |
| 213 | GrPlot* plot = atlas->fPlots[i]; |
| 214 | if (plot->addSubImage(width, height, image, loc)) { |
| 215 | this->moveToHead(plot); |
| 216 | return plot; |
| commit-bot@chromium.org | 67ed64e | 2013-08-05 19:42:56 +0000 | [diff] [blame] | 217 | } |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 218 | } |
| 219 | |
| commit-bot@chromium.org | c9b2c88 | 2014-03-03 14:30:25 +0000 | [diff] [blame] | 220 | // before we get a new plot, make sure we have a backing texture |
| commit-bot@chromium.org | 3fddf0e | 2013-09-26 12:57:19 +0000 | [diff] [blame] | 221 | if (NULL == fTexture) { |
| bsalomon@google.com | 95ed55a | 2013-01-24 14:46:47 +0000 | [diff] [blame] | 222 | // TODO: Update this to use the cache rather than directly creating a texture. |
| robertphillips@google.com | 75b3c96 | 2012-06-07 12:08:45 +0000 | [diff] [blame] | 223 | GrTextureDesc desc; |
| 224 | desc.fFlags = kDynamicUpdate_GrTextureFlagBit; |
| commit-bot@chromium.org | 53e1e4d | 2014-04-01 16:25:11 +0000 | [diff] [blame] | 225 | desc.fWidth = fBackingTextureSize.width(); |
| 226 | desc.fHeight = fBackingTextureSize.height(); |
| commit-bot@chromium.org | 9529441 | 2013-09-26 15:28:40 +0000 | [diff] [blame] | 227 | desc.fConfig = fPixelConfig; |
| robertphillips@google.com | 75b3c96 | 2012-06-07 12:08:45 +0000 | [diff] [blame] | 228 | |
| commit-bot@chromium.org | 3fddf0e | 2013-09-26 12:57:19 +0000 | [diff] [blame] | 229 | fTexture = fGpu->createTexture(desc, NULL, 0); |
| 230 | if (NULL == fTexture) { |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 231 | return NULL; |
| 232 | } |
| 233 | } |
| skia.committer@gmail.com | 50df4d0 | 2013-09-28 07:01:33 +0000 | [diff] [blame] | 234 | |
| commit-bot@chromium.org | c9b2c88 | 2014-03-03 14:30:25 +0000 | [diff] [blame] | 235 | // now look through all allocated plots for one we can share, in MRU order |
| 236 | GrPlotList::Iter plotIter; |
| 237 | plotIter.init(fPlotList, GrPlotList::Iter::kHead_IterStart); |
| 238 | GrPlot* plot; |
| 239 | while (NULL != (plot = plotIter.get())) { |
| 240 | // make sure texture is set for quick lookup |
| 241 | plot->fTexture = fTexture; |
| 242 | if (plot->addSubImage(width, height, image, loc)) { |
| 243 | this->moveToHead(plot); |
| 244 | // new plot for atlas, put at end of array |
| 245 | *(atlas->fPlots.append()) = plot; |
| 246 | return plot; |
| 247 | } |
| 248 | plotIter.next(); |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 249 | } |
| 250 | |
| commit-bot@chromium.org | c9b2c88 | 2014-03-03 14:30:25 +0000 | [diff] [blame] | 251 | // If the above fails, then the current plot list has no room |
| 252 | return NULL; |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 253 | } |
| 254 | |
| commit-bot@chromium.org | c9b2c88 | 2014-03-03 14:30:25 +0000 | [diff] [blame] | 255 | bool GrAtlasMgr::removePlot(GrAtlas* atlas, const GrPlot* plot) { |
| 256 | // iterate through plot list for this atlas |
| 257 | int count = atlas->fPlots.count(); |
| 258 | for (int i = 0; i < count; ++i) { |
| 259 | if (plot == atlas->fPlots[i]) { |
| 260 | atlas->fPlots.remove(i); |
| 261 | return true; |
| commit-bot@chromium.org | 7d330eb | 2013-09-27 19:39:38 +0000 | [diff] [blame] | 262 | } |
| 263 | } |
| skia.committer@gmail.com | 50df4d0 | 2013-09-28 07:01:33 +0000 | [diff] [blame] | 264 | |
| commit-bot@chromium.org | c9b2c88 | 2014-03-03 14:30:25 +0000 | [diff] [blame] | 265 | return false; |
| commit-bot@chromium.org | 7d330eb | 2013-09-27 19:39:38 +0000 | [diff] [blame] | 266 | } |
| 267 | |
| commit-bot@chromium.org | c9b2c88 | 2014-03-03 14:30:25 +0000 | [diff] [blame] | 268 | // get a plot that's not being used by the current draw |
| 269 | GrPlot* GrAtlasMgr::getUnusedPlot() { |
| 270 | GrPlotList::Iter plotIter; |
| 271 | plotIter.init(fPlotList, GrPlotList::Iter::kTail_IterStart); |
| 272 | GrPlot* plot; |
| 273 | while (NULL != (plot = plotIter.get())) { |
| 274 | if (plot->drawToken().isIssued()) { |
| 275 | return plot; |
| 276 | } |
| 277 | plotIter.prev(); |
| commit-bot@chromium.org | 7d330eb | 2013-09-27 19:39:38 +0000 | [diff] [blame] | 278 | } |
| skia.committer@gmail.com | 50df4d0 | 2013-09-28 07:01:33 +0000 | [diff] [blame] | 279 | |
| commit-bot@chromium.org | c9b2c88 | 2014-03-03 14:30:25 +0000 | [diff] [blame] | 280 | return NULL; |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 281 | } |
| commit-bot@chromium.org | 7801faa | 2014-05-14 15:14:51 +0000 | [diff] [blame] | 282 | |
| 283 | void GrAtlasMgr::uploadPlotsToTexture() { |
| 284 | if (fBatchUploads) { |
| 285 | GrPlotList::Iter plotIter; |
| 286 | plotIter.init(fPlotList, GrPlotList::Iter::kHead_IterStart); |
| 287 | GrPlot* plot; |
| 288 | while (NULL != (plot = plotIter.get())) { |
| 289 | plot->uploadToTexture(); |
| 290 | plotIter.next(); |
| 291 | } |
| 292 | } |
| 293 | } |