{"id":1861,"date":"2007-11-15T01:50:04","date_gmt":"2007-11-14T16:50:04","guid":{"rendered":"http:\/\/yasu2.prosou.nu\/blog\/index.php\/2007\/11\/15\/multithreaded_rendering_with_c\/"},"modified":"2007-11-15T01:50:04","modified_gmt":"2007-11-14T16:50:04","slug":"multithreaded_rendering_with_c","status":"publish","type":"post","link":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/2007\/11\/15\/1861\/","title":{"rendered":"Multithreaded rendering with Cairo"},"content":{"rendered":"<p>NOTE: if someone need English translation of this entry, I&#8217;ll do that with pleasure.  If you need, please send me an E-mail.<\/p>\n<p>\n<a href=\"http:\/\/www.cairographics.org\/\">cairo<\/a> \u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c6\u30fc\u30b7\u30e7\u30f3\u3068\u3044\u3046\u306e\u306f\u4e0d\u601d\u8b70\u306a\u307b\u3069\u5c11\u306a\u304f\u3066\u3001API doc \u3092\u9685\u304b\u3089\u9685\u307e\u3067\u8aad\u3093\u3060\u4e0a\u3067\u3001\u3044\u308d\u3044\u308d\u8a66\u3057\u305f\u308a\u60f3\u50cf\u3092\u3075\u304f\u3089\u307e\u305b\u305f\u308a\u3057\u3066\u904a\u3093\u3067\u308b\u308f\u3051\u3060\u304c\u3001\u3053\u306e\u305f\u3073\u4e00\u5ff5\u767a\u8d77\u3057\u3066\u3001\u305a\u3063\u3068\u958b\u767a\u3057\u3066\u3044\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u3001cairo \u3092\u4f7f\u3063\u305f\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3092\u4e26\u5217\u5316\u3059\u308b\u3053\u3068\u306b\u3057\u305f\u3002\u81ea\u5206\u304c dual core \u306a\u30d7\u30ed\u30bb\u30c3\u30b5\u306e\u30de\u30b7\u30f3\u3092\u4f7f\u3063\u3066\u3044\u308b\u306e\u306b\u3001\u66f8\u3044\u3066\u3044\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u304c single threaded \u3060\u306a\u3093\u3066\u3001\u304b\u3063\u3053\u60aa\u3044\u304b\u3089\u306a\u3002<\/p>\n<p>\n\u57fa\u672c\u7684\u306a\u3084\u308a\u65b9\u3068\u3057\u3066\u306f\u3001\u30e1\u30a4\u30f3\u306e\u753b\u50cf\u306e\u4e00\u90e8\u3092\u5225\u306e\u30b9\u30ec\u30c3\u30c9\u3067\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3057\u3066\u306f\u3081\u8fbc\u3080\u3001\u3082\u3057\u304f\u306f alpha channel \u3092\u4f7f\u3063\u3066\u4e0a\u306b\u91cd\u306d\u308b\u308f\u3051\u3060\u304c\u3001\u3069\u3061\u3089\u3082\u3084\u308a\u65b9\u306f\u307b\u3068\u3093\u3069\u540c\u3058\u3060\u3068\u601d\u3046\u3002\u307e\u305a\u6700\u521d\u306b\u3001\u30b9\u30ec\u30c3\u30c9\u306e\u6570\u3060\u3051\u306e surface \u3068 cairo drawing context \u3092\u4f5c\u308b\u3002\u3053\u306e\u3068\u304d\u3001surface type \u306f\u30e1\u30a4\u30f3\u306e\u753b\u50cf\u306e\u3082\u306e\u3068\u540c\u3058\u306b\u3059\u308b\u304c\u3001surface content \u306f color with alpha \u306b\u3057\u3066\u304a\u304f\u306e\u304c\u5927\u4e8b\u3060\u3068\u601d\u3046\u3002<\/p>\n<p>\n\u30e1\u30a4\u30f3\u306e cairo_t \u3092 cr \u3068\u3059\u308b\u3068\u3001<\/p>\n<pre>\ncairo_surface_t* surface;\ncairo_surface_t* surface_p[10];\ncairo_t* cr_p[10];\n\/\/ create surfaces\nsurface = cairo_get_target(cr);\nfor(int i=0; i&lt;10; i++){\nsurface_p[i] = cairo_surface_create_similar(surface,\nCAIRO_CONTENT_COLOR_ALPHA,\nWIDTH, HEIGHT);\ncr_p[i] = cairo_create(surface_p[i]);\n}<\/pre>\n<p>\u3053\u3093\u306a\u611f\u3058\u3067\u3001surface \u3068 cairo context \u3092\u305f\u304f\u3055\u3093\u4f5c\u3063\u3066\u3001\u3042\u3068\u306f\u305d\u308c\u305e\u308c\u306e context \u306e\u4e0a\u306b\u3058\u3083\u3093\u3058\u3083\u304b\u7d75\u3092\u63cf\u3051\u3070\u3088\u3044\u3002<\/p>\n<p>\n\u3055\u3066\u3001\u554f\u984c\u306f\u3053\u308c\u3092\u306f\u3081\u8fbc\u3080\u3068\u304d\u3060\u3002\u4ed5\u639b\u3051\u3068\u3057\u3066\u306f\u3001\u3055\u304d\u307b\u3069\u305f\u304f\u3055\u3093\u4f5c\u3063\u305f surface \u304b\u3089 cairo_pattern_create_for_surface() \u3067 pattern \u3092\u4f5c\u308a\u3001\u305d\u308c\u3092 cairo_set_source() \u3067\u6307\u5b9a\u3057\u305f\u4e0a\u3067 cairo_rectangle(); cairo_fill() \u3068\u304b\u3059\u308c\u3070\u3088\u3044\u306e\u3060\u304c\u3001\u91cd\u8981\u306a\u306e\u306f\u3001<em>cairo_pattern \u3092\u4f7f\u3046\u5834\u5408\u3001pattern \u306f rectangle \u306a\u3069\u306e\u4f4d\u7f6e\u306b\u95a2\u4fc2\u306a\u304f\u3001\u5fc5\u305a(0, 0) \u3092\u57fa\u6e96\u306b\u3057\u3066\u5c55\u958b\u3055\u308c\u308b<\/em> \u3068\u3044\u3046\u3053\u3068\u3067\u3042\u308b\u3002\u3057\u305f\u304c\u3063\u3066\u3001rectangle \u306e\u4f4d\u7f6e\u306b pattern \u306e\u4f4d\u7f6e\u304c\u5408\u3046\u3088\u3046\u306b\u3001transformation matrix \u3092\u6307\u5b9a\u3057\u3066\u3084\u3089\u306d\u3070\u306a\u3089\u306a\u3044\u3002<\/p>\n<pre>\ncairo_pattern_t* pattern;\nfor(int i=0; i&lt;10; i++){\ncairo_matrix_t m;\npattern = cairo_pattern_create_for_surface(surface_p[i]);\ncairo_matrix_init_identity(&m);\nm.x0 = -XPOS;  \/\/ -XPOS, but not XPOS !\nm.y0 = -YPOS;  \/\/ -YPOS, but not YPOS!\ncairo_pattern_set_matrix(pattern, &m);\ncairo_set_source(cr, pattern);\ncairo_rectangle(cr, XPOS, YPOS, WIDTH, HEIGHT);\ncairo_fill(cr);\ncairo_pattern_destroy(pattern);\ncairo_surface_destroy(surface_p[i]);\ncairo_destroy(cr_p[i]);\n}<\/pre>\n<p>\u3068\u307e\u3042\u3001\u3053\u3093\u306a\u611f\u3058\u3002GTK \u3068\u304b PDF \u3067\u8a66\u3057\u305f\u611f\u3058\u3067\u306f\u3001\u3046\u307e\u304f\u3044\u3063\u3066\u3044\u308b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>NOTE: if someone need English translation of this entry, I&#8217;ll do that with pleasure. If you need, please &hellip; <a href=\"https:\/\/yasu2.prosou.nu\/blog\/index.php\/2007\/11\/15\/1861\/\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Multithreaded rendering with Cairo&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":""},"categories":[6],"tags":[],"class_list":["post-1861","post","type-post","status-publish","format-standard","hentry","category-unix-"],"_links":{"self":[{"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1861","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=1861"}],"version-history":[{"count":0,"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1861\/revisions"}],"wp:attachment":[{"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1861"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1861"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yasu2.prosou.nu\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1861"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}