OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> | 2 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> |
3 * Copyright (C) 2006 Apple Computer, Inc. | 3 * Copyright (C) 2006 Apple Computer, Inc. |
4 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> | 4 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> |
5 * Copyright (C) 2007, 2008, 2009 Rob Buis <buis@kde.org> | 5 * Copyright (C) 2007, 2008, 2009 Rob Buis <buis@kde.org> |
6 * Copyright (C) 2009 Google, Inc. | 6 * Copyright (C) 2009 Google, Inc. |
7 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 7 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
8 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> | 8 * Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com> |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 RenderSVGModelObject::setNeedsBoundariesUpdate(); | 117 RenderSVGModelObject::setNeedsBoundariesUpdate(); |
118 | 118 |
119 repainter.repaintAfterLayout(); | 119 repainter.repaintAfterLayout(); |
120 clearNeedsLayout(); | 120 clearNeedsLayout(); |
121 } | 121 } |
122 | 122 |
123 void RenderSVGImage::paint(PaintInfo& paintInfo, const LayoutPoint&) | 123 void RenderSVGImage::paint(PaintInfo& paintInfo, const LayoutPoint&) |
124 { | 124 { |
125 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); | 125 ANNOTATE_GRAPHICS_CONTEXT(paintInfo, this); |
126 | 126 |
127 if (paintInfo.context->paintingDisabled() || style()->visibility() == HIDDEN
|| !m_imageResource->hasImage()) | 127 if (paintInfo.context->paintingDisabled() |
| 128 || paintInfo.phase != PaintPhaseForeground |
| 129 || style()->visibility() == HIDDEN |
| 130 || !m_imageResource->hasImage()) |
128 return; | 131 return; |
129 | 132 |
130 FloatRect boundingBox = repaintRectInLocalCoordinates(); | 133 FloatRect boundingBox = repaintRectInLocalCoordinates(); |
131 if (!SVGRenderSupport::paintInfoIntersectsRepaintRect(boundingBox, m_localTr
ansform, paintInfo)) | 134 if (!SVGRenderSupport::paintInfoIntersectsRepaintRect(boundingBox, m_localTr
ansform, paintInfo)) |
132 return; | 135 return; |
133 | 136 |
134 PaintInfo childPaintInfo(paintInfo); | 137 PaintInfo childPaintInfo(paintInfo); |
135 bool drawsOutline = style()->outlineWidth() && (childPaintInfo.phase == Pain
tPhaseOutline || childPaintInfo.phase == PaintPhaseSelfOutline); | 138 GraphicsContextStateSaver stateSaver(*childPaintInfo.context, false); |
136 if (drawsOutline || childPaintInfo.phase == PaintPhaseForeground) { | 139 |
137 GraphicsContextStateSaver stateSaver(*childPaintInfo.context, false); | 140 if (!m_localTransform.isIdentity()) { |
138 if (!m_localTransform.isIdentity()) { | 141 stateSaver.save(); |
139 stateSaver.save(); | 142 childPaintInfo.applyTransform(m_localTransform, false); |
140 childPaintInfo.applyTransform(m_localTransform, false); | 143 } |
| 144 if (!m_objectBoundingBox.isEmpty()) { |
| 145 // SVGRenderingContext may taint the state - make sure we're always savi
ng. |
| 146 SVGRenderingContext renderingContext(this, childPaintInfo, stateSaver.sa
ved() ? |
| 147 SVGRenderingContext::DontSaveGraphicsContext : SVGRenderingContext::
SaveGraphicsContext); |
| 148 |
| 149 if (renderingContext.isRenderingPrepared()) { |
| 150 if (style()->svgStyle()->bufferedRendering() == BR_STATIC && renderi
ngContext.bufferForeground(m_bufferedForeground)) |
| 151 return; |
| 152 |
| 153 paintForeground(childPaintInfo); |
141 } | 154 } |
142 if (childPaintInfo.phase == PaintPhaseForeground && !m_objectBoundingBox
.isEmpty()) { | 155 } |
143 // SVGRenderingContext may taint the state - make sure we're always
saving. | |
144 SVGRenderingContext renderingContext(this, childPaintInfo, stateSave
r.saved() ? | |
145 SVGRenderingContext::DontSaveGraphicsContext : SVGRenderingConte
xt::SaveGraphicsContext); | |
146 | 156 |
147 if (renderingContext.isRenderingPrepared()) { | 157 if (style()->outlineWidth()) |
148 if (style()->svgStyle()->bufferedRendering() == BR_STATIC && ren
deringContext.bufferForeground(m_bufferedForeground)) | 158 paintOutline(childPaintInfo, IntRect(boundingBox)); |
149 return; | |
150 | |
151 paintForeground(childPaintInfo); | |
152 } | |
153 } | |
154 | |
155 if (drawsOutline) | |
156 paintOutline(childPaintInfo, IntRect(boundingBox)); | |
157 } | |
158 } | 159 } |
159 | 160 |
160 void RenderSVGImage::paintForeground(PaintInfo& paintInfo) | 161 void RenderSVGImage::paintForeground(PaintInfo& paintInfo) |
161 { | 162 { |
162 RefPtr<Image> image = m_imageResource->image(); | 163 RefPtr<Image> image = m_imageResource->image(); |
163 FloatRect destRect = m_objectBoundingBox; | 164 FloatRect destRect = m_objectBoundingBox; |
164 FloatRect srcRect(0, 0, image->width(), image->height()); | 165 FloatRect srcRect(0, 0, image->width(), image->height()); |
165 | 166 |
166 SVGImageElement* imageElement = toSVGImageElement(element()); | 167 SVGImageElement* imageElement = toSVGImageElement(element()); |
167 imageElement->preserveAspectRatio()->currentValue()->transformRect(destRect,
srcRect); | 168 imageElement->preserveAspectRatio()->currentValue()->transformRect(destRect,
srcRect); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 229 |
229 void RenderSVGImage::addFocusRingRects(Vector<IntRect>& rects, const LayoutPoint
&, const RenderLayerModelObject*) | 230 void RenderSVGImage::addFocusRingRects(Vector<IntRect>& rects, const LayoutPoint
&, const RenderLayerModelObject*) |
230 { | 231 { |
231 // this is called from paint() after the localTransform has already been app
lied | 232 // this is called from paint() after the localTransform has already been app
lied |
232 IntRect contentRect = enclosingIntRect(repaintRectInLocalCoordinates()); | 233 IntRect contentRect = enclosingIntRect(repaintRectInLocalCoordinates()); |
233 if (!contentRect.isEmpty()) | 234 if (!contentRect.isEmpty()) |
234 rects.append(contentRect); | 235 rects.append(contentRect); |
235 } | 236 } |
236 | 237 |
237 } // namespace WebCore | 238 } // namespace WebCore |
OLD | NEW |