joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "src/gpu/GrDrawOpAtlas.h" |
Robert Phillips | 32f2818 | 2017-02-28 16:20:03 -0500 | [diff] [blame] | 9 | |
John Stiles | fbd050b | 2020-08-03 13:21:46 -0400 | [diff] [blame] | 10 | #include <memory> |
| 11 | |
Robert Phillips | 03e4c95 | 2019-11-26 16:20:22 -0500 | [diff] [blame] | 12 | #include "src/core/SkOpts.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 13 | #include "src/gpu/GrOnFlushResourceProvider.h" |
| 14 | #include "src/gpu/GrOpFlushState.h" |
| 15 | #include "src/gpu/GrProxyProvider.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 16 | #include "src/gpu/GrResourceProvider.h" |
Greg Daniel | 7fd7a8a | 2019-10-10 16:10:31 -0400 | [diff] [blame] | 17 | #include "src/gpu/GrResourceProviderPriv.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 18 | #include "src/gpu/GrSurfaceProxyPriv.h" |
Greg Daniel | 456f9b5 | 2020-03-05 19:14:18 +0000 | [diff] [blame] | 19 | #include "src/gpu/GrTexture.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 20 | #include "src/gpu/GrTracing.h" |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 21 | |
Jim Van Verth | fb39510 | 2020-02-03 10:11:19 -0500 | [diff] [blame] | 22 | #ifdef DUMP_ATLAS_DATA |
| 23 | static bool gDumpAtlasData = false; |
| 24 | #endif |
| 25 | |
Robert Phillips | e87106d | 2020-04-09 14:21:33 -0400 | [diff] [blame] | 26 | #ifdef SK_DEBUG |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame^] | 27 | void GrDrawOpAtlas::validate(const AtlasLocator& atlasLocator) const { |
Robert Phillips | e87106d | 2020-04-09 14:21:33 -0400 | [diff] [blame] | 28 | // Verify that the plotIndex stored in the PlotLocator is consistent with the glyph rectangle |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame^] | 29 | int numPlotsX = fTextureWidth / fPlotWidth; |
| 30 | int numPlotsY = fTextureHeight / fPlotHeight; |
Robert Phillips | e87106d | 2020-04-09 14:21:33 -0400 | [diff] [blame] | 31 | |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame^] | 32 | int plotIndex = atlasLocator.plotIndex(); |
| 33 | auto rect = atlasLocator.rect(); |
| 34 | int plotX = rect.fLeft / fPlotWidth; |
| 35 | int plotY = rect.fTop / fPlotHeight; |
Robert Phillips | e87106d | 2020-04-09 14:21:33 -0400 | [diff] [blame] | 36 | SkASSERT(plotIndex == (numPlotsY - plotY - 1) * numPlotsX + (numPlotsX - plotX - 1)); |
| 37 | } |
| 38 | #endif |
| 39 | |
Robert Phillips | cd5099c | 2018-02-09 09:56:56 -0500 | [diff] [blame] | 40 | // When proxy allocation is deferred until flush time the proxies acting as atlases require |
| 41 | // special handling. This is because the usage that can be determined from the ops themselves |
| 42 | // isn't sufficient. Independent of the ops there will be ASAP and inline uploads to the |
| 43 | // atlases. Extending the usage interval of any op that uses an atlas to the start of the |
| 44 | // flush (as is done for proxies that are used for sw-generated masks) also won't work because |
| 45 | // the atlas persists even beyond the last use in an op - for a given flush. Given this, atlases |
| 46 | // must explicitly manage the lifetime of their backing proxies via the onFlushCallback system |
| 47 | // (which calls this method). |
| 48 | void GrDrawOpAtlas::instantiate(GrOnFlushResourceProvider* onFlushResourceProvider) { |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 49 | for (uint32_t i = 0; i < fNumActivePages; ++i) { |
| 50 | // All the atlas pages are now instantiated at flush time in the activeNewPage method. |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 51 | SkASSERT(fViews[i].proxy() && fViews[i].proxy()->isInstantiated()); |
Robert Phillips | cd5099c | 2018-02-09 09:56:56 -0500 | [diff] [blame] | 52 | } |
| 53 | } |
| 54 | |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 55 | std::unique_ptr<GrDrawOpAtlas> GrDrawOpAtlas::Make(GrProxyProvider* proxyProvider, |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 56 | const GrBackendFormat& format, |
Robert Phillips | 42dda08 | 2019-05-14 13:29:45 -0400 | [diff] [blame] | 57 | GrColorType colorType, int width, |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 58 | int height, int plotWidth, int plotHeight, |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 59 | GenerationCounter* generationCounter, |
Brian Salomon | 9f545bc | 2017-11-06 10:36:57 -0500 | [diff] [blame] | 60 | AllowMultitexturing allowMultitexturing, |
Herb Derby | 1a496c5 | 2020-01-22 17:26:56 -0500 | [diff] [blame] | 61 | EvictionCallback* evictor) { |
Robert Phillips | 0a15cc6 | 2019-07-30 12:49:10 -0400 | [diff] [blame] | 62 | if (!format.isValid()) { |
| 63 | return nullptr; |
| 64 | } |
| 65 | |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 66 | std::unique_ptr<GrDrawOpAtlas> atlas(new GrDrawOpAtlas(proxyProvider, format, colorType, |
| 67 | width, height, plotWidth, plotHeight, |
| 68 | generationCounter, |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 69 | allowMultitexturing)); |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 70 | if (!atlas->getViews()[0].proxy()) { |
Jim Van Verth | d74f3f2 | 2017-08-31 16:44:08 -0400 | [diff] [blame] | 71 | return nullptr; |
| 72 | } |
| 73 | |
Herb Derby | a90ed95 | 2020-01-28 15:55:58 -0500 | [diff] [blame] | 74 | if (evictor != nullptr) { |
| 75 | atlas->fEvictionCallbacks.emplace_back(evictor); |
| 76 | } |
Robert Phillips | 256c37b | 2017-03-01 14:32:46 -0500 | [diff] [blame] | 77 | return atlas; |
| 78 | } |
| 79 | |
Jim Van Verth | fb39510 | 2020-02-03 10:11:19 -0500 | [diff] [blame] | 80 | std::tuple<uint16_t, uint16_t, int> GrDrawOpAtlas::UnpackIndexFromTexCoords(uint16_t u, |
| 81 | uint16_t v) { |
| 82 | int pageIndex = 0; |
| 83 | if (u & 0x1) { |
| 84 | pageIndex |= 0x2; |
| 85 | } |
| 86 | if (v & 0x1) { |
| 87 | pageIndex |= 0x1; |
| 88 | } |
| 89 | return std::make_tuple(u >> 1, v >> 1, pageIndex); |
| 90 | } |
Robert Phillips | 256c37b | 2017-03-01 14:32:46 -0500 | [diff] [blame] | 91 | |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 92 | //////////////////////////////////////////////////////////////////////////////// |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 93 | GrDrawOpAtlas::Plot::Plot(int pageIndex, int plotIndex, GenerationCounter* generationCounter, |
| 94 | int offX, int offY, int width, int height, GrColorType colorType) |
Brian Salomon | 943ed79 | 2017-10-30 09:37:55 -0400 | [diff] [blame] | 95 | : fLastUpload(GrDeferredUploadToken::AlreadyFlushedToken()) |
| 96 | , fLastUse(GrDeferredUploadToken::AlreadyFlushedToken()) |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 97 | , fFlushesSinceLastUse(0) |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 98 | , fPageIndex(pageIndex) |
| 99 | , fPlotIndex(plotIndex) |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 100 | , fGenerationCounter(generationCounter) |
| 101 | , fGenID(fGenerationCounter->next()) |
Robert Phillips | bf5bf74 | 2020-04-13 09:29:08 -0400 | [diff] [blame] | 102 | , fPlotLocator(fPageIndex, fPlotIndex, fGenID) |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 103 | , fData(nullptr) |
| 104 | , fWidth(width) |
| 105 | , fHeight(height) |
| 106 | , fX(offX) |
| 107 | , fY(offY) |
Herb Derby | 73c7587 | 2020-01-22 18:09:16 -0500 | [diff] [blame] | 108 | , fRectanizer(width, height) |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 109 | , fOffset(SkIPoint16::Make(fX * fWidth, fY * fHeight)) |
Robert Phillips | 42dda08 | 2019-05-14 13:29:45 -0400 | [diff] [blame] | 110 | , fColorType(colorType) |
| 111 | , fBytesPerPixel(GrColorTypeBytesPerPixel(colorType)) |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 112 | #ifdef SK_DEBUG |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 113 | , fDirty(false) |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 114 | #endif |
| 115 | { |
Jim Van Verth | a8c55fa | 2018-02-20 15:38:08 -0500 | [diff] [blame] | 116 | // We expect the allocated dimensions to be a multiple of 4 bytes |
| 117 | SkASSERT(((width*fBytesPerPixel) & 0x3) == 0); |
| 118 | // The padding for faster uploads only works for 1, 2 and 4 byte texels |
| 119 | SkASSERT(fBytesPerPixel != 3 && fBytesPerPixel <= 4); |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 120 | fDirtyRect.setEmpty(); |
| 121 | } |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 122 | |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 123 | GrDrawOpAtlas::Plot::~Plot() { |
jvanverth | c3d706f | 2016-04-20 10:33:27 -0700 | [diff] [blame] | 124 | sk_free(fData); |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 125 | } |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 126 | |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame^] | 127 | bool GrDrawOpAtlas::Plot::addSubImage( |
| 128 | int width, int height, const void* image, AtlasLocator* atlasLocator) { |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 129 | SkASSERT(width <= fWidth && height <= fHeight); |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 130 | |
Robert Phillips | 6d3bc29 | 2020-04-06 10:29:28 -0400 | [diff] [blame] | 131 | SkIPoint16 loc; |
| 132 | if (!fRectanizer.addRect(width, height, &loc)) { |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 133 | return false; |
joshualitt | b4c507e | 2015-04-08 08:07:59 -0700 | [diff] [blame] | 134 | } |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 135 | |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame^] | 136 | GrIRect16 rect = GrIRect16::MakeXYWH(loc.fX, loc.fY, width, height); |
Robert Phillips | 6d3bc29 | 2020-04-06 10:29:28 -0400 | [diff] [blame] | 137 | |
jvanverth | c3d706f | 2016-04-20 10:33:27 -0700 | [diff] [blame] | 138 | if (!fData) { |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame^] | 139 | fData = reinterpret_cast<unsigned char*>( |
| 140 | sk_calloc_throw(fBytesPerPixel * fWidth * fHeight)); |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 141 | } |
| 142 | size_t rowBytes = width * fBytesPerPixel; |
| 143 | const unsigned char* imagePtr = (const unsigned char*)image; |
| 144 | // point ourselves at the right starting spot |
jvanverth | c3d706f | 2016-04-20 10:33:27 -0700 | [diff] [blame] | 145 | unsigned char* dataPtr = fData; |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame^] | 146 | dataPtr += fBytesPerPixel * fWidth * rect.fTop; |
| 147 | dataPtr += fBytesPerPixel * rect.fLeft; |
Brian Osman | cce3e58 | 2016-10-14 11:42:20 -0400 | [diff] [blame] | 148 | // copy into the data buffer, swizzling as we go if this is ARGB data |
Greg Daniel | b58a3c7 | 2020-01-23 10:05:14 -0500 | [diff] [blame] | 149 | if (4 == fBytesPerPixel && kN32_SkColorType == kBGRA_8888_SkColorType) { |
Brian Osman | cce3e58 | 2016-10-14 11:42:20 -0400 | [diff] [blame] | 150 | for (int i = 0; i < height; ++i) { |
Mike Klein | 6e78ae5 | 2018-09-19 13:37:16 -0400 | [diff] [blame] | 151 | SkOpts::RGBA_to_BGRA((uint32_t*)dataPtr, (const uint32_t*)imagePtr, width); |
Brian Osman | cce3e58 | 2016-10-14 11:42:20 -0400 | [diff] [blame] | 152 | dataPtr += fBytesPerPixel * fWidth; |
| 153 | imagePtr += rowBytes; |
| 154 | } |
| 155 | } else { |
| 156 | for (int i = 0; i < height; ++i) { |
| 157 | memcpy(dataPtr, imagePtr, rowBytes); |
| 158 | dataPtr += fBytesPerPixel * fWidth; |
| 159 | imagePtr += rowBytes; |
| 160 | } |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 161 | } |
| 162 | |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame^] | 163 | fDirtyRect.join({rect.fLeft, rect.fTop, rect.fRight, rect.fBottom}); |
robertphillips | 2b0536f | 2015-11-06 14:10:42 -0800 | [diff] [blame] | 164 | |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame^] | 165 | rect.offset(fOffset.fX, fOffset.fY); |
| 166 | atlasLocator->updateRect(rect); |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 167 | SkDEBUGCODE(fDirty = true;) |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 168 | |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 169 | return true; |
| 170 | } |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 171 | |
Brian Salomon | 943ed79 | 2017-10-30 09:37:55 -0400 | [diff] [blame] | 172 | void GrDrawOpAtlas::Plot::uploadToTexture(GrDeferredTextureUploadWritePixelsFn& writePixels, |
Robert Phillips | acaa607 | 2017-07-28 10:54:53 -0400 | [diff] [blame] | 173 | GrTextureProxy* proxy) { |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 174 | // We should only be issuing uploads if we are in fact dirty |
Brian Salomon | fd98c2c | 2018-07-31 17:25:29 -0400 | [diff] [blame] | 175 | SkASSERT(fDirty && fData && proxy && proxy->peekTexture()); |
Brian Osman | 39c08ac | 2017-07-26 09:36:09 -0400 | [diff] [blame] | 176 | TRACE_EVENT0("skia.gpu", TRACE_FUNC); |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 177 | size_t rowBytes = fBytesPerPixel * fWidth; |
jvanverth | c3d706f | 2016-04-20 10:33:27 -0700 | [diff] [blame] | 178 | const unsigned char* dataPtr = fData; |
Jim Van Verth | a8c55fa | 2018-02-20 15:38:08 -0500 | [diff] [blame] | 179 | // Clamp to 4-byte aligned boundaries |
| 180 | unsigned int clearBits = 0x3 / fBytesPerPixel; |
| 181 | fDirtyRect.fLeft &= ~clearBits; |
| 182 | fDirtyRect.fRight += clearBits; |
| 183 | fDirtyRect.fRight &= ~clearBits; |
| 184 | SkASSERT(fDirtyRect.fRight <= fWidth); |
| 185 | // Set up dataPtr |
jvanverth | c3d706f | 2016-04-20 10:33:27 -0700 | [diff] [blame] | 186 | dataPtr += rowBytes * fDirtyRect.fTop; |
| 187 | dataPtr += fBytesPerPixel * fDirtyRect.fLeft; |
Robert Phillips | 42dda08 | 2019-05-14 13:29:45 -0400 | [diff] [blame] | 188 | |
Robert Phillips | acaa607 | 2017-07-28 10:54:53 -0400 | [diff] [blame] | 189 | writePixels(proxy, fOffset.fX + fDirtyRect.fLeft, fOffset.fY + fDirtyRect.fTop, |
Robert Phillips | 42dda08 | 2019-05-14 13:29:45 -0400 | [diff] [blame] | 190 | fDirtyRect.width(), fDirtyRect.height(), fColorType, dataPtr, rowBytes); |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 191 | fDirtyRect.setEmpty(); |
| 192 | SkDEBUGCODE(fDirty = false;) |
| 193 | } |
| 194 | |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 195 | void GrDrawOpAtlas::Plot::resetRects() { |
Herb Derby | 73c7587 | 2020-01-22 18:09:16 -0500 | [diff] [blame] | 196 | fRectanizer.reset(); |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 197 | |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 198 | fGenID = fGenerationCounter->next(); |
Robert Phillips | bf5bf74 | 2020-04-13 09:29:08 -0400 | [diff] [blame] | 199 | fPlotLocator = PlotLocator(fPageIndex, fPlotIndex, fGenID); |
Brian Salomon | 943ed79 | 2017-10-30 09:37:55 -0400 | [diff] [blame] | 200 | fLastUpload = GrDeferredUploadToken::AlreadyFlushedToken(); |
| 201 | fLastUse = GrDeferredUploadToken::AlreadyFlushedToken(); |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 202 | |
| 203 | // zero out the plot |
jvanverth | c3d706f | 2016-04-20 10:33:27 -0700 | [diff] [blame] | 204 | if (fData) { |
| 205 | sk_bzero(fData, fBytesPerPixel * fWidth * fHeight); |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 206 | } |
| 207 | |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 208 | fDirtyRect.setEmpty(); |
| 209 | SkDEBUGCODE(fDirty = false;) |
| 210 | } |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 211 | |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 212 | /////////////////////////////////////////////////////////////////////////////// |
| 213 | |
Robert Phillips | a4bb064 | 2020-08-11 09:55:17 -0400 | [diff] [blame] | 214 | GrDrawOpAtlas::GrDrawOpAtlas(GrProxyProvider* proxyProvider, const GrBackendFormat& format, |
| 215 | GrColorType colorType, int width, int height, |
| 216 | int plotWidth, int plotHeight, GenerationCounter* generationCounter, |
| 217 | AllowMultitexturing allowMultitexturing) |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 218 | : fFormat(format) |
Robert Phillips | 42dda08 | 2019-05-14 13:29:45 -0400 | [diff] [blame] | 219 | , fColorType(colorType) |
Jim Van Verth | d74f3f2 | 2017-08-31 16:44:08 -0400 | [diff] [blame] | 220 | , fTextureWidth(width) |
| 221 | , fTextureHeight(height) |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 222 | , fPlotWidth(plotWidth) |
| 223 | , fPlotHeight(plotHeight) |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 224 | , fGenerationCounter(generationCounter) |
| 225 | , fAtlasGeneration(fGenerationCounter->next()) |
Brian Salomon | 943ed79 | 2017-10-30 09:37:55 -0400 | [diff] [blame] | 226 | , fPrevFlushToken(GrDeferredUploadToken::AlreadyFlushedToken()) |
Jim Van Verth | 77eb96d | 2020-03-18 12:32:34 -0400 | [diff] [blame] | 227 | , fFlushesSinceLastUse(0) |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 228 | , fMaxPages(AllowMultitexturing::kYes == allowMultitexturing ? kMaxMultitexturePages : 1) |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 229 | , fNumActivePages(0) { |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 230 | int numPlotsX = width/plotWidth; |
| 231 | int numPlotsY = height/plotHeight; |
Herb Derby | bbf5fb5 | 2018-10-15 16:39:39 -0400 | [diff] [blame] | 232 | SkASSERT(numPlotsX * numPlotsY <= GrDrawOpAtlas::kMaxPlots); |
Jim Van Verth | d74f3f2 | 2017-08-31 16:44:08 -0400 | [diff] [blame] | 233 | SkASSERT(fPlotWidth * numPlotsX == fTextureWidth); |
| 234 | SkASSERT(fPlotHeight * numPlotsY == fTextureHeight); |
robertphillips | 2b0536f | 2015-11-06 14:10:42 -0800 | [diff] [blame] | 235 | |
Jim Van Verth | 06f593c | 2018-02-20 11:30:10 -0500 | [diff] [blame] | 236 | fNumPlots = numPlotsX * numPlotsY; |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 237 | |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 238 | this->createPages(proxyProvider, generationCounter); |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 239 | } |
| 240 | |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 241 | inline void GrDrawOpAtlas::processEviction(PlotLocator plotLocator) { |
John Stiles | bd3ffa4 | 2020-07-30 20:24:57 -0400 | [diff] [blame] | 242 | for (EvictionCallback* evictor : fEvictionCallbacks) { |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 243 | evictor->evict(plotLocator); |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 244 | } |
Herb Derby | 1a496c5 | 2020-01-22 17:26:56 -0500 | [diff] [blame] | 245 | |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 246 | fAtlasGeneration = fGenerationCounter->next(); |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 247 | } |
| 248 | |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 249 | inline bool GrDrawOpAtlas::updatePlot(GrDeferredUploadTarget* target, |
Robert Phillips | 6d3bc29 | 2020-04-06 10:29:28 -0400 | [diff] [blame] | 250 | AtlasLocator* atlasLocator, Plot* plot) { |
| 251 | int pageIdx = plot->pageIndex(); |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 252 | this->makeMRU(plot, pageIdx); |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 253 | |
| 254 | // If our most recent upload has already occurred then we have to insert a new |
| 255 | // upload. Otherwise, we already have a scheduled upload that hasn't yet ocurred. |
| 256 | // This new update will piggy back on that previously scheduled update. |
Robert Phillips | 40a29d7 | 2018-01-18 12:59:22 -0500 | [diff] [blame] | 257 | if (plot->lastUploadToken() < target->tokenTracker()->nextTokenToFlush()) { |
jvanverth | c3d706f | 2016-04-20 10:33:27 -0700 | [diff] [blame] | 258 | // With c+14 we could move sk_sp into lamba to only ref once. |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 259 | sk_sp<Plot> plotsp(SkRef(plot)); |
Robert Phillips | 256c37b | 2017-03-01 14:32:46 -0500 | [diff] [blame] | 260 | |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 261 | GrTextureProxy* proxy = fViews[pageIdx].asTextureProxy(); |
| 262 | SkASSERT(proxy && proxy->isInstantiated()); // This is occurring at flush time |
Robert Phillips | 256c37b | 2017-03-01 14:32:46 -0500 | [diff] [blame] | 263 | |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 264 | GrDeferredUploadToken lastUploadToken = target->addASAPUpload( |
Brian Salomon | 943ed79 | 2017-10-30 09:37:55 -0400 | [diff] [blame] | 265 | [plotsp, proxy](GrDeferredTextureUploadWritePixelsFn& writePixels) { |
| 266 | plotsp->uploadToTexture(writePixels, proxy); |
| 267 | }); |
Robert Phillips | 256c37b | 2017-03-01 14:32:46 -0500 | [diff] [blame] | 268 | plot->setLastUploadToken(lastUploadToken); |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 269 | } |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame^] | 270 | atlasLocator->updatePlotLocator(plot->plotLocator()); |
| 271 | SkDEBUGCODE(this->validate(*atlasLocator);) |
Robert Phillips | 256c37b | 2017-03-01 14:32:46 -0500 | [diff] [blame] | 272 | return true; |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 273 | } |
| 274 | |
Robert Phillips | 6d3bc29 | 2020-04-06 10:29:28 -0400 | [diff] [blame] | 275 | bool GrDrawOpAtlas::uploadToPage(const GrCaps& caps, unsigned int pageIdx, |
Greg Daniel | 7fd7a8a | 2019-10-10 16:10:31 -0400 | [diff] [blame] | 276 | GrDeferredUploadTarget* target, int width, int height, |
Robert Phillips | 6d3bc29 | 2020-04-06 10:29:28 -0400 | [diff] [blame] | 277 | const void* image, AtlasLocator* atlasLocator) { |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 278 | SkASSERT(fViews[pageIdx].proxy() && fViews[pageIdx].proxy()->isInstantiated()); |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 279 | |
| 280 | // look through all allocated plots for one we can share, in Most Recently Refed order |
| 281 | PlotList::Iter plotIter; |
| 282 | plotIter.init(fPages[pageIdx].fPlotList, PlotList::Iter::kHead_IterStart); |
| 283 | |
| 284 | for (Plot* plot = plotIter.get(); plot; plot = plotIter.next()) { |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 285 | SkASSERT(caps.bytesPerPixel(fViews[pageIdx].proxy()->backendFormat()) == plot->bpp()); |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 286 | |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame^] | 287 | if (plot->addSubImage(width, height, image, atlasLocator)) { |
Robert Phillips | 6d3bc29 | 2020-04-06 10:29:28 -0400 | [diff] [blame] | 288 | return this->updatePlot(target, atlasLocator, plot); |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 289 | } |
| 290 | } |
| 291 | |
| 292 | return false; |
| 293 | } |
| 294 | |
Jim Van Verth | 62ea0cd | 2017-09-27 12:59:45 -0400 | [diff] [blame] | 295 | // Number of atlas-related flushes beyond which we consider a plot to no longer be in use. |
| 296 | // |
| 297 | // This value is somewhat arbitrary -- the idea is to keep it low enough that |
| 298 | // a page with unused plots will get removed reasonably quickly, but allow it |
| 299 | // to hang around for a bit in case it's needed. The assumption is that flushes |
| 300 | // are rare; i.e., we are not continually refreshing the frame. |
Jonathan Backer | 40c683a | 2020-05-04 15:00:02 -0400 | [diff] [blame] | 301 | static constexpr auto kPlotRecentlyUsedCount = 32; |
| 302 | static constexpr auto kAtlasRecentlyUsedCount = 128; |
Jim Van Verth | 62ea0cd | 2017-09-27 12:59:45 -0400 | [diff] [blame] | 303 | |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 304 | GrDrawOpAtlas::ErrorCode GrDrawOpAtlas::addToAtlas(GrResourceProvider* resourceProvider, |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 305 | GrDeferredUploadTarget* target, |
Robert Phillips | 6d3bc29 | 2020-04-06 10:29:28 -0400 | [diff] [blame] | 306 | int width, int height, const void* image, |
| 307 | AtlasLocator* atlasLocator) { |
bsalomon | 6d6b6ad | 2016-07-13 14:45:28 -0700 | [diff] [blame] | 308 | if (width > fPlotWidth || height > fPlotHeight) { |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 309 | return ErrorCode::kError; |
bsalomon | 6d6b6ad | 2016-07-13 14:45:28 -0700 | [diff] [blame] | 310 | } |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 311 | |
Greg Daniel | 7fd7a8a | 2019-10-10 16:10:31 -0400 | [diff] [blame] | 312 | const GrCaps& caps = *resourceProvider->caps(); |
| 313 | |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 314 | // Look through each page to see if we can upload without having to flush |
| 315 | // We prioritize this upload to the first pages, not the most recently used, to make it easier |
| 316 | // to remove unused pages in reverse page order. |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 317 | for (unsigned int pageIdx = 0; pageIdx < fNumActivePages; ++pageIdx) { |
Robert Phillips | 6d3bc29 | 2020-04-06 10:29:28 -0400 | [diff] [blame] | 318 | if (this->uploadToPage(caps, pageIdx, target, width, height, image, atlasLocator)) { |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 319 | return ErrorCode::kSucceeded; |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 320 | } |
Jim Van Verth | 712fe73 | 2017-09-25 16:53:49 -0400 | [diff] [blame] | 321 | } |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 322 | |
Jim Van Verth | 712fe73 | 2017-09-25 16:53:49 -0400 | [diff] [blame] | 323 | // If the above fails, then see if the least recently used plot per page has already been |
Jim Van Verth | 62ea0cd | 2017-09-27 12:59:45 -0400 | [diff] [blame] | 324 | // flushed to the gpu if we're at max page allocation, or if the plot has aged out otherwise. |
| 325 | // We wait until we've grown to the full number of pages to begin evicting already flushed |
| 326 | // plots so that we can maximize the opportunity for reuse. |
Jim Van Verth | 712fe73 | 2017-09-25 16:53:49 -0400 | [diff] [blame] | 327 | // As before we prioritize this upload to the first pages, not the most recently used. |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 328 | if (fNumActivePages == this->maxPages()) { |
| 329 | for (unsigned int pageIdx = 0; pageIdx < fNumActivePages; ++pageIdx) { |
| 330 | Plot* plot = fPages[pageIdx].fPlotList.tail(); |
| 331 | SkASSERT(plot); |
Jim Van Verth | ba98b7d | 2018-12-05 12:33:43 -0500 | [diff] [blame] | 332 | if (plot->lastUseToken() < target->tokenTracker()->nextTokenToFlush()) { |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 333 | this->processEvictionAndResetRects(plot); |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 334 | SkASSERT(caps.bytesPerPixel(fViews[pageIdx].proxy()->backendFormat()) == |
| 335 | plot->bpp()); |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame^] | 336 | SkDEBUGCODE(bool verify = )plot->addSubImage(width, height, image, atlasLocator); |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 337 | SkASSERT(verify); |
Robert Phillips | 6d3bc29 | 2020-04-06 10:29:28 -0400 | [diff] [blame] | 338 | if (!this->updatePlot(target, atlasLocator, plot)) { |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 339 | return ErrorCode::kError; |
| 340 | } |
| 341 | return ErrorCode::kSucceeded; |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 342 | } |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 343 | } |
| 344 | } else { |
| 345 | // If we haven't activated all the available pages, try to create a new one and add to it |
| 346 | if (!this->activateNewPage(resourceProvider)) { |
| 347 | return ErrorCode::kError; |
| 348 | } |
| 349 | |
Robert Phillips | 6d3bc29 | 2020-04-06 10:29:28 -0400 | [diff] [blame] | 350 | if (this->uploadToPage(caps, fNumActivePages-1, target, width, height, image, |
| 351 | atlasLocator)) { |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 352 | return ErrorCode::kSucceeded; |
| 353 | } else { |
| 354 | // If we fail to upload to a newly activated page then something has gone terribly |
| 355 | // wrong - return an error |
| 356 | return ErrorCode::kError; |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 357 | } |
| 358 | } |
| 359 | |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 360 | if (!fNumActivePages) { |
| 361 | return ErrorCode::kError; |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 362 | } |
| 363 | |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 364 | // Try to find a plot that we can perform an inline upload to. |
| 365 | // We prioritize this upload in reverse order of pages to counterbalance the order above. |
| 366 | Plot* plot = nullptr; |
Robert Phillips | 6250f29 | 2018-03-01 10:53:45 -0500 | [diff] [blame] | 367 | for (int pageIdx = ((int)fNumActivePages)-1; pageIdx >= 0; --pageIdx) { |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 368 | Plot* currentPlot = fPages[pageIdx].fPlotList.tail(); |
Robert Phillips | 40a29d7 | 2018-01-18 12:59:22 -0500 | [diff] [blame] | 369 | if (currentPlot->lastUseToken() != target->tokenTracker()->nextDrawToken()) { |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 370 | plot = currentPlot; |
| 371 | break; |
Robert Phillips | 256c37b | 2017-03-01 14:32:46 -0500 | [diff] [blame] | 372 | } |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 373 | } |
| 374 | |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 375 | // If we can't find a plot that is not used in a draw currently being prepared by an op, then |
| 376 | // we have to fail. This gives the op a chance to enqueue the draw, and call back into this |
| 377 | // function. When that draw is enqueued, the draw token advances, and the subsequent call will |
| 378 | // continue past this branch and prepare an inline upload that will occur after the enqueued |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 379 | // draw which references the plot's pre-upload content. |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 380 | if (!plot) { |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 381 | return ErrorCode::kTryAgain; |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 382 | } |
| 383 | |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 384 | this->processEviction(plot->plotLocator()); |
Robert Phillips | 6d3bc29 | 2020-04-06 10:29:28 -0400 | [diff] [blame] | 385 | int pageIdx = plot->pageIndex(); |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 386 | fPages[pageIdx].fPlotList.remove(plot); |
Robert Phillips | 6d3bc29 | 2020-04-06 10:29:28 -0400 | [diff] [blame] | 387 | sk_sp<Plot>& newPlot = fPages[pageIdx].fPlotArray[plot->plotIndex()]; |
robertphillips | 2b0536f | 2015-11-06 14:10:42 -0800 | [diff] [blame] | 388 | newPlot.reset(plot->clone()); |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 389 | |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 390 | fPages[pageIdx].fPlotList.addToHead(newPlot.get()); |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 391 | SkASSERT(caps.bytesPerPixel(fViews[pageIdx].proxy()->backendFormat()) == newPlot->bpp()); |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame^] | 392 | SkDEBUGCODE(bool verify = )newPlot->addSubImage(width, height, image, atlasLocator); |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 393 | SkASSERT(verify); |
robertphillips | 2b0536f | 2015-11-06 14:10:42 -0800 | [diff] [blame] | 394 | |
robertphillips | 1f0e350 | 2015-11-10 10:19:50 -0800 | [diff] [blame] | 395 | // Note that this plot will be uploaded inline with the draws whereas the |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 396 | // one it displaced most likely was uploaded ASAP. |
Robert Phillips | e87106d | 2020-04-09 14:21:33 -0400 | [diff] [blame] | 397 | // With c++14 we could move sk_sp into lambda to only ref once. |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 398 | sk_sp<Plot> plotsp(SkRef(newPlot.get())); |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 399 | |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 400 | GrTextureProxy* proxy = fViews[pageIdx].asTextureProxy(); |
| 401 | SkASSERT(proxy && proxy->isInstantiated()); |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 402 | |
Brian Salomon | 943ed79 | 2017-10-30 09:37:55 -0400 | [diff] [blame] | 403 | GrDeferredUploadToken lastUploadToken = target->addInlineUpload( |
| 404 | [plotsp, proxy](GrDeferredTextureUploadWritePixelsFn& writePixels) { |
| 405 | plotsp->uploadToTexture(writePixels, proxy); |
| 406 | }); |
Robert Phillips | 256c37b | 2017-03-01 14:32:46 -0500 | [diff] [blame] | 407 | newPlot->setLastUploadToken(lastUploadToken); |
| 408 | |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame^] | 409 | atlasLocator->updatePlotLocator(newPlot->plotLocator()); |
| 410 | SkDEBUGCODE(this->validate(*atlasLocator);) |
robertphillips | 2b0536f | 2015-11-06 14:10:42 -0800 | [diff] [blame] | 411 | |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 412 | return ErrorCode::kSucceeded; |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 413 | } |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 414 | |
Brian Salomon | 943ed79 | 2017-10-30 09:37:55 -0400 | [diff] [blame] | 415 | void GrDrawOpAtlas::compact(GrDeferredUploadToken startTokenForNextFlush) { |
Jim Van Verth | 77eb96d | 2020-03-18 12:32:34 -0400 | [diff] [blame] | 416 | if (fNumActivePages < 1) { |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 417 | fPrevFlushToken = startTokenForNextFlush; |
| 418 | return; |
| 419 | } |
| 420 | |
Jim Van Verth | 62ea0cd | 2017-09-27 12:59:45 -0400 | [diff] [blame] | 421 | // For all plots, reset number of flushes since used if used this frame. |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 422 | PlotList::Iter plotIter; |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 423 | bool atlasUsedThisFlush = false; |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 424 | for (uint32_t pageIndex = 0; pageIndex < fNumActivePages; ++pageIndex) { |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 425 | plotIter.init(fPages[pageIndex].fPlotList, PlotList::Iter::kHead_IterStart); |
| 426 | while (Plot* plot = plotIter.get()) { |
Jim Van Verth | 62ea0cd | 2017-09-27 12:59:45 -0400 | [diff] [blame] | 427 | // Reset number of flushes since used |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 428 | if (plot->lastUseToken().inInterval(fPrevFlushToken, startTokenForNextFlush)) { |
| 429 | plot->resetFlushesSinceLastUsed(); |
| 430 | atlasUsedThisFlush = true; |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 431 | } |
| 432 | |
| 433 | plotIter.next(); |
| 434 | } |
| 435 | } |
| 436 | |
Jim Van Verth | 77eb96d | 2020-03-18 12:32:34 -0400 | [diff] [blame] | 437 | if (atlasUsedThisFlush) { |
| 438 | fFlushesSinceLastUse = 0; |
| 439 | } else { |
| 440 | ++fFlushesSinceLastUse; |
| 441 | } |
| 442 | |
| 443 | // We only try to compact if the atlas was used in the recently completed flush or |
| 444 | // hasn't been used in a long time. |
Jim Van Verth | 62ea0cd | 2017-09-27 12:59:45 -0400 | [diff] [blame] | 445 | // This is to handle the case where a lot of text or path rendering has occurred but then just |
| 446 | // a blinking cursor is drawn. |
Jim Van Verth | 77eb96d | 2020-03-18 12:32:34 -0400 | [diff] [blame] | 447 | if (atlasUsedThisFlush || fFlushesSinceLastUse > kAtlasRecentlyUsedCount) { |
Jim Van Verth | cad0acf | 2018-02-16 18:41:41 -0500 | [diff] [blame] | 448 | SkTArray<Plot*> availablePlots; |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 449 | uint32_t lastPageIndex = fNumActivePages - 1; |
Jim Van Verth | 62ea0cd | 2017-09-27 12:59:45 -0400 | [diff] [blame] | 450 | |
| 451 | // For all plots but the last one, update number of flushes since used, and check to see |
| 452 | // if there are any in the first pages that the last page can safely upload to. |
| 453 | for (uint32_t pageIndex = 0; pageIndex < lastPageIndex; ++pageIndex) { |
Jim Van Verth | c3269ae | 2017-09-28 15:04:00 -0400 | [diff] [blame] | 454 | #ifdef DUMP_ATLAS_DATA |
| 455 | if (gDumpAtlasData) { |
| 456 | SkDebugf("page %d: ", pageIndex); |
| 457 | } |
| 458 | #endif |
Jim Van Verth | 62ea0cd | 2017-09-27 12:59:45 -0400 | [diff] [blame] | 459 | plotIter.init(fPages[pageIndex].fPlotList, PlotList::Iter::kHead_IterStart); |
| 460 | while (Plot* plot = plotIter.get()) { |
| 461 | // Update number of flushes since plot was last used |
| 462 | // We only increment the 'sinceLastUsed' count for flushes where the atlas was used |
| 463 | // to avoid deleting everything when we return to text drawing in the blinking |
| 464 | // cursor case |
| 465 | if (!plot->lastUseToken().inInterval(fPrevFlushToken, startTokenForNextFlush)) { |
| 466 | plot->incFlushesSinceLastUsed(); |
| 467 | } |
| 468 | |
Jim Van Verth | c3269ae | 2017-09-28 15:04:00 -0400 | [diff] [blame] | 469 | #ifdef DUMP_ATLAS_DATA |
| 470 | if (gDumpAtlasData) { |
| 471 | SkDebugf("%d ", plot->flushesSinceLastUsed()); |
| 472 | } |
| 473 | #endif |
Jim Van Verth | 62ea0cd | 2017-09-27 12:59:45 -0400 | [diff] [blame] | 474 | // Count plots we can potentially upload to in all pages except the last one |
| 475 | // (the potential compactee). |
Jim Van Verth | 77eb96d | 2020-03-18 12:32:34 -0400 | [diff] [blame] | 476 | if (plot->flushesSinceLastUsed() > kPlotRecentlyUsedCount) { |
Jim Van Verth | cad0acf | 2018-02-16 18:41:41 -0500 | [diff] [blame] | 477 | availablePlots.push_back() = plot; |
Jim Van Verth | 62ea0cd | 2017-09-27 12:59:45 -0400 | [diff] [blame] | 478 | } |
| 479 | |
| 480 | plotIter.next(); |
| 481 | } |
Jim Van Verth | c3269ae | 2017-09-28 15:04:00 -0400 | [diff] [blame] | 482 | #ifdef DUMP_ATLAS_DATA |
| 483 | if (gDumpAtlasData) { |
| 484 | SkDebugf("\n"); |
| 485 | } |
| 486 | #endif |
Jim Van Verth | 62ea0cd | 2017-09-27 12:59:45 -0400 | [diff] [blame] | 487 | } |
| 488 | |
Jim Van Verth | 06f593c | 2018-02-20 11:30:10 -0500 | [diff] [blame] | 489 | // Count recently used plots in the last page and evict any that are no longer in use. |
| 490 | // Since we prioritize uploading to the first pages, this will eventually |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 491 | // clear out usage of this page unless we have a large need. |
| 492 | plotIter.init(fPages[lastPageIndex].fPlotList, PlotList::Iter::kHead_IterStart); |
Jim Van Verth | 06f593c | 2018-02-20 11:30:10 -0500 | [diff] [blame] | 493 | unsigned int usedPlots = 0; |
Jim Van Verth | c3269ae | 2017-09-28 15:04:00 -0400 | [diff] [blame] | 494 | #ifdef DUMP_ATLAS_DATA |
| 495 | if (gDumpAtlasData) { |
| 496 | SkDebugf("page %d: ", lastPageIndex); |
| 497 | } |
| 498 | #endif |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 499 | while (Plot* plot = plotIter.get()) { |
Jim Van Verth | 62ea0cd | 2017-09-27 12:59:45 -0400 | [diff] [blame] | 500 | // Update number of flushes since plot was last used |
| 501 | if (!plot->lastUseToken().inInterval(fPrevFlushToken, startTokenForNextFlush)) { |
| 502 | plot->incFlushesSinceLastUsed(); |
| 503 | } |
| 504 | |
Jim Van Verth | c3269ae | 2017-09-28 15:04:00 -0400 | [diff] [blame] | 505 | #ifdef DUMP_ATLAS_DATA |
| 506 | if (gDumpAtlasData) { |
| 507 | SkDebugf("%d ", plot->flushesSinceLastUsed()); |
| 508 | } |
| 509 | #endif |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 510 | // If this plot was used recently |
Jim Van Verth | 77eb96d | 2020-03-18 12:32:34 -0400 | [diff] [blame] | 511 | if (plot->flushesSinceLastUsed() <= kPlotRecentlyUsedCount) { |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 512 | usedPlots++; |
Brian Salomon | 943ed79 | 2017-10-30 09:37:55 -0400 | [diff] [blame] | 513 | } else if (plot->lastUseToken() != GrDeferredUploadToken::AlreadyFlushedToken()) { |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 514 | // otherwise if aged out just evict it. |
Jim Van Verth | c3269ae | 2017-09-28 15:04:00 -0400 | [diff] [blame] | 515 | this->processEvictionAndResetRects(plot); |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 516 | } |
| 517 | plotIter.next(); |
| 518 | } |
Jim Van Verth | c3269ae | 2017-09-28 15:04:00 -0400 | [diff] [blame] | 519 | #ifdef DUMP_ATLAS_DATA |
| 520 | if (gDumpAtlasData) { |
| 521 | SkDebugf("\n"); |
| 522 | } |
| 523 | #endif |
Jim Van Verth | 06f593c | 2018-02-20 11:30:10 -0500 | [diff] [blame] | 524 | |
| 525 | // If recently used plots in the last page are using less than a quarter of the page, try |
| 526 | // to evict them if there's available space in earlier pages. Since we prioritize uploading |
| 527 | // to the first pages, this will eventually clear out usage of this page unless we have a |
| 528 | // large need. |
| 529 | if (availablePlots.count() && usedPlots && usedPlots <= fNumPlots / 4) { |
| 530 | plotIter.init(fPages[lastPageIndex].fPlotList, PlotList::Iter::kHead_IterStart); |
| 531 | while (Plot* plot = plotIter.get()) { |
| 532 | // If this plot was used recently |
Jim Van Verth | 77eb96d | 2020-03-18 12:32:34 -0400 | [diff] [blame] | 533 | if (plot->flushesSinceLastUsed() <= kPlotRecentlyUsedCount) { |
Jim Van Verth | 06f593c | 2018-02-20 11:30:10 -0500 | [diff] [blame] | 534 | // See if there's room in an earlier page and if so evict. |
| 535 | // We need to be somewhat harsh here so that a handful of plots that are |
| 536 | // consistently in use don't end up locking the page in memory. |
| 537 | if (availablePlots.count() > 0) { |
| 538 | this->processEvictionAndResetRects(plot); |
| 539 | this->processEvictionAndResetRects(availablePlots.back()); |
| 540 | availablePlots.pop_back(); |
| 541 | --usedPlots; |
| 542 | } |
| 543 | if (!usedPlots || !availablePlots.count()) { |
| 544 | break; |
| 545 | } |
| 546 | } |
| 547 | plotIter.next(); |
| 548 | } |
| 549 | } |
| 550 | |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 551 | // If none of the plots in the last page have been used recently, delete it. |
Jim Van Verth | 2665188 | 2020-03-18 15:30:07 +0000 | [diff] [blame] | 552 | if (!usedPlots) { |
Jim Van Verth | c3269ae | 2017-09-28 15:04:00 -0400 | [diff] [blame] | 553 | #ifdef DUMP_ATLAS_DATA |
| 554 | if (gDumpAtlasData) { |
Jim Van Verth | 77eb96d | 2020-03-18 12:32:34 -0400 | [diff] [blame] | 555 | SkDebugf("delete %d\n", fNumActivePages-1); |
Jim Van Verth | c3269ae | 2017-09-28 15:04:00 -0400 | [diff] [blame] | 556 | } |
| 557 | #endif |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 558 | this->deactivateLastPage(); |
Jim Van Verth | 77eb96d | 2020-03-18 12:32:34 -0400 | [diff] [blame] | 559 | fFlushesSinceLastUse = 0; |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 560 | } |
| 561 | } |
| 562 | |
| 563 | fPrevFlushToken = startTokenForNextFlush; |
| 564 | } |
| 565 | |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 566 | bool GrDrawOpAtlas::createPages( |
| 567 | GrProxyProvider* proxyProvider, GenerationCounter* generationCounter) { |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 568 | SkASSERT(SkIsPow2(fTextureWidth) && SkIsPow2(fTextureHeight)); |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 569 | |
Brian Salomon | a56a746 | 2020-02-07 14:17:25 -0500 | [diff] [blame] | 570 | SkISize dims = {fTextureWidth, fTextureHeight}; |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 571 | |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 572 | int numPlotsX = fTextureWidth/fPlotWidth; |
| 573 | int numPlotsY = fTextureHeight/fPlotHeight; |
| 574 | |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 575 | for (uint32_t i = 0; i < this->maxPages(); ++i) { |
Greg Daniel | 47c20e8 | 2020-01-21 14:29:57 -0500 | [diff] [blame] | 576 | GrSwizzle swizzle = proxyProvider->caps()->getReadSwizzle(fFormat, fColorType); |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 577 | sk_sp<GrSurfaceProxy> proxy = proxyProvider->createProxy( |
Brian Salomon | 7e67dca | 2020-07-21 09:27:25 -0400 | [diff] [blame] | 578 | fFormat, dims, GrRenderable::kNo, 1, GrMipmapped::kNo, SkBackingFit::kExact, |
Brian Salomon | df1bd6d | 2020-03-26 20:37:01 -0400 | [diff] [blame] | 579 | SkBudgeted::kYes, GrProtected::kNo, GrInternalSurfaceFlags::kNone, |
| 580 | GrSurfaceProxy::UseAllocator::kNo); |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 581 | if (!proxy) { |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 582 | return false; |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 583 | } |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 584 | fViews[i] = GrSurfaceProxyView(std::move(proxy), kTopLeft_GrSurfaceOrigin, swizzle); |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 585 | |
| 586 | // set up allocated plots |
John Stiles | fbd050b | 2020-08-03 13:21:46 -0400 | [diff] [blame] | 587 | fPages[i].fPlotArray = std::make_unique<sk_sp<Plot>[]>(numPlotsX * numPlotsY); |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 588 | |
| 589 | sk_sp<Plot>* currPlot = fPages[i].fPlotArray.get(); |
| 590 | for (int y = numPlotsY - 1, r = 0; y >= 0; --y, ++r) { |
| 591 | for (int x = numPlotsX - 1, c = 0; x >= 0; --x, ++c) { |
| 592 | uint32_t plotIndex = r * numPlotsX + c; |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 593 | currPlot->reset(new Plot( |
| 594 | i, plotIndex, generationCounter, x, y, fPlotWidth, fPlotHeight, fColorType)); |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 595 | |
| 596 | // build LRU list |
| 597 | fPages[i].fPlotList.addToHead(currPlot->get()); |
| 598 | ++currPlot; |
| 599 | } |
| 600 | } |
| 601 | |
| 602 | } |
| 603 | |
| 604 | return true; |
| 605 | } |
| 606 | |
| 607 | |
| 608 | bool GrDrawOpAtlas::activateNewPage(GrResourceProvider* resourceProvider) { |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 609 | SkASSERT(fNumActivePages < this->maxPages()); |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 610 | |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 611 | if (!fViews[fNumActivePages].proxy()->instantiate(resourceProvider)) { |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 612 | return false; |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 613 | } |
| 614 | |
Jim Van Verth | c3269ae | 2017-09-28 15:04:00 -0400 | [diff] [blame] | 615 | #ifdef DUMP_ATLAS_DATA |
| 616 | if (gDumpAtlasData) { |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 617 | SkDebugf("activated page#: %d\n", fNumActivePages); |
Jim Van Verth | c3269ae | 2017-09-28 15:04:00 -0400 | [diff] [blame] | 618 | } |
| 619 | #endif |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 620 | |
| 621 | ++fNumActivePages; |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 622 | return true; |
| 623 | } |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 624 | |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 625 | |
| 626 | inline void GrDrawOpAtlas::deactivateLastPage() { |
| 627 | SkASSERT(fNumActivePages); |
| 628 | |
| 629 | uint32_t lastPageIndex = fNumActivePages - 1; |
| 630 | |
| 631 | int numPlotsX = fTextureWidth/fPlotWidth; |
| 632 | int numPlotsY = fTextureHeight/fPlotHeight; |
| 633 | |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 634 | fPages[lastPageIndex].fPlotList.reset(); |
Robert Phillips | 6250f29 | 2018-03-01 10:53:45 -0500 | [diff] [blame] | 635 | for (int r = 0; r < numPlotsY; ++r) { |
| 636 | for (int c = 0; c < numPlotsX; ++c) { |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 637 | uint32_t plotIndex = r * numPlotsX + c; |
| 638 | |
| 639 | Plot* currPlot = fPages[lastPageIndex].fPlotArray[plotIndex].get(); |
| 640 | currPlot->resetRects(); |
| 641 | currPlot->resetFlushesSinceLastUsed(); |
| 642 | |
| 643 | // rebuild the LRU list |
| 644 | SkDEBUGCODE(currPlot->fPrev = currPlot->fNext = nullptr); |
| 645 | SkDEBUGCODE(currPlot->fList = nullptr); |
| 646 | fPages[lastPageIndex].fPlotList.addToHead(currPlot); |
| 647 | } |
| 648 | } |
| 649 | |
| 650 | // remove ref to the backing texture |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 651 | fViews[lastPageIndex].proxy()->deinstantiate(); |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 652 | --fNumActivePages; |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 653 | } |
Herb Derby | 15d9ef2 | 2018-10-18 13:41:32 -0400 | [diff] [blame] | 654 | |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 655 | GrDrawOpAtlasConfig::GrDrawOpAtlasConfig(int maxTextureSize, size_t maxBytes) { |
| 656 | static const SkISize kARGBDimensions[] = { |
| 657 | {256, 256}, // maxBytes < 2^19 |
| 658 | {512, 256}, // 2^19 <= maxBytes < 2^20 |
| 659 | {512, 512}, // 2^20 <= maxBytes < 2^21 |
| 660 | {1024, 512}, // 2^21 <= maxBytes < 2^22 |
| 661 | {1024, 1024}, // 2^22 <= maxBytes < 2^23 |
| 662 | {2048, 1024}, // 2^23 <= maxBytes |
| 663 | }; |
Herb Derby | 15d9ef2 | 2018-10-18 13:41:32 -0400 | [diff] [blame] | 664 | |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 665 | // Index 0 corresponds to maxBytes of 2^18, so start by dividing it by that |
| 666 | maxBytes >>= 18; |
| 667 | // Take the floor of the log to get the index |
| 668 | int index = maxBytes > 0 |
| 669 | ? SkTPin<int>(SkPrevLog2(maxBytes), 0, SK_ARRAY_COUNT(kARGBDimensions) - 1) |
| 670 | : 0; |
Herb Derby | 15d9ef2 | 2018-10-18 13:41:32 -0400 | [diff] [blame] | 671 | |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 672 | SkASSERT(kARGBDimensions[index].width() <= kMaxAtlasDim); |
| 673 | SkASSERT(kARGBDimensions[index].height() <= kMaxAtlasDim); |
Brian Osman | 788b916 | 2020-02-07 10:36:46 -0500 | [diff] [blame] | 674 | fARGBDimensions.set(std::min<int>(kARGBDimensions[index].width(), maxTextureSize), |
| 675 | std::min<int>(kARGBDimensions[index].height(), maxTextureSize)); |
| 676 | fMaxTextureSize = std::min<int>(maxTextureSize, kMaxAtlasDim); |
Herb Derby | 15d9ef2 | 2018-10-18 13:41:32 -0400 | [diff] [blame] | 677 | } |
| 678 | |
| 679 | SkISize GrDrawOpAtlasConfig::atlasDimensions(GrMaskFormat type) const { |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 680 | if (kA8_GrMaskFormat == type) { |
| 681 | // A8 is always 2x the ARGB dimensions, clamped to the max allowed texture size |
Brian Osman | 788b916 | 2020-02-07 10:36:46 -0500 | [diff] [blame] | 682 | return { std::min<int>(2 * fARGBDimensions.width(), fMaxTextureSize), |
| 683 | std::min<int>(2 * fARGBDimensions.height(), fMaxTextureSize) }; |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 684 | } else { |
| 685 | return fARGBDimensions; |
| 686 | } |
Herb Derby | 15d9ef2 | 2018-10-18 13:41:32 -0400 | [diff] [blame] | 687 | } |
| 688 | |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 689 | SkISize GrDrawOpAtlasConfig::plotDimensions(GrMaskFormat type) const { |
| 690 | if (kA8_GrMaskFormat == type) { |
| 691 | SkISize atlasDimensions = this->atlasDimensions(type); |
| 692 | // For A8 we want to grow the plots at larger texture sizes to accept more of the |
| 693 | // larger SDF glyphs. Since the largest SDF glyph can be 170x170 with padding, this |
| 694 | // allows us to pack 3 in a 512x256 plot, or 9 in a 512x512 plot. |
Herb Derby | 15d9ef2 | 2018-10-18 13:41:32 -0400 | [diff] [blame] | 695 | |
Jim Van Verth | 578b089 | 2018-12-20 20:48:55 +0000 | [diff] [blame] | 696 | // This will give us 512x256 plots for 2048x1024, 512x512 plots for 2048x2048, |
| 697 | // and 256x256 plots otherwise. |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 698 | int plotWidth = atlasDimensions.width() >= 2048 ? 512 : 256; |
Jim Van Verth | 578b089 | 2018-12-20 20:48:55 +0000 | [diff] [blame] | 699 | int plotHeight = atlasDimensions.height() >= 2048 ? 512 : 256; |
Herb Derby | 15d9ef2 | 2018-10-18 13:41:32 -0400 | [diff] [blame] | 700 | |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 701 | return { plotWidth, plotHeight }; |
| 702 | } else { |
| 703 | // ARGB and LCD always use 256x256 plots -- this has been shown to be faster |
| 704 | return { 256, 256 }; |
| 705 | } |
Herb Derby | 15d9ef2 | 2018-10-18 13:41:32 -0400 | [diff] [blame] | 706 | } |
| 707 | |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 708 | constexpr int GrDrawOpAtlasConfig::kMaxAtlasDim; |