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

Side by Side Diff: Source/WebCore/platform/graphics/skia/NativeImageSkia.cpp

Issue 10083037: Merge 114487 - Skia OOM error when upscaling small subsets of images by large quantities (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1084/
Patch Set: Created 8 years, 8 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 | « no previous file | no next file » | 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) 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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698