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

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

Issue 1774523002: make pm4f be RGBA always, not pmcolor order (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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/SkColor.cpp ('k') | src/core/SkPM4fPriv.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 SkPM4f_DEFINED 8 #ifndef SkPM4f_DEFINED
9 #define SkPM4f_DEFINED 9 #define SkPM4f_DEFINED
10 10
11 #include "SkColorPriv.h" 11 #include "SkColorPriv.h"
12 #include "SkNx.h"
13
14 static inline Sk4f swizzle_rb(const Sk4f& x) {
15 return Sk4f(x[2], x[1], x[0], x[3]);
mtklein 2016/03/07 16:13:49 We'll have better opportunity to improve this late
reed1 2016/03/07 17:39:07 Done.
16 }
17
18 static inline Sk4f swizzle_rgba_to_pmorder(const Sk4f& x) {
19 #ifdef SK_PMCOLOR_IS_BGRA
20 return Sk4f(x[2], x[1], x[0], x[3]);
mtklein 2016/03/07 16:13:49 return swizzle_rb(x); ?
reed1 2016/03/07 17:39:07 Done.
21 #else
22 return x;
23 #endif
24 }
25
26 static inline Sk4f swizzle_pmorder_to_rgba(const Sk4f& x) {
27 #ifdef SK_PMCOLOR_IS_BGRA
28 return Sk4f(x[2], x[1], x[0], x[3]);
mtklein 2016/03/07 16:13:49 ditto
reed1 2016/03/07 17:39:07 Done.
29 #else
30 return x;
31 #endif
32 }
12 33
13 /* 34 /*
14 * The float values are 0...1 premultiplied 35 * The float values are 0...1 premultiplied
15 */ 36 */
16 struct SkPM4f { 37 struct SkPM4f {
17 enum { 38 enum {
39 #if 0
18 A = SK_A32_SHIFT/8, 40 A = SK_A32_SHIFT/8,
19 R = SK_R32_SHIFT/8, 41 R = SK_R32_SHIFT/8,
20 G = SK_G32_SHIFT/8, 42 G = SK_G32_SHIFT/8,
21 B = SK_B32_SHIFT/8, 43 B = SK_B32_SHIFT/8,
44 #else
45 R, G, B, A,
46 #endif
22 }; 47 };
23 float fVec[4]; 48 float fVec[4];
24 49
25 float a() const { return fVec[A]; } 50 float a() const { return fVec[A]; }
26 51
27 SkColor4f unpremul() const; 52 SkPM4f rgba() const { return *this; }
mtklein 2016/03/07 16:13:49 It seems weird for these to return SkPM4f. Only r
reed1 2016/03/07 17:39:07 Moved to call-site
53 SkPM4f bgra() const { return{{ fVec[2], fVec[1], fVec[0], fVec[3] }}; }
54 SkPM4f pmorder() const {
55 #ifdef SK_PMCOLOR_IS_BGRA
56 return this->bgra();
57 #else
58 return this->rgba();
59 #endif
60 }
28 61
62 static SkPM4f From4f(const Sk4f& x) {
63 SkPM4f pm;
64 x.store(pm.fVec);
65 return pm;
66 }
67 static SkPM4f FromF16(const uint16_t[4]);
29 static SkPM4f FromPMColor(SkPMColor); 68 static SkPM4f FromPMColor(SkPMColor);
30 69
31 // half-float routines 70 Sk4f to4f() const { return Sk4f::Load(fVec); }
71 Sk4f to4f_rgba() const { return this->to4f(); }
72 Sk4f to4f_bgra() const { return swizzle_rb(this->to4f()); }
73 Sk4f to4f_pmorder() const { return swizzle_rgba_to_pmorder(this->to4f()); }
74
32 void toF16(uint16_t[4]) const; 75 void toF16(uint16_t[4]) const;
33 uint64_t toF16() const; // 4 float16 values packed into uint64_t 76 uint64_t toF16() const; // 4 float16 values packed into uint64_t
34 static SkPM4f FromF16(const uint16_t[4]); 77
78 SkColor4f unpremul() const;
35 79
36 #ifdef SK_DEBUG 80 #ifdef SK_DEBUG
37 void assertIsUnit() const; 81 void assertIsUnit() const;
38 #else 82 #else
39 void assertIsUnit() const {} 83 void assertIsUnit() const {}
40 #endif 84 #endif
41 }; 85 };
42 86
43 typedef SkPM4f (*SkXfermodeProc4f)(const SkPM4f& src, const SkPM4f& dst); 87 typedef SkPM4f (*SkXfermodeProc4f)(const SkPM4f& src, const SkPM4f& dst);
44 88
45
46 #endif 89 #endif
OLDNEW
« no previous file with comments | « src/core/SkColor.cpp ('k') | src/core/SkPM4fPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698