+ return 0;
+}
+
+EXTERN tdm_error
+tdm_helper_convert_buffer(tbm_surface_h srcbuf, tbm_surface_h dstbuf,
+ tdm_pos *srcpos, tdm_pos *dstpos,
+ tdm_transform transform, int over)
+{
+ tbm_surface_info_s src_info, dst_info;
+ pixman_image_t *src_img = NULL, *dst_img = NULL;
+ pixman_format_code_t src_format, dst_format;
+ double scale_x, scale_y;
+ int rotate_step, bos;
+ pixman_transform_t t;
+ struct pixman_f_transform ft;
+ pixman_op_t op;
+ int src_stride, dst_stride;
+ int buf_width, err;
+ tdm_error ret = TDM_ERROR_OPERATION_FAILED;
+
+ TDM_RETURN_VAL_IF_FAIL(srcbuf != NULL, TDM_ERROR_INVALID_PARAMETER);
+ TDM_RETURN_VAL_IF_FAIL(dstbuf != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+ bos = tbm_surface_internal_get_num_bos(srcbuf);
+ TDM_RETURN_VAL_IF_FAIL(bos == 1, TDM_ERROR_OPERATION_FAILED);
+
+ bos = tbm_surface_internal_get_num_bos(dstbuf);
+ TDM_RETURN_VAL_IF_FAIL(bos == 1, TDM_ERROR_OPERATION_FAILED);
+
+ err = tbm_surface_map(srcbuf, TBM_OPTION_READ, &src_info);
+ TDM_RETURN_VAL_IF_FAIL(err == TBM_SURFACE_ERROR_NONE, TDM_ERROR_OPERATION_FAILED);
+
+ err = tbm_surface_map(dstbuf, TBM_OPTION_WRITE, &dst_info);
+ TDM_GOTO_IF_FAIL(err == TBM_SURFACE_ERROR_NONE, unmap_srcbuf);
+
+ /* not handle buffers which have 2 more gem handles */
+ TDM_GOTO_IF_FAIL(src_info.planes[0].ptr != NULL, unmap_dstbuf);
+ TDM_GOTO_IF_FAIL(dst_info.planes[0].ptr != NULL, unmap_dstbuf);
+
+ src_format = _tdm_helper_pixman_format_get(src_info.format);
+ TDM_GOTO_IF_FAIL(src_format > 0, unmap_dstbuf);
+ dst_format = _tdm_helper_pixman_format_get(dst_info.format);
+ TDM_GOTO_IF_FAIL(dst_format > 0, unmap_dstbuf);
+
+ buf_width = src_info.planes[0].stride >> 2;
+ src_stride = src_info.planes[0].stride;
+ src_img = pixman_image_create_bits(src_format, buf_width, src_info.height,
+ (uint32_t*)src_info.planes[0].ptr, src_stride);
+ TDM_GOTO_IF_FAIL(src_img, unref_img);
+
+ buf_width = dst_info.planes[0].stride >> 2;
+ dst_stride = dst_info.planes[0].stride;
+ dst_img = pixman_image_create_bits(dst_format, buf_width, dst_info.height,
+ (uint32_t*)dst_info.planes[0].ptr, dst_stride);
+ TDM_GOTO_IF_FAIL(dst_img, unref_img);
+
+ pixman_f_transform_init_identity(&ft);
+
+ if (transform & TDM_TRANSFORM_FLIPPED) {
+ pixman_f_transform_scale(&ft, NULL, -1, 1);
+ pixman_f_transform_translate(&ft, NULL, dstpos->w, 0);