OLD | NEW |
1 /* | 1 /* |
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
6 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 6 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. 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 139 matching lines...) Loading... |
150 | 150 |
151 DEFINE_STATIC_LOCAL(Image*, brokenImageLoRes, (Image::loadPlatformResource("
missingImage").leakRef())); | 151 DEFINE_STATIC_LOCAL(Image*, brokenImageLoRes, (Image::loadPlatformResource("
missingImage").leakRef())); |
152 return std::make_pair(brokenImageLoRes, 1); | 152 return std::make_pair(brokenImageLoRes, 1); |
153 } | 153 } |
154 | 154 |
155 bool CachedImage::willPaintBrokenImage() const | 155 bool CachedImage::willPaintBrokenImage() const |
156 { | 156 { |
157 return errorOccurred() && m_shouldPaintBrokenImage; | 157 return errorOccurred() && m_shouldPaintBrokenImage; |
158 } | 158 } |
159 | 159 |
160 #if ENABLE(SVG) | |
161 inline Image* CachedImage::lookupOrCreateImageForRenderer(const RenderObject* re
nderer) | |
162 { | |
163 if (!m_image) | |
164 return 0; | |
165 if (!m_image->isSVGImage()) | |
166 return m_image.get(); | |
167 Image* useImage = m_svgImageCache->imageForRenderer(renderer); | |
168 if (useImage == Image::nullImage()) | |
169 return m_image.get(); | |
170 return useImage; | |
171 } | |
172 #else | |
173 inline Image* CachedImage::lookupOrCreateImageForRenderer(const RenderObject*) | |
174 { | |
175 return m_image.get(); | |
176 } | |
177 #endif | |
178 | |
179 Image* CachedImage::image() | 160 Image* CachedImage::image() |
180 { | 161 { |
181 ASSERT(!isPurgeable()); | 162 ASSERT(!isPurgeable()); |
182 | 163 |
183 if (errorOccurred() && m_shouldPaintBrokenImage) { | 164 if (errorOccurred() && m_shouldPaintBrokenImage) { |
184 // Returning the 1x broken image is non-ideal, but we cannot reliably ac
cess the appropriate | 165 // Returning the 1x broken image is non-ideal, but we cannot reliably ac
cess the appropriate |
185 // deviceScaleFactor from here. It is critical that callers use CachedIm
age::brokenImage() | 166 // deviceScaleFactor from here. It is critical that callers use CachedIm
age::brokenImage() |
186 // when they need the real, deviceScaleFactor-appropriate broken image i
con. | 167 // when they need the real, deviceScaleFactor-appropriate broken image i
con. |
187 return brokenImage(1).first; | 168 return brokenImage(1).first; |
188 } | 169 } |
189 | 170 |
190 if (m_image) | 171 if (m_image) |
191 return m_image.get(); | 172 return m_image.get(); |
192 | 173 |
193 return Image::nullImage(); | 174 return Image::nullImage(); |
194 } | 175 } |
195 | 176 |
196 Image* CachedImage::imageForRenderer(const RenderObject* renderer) | 177 Image* CachedImage::imageForRenderer(const RenderObject* renderer) |
197 { | 178 { |
198 ASSERT(!isPurgeable()); | 179 ASSERT(!isPurgeable()); |
199 | 180 |
200 if (errorOccurred() && m_shouldPaintBrokenImage) { | 181 if (errorOccurred() && m_shouldPaintBrokenImage) { |
201 // Returning the 1x broken image is non-ideal, but we cannot reliably ac
cess the appropriate | 182 // Returning the 1x broken image is non-ideal, but we cannot reliably ac
cess the appropriate |
202 // deviceScaleFactor from here. It is critical that callers use CachedIm
age::brokenImage() | 183 // deviceScaleFactor from here. It is critical that callers use CachedIm
age::brokenImage() |
203 // when they need the real, deviceScaleFactor-appropriate broken image i
con. | 184 // when they need the real, deviceScaleFactor-appropriate broken image i
con. |
204 return brokenImage(1).first; | 185 return brokenImage(1).first; |
205 } | 186 } |
206 | 187 |
207 if (m_image) | 188 if (!m_image) |
208 return lookupOrCreateImageForRenderer(renderer); | 189 return Image::nullImage(); |
209 | 190 |
210 return Image::nullImage(); | 191 #if ENABLE(SVG) |
| 192 if (m_image->isSVGImage()) { |
| 193 Image* image = m_svgImageCache->imageForRenderer(renderer); |
| 194 if (image != Image::nullImage()) |
| 195 return image; |
| 196 } |
| 197 #else |
| 198 UNUSED_PARAM(renderer); |
| 199 #endif |
| 200 return m_image.get(); |
211 } | 201 } |
212 | 202 |
213 void CachedImage::setContainerSizeForRenderer(const CachedImageClient* renderer,
const IntSize& containerSize, float containerZoom) | 203 void CachedImage::setContainerSizeForRenderer(const CachedImageClient* renderer,
const IntSize& containerSize, float containerZoom) |
214 { | 204 { |
215 if (containerSize.isEmpty()) | 205 if (containerSize.isEmpty()) |
216 return; | 206 return; |
217 ASSERT(renderer); | 207 ASSERT(renderer); |
218 ASSERT(containerZoom); | 208 ASSERT(containerZoom); |
219 if (!m_image) { | 209 if (!m_image) { |
220 m_pendingContainerSizeRequests.set(renderer, SizeAndZoom(containerSize,
containerZoom)); | 210 m_pendingContainerSizeRequests.set(renderer, SizeAndZoom(containerSize,
containerZoom)); |
(...skipping 278 matching lines...) Loading... |
499 | 489 |
500 bool CachedImage::currentFrameKnownToBeOpaque(const RenderObject* renderer) | 490 bool CachedImage::currentFrameKnownToBeOpaque(const RenderObject* renderer) |
501 { | 491 { |
502 Image* image = imageForRenderer(renderer); | 492 Image* image = imageForRenderer(renderer); |
503 if (image->isBitmapImage()) | 493 if (image->isBitmapImage()) |
504 image->nativeImageForCurrentFrame(); // force decode | 494 image->nativeImageForCurrentFrame(); // force decode |
505 return image->currentFrameKnownToBeOpaque(); | 495 return image->currentFrameKnownToBeOpaque(); |
506 } | 496 } |
507 | 497 |
508 } // namespace WebCore | 498 } // namespace WebCore |
OLD | NEW |