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

Unified Diff: src/core/SkMipMap.h

Issue 2042843005: SkMipMap::ComputeLevelSize should only cover SkMipMap's levels. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Adding asserts to the unit tests. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkMipMap.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkMipMap.h
diff --git a/src/core/SkMipMap.h b/src/core/SkMipMap.h
index a230a23392a831caf5b39baea09d075dc57ca2e1..7c798ef8337069c27dcc2efc5a1ac311aa545a4a 100644
--- a/src/core/SkMipMap.h
+++ b/src/core/SkMipMap.h
@@ -18,15 +18,26 @@ class SkDiscardableMemory;
typedef SkDiscardableMemory* (*SkDiscardableFactoryProc)(size_t bytes);
+/*
+ * SkMipMap will generate mipmap levels when given a base mipmap level image.
+ *
+ * Any function which deals with mipmap levels indices will start with index 0
+ * being the first mipmap level which was generated. Said another way, it does
+ * not include the base level in its range.
+ */
class SkMipMap : public SkCachedData {
public:
static SkMipMap* Build(const SkPixmap& src, SkDiscardableFactoryProc);
static SkMipMap* Build(const SkBitmap& src, SkDiscardableFactoryProc);
// Determines how many levels a SkMipMap will have without creating that mipmap.
+ // This does not include the base mipmap level that the user provided when
+ // creating the SkMipMap.
static int ComputeLevelCount(int baseWidth, int baseHeight);
// Determines the size of a given mipmap level.
+ // |level| is an index into the generated mipmap levels. It does not include
+ // the base level. So index 0 represents mipmap level 1.
static SkISize ComputeLevelSize(int baseWidth, int baseHeight, int level);
struct Level {
@@ -35,7 +46,13 @@ public:
};
bool extractLevel(const SkSize& scale, Level*) const;
+
+ // countLevels returns the number of mipmap levels generated (which does not
+ // include the base mipmap level).
int countLevels() const;
+
+ // |index| is an index into the generated mipmap levels. It does not include
+ // the base level. So index 0 represents mipmap level 1.
bool getLevel(int index, Level*) const;
protected:
« 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