Skip to content

Commit

Permalink
add image_g2d_benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
xianjimli committed Dec 5, 2024
1 parent fb4d0e5 commit f1750d9
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
6 changes: 6 additions & 0 deletions demos/demo_ui_old_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
*/

#include "awtk.h"
#include "blend/image_g2d.h"

#include "ext_widgets.h"
#include "base/font_manager.h"
#include "base/event_recorder_player.h"
Expand Down Expand Up @@ -90,6 +92,10 @@ uint32_t tk_mem_speed_test(void* buffer, uint32_t length, uint32_t* pmemcpy_spee
*pmemcpy_speed = memcpy_speed;
}

#ifdef WITH_G2D
image_g2d_benchmark();
#endif/*WITH_G2D*/

return total_cost;
}

Expand Down
71 changes: 71 additions & 0 deletions src/blend/image_g2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,75 @@ ret_t image_rotate_blend(bitmap_t* dst, bitmap_t* src, const rectf_t* dst_r, con
return RET_NOT_IMPL;
}
#endif

#if defined(WITH_G2D)
#include "tkc/time_now.h"

ret_t image_g2d_benchmark(void) {
int w = 1024;
int h = 1024;
int i = 0;
int n = 10;
rect_t r = rect_init(0, 0, w, h);
color_t c = color_init(0x80, 0x80, 0x80, 0xff);
bitmap_t* img_rgba8888 = bitmap_create_ex(w, h, w * 4, BITMAP_FMT_RGBA8888);
bitmap_t* img_rgba8888_src = bitmap_create_ex(w, h, w * 4, BITMAP_FMT_RGBA8888);
bitmap_t* img_rgb565 = bitmap_create_ex(w, h, w * 4, BITMAP_FMT_BGR565);
bitmap_t* img_rgb565_src = bitmap_create_ex(w, h, w * 4, BITMAP_FMT_BGR565);
uint64_t start = time_now_us();
uint32_t cost = 0;
for (i = 0; i < n; i++) {
soft_fill_rect(img_rgba8888, &r, c);
soft_fill_rect(img_rgb565, &r, c);
}
cost = time_now_us() - start;
log_debug("soft_fill_rect cost=%u\n", cost);

start = time_now_us();
for (i = 0; i < n; i++) {
g2d_fill_rect(img_rgba8888, &r, c);
g2d_fill_rect(img_rgb565, &r, c);
}
cost = time_now_us() - start;
log_debug("g2d_fill_rect cost=%u\n", cost);

start = time_now_us();
for (i = 0; i < n; i++) {
soft_copy_image(img_rgb565, img_rgb565_src, &r, 0, 0);
}
cost = time_now_us() - start;
log_debug("soft_copy_image cost=%u\n", cost);

start = time_now_us();
for (i = 0; i < n; i++) {
g2d_copy_image(img_rgb565, img_rgb565_src, &r, 0, 0);
}
cost = time_now_us() - start;
log_debug("g2d_copy_image cost=%u\n", cost);

start = time_now_us();
for (i = 0; i < n; i++) {
rectf_t rf = {0, 0, w, h};
soft_blend_image(img_rgba8888, img_rgba8888_src, &rf, &rf, 0xff);
}
cost = time_now_us() - start;
log_debug("soft_blend_image cost=%u\n", cost);

start = time_now_us();
for (i = 0; i < n; i++) {
g2d_blend_image(img_rgba8888, img_rgba8888_src, &r, &r, 0xff);
}
cost = time_now_us() - start;
log_debug("g2d_blend_image cost=%u\n", cost);

bitmap_destroy(img_rgba8888);
bitmap_destroy(img_rgba8888_src);
bitmap_destroy(img_rgb565);
bitmap_destroy(img_rgb565_src);

return RET_OK;
}

#endif/*WITH_G2D*/

#endif/*ndef AWTK_WEB*/
2 changes: 2 additions & 0 deletions src/blend/image_g2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ ret_t image_rotate_ex(bitmap_t* dst, bitmap_t* src, const rect_t* src_r, xy_t dx
ret_t image_rotate_blend(bitmap_t* dst, bitmap_t* src, const rectf_t* dst_r, const rectf_t* src_r,
uint8_t global_alpha, lcd_orientation_t o);


ret_t image_g2d_benchmark(void);
#endif

END_C_DECLS
Expand Down
10 changes: 10 additions & 0 deletions src/blend/pixman_g2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ ret_t g2d_rotate_image(bitmap_t* fb, bitmap_t* img, const rect_t* src, lcd_orien
return RET_NOT_IMPL;
}

ret_t g2d_blend_image_rotate(bitmap_t* dst, bitmap_t* src, const rectf_t* dst_r,
const rectf_t* src_r, uint8_t alpha, lcd_orientation_t o) {
return RET_NOT_IMPL;
}

ret_t g2d_blend_image(bitmap_t* fb, bitmap_t* img, const rect_t* dst, const rect_t* src,
uint8_t global_alpha) {
pixman_image_t* dst_img = pixman_image_get_dst(fb);
Expand All @@ -168,6 +173,11 @@ ret_t g2d_blend_image(bitmap_t* fb, bitmap_t* img, const rect_t* dst, const rect
return RET_OK;
}

ret_t g2d_rotate_image_ex(bitmap_t* dst, bitmap_t* src, const rect_t* src_r, xy_t dx,
xy_t dy, lcd_orientation_t o) {
return RET_NOT_IMPL;
}

ret_t tk_g2d_init(void) {
return RET_OK;
}
Expand Down

0 comments on commit f1750d9

Please sign in to comment.