From fb6dfe64b87a30e95f3ee059da9fd01e800fa8d2 Mon Sep 17 00:00:00 2001 From: Hoyub Lee Date: Mon, 27 Feb 2017 16:09:56 +0900 Subject: [PATCH 01/16] tc: Fix bug on tpl_test_parse_arguments() Change-Id: Iab6a48c4b6be05eb53befede02b67893f595b0bd Signed-off-by: Hoyub Lee --- tc/src/main.cpp | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/tc/src/main.cpp b/tc/src/main.cpp index cab1b30..e9c9b1c 100644 --- a/tc/src/main.cpp +++ b/tc/src/main.cpp @@ -53,27 +53,25 @@ tpl_test_parse_arguments(int argc, char **argv) // Parse arguments int opt; - do { - opt = getopt_long_only(argc, argv, "", longopts, NULL); - + while ((opt = getopt_long_only(argc, argv, "", longopts, NULL)) != -1) { if (opt == 'h') { tpl_test_print_help(); return config; + } else if (opt_width == 1) { + printf("Width set: %s\n", optarg); + config.width = atoi(optarg); + opt_width = 0; + } else if (opt_height == 1) { + printf("Height set: %s\n", optarg); + config.height = atoi(optarg); + opt_height = 0; + } else if (opt_depth == 1) { + printf("Depth set: %s\n", optarg); + config.depth = atoi(optarg); + opt_depth = 0; + } else { + break; } - } while (opt != -1 && opt != '?'); - - // Set Config - if (opt_width == 1) { - printf("width set: %s\n", optarg); - config.width = atoi(optarg); - } - if (opt_height == 1) { - printf("height set: %s\n", optarg); - config.height = atoi(optarg); - } - if (opt_depth == 1) { - printf("depth set: %s\n", optarg); - config.depth = atoi(optarg); } return config; -- 2.7.4 From 43b1d090b3aaf0d5297e77f0d11540062c498608 Mon Sep 17 00:00:00 2001 From: Hoyub Lee Date: Wed, 1 Feb 2017 18:29:50 +0900 Subject: [PATCH 02/16] tc: Change build process not to use spec file Change the build process as follows: - Removes tpl-test.spec which was used for building tpl-test which could leads buggy behaviour in binary build process. - Instead, all build processes are done with libtpl-egl.spec and tc/Makefile. ------------------------------------ (Changed) tpl-test build instruction ------------------------------------ - Build libtpl-egl: $ gbs build -A armv7l - Build libtpl-egl with tpl-test: Change the value of 'ENABLE_TPL_TEST' from 0 to 1 in libtpl-egl.spec. Then, build with [--include-all] flag like below. $ gbs build -A armv7l --include-all Change-Id: I987556c04192009b2143ebcad513a460f13e9ad0 Signed-off-by: Hoyub Lee --- README | 11 ++--- packaging/libtpl-egl.spec | 33 ++++++++++++++- packaging/tpl-test.spec | 101 ---------------------------------------------- tc/Makefile | 84 ++++++++++++++++++++++++++++---------- tc/README | 29 ++++--------- 5 files changed, 107 insertions(+), 151 deletions(-) delete mode 100644 packaging/tpl-test.spec diff --git a/README b/README index 56527b2..00672c6 100644 --- a/README +++ b/README @@ -5,11 +5,12 @@ GBS Build Instruction --------------------- - Build libtpl-egl: - $ gbs build -A armv7l --spec=libtpl-egl.spec + $ gbs build -A armv7l -- Build tpl-test: - $ gbs build -A armv7l --spec=tpl-test.spec +- Build libtpl-egl with tpl-test: + Change the value of 'ENABLE_TPL_TEST' from 0 to 1 in libtpl-egl.spec + Then, build like below + + $ gbs build -A armv7l --include-all -- Build all: - $ gbs build -A armv7l diff --git a/packaging/libtpl-egl.spec b/packaging/libtpl-egl.spec index fabb59a..286cbf6 100644 --- a/packaging/libtpl-egl.spec +++ b/packaging/libtpl-egl.spec @@ -14,6 +14,10 @@ %define ENABLE_DEFAULT_LOG 0 %define ENABLE_DEFAULT_DUMP 0 %define ENABLE_OBJECT_HASH_CHECK 1 + +#TPL INSTALL OPTION +%define ENABLE_TPL_TEST 0 + #WAYLAND-EGL VERSION MACROS %define WL_EGL_VERSION 1.0.0 @@ -42,7 +46,8 @@ Summary: Tizen Porting Layer for EGL (DRI3 backend) Summary: Tizen Porting Layer for EGL (Wayland backend) %endif Group: Graphics & UI Framework/GL -License: MIT +# The entire source code is MIT except tc/libs/gtest/ which is BSD-3-Clause +License: MIT and BSD-3-Clause Source: %{name}-%{version}.tar.gz BuildRequires: cmake @@ -179,6 +184,13 @@ make cd ../../ %endif +#tpl-test build +%if "%{ENABLE_TPL_TEST}" == "1" +cd tc/ +make +cd ../ +%endif + #pkgconfig configure cd pkgconfig cmake . @@ -221,6 +233,16 @@ cd src/wayland-vulkan cd - %endif +#tpl-test install +%if "%{ENABLE_TPL_TEST}" == "1" +mkdir -p %{buildroot}/opt/usr/tpl-test +cp -arp ./tc/tpl-test %{buildroot}/opt/usr/tpl-test + +# License of Google Test which is BSD-3-Clause +mkdir -p %{buildroot}/%{TZ_SYS_RO_SHARE}/license +cp -a %{_builddir}/%{buildsubdir}/tc/libs/gtest/googletest/LICENSE %{buildroot}/%{TZ_SYS_RO_SHARE}/license/googletest +%endif + %post -p /sbin/ldconfig %postun -p /sbin/ldconfig @@ -238,6 +260,15 @@ cd - %{_libdir}/libtpl-egl.so.%{TPL_VERSION} %{_libdir}/libtpl-egl.so.%{TPL_VER_FULL} +#tpl-test files +%if "%{ENABLE_TPL_TEST}" == "1" +%dir /opt/usr/tpl-test/ +/opt/usr/tpl-test/tpl-test + +# License of Google Test which is BSD-3-Clause +%{TZ_SYS_RO_SHARE}/license/googletest +%endif + %files devel %defattr(-,root,root,-) %{_includedir}/tpl.h diff --git a/packaging/tpl-test.spec b/packaging/tpl-test.spec deleted file mode 100644 index 30f0b52..0000000 --- a/packaging/tpl-test.spec +++ /dev/null @@ -1,101 +0,0 @@ -Name: tpl-test -Version: 0.3.0 -Release: 0 -Summary: TPL Test Module - -Group: Graphics & UI Framework/GL - -# The entire source code is MIT except tc/libs/gtest/ which is BSD-3-Clause -License: MIT and BSD-3-Clause -Source0: %{name}-%{version}.tar.gz - -BuildRequires: pkgconfig(libtbm) -BuildRequires: pkgconfig(gbm) -BuildRequires: pkgconfig(wayland-client) -BuildRequires: pkgconfig(tpl-egl) -BuildRequires: cmake - -%global TZ_SYS_RO_SHARE %{?TZ_SYS_RO_SHARE:%TZ_SYS_RO_SHARE}%{!?TZ_SYS_RO_SHARE:/usr/share} - - -%description -Test module for testing libtpl-egl frontend APIs - - -%prep -%setup -q - - -%build -###### Setup variables for build ###### -export BUILD_DIR="%{_builddir}/%{buildsubdir}" -export GTEST_DIR="${BUILD_DIR}/tc/libs/gtest" - -export GTEST_INCLUDE="-I${GTEST_DIR}/googletest -I${GTEST_DIR}/googletest/include \ - -I${GTEST_DIR}/googlemock -I${GTEST_DIR}/googlemock/include" -export GTEST_FLAGS="-g -Wall -Wextra -pthread" - -export GTEST_LIB_PATH="${GTEST_DIR}/build/gtest/libgtest.a" # googletest output path -export GMOCK_LIB_PATH="${GTEST_DIR}/build/libgmock.a" # googlemock output path - -export BIN_NAME="tpl-test" - - -##### Build Google Test Framework ##### -mkdir ${GTEST_DIR}/build -cd ${GTEST_DIR}/build -cmake ../googlemock -make - -##### Build tpl-test using libgtest.a ###### -cd ${BUILD_DIR}/tc/ -make - - -%pre -if [ "$1" -eq 1 ]; then -echo "Initial installation" - # Perform tasks to prepare for the initial installation -elif [ "$1" -eq 2 ]; then - # Perform whatever maintenance must occur before the upgrade begins -rm -rf /opt/usr/tpl-test -fi - - -%install -##### Install Binary ##### -mkdir -p %{buildroot}/opt/usr/tpl-test -cp -arp ./tc/tpl-test %{buildroot}/opt/usr/tpl-test - -##### Licenses ##### -mkdir -p %{buildroot}/%{TZ_SYS_RO_SHARE}/license -# MIT -cp -a %{_builddir}/%{buildsubdir}/COPYING %{buildroot}/%{TZ_SYS_RO_SHARE}/license/%{name} -# BSD-3-Clause -cp -a %{_builddir}/%{buildsubdir}/tc/libs/gtest/googletest/LICENSE %{buildroot}/%{TZ_SYS_RO_SHARE}/license/googletest - - -%post -/opt/usr/tpl-test/tpl-test --gtest_filter=TPL* -if [ "$?" -eq 0 ]; then -echo "Verification of libtpl-egl has been successfully done." -else -echo "Verification of libtpl-egl has been failed." -fi - - -%clean -rm -rf %{buildroot} - - -%files -%defattr(-,root,root,-) -##### Binary Files ##### -%dir /opt/usr/tpl-test/ -/opt/usr/tpl-test/* - -##### Licenses ###### -# MIT -%{TZ_SYS_RO_SHARE}/license/%{name} -# BSD-3-Clause -%{TZ_SYS_RO_SHARE}/license/googletest diff --git a/tc/Makefile b/tc/Makefile index 5c8a5e3..938ec88 100644 --- a/tc/Makefile +++ b/tc/Makefile @@ -2,40 +2,80 @@ ##### Makefile to build tpl-test using libgtest.a ##### ####################################################### -# Following variables will be exported from spec file -# -# GTEST_LIB_PATH -# GMOCK_LIB_PATH -# GTEST_INCLUDE -# GTEST_FLAGS -# BIN_NAME - -##### Libraries ##### -LD_FLAGS = -lm -lrt -lpthread -ltpl-egl -lwayland-client -lwayland-egl -CPPFLAGS += -I./ - -##### tpl-test srcs ##### +BIN_NAME := tpl-test + +CXX ?= g++ + + +########## Helper Functions ########## +#$(call is-feature-enabled,featurename) +#returns non-empty string if enabled, empty if not +define is-feature-enabled +$(findstring -$1-,-$(TPL_OPTIONS)-) +endef + + +########## Build Environments ########## +TC_DIR := $(shell pwd) + +TC_CXXFLAGS = +TC_LDFLAGS = + +# src include +TC_CXXFLAGS += -I./ +TC_CXXFLAGS += -I../src/ + +# gtest +GTEST_DIR := $(TC_DIR)/libs/gtest +GTEST_INCLUDE := -I$(GTEST_DIR)/googletest -I$(GTEST_DIR)/googletest/include \ + -I$(GTEST_DIR)/googlemock -I$(GTEST_DIR)/googlemock/include +GTEST_FLAGS := -g -Wall -pthread +GTEST_LIB_PATH := $(GTEST_DIR)/build/gtest/libgtest.a # googletest output path +GMOCK_LIB_PATH := $(GTEST_DIR)/build/libgmock.a # googlemock output path + +# libtpl-egl, libwayland-egl +TPL_LIB_PATH = ../libtpl-egl.so.$(TPL_VER_MAJOR).$(TPL_VER_MINOR).$(TPL_RELEASE) +WAYLAND_EGL_OBJ_PATH = ../src/wayland-egl/wayland-egl.o + + +########## Backend Setup ########## +ifneq ($(call is-feature-enabled,winsys_wl),) + TC_CXXFLAGS += `pkg-config --cflags gbm libtdm-client` + TC_LDFLAGS += `pkg-config --libs gbm wayland-tbm-client wayland-tbm-server libtdm-client` +endif + + +########## tpl-test srcs ########## SRCS = $(wildcard src/*.cpp) SRCS += $(wildcard mocked/*.cpp) HEADERS = $(wildcard src/*.h) HEADERS += $(wildcard mocked/*.h) -##### tpl-test test cases srcs ##### -TESTS = $(wildcard test/*.cpp) + +########## tpl-test test cases srcs ########## +TESTS = $(wildcard test/*.cpp) + +OBJS = $(SRCS:%.cpp=%.o) \ + $(TESTS:%.cpp=%.o) \ + $(NULL) -OBJS = $(SRCS:%.cpp=%.o) \ - $(TESTS:%.cpp=%.o) \ - $(NULL) +########## Build Commands ########## +all : gtest $(BIN_NAME) -all : $(BIN_NAME) +gtest : + mkdir $(GTEST_DIR)/build && \ + cd $(GTEST_DIR)/build && \ + cmake ../googlemock && \ + make clean : rm -f $(BIN_NAME) %.o: %.cpp - $(CXX) -c -o $@ $< $(GTEST_INCLUDE) $(GTEST_FLAGS) $(CPPFLAGS) $(LD_FLAGS) + $(CXX) -c -o $@ $< $(GTEST_INCLUDE) $(GTEST_FLAGS) $(TC_CXXFLAGS) $(TC_LDFLAGS) -$(BIN_NAME) : $(OBJS) $(GTEST_LIB_PATH) $(GMOCK_LIB_PATH) - $(CXX) -lpthread $^ -o $@ $(GTEST_FLAGS) $(CPPFLAGS) $(LD_FLAGS) +$(BIN_NAME) : $(OBJS) $(GTEST_LIB_PATH) $(GMOCK_LIB_PATH) $(TPL_LIB_PATH) $(WAYLAND_EGL_OBJ_PATH) + cd ${TC_DIR} && \ + $(CXX) -lpthread $^ -o $@ $(GTEST_FLAGS) $(TC_CXXFLAGS) $(TC_LDFLAGS) diff --git a/tc/README b/tc/README index 421e940..8a1d076 100644 --- a/tc/README +++ b/tc/README @@ -7,39 +7,24 @@ tpl-test is the test module for testing libtpl-egl frontend APIs GBS Build Instruction --------------------- -* Build libtpl-egl: - $ gbs build -A armv7l --spec=libtpl-egl.spec - -* Build tpl-test: - $ gbs build -A armv7l --spec=tpl-test.spec - -* Build all: +- Build libtpl-egl: $ gbs build -A armv7l +- Build libtpl-egl with tpl-test: + Change the value of 'ENABLE_TPL_TEST' from 0 to 1 in libtpl-egl.spec + Then, build like below -Install Instruction -------------------- - -* Install - $ rpm -ivh tpl-test-0.3.0-0.armv7l.rpm - (file name can be different with version change) - - then tpl-test binary file will be installed on - /opt/usr/tpl-test/ - - -* Uninstall - $ rpm -e tpl-test + $ gbs build -A armv7l --include-all Run Tests --------- -* Run +- Run $ cd /opt/usr/tpl-test $ ./tpl-test -* Run with configuration +- Run with configuration $ ./tpl-test --config.width=720 --config.height=1280 --config.depth=24 -- 2.7.4 From 01537ffd26de548c216a6f8dc6253e08a33795b2 Mon Sep 17 00:00:00 2001 From: Hoyub Lee Date: Fri, 16 Dec 2016 10:39:30 +0900 Subject: [PATCH 03/16] tc: Reorganize test cases based on libtpl-egl APIs Reorganize test cases based on the name of libtpl-egl APIs to cover all flows of libtpl-egl APIs. Followings are changed in this patch: - Test cases are organized and renamed with DEFAULT and EXTRA cases. - Most of test cases are renamed with the function name of libtpl-egl APIs, and test name will represent its working flow. example> TEST CASE | TEST ------------------------------------------ DEFAULT_tpl_display_get | success DEFAULT_tpl_display_get | failure_null Change-Id: I86f6e16c75ceeba29b46356ab7d296b281acb934 Signed-off-by: Hoyub Lee --- tc/test/tpl-test_display_test.cpp | 87 ++++++++++++++++++++++++----------- tc/test/tpl-test_object_test.cpp | 97 +++++++++++++++++++++++++++++++++++---- tc/test/tpl-test_surface_test.cpp | 96 +++++++++++++++++++++++++++++++------- 3 files changed, 228 insertions(+), 52 deletions(-) diff --git a/tc/test/tpl-test_display_test.cpp b/tc/test/tpl-test_display_test.cpp index f76f901..923538b 100644 --- a/tc/test/tpl-test_display_test.cpp +++ b/tc/test/tpl-test_display_test.cpp @@ -9,34 +9,45 @@ #include "src/tpl-test_base.h" -class TPLDisplay : public TPLTestBase {}; -class TPLDisplaySupport : public TPLDisplay {}; +typedef TPLTestBase DEFAULT_tpl_display_get; - -// Tests tpl_display_get(tpl_handle_t) -TEST_F(TPLDisplay, tpl_display_get) +TEST_F(DEFAULT_tpl_display_get, success) { tpl_display_t *tpl_display = tpl_display_get(backend->display_handle); - ASSERT_EQ(tpl_display, backend->tpl_display); + ASSERT_EQ(backend->tpl_display, tpl_display); +} + +TEST_F(DEFAULT_tpl_display_get, failure_null) +{ + tpl_display_t *tpl_display = tpl_display_get(NULL); + + ASSERT_EQ((void *)NULL, tpl_display); } -// Tests tpl_display_get_native_handle(tpl_handle_t) -TEST_F(TPLDisplay, tpl_display_get_native_handle) +typedef TPLTestBase DEFAULT_tpl_display_get_native_handle; + +TEST_F(DEFAULT_tpl_display_get_native_handle, success) { tpl_handle_t display_handle = tpl_display_get_native_handle(backend->tpl_display); - ASSERT_EQ(display_handle, backend->display_handle); + ASSERT_EQ(backend->display_handle, display_handle); } +TEST_F(DEFAULT_tpl_display_get_native_handle, failure_invalid_display) +{ + tpl_handle_t display_handle = + tpl_display_get_native_handle(NULL); -// Tests tpl_display_query_config(...) -// -// 1. Tests with normal cases -// 2. Tests with abnormal case -TEST_F(TPLDisplay, tpl_display_query_config) + ASSERT_EQ((void *)NULL, display_handle); +} + + +typedef TPLTestBase DEFAULT_tpl_display_query_config; + +TEST_F(DEFAULT_tpl_display_query_config, success_1) { tpl_result_t result; @@ -53,6 +64,11 @@ TEST_F(TPLDisplay, tpl_display_query_config) NULL); ASSERT_EQ(TPL_ERROR_NONE, result); +} + +TEST_F(DEFAULT_tpl_display_query_config, success_2) +{ + tpl_result_t result; // #2: Normal case // Expected Value: TPL_ERROR_NONE @@ -67,6 +83,11 @@ TEST_F(TPLDisplay, tpl_display_query_config) NULL); ASSERT_EQ(TPL_ERROR_NONE, result); +} + +TEST_F(DEFAULT_tpl_display_query_config, failure_invalid_parameter_R) +{ + tpl_result_t result; // #3: Abnormal case // Expected Value: not TPL_ERROR_NONE @@ -84,29 +105,40 @@ TEST_F(TPLDisplay, tpl_display_query_config) } -// Tests tpl_display_filter_config(...) -TEST_F(TPLDisplay, tpl_display_filter_config) +typedef TPLTestBase DEFAULT_tpl_display_filter_config; + +TEST_F(DEFAULT_tpl_display_filter_config, success) { tpl_result_t result; int test_visual_id = GBM_FORMAT_ARGB8888; result = tpl_display_filter_config(backend->tpl_display, - &test_visual_id, 0); + &test_visual_id, 0); - // Expected Value: TPL_ERROR_NONE ASSERT_EQ(TPL_ERROR_NONE, result); } +TEST_F(DEFAULT_tpl_display_filter_config, failure_invalid_display) +{ + tpl_result_t result; + int test_visual_id = GBM_FORMAT_ARGB8888; + result = tpl_display_filter_config(NULL, &test_visual_id, 0); + + ASSERT_EQ(TPL_ERROR_INVALID_PARAMETER, result); +} -// Tests tpl_display_get_native_window_info(...) -TEST_F(TPLDisplay, tpl_display_get_native_window_info) + +typedef TPLTestBase DEFAULT_tpl_display_get_native_window_info; + +TEST_F(DEFAULT_tpl_display_get_native_window_info, success) { tpl_result_t result; int width, height; tbm_format format; result = tpl_display_get_native_window_info(backend->tpl_display, - backend->surface_handle, &width, &height, &format, - config.depth, 8); + backend->surface_handle, + &width, &height, &format, + config.depth, 8); EXPECT_EQ(config.width, width); EXPECT_EQ(config.height, height); @@ -115,16 +147,19 @@ TEST_F(TPLDisplay, tpl_display_get_native_window_info) ASSERT_EQ(TPL_ERROR_NONE, result); } +/* TODO: Make test - DEFAULT_tpl_display_get_native_window_info, failure */ + +typedef TPLTestBase +EXTRA_tpl_display_query_supported_buffer_count_from_native_window; -TEST_F(TPLDisplaySupport, - tpl_display_query_supported_buffer_count_from_native_window) +TEST_F(EXTRA_tpl_display_query_supported_buffer_count_from_native_window, + success) { tpl_result_t result; int min, max; result = tpl_display_query_supported_buffer_count_from_native_window( - backend->tpl_display, backend->surface_handle, - &min, &max); + backend->tpl_display, backend->surface_handle, &min, &max); // SUCCEED() if backend does not support operation if (result == TPL_ERROR_INVALID_OPERATION) { diff --git a/tc/test/tpl-test_object_test.cpp b/tc/test/tpl-test_object_test.cpp index e292fa7..093690f 100644 --- a/tc/test/tpl-test_object_test.cpp +++ b/tc/test/tpl-test_object_test.cpp @@ -9,46 +9,99 @@ #include "src/tpl-test_base.h" -class TPLObject : public TPLTestBase {}; +typedef TPLTestBase DEFAULT_tpl_object_get_type; - -// Tests tpl_object_get_type(tpl_object_t *) -TEST_F(TPLObject, tpl_object_get_type) +TEST_F(DEFAULT_tpl_object_get_type, success_get_tpl_display) { int obj_type = -1; obj_type = tpl_object_get_type((tpl_object_t *)backend->tpl_display); ASSERT_EQ(TPL_OBJECT_DISPLAY, obj_type); +} - obj_type = -1; +TEST_F(DEFAULT_tpl_object_get_type, success_get_tpl_surfcae) +{ + int obj_type = -1; obj_type = tpl_object_get_type((tpl_object_t *)backend->tpl_surface); ASSERT_EQ(TPL_OBJECT_SURFACE, obj_type); } +TEST_F(DEFAULT_tpl_object_get_type, failure_invalid_object) +{ + int obj_type = -1; + obj_type = tpl_object_get_type(NULL); + ASSERT_EQ(TPL_OBJECT_ERROR, obj_type); +} + + +typedef TPLTestBase DEFAULT_tpl_object_set_get_user_data; // Tests setting user data flow: // 1. Set user data // 2. Get user data -TEST_F(TPLObject, tpl_object_userdata_test) +TEST_F(DEFAULT_tpl_object_set_get_user_data, success_set_get) +{ + unsigned long key; + + // set user data + tpl_object_set_user_data((tpl_object_t *)backend->tpl_display, &key, + (void *)backend->display_handle, NULL); + + // get user data + void *get_dpy = NULL; + get_dpy = (void *)tpl_object_get_user_data( + (tpl_object_t *)backend->tpl_display, &key); + + ASSERT_EQ((void *)backend->display_handle, get_dpy); +} + +TEST_F(DEFAULT_tpl_object_set_get_user_data, failure_set_invalid_object) +{ + unsigned long key; + int result; + + // set user data + result = tpl_object_set_user_data(NULL, &key, + (void *)backend->display_handle, NULL); + + ASSERT_EQ(TPL_ERROR_INVALID_PARAMETER, result); +} + +TEST_F(DEFAULT_tpl_object_set_get_user_data, failure_get_invalid_object) +{ + unsigned long key; + + // get user data + void *get_dpy = NULL; + get_dpy = (void *)tpl_object_get_user_data(NULL, &key); + + ASSERT_EQ(NULL, get_dpy); +} + +TEST_F(DEFAULT_tpl_object_set_get_user_data, failure_get_invalid_key) { unsigned long key; - // TODO: Check // set user data tpl_object_set_user_data((tpl_object_t *)backend->tpl_display, &key, (void *)backend->display_handle, NULL); + unsigned long invalid_key; + // get user data void *get_dpy = NULL; get_dpy = (void *)tpl_object_get_user_data( - (tpl_object_t *)backend->tpl_display, &key); + (tpl_object_t *)backend->tpl_display, &invalid_key); - ASSERT_EQ(get_dpy, (void *)backend->display_handle); + ASSERT_EQ(NULL, get_dpy); } + +typedef TPLTestBase DEFAULT_tpl_object_reference; + // Tests object reference flow: // 1. Reference // 2. Unreference -TEST_F(TPLObject, tpl_object_reference) +TEST_F(DEFAULT_tpl_object_reference, ref_unref) { // tpl_object_reference tpl_object_reference((tpl_object_t *)backend->tpl_display); @@ -64,3 +117,27 @@ TEST_F(TPLObject, tpl_object_reference) ASSERT_EQ(ref_count - 1, unref_count); } +TEST_F(DEFAULT_tpl_object_reference, failure_ref_invalid_object) +{ + int result; + result = tpl_object_reference(NULL); + + ASSERT_EQ(-1, result); +} + +TEST_F(DEFAULT_tpl_object_reference, failure_unref_invalid_object) +{ + int result; + result = tpl_object_reference(NULL); + + ASSERT_EQ(-1, result); +} + +TEST_F(DEFAULT_tpl_object_reference, failure_get_ref_invalid_object) +{ + int result; + result = tpl_object_get_reference(NULL); + + ASSERT_EQ(-1, result); +} + diff --git a/tc/test/tpl-test_surface_test.cpp b/tc/test/tpl-test_surface_test.cpp index 2bf6ab6..ae52edb 100644 --- a/tc/test/tpl-test_surface_test.cpp +++ b/tc/test/tpl-test_surface_test.cpp @@ -9,51 +9,111 @@ #include "src/tpl-test_base.h" -class TPLSurface : public TPLTestBase {}; -class TPLSurfaceSupport : public TPLSurface {}; +typedef TPLTestBase DEFAULT_tpl_surface_validate; - -// Tests tpl_surface_validate(tpl_surface_t *) -TEST_F(TPLSurface, tpl_surface_validate) +TEST_F(DEFAULT_tpl_surface_validate, success) { tpl_bool_t result = tpl_surface_validate(backend->tpl_surface); - // Expected Value: TPL_TRUE ASSERT_EQ(TPL_TRUE, result); } +TEST_F(DEFAULT_tpl_surface_validate, failure_invalid_surface) +{ + tpl_bool_t result = tpl_surface_validate(NULL); + + ASSERT_EQ(TPL_FALSE, result); +} + + +typedef TPLTestBase DEFAULT_tpl_surface_get_display; -TEST_F(TPLSurface, tpl_surface_get_args) +TEST_F(DEFAULT_tpl_surface_get_display, success) { // tpl_surface_get_display test tpl_display_t *test_dpy = tpl_surface_get_display(backend->tpl_surface); - ASSERT_EQ(test_dpy, backend->tpl_display); + ASSERT_EQ(backend->tpl_display, test_dpy); +} + +TEST_F(DEFAULT_tpl_surface_get_display, failure_invalid_surface) +{ + // tpl_surface_get_display test + tpl_display_t *test_dpy = tpl_surface_get_display(NULL); + + ASSERT_EQ((void *)NULL, test_dpy); +} + + +typedef TPLTestBase DEFAULT_tpl_surface_get_native_handle; + +TEST_F(DEFAULT_tpl_surface_get_native_handle, success) +{ // tpl_surface_get_native_handle tpl_handle_t test_handle = tpl_surface_get_native_handle(backend->tpl_surface); - ASSERT_EQ(test_handle, backend->surface_handle); + ASSERT_EQ(backend->surface_handle, test_handle); +} + +TEST_F(DEFAULT_tpl_surface_get_native_handle, failure_invalid_surface) +{ + // tpl_surface_get_native_handle + tpl_handle_t test_handle = tpl_surface_get_native_handle(NULL); + + ASSERT_EQ((void *)NULL, test_handle); +} + + +typedef TPLTestBase DEFAULT_tpl_surface_get_type; + +TEST_F(DEFAULT_tpl_surface_get_type, success) +{ // tpl_surface_get_type test tpl_surface_type_t test_type = tpl_surface_get_type(backend->tpl_surface); ASSERT_EQ(TPL_SURFACE_TYPE_WINDOW, test_type); +} +TEST_F(DEFAULT_tpl_surface_get_type, failure_invalid_surface) +{ + // tpl_surface_get_type test + tpl_surface_type_t test_type = tpl_surface_get_type(NULL); + ASSERT_EQ(TPL_SURFACE_ERROR, test_type); +} + + +typedef TPLTestBase DEFAULT_tpl_surface_get_size; + +TEST_F(DEFAULT_tpl_surface_get_size, success) +{ // tpl_surface_get_size test int width, height; tpl_result_t test_size = tpl_surface_get_size(backend->tpl_surface, &width, &height); + ASSERT_EQ(TPL_ERROR_NONE, test_size); + EXPECT_EQ(config.width, width); EXPECT_EQ(config.height, height); - ASSERT_EQ(TPL_ERROR_NONE, test_size); } +TEST_F(DEFAULT_tpl_surface_get_size, failure_invalid_surface) +{ + int width, height; + tpl_result_t test_size = + tpl_surface_get_size(NULL, &width, &height); + + ASSERT_EQ(TPL_ERROR_INVALID_PARAMETER, test_size); +} + + +typedef TPLTestBase DEFAULT_tpl_surface_dequeue_enqueue; // Tests simple normal buffer flow: // 1. Dequeue buffer by calling tpl_surface_dequeue_buffer // 2. Set post interval // 3. Enqueue buffer by calling tpl_surface_enqueue_buffer -TEST_F(TPLSurface, tpl_surface_dequeue_and_enqueue_buffer_test) +TEST_F(DEFAULT_tpl_surface_dequeue_enqueue, deq_enq) { // dequeue tbm_surface_h tbm_surf = NULL; @@ -73,15 +133,19 @@ TEST_F(TPLSurface, tpl_surface_dequeue_and_enqueue_buffer_test) } -TEST_F(TPLSurfaceSupport, tpl_surface_create_get_destroy_swapchain_test) +typedef TPLTestBase EXTRA_tpl_surface_swapchain; + +TEST_F(EXTRA_tpl_surface_swapchain, success) { int buffer_set = 2; tpl_result_t result; // Create swapchain result = tpl_surface_create_swapchain(backend->tpl_surface, - TBM_FORMAT_ARGB8888, config.width, config.height, buffer_set, - TPL_DISPLAY_PRESENT_MODE_IMMEDIATE); + TBM_FORMAT_ARGB8888, + config.width, config.height, + buffer_set, + TPL_DISPLAY_PRESENT_MODE_IMMEDIATE); // SUCCEED() if backend does not support operation if (result == TPL_ERROR_INVALID_OPERATION) { @@ -91,12 +155,12 @@ TEST_F(TPLSurfaceSupport, tpl_surface_create_get_destroy_swapchain_test) ASSERT_EQ(TPL_ERROR_NONE, result); - tbm_surface_h **buffers; + tbm_surface_h **buffers = NULL; int buffer_get; // Get swapchain buffers result = tpl_surface_get_swapchain_buffers(backend->tpl_surface, - buffers, &buffer_get); + buffers, &buffer_get); EXPECT_EQ(buffer_set, buffer_get); ASSERT_EQ(TPL_ERROR_NONE, result); -- 2.7.4 From 6590892f13da9e387735879ee90d6fae9de3e7f7 Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Wed, 14 Dec 2016 13:05:15 +0900 Subject: [PATCH 04/16] tpl_tbm: Add logs for default info. Change-Id: I06ad809fcab02205627fedb7122b7a5dac06ee2b Signed-off-by: joonbum.ko --- src/tpl_tbm.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/tpl_tbm.c b/src/tpl_tbm.c index ff62ce6..e8cc626 100644 --- a/src/tpl_tbm.c +++ b/src/tpl_tbm.c @@ -107,6 +107,9 @@ __tpl_tbm_display_init(tpl_display_t *display) display->backend.data = tbm_display; display->bufmgr_fd = -1; + TPL_LOG_B("TBM", "[INIT] tpl_display(%p) tpl_tbm_display_t(%p) tbm_bufmgr(%p)", + display, tbm_display, display->native_handle); + return TPL_ERROR_NONE; } @@ -119,6 +122,8 @@ __tpl_tbm_display_fini(tpl_display_t *display) tbm_display = (tpl_tbm_display_t *)display->backend.data; + TPL_LOG_B("TBM", "[FINI] tpl_display(%p) tpl_tbm_display_t(%p) tbm_bufmgr(%p)", + display, tbm_display, display->native_handle); display->backend.data = NULL; if (tbm_display) { @@ -449,6 +454,9 @@ __tpl_tbm_surface_init(tpl_surface_t *surface) __tpl_tbm_surface_queue_notify_cb, surface); + TPL_LOG_B("TBM", "[INIT] tpl_surface(%p) tpl_tbm_surface_t(%p) tbm_surface_queue(%p)", + surface, tpl_tbm_surface, surface->native_handle); + return TPL_ERROR_NONE; } else if (surface->type == TPL_SURFACE_TYPE_PIXMAP) { if (__tpl_tbm_display_get_pixmap_info(surface->display, @@ -488,6 +496,9 @@ __tpl_tbm_surface_fini(tpl_surface_t *surface) TPL_ASSERT(surface); TPL_ASSERT(surface->display); + TPL_LOG_B("TBM", "[FINI] tpl_surface(%p) tpl_tbm_surface_t(%p) native_handle(%p)", + surface, surface->backend.data, surface->native_handle); + if (surface->type == TPL_SURFACE_TYPE_PIXMAP) tbm_surface_internal_unref((tbm_surface_h)surface->native_handle); else if (surface->type == TPL_SURFACE_TYPE_WINDOW) { @@ -562,6 +573,10 @@ __tpl_tbm_surface_enqueue_buffer(tpl_surface_t *surface, } } + TPL_LOG_B("TBM", "[ENQ] tpl_surface(%p) tbm_queue(%p) tbm_surface(%p) bo(%d)", + surface, tbm_queue, tbm_surface, + tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + return TPL_ERROR_NONE; } @@ -618,6 +633,10 @@ __tpl_tbm_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, /* It will be dec when before tbm_surface_queue_enqueue called */ tbm_surface_internal_ref(tbm_surface); + TPL_LOG_B("TBM", "[DEQ] tpl_surface(%p) tbm_queue(%p) tbm_surface(%p) bo(%d)", + surface, tbm_queue, tbm_surface, + tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + return tbm_surface; } -- 2.7.4 From 082cd6d9010546db99a19692f9daa6cc9abea536 Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Wed, 15 Feb 2017 17:31:50 +0900 Subject: [PATCH 05/16] tpl_wayland_egl: subdivided the reason of failure of tbm_suface_queue_enqueue. - When tbm_surface_queue_enqueue failed although tbm_surface was valid, client is going to do wl_surface_commit forcibly to assure the lastest frame. - In enlightenment(E20) of TIZEN platform, depending on some situation(Activate, Deactivate), the compositor may or may not display the last forcibly commited buffer in this way. In this situation, the compositor's display policy may vary from server to server. - libtbm tbm_surface_queue: Added some enum value for checking detail errors. 0a43ad4cfa6b57b2f33d8fe2f06eb89db8841f58 Change-Id: I2434341d093792112b1b89eefe3d140c5b6a840d Signed-off-by: joonbum.ko --- src/tpl_wayland_egl.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index 358432c..4f4ad44 100644 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -869,6 +869,26 @@ __tpl_wayland_egl_surface_enqueue_buffer(tpl_surface_t *surface, */ tbm_surface_internal_unref(tbm_surface); } else { + /* + * If tbm_surface is valid but it is not tracked by tbm_surface_queue, + * tbm_surface_queue_enqueue will return below value. + * TBM_SURFACE_QUEUE_ERROR_UNKNOWN_SURFACE + * It means tbm_surface_queue has been reset before client try + * to enqueue this tbm_surface. + * We should commit this buffer to display to assure the latest frame. + * + * In enlightenment(E20) of TIZEN platform, depending on + * some situation(Activate, Deactivate), the compositor may or may not + * display the last forcibly commited buffer in this way. + * + * In this situation, the compositor's display policy may vary from + * server to server. + */ + if (tsq_err == TBM_SURFACE_QUEUE_ERROR_UNKNOWN_SURFACE) { + __tpl_wayland_egl_surface_commit(surface, tbm_surface, + num_rects, rects); + return TPL_ERROR_NONE; + } TPL_ERR("Failed to enqeueue tbm_surface(%p). | tsq_err = %d", tbm_surface, tsq_err); -- 2.7.4 From e6f94d91e82d4c45bb8e2f2cc4e37bf5f26e7991 Mon Sep 17 00:00:00 2001 From: Hoyub Lee Date: Thu, 23 Mar 2017 11:28:08 +0900 Subject: [PATCH 06/16] Use %license macro to copy license file This patch applies %license macro to libtpl-egl, libwayland-egl. For tpl-test which use googletest, %license macro is not applied, but the path where license be copied is changed to Tizen licenses folder. Change-Id: I048158c1cdc9ce59f0ca86e91ff61a721652ff2c Signed-off-by: Hoyub Lee --- packaging/libtpl-egl.spec | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/packaging/libtpl-egl.spec b/packaging/libtpl-egl.spec index 286cbf6..f0998a5 100644 --- a/packaging/libtpl-egl.spec +++ b/packaging/libtpl-egl.spec @@ -215,15 +215,11 @@ ln -sf libtpl-egl.so.%{TPL_VER_MAJOR} %{buildroot}%{_libdir}/libtpl-egl.so cp -a src/tpl.h %{buildroot}%{_includedir}/ cp -a pkgconfig/tpl-egl.pc %{buildroot}%{_libdir}/pkgconfig/ -mkdir -p %{buildroot}/%{TZ_SYS_RO_SHARE}/license -cp -a %{_builddir}/%{buildsubdir}/COPYING %{buildroot}/%{TZ_SYS_RO_SHARE}/license/%{name} - %if "%{TPL_WINSYS}" == "WL" cd src/wayland-egl cp libwayland-egl.so.%{WL_EGL_VERSION} %{buildroot}%{_libdir}/libwayland-egl.so cp libwayland-egl.so.%{WL_EGL_VERSION} %{buildroot}%{_libdir}/libwayland-egl.so.1 cp libwayland-egl.so.%{WL_EGL_VERSION} %{buildroot}%{_libdir}/libwayland-egl.so.1.0 -cp -a %{_builddir}/%{buildsubdir}/COPYING %{buildroot}/%{TZ_SYS_RO_SHARE}/license/libwayland-egl export WLD_EGL_SO_VER=%{WL_EGL_VERSION} %makeinstall cd - @@ -239,8 +235,8 @@ mkdir -p %{buildroot}/opt/usr/tpl-test cp -arp ./tc/tpl-test %{buildroot}/opt/usr/tpl-test # License of Google Test which is BSD-3-Clause -mkdir -p %{buildroot}/%{TZ_SYS_RO_SHARE}/license -cp -a %{_builddir}/%{buildsubdir}/tc/libs/gtest/googletest/LICENSE %{buildroot}/%{TZ_SYS_RO_SHARE}/license/googletest +mkdir -p %{buildroot}/%{TZ_SYS_RO_SHARE}/licenses/googletest +cp -a %{_builddir}/%{buildsubdir}/tc/libs/gtest/googletest/LICENSE %{buildroot}/%{TZ_SYS_RO_SHARE}/licenses/googletest/LICENSE %endif %post -p /sbin/ldconfig @@ -253,7 +249,7 @@ cp -a %{_builddir}/%{buildsubdir}/tc/libs/gtest/googletest/LICENSE %{buildroot}/ %files %manifest packaging/libtpl-egl.manifest -%{TZ_SYS_RO_SHARE}/license/%{name} +%license COPYING %defattr(-,root,root,-) %{_libdir}/libtpl-egl.so %{_libdir}/libtpl-egl.so.%{TPL_VER_MAJOR} @@ -266,7 +262,7 @@ cp -a %{_builddir}/%{buildsubdir}/tc/libs/gtest/googletest/LICENSE %{buildroot}/ /opt/usr/tpl-test/tpl-test # License of Google Test which is BSD-3-Clause -%{TZ_SYS_RO_SHARE}/license/googletest +%{TZ_SYS_RO_SHARE}/licenses/googletest/LICENSE %endif %files devel @@ -277,7 +273,7 @@ cp -a %{_builddir}/%{buildsubdir}/tc/libs/gtest/googletest/LICENSE %{buildroot}/ %if "%{TPL_WINSYS}" == "WL" %files -n libwayland-egl %manifest packaging/libwayland-egl.manifest -%{TZ_SYS_RO_SHARE}/license/libwayland-egl +%license COPYING %defattr(-,root,root,-) %{_libdir}/libwayland-egl.so %{_libdir}/libwayland-egl.so.1 -- 2.7.4 From b0619c3e1348571365f31d752c8b0b012595cfe1 Mon Sep 17 00:00:00 2001 From: Hoyub Lee Date: Tue, 4 Apr 2017 14:47:10 +0900 Subject: [PATCH 07/16] tpl_tbm: Fix uninitialized local variable problem Change-Id: Ie8594d2d59c2e7c1094dbc742d074659f1082c41 Signed-off-by: Hoyub Lee --- src/tpl_tbm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tpl_tbm.c b/src/tpl_tbm.c index e8cc626..b5c022e 100644 --- a/src/tpl_tbm.c +++ b/src/tpl_tbm.c @@ -519,7 +519,7 @@ __tpl_tbm_surface_enqueue_buffer(tpl_surface_t *surface, { tpl_tbm_surface_t *tpl_tbm_surface = NULL; tpl_tbm_buffer_t *tpl_tbm_buffer = NULL; - tbm_surface_queue_h tbm_queue; + tbm_surface_queue_h tbm_queue = NULL; TPL_ASSERT(surface); TPL_ASSERT(surface->display); -- 2.7.4 From ef4ef42c6e7ba2faacfa9f6d40557ea9e1432eb3 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Fri, 14 Apr 2017 10:39:41 +0900 Subject: [PATCH 08/16] add BSD-3-Clause License to COPYING for gtest The license of the gtest is BSD-3-Cluase. Change-Id: If2e16415464ae155ac06aa5b7dddf0be4a1697ef --- COPYING | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/COPYING b/COPYING index 9036173..ade2193 100644 --- a/COPYING +++ b/COPYING @@ -17,3 +17,32 @@ CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +Copyright 2008, Google Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +* Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. +* Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- 2.7.4 From 90e32de400d1d5ebe9aec757c8e5b677197f2349 Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Fri, 17 Feb 2017 17:43:28 +0900 Subject: [PATCH 09/16] tpl_gbm: Register reset callback of gbm's tbm_surface_queue - Server(E20) will be able to reset buffer_age of their buffers. - In order to work well with partial updates, server need to reset the buffer_age at the time of ACTIVE and DEACTIVE switching. Change-Id: I79ff9702fe7d0d14fb8a8d1204b87db1e1318736 Signed-off-by: joonbum.ko --- src/tpl_gbm.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/tpl_gbm.c b/src/tpl_gbm.c index 42f1a90..f45ba99 100644 --- a/src/tpl_gbm.c +++ b/src/tpl_gbm.c @@ -39,6 +39,7 @@ struct _tpl_gbm_display { struct _tpl_gbm_surface { tbm_surface_queue_h tbm_queue; tbm_surface_h current_buffer; + tpl_bool_t reset; /* TRUE if queue was reset by external */ }; struct _tpl_gbm_buffer { @@ -254,6 +255,27 @@ __tpl_gbm_display_get_buffer_from_native_pixmap(tpl_handle_t pixmap) return tbm_surface; } +static void +__cb_tbm_surface_queue_reset_callback(tbm_surface_queue_h surface_queue, + void *data) +{ + tpl_surface_t *surface = NULL; + tpl_gbm_surface_t *tpl_gbm_surface = NULL; + + surface = (tpl_surface_t *)data; + TPL_CHECK_ON_NULL_RETURN(surface); + + tpl_gbm_surface = (tpl_gbm_surface_t *)surface->backend.data; + TPL_CHECK_ON_NULL_RETURN(tpl_gbm_surface); + + TPL_LOG_B("GBM", + "[QUEUE_RESET_CB] tpl_gbm_surface_t(%p) surface_queue(%p)", + data, surface_queue); + + if (surface->reset_cb) + surface->reset_cb(surface->reset_data); +} + static tpl_result_t __tpl_gbm_surface_init(tpl_surface_t *surface) { @@ -279,6 +301,14 @@ __tpl_gbm_surface_init(tpl_surface_t *surface) goto error; } + /* Set reset_callback to tbm_queue */ + if (tbm_surface_queue_add_reset_cb(tpl_gbm_surface->tbm_queue, + __cb_tbm_surface_queue_reset_callback, + (void *)surface)) { + TPL_ERR("TBM surface queue add reset cb failed!"); + goto error; + } + if (__tpl_gbm_display_get_window_info(surface->display, surface->native_handle, &surface->width, &surface->height, NULL, 0, 0) != TPL_ERROR_NONE) { -- 2.7.4 From 2cd1da010e4ed140030183582a7d807050d5051d Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Mon, 20 Feb 2017 16:54:17 +0900 Subject: [PATCH 10/16] tpl_wayland_egl: Set event queue by using new API of wayland-tbm. - Use new API to set event_queue in order to do roundtrip in wl_tbm. - platform/core/uifw/wayland-tbm commit_id : 21c96897bbcde143eff825e2d59fe820e99e5e16 commit_message : client: added function wayland_tbm_client_set_event_queue Change-Id: Idcd7d24912fd8fe655ecdf2d834e8cc10a92a3d0 Signed-off-by: joonbum.ko --- src/tpl_wayland_egl.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index 4f4ad44..f24bdc4 100644 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -162,14 +162,6 @@ __tpl_wayland_egl_display_init(tpl_display_t *display) goto free_wl_display; } - wayland_egl_display->wl_tbm = - (struct wl_proxy *)wayland_tbm_client_get_wl_tbm( - wayland_egl_display->wl_tbm_client); - if (!wayland_egl_display->wl_tbm) { - TPL_ERR("Failed to get wl_tbm from wayland_tbm_client."); - goto free_wl_display; - } - wayland_egl_display->wl_tbm_event_queue = wl_display_create_queue(wl_dpy); if (!wayland_egl_display->wl_tbm_event_queue) { @@ -177,8 +169,12 @@ __tpl_wayland_egl_display_init(tpl_display_t *display) goto free_wl_display; } - wl_proxy_set_queue(wayland_egl_display->wl_tbm, - wayland_egl_display->wl_tbm_event_queue); + if (!wayland_tbm_client_set_event_queue( + wayland_egl_display->wl_tbm_client, + wayland_egl_display->wl_tbm_event_queue)) { + TPL_ERR("Failed to set event_queue to wl_tbm."); + goto free_wl_display; + } if (env == NULL || atoi(env)) { TPL_LOG_B("WL_EGL", "[INIT] ENABLE wait vblank."); @@ -208,8 +204,8 @@ __tpl_wayland_egl_display_init(tpl_display_t *display) free_wl_display: if (wayland_egl_display->tdm_client) tdm_client_destroy(wayland_egl_display->tdm_client); - if ((wayland_egl_display->wl_tbm) && (wayland_egl_display->wl_tbm_event_queue)) - wl_proxy_set_queue(wayland_egl_display->wl_tbm, NULL); + if (wayland_egl_display->wl_tbm_client) + wayland_tbm_client_set_event_queue(wayland_egl_display->wl_tbm_client, NULL); if (wayland_egl_display->wl_tbm_event_queue) wl_event_queue_destroy(wayland_egl_display->wl_tbm_event_queue); if (wayland_egl_display->wl_tbm_client) @@ -218,7 +214,6 @@ free_wl_display: wayland_egl_display->wl_tbm_event_queue = NULL; wayland_egl_display->wl_tbm_client = NULL; wayland_egl_display->tdm_client = NULL; - wayland_egl_display->wl_tbm = NULL; wayland_egl_display->wl_dpy = NULL; free(wayland_egl_display); @@ -243,8 +238,8 @@ __tpl_wayland_egl_display_fini(tpl_display_t *display) if (wayland_egl_display->tdm_client) tdm_client_destroy(wayland_egl_display->tdm_client); - if ((wayland_egl_display->wl_tbm) && (wayland_egl_display->wl_tbm_event_queue)) - wl_proxy_set_queue(wayland_egl_display->wl_tbm, NULL); + if (wayland_egl_display->wl_tbm_client) + wayland_tbm_client_set_event_queue(wayland_egl_display->wl_tbm_client, NULL); if (wayland_egl_display->wl_tbm_event_queue) wl_event_queue_destroy(wayland_egl_display->wl_tbm_event_queue); @@ -255,7 +250,6 @@ __tpl_wayland_egl_display_fini(tpl_display_t *display) wayland_egl_display->wl_tbm_event_queue = NULL; wayland_egl_display->wl_tbm_client = NULL; wayland_egl_display->tdm_client = NULL; - wayland_egl_display->wl_tbm = NULL; wayland_egl_display->wl_dpy = NULL; free(wayland_egl_display); } -- 2.7.4 From d62f62e47c0840719e8efd88db9f565caaf93e15 Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Tue, 14 Mar 2017 17:15:29 +0900 Subject: [PATCH 11/16] tpl_gbm, tpl_tbm: Revised exception checking syntax of the dequeue error situation. - This patch will be able to resolve SVACE issue about below error situation. 1. tbm_surface_queue_dequeue return (tbm_surface == NULL) 2. tbm_surface_queue_can_dequeue return 0, because of internal error. 3. cannot enter the if syntax and cannot call tbm_surface_queue_dequeue. 4. tbm_surface is still NULL but try to call tbm_surface_internal_ref. <- error case. Change-Id: I4dbdb51bf3682a1acadde4d7c07d899de6fe01cd Signed-off-by: joonbum.ko --- src/tpl_gbm.c | 19 +++++++++---------- src/tpl_tbm.c | 15 +++++++-------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/tpl_gbm.c b/src/tpl_gbm.c index f45ba99..06596a2 100644 --- a/src/tpl_gbm.c +++ b/src/tpl_gbm.c @@ -442,7 +442,7 @@ __tpl_gbm_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, { tbm_bo bo; tbm_surface_h tbm_surface = NULL; - tbm_surface_queue_error_e tsq_err = 0; + tbm_surface_queue_error_e tsq_err = TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE; tpl_gbm_buffer_t *gbm_buffer = NULL; tpl_gbm_surface_t *gbm_surface = NULL; @@ -458,18 +458,17 @@ __tpl_gbm_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, gbm_surface = (tpl_gbm_surface_t *)surface->backend.data; TRACE_BEGIN("WAITING FOR DEQUEUEABLE"); - tsq_err = tbm_surface_queue_dequeue(gbm_surface->tbm_queue, &tbm_surface); - if (!tbm_surface - && tbm_surface_queue_can_dequeue(gbm_surface->tbm_queue, 1) == 1) { + if (tbm_surface_queue_can_dequeue(gbm_surface->tbm_queue, 1) == 1) tsq_err = tbm_surface_queue_dequeue(gbm_surface->tbm_queue, &tbm_surface); - if (!tbm_surface) { - TPL_ERR("Failed to get tbm_surface from tbm_surface_queue | tsq_err = %d", - tsq_err); - TRACE_END(); - return NULL; - } + + if (!tbm_surface) { + TPL_ERR("Failed to get tbm_surface from tbm_surface_queue | tsq_err = %d", + tsq_err); + TRACE_END(); + return NULL; } TRACE_END(); + /* Inc ref count about tbm_surface */ /* It will be dec when before tbm_surface_queue_enqueue called */ tbm_surface_internal_ref(tbm_surface); diff --git a/src/tpl_tbm.c b/src/tpl_tbm.c index b5c022e..50154e5 100644 --- a/src/tpl_tbm.c +++ b/src/tpl_tbm.c @@ -594,7 +594,7 @@ __tpl_tbm_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, { tbm_surface_h tbm_surface = NULL; tbm_surface_queue_h tbm_queue = NULL; - tbm_surface_queue_error_e tsq_err = 0; + tbm_surface_queue_error_e tsq_err = TBM_SURFACE_QUEUE_ERROR_INVALID_QUEUE; tpl_tbm_buffer_t *tpl_tbm_buffer = NULL; TPL_ASSERT(surface); @@ -607,14 +607,13 @@ __tpl_tbm_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeout_ns, tbm_queue = (tbm_surface_queue_h)surface->native_handle; - tsq_err = tbm_surface_queue_dequeue(tbm_queue, &tbm_surface); - if (!tbm_surface && tbm_surface_queue_can_dequeue(tbm_queue, 1) == 1) { + if (tbm_surface_queue_can_dequeue(tbm_queue, 1) == 1) tsq_err = tbm_surface_queue_dequeue(tbm_queue, &tbm_surface); - if (!tbm_surface) { - TPL_ERR("Failed to get tbm_surface from tbm_surface_queue | tsq_err = %d", - tsq_err); - return NULL; - } + + if (!tbm_surface) { + TPL_ERR("Failed to get tbm_surface from tbm_surface_queue | tsq_err = %d", + tsq_err); + return NULL; } if (surface->backend.type == TPL_BACKEND_TBM_VULKAN_WSI) { -- 2.7.4 From 115ebb65c80ebce7ea47f5d2363e47c4907300ba Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Thu, 16 Mar 2017 09:13:32 +0900 Subject: [PATCH 12/16] tpl_wayland_egl: Added geometry information of the client window to tpl_wayland_egl_buffer_t. - Store the native window information when the wayland client do dequeue buffer in tpl_wayland_egl_buffer_t. - By using the information remaining in the tpl_wayland_egl_buffer_t which rendering job end, do commit to server. - This change will be able to inform accurate information of client window to server. Change-Id: I4a7c4646cfc8ab3f39c8755f7c1193b33992a1ed Signed-off-by: joonbum.ko --- src/tpl_wayland_egl.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index f24bdc4..4f9cb12 100644 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -57,6 +57,9 @@ struct _tpl_wayland_egl_surface { struct _tpl_wayland_egl_buffer { tpl_wayland_egl_display_t *display; tpl_wayland_egl_surface_t *wayland_egl_surface; + int dx, dy; + int width, height; + int rotation; tbm_bo bo; tpl_bool_t reset; /* TRUE if queue reseted by external */ struct wl_proxy *wl_proxy; /* wl_buffer proxy */ @@ -723,15 +726,15 @@ __tpl_wayland_egl_surface_commit(tpl_surface_t *surface, TPL_IMAGE_DUMP(tbm_surface, surface->width, surface->height); wl_surface_attach(wl_egl_window->surface, (void *)wayland_egl_buffer->wl_proxy, - wl_egl_window->dx, wl_egl_window->dy); + wayland_egl_buffer->dx, wayland_egl_buffer->dy); - wl_egl_window->attached_width = wl_egl_window->width; - wl_egl_window->attached_height = wl_egl_window->height; + wl_egl_window->attached_width = wayland_egl_buffer->width; + wl_egl_window->attached_height = wayland_egl_buffer->height; if (num_rects < 1 || rects == NULL) { wl_surface_damage(wl_egl_window->surface, - wl_egl_window->dx, wl_egl_window->dy, - wl_egl_window->width, wl_egl_window->height); + wayland_egl_buffer->dx, wayland_egl_buffer->dy, + wayland_egl_buffer->width, wayland_egl_buffer->height); } else { int i; @@ -741,7 +744,7 @@ __tpl_wayland_egl_surface_commit(tpl_surface_t *surface, * WINDOW(Top-left) coord like below. * y = [WINDOW.HEIGHT] - (RECT.Y + RECT.HEIGHT) */ int inverted_y = - wl_egl_window->height - (rects[i * 4 + 1] + rects[i * 4 + 3]); + wayland_egl_buffer->height - (rects[i * 4 + 1] + rects[i * 4 + 3]); wl_surface_damage(wl_egl_window->surface, rects[i * 4 + 0], inverted_y, rects[i * 4 + 2], rects[i * 4 + 3]); @@ -753,9 +756,10 @@ __tpl_wayland_egl_surface_commit(tpl_surface_t *surface, wl_display_flush(wayland_egl_display->wl_dpy); TPL_LOG_B("WL_EGL", - "[COMMIT] wl_surface(%p) wl_egl_window(%p)(%dx%d) wl_buffer(%p)", + "[COMMIT] wl_surface(%p) wl_egl_window(%p) wl_buffer(%p)(%dx%d)", wl_egl_window->surface, wl_egl_window, - wl_egl_window->width, wl_egl_window->height, wayland_egl_buffer->wl_proxy); + wayland_egl_buffer->wl_proxy, + wayland_egl_buffer->width, wayland_egl_buffer->height); if (wayland_egl_surface->attached_buffers) { TPL_OBJECT_LOCK(&wayland_egl_surface->base); @@ -999,6 +1003,8 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou tpl_wayland_egl_display_t *wayland_egl_display = (tpl_wayland_egl_display_t *)surface->display->backend.data; struct wl_proxy *wl_proxy = NULL; + struct wl_egl_window *wl_egl_window = + (struct wl_egl_window *)surface->native_handle; tbm_surface_queue_error_e tsq_err = 0; if (sync_fence) @@ -1006,8 +1012,6 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou /* Check whether the surface was resized by wayland_egl */ if (wayland_egl_surface->resized == TPL_TRUE) { - struct wl_egl_window *wl_egl_window = - (struct wl_egl_window *)surface->native_handle; int width, height, format; width = wl_egl_window->width; height = wl_egl_window->height; @@ -1047,6 +1051,12 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou wayland_egl_buffer->wl_proxy, tbm_surface, tbm_bo_export(wayland_egl_buffer->bo)); + wayland_egl_buffer->dx = wl_egl_window->dx; + wayland_egl_buffer->dy = wl_egl_window->dy; + wayland_egl_buffer->width = wl_egl_window->width; + wayland_egl_buffer->height = wl_egl_window->height; + wayland_egl_buffer->rotation = wl_egl_window->rotation; + wayland_egl_buffer->reset = TPL_FALSE; wayland_egl_surface->reset = TPL_FALSE; @@ -1084,6 +1094,11 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou wl_display_flush(wayland_egl_display->wl_dpy); + wayland_egl_buffer->dx = wl_egl_window->dx; + wayland_egl_buffer->dy = wl_egl_window->dy; + wayland_egl_buffer->width = wl_egl_window->width; + wayland_egl_buffer->height = wl_egl_window->height; + wayland_egl_buffer->rotation = wl_egl_window->rotation; wayland_egl_buffer->display = wayland_egl_display; wayland_egl_buffer->wl_proxy = wl_proxy; wayland_egl_buffer->bo = tbm_surface_internal_get_bo(tbm_surface, 0); -- 2.7.4 From a7d8b298449ddef34062cdb933115b8eaec02bf4 Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Thu, 2 Mar 2017 15:29:14 +0900 Subject: [PATCH 13/16] wayland-egl: Prerotation need not to do window resize. Change-Id: I1b12350e01862317358f7ac29a1274cab6812ae8 Signed-off-by: joonbum.ko --- src/wayland-egl/wayland-egl.c | 83 ++++++------------------------------------- 1 file changed, 11 insertions(+), 72 deletions(-) diff --git a/src/wayland-egl/wayland-egl.c b/src/wayland-egl/wayland-egl.c index 8ed649f..46d47a0 100644 --- a/src/wayland-egl/wayland-egl.c +++ b/src/wayland-egl/wayland-egl.c @@ -15,17 +15,14 @@ unsigned int wl_egl_log_level; /* WL-EGL Log Level - 0:unintialized, 1:initialized(no logging), 2:min log, 3:more log */ -#define WL_EGL_LOG(lvl, f, x...) \ - { \ - if(wl_egl_log_level == 1) \ - {} \ - else if(wl_egl_log_level > 1) \ - { \ +#define WL_EGL_LOG(lvl, f, x...) { \ + if(wl_egl_log_level == 1) { \ + } \ + else if(wl_egl_log_level > 1) { \ if(wl_egl_log_level <= lvl) \ WL_EGL_LOG_PRINT(f, ##x) \ } \ - else \ - { \ + else { \ char *env = getenv("WL_EGL_LOG_LEVEL"); \ if(env == NULL) \ wl_egl_log_level = 1; \ @@ -37,14 +34,12 @@ unsigned int wl_egl_log_level; } \ } -#define WL_EGL_LOG_PRINT(fmt, args...) \ - { \ +#define WL_EGL_LOG_PRINT(fmt, args...) { \ printf("[\x1b[32mWL-EGL\x1b[0m %d:%d|\x1b[32m%s\x1b[0m|%d] " fmt "\n", \ getpid(), (int)syscall(SYS_gettid), __func__,__LINE__, ##args); \ } -#define WL_EGL_ERR(f, x...) \ - { \ +#define WL_EGL_ERR(f, x...) { \ printf("[\x1b[31mWL-EGL_ERR\x1b[0m %d:%d|\x1b[31m%s\x1b[0m|%d] " f "\n",\ getpid(), (int)syscall(SYS_gettid), __func__, __LINE__, ##x); \ } @@ -58,7 +53,6 @@ wl_egl_window_resize(struct wl_egl_window *egl_window, int width, int height, int dx, int dy) { - int prev_width, prev_height; wl_egl_window_rotation rotation; if (egl_window == NULL) { @@ -69,35 +63,10 @@ wl_egl_window_resize(struct wl_egl_window *egl_window, egl_window->dx = dx; egl_window->dy = dy; - rotation = egl_window->rotation; - switch (rotation) { - case ROTATION_0: - case ROTATION_180: - default: - prev_width = egl_window->width; - prev_height = egl_window->height; - break; - case ROTATION_90: - case ROTATION_270: - prev_width = egl_window->height; - prev_height = egl_window->width; - break; - } - if ((prev_width == width) && (prev_height == height)) return; - - switch (rotation) { - case ROTATION_0: - case ROTATION_180: - default: - egl_window->width = width; - egl_window->height = height; - break; - case ROTATION_90: - case ROTATION_270: - egl_window->width = height; - egl_window->height = width; - break; - } + if ((egl_window->width == width) && (egl_window->height == height)) return; + + egl_window->width = width; + egl_window->height = height; if (egl_window->resize_callback) egl_window->resize_callback(egl_window, egl_window->private); @@ -175,9 +144,6 @@ WL_EGL_EXPORT void wl_egl_window_set_rotation(struct wl_egl_window *egl_window, wl_egl_window_rotation rotation) { - int resize = 0; - wl_egl_window_rotation prev_rotation; - if (egl_window == NULL) { WL_EGL_ERR("egl_window is NULL"); return; @@ -188,37 +154,10 @@ wl_egl_window_set_rotation(struct wl_egl_window *egl_window, return; } - prev_rotation = egl_window->rotation; - switch (rotation) { - case ROTATION_0: - case ROTATION_180: - if (prev_rotation == ROTATION_90 || prev_rotation == ROTATION_270) - resize = 1; - break; - case ROTATION_90: - case ROTATION_270: - if (prev_rotation == ROTATION_0 || prev_rotation == ROTATION_180) - resize = 1; - break; - default: - WL_EGL_ERR("Invalid rotation value"); - return; - } - - WL_EGL_LOG(2, "egl_win:%10p prev_rotation:%d curr_rotation: %d", - egl_window, egl_window->rotation, rotation); - egl_window->rotation = rotation; if (egl_window->rotate_callback) egl_window->rotate_callback(egl_window, egl_window->private); - - if ((resize == 1) && (egl_window->resize_callback != NULL)) { - int temp = egl_window->width; - egl_window->width = egl_window->height; - egl_window->height = temp; - egl_window->resize_callback(egl_window, egl_window->private); - } } WL_EGL_EXPORT int -- 2.7.4 From 27275e57af0bf648079b9ec3c0a8d73e0dc83ace Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Mon, 10 Apr 2017 13:21:52 +0900 Subject: [PATCH 14/16] wayland-egl: Changed an ERR_LOG to normal log when wl_egl_window already has been rotated. Change-Id: I10f8fe00be29cdfb24c0c3a6962091d87dbca4c6 Signed-off-by: joonbum.ko --- src/wayland-egl/wayland-egl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wayland-egl/wayland-egl.c b/src/wayland-egl/wayland-egl.c index 46d47a0..475bf7c 100644 --- a/src/wayland-egl/wayland-egl.c +++ b/src/wayland-egl/wayland-egl.c @@ -150,7 +150,7 @@ wl_egl_window_set_rotation(struct wl_egl_window *egl_window, } if (egl_window->rotation == rotation) { - WL_EGL_ERR("rotation value is same"); + WL_EGL_LOG(2, "rotation(%d) egl_window->rotation(%d) already rotated"); return; } -- 2.7.4 From 632bc065beec9e09625f5b8d1e3f987efad5475c Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Mon, 15 May 2017 18:58:44 +0900 Subject: [PATCH 15/16] tpl_surface, tpl_wayland_egl: Refactored the procedue related with frontbuffer mode. - There was a problem with HWC in the existing procedure related with frontbuffer_mode. The existing procedure was difficult to use eglFrontBufferSetSEC because the client did not know exactly when to use the frontbuffer. - Solved this problem through wayland_tbm_client API. - platform/core/uifw/wayland-tbm commit_id : 0de11f336d666d7b8cc171deeb404ec3b287cde8 commit_message : client: added wayland_tbm_client_queue_check_activate - See comments of the codes related with frontbuffer_mode for details. Change-Id: I5d024284d65ae65277fe67a4cd000a78f592665f Signed-off-by: joonbum.ko --- src/tpl_surface.c | 25 ++-------------- src/tpl_wayland_egl.c | 80 +++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 75 insertions(+), 30 deletions(-) diff --git a/src/tpl_surface.c b/src/tpl_surface.c index c991868..a595ef4 100644 --- a/src/tpl_surface.c +++ b/src/tpl_surface.c @@ -214,16 +214,7 @@ tpl_surface_dequeue_buffer_with_sync(tpl_surface_t *surface, TRACE_BEGIN("TPL:DEQUEUE_BUFFER"); TPL_OBJECT_LOCK(surface); - if (surface->is_frontbuffer_mode && surface->frontbuffer) { - if (TPL_TRUE == surface->backend.validate(surface)) { - tbm_surface = surface->frontbuffer; - } else { - surface->frontbuffer = NULL; - } - } - - if (!tbm_surface) - tbm_surface = surface->backend.dequeue_buffer(surface, timeout_ns, sync_fence); + tbm_surface = surface->backend.dequeue_buffer(surface, timeout_ns, sync_fence); if (tbm_surface) { /* Update size of the surface. */ @@ -277,15 +268,6 @@ tpl_surface_enqueue_buffer_with_damage_and_sync(tpl_surface_t *surface, TRACE_BEGIN("TPL:ENQUEUE_BUFFER_WITH_DAMAGE"); TPL_OBJECT_LOCK(surface); - if (surface->is_frontbuffer_mode) { - if (surface->frontbuffer == tbm_surface) { - TPL_OBJECT_UNLOCK(surface); - TRACE_END(); - return ret; - } - surface->frontbuffer = tbm_surface; - } - TPL_LOG_F("tpl_surface_t(%p) tbm_surface(%p) (%dx%d)", surface, tbm_surface, tbm_surface_get_width(tbm_surface), tbm_surface_get_height(tbm_surface)); @@ -341,7 +323,7 @@ tpl_surface_create_swapchain(tpl_surface_t *surface, tbm_format format, return TPL_ERROR_INVALID_PARAMETER; } - if ((width <= 0) || (height <= 0) ) { + if ((width <= 0) || (height <= 0)) { TPL_ERR("Invalid width or height!"); return TPL_ERROR_INVALID_PARAMETER; } @@ -422,8 +404,7 @@ tpl_surface_set_reset_cb(tpl_surface_t *surface, void *data, tpl_surface_cb_func { tpl_result_t ret = TPL_ERROR_NONE; - if (!surface) - { + if (!surface) { TPL_ERR("Invalid surface!"); return TPL_ERROR_INVALID_PARAMETER; } diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index 4f9cb12..fe8c4d8 100644 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -62,6 +62,7 @@ struct _tpl_wayland_egl_buffer { int rotation; tbm_bo bo; tpl_bool_t reset; /* TRUE if queue reseted by external */ + tpl_bool_t is_new; /* for frontbuffer mode */ struct wl_proxy *wl_proxy; /* wl_buffer proxy */ }; @@ -817,6 +818,33 @@ __tpl_wayland_egl_surface_enqueue_buffer(tpl_surface_t *surface, wayland_egl_surface, wayland_egl_surface->tbm_queue, tbm_surface, tbm_bo_export(tbm_surface_internal_get_bo(tbm_surface, 0))); + wayland_egl_buffer = + __tpl_wayland_egl_get_wayland_buffer_from_tbm_surface(tbm_surface); + + if (!wayland_egl_buffer) return TPL_ERROR_INVALID_PARAMETER; + + /* In frontbuffer mode, will skip tbm_surface_queue_enqueue, acquire, and + * commit if surface->frontbuffer that is already set and the tbm_surface + * client want to enqueue are the same. + */ + if (surface->is_frontbuffer_mode && surface->frontbuffer == tbm_surface) { + TPL_LOG_B("WL_EGL", + "[ENQ_SKIP][F] Client already uses frontbuffer(%p)", + surface->frontbuffer); + + /* The first buffer to be activated in frontbuffer mode muse be + * committed. Subsequence frames do not need to be committed because + * the buffer is already displayed. + */ + if (wayland_egl_buffer->is_new) { + __tpl_wayland_egl_surface_commit(surface, tbm_surface, + num_rects, rects); + wayland_egl_buffer->is_new = TPL_FALSE; + } + + return TPL_ERROR_NONE; + } + if (wayland_egl_surface->vblank_done == TPL_FALSE) __tpl_wayland_egl_surface_wait_vblank(surface); @@ -833,11 +861,6 @@ __tpl_wayland_egl_surface_enqueue_buffer(tpl_surface_t *surface, TPL_OBJECT_UNLOCK(&wayland_egl_surface->base); } - wayland_egl_buffer = - __tpl_wayland_egl_get_wayland_buffer_from_tbm_surface(tbm_surface); - - if (!wayland_egl_buffer) return TPL_ERROR_INVALID_PARAMETER; - if (wayland_egl_buffer->reset) { /* * When tbm_surface_queue being reset for receiving @@ -1006,6 +1029,7 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou struct wl_egl_window *wl_egl_window = (struct wl_egl_window *)surface->native_handle; tbm_surface_queue_error_e tsq_err = 0; + int is_activated = 0; if (sync_fence) *sync_fence = -1; @@ -1026,10 +1050,41 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou } if (__tpl_wayland_egl_surface_wait_dequeuable(surface)) { - TPL_ERR("Failed to wait dequeeable buffer"); + TPL_ERR("Failed to wait dequeueable buffer"); return NULL; } + /* wayland client can check their states (ACTIVATED or DEACTIVATED) with + * below function [wayland_tbm_client_queue_check_activate()]. + * This function has to be called between + * __tpl_wayland_egl_surface_wait_dequeuable and tbm_surface_queue_dequeue() + * in order to know what state the buffer will be dequeued next. + * + * ACTIVATED state means non-composite mode. Client can get buffers which + can be displayed directly(without compositing). + * DEACTIVATED state means composite mode. Client's buffer will be displayed + by compositor(E20) with compositing. + */ + is_activated = wayland_tbm_client_queue_check_activate( + wayland_egl_display->wl_tbm_client, + wayland_egl_surface->tbm_queue); + + if (surface->is_frontbuffer_mode && surface->frontbuffer != NULL) { + /* If surface->frontbuffer is already set in frontbuffer mode, + * it will return that frontbuffer if it is still activated, + * otherwise dequeue the new buffer after initializing + * surface->frontbuffer to NULL. */ + if (is_activated) { + TPL_LOG_B("WL_EGL", + "[DEQ][F] surface->frontbuffer(%p) BO_NAME(%d)", + surface->frontbuffer, + tbm_bo_export(tbm_surface_internal_get_bo( + surface->frontbuffer, 0))); + return surface->frontbuffer; + } else + surface->frontbuffer = NULL; + } + tsq_err = tbm_surface_queue_dequeue(wayland_egl_surface->tbm_queue, &tbm_surface); if (!tbm_surface) { @@ -1040,6 +1095,9 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou tbm_surface_internal_ref(tbm_surface); + if (surface->is_frontbuffer_mode && is_activated) + surface->frontbuffer = tbm_surface; + if ((wayland_egl_buffer = __tpl_wayland_egl_get_wayland_buffer_from_tbm_surface(tbm_surface)) != NULL) { TRACE_MARK("[DEQ][REUSED]BO_NAME:%d", tbm_bo_export(wayland_egl_buffer->bo)); @@ -1056,8 +1114,9 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou wayland_egl_buffer->width = wl_egl_window->width; wayland_egl_buffer->height = wl_egl_window->height; wayland_egl_buffer->rotation = wl_egl_window->rotation; - wayland_egl_buffer->reset = TPL_FALSE; + wayland_egl_buffer->is_new = TPL_FALSE; + wayland_egl_surface->reset = TPL_FALSE; if (wayland_egl_surface->dequeued_buffers) { @@ -1104,9 +1163,14 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou wayland_egl_buffer->bo = tbm_surface_internal_get_bo(tbm_surface, 0); wayland_egl_buffer->wayland_egl_surface = wayland_egl_surface; - /* reset flag is to check whether it is the buffer before tbm_surface_queue is reset or not. */ + /* reset flag is to check whether it is the buffer before + * tbm_surface_queue is reset or not. */ wayland_egl_buffer->reset = TPL_FALSE; + /* 'is_new' flag is to check wheter it is a new buffer need to commit + * in frontbuffer mode. */ + wayland_egl_buffer->is_new = TPL_TRUE; + wayland_egl_surface->current_buffer = tbm_surface; wayland_egl_surface->reset = TPL_FALSE; -- 2.7.4 From 52babccab63b757c16cfba32caf26de9b8aa7953 Mon Sep 17 00:00:00 2001 From: "joonbum.ko" Date: Tue, 16 May 2017 18:17:54 +0900 Subject: [PATCH 16/16] tpl_wayland_egl: Fixed case of non-pixed buffer in frontbuffer mode. Change-Id: Ie5b6a7bc29bca359aa01092d4b9c86c79d8b0713 Signed-off-by: joonbum.ko --- src/tpl_wayland_egl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/tpl_wayland_egl.c b/src/tpl_wayland_egl.c index fe8c4d8..262183a 100644 --- a/src/tpl_wayland_egl.c +++ b/src/tpl_wayland_egl.c @@ -49,6 +49,7 @@ struct _tpl_wayland_egl_surface { tpl_bool_t reset; /* TRUE if queue reseted by external */ tdm_client_vblank *tdm_vblank; /* vblank object for each wl_surface */ tpl_bool_t vblank_done; + tpl_bool_t is_activated; tpl_list_t *attached_buffers; /* list for tracking [ACQ]~[REL] buffers */ tpl_list_t *dequeued_buffers; /* list for tracking [DEQ]~[ENQ] buffers */ struct tizen_surface_shm_flusher *tizen_surface_shm_flusher; /* wl_proxy for buffer flush */ @@ -500,6 +501,7 @@ __tpl_wayland_egl_surface_init(tpl_surface_t *surface) wayland_egl_surface->resized = TPL_FALSE; wayland_egl_surface->reset = TPL_FALSE; wayland_egl_surface->vblank_done = TPL_TRUE; + wayland_egl_surface->is_activated = TPL_FALSE; wayland_egl_surface->current_buffer = NULL; wayland_egl_surface->attached_buffers = __tpl_list_alloc(); @@ -1115,9 +1117,12 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou wayland_egl_buffer->height = wl_egl_window->height; wayland_egl_buffer->rotation = wl_egl_window->rotation; wayland_egl_buffer->reset = TPL_FALSE; - wayland_egl_buffer->is_new = TPL_FALSE; + + if (wayland_egl_surface->is_activated != is_activated) + wayland_egl_buffer->is_new = TPL_TRUE; wayland_egl_surface->reset = TPL_FALSE; + wayland_egl_surface->is_activated = is_activated; if (wayland_egl_surface->dequeued_buffers) { TPL_OBJECT_LOCK(&wayland_egl_surface->base); @@ -1170,6 +1175,7 @@ __tpl_wayland_egl_surface_dequeue_buffer(tpl_surface_t *surface, uint64_t timeou /* 'is_new' flag is to check wheter it is a new buffer need to commit * in frontbuffer mode. */ wayland_egl_buffer->is_new = TPL_TRUE; + wayland_egl_surface->is_activated = is_activated; wayland_egl_surface->current_buffer = tbm_surface; wayland_egl_surface->reset = TPL_FALSE; -- 2.7.4