Chromium Code Reviews| 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 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 public: | 22 public: |
| 23 static SkMipMap* Build(const SkPixmap& src, SkDiscardableFactoryProc); | 23 static SkMipMap* Build(const SkPixmap& src, SkDiscardableFactoryProc); |
| 24 static SkMipMap* Build(const SkBitmap& src, SkDiscardableFactoryProc); | 24 static SkMipMap* Build(const SkBitmap& src, SkDiscardableFactoryProc); |
| 25 | 25 |
| 26 struct Level { | 26 struct Level { |
| 27 SkPixmap fPixmap; | 27 SkPixmap fPixmap; |
| 28 SkSize fScale; // < 1.0 | 28 SkSize fScale; // < 1.0 |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 bool extractLevel(SkScalar scale, Level*) const; | 31 bool extractLevel(SkScalar scale, Level*) const; |
| 32 int countLevels() const; | |
| 33 void getLevel(int index, Level*) const; | |
| 32 | 34 |
| 33 protected: | 35 protected: |
| 34 void onDataChange(void* oldData, void* newData) override { | 36 void onDataChange(void* oldData, void* newData) override { |
| 35 fLevels = (Level*)newData; // could be nullptr | 37 fLevels = (Level*)newData; // could be nullptr |
| 36 } | 38 } |
| 37 | 39 |
| 38 private: | 40 private: |
| 39 Level* fLevels; | 41 Level* fLevels; |
| 40 int fCount; | 42 int fCount; |
| 41 | 43 |
| 42 // we take ownership of levels, and will free it with sk_free() | 44 // we take ownership of levels, and will free it with sk_free() |
| 43 SkMipMap(void* malloc, size_t size) : INHERITED(malloc, size) {} | 45 SkMipMap(void* malloc, size_t size) : INHERITED(malloc, size) {} |
| 44 SkMipMap(size_t size, SkDiscardableMemory* dm) : INHERITED(size, dm) {} | 46 SkMipMap(size_t size, SkDiscardableMemory* dm) : INHERITED(size, dm) {} |
| 45 | 47 |
| 46 static size_t AllocLevelsSize(int levelCount, size_t pixelSize); | 48 static size_t AllocLevelsSize(int levelCount, size_t pixelSize); |
| 47 | 49 |
| 48 typedef SkCachedData INHERITED; | 50 typedef SkCachedData INHERITED; |
| 49 }; | 51 }; |
| 50 | 52 |
| 53 // This function lets you determine how many levels a mipmap will have without | |
| 54 // creating that mipmap. | |
| 55 int SkGetMipMapLevelCount(int baseWidth, int baseHeight); | |
|
reed1
2016/01/26 14:25:55
This should be a static method on SkMipMap..
int
cblume
2016/01/26 17:16:53
Done.
| |
| 56 | |
| 51 #endif | 57 #endif |
| OLD | NEW |