Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DState.cpp

Issue 1543593002: Forward fill and stroke styles from 2d canvas to canvas filters (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 SkPaint fillPaint;
Justin Novosad 2016/01/11 19:52:42 Is there a reason why we need to create a new pain
ajuma 2016/01/11 21:33:08 Added a comment and changed the variable names.
360 SkPaint strokePaint;
361 m_fillStyle->applyToPaint(fillPaint);
362 m_strokeStyle->applyToPaint(strokePaint);
363 fillPaint.setColor(m_fillStyle->paintColor());
364 strokePaint.setColor(m_strokeStyle->paintColor());
361 const double effectiveZoom = 1.0; // Deliberately ignore zoom on the can vas element 365 const double effectiveZoom = 1.0; // Deliberately ignore zoom on the can vas element
362 filterEffectBuilder->build(styleResolutionHost, filterStyle->filter(), e ffectiveZoom); 366 filterEffectBuilder->build(styleResolutionHost, filterStyle->filter(), e ffectiveZoom, &fillPaint, &strokePaint);
363 367
364 SkiaImageFilterBuilder imageFilterBuilder; 368 SkiaImageFilterBuilder imageFilterBuilder;
365 RefPtrWillBeRawPtr<FilterEffect> lastEffect = filterEffectBuilder->lastE ffect(); 369 RefPtrWillBeRawPtr<FilterEffect> lastEffect = filterEffectBuilder->lastE ffect();
366 m_resolvedFilter = imageFilterBuilder.build(lastEffect.get(), ColorSpace DeviceRGB); 370 m_resolvedFilter = imageFilterBuilder.build(lastEffect.get(), ColorSpace DeviceRGB);
367 } 371 }
368 372
369 return m_resolvedFilter.get(); 373 return m_resolvedFilter.get();
370 } 374 }
371 375
372 SkDrawLooper* CanvasRenderingContext2DState::emptyDrawLooper() const 376 SkDrawLooper* CanvasRenderingContext2DState::emptyDrawLooper() const
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 paint->setLooper(0); 586 paint->setLooper(0);
583 paint->setImageFilter(shadowAndForegroundImageFilter()); 587 paint->setImageFilter(shadowAndForegroundImageFilter());
584 return paint; 588 return paint;
585 } 589 }
586 paint->setLooper(shadowAndForegroundDrawLooper()); 590 paint->setLooper(shadowAndForegroundDrawLooper());
587 paint->setImageFilter(0); 591 paint->setImageFilter(0);
588 return paint; 592 return paint;
589 } 593 }
590 594
591 } // blink 595 } // blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698