Bug 20838 - [CAIRO] needs getImageData and putImageData support
Summary: [CAIRO] needs getImageData and putImageData support
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC All
: P2 Normal
Assignee: Nobody
URL:
Keywords: Cairo
Depends on:
Blocks:
 
Reported: 2008-09-14 03:24 PDT by Dirk Schulze
Modified: 2008-09-23 14:33 PDT (History)
1 user (show)

See Also:


Attachments
Cairo getImageData() (3.18 KB, patch)
2008-09-14 03:30 PDT, Dirk Schulze
no flags Details | Formatted Diff | Diff
Cairo getImageData() (3.52 KB, patch)
2008-09-14 10:01 PDT, Dirk Schulze
no flags Details | Formatted Diff | Diff
Cairo get/putImageData() (5.82 KB, patch)
2008-09-14 11:19 PDT, Dirk Schulze
no flags Details | Formatted Diff | Diff
Cairo get/putImageData() with ASSERT for image_surface (5.99 KB, patch)
2008-09-16 09:32 PDT, Dirk Schulze
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Schulze 2008-09-14 03:24:24 PDT
Cairo needs getImageData() support for HTML 5 and Canvas.
Comment 1 Dirk Schulze 2008-09-14 03:30:09 PDT
Created attachment 23408 [details]
Cairo getImageData()

Added getImageData support to Cairo. Has the same logic as the Cg port but uses the stored m_surface.
Comment 2 Dirk Schulze 2008-09-14 10:01:22 PDT
Created attachment 23412 [details]
Cairo getImageData()

added copyright.
Comment 3 Dirk Schulze 2008-09-14 11:19:10 PDT
Created attachment 23413 [details]
Cairo get/putImageData()

added putImageData() too.
Comment 4 Alp Toker 2008-09-16 01:31:15 PDT
(In reply to comment #3)
> Created an attachment (id=23413) [edit]
> Cairo get/putImageData()
> 
> added putImageData() too.
> 

Can we use cairo_image_surface_get_stride() instead of cairo_format_stride_for_width() in some places here?

An assertion to ensure the surface passed in are image surfaces using cairo_surface_get_type() would be helpful too (to catch issues when we start to make use of more platform surfaces in future).
Comment 5 Dirk Schulze 2008-09-16 03:57:29 PDT
(In reply to comment #4)
> Can we use cairo_image_surface_get_stride() instead of
> cairo_format_stride_for_width() in some places here?

You mean reaplce:

+int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, m_size.width());

by

+int stride;
+if (cairo_surface_get_type(m_surface) == CAIRO_SURFACE_TYPE_IMAGE)
+    stride = cairo_image_surface_get_stride(m_surface);
+else
+    stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, m_size.width());

and expanse it if necessary?
Comment 6 Alp Toker 2008-09-16 08:45:31 PDT
(In reply to comment #5)
> (In reply to comment #4)
> > Can we use cairo_image_surface_get_stride() instead of
> > cairo_format_stride_for_width() in some places here?
> 
> You mean reaplce:
> 
> +int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32,
> m_size.width());
> 
> by
> 
> +int stride;
> +if (cairo_surface_get_type(m_surface) == CAIRO_SURFACE_TYPE_IMAGE)
> +    stride = cairo_image_surface_get_stride(m_surface);
> +else
> +    stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32,
> m_size.width());
> 
> and expanse it if necessary?
> 

Nope. I meant putting a cairo_surface_get_type() check is at the top as a debug ASSERT() since no cairo_image_surface_ functions all require an image surface.

I don't think you need to use cairo_format_stride_for_width() at all here. cairo_image_surface_get_stride() can be used both to get the source stride in one function and the destination stride in the other, right?
Comment 7 Dirk Schulze 2008-09-16 09:32:27 PDT
Created attachment 23475 [details]
Cairo get/putImageData() with ASSERT for image_surface

Added the asserts to get/putImageData and took cairo_image_surface_get_stride().
Comment 8 Darin Adler 2008-09-16 09:48:26 PDT
Comment on attachment 23475 [details]
Cairo get/putImageData() with ASSERT for image_surface

+    unsigned char* dataDst = result->data()->data().data();

LOL!

Looks fine, r=me
Comment 9 Jan Alonzo 2008-09-23 14:33:40 PDT
landed in r36813