OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2008, Google Inc. All rights reserved. | 2 * Copyright (c) 2008, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // This will return an existing resized image subset, or generate a new one | 98 // This will return an existing resized image subset, or generate a new one |
99 // of the specified size and subset and possibly cache it. | 99 // of the specified size and subset and possibly cache it. |
100 // | 100 // |
101 // scaledImageSize | 101 // scaledImageSize |
102 // Dimensions of the scaled full image. | 102 // Dimensions of the scaled full image. |
103 // | 103 // |
104 // scaledImageSubset | 104 // scaledImageSubset |
105 // Rectangle of the subset in the scaled image. | 105 // Rectangle of the subset in the scaled image. |
106 SkBitmap resizedBitmap(const SkISize& scaledImageSize, const SkIRect& scaled
ImageSubset) const; | 106 SkBitmap resizedBitmap(const SkISize& scaledImageSize, const SkIRect& scaled
ImageSubset) const; |
107 | 107 |
108 void draw(GraphicsContext*, const SkRect& srcRect, const SkRect& destRect, P
assRefPtr<SkXfermode>) const; | 108 void draw( |
| 109 GraphicsContext*, |
| 110 const SkRect& srcRect, |
| 111 const SkRect& destRect, |
| 112 CompositeOperator, |
| 113 blink::WebBlendMode) const; |
| 114 |
109 void drawPattern( | 115 void drawPattern( |
110 GraphicsContext*, | 116 GraphicsContext*, |
111 const FloatRect& srcRect, | 117 const FloatRect& srcRect, |
112 const FloatSize& scale, | 118 const FloatSize& scale, |
113 const FloatPoint& phase, | 119 const FloatPoint& phase, |
114 CompositeOperator, | 120 CompositeOperator, |
115 const FloatRect& destRect, | 121 const FloatRect& destRect, |
116 blink::WebBlendMode, | 122 blink::WebBlendMode, |
117 const IntSize& repeatSpacing) const; | 123 const IntSize& repeatSpacing) const; |
118 | 124 |
(...skipping 26 matching lines...) Expand all Loading... |
145 // result of subsequent calls. | 151 // result of subsequent calls. |
146 // | 152 // |
147 // On the one hand, if only a small subset is desired, then we will waste a | 153 // On the one hand, if only a small subset is desired, then we will waste a |
148 // lot of time resampling the entire thing, so we only want to do exactly | 154 // lot of time resampling the entire thing, so we only want to do exactly |
149 // what's required. On the other hand, resampling the entire bitmap is | 155 // what's required. On the other hand, resampling the entire bitmap is |
150 // better if we're going to be using it more than once (like a bitmap | 156 // better if we're going to be using it more than once (like a bitmap |
151 // scrolling on and off the screen. Since we only cache when doing the | 157 // scrolling on and off the screen. Since we only cache when doing the |
152 // entire thing, it's best to just do it up front. | 158 // entire thing, it's best to just do it up front. |
153 bool shouldCacheResampling(const SkISize& scaledImageSize, const SkIRect& sc
aledImageSubset) const; | 159 bool shouldCacheResampling(const SkISize& scaledImageSize, const SkIRect& sc
aledImageSubset) const; |
154 | 160 |
155 InterpolationQuality computeInterpolationQuality(const SkMatrix&, float srcW
idth, float srcHeight, float destWidth, float destHeight) const; | |
156 SkBitmap extractScaledImageFragment(const SkRect& srcRect, float scaleX, flo
at scaleY, SkRect* scaledSrcRect) const; | 161 SkBitmap extractScaledImageFragment(const SkRect& srcRect, float scaleX, flo
at scaleY, SkRect* scaledSrcRect) const; |
157 void drawResampledBitmap(GraphicsContext*, SkPaint&, const SkRect& srcRect,
const SkRect& destRect) const; | |
158 | 162 |
159 // The original image. | 163 // The original image. |
160 SkBitmap m_image; | 164 SkBitmap m_image; |
161 | 165 |
162 // The cached bitmap fragment. This is a subset of the scaled version of | 166 // The cached bitmap fragment. This is a subset of the scaled version of |
163 // |m_image|. empty() returns true if there is no cached image. | 167 // |m_image|. empty() returns true if there is no cached image. |
164 mutable SkBitmap m_resizedImage; | 168 mutable SkBitmap m_resizedImage; |
165 | 169 |
166 // References how many times that the image size has been requested for | 170 // References how many times that the image size has been requested for |
167 // the last size. | 171 // the last size. |
168 // | 172 // |
169 // Every time we get a call to shouldCacheResampling, if it matches the | 173 // Every time we get a call to shouldCacheResampling, if it matches the |
170 // m_cachedImageInfo, we'll increment the counter, and if not, we'll reset | 174 // m_cachedImageInfo, we'll increment the counter, and if not, we'll reset |
171 // the counter and save the dimensions. | 175 // the counter and save the dimensions. |
172 // | 176 // |
173 // This allows us to see if many requests have been made for the same | 177 // This allows us to see if many requests have been made for the same |
174 // resized image, we know that we should probably cache it, even if all of | 178 // resized image, we know that we should probably cache it, even if all of |
175 // those requests individually are small and would not otherwise be cached. | 179 // those requests individually are small and would not otherwise be cached. |
176 // | 180 // |
177 // We also track scaling information and destination subset for the scaled | 181 // We also track scaling information and destination subset for the scaled |
178 // image. See comments for ImageResourceInfo. | 182 // image. See comments for ImageResourceInfo. |
179 mutable ImageResourceInfo m_cachedImageInfo; | 183 mutable ImageResourceInfo m_cachedImageInfo; |
180 mutable int m_resizeRequests; | 184 mutable int m_resizeRequests; |
181 }; | 185 }; |
182 | 186 |
183 } | 187 } |
184 #endif // NativeImageSkia_h | 188 #endif // NativeImageSkia_h |
OLD | NEW |