<div>Hi,</div>
<div>I'm developer of mobile browser using webkit with cairo library.</div>
<div>I did performance comparing test between recording surface and image surface with cairo 1.10.2. </div>
<div>The performance(paint time) of recording surface seems quite low.</div>
<div>I doubt the testing code maybe written wrong and if the test code is right, I want to know why the recording surface performance is low.</div>
<div> </div>
<div>I'd appreciate if you explain how recording surface works when cairo_paint(dst_cr); is called in recording_surface().</div>
<div>When the operations "replay" for recording surface?</div>
<div>Why cairo_paint(dst_cr) time is different in recording_surface() and image_surface()?</div>
<div>I wonder the advantage of recording surface over image surface.</div>
<div> </div>
<div>Thank you</div>
<div>My testing code was like below : </div>
<div> </div>
<div>int image_surface(int num, uint32_t width, uint32_t height)<br>{<br> // Dst Surface<br> uint32_t* dst_buffer = create_buffer32(480*800, 0xffff0000);</div>
<div> cairo_surface_t* dst_surface = cairo_image_surface_create_for_data (<br> (unsigned char*)dst_buffer,<br> CAIRO_FORMAT_ARGB32,<br>
480, 800,<br> cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, 480));<br> // Src Surface<br> uint32_t* src_buffer = create_buffer32(width*height, 0xff0000ff);</div>
<div> cairo_surface_t* src_surface = cairo_image_surface_create_for_data (<br> (unsigned char*)src_buffer,<br> CAIRO_FORMAT_ARGB32,<br>
width, height,<br> cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width));</div>
<div> cairo_t* dst_cr = cairo_create(dst_surface);<br> cairo_t* src_cr = cairo_create(src_surface);</div>
<div> </div>
<div> curve_rectangle(src_cr);<br> gradient(src_cr);<br> fill(src_cr);<br> arc(src_cr);<br> text(src_cr);</div>
<div> cairo_paint(src_cr);<br> <br> cairo_set_source_surface(dst_cr, src_surface, 0, 0);<br> <br> uint64_t sTime = CURRENT_TIME_USEC();<br> cairo_paint(dst_cr);<br> uint64_t eTime = CURRENT_TIME_USEC();</div>
<div> </div>
<div> uint64_t png_sTime = CURRENT_TIME_USEC(); <br> cairo_surface_write_to_png(dst_surface,"test.png");<br> uint64_t png_eTime = CURRENT_TIME_USEC();</div>
<div><br> fprintf(stderr, "[%s] size(%d,%d),paint time(%lld),write png time(%lld) \n", __FUNCTION__, width,height, (eTime-sTime), (png_eTime-png_sTime));</div>
<div> </div>
<div> cairo_destroy(src_cr);<br> cairo_surface_destroy(src_surface); </div>
<div> cairo_surface_destroy(dst_surface);<br> cairo_destroy(dst_cr);</div>
<div> destroy_buffer32(src_buffer);<br> destroy_buffer32(dst_buffer); <br>}</div>
<div> </div>
<div>int recoding_surface(int num, uint32_t width, uint32_t height)<br>{</div>
<div> cairo_surface_t *record_surface;<br> cairo_t *record_cr;</div>
<div> </div>
<div> // Dst Surface<br> uint32_t* dst_buffer = create_buffer32(480*800, 0xffff0000);</div>
<div> cairo_surface_t* dst_surface = cairo_image_surface_create_for_data (<br> (unsigned char*)dst_buffer,<br> CAIRO_FORMAT_ARGB32,<br>
480, 800,<br> cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, 480));<br> // Src Surface<br> uint32_t* src_buffer = create_buffer32(width*height, 0xff0000ff);</div>
<div> cairo_surface_t* src_surface = cairo_image_surface_create_for_data (<br> (unsigned char*)src_buffer,<br> CAIRO_FORMAT_ARGB32,<br>
width, height,<br> cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width));</div>
<div> </div>
<div> cairo_t* dst_cr = cairo_create(dst_surface);<br> cairo_t* src_cr = cairo_create(src_surface);</div>
<div> cairo_rectangle_t extents = { 0, 0, width, height};<br> <br> curve_rectangle(src_cr);<br> gradient(src_cr);<br> fill(src_cr);<br> arc(src_cr);<br> text(src_cr);<br> cairo_paint(src_cr);<br> <br> record_surface = cairo_recording_surface_create (CAIRO_CONTENT_COLOR_ALPHA, &extents);<br>
record_cr = cairo_create (record_surface);<br> <br> cairo_set_source_surface (record_cr, src_surface, 0, 0);<br> cairo_paint(record_cr);</div>
<div> cairo_surface_destroy(src_surface);<br> cairo_destroy(src_cr);</div>
<div> </div>
<div> cairo_set_source_surface (dst_cr, record_surface, 0, 0);</div>
<div> uint64_t sTime = CURRENT_TIME_USEC(); <br> cairo_paint(dst_cr);<br> uint64_t eTime = CURRENT_TIME_USEC();</div>
<div> </div>
<div> uint64_t png_sTime = CURRENT_TIME_USEC(); <br> cairo_surface_write_to_png(dst_surface,"test.png");<br> uint64_t png_eTime = CURRENT_TIME_USEC();<br> <br> <br> fprintf(stderr, "[%s] size(%d,%d),paint time(%lld),write png time(%lld) \n", __FUNCTION__, width,height, (eTime-sTime), (png_eTime-png_sTime));<br>
<br> cairo_surface_destroy(record_surface);<br> cairo_destroy(record_cr);<br> <br> cairo_surface_destroy(dst_surface);<br> cairo_destroy(dst_cr);</div>
<div> destroy_buffer32(src_buffer);<br> destroy_buffer32(dst_buffer); </div>
<div>}</div>
<div> </div>
<div>This is test results in linux host : </div>
<div>src_size(2, 2) [image_surface] size(2,2),paint time(6),write png time(32870) <br>src_size(4, 4) [image_surface] size(4,4),paint time(5),write png time(34295) <br>src_size(8, 8) [image_surface] size(8,8),paint time(5),write png time(36821) <br>
src_size(16, 16) [image_surface] size(16,16),paint time(3),write png time(35396) <br>src_size(32, 32) [image_surface] size(32,32),paint time(7),write png time(43746) <br>src_size(64, 64) [image_surface] size(64,64),paint time(12),write png time(35914) <br>
src_size(128, 128) [image_surface] size(128,128),paint time(31),write png time(34925) <br>src_size(256, 256) [image_surface] size(256,256),paint time(42),write png time(34202) <br>src_size(480, 480) [image_surface] size(480,480),paint time(133),write png time(35698) <br>
src_size(480, 640) [image_surface] size(480,640),paint time(175),write png time(34986) <br>src_size(480, 800) [image_surface] size(480,800),paint time(219),write png time(34949) <br>-----------------------------------------------------------------------------------------------------------------------------</div>
<div>src_size(2, 2) [recoding_surface] size(2,2),paint time(19),write png time(33206) <br>src_size(4, 4) [recoding_surface] size(4,4),paint time(7),write png time(33482) <br>src_size(8, 8) [recoding_surface] size(8,8),paint time(14),write png time(39522) <br>
src_size(16, 16) [recoding_surface] size(16,16),paint time(16),write png time(37932) <br>src_size(32, 32) [recoding_surface] size(32,32),paint time(19),write png time(37256) <br>src_size(64, 64) [recoding_surface] size(64,64),paint time(31),write png time(36909) <br>
src_size(128, 128) [recoding_surface] size(128,128),paint time(73),write png time(34764) <br>src_size(256, 256) [recoding_surface] size(256,256),paint time(141),write png time(34244) <br>src_size(480, 480) [recoding_surface] size(480,480),paint time(537),write png time(34879) <br>
src_size(480, 640) [recoding_surface] size(480,640),paint time(722),write png time(35424) <br>src_size(480, 800) [recoding_surface] size(480,800),paint time(891),write png time(34894) </div>
<div> </div>
<div>Thank you.</div>