void test_copy(uint32_t w, uint32_t h, uint32_t format) { PixmapPtr src, dest; C2D_OBJECT blit = {}; C2D_RECT rect; c2d_ts_handle curTimestamp; DEBUG_MSG("----------------------------------------------------------------"); DEBUG_MSG("copy: %04dx%04d-%08x", w, h, format); RD_START("copy", "%dx%d format:%08x", w, h, format); dest = create_pixmap(w, h, format); src = create_pixmap(13, 17, format); rect.x = 1; rect.y = 2; rect.width = w - 2; rect.height = h - 3; CHK(c2dFillSurface(dest->id, 0xff556677, &rect)); CHK(c2dFlush(dest->id, &curTimestamp)); CHK(c2dWaitTimestamp(curTimestamp)); rect.x = 0; rect.y = 0; rect.width = 13; rect.height = 17; CHK(c2dFillSurface(src->id, 0xff223344, &rect)); CHK(c2dFlush(src->id, &curTimestamp)); CHK(c2dWaitTimestamp(curTimestamp)); blit.surface_id = src->id; blit.config_mask = DEFAULT_BLIT_MASK; blit.next = NULL; blit.source_rect.x = FIXED(1); blit.source_rect.y = FIXED(2); blit.source_rect.width = FIXED(13-1); blit.source_rect.height = FIXED(17-2); blit.target_rect.x = FIXED((w - 13) / 2); blit.target_rect.y = FIXED((h - 17) / 2); blit.target_rect.width = FIXED(13); blit.target_rect.height = FIXED(17); CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); CHK(c2dFlush(dest->id, &curTimestamp)); CHK(c2dWaitTimestamp(curTimestamp)); RD_END(); dump_pixmap(dest, "copy-%04dx%04d-%08x.bmp", w, h, format); }
static void copy(PixmapPtr dest, PixmapPtr src, int srcX, int srcY, int dstX, int dstY, int width, int height) { C2D_OBJECT blit = {}; blit.surface_id = src->id; blit.config_mask = C2D_SOURCE_RECT_BIT | C2D_TARGET_RECT_BIT | C2D_NO_PIXEL_ALPHA_BIT | C2D_NO_BILINEAR_BIT | C2D_NO_ANTIALIASING_BIT | C2D_ALPHA_BLEND_NONE; blit.next = NULL; blit.source_rect.x = FIXED(srcX); blit.source_rect.y = FIXED(srcY); blit.source_rect.width = FIXED(width); blit.source_rect.height = FIXED(height); blit.target_rect.x = FIXED(dstX); blit.target_rect.y = FIXED(dstY); blit.target_rect.width = FIXED(width); blit.target_rect.height = FIXED(height); CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); }
void test_composite(const char *name, const struct blend_mode *blend, const struct format_mode *dst_format, uint32_t bw, uint32_t bh, const struct format_mode *src_format, uint32_t src_repeat, uint32_t sw, uint32_t sh, const struct format_mode *mask_format, uint32_t mask_repeat, uint32_t mw, uint32_t mh) { PixmapPtr src, dest, mask = NULL; C2D_OBJECT blit = {}; c2d_ts_handle curTimestamp; DEBUG_MSG("%s: op:%s src:%s (repeat:%d) mask=%s (repeat:%d) dst:%s", name, blend->name, src_format->name, src_repeat, mask_format ? mask_format->name : "none", mask_repeat, dst_format->name); RD_START(name, "op:%s src:%s (repeat:%d) mask=%s (repeat:%d) dst:%s", blend->name, src_format->name, src_repeat, mask_format ? mask_format->name : "none", mask_repeat, dst_format->name); blit.config_mask = DEFAULT_BLEND_MASK | blend->mode; dest = create_pixmap(1033, 1077, dst_format->format); if (src_repeat) { src = create_pixmap(1, 1, src_format->format); blit.config_mask |= C2D_SOURCE_TILE_BIT; } else { src = create_pixmap(sw, sh, src_format->format); } blit.config_mask |= C2D_SOURCE_RECT_BIT; blit.surface_id = src->id; if (mask_format) { /* TODO not clear if mask repeat is really supported.. msm-exa-c2d2.c * seems to reject it but C2D_MASK_TILE_BIT?? * * Also, for src format, msm-exa-c2d2.c seems to encode fgcolor (like * a solid fill) for repeats.. not really clear if TILE_BIT does what * we expect or not?? * * Seems like libC2D2 doesn't actually give any way to specify the * maskX/maskY!!! The previous c2d API does, so I'd have to assume * this is actually supported by the hardware and this is just C2D2 * retardation */ if (mask_repeat) { mask = create_pixmap(1, 1, mask_format->format); blit.config_mask |= C2D_MASK_TILE_BIT; } else { mask = create_pixmap(mw, mh, mask_format->format); } blit.config_mask |= C2D_MASK_SURFACE_BIT; blit.mask_surface_id = mask->id; } else { // TODO make redump not confused when one column has extra rows mask = create_pixmap(1, 1, ARGB); } blit.next = NULL; blit.source_rect.x = FIXED(1); blit.source_rect.y = FIXED(2); blit.source_rect.width = FIXED(bw - blit.source_rect.x - 1); blit.source_rect.height = FIXED(bh - blit.source_rect.y - 2); blit.target_rect.x = FIXED((dest->width - sw) / 2); blit.target_rect.y = FIXED((dest->height - sh) / 2); blit.target_rect.width = blit.source_rect.width; blit.target_rect.height = blit.source_rect.height; CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); CHK(c2dFlush(dest->id, &curTimestamp)); CHK(c2dWaitTimestamp(curTimestamp)); free_pixmap(src); free_pixmap(dest); if (mask) free_pixmap(mask); RD_END(); // dump_pixmap(dest, "copy-%04dx%04d-%08x.bmp", w, h, format); }
void test_composite(uint32_t blend_mode, uint32_t dst_format, uint32_t dst_width, uint32_t dst_height, uint32_t src_format, uint32_t src_width, uint32_t src_height, uint32_t mask_format, uint32_t mask_width, uint32_t mask_height, uint32_t src_x, uint32_t src_y, uint32_t mask_x, uint32_t mask_y, uint32_t dst_x, uint32_t dst_y, uint32_t w, uint32_t h) { PixmapPtr src, dest, mask = NULL; C2D_OBJECT blit = {}; c2d_ts_handle curTimestamp; DEBUG_MSG("composite2: blend_mode:%08x, dst_format:%08x, dst_width:%x, dst_height=%x, " "src_format:%08x, src_width:%x, src_height:%x, " "mask_format:%08x, mask_width:%x, mask_height:%x, " "src_x:%x, src_y:%x, mask_x:%x, mask_y:%x, dst_x:%x, dst_y:%x, w:%x, h:%x", blend_mode, dst_format, dst_width, dst_height, src_format, src_width, src_height, mask_format, mask_width, mask_height, src_x, src_y, mask_x, mask_y, dst_x, dst_y, w, h); RD_START("composite2","blend_mode:%08x, dst_format:%08x, dst_width:%x, dst_height=%x, " "src_format:%08x, src_width:%x, src_height:%x, " "mask_format:%08x, mask_width:%x, mask_height:%x, " "src_x:%x, src_y:%x, mask_x:%x, mask_y:%x, dst_x:%x, dst_y:%x, w:%x, h:%x", blend_mode, dst_format, dst_width, dst_height, src_format, src_width, src_height, mask_format, mask_width, mask_height, src_x, src_y, mask_x, mask_y, dst_x, dst_y, w, h); blit.config_mask = DEFAULT_BLEND_MASK | blend_mode; dest = create_pixmap(dst_width, dst_height, dst_format); src = create_pixmap(src_width, src_height, src_format); blit.config_mask |= C2D_SOURCE_RECT_BIT; blit.surface_id = src->id; if (mask_format) { /* TODO not clear if mask repeat is really supported.. msm-exa-c2d2.c * seems to reject it but C2D_MASK_TILE_BIT?? * * Also, for src format, msm-exa-c2d2.c seems to encode fgcolor (like * a solid fill) for repeats.. not really clear if TILE_BIT does what * we expect or not?? * * Seems like libC2D2 doesn't actually give any way to specify the * maskX/maskY!!! The previous c2d API does, so I'd have to assume * this is actually supported by the hardware and this is just C2D2 * retardation */ mask = create_pixmap(mask_width, mask_height, mask_format); blit.config_mask |= C2D_MASK_SURFACE_BIT; blit.mask_surface_id = mask->id; } blit.next = NULL; blit.source_rect.x = FIXED(src_x); blit.source_rect.y = FIXED(src_y); blit.source_rect.width = FIXED(w); blit.source_rect.height = FIXED(h); blit.target_rect.x = FIXED(dst_x); blit.target_rect.y = FIXED(dst_y); blit.target_rect.width = FIXED(w); blit.target_rect.height = FIXED(h); CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); CHK(c2dFlush(dest->id, &curTimestamp)); CHK(c2dWaitTimestamp(curTimestamp)); free_pixmap(src); free_pixmap(dest); if (mask) free_pixmap(mask); RD_END(); // dump_pixmap(dest, "copy-%04dx%04d-%08x.bmp", w, h, format); }
void test_multi(void) { PixmapPtr src, dest; C2D_OBJECT blit = {}; C2D_RECT rect; c2d_ts_handle curTimestamp; uint32_t w = 1920, h = 1080, format = xRGB; int i; DEBUG_MSG("multi: %04dx%04d-%08x", w, h, format); RD_START("multi", "%dx%d format:%08x", w, h, format); dest = create_pixmap(w, h, format); src = create_pixmap(w, h, format); for (i = 0; i < 200; i++ ) { rect.x = 1; rect.y = 2; rect.width = w - 2; rect.height = h - 3; CHK(c2dFillSurface(dest->id, 0xff556677, &rect)); CHK(c2dFillSurface(dest->id, 0xff556677, &rect)); CHK(c2dFillSurface(dest->id, 0xff556677, &rect)); CHK(c2dFillSurface(dest->id, 0xff556677, &rect)); CHK(c2dFillSurface(dest->id, 0xff556677, &rect)); CHK(c2dFillSurface(dest->id, 0xff556677, &rect)); CHK(c2dFillSurface(dest->id, 0xff556677, &rect)); CHK(c2dFillSurface(dest->id, 0xff556677, &rect)); rect.x = 0; rect.y = 0; rect.width = 13; rect.height = 17; CHK(c2dFillSurface(src->id, 0xff223344, &rect)); CHK(c2dFillSurface(src->id, 0xff223344, &rect)); CHK(c2dFillSurface(src->id, 0xff223344, &rect)); CHK(c2dFillSurface(src->id, 0xff223344, &rect)); CHK(c2dFillSurface(src->id, 0xff223344, &rect)); CHK(c2dFillSurface(src->id, 0xff223344, &rect)); CHK(c2dFillSurface(src->id, 0xff223344, &rect)); CHK(c2dFillSurface(src->id, 0xff223344, &rect)); blit.surface_id = src->id; blit.config_mask = DEFAULT_BLIT_MASK; blit.next = NULL; blit.source_rect.x = FIXED(1); blit.source_rect.y = FIXED(2); blit.source_rect.width = FIXED(13-2); blit.source_rect.height = FIXED(17-4); blit.target_rect.x = FIXED((w - 13) / 2); blit.target_rect.y = FIXED((h - 17) / 2); blit.target_rect.width = blit.source_rect.width; blit.target_rect.height = blit.source_rect.height; CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); // well, identical copy twice is fine, and I'm lazy: CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); CHK(c2dDraw(dest->id, 0, NULL, 0, 0, &blit, 1)); CHK(c2dFlush(dest->id, &curTimestamp)); if (!(i % 16)) CHK(c2dWaitTimestamp(curTimestamp)); } free_pixmap(src); free_pixmap(dest); RD_END(); }