| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 bool SVGPaintContext::applyMaskIfNecessary(SVGResources* resources) | 145 bool SVGPaintContext::applyMaskIfNecessary(SVGResources* resources) |
| 146 { | 146 { |
| 147 if (LayoutSVGResourceMasker* masker = resources ? resources->masker() : null
ptr) { | 147 if (LayoutSVGResourceMasker* masker = resources ? resources->masker() : null
ptr) { |
| 148 if (!SVGMaskPainter(*masker).prepareEffect(m_object, paintInfo().context
)) | 148 if (!SVGMaskPainter(*masker).prepareEffect(m_object, paintInfo().context
)) |
| 149 return false; | 149 return false; |
| 150 m_masker = masker; | 150 m_masker = masker; |
| 151 } | 151 } |
| 152 return true; | 152 return true; |
| 153 } | 153 } |
| 154 | 154 |
| 155 static bool hasReferenceFilterOnly(const ComputedStyle& style) |
| 156 { |
| 157 if (!style.hasFilter()) |
| 158 return false; |
| 159 const FilterOperations& operations = style.filter(); |
| 160 if (operations.size() != 1) |
| 161 return false; |
| 162 return operations.at(0)->type() == FilterOperation::REFERENCE; |
| 163 } |
| 164 |
| 155 bool SVGPaintContext::applyFilterIfNecessary(SVGResources* resources) | 165 bool SVGPaintContext::applyFilterIfNecessary(SVGResources* resources) |
| 156 { | 166 { |
| 157 if (!resources) { | 167 if (!resources) |
| 158 if (m_object.style()->hasFilter()) | 168 return !hasReferenceFilterOnly(m_object.styleRef()); |
| 159 return false; | |
| 160 } else if (LayoutSVGResourceFilter* filter = resources->filter()) { | |
| 161 m_filterRecordingContext = wrapUnique(new SVGFilterRecordingContext(pain
tInfo().context)); | |
| 162 m_filter = filter; | |
| 163 GraphicsContext* filterContext = SVGFilterPainter(*filter).prepareEffect
(m_object, *m_filterRecordingContext); | |
| 164 if (!filterContext) | |
| 165 return false; | |
| 166 | 169 |
| 167 // Because the filter needs to cache its contents we replace the context | 170 LayoutSVGResourceFilter* filter = resources->filter(); |
| 168 // during filtering with the filter's context. | 171 if (!filter) |
| 169 m_filterPaintInfo = wrapUnique(new PaintInfo(*filterContext, m_paintInfo
)); | 172 return true; |
| 173 m_filterRecordingContext = wrapUnique(new SVGFilterRecordingContext(paintInf
o().context)); |
| 174 m_filter = filter; |
| 175 GraphicsContext* filterContext = SVGFilterPainter(*filter).prepareEffect(m_o
bject, *m_filterRecordingContext); |
| 176 if (!filterContext) |
| 177 return false; |
| 170 | 178 |
| 171 // Because we cache the filter contents and do not invalidate on paint | 179 // Because the filter needs to cache its contents we replace the context |
| 172 // invalidation rect changes, we need to paint the entire filter region | 180 // during filtering with the filter's context. |
| 173 // so elements outside the initial paint (due to scrolling, etc) paint. | 181 m_filterPaintInfo = wrapUnique(new PaintInfo(*filterContext, m_paintInfo)); |
| 174 m_filterPaintInfo->m_cullRect.m_rect = LayoutRect::infiniteIntRect(); | 182 |
| 175 } | 183 // Because we cache the filter contents and do not invalidate on paint |
| 184 // invalidation rect changes, we need to paint the entire filter region |
| 185 // so elements outside the initial paint (due to scrolling, etc) paint. |
| 186 m_filterPaintInfo->m_cullRect.m_rect = LayoutRect::infiniteIntRect(); |
| 176 return true; | 187 return true; |
| 177 } | 188 } |
| 178 | 189 |
| 179 bool SVGPaintContext::isIsolationInstalled() const | 190 bool SVGPaintContext::isIsolationInstalled() const |
| 180 { | 191 { |
| 181 if (m_compositingRecorder) | 192 if (m_compositingRecorder) |
| 182 return true; | 193 return true; |
| 183 if (m_masker || m_filter) | 194 if (m_masker || m_filter) |
| 184 return true; | 195 return true; |
| 185 if (m_clipper && m_clipperState == SVGClipPainter::ClipperAppliedMask) | 196 if (m_clipper && m_clipperState == SVGClipPainter::ClipperAppliedMask) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 // though. | 241 // though. |
| 231 // Additionally, it's not really safe/guaranteed to be correct, as | 242 // Additionally, it's not really safe/guaranteed to be correct, as |
| 232 // something down the paint pipe may want to farther tweak the color | 243 // something down the paint pipe may want to farther tweak the color |
| 233 // filter, which could yield incorrect results. (Consider just using | 244 // filter, which could yield incorrect results. (Consider just using |
| 234 // saveLayer() w/ this color filter explicitly instead.) | 245 // saveLayer() w/ this color filter explicitly instead.) |
| 235 paint.setColorFilter(sk_ref_sp(paintInfo.context.colorFilter())); | 246 paint.setColorFilter(sk_ref_sp(paintInfo.context.colorFilter())); |
| 236 return true; | 247 return true; |
| 237 } | 248 } |
| 238 | 249 |
| 239 } // namespace blink | 250 } // namespace blink |
| OLD | NEW |