| OLD | NEW |
| 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 21 matching lines...) Expand all Loading... |
| 32 #include "platform/graphics/DrawLooper.h" | 32 #include "platform/graphics/DrawLooper.h" |
| 33 | 33 |
| 34 #include "platform/geometry/FloatSize.h" | 34 #include "platform/geometry/FloatSize.h" |
| 35 #include "platform/graphics/Color.h" | 35 #include "platform/graphics/Color.h" |
| 36 #include "third_party/skia/include/core/SkColor.h" | 36 #include "third_party/skia/include/core/SkColor.h" |
| 37 #include "third_party/skia/include/core/SkColorFilter.h" | 37 #include "third_party/skia/include/core/SkColorFilter.h" |
| 38 #include "third_party/skia/include/core/SkDrawLooper.h" | 38 #include "third_party/skia/include/core/SkDrawLooper.h" |
| 39 #include "third_party/skia/include/core/SkPaint.h" | 39 #include "third_party/skia/include/core/SkPaint.h" |
| 40 #include "third_party/skia/include/core/SkXfermode.h" | 40 #include "third_party/skia/include/core/SkXfermode.h" |
| 41 #include "third_party/skia/include/effects/SkBlurMaskFilter.h" | 41 #include "third_party/skia/include/effects/SkBlurMaskFilter.h" |
| 42 #include "third_party/skia/include/effects/SkLayerDrawLooper.h" | |
| 43 | 42 |
| 44 namespace WebCore { | 43 namespace WebCore { |
| 45 | 44 |
| 46 DrawLooper::DrawLooper() : m_skDrawLooper(adoptRef(new SkLayerDrawLooper)) { } | 45 DrawLooper::DrawLooper() { } |
| 47 | 46 |
| 48 DrawLooper::~DrawLooper() { } | 47 DrawLooper::~DrawLooper() { } |
| 49 | 48 |
| 50 SkDrawLooper* DrawLooper::skDrawLooper() const | 49 SkDrawLooper* DrawLooper::skDrawLooper() |
| 51 { | 50 { |
| 52 return m_skDrawLooper.get(); | 51 return m_skDrawLooperBuilder.detachLooper(); |
| 53 } | 52 } |
| 54 | 53 |
| 55 void DrawLooper::addUnmodifiedContent() | 54 void DrawLooper::addUnmodifiedContent() |
| 56 { | 55 { |
| 57 SkLayerDrawLooper::LayerInfo info; | 56 SkLayerDrawLooper::LayerInfo info; |
| 58 m_skDrawLooper->addLayerOnTop(info); | 57 m_skDrawLooperBuilder.addLayerOnTop(info); |
| 59 } | 58 } |
| 60 | 59 |
| 61 void DrawLooper::addShadow(const FloatSize& offset, float blur, const Color& col
or, | 60 void DrawLooper::addShadow(const FloatSize& offset, float blur, const Color& col
or, |
| 62 ShadowTransformMode shadowTransformMode, ShadowAlphaMode shadowAlphaMode) | 61 ShadowTransformMode shadowTransformMode, ShadowAlphaMode shadowAlphaMode) |
| 63 { | 62 { |
| 64 // Detect when there's no effective shadow. | 63 // Detect when there's no effective shadow. |
| 65 if (!color.alpha()) | 64 if (!color.alpha()) |
| 66 return; | 65 return; |
| 67 | 66 |
| 68 SkColor skColor = color.rgb(); | 67 SkColor skColor = color.rgb(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 79 default: | 78 default: |
| 80 ASSERT_NOT_REACHED(); | 79 ASSERT_NOT_REACHED(); |
| 81 } | 80 } |
| 82 | 81 |
| 83 if (blur) | 82 if (blur) |
| 84 info.fPaintBits |= SkLayerDrawLooper::kMaskFilter_Bit; // our blur | 83 info.fPaintBits |= SkLayerDrawLooper::kMaskFilter_Bit; // our blur |
| 85 info.fPaintBits |= SkLayerDrawLooper::kColorFilter_Bit; | 84 info.fPaintBits |= SkLayerDrawLooper::kColorFilter_Bit; |
| 86 info.fOffset.set(offset.width(), offset.height()); | 85 info.fOffset.set(offset.width(), offset.height()); |
| 87 info.fPostTranslate = (shadowTransformMode == ShadowIgnoresTransforms); | 86 info.fPostTranslate = (shadowTransformMode == ShadowIgnoresTransforms); |
| 88 | 87 |
| 89 SkPaint* paint = m_skDrawLooper->addLayerOnTop(info); | 88 SkPaint* paint = m_skDrawLooperBuilder.addLayerOnTop(info); |
| 90 | 89 |
| 91 if (blur) { | 90 if (blur) { |
| 92 uint32_t mfFlags = SkBlurMaskFilter::kHighQuality_BlurFlag; | 91 uint32_t mfFlags = SkBlurMaskFilter::kHighQuality_BlurFlag; |
| 93 if (shadowTransformMode == ShadowIgnoresTransforms) | 92 if (shadowTransformMode == ShadowIgnoresTransforms) |
| 94 mfFlags |= SkBlurMaskFilter::kIgnoreTransform_BlurFlag; | 93 mfFlags |= SkBlurMaskFilter::kIgnoreTransform_BlurFlag; |
| 95 RefPtr<SkMaskFilter> mf = adoptRef(SkBlurMaskFilter::Create( | 94 RefPtr<SkMaskFilter> mf = adoptRef(SkBlurMaskFilter::Create( |
| 96 (double)blur / 2.0, SkBlurMaskFilter::kNormal_BlurStyle, mfFlags)); | 95 (double)blur / 2.0, SkBlurMaskFilter::kNormal_BlurStyle, mfFlags)); |
| 97 paint->setMaskFilter(mf.get()); | 96 paint->setMaskFilter(mf.get()); |
| 98 } | 97 } |
| 99 | 98 |
| 100 RefPtr<SkColorFilter> cf = adoptRef(SkColorFilter::CreateModeFilter(skColor,
SkXfermode::kSrcIn_Mode)); | 99 RefPtr<SkColorFilter> cf = adoptRef(SkColorFilter::CreateModeFilter(skColor,
SkXfermode::kSrcIn_Mode)); |
| 101 paint->setColorFilter(cf.get()); | 100 paint->setColorFilter(cf.get()); |
| 102 } | 101 } |
| 103 | 102 |
| 104 } // namespace WebCore | 103 } // namespace WebCore |
| OLD | NEW |