#endif
#include <png.h>
-#include <string.h>
-#include <tbm_surface.h>
-#include <tbm_surface_internal.h>
-#include <tbm_drm_helper.h>
-#include <string.h>
-#include <time.h>
#include <pixman.h>
-#include <inttypes.h>
-#include "tdm.h"
#include "tdm_private.h"
-#include "tdm_helper.h"
#define PNG_DEPTH 8
}
static int
-_tdm_helper_check_file_is_valid(const char* path, int del_link)
+_tdm_helper_check_file_is_symbolic_link(const char* path)
{
- char *real_path;
+ struct stat sb;
if (!path)
return 0;
- real_path = realpath(path, NULL);
- if (real_path && strncmp(path, real_path, strlen(path))) {
- if (del_link)
- unlink(path);
- free(real_path);
-
+ if (stat(path, &sb) != 0)
return 0;
- }
- if (real_path)
- free(real_path);
+ if (S_ISLNK(sb.st_mode))
+ return 1;
- return 1;
+ return 0;
}
static void
unsigned int *blocks;
FILE *fp;
- if (!_tdm_helper_check_file_is_valid(file, 1))
- TDM_WRN("'%s' may be symbolic link\n", file);
+ if (_tdm_helper_check_file_is_symbolic_link(file)) {
+ TDM_ERR("'%s' may be symbolic link\n", file);
+ return;
+ }
fp = fopen(file, "w+");
TDM_RETURN_IF_FAIL(fp != NULL);
{
FILE *fp;
- if (!_tdm_helper_check_file_is_valid(file, 1))
- TDM_WRN("'%s' may be symbolic link\n", file);
+ if (_tdm_helper_check_file_is_symbolic_link(file)) {
+ TDM_ERR("'%s' may be symbolic link\n", file);
+ return;
+ }
fp = fopen(file, "wb");
TDM_RETURN_IF_FAIL(fp != NULL);
fclose(fp);
}
+/* LCOV_EXCL_START */
INTERN char *
tdm_helper_dump_make_directory(const char *path, char *reply, int *len)
{
return NULL;
}
-INTERN void
+EXTERN void
tdm_helper_dump_buffer_str(tbm_surface_h buffer, char *dir, char *str)
{
tbm_surface_info_s info;
- const char *ext;
char file[TDM_PATH_LEN];
int ret, bw, bh;
TDM_RETURN_IF_FAIL(buffer != NULL);
- TDM_RETURN_IF_FAIL(dir != NULL);
TDM_RETURN_IF_FAIL(str != NULL);
+ if (!dir)
+ dir = ".";
+
ret = tbm_surface_get_info(buffer, &info);
TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE);
- if (IS_RGB(info.format))
- ext = file_exts[0];
- else
- ext = file_exts[1];
-
tdm_helper_get_buffer_full_size(buffer, &bw, &bh);
- snprintf(file, TDM_PATH_LEN, "%s/%c%c%c%c_%dx%d_%dx%d_%s.%s",
- dir, FOURCC_STR(info.format), bw, bh, info.width, info.height, str, ext);
+ snprintf(file, TDM_PATH_LEN, "%s/%c%c%c%c_%dx%d_%dx%d_%s",
+ dir, FOURCC_STR(info.format), bw, bh, info.width, info.height, str);
tdm_helper_dump_buffer(buffer, file);
}
+/* LCOV_EXCL_STOP */
EXTERN void
tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file)
{
+ char temp[TDM_PATH_LEN] = {0,};
tbm_surface_info_s info;
int len, ret;
const char *ext;
int bo_cnt;
int bw, bh;
+ char *dot, *p = temp;
TDM_RETURN_IF_FAIL(buffer != NULL);
TDM_RETURN_IF_FAIL(file != NULL);
ret = tbm_surface_map(buffer, TBM_OPTION_READ, &info);
TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE);
- len = strnlen(file, 1024);
if (IS_RGB(info.format))
ext = file_exts[0];
else
ext = file_exts[1];
- if (strncmp(file + (len - 3), ext, 3)) {
- TDM_ERR("can't dump to '%s' file", file + (len - 3));
- tbm_surface_unmap(buffer);
- return;
+ dot = strrchr(file, '.');
+ if (!dot || strlen(dot + 1) != 3 || strncmp(dot + 1, ext, 3)) {
+ len = strnlen(file, TDM_PATH_LEN - 5);
+ strncat(p, file, len);
+ p += len;
+ *(p++) = '.';
+ strncat(p, ext, 3);
+ p += 3;
+ *p = '\0';
}
tdm_helper_get_buffer_full_size(buffer, &bw, &bh);
switch (info.format) {
case TBM_FORMAT_ARGB8888:
case TBM_FORMAT_XRGB8888:
- _tdm_helper_dump_png(file, info.planes[0].ptr, bw, bh);
+ _tdm_helper_dump_png(temp, info.planes[0].ptr, bw, bh);
break;
case TBM_FORMAT_YVU420:
case TBM_FORMAT_YUV420:
- _tdm_helper_dump_raw(file,
+ _tdm_helper_dump_raw((const char*)temp,
info.planes[0].ptr,
info.planes[0].size,
info.planes[1].ptr,
break;
case TBM_FORMAT_NV12:
case TBM_FORMAT_NV21:
- _tdm_helper_dump_raw(file,
+ _tdm_helper_dump_raw((const char*)temp,
info.planes[0].ptr,
info.planes[0].size,
info.planes[1].ptr,
break;
case TBM_FORMAT_YUYV:
case TBM_FORMAT_UYVY:
- _tdm_helper_dump_raw(file,
+ _tdm_helper_dump_raw((const char*)temp,
info.planes[0].ptr,
info.planes[0].size, NULL, 0,
NULL, 0);
tbm_surface_unmap(buffer);
- TDM_INFO("dump %s", file);
+ TDM_INFO("dump %s", temp);
}
EXTERN void
return ret;
}
+/* LCOV_EXCL_START */
EXTERN int
tdm_helper_get_fd(const char *env)
{
tbm_drm_helper_set_tbm_master_fd(fd);
}
+/* LCOV_EXCL_STOP */
EXTERN void
tdm_helper_dump_start(char *dumppath, int *count)
TDM_DBG("tdm_helper_dump stop.");
}
+/* LCOV_EXCL_START */
static tdm_error
_tdm_helper_buffer_convert(tbm_surface_h srcbuf, tbm_surface_h dstbuf,
int dx, int dy, int dw, int dh, int count)
return TDM_ERROR_OPERATION_FAILED;
}
+/* LCOV_EXCL_STOP */
+
EXTERN tdm_error
tdm_helper_capture_output(tdm_output *output, tbm_surface_h dst_buffer,
TDM_RETURN_VAL_IF_FAIL(w >= 0, TDM_ERROR_INVALID_PARAMETER);
TDM_RETURN_VAL_IF_FAIL(h >= 0, TDM_ERROR_INVALID_PARAMETER);
TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER);
- TDM_RETURN_VAL_IF_FAIL(data != NULL, TDM_ERROR_INVALID_PARAMETER);
err = tdm_output_get_layer_count(output, &count);
if (err != TDM_ERROR_NONE) {
TDM_SNPRINTF(reply, len, "\n");
}
+/* LCOV_EXCL_START */
EXTERN int
tdm_helper_commit_per_vblank_enabled(tdm_display *dpy)
{
- tdm_private_display *private_display;
+ TDM_ERR("the deprecated function, use 'tdm_helper_output_commit_per_vblank_enabled' instead.");
- TDM_RETURN_VAL_IF_FAIL(dpy != NULL, 0);
+ return 0;
+}
+/* LCOV_EXCL_STOP */
- private_display = dpy;
+EXTERN int
+tdm_helper_output_commit_per_vblank_enabled(tdm_output *output)
+{
+ tdm_private_output *private_output = output;
+
+ TDM_RETURN_VAL_IF_FAIL(private_output != NULL, -1);
- return private_display->commit_per_vblank;
+ return !!private_output->commit_per_vblank;
}