| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. | 2 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. |
| 3 * Copyright (C) 2013 Apple Inc. All rights reserved. | 3 * Copyright (C) 2013 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
| 14 * | 14 * |
| 15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
| 16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
| 19 */ | 19 */ |
| 20 | 20 |
| 21 #include "config.h" | 21 #include "config.h" |
| 22 #include "core/svg/graphics/SVGImageCache.h" | 22 #include "core/platform/graphics/ImageCache.h" |
| 23 | 23 |
| 24 #include "core/fetch/ImageResource.h" | 24 #include "core/fetch/ImageResource.h" |
| 25 #include "core/page/FrameView.h" | 25 #include "core/page/FrameView.h" |
| 26 #include "core/page/Page.h" | 26 #include "core/page/Page.h" |
| 27 #include "core/platform/graphics/GraphicsContext.h" | 27 #include "core/platform/graphics/GraphicsContext.h" |
| 28 #include "core/platform/graphics/Image.h" |
| 28 #include "core/platform/graphics/ImageBuffer.h" | 29 #include "core/platform/graphics/ImageBuffer.h" |
| 30 #include "core/platform/graphics/ImageForContainer.h" |
| 29 #include "core/rendering/svg/RenderSVGRoot.h" | 31 #include "core/rendering/svg/RenderSVGRoot.h" |
| 30 #include "core/svg/graphics/SVGImage.h" | |
| 31 #include "core/svg/graphics/SVGImageForContainer.h" | |
| 32 | 32 |
| 33 namespace WebCore { | 33 namespace WebCore { |
| 34 | 34 |
| 35 SVGImageCache::SVGImageCache(SVGImage* svgImage) | 35 ImageCache::ImageCache(Image* image) |
| 36 : m_svgImage(svgImage) | 36 : m_image(image) |
| 37 { | 37 { |
| 38 ASSERT(m_svgImage); | 38 ASSERT(m_image); |
| 39 } | 39 } |
| 40 | 40 |
| 41 SVGImageCache::~SVGImageCache() | 41 ImageCache::~ImageCache() |
| 42 { | 42 { |
| 43 m_imageForContainerMap.clear(); | 43 m_imageForContainerMap.clear(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void SVGImageCache::removeClientFromCache(const ImageResourceClient* client) | 46 void ImageCache::removeClientFromCache(const ImageResourceClient* client) |
| 47 { | 47 { |
| 48 ASSERT(client); | 48 ASSERT(client); |
| 49 | 49 |
| 50 if (m_imageForContainerMap.contains(client)) | 50 if (m_imageForContainerMap.contains(client)) |
| 51 m_imageForContainerMap.remove(client); | 51 m_imageForContainerMap.remove(client); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void SVGImageCache::setContainerSizeForRenderer(const ImageResourceClient* clien
t, const IntSize& containerSize, float containerZoom) | 54 void ImageCache::setContainerSizeForRenderer(const ImageResourceClient* client,
const IntSize& containerSize, float containerZoom) |
| 55 { | 55 { |
| 56 ASSERT(client); | 56 ASSERT(client); |
| 57 ASSERT(!containerSize.isEmpty()); | 57 ASSERT(!containerSize.isEmpty()); |
| 58 ASSERT(containerZoom); | 58 ASSERT(containerZoom); |
| 59 | 59 |
| 60 FloatSize containerSizeWithoutZoom(containerSize); | 60 FloatSize containerSizeWithoutZoom(containerSize); |
| 61 containerSizeWithoutZoom.scale(1 / containerZoom); | 61 containerSizeWithoutZoom.scale(1 / containerZoom); |
| 62 | 62 |
| 63 m_imageForContainerMap.set(client, SVGImageForContainer::create(m_svgImage,
containerSizeWithoutZoom, containerZoom)); | 63 m_imageForContainerMap.set(client, ImageForContainer::create(m_image, contai
nerSizeWithoutZoom, containerZoom)); |
| 64 } | 64 } |
| 65 | 65 |
| 66 IntSize SVGImageCache::imageSizeForRenderer(const RenderObject* renderer) const | 66 IntSize ImageCache::imageSizeForRenderer(const RenderObject* renderer) const |
| 67 { | 67 { |
| 68 IntSize imageSize = m_svgImage->size(); | 68 IntSize imageSize = m_image->size(); |
| 69 if (!renderer) | 69 if (!renderer) |
| 70 return imageSize; | 70 return imageSize; |
| 71 | 71 |
| 72 ImageForContainerMap::const_iterator it = m_imageForContainerMap.find(render
er); | 72 ImageForContainerMap::const_iterator it = m_imageForContainerMap.find(render
er); |
| 73 if (it == m_imageForContainerMap.end()) | 73 if (it == m_imageForContainerMap.end()) |
| 74 return imageSize; | 74 return imageSize; |
| 75 | 75 |
| 76 RefPtr<SVGImageForContainer> imageForContainer = it->value; | 76 RefPtr<ImageForContainer> imageForContainer = it->value; |
| 77 ASSERT(!imageForContainer->size().isEmpty()); | 77 ASSERT(!imageForContainer->size().isEmpty()); |
| 78 return imageForContainer->size(); | 78 return imageForContainer->size(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 // FIXME: This doesn't take into account the animation timeline so animations wi
ll not | 81 // FIXME: This doesn't take into account the animation timeline so animations wi
ll not |
| 82 // restart on page load, nor will two animations in different pages have differe
nt timelines. | 82 // restart on page load, nor will two animations in different pages have differe
nt timelines. |
| 83 Image* SVGImageCache::imageForRenderer(const RenderObject* renderer) | 83 Image* ImageCache::imageForRenderer(const RenderObject* renderer) |
| 84 { | 84 { |
| 85 if (!renderer) | 85 if (!renderer) |
| 86 return Image::nullImage(); | 86 return Image::nullImage(); |
| 87 | 87 |
| 88 ImageForContainerMap::iterator it = m_imageForContainerMap.find(renderer); | 88 ImageForContainerMap::iterator it = m_imageForContainerMap.find(renderer); |
| 89 if (it == m_imageForContainerMap.end()) | 89 if (it == m_imageForContainerMap.end()) |
| 90 return Image::nullImage(); | 90 return Image::nullImage(); |
| 91 | 91 |
| 92 RefPtr<SVGImageForContainer> imageForContainer = it->value; | 92 RefPtr<ImageForContainer> imageForContainer = it->value; |
| 93 ASSERT(!imageForContainer->size().isEmpty()); | 93 ASSERT(!imageForContainer->size().isEmpty()); |
| 94 return imageForContainer.get(); | 94 return imageForContainer.get(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 } // namespace WebCore | 97 } // namespace WebCore |
| 98 |
| OLD | NEW |