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

Side by Side Diff: Source/platform/graphics/skia/SkiaUtils.cpp

Issue 900463002: Make SVG painting independent of GraphicsContext's alpha state (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address reviewer comments Created 5 years, 10 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 | « Source/platform/graphics/skia/SkiaUtils.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 (c) 2006,2007,2008, Google Inc. All rights reserved. 2 * Copyright (c) 2006,2007,2008, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 // discouraged. Always drawing with AA can negatively impact performance 353 // discouraged. Always drawing with AA can negatively impact performance
354 // though - that's why it's not always on. 354 // though - that's why it's not always on.
355 SkScalar widthExpansion, heightExpansion; 355 SkScalar widthExpansion, heightExpansion;
356 if (totalMatrix.getType() & SkMatrix::kAffine_Mask) 356 if (totalMatrix.getType() & SkMatrix::kAffine_Mask)
357 widthExpansion = totalMatrix[SkMatrix::kMSkewY], heightExpansion = total Matrix[SkMatrix::kMSkewX]; 357 widthExpansion = totalMatrix[SkMatrix::kMSkewY], heightExpansion = total Matrix[SkMatrix::kMSkewX];
358 else 358 else
359 widthExpansion = totalMatrix[SkMatrix::kMScaleX], heightExpansion = tota lMatrix[SkMatrix::kMScaleY]; 359 widthExpansion = totalMatrix[SkMatrix::kMScaleX], heightExpansion = tota lMatrix[SkMatrix::kMScaleY];
360 return destRect.width() * fabs(widthExpansion) < 1 || destRect.height() * fa bs(heightExpansion) < 1; 360 return destRect.width() * fabs(widthExpansion) < 1 || destRect.height() * fa bs(heightExpansion) < 1;
361 } 361 }
362 362
363 int clampedAlphaForBlending(float alpha)
364 {
365 if (alpha < 0)
366 return 0;
367 int roundedAlpha = roundf(alpha * 256);
368 if (roundedAlpha > 256)
369 roundedAlpha = 256;
370 return roundedAlpha;
371 }
372
373 SkColor multiplyAlpha(SkColor color, float alpha)
374 {
375 return multiplyAlpha(color, clampedAlphaForBlending(alpha));
376 }
377
378 SkColor multiplyAlpha(SkColor color, int alpha)
379 {
380 int a = (SkColorGetA(color) * alpha) >> 8;
381 return (color & 0x00FFFFFF) | (a << 24);
382 }
383
363 } // namespace blink 384 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/graphics/skia/SkiaUtils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698