OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "modules/canvas2d/CanvasRenderingContext2DState.h" | 5 #include "modules/canvas2d/CanvasRenderingContext2DState.h" |
6 | 6 |
7 #include "core/css/CSSFontSelector.h" | 7 #include "core/css/CSSFontSelector.h" |
8 #include "core/css/resolver/FilterOperationResolver.h" | 8 #include "core/css/resolver/FilterOperationResolver.h" |
9 #include "core/css/resolver/StyleBuilder.h" | 9 #include "core/css/resolver/StyleBuilder.h" |
10 #include "core/css/resolver/StyleResolverState.h" | 10 #include "core/css/resolver/StyleResolverState.h" |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 return nullptr; | 347 return nullptr; |
348 | 348 |
349 if (!m_resolvedFilter) { | 349 if (!m_resolvedFilter) { |
350 RefPtr<ComputedStyle> filterStyle = ComputedStyle::create(); | 350 RefPtr<ComputedStyle> filterStyle = ComputedStyle::create(); |
351 // Must set font in case the filter uses any font-relative units (em, ex
) | 351 // Must set font in case the filter uses any font-relative units (em, ex
) |
352 filterStyle->setFont(font); | 352 filterStyle->setFont(font); |
353 | 353 |
354 StyleResolverState resolverState(styleResolutionHost->document(), styleR
esolutionHost, filterStyle.get()); | 354 StyleResolverState resolverState(styleResolutionHost->document(), styleR
esolutionHost, filterStyle.get()); |
355 resolverState.setStyle(filterStyle); | 355 resolverState.setStyle(filterStyle); |
356 | 356 |
357 // TODO(junov): crbug.com/502877 Feed m_fillStyle and m_strokeStyle into
FillPaint and | |
358 // StrokePaint respectively for filters that reference SVG. | |
359 StyleBuilder::applyProperty(CSSPropertyWebkitFilter, resolverState, m_fi
lterValue.get()); | 357 StyleBuilder::applyProperty(CSSPropertyWebkitFilter, resolverState, m_fi
lterValue.get()); |
360 RefPtrWillBeRawPtr<FilterEffectBuilder> filterEffectBuilder = FilterEffe
ctBuilder::create(); | 358 RefPtrWillBeRawPtr<FilterEffectBuilder> filterEffectBuilder = FilterEffe
ctBuilder::create(); |
| 359 |
| 360 // We can't reuse m_fillPaint and m_strokePaint for the filter, since th
ese incorporate |
| 361 // the global alpha, which isn't applicable here. |
| 362 SkPaint fillPaintForFilter; |
| 363 SkPaint strokePaintForFilter; |
| 364 m_fillStyle->applyToPaint(fillPaintForFilter); |
| 365 m_strokeStyle->applyToPaint(strokePaintForFilter); |
| 366 fillPaintForFilter.setColor(m_fillStyle->paintColor()); |
| 367 strokePaintForFilter.setColor(m_strokeStyle->paintColor()); |
361 const double effectiveZoom = 1.0; // Deliberately ignore zoom on the can
vas element | 368 const double effectiveZoom = 1.0; // Deliberately ignore zoom on the can
vas element |
362 filterEffectBuilder->build(styleResolutionHost, filterStyle->filter(), e
ffectiveZoom); | 369 filterEffectBuilder->build(styleResolutionHost, filterStyle->filter(), e
ffectiveZoom, &fillPaintForFilter, &strokePaintForFilter); |
363 | 370 |
364 SkiaImageFilterBuilder imageFilterBuilder; | 371 SkiaImageFilterBuilder imageFilterBuilder; |
365 RefPtrWillBeRawPtr<FilterEffect> lastEffect = filterEffectBuilder->lastE
ffect(); | 372 RefPtrWillBeRawPtr<FilterEffect> lastEffect = filterEffectBuilder->lastE
ffect(); |
366 m_resolvedFilter = imageFilterBuilder.build(lastEffect.get(), ColorSpace
DeviceRGB); | 373 m_resolvedFilter = imageFilterBuilder.build(lastEffect.get(), ColorSpace
DeviceRGB); |
367 } | 374 } |
368 | 375 |
369 return m_resolvedFilter.get(); | 376 return m_resolvedFilter.get(); |
370 } | 377 } |
371 | 378 |
372 SkDrawLooper* CanvasRenderingContext2DState::emptyDrawLooper() const | 379 SkDrawLooper* CanvasRenderingContext2DState::emptyDrawLooper() const |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 paint->setLooper(0); | 589 paint->setLooper(0); |
583 paint->setImageFilter(shadowAndForegroundImageFilter()); | 590 paint->setImageFilter(shadowAndForegroundImageFilter()); |
584 return paint; | 591 return paint; |
585 } | 592 } |
586 paint->setLooper(shadowAndForegroundDrawLooper()); | 593 paint->setLooper(shadowAndForegroundDrawLooper()); |
587 paint->setImageFilter(0); | 594 paint->setImageFilter(0); |
588 return paint; | 595 return paint; |
589 } | 596 } |
590 | 597 |
591 } // blink | 598 } // blink |
OLD | NEW |