Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrBatchAtlas_DEFINED | 8 #ifndef GrBatchAtlas_DEFINED |
| 9 #define GrBatchAtlas_DEFINED | 9 #define GrBatchAtlas_DEFINED |
| 10 | 10 |
| 11 #include "GrTexture.h" | 11 #include "GrTexture.h" |
| 12 #include "SkPoint.h" | 12 #include "SkPoint.h" |
| 13 #include "SkTDArray.h" | 13 #include "SkTDArray.h" |
| 14 #include "SkTInternalLList.h" | 14 #include "SkTInternalLList.h" |
| 15 | 15 |
| 16 class BatchPlot; | 16 class BatchPlot; |
| 17 class GrBatchTarget; | 17 class GrBatchTarget; |
| 18 class GrRectanizer; | 18 class GrRectanizer; |
| 19 | 19 |
| 20 typedef SkTInternalLList<BatchPlot> GrBatchPlotList; | 20 typedef SkTInternalLList<BatchPlot> GrBatchPlotList; |
| 21 | 21 |
| 22 class GrBatchAtlas { | 22 class GrBatchAtlas { |
| 23 public: | 23 public: |
| 24 typedef uint64_t BatchToken; | 24 typedef uint64_t BatchToken; |
| 25 // An AtlasID is an opaque handle which callers can use to determine if the atlas contains | 25 // An AtlasID is an opaque handle which callers can use to determine if the atlas contains |
| 26 // a specific piece of data | 26 // a specific piece of data |
| 27 typedef uint32_t AtlasID; | 27 typedef uint64_t AtlasID; |
| 28 static const uint32_t kInvalidAtlasID = 0; | 28 static const uint32_t kInvalidAtlasID = 0; |
| 29 static const uint64_t kInvalidAtlasGeneration = 0; | 29 static const uint64_t kInvalidAtlasGeneration = 0; |
| 30 | 30 |
| 31 // A function pointer for use as a callback during eviction. Whenever GrBat chAtlas evicts a | 31 // A function pointer for use as a callback during eviction. Whenever GrBat chAtlas evicts a |
| 32 // specific AtlasID, it will call all of the registered listeners so they ca n optionally process | 32 // specific AtlasID, it will call all of the registered listeners so they ca n optionally process |
| 33 // the eviction | 33 // the eviction |
| 34 typedef void (*EvictionFunc)(GrBatchAtlas::AtlasID, void*); | 34 typedef void (*EvictionFunc)(GrBatchAtlas::AtlasID, void*); |
| 35 | 35 |
| 36 GrBatchAtlas(GrTexture*, int numPlotsX, int numPlotsY); | 36 GrBatchAtlas(GrTexture*, int numPlotsX, int numPlotsY); |
| 37 ~GrBatchAtlas(); | 37 ~GrBatchAtlas(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 friend class GrBatchAtlas; | 99 friend class GrBatchAtlas; |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 void setLastUseTokenBulk(const BulkUseTokenUpdater& reffer, BatchToken); | 102 void setLastUseTokenBulk(const BulkUseTokenUpdater& reffer, BatchToken); |
| 103 | 103 |
| 104 static const int kGlyphMaxDim = 256; | 104 static const int kGlyphMaxDim = 256; |
| 105 static bool GlyphTooLargeForAtlas(int width, int height) { | 105 static bool GlyphTooLargeForAtlas(int width, int height) { |
| 106 return width > kGlyphMaxDim || height > kGlyphMaxDim; | 106 return width > kGlyphMaxDim || height > kGlyphMaxDim; |
| 107 } | 107 } |
| 108 | 108 |
| 109 private: | 109 private: |
|
robertphillips
2015/07/31 15:00:54
uint16_t ? do we care ?
| |
| 110 static int GetIndexFromID(AtlasID id) { | 110 static uint32_t GetIndexFromID(AtlasID id) { |
| 111 return id & 0xffff; | 111 return id & 0xffff; |
| 112 } | 112 } |
| 113 | 113 |
| 114 static int GetGenerationFromID(AtlasID id) { | 114 // top 48 bits are reserved for the generation ID |
| 115 return (id >> 16) & 0xffff; | 115 static uint64_t GetGenerationFromID(AtlasID id) { |
|
robertphillips
2015/07/31 15:00:54
Aren't we missing an 'ff' here ?
| |
| 116 return (id >> 16) & 0xffffffffff; | |
| 116 } | 117 } |
| 117 | 118 |
| 118 inline void updatePlot(GrBatchTarget*, AtlasID*, BatchPlot*); | 119 inline void updatePlot(GrBatchTarget*, AtlasID*, BatchPlot*); |
| 119 | 120 |
| 120 inline void makeMRU(BatchPlot* plot); | 121 inline void makeMRU(BatchPlot* plot); |
| 121 | 122 |
| 122 inline void processEviction(AtlasID); | 123 inline void processEviction(AtlasID); |
| 123 | 124 |
| 124 GrTexture* fTexture; | 125 GrTexture* fTexture; |
|
robertphillips
2015/07/31 15:00:54
Why do we have to be more explicit about these typ
| |
| 125 int fNumPlotsX; | 126 uint32_t fNumPlotsX; |
| 126 int fNumPlotsY; | 127 uint32_t fNumPlotsY; |
| 127 int fPlotWidth; | 128 uint32_t fPlotWidth; |
| 128 int fPlotHeight; | 129 uint32_t fPlotHeight; |
| 129 size_t fBPP; | 130 size_t fBPP; |
| 130 uint64_t fAtlasGeneration; | 131 uint64_t fAtlasGeneration; |
| 131 | 132 |
| 132 struct EvictionData { | 133 struct EvictionData { |
| 133 EvictionFunc fFunc; | 134 EvictionFunc fFunc; |
| 134 void* fData; | 135 void* fData; |
| 135 }; | 136 }; |
| 136 | 137 |
| 137 SkTDArray<EvictionData> fEvictionCallbacks; | 138 SkTDArray<EvictionData> fEvictionCallbacks; |
| 138 // allocated array of GrBatchPlots | 139 // allocated array of GrBatchPlots |
| 139 SkAutoTUnref<BatchPlot>* fPlotArray; | 140 SkAutoTUnref<BatchPlot>* fPlotArray; |
| 140 // LRU list of GrPlots (MRU at head - LRU at tail) | 141 // LRU list of GrPlots (MRU at head - LRU at tail) |
| 141 GrBatchPlotList fPlotList; | 142 GrBatchPlotList fPlotList; |
| 142 }; | 143 }; |
| 143 | 144 |
| 144 #endif | 145 #endif |
| OLD | NEW |