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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 m_resizedImage.reset(); | 120 m_resizedImage.reset(); |
121 } | 121 } |
122 | 122 |
123 // We can not cache incomplete frames. This might be a good optimization in | 123 // We can not cache incomplete frames. This might be a good optimization in |
124 // the future, were we know how much of the frame has been decoded, so when | 124 // the future, were we know how much of the frame has been decoded, so when |
125 // we incrementally draw more of the image, we only have to resample the | 125 // we incrementally draw more of the image, we only have to resample the |
126 // parts that are changed. | 126 // parts that are changed. |
127 if (!isDataComplete()) | 127 if (!isDataComplete()) |
128 return false; | 128 return false; |
129 | 129 |
| 130 // If the destination bitmap is excessively large, we'll never allow caching
. |
| 131 static const unsigned long long kLargeBitmapSize = 4096ULL * 4096ULL; |
| 132 if ((static_cast<unsigned long long>(destWidth) * static_cast<unsigned long
long>(destHeight)) > kLargeBitmapSize) |
| 133 return false; |
| 134 |
130 // If the destination bitmap is small, we'll always allow caching, since | 135 // If the destination bitmap is small, we'll always allow caching, since |
131 // there is not very much penalty for computing it and it may come in handy. | 136 // there is not very much penalty for computing it and it may come in handy. |
132 static const int kSmallBitmapSize = 4096; | 137 static const int kSmallBitmapSize = 4096; |
133 if (destWidth * destHeight <= kSmallBitmapSize) | 138 if (destWidth * destHeight <= kSmallBitmapSize) |
134 return true; | 139 return true; |
135 | 140 |
136 // If "too many" requests have been made for this bitmap, we assume that | 141 // If "too many" requests have been made for this bitmap, we assume that |
137 // many more will be made as well, and we'll go ahead and cache it. | 142 // many more will be made as well, and we'll go ahead and cache it. |
138 static const int kManyRequestThreshold = 4; | 143 static const int kManyRequestThreshold = 4; |
139 if (m_resizeRequests >= kManyRequestThreshold) | 144 if (m_resizeRequests >= kManyRequestThreshold) |
(...skipping 17 matching lines...) Expand all Loading... |
157 } | 162 } |
158 | 163 |
159 void NativeImageSkia::CachedImageInfo::set(const SkIRect& otherSrcSubset, int wi
dth, int height) | 164 void NativeImageSkia::CachedImageInfo::set(const SkIRect& otherSrcSubset, int wi
dth, int height) |
160 { | 165 { |
161 srcSubset = otherSrcSubset; | 166 srcSubset = otherSrcSubset; |
162 requestSize.setWidth(width); | 167 requestSize.setWidth(width); |
163 requestSize.setHeight(height); | 168 requestSize.setHeight(height); |
164 } | 169 } |
165 | 170 |
166 } // namespace WebCore | 171 } // namespace WebCore |
OLD | NEW |