Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DirectFb backend #56

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ option(USE_BACKEND_BCM_NEXUS_WAYLAND "Whether to enable support for the BCM_NEXU
option(USE_BACKEND_BCM_RPI "Whether to enable support for the BCM_RPi WPE backend" OFF)
option(USE_BACKEND_INTEL_CE "Whether to enable support for the Intel CE WPE backend" OFF)
option(USE_BACKEND_WAYLAND_EGL "Whether to enable support for the wayland-egl WPE backend" OFF)
option(USE_BACKEND_DIRECTFB "Whether to enable support for the directfb WPE backend" OFF)
option(USE_BACKEND_WESTEROS "Whether to enable support for the Westeros WPE backend" OFF)
option(USE_BACKEND_REALTEK "Whether to enable support for Realtek's Wayland EGL WPE backend" OFF)
option(USE_BACKEND_VIV_IMX6_EGL "Whether to enable support for NXP's IMX6 EGL WPE backend" OFF)
Expand Down Expand Up @@ -126,6 +127,10 @@ if (USE_BACKEND_WAYLAND_EGL)
include(src/wayland-egl/CMakeLists.txt)
endif ()

if (USE_BACKEND_DIRECTFB)
include(src/directfb/CMakeLists.txt)
endif ()

if (USE_BACKEND_WESTEROS)
include(src/westeros/CMakeLists.txt)
endif ()
Expand Down
54 changes: 54 additions & 0 deletions cmake/FindDirectFB.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# - Try to Find DirectFB
# Once done, this will define
#
# DIRECTFB_FOUND - system has DirectFB.
# DIRECTFB_INCLUDE_DIRS - the DirectFB include directories
# DIRECTFB_LIBRARIES - link these to use DirectFB.
#
# Copyright (C) 2014 Igalia S.L.
# Copyright (C) 1994-2020 OpenTV, Inc. and Nagravision S.A.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. 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.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS 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 HOLDER OR ITS
# 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.



find_package(PkgConfig)

pkg_check_modules(PC_DIRECTFB directfb)

if (PC_DIRECTFB_FOUND)
set(DIRECTFB_DEFINITIONS ${PC_DIRECTFB_CFLAGS_OTHER})
endif ()

find_path(DIRECTFB_INCLUDE_DIRS NAMES directfb.h
HINTS ${PC_DIRECTFB_INCLUDEDIR} ${PC_DIRECTFB_INCLUDE_DIRS}
)

find_library(DIRECTFB_LIBRARIES directfb
HINTS ${PC_DIRECTFB_LIBDIR} ${PC_DIRECTFB_LIBRARY_DIRS}
)

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(DIRECTFB DEFAULT_MSG DIRECTFB_INCLUDE_DIRS DIRECTFB_LIBRARIES)

mark_as_advanced(DIRECTFB_INCLUDE_DIRS DIRECTFB_LIBRARIES)

27 changes: 27 additions & 0 deletions src/directfb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/src/directfb/cmake")

find_package(EGL REQUIRED)
find_package(DirectFB REQUIRED)

add_definitions(-DBACKEND_DIRECTFB=1)

list(APPEND WPE_PLATFORM_INCLUDE_DIRECTORIES
${DIRECTFB_INCLUDE_DIRS}
"${CMAKE_SOURCE_DIR}/src/diretfb/"
)

list(APPEND WPE_PLATFORM_LIBRARIES
${DIRECTFB_LIBRARIES}
${EGL_LIBRARIES_dbpl}
)

list(APPEND WPE_PLATFORM_SOURCES
src/directfb/renderer-backend.cpp
src/directfb/view-backend.cpp
src/directfb/display.cpp
)

if (USE_INPUT_LIBINPUT OR USE_VIRTUAL_KEYBOARD)
add_definitions(-DKEY_INPUT_HANDLING_LIBINPUT=1)
endif ()

88 changes: 88 additions & 0 deletions src/directfb/dfb_backend_log.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* Copyright (C) 2018-2020 OpenTV, Inc. and Nagravision S.A.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* 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
* HOLDER 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.
*/

#ifndef __DFB_BACKEND_LOG_H
#define __DFB_BACKEND_LOG_H

#include <stdint.h>

#define WPEB_DFB_LOG_DEFAULT_TYPE 1 /* Default fprintf with color logging */

#define WPEB_DFB_ABORT(cond) abort()
#define WPEB_DFB_ASSERT(cond) assert((cond))

#if defined (WPEB_DFB_LOG_DEFAULT_TYPE) && (WPEB_DFB_LOG_DEFAULT_TYPE == 1)

#define WPEB_DFB_LOG_LEVEL 3 /* 0 Critical, 1 Error, 2 Warning, 3 Info, 4 Debug, 5 Trace */

#if (WPEB_DFB_LOG_LEVEL >= 0)
#define WPEB_DFB_LOG_CRITICAL(msg, args...) fprintf(stderr, "\033[22;31m[WPEBACKEND_DFB] [CRITICAL] %-24s +%-4d : \033[22;0m" msg , __FILE__, __LINE__, ## args);
#else
#define WPEB_DFB_LOG_CRITICAL(msg, args...) ((void)0)
#endif

#if (WPEB_DFB_LOG_LEVEL >= 1)
#define WPEB_DFB_LOG_ERROR(msg, args...) fprintf(stderr, "\033[22;31m[WPEBACKEND_DFB] [ERROR] %-24s +%-4d : \033[22;0m" msg , __FILE__, __LINE__, ## args);
#else
#define WPEB_DFB_LOG_ERROR(msg, args...) ((void)0)
#endif

#if (WPEB_DFB_LOG_LEVEL >= 2)
#define WPEB_DFB_LOG_WARNING(msg, args...) fprintf(stderr, "\033[22;35m[WPEBACKEND_DFB] [WARN] %-24s +%-4d : \033[22;0m" msg , __FILE__, __LINE__, ## args);
#else
#define WPEB_DFB_LOG_WARNING(msg, args...) ((void)0)
#endif

#if (WPEB_DFB_LOG_LEVEL >= 3)
#define WPEB_DFB_LOG_INFO(msg, args...) fprintf(stderr, "\033[22;34m[WPEBACKEND_DFB] [INFO] %-24s +%-4d : \033[22;0m" msg , __FILE__, __LINE__, ## args);
#else
#define WPEB_DFB_LOG_INFO(msg, args...) ((void)0)
#endif

#if (WPEB_DFB_LOG_LEVEL >= 4)
#define WPEB_DFB_LOG_DEBUG(msg, args...) fprintf(stderr, "\033[22;32m[WPEBACKEND_DFB] [DEBUG] %-24s +%-4d : \033[22;0m" msg , __FILE__, __LINE__, ## args);
#else
#define WPEB_DFB_LOG_DEBUG(msg, args...) ((void)0)
#endif

#if (WPEB_DFB_LOG_LEVEL >= 5)
#define WPEB_DFB_LOG_TRACE(msg, args...) fprintf(stderr, "\033[22;33m[WPEBACKEND_DFB] [TRACE] %-24s +%-4d : \033[22;0m" msg , __FILE__, __LINE__, ## args);
#else
#define WPEB_DFB_LOG_TRACE(msg, args...) ((void)0)
#endif

#else /* Disable logging */

#define WPEB_DFB_LOG_CRITICAL ((void)0)
#define WPEB_DFB_LOG_ERROR ((void)0)
#define WPEB_DFB_LOG_WARNING ((void)0)
#define WPEB_DFB_LOG_INFO ((void)0)
#define WPEB_DFB_LOG_DEBUG ((void)0)
#define WPEB_DFB_LOG_TRACE ((void)0)

#endif /* WPEB_DFB_LOG_DEFAULT_TYPE*/

#endif /*__DFB_BACKEND_LOG_H*/
Loading