[WK2][CAIRO] Use cairo_format_stride_for_width() in ShareableBitmap
authorcommit-queue <commit-queue@webkit.org>
Mon, 15 Oct 2012 21:00:46 +0000 (21:00 +0000)
committercommit-queue <commit-queue@webkit.org>
Mon, 15 Oct 2012 21:00:46 +0000 (21:00 +0000)
commitf7e6d0afbcc1b1c7a86bc99a15dcf2ce13b0b583
tree4b06a99e0a7974e1073e1ee1d83d09ffcfed3b0f
parent17e8d4ceb0b02ca29f93d540f1cbbcf102ec6d39
[WK2][CAIRO] Use cairo_format_stride_for_width() in ShareableBitmap
https://bugs.webkit.org/show_bug.cgi?id=99332

Patch by Christophe Dumez <christophe.dumez@intel.com> on 2012-10-15
Reviewed by Martin Robinson.

Cairo implementation of ShareableBitmap is calling
cairo_image_surface_create_for_data() to create an image surface for
the provided pixel data. However, it was passing "m_size.width() * 4"
for the stride argument instead of calling
cairo_format_stride_for_width().

The Cairo documentation states:
"Note that the stride may be larger than width*bytes_per_pixel to
provide proper alignment for each pixel and row. This alignment is
required to allow high-performance rendering within cairo. The correct
way to obtain a legal stride value is to call
cairo_format_stride_for_width() with the desired format and maximum
image width value, and then use the resulting stride value to allocate
the data and to create the image surface."

This patch calls cairo_format_stride_for_width() is ShareableBitmap
in order to obtain a legal stride value to make sure we provide proper
alignment for each pixel and row, and allow high-performance rendering
within cairo.

* Shared/ShareableBitmap.h:
(ShareableBitmap):
* Shared/cairo/ShareableBitmapCairo.cpp:
(WebKit):
(WebKit::ShareableBitmap::numBytesForSize):
(WebKit::createSurfaceFromData):
(WebKit::ShareableBitmap::paint):
(WebKit::ShareableBitmap::createCairoSurface):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131354 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/ShareableBitmap.h
Source/WebKit2/Shared/cairo/ShareableBitmapCairo.cpp