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 | |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 8 | #ifndef GrDrawOpAtlas_DEFINED |
| 9 | #define GrDrawOpAtlas_DEFINED |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 10 | |
Herb Derby | 3c4d533 | 2018-09-07 15:27:57 -0400 | [diff] [blame] | 11 | #include <cmath> |
Herb Derby | 1a496c5 | 2020-01-22 17:26:56 -0500 | [diff] [blame] | 12 | #include <vector> |
Herb Derby | 3c4d533 | 2018-09-07 15:27:57 -0400 | [diff] [blame] | 13 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 14 | #include "include/core/SkSize.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 15 | #include "src/core/SkGlyphRunPainter.h" |
| 16 | #include "src/core/SkIPoint16.h" |
Ben Wagner | 729a23f | 2019-05-17 16:29:34 -0400 | [diff] [blame] | 17 | #include "src/core/SkTInternalLList.h" |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 18 | |
Herb Derby | 73c7587 | 2020-01-22 18:09:16 -0500 | [diff] [blame] | 19 | #include "src/gpu/GrRectanizerSkyline.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 20 | #include "src/gpu/ops/GrDrawOp.h" |
joshualitt | ddd22d8 | 2016-02-16 06:47:52 -0800 | [diff] [blame] | 21 | |
Robert Phillips | cd5099c | 2018-02-09 09:56:56 -0500 | [diff] [blame] | 22 | class GrOnFlushResourceProvider; |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 23 | |
joshualitt | da04e0e | 2015-08-19 08:16:43 -0700 | [diff] [blame] | 24 | |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 25 | /** |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 26 | * This class manages one or more atlas textures on behalf of GrDrawOps. The draw ops that use the |
| 27 | * atlas perform texture uploads when preparing their draws during flush. The class provides |
| 28 | * facilities for using GrDrawOpUploadToken to detect data hazards. Op's uploads are performed in |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 29 | * "ASAP" mode until it is impossible to add data without overwriting texels read by draws that |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 30 | * have not yet executed on the gpu. At that point, the atlas will attempt to allocate a new |
| 31 | * atlas texture (or "page") of the same size, up to a maximum number of textures, and upload |
| 32 | * to that texture. If that's not possible, the uploads are performed "inline" between draws. If a |
| 33 | * single draw would use enough subimage space to overflow the atlas texture then the atlas will |
| 34 | * fail to add a subimage. This gives the op the chance to end the draw and begin a new one. |
| 35 | * Additional uploads will then succeed in inline mode. |
| 36 | * |
| 37 | * When the atlas has multiple pages, new uploads are prioritized to the lower index pages, i.e., |
| 38 | * it will try to upload to page 0 before page 1 or 2. To keep the atlas from continually using |
| 39 | * excess space, periodic garbage collection is needed to shift data from the higher index pages to |
| 40 | * the lower ones, and then eventually remove any pages that are no longer in use. "In use" is |
| 41 | * determined by using the GrDrawUploadToken system: After a flush each subarea of the page |
| 42 | * is checked to see whether it was used in that flush; if it is not, a counter is incremented. |
| 43 | * Once that counter reaches a threshold that subarea is considered to be no longer in use. |
| 44 | * |
| 45 | * Garbage collection is initiated by the GrDrawOpAtlas's client via the compact() method. One |
| 46 | * solution is to make the client a subclass of GrOnFlushCallbackObject, register it with the |
| 47 | * GrContext via addOnFlushCallbackObject(), and the client's postFlush() method calls compact() |
| 48 | * and passes in the given GrDrawUploadToken. |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 49 | */ |
| 50 | class GrDrawOpAtlas { |
Brian Salomon | 9f545bc | 2017-11-06 10:36:57 -0500 | [diff] [blame] | 51 | private: |
| 52 | static constexpr auto kMaxMultitexturePages = 4; |
| 53 | |
Herb Derby | 3c4d533 | 2018-09-07 15:27:57 -0400 | [diff] [blame] | 54 | |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 55 | public: |
Brian Salomon | 9f545bc | 2017-11-06 10:36:57 -0500 | [diff] [blame] | 56 | /** Is the atlas allowed to use more than one texture? */ |
| 57 | enum class AllowMultitexturing : bool { kNo, kYes }; |
| 58 | |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 59 | static constexpr int kMaxPlots = 32; // restricted by the fPlotAlreadyUpdated bitfield |
| 60 | // in BulkUseTokenUpdater |
Herb Derby | bbf5fb5 | 2018-10-15 16:39:39 -0400 | [diff] [blame] | 61 | |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 62 | /** |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 63 | * A PlotLocator specifies the plot and is analogous to a directory path: |
| 64 | * page/plot/plotGeneration |
| 65 | * |
| 66 | * In fact PlotLocator is a portion of a glyph image location in the atlas fully specified by: |
| 67 | * format/atlasGeneration/page/plot/plotGeneration/(u,v) |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 68 | */ |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 69 | typedef uint64_t PlotLocator; |
| 70 | static const uint64_t kInvalidPlotLocator = 0; |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 71 | static const uint64_t kInvalidAtlasGeneration = 0; |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 72 | |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 73 | /** |
Herb Derby | 1a496c5 | 2020-01-22 17:26:56 -0500 | [diff] [blame] | 74 | * An interface for eviction callbacks. Whenever GrDrawOpAtlas evicts a |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 75 | * specific PlotLocator, it will call all of the registered listeners so they can process the |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 76 | * eviction. |
| 77 | */ |
Herb Derby | 1a496c5 | 2020-01-22 17:26:56 -0500 | [diff] [blame] | 78 | class EvictionCallback { |
| 79 | public: |
| 80 | virtual ~EvictionCallback() = default; |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 81 | virtual void evict(PlotLocator plotLocator) = 0; |
Herb Derby | 1a496c5 | 2020-01-22 17:26:56 -0500 | [diff] [blame] | 82 | }; |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 83 | |
Robert Phillips | 256c37b | 2017-03-01 14:32:46 -0500 | [diff] [blame] | 84 | /** |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 85 | * Keep track of generation number for Atlases and Plots. |
| 86 | */ |
| 87 | class GenerationCounter { |
| 88 | public: |
| 89 | static constexpr uint64_t kInvalidGeneration = 0; |
| 90 | uint64_t next() { |
| 91 | return fGeneration++; |
| 92 | } |
| 93 | |
| 94 | private: |
| 95 | uint64_t fGeneration{1}; |
| 96 | }; |
| 97 | |
| 98 | /** |
Robert Phillips | 256c37b | 2017-03-01 14:32:46 -0500 | [diff] [blame] | 99 | * Returns a GrDrawOpAtlas. This function can be called anywhere, but the returned atlas |
| 100 | * should only be used inside of GrMeshDrawOp::onPrepareDraws. |
Robert Phillips | 42dda08 | 2019-05-14 13:29:45 -0400 | [diff] [blame] | 101 | * @param GrColorType The colorType which this atlas will store |
Robert Phillips | 256c37b | 2017-03-01 14:32:46 -0500 | [diff] [blame] | 102 | * @param width width in pixels of the atlas |
| 103 | * @param height height in pixels of the atlas |
| 104 | * @param numPlotsX The number of plots the atlas should be broken up into in the X |
| 105 | * direction |
| 106 | * @param numPlotsY The number of plots the atlas should be broken up into in the Y |
| 107 | * direction |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 108 | * @param atlasGeneration a pointer to the context's generation counter. |
Brian Salomon | 9f545bc | 2017-11-06 10:36:57 -0500 | [diff] [blame] | 109 | * @param allowMultitexturing Can the atlas use more than one texture. |
Herb Derby | 1a496c5 | 2020-01-22 17:26:56 -0500 | [diff] [blame] | 110 | * @param evictor A pointer to an eviction callback class. |
| 111 | * |
Robert Phillips | 256c37b | 2017-03-01 14:32:46 -0500 | [diff] [blame] | 112 | * @return An initialized GrDrawOpAtlas, or nullptr if creation fails |
| 113 | */ |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 114 | static std::unique_ptr<GrDrawOpAtlas> Make(GrProxyProvider*, |
| 115 | const GrBackendFormat& format, |
Robert Phillips | 42dda08 | 2019-05-14 13:29:45 -0400 | [diff] [blame] | 116 | GrColorType, |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 117 | int width, int height, |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 118 | int plotWidth, int plotHeight, |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 119 | GenerationCounter* generationCounter, |
Brian Salomon | 9f545bc | 2017-11-06 10:36:57 -0500 | [diff] [blame] | 120 | AllowMultitexturing allowMultitexturing, |
Herb Derby | 1a496c5 | 2020-01-22 17:26:56 -0500 | [diff] [blame] | 121 | EvictionCallback* evictor); |
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 | /** |
Jim Van Verth | fb39510 | 2020-02-03 10:11:19 -0500 | [diff] [blame^] | 124 | * Packs a texture atlas page index into the uint16 texture coordinates. |
| 125 | * @param u U texture coordinate |
| 126 | * @param v V texture coordinate |
| 127 | * @param pageIndex index of the texture these coordinates apply to. |
| 128 | Must be in the range [0, 3]. |
| 129 | * @return The new u and v coordinates with the packed value |
| 130 | */ |
| 131 | static std::pair<uint16_t, uint16_t> PackIndexInTexCoords(uint16_t u, uint16_t v, |
| 132 | int pageIndex); |
| 133 | /** |
| 134 | * Unpacks a texture atlas page index from uint16 texture coordinates. |
| 135 | * @param u Packed U texture coordinate |
| 136 | * @param v Packed V texture coordinate |
| 137 | * @return The unpacked u and v coordinates with the page index. |
| 138 | */ |
| 139 | static std::tuple<uint16_t, uint16_t, int> UnpackIndexFromTexCoords(uint16_t u, uint16_t v); |
| 140 | |
| 141 | /** |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 142 | * Adds a width x height subimage to the atlas. Upon success it returns 'kSucceeded' and returns |
| 143 | * the ID and the subimage's coordinates in the backing texture. 'kTryAgain' is returned if |
| 144 | * the subimage cannot fit in the atlas without overwriting texels that will be read in the |
| 145 | * current draw. This indicates that the op should end its current draw and begin another |
| 146 | * before adding more data. Upon success, an upload of the provided image data will have |
| 147 | * been added to the GrDrawOp::Target, in "asap" mode if possible, otherwise in "inline" mode. |
| 148 | * Successive uploads in either mode may be consolidated. |
| 149 | * 'kError' will be returned when some unrecoverable error was encountered while trying to |
| 150 | * add the subimage. In this case the op being created should be discarded. |
| 151 | * |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 152 | * NOTE: When the GrDrawOp prepares a draw that reads from the atlas, it must immediately call |
| 153 | * 'setUseToken' with the currentToken from the GrDrawOp::Target, otherwise the next call to |
| 154 | * addToAtlas might cause the previous data to be overwritten before it has been read. |
| 155 | */ |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 156 | |
| 157 | enum class ErrorCode { |
| 158 | kError, |
| 159 | kSucceeded, |
| 160 | kTryAgain |
| 161 | }; |
| 162 | |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 163 | ErrorCode addToAtlas(GrResourceProvider*, PlotLocator*, GrDeferredUploadTarget*, |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 164 | int width, int height, |
| 165 | const void* image, SkIPoint16* loc); |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 166 | |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 167 | const GrSurfaceProxyView* getViews() const { return fViews; } |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 168 | |
joshualitt | 7c3a2f8 | 2015-03-31 13:32:05 -0700 | [diff] [blame] | 169 | uint64_t atlasGeneration() const { return fAtlasGeneration; } |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 170 | |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 171 | bool hasID(PlotLocator plotLocator) { |
| 172 | if (kInvalidPlotLocator == plotLocator) { |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 173 | return false; |
| 174 | } |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 175 | |
| 176 | uint32_t plot = GetPlotIndexFromID(plotLocator); |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 177 | uint32_t page = GetPageIndexFromID(plotLocator); |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 178 | uint64_t plotGeneration = fPages[page].fPlotArray[plot]->genID(); |
| 179 | uint64_t locatorGeneration = GetGenerationFromID(plotLocator); |
| 180 | return plot < fNumPlots && page < fNumActivePages && plotGeneration == locatorGeneration; |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 181 | } |
joshualitt | b4c507e | 2015-04-08 08:07:59 -0700 | [diff] [blame] | 182 | |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 183 | /** To ensure the atlas does not evict a given entry, the client must set the last use token. */ |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 184 | void setLastUseToken(PlotLocator plotLocator, GrDeferredUploadToken token) { |
| 185 | SkASSERT(this->hasID(plotLocator)); |
| 186 | uint32_t plotIdx = GetPlotIndexFromID(plotLocator); |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 187 | SkASSERT(plotIdx < fNumPlots); |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 188 | uint32_t pageIdx = GetPageIndexFromID(plotLocator); |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 189 | SkASSERT(pageIdx < fNumActivePages); |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 190 | Plot* plot = fPages[pageIdx].fPlotArray[plotIdx].get(); |
| 191 | this->makeMRU(plot, pageIdx); |
| 192 | plot->setLastUseToken(token); |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 193 | } |
| 194 | |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 195 | uint32_t numActivePages() { return fNumActivePages; } |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 196 | |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 197 | /** |
| 198 | * A class which can be handed back to GrDrawOpAtlas for updating last use tokens in bulk. The |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 199 | * current max number of plots per page the GrDrawOpAtlas can handle is 32. If in the future |
| 200 | * this is insufficient then we can move to a 64 bit int. |
joshualitt | b4c507e | 2015-04-08 08:07:59 -0700 | [diff] [blame] | 201 | */ |
| 202 | class BulkUseTokenUpdater { |
| 203 | public: |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 204 | BulkUseTokenUpdater() { |
| 205 | memset(fPlotAlreadyUpdated, 0, sizeof(fPlotAlreadyUpdated)); |
| 206 | } |
joshualitt | 7e97b0b | 2015-07-31 15:18:08 -0700 | [diff] [blame] | 207 | BulkUseTokenUpdater(const BulkUseTokenUpdater& that) |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 208 | : fPlotsToUpdate(that.fPlotsToUpdate) { |
| 209 | memcpy(fPlotAlreadyUpdated, that.fPlotAlreadyUpdated, sizeof(fPlotAlreadyUpdated)); |
joshualitt | 7e97b0b | 2015-07-31 15:18:08 -0700 | [diff] [blame] | 210 | } |
| 211 | |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 212 | bool add(PlotLocator plotLocator) { |
| 213 | int index = GrDrawOpAtlas::GetPlotIndexFromID(plotLocator); |
| 214 | int pageIdx = GrDrawOpAtlas::GetPageIndexFromID(plotLocator); |
Jim Van Verth | ba98b7d | 2018-12-05 12:33:43 -0500 | [diff] [blame] | 215 | if (this->find(pageIdx, index)) { |
| 216 | return false; |
joshualitt | b4c507e | 2015-04-08 08:07:59 -0700 | [diff] [blame] | 217 | } |
Jim Van Verth | ba98b7d | 2018-12-05 12:33:43 -0500 | [diff] [blame] | 218 | this->set(pageIdx, index); |
| 219 | return true; |
joshualitt | b4c507e | 2015-04-08 08:07:59 -0700 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | void reset() { |
joshualitt | 4314e08 | 2015-04-23 08:03:35 -0700 | [diff] [blame] | 223 | fPlotsToUpdate.reset(); |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 224 | memset(fPlotAlreadyUpdated, 0, sizeof(fPlotAlreadyUpdated)); |
joshualitt | b4c507e | 2015-04-08 08:07:59 -0700 | [diff] [blame] | 225 | } |
| 226 | |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 227 | struct PlotData { |
| 228 | PlotData(int pageIdx, int plotIdx) : fPageIndex(pageIdx), fPlotIndex(plotIdx) {} |
| 229 | uint32_t fPageIndex; |
| 230 | uint32_t fPlotIndex; |
| 231 | }; |
| 232 | |
joshualitt | b4c507e | 2015-04-08 08:07:59 -0700 | [diff] [blame] | 233 | private: |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 234 | bool find(int pageIdx, int index) const { |
joshualitt | b4c507e | 2015-04-08 08:07:59 -0700 | [diff] [blame] | 235 | SkASSERT(index < kMaxPlots); |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 236 | return (fPlotAlreadyUpdated[pageIdx] >> index) & 1; |
joshualitt | b4c507e | 2015-04-08 08:07:59 -0700 | [diff] [blame] | 237 | } |
| 238 | |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 239 | void set(int pageIdx, int index) { |
| 240 | SkASSERT(!this->find(pageIdx, index)); |
| 241 | fPlotAlreadyUpdated[pageIdx] |= (1 << index); |
| 242 | fPlotsToUpdate.push_back(PlotData(pageIdx, index)); |
joshualitt | b4c507e | 2015-04-08 08:07:59 -0700 | [diff] [blame] | 243 | } |
| 244 | |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 245 | static constexpr int kMinItems = 4; |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 246 | SkSTArray<kMinItems, PlotData, true> fPlotsToUpdate; |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 247 | uint32_t fPlotAlreadyUpdated[kMaxMultitexturePages]; // TODO: increase this to uint64_t |
| 248 | // to allow more plots per page |
joshualitt | b4c507e | 2015-04-08 08:07:59 -0700 | [diff] [blame] | 249 | |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 250 | friend class GrDrawOpAtlas; |
joshualitt | b4c507e | 2015-04-08 08:07:59 -0700 | [diff] [blame] | 251 | }; |
| 252 | |
Brian Salomon | 943ed79 | 2017-10-30 09:37:55 -0400 | [diff] [blame] | 253 | void setLastUseTokenBulk(const BulkUseTokenUpdater& updater, GrDeferredUploadToken token) { |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 254 | int count = updater.fPlotsToUpdate.count(); |
| 255 | for (int i = 0; i < count; i++) { |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 256 | const BulkUseTokenUpdater::PlotData& pd = updater.fPlotsToUpdate[i]; |
Jim Van Verth | c3269ae | 2017-09-28 15:04:00 -0400 | [diff] [blame] | 257 | // it's possible we've added a plot to the updater and subsequently the plot's page |
| 258 | // was deleted -- so we check to prevent a crash |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 259 | if (pd.fPageIndex < fNumActivePages) { |
Jim Van Verth | 6ca9c6f | 2017-09-27 18:04:34 -0400 | [diff] [blame] | 260 | Plot* plot = fPages[pd.fPageIndex].fPlotArray[pd.fPlotIndex].get(); |
| 261 | this->makeMRU(plot, pd.fPageIndex); |
| 262 | plot->setLastUseToken(token); |
| 263 | } |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 264 | } |
| 265 | } |
joshualitt | b4c507e | 2015-04-08 08:07:59 -0700 | [diff] [blame] | 266 | |
Brian Salomon | 943ed79 | 2017-10-30 09:37:55 -0400 | [diff] [blame] | 267 | void compact(GrDeferredUploadToken startTokenForNextFlush); |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 268 | |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 269 | static uint32_t GetPageIndexFromID(PlotLocator plotLocator) { |
| 270 | return plotLocator & 0xff; |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 271 | } |
| 272 | |
Robert Phillips | cd5099c | 2018-02-09 09:56:56 -0500 | [diff] [blame] | 273 | void instantiate(GrOnFlushResourceProvider*); |
| 274 | |
Brian Salomon | 9f545bc | 2017-11-06 10:36:57 -0500 | [diff] [blame] | 275 | uint32_t maxPages() const { |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 276 | return fMaxPages; |
Brian Salomon | 9f545bc | 2017-11-06 10:36:57 -0500 | [diff] [blame] | 277 | } |
| 278 | |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 279 | int numAllocated_TestingOnly() const; |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 280 | void setMaxPages_TestingOnly(uint32_t maxPages); |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 281 | |
| 282 | private: |
Robert Phillips | 42dda08 | 2019-05-14 13:29:45 -0400 | [diff] [blame] | 283 | GrDrawOpAtlas(GrProxyProvider*, const GrBackendFormat& format, GrColorType, int width, |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 284 | int height, int plotWidth, int plotHeight, GenerationCounter* generationCounter, |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 285 | AllowMultitexturing allowMultitexturing); |
Robert Phillips | 256c37b | 2017-03-01 14:32:46 -0500 | [diff] [blame] | 286 | |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 287 | /** |
| 288 | * The backing GrTexture for a GrDrawOpAtlas is broken into a spatial grid of Plots. The Plots |
| 289 | * keep track of subimage placement via their GrRectanizer. A Plot manages the lifetime of its |
| 290 | * data using two tokens, a last use token and a last upload token. Once a Plot is "full" (i.e. |
| 291 | * there is no room for the new subimage according to the GrRectanizer), it can no longer be |
| 292 | * used unless the last use of the Plot has already been flushed through to the gpu. |
| 293 | */ |
| 294 | class Plot : public SkRefCnt { |
| 295 | SK_DECLARE_INTERNAL_LLIST_INTERFACE(Plot); |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 296 | |
| 297 | public: |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 298 | /** index() is a unique id for the plot relative to the owning GrAtlas and page. */ |
| 299 | uint32_t index() const { return fPlotIndex; } |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 300 | /** |
| 301 | * genID() is incremented when the plot is evicted due to a atlas spill. It is used to know |
| 302 | * if a particular subimage is still present in the atlas. |
| 303 | */ |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 304 | uint64_t genID() const { return fGenID; } |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 305 | GrDrawOpAtlas::PlotLocator plotLocator() const { |
| 306 | SkASSERT(GrDrawOpAtlas::kInvalidPlotLocator != fPlotLocator); |
| 307 | return fPlotLocator; |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 308 | } |
| 309 | SkDEBUGCODE(size_t bpp() const { return fBytesPerPixel; }) |
| 310 | |
| 311 | bool addSubImage(int width, int height, const void* image, SkIPoint16* loc); |
| 312 | |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 313 | /** |
| 314 | * To manage the lifetime of a plot, we use two tokens. We use the last upload token to |
| 315 | * know when we can 'piggy back' uploads, i.e. if the last upload hasn't been flushed to |
| 316 | * the gpu, we don't need to issue a new upload even if we update the cpu backing store. We |
| 317 | * use lastUse to determine when we can evict a plot from the cache, i.e. if the last use |
| 318 | * has already flushed through the gpu then we can reuse the plot. |
| 319 | */ |
Brian Salomon | 943ed79 | 2017-10-30 09:37:55 -0400 | [diff] [blame] | 320 | GrDeferredUploadToken lastUploadToken() const { return fLastUpload; } |
| 321 | GrDeferredUploadToken lastUseToken() const { return fLastUse; } |
| 322 | void setLastUploadToken(GrDeferredUploadToken token) { fLastUpload = token; } |
| 323 | void setLastUseToken(GrDeferredUploadToken token) { fLastUse = token; } |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 324 | |
Brian Salomon | 943ed79 | 2017-10-30 09:37:55 -0400 | [diff] [blame] | 325 | void uploadToTexture(GrDeferredTextureUploadWritePixelsFn&, GrTextureProxy*); |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 326 | void resetRects(); |
| 327 | |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 328 | int flushesSinceLastUsed() { return fFlushesSinceLastUse; } |
| 329 | void resetFlushesSinceLastUsed() { fFlushesSinceLastUse = 0; } |
| 330 | void incFlushesSinceLastUsed() { fFlushesSinceLastUse++; } |
| 331 | |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 332 | private: |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 333 | Plot(int pageIndex, int plotIndex, GenerationCounter* generationCounter, |
| 334 | int offX, int offY, int width, int height, GrColorType colorType); |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 335 | |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 336 | ~Plot() override; |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 337 | |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 338 | /** |
| 339 | * Create a clone of this plot. The cloned plot will take the place of the current plot in |
| 340 | * the atlas |
| 341 | */ |
| 342 | Plot* clone() const { |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 343 | return new Plot( |
| 344 | fPageIndex, fPlotIndex, fGenerationCounter, fX, fY, fWidth, fHeight, fColorType); |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 345 | } |
| 346 | |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 347 | static GrDrawOpAtlas::PlotLocator CreatePlotLocator( |
| 348 | uint32_t pageIdx, uint32_t plotIdx, uint64_t generation) { |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 349 | SkASSERT(pageIdx < (1 << 8)); |
Brian Salomon | 9f545bc | 2017-11-06 10:36:57 -0500 | [diff] [blame] | 350 | SkASSERT(pageIdx < kMaxMultitexturePages); |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 351 | SkASSERT(plotIdx < (1 << 8)); |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 352 | SkASSERT(generation < ((uint64_t)1 << 48)); |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 353 | return generation << 16 | plotIdx << 8 | pageIdx; |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 354 | } |
| 355 | |
Brian Salomon | 943ed79 | 2017-10-30 09:37:55 -0400 | [diff] [blame] | 356 | GrDeferredUploadToken fLastUpload; |
| 357 | GrDeferredUploadToken fLastUse; |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 358 | // the number of flushes since this plot has been last used |
| 359 | int fFlushesSinceLastUse; |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 360 | |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 361 | struct { |
| 362 | const uint32_t fPageIndex : 16; |
| 363 | const uint32_t fPlotIndex : 16; |
| 364 | }; |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 365 | GenerationCounter* const fGenerationCounter; |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 366 | uint64_t fGenID; |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 367 | GrDrawOpAtlas::PlotLocator fPlotLocator; |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 368 | unsigned char* fData; |
| 369 | const int fWidth; |
| 370 | const int fHeight; |
| 371 | const int fX; |
| 372 | const int fY; |
Herb Derby | 73c7587 | 2020-01-22 18:09:16 -0500 | [diff] [blame] | 373 | GrRectanizerSkyline fRectanizer; |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 374 | const SkIPoint16 fOffset; // the offset of the plot in the backing texture |
Robert Phillips | 42dda08 | 2019-05-14 13:29:45 -0400 | [diff] [blame] | 375 | const GrColorType fColorType; |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 376 | const size_t fBytesPerPixel; |
| 377 | SkIRect fDirtyRect; |
| 378 | SkDEBUGCODE(bool fDirty); |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 379 | |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 380 | friend class GrDrawOpAtlas; |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 381 | |
| 382 | typedef SkRefCnt INHERITED; |
| 383 | }; |
| 384 | |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 385 | typedef SkTInternalLList<Plot> PlotList; |
robertphillips | 2b0536f | 2015-11-06 14:10:42 -0800 | [diff] [blame] | 386 | |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 387 | static uint32_t GetPlotIndexFromID(PlotLocator plotLocator) { |
| 388 | return (plotLocator >> 8) & 0xff; |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 389 | } |
| 390 | |
joshualitt | 8db6fdc | 2015-07-31 08:25:07 -0700 | [diff] [blame] | 391 | // top 48 bits are reserved for the generation ID |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 392 | static uint64_t GetGenerationFromID(PlotLocator plotLocator) { |
| 393 | return (plotLocator >> 16) & 0xffffffffffff; |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 394 | } |
| 395 | |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 396 | inline bool updatePlot(GrDeferredUploadTarget*, PlotLocator*, Plot*); |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 397 | |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 398 | inline void makeMRU(Plot* plot, int pageIdx) { |
| 399 | if (fPages[pageIdx].fPlotList.head() == plot) { |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 400 | return; |
| 401 | } |
| 402 | |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 403 | fPages[pageIdx].fPlotList.remove(plot); |
| 404 | fPages[pageIdx].fPlotList.addToHead(plot); |
| 405 | |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 406 | // No MRU update for pages -- since we will always try to add from |
| 407 | // the front and remove from the back there is no need for MRU. |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 408 | } |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 409 | |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 410 | bool uploadToPage(const GrCaps&, unsigned int pageIdx, PlotLocator* plotLocator, |
Greg Daniel | 7fd7a8a | 2019-10-10 16:10:31 -0400 | [diff] [blame] | 411 | GrDeferredUploadTarget* target, int width, int height, const void* image, |
| 412 | SkIPoint16* loc); |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 413 | |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 414 | bool createPages(GrProxyProvider*, GenerationCounter*); |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 415 | bool activateNewPage(GrResourceProvider*); |
| 416 | void deactivateLastPage(); |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 417 | |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 418 | void processEviction(PlotLocator); |
Jim Van Verth | c3269ae | 2017-09-28 15:04:00 -0400 | [diff] [blame] | 419 | inline void processEvictionAndResetRects(Plot* plot) { |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 420 | this->processEviction(plot->plotLocator()); |
Jim Van Verth | c3269ae | 2017-09-28 15:04:00 -0400 | [diff] [blame] | 421 | plot->resetRects(); |
| 422 | } |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 423 | |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 424 | GrBackendFormat fFormat; |
Robert Phillips | 42dda08 | 2019-05-14 13:29:45 -0400 | [diff] [blame] | 425 | GrColorType fColorType; |
Jim Van Verth | d74f3f2 | 2017-08-31 16:44:08 -0400 | [diff] [blame] | 426 | int fTextureWidth; |
| 427 | int fTextureHeight; |
Robert Phillips | 32f2818 | 2017-02-28 16:20:03 -0500 | [diff] [blame] | 428 | int fPlotWidth; |
| 429 | int fPlotHeight; |
Jim Van Verth | 06f593c | 2018-02-20 11:30:10 -0500 | [diff] [blame] | 430 | unsigned int fNumPlots; |
robertphillips | 2b0536f | 2015-11-06 14:10:42 -0800 | [diff] [blame] | 431 | |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 432 | GenerationCounter* const fGenerationCounter; |
| 433 | uint64_t fAtlasGeneration; |
| 434 | |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 435 | // nextTokenToFlush() value at the end of the previous flush |
Brian Salomon | 943ed79 | 2017-10-30 09:37:55 -0400 | [diff] [blame] | 436 | GrDeferredUploadToken fPrevFlushToken; |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 437 | |
Herb Derby | 1a496c5 | 2020-01-22 17:26:56 -0500 | [diff] [blame] | 438 | std::vector<EvictionCallback*> fEvictionCallbacks; |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 439 | |
| 440 | struct Page { |
| 441 | // allocated array of Plots |
| 442 | std::unique_ptr<sk_sp<Plot>[]> fPlotArray; |
| 443 | // LRU list of Plots (MRU at head - LRU at tail) |
| 444 | PlotList fPlotList; |
| 445 | }; |
| 446 | // proxies kept separate to make it easier to pass them up to client |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 447 | GrSurfaceProxyView fViews[kMaxMultitexturePages]; |
Brian Salomon | 9f545bc | 2017-11-06 10:36:57 -0500 | [diff] [blame] | 448 | Page fPages[kMaxMultitexturePages]; |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 449 | uint32_t fMaxPages; |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 450 | |
| 451 | uint32_t fNumActivePages; |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 452 | }; |
| 453 | |
Herb Derby | bbf5fb5 | 2018-10-15 16:39:39 -0400 | [diff] [blame] | 454 | // There are three atlases (A8, 565, ARGB) that are kept in relation with one another. In |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 455 | // general, the A8 dimensions are 2x the 565 and ARGB dimensions with the constraint that an atlas |
Herb Derby | bbf5fb5 | 2018-10-15 16:39:39 -0400 | [diff] [blame] | 456 | // size will always contain at least one plot. Since the ARGB atlas takes the most space, its |
| 457 | // dimensions are used to size the other two atlases. |
| 458 | class GrDrawOpAtlasConfig { |
| 459 | public: |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 460 | // The capabilities of the GPU define maxTextureSize. The client provides maxBytes, and this |
| 461 | // represents the largest they want a single atlas texture to be. Due to multitexturing, we |
| 462 | // may expand temporarily to use more space as needed. |
| 463 | GrDrawOpAtlasConfig(int maxTextureSize, size_t maxBytes); |
Herb Derby | bbf5fb5 | 2018-10-15 16:39:39 -0400 | [diff] [blame] | 464 | |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 465 | // For testing only - make minimum sized atlases -- a single plot for ARGB, four for A8 |
| 466 | GrDrawOpAtlasConfig() : GrDrawOpAtlasConfig(kMaxAtlasDim, 0) {} |
Herb Derby | bbf5fb5 | 2018-10-15 16:39:39 -0400 | [diff] [blame] | 467 | |
Herb Derby | 15d9ef2 | 2018-10-18 13:41:32 -0400 | [diff] [blame] | 468 | SkISize atlasDimensions(GrMaskFormat type) const; |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 469 | SkISize plotDimensions(GrMaskFormat type) const; |
Herb Derby | bbf5fb5 | 2018-10-15 16:39:39 -0400 | [diff] [blame] | 470 | |
| 471 | private: |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 472 | // On some systems texture coordinates are represented using half-precision floating point, |
| 473 | // which limits the largest atlas dimensions to 2048x2048. |
| 474 | // For simplicity we'll use this constraint for all of our atlas textures. |
| 475 | // This can be revisited later if we need larger atlases. |
| 476 | static constexpr int kMaxAtlasDim = 2048; |
Herb Derby | bbf5fb5 | 2018-10-15 16:39:39 -0400 | [diff] [blame] | 477 | |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 478 | SkISize fARGBDimensions; |
| 479 | int fMaxTextureSize; |
Herb Derby | bbf5fb5 | 2018-10-15 16:39:39 -0400 | [diff] [blame] | 480 | }; |
| 481 | |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 482 | #endif |