reed@google.com | dc6c8ba | 2013-07-18 21:14:04 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
reed@google.com | eed6f1b | 2013-07-18 19:53:31 +0000 | [diff] [blame] | 8 | #ifndef SkMipMap_DEFINED |
| 9 | #define SkMipMap_DEFINED |
| 10 | |
| 11 | #include "SkRefCnt.h" |
| 12 | #include "SkScalar.h" |
| 13 | |
| 14 | class SkBitmap; |
| 15 | |
| 16 | class SkMipMap : public SkRefCnt { |
| 17 | public: |
| 18 | static SkMipMap* Build(const SkBitmap& src); |
| 19 | |
| 20 | struct Level { |
| 21 | void* fPixels; |
| 22 | uint32_t fRowBytes; |
| 23 | uint32_t fWidth, fHeight; |
reed@google.com | d94697c | 2013-07-24 14:31:33 +0000 | [diff] [blame^] | 24 | float fScale; // < 1.0 |
reed@google.com | eed6f1b | 2013-07-18 19:53:31 +0000 | [diff] [blame] | 25 | }; |
skia.committer@gmail.com | a799198 | 2013-07-19 07:00:57 +0000 | [diff] [blame] | 26 | |
reed@google.com | eed6f1b | 2013-07-18 19:53:31 +0000 | [diff] [blame] | 27 | bool extractLevel(SkScalar scale, Level*) const; |
| 28 | |
reed@google.com | d94697c | 2013-07-24 14:31:33 +0000 | [diff] [blame^] | 29 | size_t getSize() const { return fSize; } |
| 30 | |
reed@google.com | eed6f1b | 2013-07-18 19:53:31 +0000 | [diff] [blame] | 31 | private: |
reed@google.com | d94697c | 2013-07-24 14:31:33 +0000 | [diff] [blame^] | 32 | size_t fSize; |
reed@google.com | eed6f1b | 2013-07-18 19:53:31 +0000 | [diff] [blame] | 33 | Level* fLevels; |
| 34 | int fCount; |
| 35 | |
| 36 | // we take ownership of levels, and will free it with sk_free() |
reed@google.com | d94697c | 2013-07-24 14:31:33 +0000 | [diff] [blame^] | 37 | SkMipMap(Level* levels, int count, size_t size); |
| 38 | virtual ~SkMipMap(); |
reed@google.com | eed6f1b | 2013-07-18 19:53:31 +0000 | [diff] [blame] | 39 | |
| 40 | static Level* AllocLevels(int levelCount, size_t pixelSize); |
| 41 | }; |
| 42 | |
| 43 | #endif |