epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 2 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 3 | * Copyright 2010 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 10 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 11 | #ifndef GrAtlas_DEFINED |
| 12 | #define GrAtlas_DEFINED |
| 13 | |
| 14 | #include "GrPoint.h" |
| 15 | #include "GrTexture.h" |
| 16 | #include "GrTDArray.h" |
| 17 | |
| 18 | class GrGpu; |
| 19 | class GrRectanizer; |
| 20 | class GrAtlasMgr; |
| 21 | |
| 22 | class GrAtlas { |
| 23 | public: |
reed@google.com | 98539c6 | 2011-03-15 15:40:16 +0000 | [diff] [blame] | 24 | GrAtlas(GrAtlasMgr*, int plotX, int plotY, GrMaskFormat); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 25 | |
| 26 | int getPlotX() const { return fPlot.fX; } |
| 27 | int getPlotY() const { return fPlot.fY; } |
reed@google.com | 98539c6 | 2011-03-15 15:40:16 +0000 | [diff] [blame] | 28 | GrMaskFormat getMaskFormat() const { return fMaskFormat; } |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 29 | |
| 30 | GrTexture* texture() const { return fTexture; } |
| 31 | |
| 32 | bool addSubImage(int width, int height, const void*, GrIPoint16*); |
| 33 | |
| 34 | static void FreeLList(GrAtlas* atlas) { |
| 35 | while (atlas) { |
| 36 | GrAtlas* next = atlas->fNext; |
| 37 | delete atlas; |
| 38 | atlas = next; |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | // testing |
| 43 | GrAtlas* nextAtlas() const { return fNext; } |
| 44 | |
| 45 | private: |
| 46 | ~GrAtlas(); // does not try to delete the fNext field |
| 47 | |
| 48 | GrAtlas* fNext; |
| 49 | GrTexture* fTexture; |
| 50 | GrRectanizer* fRects; |
| 51 | GrAtlasMgr* fAtlasMgr; |
| 52 | GrIPoint16 fPlot; |
reed@google.com | 98539c6 | 2011-03-15 15:40:16 +0000 | [diff] [blame] | 53 | GrMaskFormat fMaskFormat; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 54 | |
| 55 | friend class GrAtlasMgr; |
| 56 | }; |
| 57 | |
| 58 | class GrPlotMgr; |
| 59 | |
| 60 | class GrAtlasMgr { |
| 61 | public: |
| 62 | GrAtlasMgr(GrGpu*); |
| 63 | ~GrAtlasMgr(); |
| 64 | |
| 65 | GrAtlas* addToAtlas(GrAtlas*, int width, int height, const void*, |
reed@google.com | 98539c6 | 2011-03-15 15:40:16 +0000 | [diff] [blame] | 66 | GrMaskFormat, GrIPoint16*); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 67 | |
reed@google.com | 759c16e | 2011-03-15 19:15:15 +0000 | [diff] [blame] | 68 | GrTexture* getTexture(GrMaskFormat format) const { |
| 69 | GrAssert((unsigned)format < kCount_GrMaskFormats); |
| 70 | return fTexture[format]; |
| 71 | } |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 72 | |
| 73 | // to be called by ~GrAtlas() |
| 74 | void freePlot(int x, int y); |
| 75 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 76 | private: |
| 77 | GrGpu* fGpu; |
reed@google.com | 759c16e | 2011-03-15 19:15:15 +0000 | [diff] [blame] | 78 | GrTexture* fTexture[kCount_GrMaskFormats]; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 79 | GrPlotMgr* fPlotMgr; |
| 80 | }; |
| 81 | |
| 82 | #endif |
| 83 | |
| 84 | |