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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 return adoptPtr(new DrawLooperBuilder); | 53 return adoptPtr(new DrawLooperBuilder); |
54 } | 54 } |
55 | 55 |
56 PassRefPtr<SkDrawLooper> DrawLooperBuilder::detachDrawLooper() | 56 PassRefPtr<SkDrawLooper> DrawLooperBuilder::detachDrawLooper() |
57 { | 57 { |
58 return adoptRef(m_skDrawLooperBuilder.detachLooper()); | 58 return adoptRef(m_skDrawLooperBuilder.detachLooper()); |
59 } | 59 } |
60 | 60 |
61 void DrawLooperBuilder::addUnmodifiedContent() | 61 void DrawLooperBuilder::addUnmodifiedContent() |
62 { | 62 { |
63 SkLayerDrawLooper::LayerInfo info; | 63 m_skDrawLooperBuilder.addLayer(); |
64 m_skDrawLooperBuilder.addLayerOnTop(info); | |
65 } | 64 } |
66 | 65 |
67 void DrawLooperBuilder::addShadow(const FloatSize& offset, float blur, const Col
or& color, | 66 void DrawLooperBuilder::addShadow(const FloatSize& offset, float blur, const Col
or& color, |
68 ShadowTransformMode shadowTransformMode, ShadowAlphaMode shadowAlphaMode) | 67 ShadowTransformMode shadowTransformMode, ShadowAlphaMode shadowAlphaMode) |
69 { | 68 { |
70 // Detect when there's no effective shadow. | 69 // Detect when there's no effective shadow. |
71 if (!color.alpha()) | 70 if (!color.alpha()) |
72 return; | 71 return; |
73 | 72 |
74 SkColor skColor = color.rgb(); | 73 SkColor skColor = color.rgb(); |
(...skipping 10 matching lines...) Expand all Loading... |
85 default: | 84 default: |
86 ASSERT_NOT_REACHED(); | 85 ASSERT_NOT_REACHED(); |
87 } | 86 } |
88 | 87 |
89 if (blur) | 88 if (blur) |
90 info.fPaintBits |= SkLayerDrawLooper::kMaskFilter_Bit; // our blur | 89 info.fPaintBits |= SkLayerDrawLooper::kMaskFilter_Bit; // our blur |
91 info.fPaintBits |= SkLayerDrawLooper::kColorFilter_Bit; | 90 info.fPaintBits |= SkLayerDrawLooper::kColorFilter_Bit; |
92 info.fOffset.set(offset.width(), offset.height()); | 91 info.fOffset.set(offset.width(), offset.height()); |
93 info.fPostTranslate = (shadowTransformMode == ShadowIgnoresTransforms); | 92 info.fPostTranslate = (shadowTransformMode == ShadowIgnoresTransforms); |
94 | 93 |
95 SkPaint* paint = m_skDrawLooperBuilder.addLayerOnTop(info); | 94 SkPaint* paint = m_skDrawLooperBuilder.addLayer(info); |
96 | 95 |
97 if (blur) { | 96 if (blur) { |
98 const SkScalar sigma = skBlurRadiusToSigma(blur); | 97 const SkScalar sigma = skBlurRadiusToSigma(blur); |
99 uint32_t mfFlags = SkBlurMaskFilter::kHighQuality_BlurFlag; | 98 uint32_t mfFlags = SkBlurMaskFilter::kHighQuality_BlurFlag; |
100 if (shadowTransformMode == ShadowIgnoresTransforms) | 99 if (shadowTransformMode == ShadowIgnoresTransforms) |
101 mfFlags |= SkBlurMaskFilter::kIgnoreTransform_BlurFlag; | 100 mfFlags |= SkBlurMaskFilter::kIgnoreTransform_BlurFlag; |
102 RefPtr<SkMaskFilter> mf = adoptRef(SkBlurMaskFilter::Create(kNormal_SkBl
urStyle, sigma, mfFlags)); | 101 RefPtr<SkMaskFilter> mf = adoptRef(SkBlurMaskFilter::Create(kNormal_SkBl
urStyle, sigma, mfFlags)); |
103 paint->setMaskFilter(mf.get()); | 102 paint->setMaskFilter(mf.get()); |
104 } | 103 } |
105 | 104 |
106 RefPtr<SkColorFilter> cf = adoptRef(SkColorFilter::CreateModeFilter(skColor,
SkXfermode::kSrcIn_Mode)); | 105 RefPtr<SkColorFilter> cf = adoptRef(SkColorFilter::CreateModeFilter(skColor,
SkXfermode::kSrcIn_Mode)); |
107 paint->setColorFilter(cf.get()); | 106 paint->setColorFilter(cf.get()); |
108 } | 107 } |
109 | 108 |
110 } // namespace blink | 109 } // namespace blink |
OLD | NEW |