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

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

Issue 2036313002: SkMipMap::ComputeLevelSize to return SkISize (Closed) Base URL: https://skia.googlesource.com/skia.git@pipe-mipmap-levels-to-creation
Patch Set: Created 4 years, 6 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 // Determines how many levels a SkMipMap will have without creating that mip map. 26 // Determines how many levels a SkMipMap will have without creating that mip map.
27 static int ComputeLevelCount(int baseWidth, int baseHeight); 27 static int ComputeLevelCount(int baseWidth, int baseHeight);
28 28
29 // Determines the size of a given mipmap level. 29 // Determines the size of a given mipmap level.
30 static SkSize ComputeLevelSize(int baseWidth, int baseHeight, int level); 30 static SkISize ComputeLevelSize(int baseWidth, int baseHeight, int level);
31 31
32 struct Level { 32 struct Level {
33 SkPixmap fPixmap; 33 SkPixmap fPixmap;
34 SkSize fScale; // < 1.0 34 SkSize fScale; // < 1.0
35 }; 35 };
36 36
37 bool extractLevel(const SkSize& scale, Level*) const; 37 bool extractLevel(const SkSize& scale, Level*) const;
38 int countLevels() const; 38 int countLevels() const;
39 bool getLevel(int index, Level*) const; 39 bool getLevel(int index, Level*) const;
40 40
41 protected: 41 protected:
42 void onDataChange(void* oldData, void* newData) override { 42 void onDataChange(void* oldData, void* newData) override {
43 fLevels = (Level*)newData; // could be nullptr 43 fLevels = (Level*)newData; // could be nullptr
44 } 44 }
45 45
46 private: 46 private:
47 Level* fLevels; 47 Level* fLevels;
48 int fCount; 48 int fCount;
49 49
50 // we take ownership of levels, and will free it with sk_free() 50 // we take ownership of levels, and will free it with sk_free()
51 SkMipMap(void* malloc, size_t size) : INHERITED(malloc, size) {} 51 SkMipMap(void* malloc, size_t size) : INHERITED(malloc, size) {}
52 SkMipMap(size_t size, SkDiscardableMemory* dm) : INHERITED(size, dm) {} 52 SkMipMap(size_t size, SkDiscardableMemory* dm) : INHERITED(size, dm) {}
53 53
54 static size_t AllocLevelsSize(int levelCount, size_t pixelSize); 54 static size_t AllocLevelsSize(int levelCount, size_t pixelSize);
55 55
56 typedef SkCachedData INHERITED; 56 typedef SkCachedData INHERITED;
57 }; 57 };
58 58
59 #endif 59 #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