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

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

Issue 2490163002: Reland of "Tracking reference filter mutation via SVGElementProxy" (Closed)
Patch Set: Fix double observer unregistration; simplify scope selection; add tests 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
« no previous file with comments | « third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 const AffineTransform& transform) { 265 const AffineTransform& transform) {
266 m_isTransformInvertible = transform.isInvertible(); 266 m_isTransformInvertible = transform.isInvertible();
267 m_transform = transform; 267 m_transform = transform;
268 } 268 }
269 269
270 void CanvasRenderingContext2DState::resetTransform() { 270 void CanvasRenderingContext2DState::resetTransform() {
271 m_transform.makeIdentity(); 271 m_transform.makeIdentity();
272 m_isTransformInvertible = true; 272 m_isTransformInvertible = true;
273 } 273 }
274 274
275 static void updateFilterReferences(HTMLCanvasElement* canvasElement,
276 CanvasRenderingContext2D* context,
277 const FilterOperations& filters) {
278 context->clearFilterReferences();
279 context->addFilterReferences(filters, canvasElement->document());
280 }
281
282 sk_sp<SkImageFilter> CanvasRenderingContext2DState::getFilter( 275 sk_sp<SkImageFilter> CanvasRenderingContext2DState::getFilter(
283 Element* styleResolutionHost, 276 Element* styleResolutionHost,
284 IntSize canvasSize, 277 IntSize canvasSize,
285 CanvasRenderingContext2D* context) const { 278 CanvasRenderingContext2D* context) const {
286 if (!m_filterValue) 279 if (!m_filterValue)
287 return nullptr; 280 return nullptr;
288 281
289 // StyleResolverState cannot be used in frame-less documents. 282 // StyleResolverState cannot be used in frame-less documents.
290 if (!styleResolutionHost->document().frame()) 283 if (!styleResolutionHost->document().frame())
291 return nullptr; 284 return nullptr;
(...skipping 23 matching lines...) Expand all
315 FilterEffectBuilder filterEffectBuilder( 308 FilterEffectBuilder filterEffectBuilder(
316 styleResolutionHost, FloatRect((FloatPoint()), FloatSize(canvasSize)), 309 styleResolutionHost, FloatRect((FloatPoint()), FloatSize(canvasSize)),
317 1.0f, // Deliberately ignore zoom on the canvas element. 310 1.0f, // Deliberately ignore zoom on the canvas element.
318 &fillPaintForFilter, &strokePaintForFilter); 311 &fillPaintForFilter, &strokePaintForFilter);
319 312
320 if (FilterEffect* lastEffect = 313 if (FilterEffect* lastEffect =
321 filterEffectBuilder.buildFilterEffect(filterStyle->filter())) { 314 filterEffectBuilder.buildFilterEffect(filterStyle->filter())) {
322 m_resolvedFilter = 315 m_resolvedFilter =
323 SkiaImageFilterBuilder::build(lastEffect, ColorSpaceDeviceRGB); 316 SkiaImageFilterBuilder::build(lastEffect, ColorSpaceDeviceRGB);
324 if (m_resolvedFilter) { 317 if (m_resolvedFilter) {
325 updateFilterReferences(toHTMLCanvasElement(styleResolutionHost), 318 context->updateFilterReferences(filterStyle->filter());
326 context, filterStyle->filter());
327 if (lastEffect->originTainted()) 319 if (lastEffect->originTainted())
328 context->setOriginTainted(); 320 context->setOriginTainted();
329 } 321 }
330 } 322 }
331 } 323 }
332 324
333 return m_resolvedFilter; 325 return m_resolvedFilter;
334 } 326 }
335 327
336 bool CanvasRenderingContext2DState::hasFilter( 328 bool CanvasRenderingContext2DState::hasFilter(
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 paint->setLooper(0); 549 paint->setLooper(0);
558 paint->setImageFilter(shadowAndForegroundImageFilter()); 550 paint->setImageFilter(shadowAndForegroundImageFilter());
559 return paint; 551 return paint;
560 } 552 }
561 paint->setLooper(sk_ref_sp(shadowAndForegroundDrawLooper())); 553 paint->setLooper(sk_ref_sp(shadowAndForegroundDrawLooper()));
562 paint->setImageFilter(0); 554 paint->setImageFilter(0);
563 return paint; 555 return paint;
564 } 556 }
565 557
566 } // namespace blink 558 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2D.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698