OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 SkMipMap_DEFINED | 8 #ifndef SkMipMap_DEFINED |
9 #define SkMipMap_DEFINED | 9 #define SkMipMap_DEFINED |
10 | 10 |
11 #include "SkRefCnt.h" | 11 #include "SkRefCnt.h" |
12 #include "SkScalar.h" | 12 #include "SkScalar.h" |
13 | 13 |
14 class SkBitmap; | 14 class SkBitmap; |
15 | 15 |
16 class SkMipMap : public SkRefCnt { | 16 class SkMipMap : public SkRefCnt { |
17 public: | 17 public: |
18 static SkMipMap* Build(const SkBitmap& src); | 18 static SkMipMap* Build(const SkBitmap& src); |
19 | 19 |
20 struct Level { | 20 struct Level { |
21 void* fPixels; | 21 void* fPixels; |
22 uint32_t fRowBytes; | 22 uint32_t fRowBytes; |
23 uint32_t fWidth, fHeight; | 23 uint32_t fWidth, fHeight; |
| 24 float fScale; // < 1.0 |
24 }; | 25 }; |
25 | 26 |
26 bool extractLevel(SkScalar scale, Level*) const; | 27 bool extractLevel(SkScalar scale, Level*) const; |
27 | 28 |
| 29 size_t getSize() const { return fSize; } |
| 30 |
28 private: | 31 private: |
| 32 size_t fSize; |
29 Level* fLevels; | 33 Level* fLevels; |
30 int fCount; | 34 int fCount; |
31 | 35 |
32 // we take ownership of levels, and will free it with sk_free() | 36 // we take ownership of levels, and will free it with sk_free() |
33 SkMipMap(Level* levels, int count) : fLevels(levels), fCount(count) { | 37 SkMipMap(Level* levels, int count, size_t size); |
34 SkASSERT(levels); | 38 virtual ~SkMipMap(); |
35 SkASSERT(count > 0); | |
36 } | |
37 | |
38 virtual ~SkMipMap() { | |
39 sk_free(fLevels); | |
40 } | |
41 | 39 |
42 static Level* AllocLevels(int levelCount, size_t pixelSize); | 40 static Level* AllocLevels(int levelCount, size_t pixelSize); |
43 }; | 41 }; |
44 | 42 |
45 #endif | 43 #endif |
OLD | NEW |