blob: f8753cdc1b77cb1e59d5145bba1c4018ea579e29 [file] [log] [blame]
reed@google.comdc6c8ba2013-07-18 21:14:04 +00001/*
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.comeed6f1b2013-07-18 19:53:31 +00008#ifndef SkMipMap_DEFINED
9#define SkMipMap_DEFINED
10
11#include "SkRefCnt.h"
12#include "SkScalar.h"
13
14class SkBitmap;
15
16class SkMipMap : public SkRefCnt {
17public:
18 static SkMipMap* Build(const SkBitmap& src);
19
20 struct Level {
21 void* fPixels;
22 uint32_t fRowBytes;
23 uint32_t fWidth, fHeight;
24 };
skia.committer@gmail.coma7991982013-07-19 07:00:57 +000025
reed@google.comeed6f1b2013-07-18 19:53:31 +000026 bool extractLevel(SkScalar scale, Level*) const;
27
28private:
29 Level* fLevels;
30 int fCount;
31
32 // we take ownership of levels, and will free it with sk_free()
33 SkMipMap(Level* levels, int count) : fLevels(levels), fCount(count) {
34 SkASSERT(levels);
35 SkASSERT(count > 0);
36 }
37
38 virtual ~SkMipMap() {
39 sk_free(fLevels);
40 }
41
42 static Level* AllocLevels(int levelCount, size_t pixelSize);
43};
44
45#endif