diff options
author | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-25 16:17:59 +0000 |
---|---|---|
committer | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-25 16:17:59 +0000 |
commit | 9499a0ba213dfd86c206c4dc0cc83651da3f9f3b (patch) | |
tree | 61a6a4c634ceba976401eb199f88c489891f53dc /ui/gfx/render_text.cc | |
parent | 08b054b8e97300159b1b2bcad37268fdab654f93 (diff) | |
download | chromium_src-9499a0ba213dfd86c206c4dc0cc83651da3f9f3b.zip chromium_src-9499a0ba213dfd86c206c4dc0cc83651da3f9f3b.tar.gz chromium_src-9499a0ba213dfd86c206c4dc0cc83651da3f9f3b.tar.bz2 |
Move shadow looper generation code into skia_util.
So that it could be used other than text shadows.
BUG=none.
TEST=none.
Review URL: https://chromiumcodereview.appspot.com/10445023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139054 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/render_text.cc')
-rw-r--r-- | ui/gfx/render_text.cc | 39 |
1 files changed, 1 insertions, 38 deletions
diff --git a/ui/gfx/render_text.cc b/ui/gfx/render_text.cc index d7de8a3..5b55c67 100644 --- a/ui/gfx/render_text.cc +++ b/ui/gfx/render_text.cc @@ -10,11 +10,8 @@ #include "base/i18n/break_iterator.h" #include "base/logging.h" #include "base/stl_util.h" -#include "third_party/skia/include/core/SkColorFilter.h" #include "third_party/skia/include/core/SkTypeface.h" -#include "third_party/skia/include/effects/SkBlurMaskFilter.h" #include "third_party/skia/include/effects/SkGradientShader.h" -#include "third_party/skia/include/effects/SkLayerDrawLooper.h" #include "ui/base/text/utf16_indexing.h" #include "ui/gfx/canvas.h" #include "ui/gfx/insets.h" @@ -874,42 +871,8 @@ void RenderText::ApplyFadeEffects(internal::SkiaTextRenderer* renderer) { } void RenderText::ApplyTextShadows(internal::SkiaTextRenderer* renderer) { - if (text_shadows_.empty()) { - renderer->SetDrawLooper(NULL); - return; - } - - SkLayerDrawLooper* looper = new SkLayerDrawLooper; + SkDrawLooper* looper = gfx::CreateShadowDrawLooper(text_shadows_); SkAutoUnref auto_unref(looper); - - looper->addLayer(); // top layer of the original. - - SkLayerDrawLooper::LayerInfo layer_info; - layer_info.fPaintBits |= SkLayerDrawLooper::kMaskFilter_Bit; - layer_info.fPaintBits |= SkLayerDrawLooper::kColorFilter_Bit; - layer_info.fColorMode = SkXfermode::kSrc_Mode; - - for (size_t i = 0; i < text_shadows_.size(); ++i) { - const ShadowValue& shadow = text_shadows_[i]; - - layer_info.fOffset.set(SkIntToScalar(shadow.x()), - SkIntToScalar(shadow.y())); - - // 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); - - SkPaint* paint = looper->addLayer(layer_info); - SkSafeUnref(paint->setMaskFilter(blur_mask)); - SkSafeUnref(paint->setColorFilter(color_filter)); - } - renderer->SetDrawLooper(looper); } |