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

Side by Side Diff: third_party/WebKit/Source/core/layout/svg/LayoutSVGResourceFilter.cpp

Issue 2846593008: Proactively dispose image filters for SVG filter chains (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/svg/graphics/filters/SVGFilterBuilder.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
4 * Copyright (C) 2005 Eric Seidel <eric@webkit.org> 4 * Copyright (C) 2005 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> 5 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 18 matching lines...) Expand all
29 29
30 namespace blink { 30 namespace blink {
31 31
32 DEFINE_TRACE(FilterData) { 32 DEFINE_TRACE(FilterData) {
33 visitor->Trace(last_effect); 33 visitor->Trace(last_effect);
34 visitor->Trace(node_map); 34 visitor->Trace(node_map);
35 } 35 }
36 36
37 void FilterData::Dispose() { 37 void FilterData::Dispose() {
38 node_map = nullptr; 38 node_map = nullptr;
39 if (last_effect)
40 last_effect->DisposeImageFiltersRecursive();
39 last_effect = nullptr; 41 last_effect = nullptr;
40 } 42 }
41 43
42 LayoutSVGResourceFilter::LayoutSVGResourceFilter(SVGFilterElement* node) 44 LayoutSVGResourceFilter::LayoutSVGResourceFilter(SVGFilterElement* node)
43 : LayoutSVGResourceContainer(node) {} 45 : LayoutSVGResourceContainer(node) {}
44 46
45 LayoutSVGResourceFilter::~LayoutSVGResourceFilter() {} 47 LayoutSVGResourceFilter::~LayoutSVGResourceFilter() {}
46 48
47 void LayoutSVGResourceFilter::DisposeFilterMap() { 49 void LayoutSVGResourceFilter::DisposeFilterMap() {
48 for (auto& filter : filter_) 50 for (auto& entry : filter_)
49 filter.value->Dispose(); 51 entry.value->Dispose();
50 filter_.clear(); 52 filter_.clear();
51 } 53 }
52 54
53 void LayoutSVGResourceFilter::WillBeDestroyed() { 55 void LayoutSVGResourceFilter::WillBeDestroyed() {
54 DisposeFilterMap(); 56 DisposeFilterMap();
55 LayoutSVGResourceContainer::WillBeDestroyed(); 57 LayoutSVGResourceContainer::WillBeDestroyed();
56 } 58 }
57 59
58 bool LayoutSVGResourceFilter::IsChildAllowed(LayoutObject* child, 60 bool LayoutSVGResourceFilter::IsChildAllowed(LayoutObject* child,
59 const ComputedStyle&) const { 61 const ComputedStyle&) const {
60 return child->IsSVGResourceFilterPrimitive(); 62 return child->IsSVGResourceFilterPrimitive();
61 } 63 }
62 64
63 void LayoutSVGResourceFilter::RemoveAllClientsFromCache( 65 void LayoutSVGResourceFilter::RemoveAllClientsFromCache(
64 bool mark_for_invalidation) { 66 bool mark_for_invalidation) {
65 // LayoutSVGResourceFilter::removeClientFromCache will be called for 67 // LayoutSVGResourceFilter::removeClientFromCache will be called for
66 // all clients through markAllClientsForInvalidation so no explicit 68 // all clients through markAllClientsForInvalidation so no explicit
67 // display item invalidation is needed here. 69 // display item invalidation is needed here.
68 DisposeFilterMap(); 70 DisposeFilterMap();
69 MarkAllClientsForInvalidation(mark_for_invalidation 71 MarkAllClientsForInvalidation(mark_for_invalidation
70 ? kLayoutAndBoundariesInvalidation 72 ? kLayoutAndBoundariesInvalidation
71 : kParentOnlyInvalidation); 73 : kParentOnlyInvalidation);
72 } 74 }
73 75
74 void LayoutSVGResourceFilter::RemoveClientFromCache( 76 void LayoutSVGResourceFilter::RemoveClientFromCache(
75 LayoutObject* client, 77 LayoutObject* client,
76 bool mark_for_invalidation) { 78 bool mark_for_invalidation) {
77 DCHECK(client); 79 DCHECK(client);
78 80
79 bool filter_cached = filter_.Contains(client); 81 auto entry = filter_.find(client);
80 if (filter_cached) 82 bool filter_cached = entry != filter_.end();
81 filter_.erase(client); 83 if (filter_cached) {
84 entry->value->Dispose();
85 filter_.erase(entry);
86 }
82 87
83 // If the filter has a cached subtree, invalidate the associated display item. 88 // If the filter has a cached subtree, invalidate the associated display item.
84 if (mark_for_invalidation && filter_cached) 89 if (mark_for_invalidation && filter_cached)
85 MarkClientForInvalidation(client, kPaintInvalidation); 90 MarkClientForInvalidation(client, kPaintInvalidation);
86 91
87 MarkClientForInvalidation(client, mark_for_invalidation 92 MarkClientForInvalidation(client, mark_for_invalidation
88 ? kBoundariesInvalidation 93 ? kBoundariesInvalidation
89 : kParentOnlyInvalidation); 94 : kParentOnlyInvalidation);
90 } 95 }
91 96
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 return; 139 return;
135 node_map->InvalidateDependentEffects(effect); 140 node_map->InvalidateDependentEffects(effect);
136 141
137 // Issue paint invalidations for the image on the screen. 142 // Issue paint invalidations for the image on the screen.
138 MarkClientForInvalidation(filter.key, kPaintInvalidation); 143 MarkClientForInvalidation(filter.key, kPaintInvalidation);
139 } 144 }
140 NotifyContentChanged(); 145 NotifyContentChanged();
141 } 146 }
142 147
143 } // namespace blink 148 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/svg/graphics/filters/SVGFilterBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698