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

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

Issue 1613053006: SkValue: to/from SkImage (Closed) Base URL: https://skia.googlesource.com/skia.git@skvalue_xfermode2
Patch Set: 2016-01-21 (Thursday) 17:20:39 EST Created 4 years, 11 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/SkValueKeys.h » ('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 2016 Google Inc. 2 * Copyright 2016 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 SkValue_DEFINED 8 #ifndef SkValue_DEFINED
9 #define SkValue_DEFINED 9 #define SkValue_DEFINED
10 10
11 #include "SkTypes.h" 11 #include "SkTypes.h"
12 #include <functional> 12 #include <functional>
13 13
14 class SkData; 14 class SkData;
15 15
16 class SkValue { 16 class SkValue {
17 public: 17 public:
18 enum Type : uint32_t { 18 enum Type : uint32_t {
19 // 0-255 are reserved for built-in SkValue types. 19 // 0-255 are reserved for built-in SkValue types.
20 Null, 20 Null,
21 Byte , S16 , U16 , S32 , U32 , S64 , U64 , F32 , F64 , 21 Byte , S16 , U16 , S32 , U32 , S64 , U64 , F32 , F64 ,
22 Bytes, S16s, U16s, S32s, U32s, S64s, U64s, F32s, F64s, 22 Bytes, S16s, U16s, S32s, U32s, S64s, U64s, F32s, F64s,
23 Array, 23 Array,
24 24
25 kMaxBuiltin = 0xFF, 25 kMaxBuiltin = 0xFF,
26 // 256-2147483647 may be used by Skia for public Object types. 26 // 256-2147483647 may be used by Skia for public Object types.
27 27
28 Image,
28 Matrix, 29 Matrix,
29 30
30 ArithmeticXfermode, 31 ArithmeticXfermode,
31 DefaultXfermode, 32 DefaultXfermode,
32 LerpXfermode, 33 LerpXfermode,
33 PixelXorXfermode, 34 PixelXorXfermode,
34 ProcCoeffXfermode, 35 ProcCoeffXfermode,
35 36
36 kMaxPublicObject = 0x7FFFFFFF, 37 kMaxPublicObject = 0x7FFFFFFF,
37 // 2147483648+ won't be used by Skia. They're open for 38 // 2147483648+ won't be used by Skia. They're open for
(...skipping 20 matching lines...) Expand all
58 static SkValue FromU32(uint32_t); 59 static SkValue FromU32(uint32_t);
59 static SkValue FromF32(float); 60 static SkValue FromF32(float);
60 static SkValue FromBytes(SkData*); 61 static SkValue FromBytes(SkData*);
61 static SkValue FromU16s(SkData*); 62 static SkValue FromU16s(SkData*);
62 static SkValue FromU32s(SkData*); 63 static SkValue FromU32s(SkData*);
63 static SkValue FromF32s(SkData*); 64 static SkValue FromF32s(SkData*);
64 static SkValue ValueArray(); 65 static SkValue ValueArray();
65 static SkValue Object(Type); 66 static SkValue Object(Type);
66 67
67 Type type() const { return fType; } 68 Type type() const { return fType; }
69 bool isData() const {
70 return Bytes == fType
71 || U16s == fType
72 || U32s == fType
73 || F32s == fType;
74 }
68 75
69 // These remaining methods may assert they're called on a value of the appro priate type. 76 // These remaining methods may assert they're called on a value of the appro priate type.
70 77
71 int32_t s32() const; 78 int32_t s32() const;
72 uint32_t u32() const; 79 uint32_t u32() const;
73 float f32() const; 80 float f32() const;
74 SkData* bytes() const; 81 SkData* bytes() const;
75 82
76 const uint16_t* u16s(int* count) const; 83 const uint16_t* u16s(int* count) const;
77 const uint32_t* u32s(int* count) const; 84 const uint32_t* u32s(int* count) const;
(...skipping 18 matching lines...) Expand all
96 int32_t fS32; 103 int32_t fS32;
97 uint32_t fU32; 104 uint32_t fU32;
98 float fF32; 105 float fF32;
99 SkData* fBytes; 106 SkData* fBytes;
100 Obj* fObject; 107 Obj* fObject;
101 Arr* fArray; 108 Arr* fArray;
102 }; 109 };
103 110
104 SkValue(Type); 111 SkValue(Type);
105 bool isObject() const { return fType > kMaxBuiltin; } 112 bool isObject() const { return fType > kMaxBuiltin; }
106 bool isData() const {
107 return Bytes == fType
108 || U16s == fType
109 || U32s == fType
110 || F32s == fType;
111 }
112 template <typename T> static SkValue FromT(SkValue::Type, T SkValue::*, T); 113 template <typename T> static SkValue FromT(SkValue::Type, T SkValue::*, T);
113 template <typename T> static SkValue FromTs(SkValue::Type, SkData*); 114 template <typename T> static SkValue FromTs(SkValue::Type, SkData*);
114 template <typename T> const T* asTs(SkValue::Type, int*) const; 115 template <typename T> const T* asTs(SkValue::Type, int*) const;
115 }; 116 };
116 117
117 #endif // SkValue_DEFINED 118 #endif // SkValue_DEFINED
OLDNEW
« no previous file with comments | « no previous file | src/core/SkValueKeys.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698