Changeset 92430 in webkit
- Timestamp:
- Aug 4, 2011, 4:46:59 PM (14 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r92425 r92430 1 2011-08-04 James Robinson <jamesr@chromium.org> 2 3 [chromium] Implement a global resource limit for DrawingBuffer to limit the amount of GPU memory used by 2d canvas backing stores 4 https://bugs.webkit.org/show_bug.cgi?id=65655 5 6 Reviewed by Kenneth Russell. 7 8 * platform/graphics/gpu/DrawingBuffer.cpp: 9 (WebCore::DrawingBuffer::setResourceLimit): 10 (WebCore::DrawingBuffer::clear): 11 (WebCore::DrawingBuffer::reset): 12 * platform/graphics/gpu/DrawingBuffer.h: 13 1 14 2011-08-04 Kenichi Ishibashi <bashi@chromium.org> 2 15 -
trunk/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp
r90872 r92430 39 39 namespace WebCore { 40 40 41 // Global resource ceiling (expressed in terms of pixels) for DrawingBuffer creation and resize. 42 // When this limit is set, DrawingBuffer::create() and DrawingBuffer::reset() calls that would 43 // exceed the global cap will instead clear the buffer. 44 #if PLATFORM(CHROMIUM) // Currently, this cap only exists for chromium. 45 static int s_maximumResourceUsePixels = 16 * 1024 * 1024; 46 #else 47 static int s_maximumResourceUsePixels = 0; 48 #endif 49 static int s_currentResourceUsePixels = 0; 50 41 51 PassRefPtr<DrawingBuffer> DrawingBuffer::create(GraphicsContext3D* context, const IntSize& size) 42 52 { … … 61 71 62 72 m_context->makeContextCurrent(); 73 if (!m_size.isEmpty()) 74 s_currentResourceUsePixels -= m_size.width() * m_size.height(); 63 75 64 76 if (m_colorBuffer) { … … 203 215 m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &maxTextureSize); 204 216 if (newSize.height() > maxTextureSize || newSize.width() > maxTextureSize) { 205 clear(); 206 return false; 207 } 217 clear(); 218 return false; 219 } 220 221 int pixelDelta = newSize.width() * newSize.height(); 222 if (!m_size.isEmpty()) 223 pixelDelta -= m_size.width() * m_size.height(); 224 225 if (s_maximumResourceUsePixels && (s_currentResourceUsePixels + pixelDelta) > s_maximumResourceUsePixels) { 226 clear(); 227 return false; 228 } 229 s_currentResourceUsePixels += pixelDelta; 208 230 209 231 const GraphicsContext3D::Attributes& attributes = m_context->getContextAttributes(); -
trunk/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h
r87987 r92430 59 59 public: 60 60 friend class GraphicsContext3D; 61 61 62 62 ~DrawingBuffer(); 63 63 … … 115 115 116 116 DrawingBuffer(GraphicsContext3D*, const IntSize&, bool multisampleExtensionSupported, bool packedDepthStencilExtensionSupported); 117 117 118 118 // Platform specific function called after reset() so each platform can do extra work if needed 119 119 void didReset();
Note:
See TracChangeset
for help on using the changeset viewer.