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

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

Issue 1639693002: Adding direct access to SkMipMap levels. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Removing comparisons of ComputeLevelCoutn and Build's level coutn, since that comparison is already… Created 4 years, 10 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 | « no previous file | 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 "SkCachedData.h" 11 #include "SkCachedData.h"
12 #include "SkPixmap.h" 12 #include "SkPixmap.h"
13 #include "SkScalar.h" 13 #include "SkScalar.h"
14 #include "SkSize.h" 14 #include "SkSize.h"
15 15
16 class SkBitmap; 16 class SkBitmap;
17 class SkDiscardableMemory; 17 class SkDiscardableMemory;
18 18
19 typedef SkDiscardableMemory* (*SkDiscardableFactoryProc)(size_t bytes); 19 typedef SkDiscardableMemory* (*SkDiscardableFactoryProc)(size_t bytes);
20 20
21 class SkMipMap : public SkCachedData { 21 class SkMipMap : public SkCachedData {
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 // This function lets you determine how many levels a SkMipMap will have wit hout
27 // creating that mipmap.
28 static int ComputeLevelCount(int baseWidth, int baseHeight);
29
26 struct Level { 30 struct Level {
27 SkPixmap fPixmap; 31 SkPixmap fPixmap;
28 SkSize fScale; // < 1.0 32 SkSize fScale; // < 1.0
29 }; 33 };
30 34
31 bool extractLevel(const SkSize& scale, Level*) const; 35 bool extractLevel(const SkSize& scale, Level*) const;
36 int countLevels() const;
37 bool getLevel(int index, Level*) const;
32 38
33 protected: 39 protected:
34 void onDataChange(void* oldData, void* newData) override { 40 void onDataChange(void* oldData, void* newData) override {
35 fLevels = (Level*)newData; // could be nullptr 41 fLevels = (Level*)newData; // could be nullptr
36 } 42 }
37 43
38 private: 44 private:
39 Level* fLevels; 45 Level* fLevels;
40 int fCount; 46 int fCount;
41 47
42 // we take ownership of levels, and will free it with sk_free() 48 // we take ownership of levels, and will free it with sk_free()
43 SkMipMap(void* malloc, size_t size) : INHERITED(malloc, size) {} 49 SkMipMap(void* malloc, size_t size) : INHERITED(malloc, size) {}
44 SkMipMap(size_t size, SkDiscardableMemory* dm) : INHERITED(size, dm) {} 50 SkMipMap(size_t size, SkDiscardableMemory* dm) : INHERITED(size, dm) {}
45 51
46 static size_t AllocLevelsSize(int levelCount, size_t pixelSize); 52 static size_t AllocLevelsSize(int levelCount, size_t pixelSize);
47 53
48 typedef SkCachedData INHERITED; 54 typedef SkCachedData INHERITED;
49 }; 55 };
50 56
51 #endif 57 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkMipMap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698