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

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

Issue 1842753002: Style bikeshed - remove extraneous whitespace (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 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/SkWriteBuffer.cpp ('k') | src/core/SkXfermodeU64.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 "SkXfermode.h" 8 #include "SkXfermode.h"
9 #include "SkXfermode_proccoeff.h" 9 #include "SkXfermode_proccoeff.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 float L = Lum(*r, *g, *b); 239 float L = Lum(*r, *g, *b);
240 float n = min(*r, *g, *b); 240 float n = min(*r, *g, *b);
241 float x = max(*r, *g, *b); 241 float x = max(*r, *g, *b);
242 float denom; 242 float denom;
243 if ((n < 0) && (denom = L - n)) { // Compute denom and make sure it's non ze ro 243 if ((n < 0) && (denom = L - n)) { // Compute denom and make sure it's non ze ro
244 float scale = L / denom; 244 float scale = L / denom;
245 *r = L + (*r - L) * scale; 245 *r = L + (*r - L) * scale;
246 *g = L + (*g - L) * scale; 246 *g = L + (*g - L) * scale;
247 *b = L + (*b - L) * scale; 247 *b = L + (*b - L) * scale;
248 } 248 }
249 249
250 if ((x > a) && (denom = x - L)) { // Compute denom and make sure it's non ze ro 250 if ((x > a) && (denom = x - L)) { // Compute denom and make sure it's non ze ro
251 float scale = (a - L) / denom; 251 float scale = (a - L) / denom;
252 *r = L + (*r - L) * scale; 252 *r = L + (*r - L) * scale;
253 *g = L + (*g - L) * scale; 253 *g = L + (*g - L) * scale;
254 *b = L + (*b - L) * scale; 254 *b = L + (*b - L) * scale;
255 } 255 }
256 } 256 }
257 257
258 static inline void SetLum(float* r, float* g, float* b, float a, float l) { 258 static inline void SetLum(float* r, float* g, float* b, float a, float l) {
259 float d = l - Lum(*r, *g, *b); 259 float d = l - Lum(*r, *g, *b);
260 *r += d; 260 *r += d;
261 *g += d; 261 *g += d;
262 *b += d; 262 *b += d;
263 clipColor(r, g, b, a); 263 clipColor(r, g, b, a);
264 } 264 }
265 265
266 static Sk4f hue_4f(const Sk4f& s, const Sk4f& d) { 266 static Sk4f hue_4f(const Sk4f& s, const Sk4f& d) {
267 float sa = s[SkPM4f::A]; 267 float sa = s[SkPM4f::A];
268 float sr = s[SkPM4f::R]; 268 float sr = s[SkPM4f::R];
269 float sg = s[SkPM4f::G]; 269 float sg = s[SkPM4f::G];
270 float sb = s[SkPM4f::B]; 270 float sb = s[SkPM4f::B];
271 271
272 float da = d[SkPM4f::A]; 272 float da = d[SkPM4f::A];
273 float dr = d[SkPM4f::R]; 273 float dr = d[SkPM4f::R];
274 float dg = d[SkPM4f::G]; 274 float dg = d[SkPM4f::G];
275 float db = d[SkPM4f::B]; 275 float db = d[SkPM4f::B];
276 276
277 float Sr = sr; 277 float Sr = sr;
278 float Sg = sg; 278 float Sg = sg;
279 float Sb = sb; 279 float Sb = sb;
280 SetSat(&Sr, &Sg, &Sb, Sat(dr, dg, db) * sa); 280 SetSat(&Sr, &Sg, &Sb, Sat(dr, dg, db) * sa);
281 SetLum(&Sr, &Sg, &Sb, sa * da, Lum(dr, dg, db) * sa); 281 SetLum(&Sr, &Sg, &Sb, sa * da, Lum(dr, dg, db) * sa);
282 282
283 return color_alpha(s * inv_alpha(d) + d * inv_alpha(s) + set_argb(0, Sr, Sg, Sb), 283 return color_alpha(s * inv_alpha(d) + d * inv_alpha(s) + set_argb(0, Sr, Sg, Sb),
284 sa + da - sa * da); 284 sa + da - sa * da);
285 } 285 }
286 286
287 static Sk4f saturation_4f(const Sk4f& s, const Sk4f& d) { 287 static Sk4f saturation_4f(const Sk4f& s, const Sk4f& d) {
288 float sa = s[SkPM4f::A]; 288 float sa = s[SkPM4f::A];
289 float sr = s[SkPM4f::R]; 289 float sr = s[SkPM4f::R];
290 float sg = s[SkPM4f::G]; 290 float sg = s[SkPM4f::G];
291 float sb = s[SkPM4f::B]; 291 float sb = s[SkPM4f::B];
292 292
293 float da = d[SkPM4f::A]; 293 float da = d[SkPM4f::A];
294 float dr = d[SkPM4f::R]; 294 float dr = d[SkPM4f::R];
295 float dg = d[SkPM4f::G]; 295 float dg = d[SkPM4f::G];
296 float db = d[SkPM4f::B]; 296 float db = d[SkPM4f::B];
297 297
298 float Dr = dr; 298 float Dr = dr;
299 float Dg = dg; 299 float Dg = dg;
300 float Db = db; 300 float Db = db;
301 SetSat(&Dr, &Dg, &Db, Sat(sr, sg, sb) * da); 301 SetSat(&Dr, &Dg, &Db, Sat(sr, sg, sb) * da);
302 SetLum(&Dr, &Dg, &Db, sa * da, Lum(dr, dg, db) * sa); 302 SetLum(&Dr, &Dg, &Db, sa * da, Lum(dr, dg, db) * sa);
303 303
304 return color_alpha(s * inv_alpha(d) + d * inv_alpha(s) + set_argb(0, Dr, Dg, Db), 304 return color_alpha(s * inv_alpha(d) + d * inv_alpha(s) + set_argb(0, Dr, Dg, Db),
305 sa + da - sa * da); 305 sa + da - sa * da);
306 } 306 }
307 307
308 static Sk4f color_4f(const Sk4f& s, const Sk4f& d) { 308 static Sk4f color_4f(const Sk4f& s, const Sk4f& d) {
309 float sa = s[SkPM4f::A]; 309 float sa = s[SkPM4f::A];
310 float sr = s[SkPM4f::R]; 310 float sr = s[SkPM4f::R];
311 float sg = s[SkPM4f::G]; 311 float sg = s[SkPM4f::G];
312 float sb = s[SkPM4f::B]; 312 float sb = s[SkPM4f::B];
313 313
314 float da = d[SkPM4f::A]; 314 float da = d[SkPM4f::A];
315 float dr = d[SkPM4f::R]; 315 float dr = d[SkPM4f::R];
316 float dg = d[SkPM4f::G]; 316 float dg = d[SkPM4f::G];
317 float db = d[SkPM4f::B]; 317 float db = d[SkPM4f::B];
318 318
319 float Sr = sr; 319 float Sr = sr;
320 float Sg = sg; 320 float Sg = sg;
321 float Sb = sb; 321 float Sb = sb;
322 SetLum(&Sr, &Sg, &Sb, sa * da, Lum(dr, dg, db) * sa); 322 SetLum(&Sr, &Sg, &Sb, sa * da, Lum(dr, dg, db) * sa);
323 323
324 Sk4f res = color_alpha(s * inv_alpha(d) + d * inv_alpha(s) + set_argb(0, Sr, Sg, Sb), 324 Sk4f res = color_alpha(s * inv_alpha(d) + d * inv_alpha(s) + set_argb(0, Sr, Sg, Sb),
325 sa + da - sa * da); 325 sa + da - sa * da);
326 // Can return tiny negative values ... 326 // Can return tiny negative values ...
327 return Sk4f::Max(res, Sk4f(0)); 327 return Sk4f::Max(res, Sk4f(0));
328 } 328 }
329 329
330 static Sk4f luminosity_4f(const Sk4f& s, const Sk4f& d) { 330 static Sk4f luminosity_4f(const Sk4f& s, const Sk4f& d) {
331 float sa = s[SkPM4f::A]; 331 float sa = s[SkPM4f::A];
332 float sr = s[SkPM4f::R]; 332 float sr = s[SkPM4f::R];
333 float sg = s[SkPM4f::G]; 333 float sg = s[SkPM4f::G];
334 float sb = s[SkPM4f::B]; 334 float sb = s[SkPM4f::B];
335 335
336 float da = d[SkPM4f::A]; 336 float da = d[SkPM4f::A];
337 float dr = d[SkPM4f::R]; 337 float dr = d[SkPM4f::R];
338 float dg = d[SkPM4f::G]; 338 float dg = d[SkPM4f::G];
339 float db = d[SkPM4f::B]; 339 float db = d[SkPM4f::B];
340 340
341 float Dr = dr; 341 float Dr = dr;
342 float Dg = dg; 342 float Dg = dg;
343 float Db = db; 343 float Db = db;
344 SetLum(&Dr, &Dg, &Db, sa * da, Lum(sr, sg, sb) * da); 344 SetLum(&Dr, &Dg, &Db, sa * da, Lum(sr, sg, sb) * da);
345 345
346 Sk4f res = color_alpha(s * inv_alpha(d) + d * inv_alpha(s) + set_argb(0, Dr, Dg, Db), 346 Sk4f res = color_alpha(s * inv_alpha(d) + d * inv_alpha(s) + set_argb(0, Dr, Dg, Db),
347 sa + da - sa * da); 347 sa + da - sa * da);
348 // Can return tiny negative values ... 348 // Can return tiny negative values ...
349 return Sk4f::Max(res, Sk4f(0)); 349 return Sk4f::Max(res, Sk4f(0));
350 } 350 }
351 351
352 /////////////////////////////////////////////////////////////////////////////// 352 ///////////////////////////////////////////////////////////////////////////////
353 353
354 // kClear_Mode, //!< [0, 0] 354 // kClear_Mode, //!< [0, 0]
355 static SkPMColor clear_modeproc(SkPMColor src, SkPMColor dst) { 355 static SkPMColor clear_modeproc(SkPMColor src, SkPMColor dst) {
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 if (!xfer) { 1410 if (!xfer) {
1411 return SkXfermode::kOpaque_SrcColorOpacity == opacityType; 1411 return SkXfermode::kOpaque_SrcColorOpacity == opacityType;
1412 } 1412 }
1413 1413
1414 return xfer->isOpaque(opacityType); 1414 return xfer->isOpaque(opacityType);
1415 } 1415 }
1416 1416
1417 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode) 1417 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkXfermode)
1418 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode) 1418 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkProcCoeffXfermode)
1419 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1419 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/core/SkWriteBuffer.cpp ('k') | src/core/SkXfermodeU64.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698