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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/DrawLooperBuilder.cpp

Issue 2807923002: Replace ASSERT, ASSERT_NOT_REACHED, and RELEASE_ASSERT in platform/graphics (Closed)
Patch Set: fix typo Created 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 void DrawLooperBuilder::AddUnmodifiedContent() { 55 void DrawLooperBuilder::AddUnmodifiedContent() {
56 SkLayerDrawLooper::LayerInfo info; 56 SkLayerDrawLooper::LayerInfo info;
57 sk_draw_looper_builder_.addLayerOnTop(info); 57 sk_draw_looper_builder_.addLayerOnTop(info);
58 } 58 }
59 59
60 void DrawLooperBuilder::AddShadow(const FloatSize& offset, 60 void DrawLooperBuilder::AddShadow(const FloatSize& offset,
61 float blur, 61 float blur,
62 const Color& color, 62 const Color& color,
63 ShadowTransformMode shadow_transform_mode, 63 ShadowTransformMode shadow_transform_mode,
64 ShadowAlphaMode shadow_alpha_mode) { 64 ShadowAlphaMode shadow_alpha_mode) {
65 ASSERT(blur >= 0); 65 DCHECK_GE(blur, 0);
66 66
67 // Detect when there's no effective shadow. 67 // Detect when there's no effective shadow.
68 if (!color.Alpha()) 68 if (!color.Alpha())
69 return; 69 return;
70 70
71 SkColor sk_color = color.Rgb(); 71 SkColor sk_color = color.Rgb();
72 72
73 SkLayerDrawLooper::LayerInfo info; 73 SkLayerDrawLooper::LayerInfo info;
74 74
75 switch (shadow_alpha_mode) { 75 switch (shadow_alpha_mode) {
76 case kShadowRespectsAlpha: 76 case kShadowRespectsAlpha:
77 info.fColorMode = SkBlendMode::kDst; 77 info.fColorMode = SkBlendMode::kDst;
78 break; 78 break;
79 case kShadowIgnoresAlpha: 79 case kShadowIgnoresAlpha:
80 info.fColorMode = SkBlendMode::kSrc; 80 info.fColorMode = SkBlendMode::kSrc;
81 break; 81 break;
82 default: 82 default:
83 ASSERT_NOT_REACHED(); 83 NOTREACHED();
84 } 84 }
85 85
86 if (blur) 86 if (blur)
87 info.fPaintBits |= SkLayerDrawLooper::kMaskFilter_Bit; // our blur 87 info.fPaintBits |= SkLayerDrawLooper::kMaskFilter_Bit; // our blur
88 info.fPaintBits |= SkLayerDrawLooper::kColorFilter_Bit; 88 info.fPaintBits |= SkLayerDrawLooper::kColorFilter_Bit;
89 info.fOffset.set(offset.Width(), offset.Height()); 89 info.fOffset.set(offset.Width(), offset.Height());
90 info.fPostTranslate = (shadow_transform_mode == kShadowIgnoresTransforms); 90 info.fPostTranslate = (shadow_transform_mode == kShadowIgnoresTransforms);
91 91
92 SkPaint* paint = sk_draw_looper_builder_.addLayerOnTop(info); 92 SkPaint* paint = sk_draw_looper_builder_.addLayerOnTop(info);
93 93
94 if (blur) { 94 if (blur) {
95 const SkScalar sigma = SkBlurRadiusToSigma(blur); 95 const SkScalar sigma = SkBlurRadiusToSigma(blur);
96 uint32_t mf_flags = SkBlurMaskFilter::kHighQuality_BlurFlag; 96 uint32_t mf_flags = SkBlurMaskFilter::kHighQuality_BlurFlag;
97 if (shadow_transform_mode == kShadowIgnoresTransforms) 97 if (shadow_transform_mode == kShadowIgnoresTransforms)
98 mf_flags |= SkBlurMaskFilter::kIgnoreTransform_BlurFlag; 98 mf_flags |= SkBlurMaskFilter::kIgnoreTransform_BlurFlag;
99 paint->setMaskFilter( 99 paint->setMaskFilter(
100 SkBlurMaskFilter::Make(kNormal_SkBlurStyle, sigma, mf_flags)); 100 SkBlurMaskFilter::Make(kNormal_SkBlurStyle, sigma, mf_flags));
101 } 101 }
102 102
103 paint->setColorFilter( 103 paint->setColorFilter(
104 SkColorFilter::MakeModeFilter(sk_color, SkBlendMode::kSrcIn)); 104 SkColorFilter::MakeModeFilter(sk_color, SkBlendMode::kSrcIn));
105 } 105 }
106 106
107 } // namespace blink 107 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698