OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org> | 2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org> |
3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> | 3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> |
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
5 * Copyright (C) 2009 Google, Inc. All rights reserved. | 5 * Copyright (C) 2009 Google, Inc. All rights reserved. |
6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 #include "config.h" | 25 #include "config.h" |
26 #include "core/paint/SVGPaintContext.h" | 26 #include "core/paint/SVGPaintContext.h" |
27 | 27 |
28 #include "core/frame/FrameHost.h" | 28 #include "core/frame/FrameHost.h" |
29 #include "core/layout/svg/LayoutSVGResourceFilter.h" | 29 #include "core/layout/svg/LayoutSVGResourceFilter.h" |
30 #include "core/layout/svg/LayoutSVGResourceMasker.h" | 30 #include "core/layout/svg/LayoutSVGResourceMasker.h" |
31 #include "core/layout/svg/SVGLayoutSupport.h" | 31 #include "core/layout/svg/SVGLayoutSupport.h" |
32 #include "core/layout/svg/SVGResources.h" | 32 #include "core/layout/svg/SVGResources.h" |
33 #include "core/layout/svg/SVGResourcesCache.h" | 33 #include "core/layout/svg/SVGResourcesCache.h" |
34 #include "core/paint/SVGFilterPainter.h" | |
35 #include "core/paint/SVGMaskPainter.h" | 34 #include "core/paint/SVGMaskPainter.h" |
36 #include "platform/FloatConversion.h" | 35 #include "platform/FloatConversion.h" |
37 | 36 |
38 namespace blink { | 37 namespace blink { |
39 | 38 |
40 SVGPaintContext::~SVGPaintContext() | 39 SVGPaintContext::~SVGPaintContext() |
41 { | 40 { |
42 if (m_filter) { | 41 if (m_filter) { |
43 ASSERT(SVGResourcesCache::cachedResourcesForLayoutObject(m_object)); | 42 ASSERT(SVGResourcesCache::cachedResourcesForLayoutObject(m_object)); |
44 ASSERT(SVGResourcesCache::cachedResourcesForLayoutObject(m_object)->filt
er() == m_filter); | 43 ASSERT(SVGResourcesCache::cachedResourcesForLayoutObject(m_object)->filt
er() == m_filter); |
45 SVGFilterPainter(*m_filter).finishEffect(*m_object, m_originalPaintInfo-
>context); | 44 ASSERT(m_filterRecordingContext); |
| 45 SVGFilterPainter(*m_filter).finishEffect(*m_object, *m_filterRecordingCo
ntext); |
46 | 46 |
47 // Reset the paint info after the filter effect has been completed. | 47 // Reset the paint info after the filter effect has been completed. |
48 // This isn't strictly required (e.g., m_paintInfo.rect is not used | 48 // This isn't strictly required (e.g., m_paintInfo.rect is not used |
49 // after this). | 49 // after this). |
50 m_paintInfo.context = m_originalPaintInfo->context; | 50 m_paintInfo.context = m_originalPaintInfo->context; |
51 m_paintInfo.rect = m_originalPaintInfo->rect; | 51 m_paintInfo.rect = m_originalPaintInfo->rect; |
52 } | 52 } |
53 | 53 |
54 if (m_masker) { | 54 if (m_masker) { |
55 ASSERT(SVGResourcesCache::cachedResourcesForLayoutObject(m_object)); | 55 ASSERT(SVGResourcesCache::cachedResourcesForLayoutObject(m_object)); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 147 } |
148 return true; | 148 return true; |
149 } | 149 } |
150 | 150 |
151 bool SVGPaintContext::applyFilterIfNecessary(SVGResources* resources) | 151 bool SVGPaintContext::applyFilterIfNecessary(SVGResources* resources) |
152 { | 152 { |
153 if (!resources) { | 153 if (!resources) { |
154 if (m_object->style()->svgStyle().hasFilter()) | 154 if (m_object->style()->svgStyle().hasFilter()) |
155 return false; | 155 return false; |
156 } else if (LayoutSVGResourceFilter* filter = resources->filter()) { | 156 } else if (LayoutSVGResourceFilter* filter = resources->filter()) { |
| 157 m_filterRecordingContext = adoptPtr(new SVGFilterRecordingContext(m_pain
tInfo.context)); |
157 m_filter = filter; | 158 m_filter = filter; |
158 GraphicsContext* filterContext = SVGFilterPainter(*filter).prepareEffect
(*m_object, m_paintInfo.context); | 159 GraphicsContext* filterContext = SVGFilterPainter(*filter).prepareEffect
(*m_object, *m_filterRecordingContext); |
159 if (!filterContext) | 160 if (!filterContext) |
160 return false; | 161 return false; |
161 | 162 |
162 // Because the filter needs to cache its contents we replace the context | 163 // Because the filter needs to cache its contents we replace the context |
163 // during filtering with the filter's context. | 164 // during filtering with the filter's context. |
164 m_paintInfo.context = filterContext; | 165 m_paintInfo.context = filterContext; |
165 | 166 |
166 // Because we cache the filter contents and do not invalidate on paint | 167 // Because we cache the filter contents and do not invalidate on paint |
167 // invalidation rect changes, we need to paint the entire filter region | 168 // invalidation rect changes, we need to paint the entire filter region |
168 // so elements outside the initial paint (due to scrolling, etc) paint. | 169 // so elements outside the initial paint (due to scrolling, etc) paint. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 // though. | 224 // though. |
224 // Additionally, it's not really safe/guaranteed to be correct, as | 225 // Additionally, it's not really safe/guaranteed to be correct, as |
225 // something down the paint pipe may want to farther tweak the color | 226 // something down the paint pipe may want to farther tweak the color |
226 // filter, which could yield incorrect results. (Consider just using | 227 // filter, which could yield incorrect results. (Consider just using |
227 // saveLayer() w/ this color filter explicitly instead.) | 228 // saveLayer() w/ this color filter explicitly instead.) |
228 paint.setColorFilter(paintInfo.context->colorFilter()); | 229 paint.setColorFilter(paintInfo.context->colorFilter()); |
229 return true; | 230 return true; |
230 } | 231 } |
231 | 232 |
232 } // namespace blink | 233 } // namespace blink |
OLD | NEW |