Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Side by Side Diff: Source/WebCore/svg/graphics/SVGImageCache.h

Issue 12319101: Merge 142765 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1410/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/WebCore/svg/graphics/SVGImage.cpp ('k') | Source/WebCore/svg/graphics/SVGImageCache.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA. 17 * Boston, MA 02110-1301, USA.
18 */ 18 */
19 19
20 #ifndef SVGImageCache_h 20 #ifndef SVGImageCache_h
21 #define SVGImageCache_h 21 #define SVGImageCache_h
22 22
23 #if ENABLE(SVG) 23 #if ENABLE(SVG)
24 #include "FloatSize.h" 24 #include "FloatSize.h"
25 #include "Image.h" 25 #include "Image.h"
26 #include "IntSize.h" 26 #include "IntSize.h"
27 #include "Timer.h"
28 #include <wtf/HashMap.h> 27 #include <wtf/HashMap.h>
29 #include <wtf/PassOwnPtr.h> 28 #include <wtf/PassOwnPtr.h>
30 #include <wtf/RefPtr.h> 29 #include <wtf/RefPtr.h>
31 30
32 namespace WebCore { 31 namespace WebCore {
33 32
34 class CachedImage; 33 class CachedImage;
35 class CachedImageClient; 34 class CachedImageClient;
36 class ImageBuffer; 35 class ImageBuffer;
37 class SVGImage; 36 class SVGImage;
37 class SVGImageForContainer;
38 class RenderObject; 38 class RenderObject;
39 39
40 class SVGImageCache { 40 class SVGImageCache {
41 WTF_MAKE_FAST_ALLOCATED; 41 WTF_MAKE_FAST_ALLOCATED;
42 public: 42 public:
43 ~SVGImageCache(); 43 ~SVGImageCache();
44 44
45 static PassOwnPtr<SVGImageCache> create(SVGImage* image) 45 static PassOwnPtr<SVGImageCache> create(SVGImage* image)
46 { 46 {
47 return adoptPtr(new SVGImageCache(image)); 47 return adoptPtr(new SVGImageCache(image));
48 } 48 }
49 49
50 struct SizeAndScales {
51 SizeAndScales()
52 : zoom(1)
53 , scale(0)
54 {
55 }
56
57 SizeAndScales(const FloatSize& newSize, float newZoom, float newScale)
58 : size(newSize)
59 , zoom(newZoom)
60 , scale(newScale)
61 {
62 }
63
64 SizeAndScales(const FloatSize& newSize, float newZoom)
65 : size(newSize)
66 , zoom(newZoom)
67 , scale(0)
68 {
69 }
70
71 FloatSize size; // This is the container size without zoom.
72 float zoom;
73 float scale; // A scale of 0 indicates that the default scale should be used.
74 };
75
76 void removeClientFromCache(const CachedImageClient*); 50 void removeClientFromCache(const CachedImageClient*);
77 51
78 void setContainerSizeForRenderer(const CachedImageClient*, const IntSize&, f loat); 52 void setContainerSizeForRenderer(const CachedImageClient*, const IntSize&, f loat);
79 IntSize imageSizeForRenderer(const RenderObject*) const; 53 IntSize imageSizeForRenderer(const RenderObject*) const;
80 54
81 Image* lookupOrCreateBitmapImageForRenderer(const RenderObject*); 55 Image* imageForRenderer(const RenderObject*);
82 void imageContentChanged();
83 56
84 private: 57 private:
85 SVGImageCache(SVGImage*); 58 SVGImageCache(SVGImage*);
86 void redraw();
87 void redrawTimerFired(Timer<SVGImageCache>*);
88 void cacheClearTimerFired(DeferrableOneShotTimer<SVGImageCache>*);
89 void clearBitmapCache();
90 59
91 struct ImageData { 60 typedef HashMap<const CachedImageClient*, RefPtr<SVGImageForContainer> > Ima geForContainerMap;
92 ImageData()
93 : imageNeedsUpdate(false)
94 , buffer(0)
95 {
96 }
97
98 ImageData(ImageBuffer* newBuffer, PassRefPtr<Image> newImage, const Size AndScales& newSizeAndScales)
99 : imageNeedsUpdate(false)
100 , sizeAndScales(newSizeAndScales)
101 , buffer(newBuffer)
102 , image(newImage)
103 {
104 }
105
106 bool imageNeedsUpdate;
107 SizeAndScales sizeAndScales;
108
109 ImageBuffer* buffer;
110 RefPtr<Image> image;
111 };
112
113 typedef HashMap<const CachedImageClient*, SizeAndScales> SizeAndScalesMap;
114 typedef HashMap<const CachedImageClient*, ImageData> ImageDataMap;
115 61
116 SVGImage* m_svgImage; 62 SVGImage* m_svgImage;
117 SizeAndScalesMap m_sizeAndScalesMap; 63 ImageForContainerMap m_imageForContainerMap;
118 ImageDataMap m_imageDataMap;
119 Timer<SVGImageCache> m_redrawTimer;
120 DeferrableOneShotTimer<SVGImageCache> m_cacheClearTimer;
121 }; 64 };
122 65
123 } // namespace WebCore 66 } // namespace WebCore
124 67
125 #endif // ENABLE(SVG) 68 #endif // ENABLE(SVG)
126 #endif // SVGImageCache_h 69 #endif // SVGImageCache_h
OLDNEW
« no previous file with comments | « Source/WebCore/svg/graphics/SVGImage.cpp ('k') | Source/WebCore/svg/graphics/SVGImageCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698