diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-05 01:00:54 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-05 01:00:54 +0000 |
commit | 3699ae5a17c4b0b68842a673550d86cdc7961728 (patch) | |
tree | cf60fc865bcbdf60e47ca37b43fa7cfd5898f01f /ui/gfx/skia_util.cc | |
parent | f775d10814adf1320c8bf9de8279d473c254dd9e (diff) | |
download | chromium_src-3699ae5a17c4b0b68842a673550d86cdc7961728.zip chromium_src-3699ae5a17c4b0b68842a673550d86cdc7961728.tar.gz chromium_src-3699ae5a17c4b0b68842a673550d86cdc7961728.tar.bz2 |
ui: Use skia::RefPtr<T> for implicit safe reference counting.
R=sky
BUG=163454
Depends on: https://codereview.chromium.org/11418217/
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/11299262
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171107 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/skia_util.cc')
-rw-r--r-- | ui/gfx/skia_util.cc | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/ui/gfx/skia_util.cc b/ui/gfx/skia_util.cc index caa35e7..162a5ba 100644 --- a/ui/gfx/skia_util.cc +++ b/ui/gfx/skia_util.cc @@ -47,11 +47,11 @@ RectF SkRectToRectF(const SkRect& rect) { } -SkShader* CreateImageRepShader(const gfx::ImageSkiaRep& image_rep, - SkShader::TileMode tile_mode, - const SkMatrix& local_matrix) { - SkShader* shader = SkShader::CreateBitmapShader(image_rep.sk_bitmap(), - tile_mode, tile_mode); +skia::RefPtr<SkShader> CreateImageRepShader(const gfx::ImageSkiaRep& image_rep, + SkShader::TileMode tile_mode, + const SkMatrix& local_matrix) { + skia::RefPtr<SkShader> shader = skia::AdoptRef(SkShader::CreateBitmapShader( + image_rep.sk_bitmap(), tile_mode, tile_mode)); SkScalar scale_x = local_matrix.getScaleX(); SkScalar scale_y = local_matrix.getScaleY(); SkScalar bitmap_scale = SkFloatToScalar(image_rep.GetScale()); @@ -72,24 +72,26 @@ SkShader* CreateImageRepShader(const gfx::ImageSkiaRep& image_rep, return shader; } -SkShader* CreateGradientShader(int start_point, - int end_point, - SkColor start_color, - SkColor end_color) { +skia::RefPtr<SkShader> CreateGradientShader(int start_point, + int end_point, + SkColor start_color, + SkColor end_color) { SkColor grad_colors[2] = { start_color, end_color}; SkPoint grad_points[2]; grad_points[0].iset(0, start_point); grad_points[1].iset(0, end_point); - return SkGradientShader::CreateLinear( - grad_points, grad_colors, NULL, 2, SkShader::kRepeat_TileMode); + return skia::AdoptRef(SkGradientShader::CreateLinear( + grad_points, grad_colors, NULL, 2, SkShader::kRepeat_TileMode)); } -SkDrawLooper* CreateShadowDrawLooper(const std::vector<ShadowValue>& shadows) { +skia::RefPtr<SkDrawLooper> CreateShadowDrawLooper( + const std::vector<ShadowValue>& shadows) { if (shadows.empty()) - return NULL; + return skia::RefPtr<SkDrawLooper>(); - SkLayerDrawLooper* looper = new SkLayerDrawLooper; + skia::RefPtr<SkLayerDrawLooper> looper = + skia::AdoptRef(new SkLayerDrawLooper); looper->addLayer(); // top layer of the original. @@ -106,17 +108,17 @@ SkDrawLooper* CreateShadowDrawLooper(const std::vector<ShadowValue>& shadows) { // SkBlurMaskFilter's blur radius defines the range to extend the blur from // original mask, which is half of blur amount as defined in ShadowValue. - SkMaskFilter* blur_mask = SkBlurMaskFilter::Create( - SkDoubleToScalar(shadow.blur() / 2), - SkBlurMaskFilter::kNormal_BlurStyle, - SkBlurMaskFilter::kHighQuality_BlurFlag); - SkColorFilter* color_filter = SkColorFilter::CreateModeFilter( - shadow.color(), - SkXfermode::kSrcIn_Mode); + skia::RefPtr<SkMaskFilter> blur_mask = skia::AdoptRef( + SkBlurMaskFilter::Create(SkDoubleToScalar(shadow.blur() / 2), + SkBlurMaskFilter::kNormal_BlurStyle, + SkBlurMaskFilter::kHighQuality_BlurFlag)); + skia::RefPtr<SkColorFilter> color_filter = skia::AdoptRef( + SkColorFilter::CreateModeFilter(shadow.color(), + SkXfermode::kSrcIn_Mode)); SkPaint* paint = looper->addLayer(layer_info); - SkSafeUnref(paint->setMaskFilter(blur_mask)); - SkSafeUnref(paint->setColorFilter(color_filter)); + paint->setMaskFilter(blur_mask.get()); + paint->setColorFilter(color_filter.get()); } return looper; |