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

Side by Side Diff: include/effects/SkTableMaskFilter.h

Issue 173633003: Factory methods for heap-allocated SkMaskFilter objects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add SkTableMaskFilter::Create(table) and remove deprecated SkEmbossMaskFilter constructor. Created 6 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 | « include/effects/SkStippleMaskFilter.h ('k') | samplecode/SampleAll.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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 SkTableMaskFilter_DEFINED 8 #ifndef SkTableMaskFilter_DEFINED
9 #define SkTableMaskFilter_DEFINED 9 #define SkTableMaskFilter_DEFINED
10 10
11 #include "SkMaskFilter.h" 11 #include "SkMaskFilter.h"
12 #include "SkScalar.h" 12 #include "SkScalar.h"
13 13
14 /** \class SkTableMaskFilter 14 /** \class SkTableMaskFilter
15 15
16 Applies a table lookup on each of the alpha values in the mask. 16 Applies a table lookup on each of the alpha values in the mask.
17 Helper methods create some common tables (e.g. gamma, clipping) 17 Helper methods create some common tables (e.g. gamma, clipping)
18 */ 18 */
19 class SK_API SkTableMaskFilter : public SkMaskFilter { 19 class SK_API SkTableMaskFilter : public SkMaskFilter {
20 public: 20 public:
21 SkTableMaskFilter();
22 SkTableMaskFilter(const uint8_t table[256]);
23 virtual ~SkTableMaskFilter(); 21 virtual ~SkTableMaskFilter();
24 22
25 /** Utility that sets the gamma table 23 /** Utility that sets the gamma table
26 */ 24 */
27 static void MakeGammaTable(uint8_t table[256], SkScalar gamma); 25 static void MakeGammaTable(uint8_t table[256], SkScalar gamma);
28 26
29 /** Utility that creates a clipping table: clamps values below min to 0 27 /** Utility that creates a clipping table: clamps values below min to 0
30 and above max to 255, and rescales the remaining into 0..255 28 and above max to 255, and rescales the remaining into 0..255
31 */ 29 */
32 static void MakeClipTable(uint8_t table[256], uint8_t min, uint8_t max); 30 static void MakeClipTable(uint8_t table[256], uint8_t min, uint8_t max);
33 31
32 static SkTableMaskFilter* Create(const uint8_t table[256]) {
33 return SkNEW_ARGS(SkTableMaskFilter, (table));
34 }
35
34 static SkTableMaskFilter* CreateGamma(SkScalar gamma) { 36 static SkTableMaskFilter* CreateGamma(SkScalar gamma) {
35 uint8_t table[256]; 37 uint8_t table[256];
36 MakeGammaTable(table, gamma); 38 MakeGammaTable(table, gamma);
37 return SkNEW_ARGS(SkTableMaskFilter, (table)); 39 return SkNEW_ARGS(SkTableMaskFilter, (table));
38 } 40 }
39 41
40 static SkTableMaskFilter* CreateClip(uint8_t min, uint8_t max) { 42 static SkTableMaskFilter* CreateClip(uint8_t min, uint8_t max) {
41 uint8_t table[256]; 43 uint8_t table[256];
42 MakeClipTable(table, min, max); 44 MakeClipTable(table, min, max);
43 return SkNEW_ARGS(SkTableMaskFilter, (table)); 45 return SkNEW_ARGS(SkTableMaskFilter, (table));
44 } 46 }
45 47
46 virtual SkMask::Format getFormat() const SK_OVERRIDE; 48 virtual SkMask::Format getFormat() const SK_OVERRIDE;
47 virtual bool filterMask(SkMask*, const SkMask&, const SkMatrix&, 49 virtual bool filterMask(SkMask*, const SkMask&, const SkMatrix&,
48 SkIPoint*) const SK_OVERRIDE; 50 SkIPoint*) const SK_OVERRIDE;
49 51
50 SkDEVCODE(virtual void toString(SkString* str) const SK_OVERRIDE;) 52 SkDEVCODE(virtual void toString(SkString* str) const SK_OVERRIDE;)
51 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTableMaskFilter) 53 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTableMaskFilter)
52 54
53 protected: 55 protected:
54 SkTableMaskFilter(SkReadBuffer& rb); 56 SkTableMaskFilter(SkReadBuffer& rb);
55 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 57 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
56 58
59 #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
60 public:
61 #endif
62 SkTableMaskFilter();
63 SkTableMaskFilter(const uint8_t table[256]);
64
57 private: 65 private:
58 uint8_t fTable[256]; 66 uint8_t fTable[256];
59 67
60 typedef SkMaskFilter INHERITED; 68 typedef SkMaskFilter INHERITED;
61 }; 69 };
62 70
63 #endif 71 #endif
OLDNEW
« no previous file with comments | « include/effects/SkStippleMaskFilter.h ('k') | samplecode/SampleAll.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698