| 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 | 9 |
| 10 | 10 |
| 11 #ifndef GrAtlas_DEFINED | 11 #ifndef GrAtlas_DEFINED |
| 12 #define GrAtlas_DEFINED | 12 #define GrAtlas_DEFINED |
| 13 | 13 |
| 14 #include "GrPoint.h" | 14 #include "GrPoint.h" |
| 15 #include "GrTexture.h" | 15 #include "GrTexture.h" |
| 16 #include "GrDrawTarget.h" | 16 #include "GrDrawTarget.h" |
| 17 | 17 |
| 18 class GrGpu; | 18 class GrGpu; |
| 19 class GrRectanizer; | 19 class GrRectanizer; |
| 20 class GrAtlasMgr; | 20 class GrAtlasMgr; |
| 21 | 21 |
| 22 class GrAtlas { | 22 class GrAtlas { |
| 23 public: | 23 public: |
| 24 int getPlotX() const { return fPlot.fX; } | 24 int getPlotX() const { return fPlot.fX; } |
| 25 int getPlotY() const { return fPlot.fY; } | 25 int getPlotY() const { return fPlot.fY; } |
| 26 GrMaskFormat getMaskFormat() const { return fMaskFormat; } | |
| 27 | 26 |
| 28 GrTexture* texture() const { return fTexture; } | 27 GrTexture* texture() const { return fTexture; } |
| 29 | 28 |
| 30 bool addSubImage(int width, int height, const void*, GrIPoint16*); | 29 bool addSubImage(int width, int height, const void*, GrIPoint16*); |
| 31 | 30 |
| 32 static void FreeLList(GrAtlas* atlas) { | 31 static void FreeLList(GrAtlas* atlas) { |
| 33 while (NULL != atlas) { | 32 while (NULL != atlas) { |
| 34 GrAtlas* next = atlas->fNext; | 33 GrAtlas* next = atlas->fNext; |
| 35 delete atlas; | 34 delete atlas; |
| 36 atlas = next; | 35 atlas = next; |
| 37 } | 36 } |
| 38 } | 37 } |
| 39 | 38 |
| 40 static bool RemoveUnusedAtlases(GrAtlasMgr* atlasMgr, GrAtlas** startAtlas); | 39 static bool RemoveUnusedAtlases(GrAtlasMgr* atlasMgr, GrAtlas** startAtlas); |
| 41 | 40 |
| 42 GrDrawTarget::DrawToken drawToken() const { return fDrawToken; } | 41 GrDrawTarget::DrawToken drawToken() const { return fDrawToken; } |
| 43 void setDrawToken(GrDrawTarget::DrawToken draw) { fDrawToken = draw; } | 42 void setDrawToken(GrDrawTarget::DrawToken draw) { fDrawToken = draw; } |
| 44 | 43 |
| 45 private: | 44 private: |
| 46 GrAtlas(GrAtlasMgr*, int plotX, int plotY, GrMaskFormat format); | 45 GrAtlas(GrAtlasMgr*, int plotX, int plotY, int bpp); |
| 47 ~GrAtlas(); // does not try to delete the fNext field | 46 ~GrAtlas(); // does not try to delete the fNext field |
| 48 | 47 |
| 49 // for recycling | 48 // for recycling |
| 50 GrDrawTarget::DrawToken fDrawToken; | 49 GrDrawTarget::DrawToken fDrawToken; |
| 51 | 50 |
| 52 GrAtlas* fNext; | 51 GrAtlas* fNext; |
| 53 | 52 |
| 54 GrTexture* fTexture; | 53 GrTexture* fTexture; |
| 55 GrRectanizer* fRects; | 54 GrRectanizer* fRects; |
| 56 GrAtlasMgr* fAtlasMgr; | 55 GrAtlasMgr* fAtlasMgr; |
| 57 GrIPoint16 fPlot; | 56 GrIPoint16 fPlot; |
| 58 GrMaskFormat fMaskFormat; | 57 int fBytesPerPixel; |
| 59 | 58 |
| 60 friend class GrAtlasMgr; | 59 friend class GrAtlasMgr; |
| 61 }; | 60 }; |
| 62 | 61 |
| 63 class GrPlotMgr; | 62 class GrPlotMgr; |
| 64 | 63 |
| 65 class GrAtlasMgr { | 64 class GrAtlasMgr { |
| 66 public: | 65 public: |
| 67 GrAtlasMgr(GrGpu*, GrMaskFormat); | 66 GrAtlasMgr(GrGpu*, GrPixelConfig); |
| 68 ~GrAtlasMgr(); | 67 ~GrAtlasMgr(); |
| 69 | 68 |
| 70 GrAtlas* addToAtlas(GrAtlas**, int width, int height, const void*, GrIPoint1
6*); | 69 GrAtlas* addToAtlas(GrAtlas**, int width, int height, const void*, GrIPoint1
6*); |
| 71 void deleteAtlas(GrAtlas* atlas) { delete atlas; } | 70 void deleteAtlas(GrAtlas* atlas) { delete atlas; } |
| 72 | 71 |
| 73 GrTexture* getTexture() const { | 72 GrTexture* getTexture() const { |
| 74 return fTexture; | 73 return fTexture; |
| 75 } | 74 } |
| 76 | 75 |
| 77 // to be called by ~GrAtlas() | 76 // to be called by ~GrAtlas() |
| 78 void freePlot(int x, int y); | 77 void freePlot(int x, int y); |
| 79 | 78 |
| 80 private: | 79 private: |
| 81 GrGpu* fGpu; | 80 GrGpu* fGpu; |
| 82 GrMaskFormat fMaskFormat; | 81 GrPixelConfig fPixelConfig; |
| 83 GrTexture* fTexture; | 82 GrTexture* fTexture; |
| 84 GrPlotMgr* fPlotMgr; | 83 GrPlotMgr* fPlotMgr; |
| 85 }; | 84 }; |
| 86 | 85 |
| 87 #endif | 86 #endif |
| OLD | NEW |