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

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

Issue 2029373004: respect srgb gamma when building mips (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix warning 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 | « src/core/SkLightingShader.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 "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 #include "SkShader.h"
15 16
16 class SkBitmap; 17 class SkBitmap;
17 class SkDiscardableMemory; 18 class SkDiscardableMemory;
18 19
19 typedef SkDiscardableMemory* (*SkDiscardableFactoryProc)(size_t bytes); 20 typedef SkDiscardableMemory* (*SkDiscardableFactoryProc)(size_t bytes);
20 21
21 /* 22 /*
22 * SkMipMap will generate mipmap levels when given a base mipmap level image. 23 * SkMipMap will generate mipmap levels when given a base mipmap level image.
23 * 24 *
24 * Any function which deals with mipmap levels indices will start with index 0 25 * Any function which deals with mipmap levels indices will start with index 0
25 * being the first mipmap level which was generated. Said another way, it does 26 * being the first mipmap level which was generated. Said another way, it does
26 * not include the base level in its range. 27 * not include the base level in its range.
27 */ 28 */
28 class SkMipMap : public SkCachedData { 29 class SkMipMap : public SkCachedData {
29 public: 30 public:
30 static SkMipMap* Build(const SkPixmap& src, SkDiscardableFactoryProc); 31 static SkMipMap* Build(const SkPixmap& src, SkSourceGammaTreatment, SkDiscar dableFactoryProc);
31 static SkMipMap* Build(const SkBitmap& src, SkDiscardableFactoryProc); 32 static SkMipMap* Build(const SkBitmap& src, SkSourceGammaTreatment, SkDiscar dableFactoryProc);
33
34 static SkSourceGammaTreatment DeduceTreatment(const SkShader::ContextRec& re c) {
35 return (SkShader::ContextRec::kPMColor_DstType == rec.fPreferredDstType) ?
36 SkSourceGammaTreatment::kIgnore : SkSourceGammaTreatment::kRespe ct;
37 }
32 38
33 // Determines how many levels a SkMipMap will have without creating that mip map. 39 // Determines how many levels a SkMipMap will have without creating that mip map.
34 // This does not include the base mipmap level that the user provided when 40 // This does not include the base mipmap level that the user provided when
35 // creating the SkMipMap. 41 // creating the SkMipMap.
36 static int ComputeLevelCount(int baseWidth, int baseHeight); 42 static int ComputeLevelCount(int baseWidth, int baseHeight);
37 43
38 // Determines the size of a given mipmap level. 44 // Determines the size of a given mipmap level.
39 // |level| is an index into the generated mipmap levels. It does not include 45 // |level| is an index into the generated mipmap levels. It does not include
40 // the base level. So index 0 represents mipmap level 1. 46 // the base level. So index 0 represents mipmap level 1.
41 static SkISize ComputeLevelSize(int baseWidth, int baseHeight, int level); 47 static SkISize ComputeLevelSize(int baseWidth, int baseHeight, int level);
(...skipping 12 matching lines...) Expand all
54 // |index| is an index into the generated mipmap levels. It does not include 60 // |index| is an index into the generated mipmap levels. It does not include
55 // the base level. So index 0 represents mipmap level 1. 61 // the base level. So index 0 represents mipmap level 1.
56 bool getLevel(int index, Level*) const; 62 bool getLevel(int index, Level*) const;
57 63
58 protected: 64 protected:
59 void onDataChange(void* oldData, void* newData) override { 65 void onDataChange(void* oldData, void* newData) override {
60 fLevels = (Level*)newData; // could be nullptr 66 fLevels = (Level*)newData; // could be nullptr
61 } 67 }
62 68
63 private: 69 private:
64 Level* fLevels; 70 sk_sp<SkColorSpace> fCS;
65 int fCount; 71 Level* fLevels; // managed by the baseclass, may be null due to onDataChanged.
72 int fCount;
66 73
67 // we take ownership of levels, and will free it with sk_free()
68 SkMipMap(void* malloc, size_t size) : INHERITED(malloc, size) {} 74 SkMipMap(void* malloc, size_t size) : INHERITED(malloc, size) {}
69 SkMipMap(size_t size, SkDiscardableMemory* dm) : INHERITED(size, dm) {} 75 SkMipMap(size_t size, SkDiscardableMemory* dm) : INHERITED(size, dm) {}
70 76
71 static size_t AllocLevelsSize(int levelCount, size_t pixelSize); 77 static size_t AllocLevelsSize(int levelCount, size_t pixelSize);
72 78
73 typedef SkCachedData INHERITED; 79 typedef SkCachedData INHERITED;
74 }; 80 };
75 81
76 #endif 82 #endif
OLDNEW
« no previous file with comments | « src/core/SkLightingShader.cpp ('k') | src/core/SkMipMap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698