Add libshared static library 51/283251/1
authorSeunghun Lee <shiin.lee@samsung.com>
Thu, 15 Sep 2022 05:34:10 +0000 (14:34 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Fri, 21 Oct 2022 02:27:55 +0000 (11:27 +0900)
The libshared library is to be used for shared functionalities.
For now, it only provides converting pixel format functionality for both
tbm_server and video implementation, but it will be expanded as needed.
Video implementation will use it in a future patch.

Change-Id: I94d7cd6479abbdcc4e0860fb41c878b96ac9296e

meson.build
src/meson.build
src/shared/meson.build [new file with mode: 0644]
src/shared/pixel_format.c [new file with mode: 0644]
src/shared/pixel_format.h [new file with mode: 0644]
src/tbm_server/meson.build
src/tbm_server/pixel_format.c [deleted file]
src/tbm_server/pixel_format.h [deleted file]
src/tbm_server/tbm_server.c

index d6804fe02e83a3beacaff01d7467bb0e8d9fd7b9..5446b2596b134745fbf113812efe1c1a3578a259 100644 (file)
@@ -19,7 +19,6 @@ dir_prefix = get_option('prefix')
 libds_tizen_bindir = join_paths(dir_prefix, get_option('bindir'))
 
 libds_tizen_inc = include_directories('include')
-common_inc = [ include_directories('.'), libds_tizen_inc ]
 
 cdata = configuration_data()
 cdata.set('LIBDS_VERSION_MAJOR', libds_tizen_version_major)
index f067865ce8b4eeddc12bdee929171301d52a9442..23fd5c073705da4ce6a991d9cc3295b316c147dd 100644 (file)
@@ -1,3 +1,5 @@
+common_inc = [ include_directories('.'), libds_tizen_inc ]
+
 math = meson.get_compiler('c').find_library('m')
 wayland_server = dependency('wayland-server', required: true)
 rt = meson.get_compiler('c').find_library('rt')
@@ -11,10 +13,12 @@ deps_base = [
   rt,
 ]
 
+dep_libds = dependency('libds', required: true)
+
 deps_libds_tizen = [
   deps_base,
   wayland_server,
-  dependency('libds', required: true),
+  dep_libds,
 ]
 
 tizen_security_files = [
@@ -27,6 +31,7 @@ deps_tizen_security = [
   dependency('libsmack', required: true)
 ]
 
+subdir('shared')
 subdir('allocator')
 subdir('tbm_server')
 subdir('backend')
diff --git a/src/shared/meson.build b/src/shared/meson.build
new file mode 100644 (file)
index 0000000..c7550ec
--- /dev/null
@@ -0,0 +1,22 @@
+libshared_srcs = [
+  'pixel_format.c',
+]
+
+libshared_deps = [
+  dep_libds,
+  dependency('libdrm', required: true),
+  dependency('libtbm', required: true),
+]
+
+lib_libshared = static_library(
+  'shared',
+  libshared_srcs,
+  dependencies: libshared_deps,
+  pic: true,
+  install: false,
+)
+
+dep_libshared = declare_dependency(
+  link_with: lib_libshared,
+  dependencies: libshared_deps,
+)
diff --git a/src/shared/pixel_format.c b/src/shared/pixel_format.c
new file mode 100644 (file)
index 0000000..030f211
--- /dev/null
@@ -0,0 +1,61 @@
+#include <inttypes.h>
+#include <drm_fourcc.h>
+#include <tbm_type.h>
+
+#include <libds/log.h>
+#include "pixel_format.h"
+
+#ifdef ARRAY_LENGTH
+#undef ARRAY_LENGTH
+#endif
+
+#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
+
+struct ds_tbm_format
+{
+    uint32_t drm_format;
+    uint32_t tbm_format;
+};
+
+static const struct ds_tbm_format formats[] =
+{
+    {
+        .drm_format = DRM_FORMAT_ARGB8888,
+        .tbm_format = TBM_FORMAT_ARGB8888,
+    },
+    {
+        .drm_format = DRM_FORMAT_XRGB8888,
+        .tbm_format = TBM_FORMAT_XRGB8888,
+    },
+    /* TODO more format */
+};
+
+uint32_t
+convert_drm_format_to_tbm(uint32_t fmt)
+{
+    size_t i;
+
+    for (i = 0; i < ARRAY_LENGTH(formats); i++) {
+        if (formats[i].drm_format == fmt)
+            return formats[i].tbm_format;
+    }
+
+    ds_err("DRM format 0x%"PRIX32" has no TBM equivalent", fmt);
+
+    return 0;
+}
+
+uint32_t
+convert_tbm_format_to_drm(uint32_t fmt)
+{
+    size_t i;
+
+    for (i = 0; i < ARRAY_LENGTH(formats); i++) {
+        if (formats[i].tbm_format == fmt)
+            return formats[i].drm_format;
+    }
+
+    ds_err("TBM format 0x%"PRIX32" has no DRM equivalent", fmt);
+
+    return 0;
+}
diff --git a/src/shared/pixel_format.h b/src/shared/pixel_format.h
new file mode 100644 (file)
index 0000000..a63d096
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef DS_TIZEN_PIXEL_FORMAT_H
+#define DS_TIZEN_PIXEL_FORMAT_H
+
+#include <stdint.h>
+
+uint32_t convert_drm_format_to_tbm(uint32_t fmt);
+
+uint32_t convert_tbm_format_to_drm(uint32_t fmt);
+
+#endif
index 795576aa74da03e521f959564de2a461d3f7f3cf..e41528f163c5931c1262b85009a8377e58262ec5 100644 (file)
@@ -1,11 +1,10 @@
 libds_tizen_tbm_server_files = [
-  'pixel_format.c',
   'tbm_server.c',
 ]
 
 libds_tizen_tbm_server_deps = [
   deps_libds_tizen,
-  dependency('libdrm', required: true),
+  dep_libshared,
   dependency('libtbm', required: true),
   dependency('wayland-tbm-server', required: true),
 ]
diff --git a/src/tbm_server/pixel_format.c b/src/tbm_server/pixel_format.c
deleted file mode 100644 (file)
index 030f211..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-#include <inttypes.h>
-#include <drm_fourcc.h>
-#include <tbm_type.h>
-
-#include <libds/log.h>
-#include "pixel_format.h"
-
-#ifdef ARRAY_LENGTH
-#undef ARRAY_LENGTH
-#endif
-
-#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
-
-struct ds_tbm_format
-{
-    uint32_t drm_format;
-    uint32_t tbm_format;
-};
-
-static const struct ds_tbm_format formats[] =
-{
-    {
-        .drm_format = DRM_FORMAT_ARGB8888,
-        .tbm_format = TBM_FORMAT_ARGB8888,
-    },
-    {
-        .drm_format = DRM_FORMAT_XRGB8888,
-        .tbm_format = TBM_FORMAT_XRGB8888,
-    },
-    /* TODO more format */
-};
-
-uint32_t
-convert_drm_format_to_tbm(uint32_t fmt)
-{
-    size_t i;
-
-    for (i = 0; i < ARRAY_LENGTH(formats); i++) {
-        if (formats[i].drm_format == fmt)
-            return formats[i].tbm_format;
-    }
-
-    ds_err("DRM format 0x%"PRIX32" has no TBM equivalent", fmt);
-
-    return 0;
-}
-
-uint32_t
-convert_tbm_format_to_drm(uint32_t fmt)
-{
-    size_t i;
-
-    for (i = 0; i < ARRAY_LENGTH(formats); i++) {
-        if (formats[i].tbm_format == fmt)
-            return formats[i].drm_format;
-    }
-
-    ds_err("TBM format 0x%"PRIX32" has no DRM equivalent", fmt);
-
-    return 0;
-}
diff --git a/src/tbm_server/pixel_format.h b/src/tbm_server/pixel_format.h
deleted file mode 100644 (file)
index a63d096..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef DS_TIZEN_PIXEL_FORMAT_H
-#define DS_TIZEN_PIXEL_FORMAT_H
-
-#include <stdint.h>
-
-uint32_t convert_drm_format_to_tbm(uint32_t fmt);
-
-uint32_t convert_tbm_format_to_drm(uint32_t fmt);
-
-#endif
index 3ae411d04f408cf77df8fc757c1288639135603c..28ec9b57019bba147a4217b43f9f10688627ef39 100644 (file)
@@ -5,7 +5,7 @@
 #include <tbm_bufmgr.h>
 
 #include <libds/log.h>
-#include "pixel_format.h"
+#include "shared/pixel_format.h"
 #include "tbm_server.h"
 
 static const struct ds_buffer_resource_interface tbm_buffer_resource_iface;