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" |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 16 | |
| 17 | class GrGpu; |
| 18 | class GrRectanizer; |
| 19 | class GrAtlasMgr; |
| 20 | |
| 21 | class GrAtlas { |
| 22 | public: |
reed@google.com | 98539c6 | 2011-03-15 15:40:16 +0000 | [diff] [blame] | 23 | GrAtlas(GrAtlasMgr*, int plotX, int plotY, GrMaskFormat); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 24 | |
| 25 | int getPlotX() const { return fPlot.fX; } |
| 26 | int getPlotY() const { return fPlot.fY; } |
reed@google.com | 98539c6 | 2011-03-15 15:40:16 +0000 | [diff] [blame] | 27 | GrMaskFormat getMaskFormat() const { return fMaskFormat; } |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 28 | |
| 29 | GrTexture* texture() const { return fTexture; } |
| 30 | |
| 31 | bool addSubImage(int width, int height, const void*, GrIPoint16*); |
| 32 | |
| 33 | static void FreeLList(GrAtlas* atlas) { |
| 34 | while (atlas) { |
| 35 | GrAtlas* next = atlas->fNext; |
| 36 | delete atlas; |
| 37 | atlas = next; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | // testing |
| 42 | GrAtlas* nextAtlas() const { return fNext; } |
| 43 | |
| 44 | private: |
| 45 | ~GrAtlas(); // does not try to delete the fNext field |
| 46 | |
| 47 | GrAtlas* fNext; |
| 48 | GrTexture* fTexture; |
| 49 | GrRectanizer* fRects; |
| 50 | GrAtlasMgr* fAtlasMgr; |
| 51 | GrIPoint16 fPlot; |
reed@google.com | 98539c6 | 2011-03-15 15:40:16 +0000 | [diff] [blame] | 52 | GrMaskFormat fMaskFormat; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 53 | |
| 54 | friend class GrAtlasMgr; |
| 55 | }; |
| 56 | |
| 57 | class GrPlotMgr; |
| 58 | |
| 59 | class GrAtlasMgr { |
| 60 | public: |
| 61 | GrAtlasMgr(GrGpu*); |
| 62 | ~GrAtlasMgr(); |
| 63 | |
| 64 | GrAtlas* addToAtlas(GrAtlas*, int width, int height, const void*, |
reed@google.com | 98539c6 | 2011-03-15 15:40:16 +0000 | [diff] [blame] | 65 | GrMaskFormat, GrIPoint16*); |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 66 | |
reed@google.com | 759c16e | 2011-03-15 19:15:15 +0000 | [diff] [blame] | 67 | GrTexture* getTexture(GrMaskFormat format) const { |
| 68 | GrAssert((unsigned)format < kCount_GrMaskFormats); |
| 69 | return fTexture[format]; |
| 70 | } |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 71 | |
| 72 | // to be called by ~GrAtlas() |
| 73 | void freePlot(int x, int y); |
| 74 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 75 | private: |
| 76 | GrGpu* fGpu; |
reed@google.com | 759c16e | 2011-03-15 19:15:15 +0000 | [diff] [blame] | 77 | GrTexture* fTexture[kCount_GrMaskFormats]; |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 78 | GrPlotMgr* fPlotMgr; |
| 79 | }; |
| 80 | |
| 81 | #endif |