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

Side by Side Diff: ui/gfx/skia_util.cc

Issue 1829093002: Use sk_sp-based APIs for SkColorFilter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to reviews 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/skia_util.h" 5 #include "ui/gfx/skia_util.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/numerics/safe_conversions.h" 10 #include "base/numerics/safe_conversions.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 158
159 layer_info.fOffset.set(SkIntToScalar(shadow.x()), 159 layer_info.fOffset.set(SkIntToScalar(shadow.x()),
160 SkIntToScalar(shadow.y())); 160 SkIntToScalar(shadow.y()));
161 161
162 // SkBlurMaskFilter's blur radius defines the range to extend the blur from 162 // SkBlurMaskFilter's blur radius defines the range to extend the blur from
163 // original mask, which is half of blur amount as defined in ShadowValue. 163 // original mask, which is half of blur amount as defined in ShadowValue.
164 skia::RefPtr<SkMaskFilter> blur_mask = skia::AdoptRef( 164 skia::RefPtr<SkMaskFilter> blur_mask = skia::AdoptRef(
165 SkBlurMaskFilter::Create(kNormal_SkBlurStyle, 165 SkBlurMaskFilter::Create(kNormal_SkBlurStyle,
166 RadiusToSigma(shadow.blur() / 2), 166 RadiusToSigma(shadow.blur() / 2),
167 SkBlurMaskFilter::kHighQuality_BlurFlag)); 167 SkBlurMaskFilter::kHighQuality_BlurFlag));
168 skia::RefPtr<SkColorFilter> color_filter = skia::AdoptRef(
169 SkColorFilter::CreateModeFilter(shadow.color(),
170 SkXfermode::kSrcIn_Mode));
171 168
172 SkPaint* paint = looper_builder.addLayer(layer_info); 169 SkPaint* paint = looper_builder.addLayer(layer_info);
173 paint->setMaskFilter(blur_mask.get()); 170 paint->setMaskFilter(blur_mask.get());
174 paint->setColorFilter(color_filter.get()); 171 paint->setColorFilter(
172 SkColorFilter::MakeModeFilter(shadow.color(),
173 SkXfermode::kSrcIn_Mode));
175 } 174 }
176 175
177 return skia::AdoptRef<SkDrawLooper>(looper_builder.detachLooper()); 176 return skia::AdoptRef<SkDrawLooper>(looper_builder.detachLooper());
178 } 177 }
179 178
180 bool BitmapsAreEqual(const SkBitmap& bitmap1, const SkBitmap& bitmap2) { 179 bool BitmapsAreEqual(const SkBitmap& bitmap1, const SkBitmap& bitmap2) {
181 void* addr1 = NULL; 180 void* addr1 = NULL;
182 void* addr2 = NULL; 181 void* addr2 = NULL;
183 size_t size1 = 0; 182 size_t size1 = 0;
184 size_t size2 = 0; 183 size_t size2 = 0;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 static const SkScalar kSkToHbRatio = SK_Scalar1 / kHbUnit1; 237 static const SkScalar kSkToHbRatio = SK_Scalar1 / kHbUnit1;
239 return kSkToHbRatio * value; 238 return kSkToHbRatio * value;
240 } 239 }
241 240
242 float HarfBuzzUnitsToFloat(int value) { 241 float HarfBuzzUnitsToFloat(int value) {
243 static const float kFloatToHbRatio = 1.0f / kHbUnit1; 242 static const float kFloatToHbRatio = 1.0f / kHbUnit1;
244 return kFloatToHbRatio * value; 243 return kFloatToHbRatio * value;
245 } 244 }
246 245
247 } // namespace gfx 246 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698