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

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

Issue 2264643002: Added SkColor4f::FromColor3f(SkColor3f, float a) (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Removed header include from .cpp file Created 4 years, 4 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/core/SkColor.h ('k') | no next file » | 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 #endif 148 #endif
149 149
150 //////////////////////////////////////////////////////////////////////////////// /////////////////// 150 //////////////////////////////////////////////////////////////////////////////// ///////////////////
151 151
152 SkColor4f SkColor4f::FromColor(SkColor bgra) { 152 SkColor4f SkColor4f::FromColor(SkColor bgra) {
153 SkColor4f rgba; 153 SkColor4f rgba;
154 swizzle_rb(Sk4f_fromS32(bgra)).store(rgba.vec()); 154 swizzle_rb(Sk4f_fromS32(bgra)).store(rgba.vec());
155 return rgba; 155 return rgba;
156 } 156 }
157 157
158 SkColor4f SkColor4f::FromColor3f(SkColor3f color3f, float a) {
159 SkColor4f rgba;
160 rgba.fR = color3f.fX;
161 rgba.fG = color3f.fY;
162 rgba.fB = color3f.fZ;
163 rgba.fA = a;
164 return rgba;
165 }
166
158 SkColor SkColor4f::toSkColor() const { 167 SkColor SkColor4f::toSkColor() const {
159 return Sk4f_toS32(swizzle_rb(Sk4f::Load(this->vec()))); 168 return Sk4f_toS32(swizzle_rb(Sk4f::Load(this->vec())));
160 } 169 }
161 170
162 SkColor4f SkColor4f::Pin(float r, float g, float b, float a) { 171 SkColor4f SkColor4f::Pin(float r, float g, float b, float a) {
163 SkColor4f c4; 172 SkColor4f c4;
164 Sk4f::Min(Sk4f::Max(Sk4f(r, g, b, a), Sk4f(0)), Sk4f(1)).store(c4.vec()); 173 Sk4f::Min(Sk4f::Max(Sk4f(r, g, b, a), Sk4f(0)), Sk4f(1)).store(c4.vec());
165 return c4; 174 return c4;
166 } 175 }
167 176
168 SkPM4f SkColor4f::premul() const { 177 SkPM4f SkColor4f::premul() const {
169 auto src = Sk4f::Load(this->pin().vec()); 178 auto src = Sk4f::Load(this->pin().vec());
170 float srcAlpha = src[3]; // need the pinned version of our alpha 179 float srcAlpha = src[3]; // need the pinned version of our alpha
171 src = src * Sk4f(srcAlpha, srcAlpha, srcAlpha, 1); 180 src = src * Sk4f(srcAlpha, srcAlpha, srcAlpha, 1);
172 181
173 return SkPM4f::From4f(src); 182 return SkPM4f::From4f(src);
174 } 183 }
OLDNEW
« no previous file with comments | « include/core/SkColor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698