| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #ifndef GrAtlas_DEFINED | 9 #ifndef GrAtlas_DEFINED |
| 10 #define GrAtlas_DEFINED | 10 #define GrAtlas_DEFINED |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrPlot); | 34 SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrPlot); |
| 35 | 35 |
| 36 // This returns a plot ID unique to each plot in a given GrAtlas. They are | 36 // This returns a plot ID unique to each plot in a given GrAtlas. They are |
| 37 // consecutive and start at 0. | 37 // consecutive and start at 0. |
| 38 int id() const { return fID; } | 38 int id() const { return fID; } |
| 39 | 39 |
| 40 GrTexture* texture() const { return fTexture; } | 40 GrTexture* texture() const { return fTexture; } |
| 41 | 41 |
| 42 bool addSubImage(int width, int height, const void*, SkIPoint16*); | 42 bool addSubImage(int width, int height, const void*, SkIPoint16*); |
| 43 | 43 |
| 44 GrDrawTarget::DrawToken drawToken() const { return fDrawToken; } | |
| 45 void setDrawToken(GrDrawTarget::DrawToken draw) { fDrawToken = draw; } | |
| 46 | |
| 47 void uploadToTexture(); | |
| 48 | |
| 49 void resetRects(); | 44 void resetRects(); |
| 50 | 45 |
| 51 private: | 46 private: |
| 52 GrPlot(); | 47 GrPlot(); |
| 53 ~GrPlot(); // does not try to delete the fNext field | 48 ~GrPlot(); // does not try to delete the fNext field |
| 54 void init(GrAtlas* atlas, int id, int offX, int offY, int width, int height,
size_t bpp, | 49 void init(GrAtlas* atlas, int id, int offX, int offY, int width, int height,
size_t bpp, |
| 55 bool batchUploads); | 50 bool batchUploads); |
| 56 | 51 |
| 57 // for recycling | |
| 58 GrDrawTarget::DrawToken fDrawToken; | |
| 59 | |
| 60 int fID; | 52 int fID; |
| 61 unsigned char* fPlotData; | 53 unsigned char* fPlotData; |
| 62 GrTexture* fTexture; | 54 GrTexture* fTexture; |
| 63 GrRectanizer* fRects; | 55 GrRectanizer* fRects; |
| 64 GrAtlas* fAtlas; | 56 GrAtlas* fAtlas; |
| 65 SkIPoint16 fOffset; // the offset of the plot in the bac
king texture | 57 SkIPoint16 fOffset; // the offset of the plot in the bac
king texture |
| 66 size_t fBytesPerPixel; | 58 size_t fBytesPerPixel; |
| 67 SkIRect fDirtyRect; | 59 SkIRect fDirtyRect; |
| 68 bool fDirty; | 60 bool fDirty; |
| 69 bool fBatchUploads; | 61 bool fBatchUploads; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // Adds a width x height subimage to the atlas. Upon success it returns | 93 // Adds a width x height subimage to the atlas. Upon success it returns |
| 102 // the containing GrPlot and absolute location in the backing texture. | 94 // the containing GrPlot and absolute location in the backing texture. |
| 103 // NULL is returned if the subimage cannot fit in the atlas. | 95 // NULL is returned if the subimage cannot fit in the atlas. |
| 104 // If provided, the image data will either be immediately uploaded or | 96 // If provided, the image data will either be immediately uploaded or |
| 105 // written to the CPU-side backing bitmap. | 97 // written to the CPU-side backing bitmap. |
| 106 GrPlot* addToAtlas(ClientPlotUsage*, int width, int height, const void* imag
e, SkIPoint16* loc); | 98 GrPlot* addToAtlas(ClientPlotUsage*, int width, int height, const void* imag
e, SkIPoint16* loc); |
| 107 | 99 |
| 108 // remove reference to this plot | 100 // remove reference to this plot |
| 109 static void RemovePlot(ClientPlotUsage* usage, const GrPlot* plot); | 101 static void RemovePlot(ClientPlotUsage* usage, const GrPlot* plot); |
| 110 | 102 |
| 111 // get a plot that's not being used by the current draw | |
| 112 // this allows us to overwrite this plot without flushing | |
| 113 GrPlot* getUnusedPlot(); | |
| 114 | |
| 115 GrTexture* getTexture() const { | 103 GrTexture* getTexture() const { |
| 116 return fTexture; | 104 return fTexture; |
| 117 } | 105 } |
| 118 | 106 |
| 119 void uploadPlotsToTexture(); | |
| 120 | |
| 121 enum IterOrder { | 107 enum IterOrder { |
| 122 kLRUFirst_IterOrder, | 108 kLRUFirst_IterOrder, |
| 123 kMRUFirst_IterOrder | 109 kMRUFirst_IterOrder |
| 124 }; | 110 }; |
| 125 | 111 |
| 126 typedef GrPlotList::Iter PlotIter; | 112 typedef GrPlotList::Iter PlotIter; |
| 127 GrPlot* iterInit(PlotIter* iter, IterOrder order) { | 113 GrPlot* iterInit(PlotIter* iter, IterOrder order) { |
| 128 return iter->init(fPlotList, kLRUFirst_IterOrder == order | 114 return iter->init(fPlotList, kLRUFirst_IterOrder == order |
| 129 ? GrPlotList::Iter::kTail
_IterStart | 115 ? GrPlotList::Iter::kTail
_IterStart |
| 130 : GrPlotList::Iter::kHead
_IterStart); | 116 : GrPlotList::Iter::kHead
_IterStart); |
| 131 } | 117 } |
| 132 | 118 |
| 133 private: | 119 private: |
| 134 void makeMRU(GrPlot* plot); | 120 void makeMRU(GrPlot* plot); |
| 135 | 121 |
| 136 GrGpu* fGpu; | 122 GrGpu* fGpu; |
| 137 GrPixelConfig fPixelConfig; | 123 GrPixelConfig fPixelConfig; |
| 138 GrSurfaceFlags fFlags; | 124 GrSurfaceFlags fFlags; |
| 139 GrTexture* fTexture; | 125 GrTexture* fTexture; |
| 140 SkISize fBackingTextureSize; | 126 SkISize fBackingTextureSize; |
| 141 int fNumPlotsX; | 127 int fNumPlotsX; |
| 142 int fNumPlotsY; | 128 int fNumPlotsY; |
| 143 bool fBatchUploads; | 129 bool fBatchUploads; |
| 144 | 130 |
| 145 // allocated array of GrPlots | 131 // allocated array of GrPlots |
| 146 GrPlot* fPlotArray; | 132 GrPlot* fPlotArray; |
| 147 // LRU list of GrPlots (MRU at head - LRU at tail) | 133 // LRU list of GrPlots (MRU at head - LRU at tail) |
| 148 GrPlotList fPlotList; | 134 GrPlotList fPlotList; |
| 149 }; | 135 }; |
| 150 | 136 |
| 151 #endif | 137 #endif |
| OLD | NEW |