2 * Copyright 2013 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef SkMipMap_DEFINED
9 #define SkMipMap_DEFINED
11 #include "SkCachedData.h"
15 class SkDiscardableMemory;
17 typedef SkDiscardableMemory* (*SkDiscardableFactoryProc)(size_t bytes);
19 class SkMipMap : public SkCachedData {
21 static SkMipMap* Build(const SkBitmap& src, SkDiscardableFactoryProc);
26 uint32_t fWidth, fHeight;
27 float fScale; // < 1.0
30 bool extractLevel(SkScalar scale, Level*) const;
33 void onDataChange(void* oldData, void* newData) SK_OVERRIDE {
34 fLevels = (Level*)newData; // could be NULL
41 // we take ownership of levels, and will free it with sk_free()
42 SkMipMap(void* malloc, size_t size) : INHERITED(malloc, size) {}
43 SkMipMap(size_t size, SkDiscardableMemory* dm) : INHERITED(size, dm) {}
45 static size_t AllocLevelsSize(int levelCount, size_t pixelSize);
47 typedef SkCachedData INHERITED;