Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: src/core/SkMipMap.h

Issue 592843003: Add SkCachedData and use it for SkMipMap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkCachedData.cpp ('k') | src/core/SkMipMap.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkCachedData.h"
12 #include "SkScalar.h" 12 #include "SkScalar.h"
13 13
14 class SkBitmap; 14 class SkBitmap;
15 class SkDiscardableMemory;
15 16
16 class SkMipMap : public SkRefCnt { 17 typedef SkDiscardableMemory* (*SkDiscardableFactoryProc)(size_t bytes);
18
19 class SkMipMap : public SkCachedData {
17 public: 20 public:
18 static SkMipMap* Build(const SkBitmap& src); 21 static SkMipMap* Build(const SkBitmap& src, SkDiscardableFactoryProc);
19 22
20 struct Level { 23 struct Level {
21 void* fPixels; 24 void* fPixels;
22 uint32_t fRowBytes; 25 uint32_t fRowBytes;
23 uint32_t fWidth, fHeight; 26 uint32_t fWidth, fHeight;
24 float fScale; // < 1.0 27 float fScale; // < 1.0
25 }; 28 };
26 29
27 bool extractLevel(SkScalar scale, Level*) const; 30 bool extractLevel(SkScalar scale, Level*) const;
28 31
29 size_t getSize() const { return fSize; } 32 protected:
33 virtual void onDataChange(void* oldData, void* newData) SK_OVERRIDE {
34 fLevels = (Level*)newData; // could be NULL
35 }
30 36
31 private: 37 private:
32 size_t fSize;
33 Level* fLevels; 38 Level* fLevels;
34 int fCount; 39 int fCount;
35 40
36 // we take ownership of levels, and will free it with sk_free() 41 // we take ownership of levels, and will free it with sk_free()
37 SkMipMap(Level* levels, int count, size_t size); 42 SkMipMap(void* malloc, size_t size) : INHERITED(malloc, size) {}
38 virtual ~SkMipMap(); 43 SkMipMap(size_t size, SkDiscardableMemory* dm) : INHERITED(size, dm) {}
39 44
40 static Level* AllocLevels(int levelCount, size_t pixelSize); 45 static size_t AllocLevelsSize(int levelCount, size_t pixelSize);
46
47 typedef SkCachedData INHERITED;
41 }; 48 };
42 49
43 #endif 50 #endif
OLDNEW
« no previous file with comments | « src/core/SkCachedData.cpp ('k') | src/core/SkMipMap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698