| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 bool SVGPaintContext::applyMaskIfNecessary(SVGResources* resources) | 127 bool SVGPaintContext::applyMaskIfNecessary(SVGResources* resources) |
| 128 { | 128 { |
| 129 if (LayoutSVGResourceMasker* masker = resources ? resources->masker() : null
ptr) { | 129 if (LayoutSVGResourceMasker* masker = resources ? resources->masker() : null
ptr) { |
| 130 if (!SVGMaskPainter(*masker).prepareEffect(m_object, paintInfo().context
)) | 130 if (!SVGMaskPainter(*masker).prepareEffect(m_object, paintInfo().context
)) |
| 131 return false; | 131 return false; |
| 132 m_masker = masker; | 132 m_masker = masker; |
| 133 } | 133 } |
| 134 return true; | 134 return true; |
| 135 } | 135 } |
| 136 | 136 |
| 137 static bool hasReferenceFilterOnly(const ComputedStyle& style) |
| 138 { |
| 139 if (!style.hasFilter()) |
| 140 return false; |
| 141 const FilterOperations& operations = style.filter(); |
| 142 if (operations.size() != 1) |
| 143 return false; |
| 144 return operations.at(0)->type() == FilterOperation::REFERENCE; |
| 145 } |
| 146 |
| 137 bool SVGPaintContext::applyFilterIfNecessary(SVGResources* resources) | 147 bool SVGPaintContext::applyFilterIfNecessary(SVGResources* resources) |
| 138 { | 148 { |
| 139 if (!resources) { | 149 if (!resources) |
| 140 if (m_object.style()->hasFilter()) | 150 return !hasReferenceFilterOnly(m_object.styleRef()); |
| 141 return false; | |
| 142 } else if (LayoutSVGResourceFilter* filter = resources->filter()) { | |
| 143 m_filterRecordingContext = wrapUnique(new SVGFilterRecordingContext(pain
tInfo().context)); | |
| 144 m_filter = filter; | |
| 145 GraphicsContext* filterContext = SVGFilterPainter(*filter).prepareEffect
(m_object, *m_filterRecordingContext); | |
| 146 if (!filterContext) | |
| 147 return false; | |
| 148 | 151 |
| 149 // Because the filter needs to cache its contents we replace the context | 152 LayoutSVGResourceFilter* filter = resources->filter(); |
| 150 // during filtering with the filter's context. | 153 if (!filter) |
| 151 m_filterPaintInfo = wrapUnique(new PaintInfo(*filterContext, m_paintInfo
)); | 154 return true; |
| 155 m_filterRecordingContext = wrapUnique(new SVGFilterRecordingContext(paintInf
o().context)); |
| 156 m_filter = filter; |
| 157 GraphicsContext* filterContext = SVGFilterPainter(*filter).prepareEffect(m_o
bject, *m_filterRecordingContext); |
| 158 if (!filterContext) |
| 159 return false; |
| 152 | 160 |
| 153 // Because we cache the filter contents and do not invalidate on paint | 161 // Because the filter needs to cache its contents we replace the context |
| 154 // invalidation rect changes, we need to paint the entire filter region | 162 // during filtering with the filter's context. |
| 155 // so elements outside the initial paint (due to scrolling, etc) paint. | 163 m_filterPaintInfo = wrapUnique(new PaintInfo(*filterContext, m_paintInfo)); |
| 156 m_filterPaintInfo->m_cullRect.m_rect = LayoutRect::infiniteIntRect(); | 164 |
| 157 } | 165 // Because we cache the filter contents and do not invalidate on paint |
| 166 // invalidation rect changes, we need to paint the entire filter region |
| 167 // so elements outside the initial paint (due to scrolling, etc) paint. |
| 168 m_filterPaintInfo->m_cullRect.m_rect = LayoutRect::infiniteIntRect(); |
| 158 return true; | 169 return true; |
| 159 } | 170 } |
| 160 | 171 |
| 161 bool SVGPaintContext::isIsolationInstalled() const | 172 bool SVGPaintContext::isIsolationInstalled() const |
| 162 { | 173 { |
| 163 if (m_compositingRecorder) | 174 if (m_compositingRecorder) |
| 164 return true; | 175 return true; |
| 165 if (m_masker || m_filter) | 176 if (m_masker || m_filter) |
| 166 return true; | 177 return true; |
| 167 if (m_clipPathClipper && m_clipPathClipper->usingMask()) | 178 if (m_clipPathClipper && m_clipPathClipper->usingMask()) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // though. | 223 // though. |
| 213 // Additionally, it's not really safe/guaranteed to be correct, as | 224 // Additionally, it's not really safe/guaranteed to be correct, as |
| 214 // something down the paint pipe may want to farther tweak the color | 225 // something down the paint pipe may want to farther tweak the color |
| 215 // filter, which could yield incorrect results. (Consider just using | 226 // filter, which could yield incorrect results. (Consider just using |
| 216 // saveLayer() w/ this color filter explicitly instead.) | 227 // saveLayer() w/ this color filter explicitly instead.) |
| 217 paint.setColorFilter(sk_ref_sp(paintInfo.context.getColorFilter())); | 228 paint.setColorFilter(sk_ref_sp(paintInfo.context.getColorFilter())); |
| 218 return true; | 229 return true; |
| 219 } | 230 } |
| 220 | 231 |
| 221 } // namespace blink | 232 } // namespace blink |
| OLD | NEW |