[cairo] scaling performance test of cairo library

cooolheater cooolheater at gmail.com
Mon Feb 7 20:52:02 PST 2011


Hi,
I'm developer of mobile browser using webkit with cairo library.
Recently, I did performance comparing test between cairo 1.10.02 and skia
library.
The performance of compstion and rotating seems similar, but scaling
performance of cairo library seems quite low.
I doubt the testing code maybe written wrong or binary is not optimized
because of not optimized compile option.

So, if the below testing code is written wrong or methods for increasing
scaling performance are exist, it'll be thankful if you let me know.


 My testing code was like below :

*#define TC_ITER_COUNT 100
 void prof_cairo_scale_by_size(TCWindow* window, cairo_operator_t oper,
double scale, uint32_t width, uint32_t height)
{
    uint32_t* dst_buffer = create_buffer32(480*800, 0xffff0000);
    cairo_surface_t* dst_surface = cairo_image_surface_create_for_data (
                                                            (unsigned
char*)dst_buffer,

CAIRO_FORMAT_ARGB32,
                                                            480, 800,

cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, 480));
    // Src Surface
    uint32_t* src_buffer = create_buffer32(width*height, 0xff0000ff);
    cairo_surface_t* src_surface = cairo_image_surface_create_for_data (
                                                            (unsigned
char*)src_buffer,

CAIRO_FORMAT_ARGB32,
                                                            width, height,

cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width));
    cairo_t* cr = cairo_create(dst_surface);
    cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
    cairo_rectangle(cr, 0, 0, width*scale, height*scale);
    cairo_clip(cr);    *

*    uint64_t totalTime = 0;
    for (int i=0; i<TC_ITER_COUNT+1; i++)
    {
        cairo_set_operator(cr, oper);
        cairo_save(cr);
         cairo_scale(cr, scale, scale);

        cairo_pattern_t* pattern =
cairo_pattern_create_for_surface(src_surface);
        cairo_pattern_set_extend(pattern, CAIRO_EXTEND_NONE);
        cairo_pattern_set_filter(pattern, CAIRO_FILTER_BILINEAR); //
high-quality
  //cairo_pattern_set_filter(pattern, CAIRO_FILTER_NEAREST); // low-quality*

*        cairo_set_source_surface(cr, src_surface, 0, 0);
        uint64_t sTime = CURRENT_TIME_USEC();
        cairo_paint(cr);
        uint64_t eTime = CURRENT_TIME_USEC();
        cairo_restore(cr);
        if (i > 0)
        {
            totalTime += eTime-sTime;
        }
    }
    fprintf(stdout, "[%s] size(%d,%d):\t%lld\n", __FUNCTION__, width,height,
(totalTime/TC_ITER_COUNT));
    window->flip(dst_buffer);
    cairo_surface_destroy(dst_surface);
    cairo_destroy(cr);
    destroy_buffer32(src_buffer);
    destroy_buffer32(dst_buffer);
}*


Testing result was like below:
( Cairo was 2~4 times slower in big size image)

Scale : 2.0
Operator : CAIRO_OPERATOR_SOURCE



*Filter: bilinear*

*Filter: nearest*

Size

Skia

Cairo

Size

Skia

Cairo

2x2

14

37

2x2

14

31

4x4

17

47

4x4

16

32

8x8

26

80

8x8

20

33

16x16

58

211

16x16

32

38

32x32

172

715

32x32

70

52

64x64

640

2697

64x64

183

120

*128x128*

*2671*

*10618*

128x128

603

394

*256x256*

*10872*

*41926*

256x256

2429

1223

Thank you.
Have a nice day.

---------- Forwarded message ----------
From: <cairo-request at cairographics.org>
Date: Tue, Feb 8, 2011 at 1:38 PM
Subject: confirm a840406652b471228f7af9716b69703e87c35920
To: cooolheater at gmail.com


Mailing list subscription confirmation notice for mailing list cairo

We have received a request from 210.94.41.89 for subscription of your
email address, "cooolheater at gmail.com", to the cairo at cairographics.org
mailing list.  To confirm that you want to be added to this mailing
list, simply reply to this message, keeping the Subject: header
intact.  Or visit this web page:


http://lists.cairographics.org/mailman/confirm/cairo/a840406652b471228f7af9716b69703e87c35920


Or include the following line -- and only the following line -- in a
message to cairo-request at cairographics.org:

   confirm a840406652b471228f7af9716b69703e87c35920

Note that simply sending a `reply' to this message should work from
most mail readers, since that usually leaves the Subject: line in the
right form (additional "Re:" text in the Subject: is okay).

If you do not wish to be subscribed to this list, please simply
disregard this message.  If you think you are being maliciously
subscribed to the list, or have any other questions, send them to
cairo-owner at cairographics.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20110208/7d67b75a/attachment-0001.html>


More information about the cairo mailing list