Changeset 211206 in webkit
- Timestamp:
- Jan 26, 2017 1:21:46 AM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r211204 r211206 1 2017-01-26 Zan Dobersek <zdobersek@igalia.com> 2 3 ImageBufferCairo: cairo_image_surface should use bmalloc-allocated memory 4 https://bugs.webkit.org/show_bug.cgi?id=165751 5 6 Reviewed by Carlos Garcia Campos. 7 8 Allocate the underlying memory for cairo_image_surface objects through FastMalloc. 9 This way we can steer such large allocations away from the default libc allocator. 10 11 Objects of this class can create Cairo surfaces that need as much as 4MB of memory 12 for the underlying pixel buffer. Allocating such objects through the default 13 libc allocator can lead to increased memory usage because of non-optimal allocation 14 strategy in libc. In contrast, bmalloc performs large allocations by directly using 15 mmap() to reserve the necessary memory. 16 17 The improvements can be significant. On nytimes.com, with the threaded version of 18 the CoordinatedGraphics system, the memory consumption can drop by roughly 20%. 19 20 * platform/graphics/cairo/ImageBufferCairo.cpp: 21 (WebCore::ImageBuffer::ImageBuffer): Zero-allocate the necessary memory via FastMalloc. 22 Tie that memory lifetime to the lifetime of the surface by using 23 cairo_surface_set_user_data() with the specific user data key. 24 1 25 2017-01-26 Miguel Gomez <magomez@igalia.com> 2 26 -
trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
r208985 r211206 219 219 ASSERT(m_data.m_renderingMode != Accelerated); 220 220 #endif 221 m_data.m_surface = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, m_size.width(), m_size.height())); 221 { 222 static cairo_user_data_key_t s_surfaceDataKey; 223 224 int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, m_size.width()); 225 auto* surfaceData = fastZeroedMalloc(m_size.height() * stride); 226 227 m_data.m_surface = adoptRef(cairo_image_surface_create_for_data(static_cast<unsigned char*>(surfaceData), CAIRO_FORMAT_ARGB32, m_size.width(), m_size.height(), stride)); 228 cairo_surface_set_user_data(m_data.m_surface.get(), &s_surfaceDataKey, surfaceData, [](void* data) { fastFree(data); }); 229 } 222 230 223 231 if (cairo_surface_status(m_data.m_surface.get()) != CAIRO_STATUS_SUCCESS)
Note: See TracChangeset
for help on using the changeset viewer.