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

Side by Side Diff: src/core/SkColor.cpp

Issue 1623453002: Revert of experiment: float color components (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 | « include/effects/SkColorMatrixFilter.h ('k') | src/core/SkColorFilter.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 #include "SkColor.h" 8 #include "SkColor.h"
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkFixed.h" 10 #include "SkFixed.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 switch (hx >> 16) { 93 switch (hx >> 16) {
94 case 0: r = v; g = t; b = p; break; 94 case 0: r = v; g = t; b = p; break;
95 case 1: r = q; g = v; b = p; break; 95 case 1: r = q; g = v; b = p; break;
96 case 2: r = p; g = v; b = t; break; 96 case 2: r = p; g = v; b = t; break;
97 case 3: r = p; g = q; b = v; break; 97 case 3: r = p; g = q; b = v; break;
98 case 4: r = t; g = p; b = v; break; 98 case 4: r = t; g = p; b = v; break;
99 default: r = v; g = p; b = q; break; 99 default: r = v; g = p; b = q; break;
100 } 100 }
101 return SkColorSetARGB(a, r, g, b); 101 return SkColorSetARGB(a, r, g, b);
102 } 102 }
103
104 //////////////////////////////////////////////////////////////////////////////// ///////////////////
105 #include "SkNx.h"
106
107 SkColor4f SkColor4f::Pin(float a, float r, float g, float b) {
108 SkColor4f c4;
109 Sk4f::Min(Sk4f::Max(Sk4f(a, r, g, b), Sk4f(0)), Sk4f(1)).store(c4.vec());
110 return c4;
111 }
112
113 SkColor4f SkColor4f::FromColor(SkColor c) {
114 Sk4f value = SkNx_shuffle<3,2,1,0>(SkNx_cast<float>(Sk4b::Load((const uint8_ t*)&c)));
115 SkColor4f c4;
116 (value * Sk4f(1.0f / 255)).store(c4.vec());
117 return c4;
118 }
119
120 SkPM4f SkColor4f::premul() const {
121 auto src = Sk4f::Load(this->pin().vec());
122 float srcAlpha = src.kth<0>(); // need the pinned version of our alpha
123 src = src * Sk4f(1, srcAlpha, srcAlpha, srcAlpha);
124
125 #ifdef SK_PMCOLOR_IS_BGRA
126 // ARGB -> BGRA
127 Sk4f dst = SkNx_shuffle<3,2,1,0>(src);
128 #else
129 // ARGB -> RGBA
130 Sk4f dst = SkNx_shuffle<1,2,3,0>(src);
131 #endif
132
133 SkPM4f pm4;
134 dst.store(pm4.fVec);
135 return pm4;
136 }
OLDNEW
« no previous file with comments | « include/effects/SkColorMatrixFilter.h ('k') | src/core/SkColorFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698