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

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

Issue 2472543002: remove legacy Skia flags (Closed)
Patch Set: address nit Created 4 years, 1 month 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 m_isTransformInvertible = true; 272 m_isTransformInvertible = true;
273 } 273 }
274 274
275 static void updateFilterReferences(HTMLCanvasElement* canvasElement, 275 static void updateFilterReferences(HTMLCanvasElement* canvasElement,
276 CanvasRenderingContext2D* context, 276 CanvasRenderingContext2D* context,
277 const FilterOperations& filters) { 277 const FilterOperations& filters) {
278 context->clearFilterReferences(); 278 context->clearFilterReferences();
279 context->addFilterReferences(filters, canvasElement->document()); 279 context->addFilterReferences(filters, canvasElement->document());
280 } 280 }
281 281
282 SkImageFilter* CanvasRenderingContext2DState::getFilter( 282 sk_sp<SkImageFilter> CanvasRenderingContext2DState::getFilter(
283 Element* styleResolutionHost, 283 Element* styleResolutionHost,
284 IntSize canvasSize, 284 IntSize canvasSize,
285 CanvasRenderingContext2D* context) const { 285 CanvasRenderingContext2D* context) const {
286 if (!m_filterValue) 286 if (!m_filterValue)
287 return nullptr; 287 return nullptr;
288 288
289 // StyleResolverState cannot be used in frame-less documents. 289 // StyleResolverState cannot be used in frame-less documents.
290 if (!styleResolutionHost->document().frame()) 290 if (!styleResolutionHost->document().frame())
291 return nullptr; 291 return nullptr;
292 292
(...skipping 30 matching lines...) Expand all
323 SkiaImageFilterBuilder::build(lastEffect, ColorSpaceDeviceRGB); 323 SkiaImageFilterBuilder::build(lastEffect, ColorSpaceDeviceRGB);
324 if (m_resolvedFilter) { 324 if (m_resolvedFilter) {
325 updateFilterReferences(toHTMLCanvasElement(styleResolutionHost), 325 updateFilterReferences(toHTMLCanvasElement(styleResolutionHost),
326 context, filterStyle->filter()); 326 context, filterStyle->filter());
327 if (lastEffect->originTainted()) 327 if (lastEffect->originTainted())
328 context->setOriginTainted(); 328 context->setOriginTainted();
329 } 329 }
330 } 330 }
331 } 331 }
332 332
333 return m_resolvedFilter.get(); 333 return m_resolvedFilter;
334 } 334 }
335 335
336 bool CanvasRenderingContext2DState::hasFilter( 336 bool CanvasRenderingContext2DState::hasFilter(
337 Element* styleResolutionHost, 337 Element* styleResolutionHost,
338 IntSize canvasSize, 338 IntSize canvasSize,
339 CanvasRenderingContext2D* context) const { 339 CanvasRenderingContext2D* context) const {
340 // Checking for a non-null m_filterValue isn't sufficient, since this value 340 // Checking for a non-null m_filterValue isn't sufficient, since this value
341 // might refer to a non-existent filter. 341 // might refer to a non-existent filter.
342 return !!getFilter(styleResolutionHost, canvasSize, context); 342 return !!getFilter(styleResolutionHost, canvasSize, context);
343 } 343 }
(...skipping 30 matching lines...) Expand all
374 DrawLooperBuilder::create(); 374 DrawLooperBuilder::create();
375 drawLooperBuilder->addShadow(m_shadowOffset, m_shadowBlur, m_shadowColor, 375 drawLooperBuilder->addShadow(m_shadowOffset, m_shadowBlur, m_shadowColor,
376 DrawLooperBuilder::ShadowIgnoresTransforms, 376 DrawLooperBuilder::ShadowIgnoresTransforms,
377 DrawLooperBuilder::ShadowRespectsAlpha); 377 DrawLooperBuilder::ShadowRespectsAlpha);
378 drawLooperBuilder->addUnmodifiedContent(); 378 drawLooperBuilder->addUnmodifiedContent();
379 m_shadowAndForegroundDrawLooper = drawLooperBuilder->detachDrawLooper(); 379 m_shadowAndForegroundDrawLooper = drawLooperBuilder->detachDrawLooper();
380 } 380 }
381 return m_shadowAndForegroundDrawLooper.get(); 381 return m_shadowAndForegroundDrawLooper.get();
382 } 382 }
383 383
384 SkImageFilter* CanvasRenderingContext2DState::shadowOnlyImageFilter() const { 384 sk_sp<SkImageFilter> CanvasRenderingContext2DState::shadowOnlyImageFilter()
385 const {
385 if (!m_shadowOnlyImageFilter) { 386 if (!m_shadowOnlyImageFilter) {
386 double sigma = skBlurRadiusToSigma(m_shadowBlur); 387 double sigma = skBlurRadiusToSigma(m_shadowBlur);
387 m_shadowOnlyImageFilter = SkDropShadowImageFilter::Make( 388 m_shadowOnlyImageFilter = SkDropShadowImageFilter::Make(
388 m_shadowOffset.width(), m_shadowOffset.height(), sigma, sigma, 389 m_shadowOffset.width(), m_shadowOffset.height(), sigma, sigma,
389 m_shadowColor, SkDropShadowImageFilter::kDrawShadowOnly_ShadowMode, 390 m_shadowColor, SkDropShadowImageFilter::kDrawShadowOnly_ShadowMode,
390 nullptr); 391 nullptr);
391 } 392 }
392 return m_shadowOnlyImageFilter.get(); 393 return m_shadowOnlyImageFilter;
393 } 394 }
394 395
395 SkImageFilter* CanvasRenderingContext2DState::shadowAndForegroundImageFilter() 396 sk_sp<SkImageFilter>
396 const { 397 CanvasRenderingContext2DState::shadowAndForegroundImageFilter() const {
397 if (!m_shadowAndForegroundImageFilter) { 398 if (!m_shadowAndForegroundImageFilter) {
398 double sigma = skBlurRadiusToSigma(m_shadowBlur); 399 double sigma = skBlurRadiusToSigma(m_shadowBlur);
399 m_shadowAndForegroundImageFilter = SkDropShadowImageFilter::Make( 400 m_shadowAndForegroundImageFilter = SkDropShadowImageFilter::Make(
400 m_shadowOffset.width(), m_shadowOffset.height(), sigma, sigma, 401 m_shadowOffset.width(), m_shadowOffset.height(), sigma, sigma,
401 m_shadowColor, 402 m_shadowColor,
402 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, nullptr); 403 SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode, nullptr);
403 } 404 }
404 return m_shadowAndForegroundImageFilter.get(); 405 return m_shadowAndForegroundImageFilter;
405 } 406 }
406 407
407 void CanvasRenderingContext2DState::shadowParameterChanged() { 408 void CanvasRenderingContext2DState::shadowParameterChanged() {
408 m_shadowOnlyDrawLooper.reset(); 409 m_shadowOnlyDrawLooper.reset();
409 m_shadowAndForegroundDrawLooper.reset(); 410 m_shadowAndForegroundDrawLooper.reset();
410 m_shadowOnlyImageFilter.reset(); 411 m_shadowOnlyImageFilter.reset();
411 m_shadowAndForegroundImageFilter.reset(); 412 m_shadowAndForegroundImageFilter.reset();
412 } 413 }
413 414
414 void CanvasRenderingContext2DState::setShadowOffsetX(double x) { 415 void CanvasRenderingContext2DState::setShadowOffsetX(double x) {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 paint->setLooper(0); 557 paint->setLooper(0);
557 paint->setImageFilter(shadowAndForegroundImageFilter()); 558 paint->setImageFilter(shadowAndForegroundImageFilter());
558 return paint; 559 return paint;
559 } 560 }
560 paint->setLooper(sk_ref_sp(shadowAndForegroundDrawLooper())); 561 paint->setLooper(sk_ref_sp(shadowAndForegroundDrawLooper()));
561 paint->setImageFilter(0); 562 paint->setImageFilter(0);
562 return paint; 563 return paint;
563 } 564 }
564 565
565 } // namespace blink 566 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698