Commit d6a19ad7 authored by Sharaf Zaman's avatar Sharaf Zaman

Setup for android(arm) build

Summary: scripts and changes to setup krita for android devices

Reviewers: vkrause, apol, #krita

Tags: #krita

Differential Revision: https://phabricator.kde.org/D19726
parent 52ee93a9
......@@ -28,3 +28,8 @@ GSYMS
BROWSE
*.kate-swp
/po/
/kf5/
/build-android/
/b/
/i/
/d/
SET(PREFIX_ext_exiv2 "${EXTPREFIX}" )
if (ANDROID)
ExternalProject_Add( ext_exiv2
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL http://files.kde.org/krita/build/dependencies/exiv2-0.26-trunk.tar.gz
......@@ -8,10 +9,29 @@ ExternalProject_Add( ext_exiv2
PATCH_COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/tzname.patch
COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/patch_mingw.patch
COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/disable_exiv_apps.diff
INSTALL_DIR ${PREFIX_ext_exiv2}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_exiv2} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE} -DEXIV2_ENABLE_BUILD_SAMPLES=OFF -DEXIV2_ENABLE_BUILD_PO=OFF -DEXIV2_ENABLE_NLS=OFF -DICONV_INCLUDE_DIR=${PREFIX_ext_exiv2}/include -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DANDROID_PLATFORM=${ANDROID_PLATFORM} -DEXPAT_LIBRARY=$ENV{KRITA_ROOT}/i/lib/libexpat.so -DEXPAT_INCLUDE_DIR=$ENV{KRITA_ROOT}/i/include
UPDATE_COMMAND ""
DEPENDS ext_iconv ext_expat
)
else()
ExternalProject_Add( ext_exiv2
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL http://files.kde.org/krita/build/dependencies/exiv2-0.26-trunk.tar.gz
URL_MD5 5399e3b570d7f9205f0e76d47582da4c
PATCH_COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/tzname.patch
COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/patch_mingw.patch
COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/disable_exiv_apps.diff
INSTALL_DIR ${PREFIX_ext_exiv2}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_exiv2} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE} -DEXIV2_ENABLE_BUILD_SAMPLES=OFF -DEXIV2_ENABLE_BUILD_PO=OFF -DEXIV2_ENABLE_NLS=OFF -DICONV_INCLUDE_DIR=${PREFIX_ext_exiv2}/include
UPDATE_COMMAND ""
DEPENDS ext_iconv ext_expat
)
endif()
......@@ -14,6 +14,20 @@ ExternalProject_Add( ext_expat
DEPENDS ext_patch
)
elseif (ANDROID)
ExternalProject_Add( ext_expat
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL http://files.kde.org/krita/build/dependencies/expat-2.1.0.tar.gz
URL_MD5 dd7dab7a5fea97d2a6a43f511449b7cd
INSTALL_DIR ${PREFIX_ext_expat}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_expat} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DANDROID_PLATFORM=${ANDROID_PLATFORM}
BUILD_COMMAND make
INSTALL_COMMAND make install
UPDATE_COMMAND ""
)
else()
ExternalProject_Add( ext_expat
......@@ -22,9 +36,9 @@ ExternalProject_Add( ext_expat
URL_MD5 dd7dab7a5fea97d2a6a43f511449b7cd
INSTALL_DIR ${PREFIX_ext_expat}
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=${PREFIX_ext_expat} ${GLOBAL_AUTOMAKE_PROFILE}
BUILD_COMMAND make
INSTALL_COMMAND make install
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=${PREFIX_ext_expat} ${GLOBAL_AUTOMAKE_PROFILE}
BUILD_COMMAND make
INSTALL_COMMAND make install
UPDATE_COMMAND ""
......
......@@ -4,11 +4,11 @@ ExternalProject_Add( ext_lcms2
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL http://files.kde.org/krita/build/dependencies/lcms2-2.9.tar.gz
URL_MD5 8de1b7724f578d2995c8fdfa35c3ad0e
PATCH_COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/lcms2-9.diff
INSTALL_DIR ${PREFIX_ext_lcms2}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_lcms2} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE} -DBUILD_TESTS=FALSE -DBUILD_UTILS=FALSE -DBUILD_STATIC=FALSE
UPDATE_COMMAND ""
DEPENDS ext_patch
)
......@@ -17,11 +17,11 @@ ExternalProject_Add( ext_lcms2
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL http://files.kde.org/krita/build/dependencies/lcms2-2.9.tar.gz
URL_MD5 8de1b7724f578d2995c8fdfa35c3ad0e
PATCH_COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/lcms2-9.diff
INSTALL_DIR ${PREFIX_ext_lcms2}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_lcms2} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE} -DBUILD_TESTS=FALSE -DBUILD_UTILS=FALSE -DBUILD_STATIC=FALSE
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_lcms2} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE} -DBUILD_TESTS=FALSE -DBUILD_UTILS=FALSE -DBUILD_STATIC=FALSE -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DANDROID_PLATFORM=${ANDROID_PLATFORM}
UPDATE_COMMAND ""
)
endif ()
......@@ -4,8 +4,10 @@ ExternalProject_Add( ext_png
URL http://files.kde.org/krita/build/dependencies/libpng-1.6.34.tar.gz
URL_MD5 03fbc5134830240104e96d3cda648e71
PATCH_COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/androidpng.patch
INSTALL_DIR ${PREFIX_ext_png}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_png} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE} -DPNG_TESTS=OFF
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_png} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE} -DPNG_TESTS=OFF -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DANDROID_PLATFORM=${ANDROID_PLATFORM}
UPDATE_COMMAND ""
)
diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -194,7 +194,7 @@
include(CheckCSourceCompiles)
option(ld-version-script "Enable linker version script" ON)
-if(ld-version-script AND NOT APPLE)
+if(ld-version-script AND NOT APPLE AND NOT ANDROID)
# Check if LD supports linker scripts.
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 {
global: sym;
SET(PREFIX_ext_quazip "${EXTPREFIX}" )
ExternalProject_Add( ext_quazip
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL https://github.com/stachenov/quazip/archive/0.7.6.zip
URL_MD5 a3335649c34053385d8390dd1a6f1ca4
PATCH_COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/find_quazip.diff
COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/liblocation.diff
INSTALL_DIR ${PREFIX_ext_quazip}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_quazip} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE}
UPDATE_COMMAND ""
DEPENDS ext_zlib
if (ANDROID)
ExternalProject_Add( ext_quazip
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL https://github.com/stachenov/quazip/archive/0.7.6.zip
URL_MD5 a3335649c34053385d8390dd1a6f1ca4
PATCH_COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/find_quazip.diff
COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/liblocation.diff
INSTALL_DIR ${PREFIX_ext_quazip}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_quazip} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DANDROID_PLATFORM=${ANDROID_PLATFORM} -DQt5Core_DIR=$ENV{QT_ANDROID}/lib/cmake/Qt5Core/
UPDATE_COMMAND ""
DEPENDS ext_zlib
)
else()
ExternalProject_Add( ext_quazip
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL https://github.com/stachenov/quazip/archive/0.7.6.zip
URL_MD5 a3335649c34053385d8390dd1a6f1ca4
PATCH_COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/find_quazip.diff
COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/liblocation.diff
INSTALL_DIR ${PREFIX_ext_quazip}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_quazip} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE}
UPDATE_COMMAND ""
DEPENDS ext_zlib
)
endif()
......@@ -6,7 +6,7 @@ ExternalProject_Add(
URL http://files.kde.org/krita/build/dependencies/zlib-1.2.11.tar.gz
URL_MD5 1c9f62f0778697a09d36121ead88e08e
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_zlib} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_zlib} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DANDROID_PLATFORM=${ANDROID_PLATFORM}
UPDATE_COMMAND ""
)
......
......@@ -251,6 +251,38 @@ endif(MINGW)
#########################
########################
# FIXME: Apparently there is no better way to do this in android toolchain
if(ANDROID)
set (Qt5_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5/)
set (Qt5Core_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5Core/)
set (Qt5Gui_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5Gui/)
set (Qt5Widgets_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5Widgets/)
set (Qt5Xml_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5Xml/)
set (Qt5Network_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5Network/)
set (Qt5PrintSupport_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5PrintSupport/)
set (Qt5Svg_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5Svg/)
set (Qt5Test_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5Test/)
set (Qt5Concurrent_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5Concurrent/)
set (Qt5Multimedia_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5Multimedia/)
set (Qt5Qml_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5Qml/)
set (Qt5Quick_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5Quick/)
set (Qt5QuickWidgets_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5QuickWidgets/)
set(ECM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/kf5/kde/install/share/ECM/cmake)
set(KF5Config_DIR ${CMAKE_CURRENT_SOURCE_DIR}/kf5/kde/install/lib/cmake/KF5Config/)
set(KF5Config_DIR ${CMAKE_CURRENT_SOURCE_DIR}/kf5/kde/install/lib/cmake/KF5Config/)
set(KF5I18n_DIR ${CMAKE_CURRENT_SOURCE_DIR}/kf5/kde/install/lib/cmake/KF5I18n/)
set(KF5WidgetsAddons_DIR ${CMAKE_CURRENT_SOURCE_DIR}/kf5/kde/install/lib/cmake/KF5WidgetsAddons)
set(KF5Completion_DIR ${CMAKE_CURRENT_SOURCE_DIR}/kf5/kde/install/lib/cmake/KF5Completion)
set(KF5GuiAddons_DIR ${CMAKE_CURRENT_SOURCE_DIR}/kf5/kde/install/lib/cmake/KF5GuiAddons)
set(KF5ItemViews_DIR ${CMAKE_CURRENT_SOURCE_DIR}/kf5/kde/install/lib/cmake/KF5ItemViews)
set(KF5WindowSystem_DIR ${CMAKE_CURRENT_SOURCE_DIR}/kf5/kde/install/lib/cmake/KF5WindowSystem)
set(KF5ItemModels_DIR ${CMAKE_CURRENT_SOURCE_DIR}/kf5/kde/install/lib/cmake/KF5ItemModels)
set(KF5CoreAddons_DIR ${CMAKE_CURRENT_SOURCE_DIR}/kf5/kde/install/lib/cmake/KF5CoreAddons)
endif()
find_package(ECM 5.22 REQUIRED NOMODULE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
include(ECMOptionalAddSubdirectory)
......@@ -306,6 +338,16 @@ find_package(Qt5 ${MIN_QT_VERSION}
Concurrent
)
if (UNIX AND NOT APPLE AND NOT ANDROID)
if (${Qt5_VERSION} VERSION_GREATER "5.11")
set (USE_QT_XCB ON)
else()
option(USE_QT_XCB "Do not use Krita's forked XCB connection and tablet support on X11, but leave everything to Qt." OFF)
add_feature_info("Use Qt's XCB and Tablet support on X11" USE_QT_XCB "Do not use Krita's forked XCB connection and tablet support on X11, but leave everything to Qt.")
endif()
configure_file(config_use_qt_xcb.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config_use_qt_xcb.h)
endif()
include (MacroAddFileDependencies)
include (MacroBoolTo01)
include (MacroEnsureOutOfSourceBuild)
......@@ -343,7 +385,7 @@ set_package_properties(Qt5QuickWidgets PROPERTIES
PURPOSE "Optionally used for the touch gui for Krita")
endif()
if (NOT WIN32 AND NOT APPLE)
if (NOT WIN32 AND NOT APPLE AND NOT ANDROID)
find_package(Qt5 ${MIN_QT_VERSION} REQUIRED X11Extras)
......@@ -456,6 +498,19 @@ set(KRITA_PLUGIN_INSTALL_DIR ${LIB_INSTALL_DIR}/kritaplugins)
############################
###########################
if (ANDROID)
set (PNG_LIBRARY ${CMAKE_CURRENT_SOURCE_DIR}/i/lib/libpng16.so)
set (PNG_PNG_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/i/include/libpng16)
set (LibExiv2_LIBRARIES ${CMAKE_CURRENT_SOURCE_DIR}/i/lib/libexiv2.so)
set (LibExiv2_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/i/include/)
set (LCMS2_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/i/include)
set (LCMS2_LIBRARIES ${CMAKE_CURRENT_SOURCE_DIR}/i/lib/liblcms2.so)
set (QUAZIP_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/i/include/quazip5)
set (QUAZIP_LIBRARIES ${CMAKE_CURRENT_SOURCE_DIR}/i/lib/libquazip5.so)
set (Boost_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/i/armeabi-v7a/include/boost-1_69)
set (Boost_LIBRARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/i/armeabi-v7a/lib)
endif()
find_package(PNG REQUIRED)
if (APPLE)
......@@ -700,7 +755,7 @@ set_package_properties(Poppler PROPERTIES
##
## Test for quazip
##
##
find_package(QuaZip 0.6)
set_package_properties(QuaZip PROPERTIES
DESCRIPTION "A library for reading and writing zip files"
......@@ -763,3 +818,4 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/po OR EXISTS ${CMAKE_CURRENT_BINARY_DIR}/p
find_package(KF5I18n CONFIG REQUIRED)
ki18n_install(po)
endif()
To build for Android the first thing to do is to read the README.md in
$KRITA_ROOT/3rdparty
1) Set the neccessary environment variables
```
KRITA_ROOT # project root directory
CMAKE_ANDROID_NDK
QT_ANDROID # example: /opt/Qt/5.12/android_armv7/
ANDROID_API_LEVEL # example: 21
ANDROID_SDK_ROOT
PY_INCLUDE_PATH # python3 includes directory usually /usr/includes/python3.5/
PY_LIBRARY # python3 lib directory usually /usr/lib/python3.5/
```
2) Create three directories in project root(KRITA_ROOT): d, i, b
3) First we'll have to build kf5 dependencies which we use `kdesrc-build`
to do. So run `$KRITA_ROOT/packaging/android/build_kf5.sh`.
Now if package kcompletion, kcoreaddons fail at first, don't stop the
build, wait for the script to stop, it will be patched and rebuilt
automatically.
4) `cd` to `$KRITA_ROOT/b` and run
```$KRITA_ROOT/packaging/android/build_ext.sh```
Now in this case
every package SHOULD be built. If it doesn't, then it's mostly a bug.
5) Now we have to build boost.
Run:
```$KRITA_ROOT/packaging/android/build_boost.sh```
This should build without any errors.
6) Create a directory in $KRITA_ROOT and set INSTALL_PREFIX environment
variable to set installation directory.
Then run `$KRITA_ROOT/packaging/android/configure_krita.sh`
```
mkdir $KRITA_ROOT/build-android && cd $KRITA_ROOT/build-android
$KRITA_ROOT/packaging/android/configure_krita.sh
```
This should build all the _required_ libraries.
7) If build is configured properly then run
```
make -j5
make install
```
arm binary should be ready
......@@ -8,6 +8,10 @@ include_directories(
${CMAKE_BINARY_DIR}/libs/flake
)
if (ANDROID)
add_definitions(-DQT_OPENGL_ES_3)
endif()
add_subdirectory(styles)
add_subdirectory(tests)
......
......@@ -7,6 +7,10 @@ include_directories(SYSTEM
${EIGEN3_INCLUDE_DIR}
)
if (ANDROID)
add_definitions(-DQT_OPENGL_ES_3)
endif()
add_subdirectory(plugins)
set(kritaqml_SRCS
......
......@@ -7,6 +7,10 @@ include_directories(SYSTEM
${OCIO_INCLUDE_DIR}
)
if (ANDROID)
add_definitions(-DQT_OPENGL_ES_3)
endif()
add_subdirectory( tests )
if (APPLE)
......@@ -334,7 +338,7 @@ set(kritaui_LIB_SRCS
canvas/kis_mirror_axis.cpp
kis_abstract_perspective_grid.cpp
KisApplication.cpp
KisAutoSaveRecoveryDialog.cpp
KisDetailsPane.cpp
......@@ -530,11 +534,16 @@ target_link_libraries(kritaui KF5::CoreAddons KF5::Completion KF5::I18n KF5::Ite
kritaimpex kritacolor kritaimage kritalibbrush kritawidgets kritawidgetutils ${PNG_LIBRARIES} LibExiv2::LibExiv2
)
if (ANDROID)
target_link_libraries(kritaui GLESv3)
target_link_libraries(kritaui Qt5::Gui)
endif()
if (HAVE_QT_MULTIMEDIA)
target_link_libraries(kritaui Qt5::Multimedia)
endif()
if (NOT WIN32 AND NOT APPLE)
if (NOT WIN32 AND NOT APPLE AND NOT ANDROID)
target_link_libraries(kritaui ${X11_X11_LIB}
${X11_Xinput_LIB}
${XCB_LIBRARIES})
......@@ -549,7 +558,7 @@ endif ()
target_link_libraries(kritaui ${OPENEXR_LIBRARIES})
# Add VSync disable workaround
if(NOT WIN32 AND NOT APPLE)
if(NOT WIN32 AND NOT APPLE AND NOT ANDROID)
target_link_libraries(kritaui ${CMAKE_DL_LIBS} Qt5::X11Extras)
endif()
......
......@@ -21,6 +21,10 @@
#include "KoConfig.h"
#ifdef Q_OS_ANDROID
#define GL_MULTISAMPLE 0x809D
#endif
#include <QPainter>
#include <QToolButton>
#include <QApplication>
......
......@@ -46,7 +46,7 @@
#include "KisOpenGLModeProber.h"
#include <KoColorModelStandardIds.h>
#ifndef Q_OS_OSX
#if !defined(Q_OS_OSX) && !defined(Q_OS_ANDROID)
#include <QOpenGLFunctions_2_1>
#endif
......@@ -104,7 +104,7 @@ public:
QVector3D vertices[6];
QVector2D texCoords[6];
#ifndef Q_OS_OSX
#if !defined(Q_OS_OSX) && !defined(Q_OS_ANDROID)
QOpenGLFunctions_2_1 *glFn201;
#endif
......@@ -250,7 +250,7 @@ void KisOpenGLCanvas2::initializeGL()
{
KisOpenGL::initializeContext(context());
initializeOpenGLFunctions();
#ifndef Q_OS_OSX
#if !defined(Q_OS_OSX) && !defined(Q_OS_ANDROID)
if (!KisOpenGL::hasOpenGLES()) {
d->glFn201 = context()->versionFunctions<QOpenGLFunctions_2_1>();
if (!d->glFn201) {
......@@ -416,6 +416,7 @@ void KisOpenGLCanvas2::paintToolOutline(const QPainterPath &path)
d->solidColorShader->setUniformValue(d->solidColorShader->location(Uniform::ModelViewProjection), modelMatrix);
if (!KisOpenGL::hasOpenGLES()) {
#ifndef Q_OS_ANDROID
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glEnable(GL_COLOR_LOGIC_OP);
......@@ -425,6 +426,7 @@ void KisOpenGLCanvas2::paintToolOutline(const QPainterPath &path)
}
#else
glLogicOp(GL_XOR);
#endif
#endif
} else {
glEnable(GL_BLEND);
......@@ -458,8 +460,10 @@ void KisOpenGLCanvas2::paintToolOutline(const QPainterPath &path)
d->lineBuffer.allocate(vertices.constData(), 3 * vertices.size() * sizeof(float));
}
else {
#ifndef Q_OS_ANDROID
d->solidColorShader->enableAttributeArray(PROGRAM_VERTEX_ATTRIBUTE);
d->solidColorShader->setAttributeArray(PROGRAM_VERTEX_ATTRIBUTE, vertices.constData());
#endif
}
glDrawArrays(GL_LINE_STRIP, 0, vertices.size());
......@@ -471,7 +475,9 @@ void KisOpenGLCanvas2::paintToolOutline(const QPainterPath &path)
}
if (!KisOpenGL::hasOpenGLES()) {
#ifndef Q_OS_ANDROID
glDisable(GL_COLOR_LOGIC_OP);
#endif
} else {
glDisable(GL_BLEND);
}
......
......@@ -18,7 +18,13 @@
#include "opengl/kis_opengl_image_textures.h"
#ifdef Q_OS_ANDROID
#include <qopengl.h>
#endif
#ifndef Q_OS_ANDROID
#include <QOpenGLFunctions>
#endif
#include <QOpenGLContext>
#include <QMessageBox>
......@@ -458,12 +464,16 @@ void initializeRGBA16FTextures(QOpenGLContext *ctx, KisGLTexturesInfo &texturesI
texturesInfo.internalFormat = GL_RGBA16F;
dbgUI << "Using half (GLES or GL3)";
} else if (ctx->hasExtension("GL_ARB_texture_float")) {
#ifndef Q_OS_ANDROID
texturesInfo.internalFormat = GL_RGBA16F_ARB;
dbgUI << "Using ARB half";
#endif
}
else if (ctx->hasExtension("GL_ATI_texture_float")) {
#ifndef Q_OS_ANDROID
texturesInfo.internalFormat = GL_RGBA_FLOAT16_ATI;
dbgUI << "Using ATI half";
#endif
}
bool haveBuiltInOpenExr = false;
......@@ -476,13 +486,17 @@ void initializeRGBA16FTextures(QOpenGLContext *ctx, KisGLTexturesInfo &texturesI
destinationColorDepthId = Float16BitsColorDepthID;
dbgUI << "Pixel type half (GLES or GL3)";
} else if (haveBuiltInOpenExr && ctx->hasExtension("GL_ARB_half_float_pixel")) {
#ifndef Q_OS_ANDROID
texturesInfo.type = GL_HALF_FLOAT_ARB;
destinationColorDepthId = Float16BitsColorDepthID;
dbgUI << "Pixel type half";
#endif
} else {
#ifndef Q_OS_ANDROID
texturesInfo.type = GL_FLOAT;
destinationColorDepthId = Float32BitsColorDepthID;
dbgUI << "Pixel type float";
#endif
}
texturesInfo.format = GL_RGBA;
}
......@@ -494,9 +508,11 @@ void KisOpenGLImageTextures::updateTextureFormat()
if (!(m_image && ctx)) return;
if (!KisOpenGL::hasOpenGLES()) {
#ifndef Q_OS_ANDROID
m_texturesInfo.internalFormat = GL_RGBA8;
m_texturesInfo.type = GL_UNSIGNED_BYTE;
m_texturesInfo.format = GL_BGRA;
#endif
} else {
m_texturesInfo.internalFormat = GL_BGRA8_EXT;
m_texturesInfo.type = GL_UNSIGNED_BYTE;
......@@ -528,11 +544,15 @@ void KisOpenGLImageTextures::updateTextureFormat()
m_texturesInfo.internalFormat = GL_RGBA32F;
dbgUI << "Using float (GLES or GL3)";
} else if (ctx->hasExtension("GL_ARB_texture_float")) {
#ifndef Q_OS_ANDROID
m_texturesInfo.internalFormat = GL_RGBA32F_ARB;
dbgUI << "Using ARB float";
#endif
} else if (ctx->hasExtension("GL_ATI_texture_float")) {
#ifndef Q_OS_ANDROID
m_texturesInfo.internalFormat = GL_RGBA_FLOAT32_ATI;
dbgUI << "Using ATI float";
#endif
}
m_texturesInfo.type = GL_FLOAT;
......@@ -540,6 +560,7 @@ void KisOpenGLImageTextures::updateTextureFormat()
destinationColorDepthId = Float32BitsColorDepthID;
}
else if (colorDepthId == Integer16BitsColorDepthID) {
#ifndef Q_OS_ANDROID
if (!KisOpenGL::hasOpenGLES()) {
m_texturesInfo.internalFormat = GL_RGBA16;
m_texturesInfo.type = GL_UNSIGNED_SHORT;
......@@ -547,17 +568,20 @@ void KisOpenGLImageTextures::updateTextureFormat()
destinationColorDepthId = Integer16BitsColorDepthID;
dbgUI << "Using 16 bits rgba";
}
#endif
// TODO: for ANGLE, see if we can convert to 16f to support 10-bit display
}
}
else {
// We will convert the colorspace to 16 bits rgba, instead of 8 bits
if (colorDepthId == Integer16BitsColorDepthID && !KisOpenGL::hasOpenGLES()) {
#ifndef Q_OS_ANDROID
m_texturesInfo.internalFormat = GL_RGBA16;
m_texturesInfo.type = GL_UNSIGNED_SHORT;
m_texturesInfo.format = GL_BGRA;
destinationColorDepthId = Integer16BitsColorDepthID;
dbgUI << "Using conversion to 16 bits rgba";
#endif
} else if (colorDepthId == Float16BitsColorDepthID && KisOpenGL::hasOpenGLES()) {
// TODO: try removing opengl es limit
initializeRGBA16FTextures(ctx, m_texturesInfo, destinationColorDepthId);
......
#!/bin/sh
: ${KRITA_ROOT?"Project root path must be set"}
: ${CMAKE_ANDROID_NDK?"Android NDK path must be set"}
CURDIR="$(pwd)"/
VERSION="1_69"
git clone https://github.com/moritz-wundke/Boost-for-Android $KRITA_ROOT/d/boost
cd $KRITA_ROOT/d/boost
./build-android.sh --prefix=$KRITA_ROOT/i --with-libraries=system \
--boost=1.69.0 --arch=armeabi-v7a \
$CMAKE_ANDROID_NDK
cd $KRITA_ROOT/i/armeabi-v7a/lib
# possible only because just one library is being used
mv libboost_system-clang-mt-a32-$VERSION.a libboost_system.a
cd $CURDIR
#!/bin/sh
# See more: 3rdparty/README.md
# Build external dependencies in $KRITA_ROOT/3rdparty
# assuming in $KRITA_ROOT/b
: ${KRITA_ROOT?"Project root path must be set"}
: ${CMAKE_ANDROID_NDK?"Android NDK path must be set"}
: ${ANDROID_API_LEVEL?"Android API level is required"}
: ${QT_ANDROID?"Path to QT root is required"}
export ANDROID_ARCHITECTURE=arm
export ANDROID_ABI=armeabi-v7a
export ANDROID_TOOLCHAIN=arm-linux-androideabi
export ANDROID_NATIVE_API_LEVEL=android-$ANDROID_API_LEVEL
cmake $KRITA_ROOT/3rdparty \
-DINSTALL_ROOT=$KRITA_ROOT/i \
-DEXTERNALS_DOWNLOAD_DIR=$KRITA_ROOT/d \
-DCMAKE_INSTALL_PREFIX=$KRITA_ROOT/i \
-DCMAKE_TOOLCHAIN_FILE=$CMAKE_ANDROID_NDK/build/cmake/android.toolchain.cmake \
-DANDROID_PLATFORM=$ANDROID_NATIVE_API_LEVEL \
-DANDROID_ABI=$ANDROID_ABI \
-DANDROID_STL=c++_static
# You can comment these and build them individually
cmake --build . --config RelWithDebInfo --target ext_png
cmake --build . --config RelWithDebInfo --target ext_zlib
cmake --build . --config RelWithDebInfo --target ext_quazip
cmake --build . --config RelWithDebInfo --target ext_lcms2
# this one SHOULD be built before exiv
cmake --build . --config RelWithDebInfo --target ext_expat
cmake --build . --config RelWithDebInfo --target ext_exiv2
#!/bin/bash
# parts used from KDE/KStars project
: ${QT_ANDROID?"Qt path must be set"}
: ${CMAKE_ANDROID_NDK?"Android NDK path must be set"}
: ${ANDROID_SDK_ROOT?"Android SDK path must be set"}
: ${ANDROID_API_LEVEL?"Android API level"}
: ${KRITA_ROOT?"Project root path must be set"}
export ANDROID_ARCHITECTURE=arm
export ANDROID_ABI=armeabi-v7a
export ANDROID_TOOLCHAIN=arm-linux-androideabi
export ANDROID_NATIVE_API_LEVEL=android-$ANDROID_API_LEVEL
cd $KRITA_ROOT
# Get the directory where the script is stored
SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
CURDIR="$(pwd)"/
mkdir kf5
cd kf5
git clone git://anongit.kde.org/scratch/cordlandwehr/kdesrc-conf-android.git
mkdir -p extragear/kdesrc-build
git clone git://anongit.kde.org/kdesrc-build extragear/kdesrc-build
ln -s extragear/kdesrc-build/kdesrc-build kdesrc-build
ln -s kdesrc-conf-android/kdesrc-buildrc kdesrc-buildrc
# Change the build configuration
sed -E -i "s|build-dir.*|build-dir $CURDIR/kf5/kde/build/${android_architecture} |g" kdesrc-conf-android/kdesrc-buildrc
sed -E -i "s|source-dir.*|source-dir $CURDIR/kf5/kde/src |g" kdesrc-conf-android/kdesrc-buildrc
sed -E -i "s|kdedir.*|kdedir $CURDIR/kf5/kde/install/${android_architecture} |g" kdesrc-conf-android/kdesrc-buildrc
sed -i -- 's/make-options -j8/make-options -j4 VERBOSE=1/g' kdesrc-conf-android/kdesrc-buildrc
# The toolchain provided by Linux distribution can be old, use this instead
./kdesrc-build extra-cmake-modules
if [ -e $qt_android_libs ]
then
sed -E -i "s|-DCMAKE_PREFIX_PATH=.*?\\ |-DCMAKE_PREFIX_PATH=$QT_ANDROID- -DCMAKE_ANDROID_NDK=$CMAKE_ANDROID_NDK -DECM_ADDITIONAL_FIND_ROOT_PATH=$QT_ANDROID\;$CURDIR/kf5/kde/install -DANDROID_STL=c++_static -DCMAKE_TOOLCHAIN_FILE=$CURDIR/kf5/kde/install/share/ECM/toolchain/Android.cmake -DKCONFIG_USE_DBUS=OFF|g" kdesrc-conf-android/kdesrc-buildrc
else
echo "Qt Android libraries path doesn't exist. Exiting."
exit
fi
sed -E -i "s|use-modules.+|use-modules kconfig ki18n|g" kdesrc-conf-android/kdesrc-buildrc
rm -rf ${kf5_android_path}/kde/build/${android_architecture}/* # clean build folders
# Needs to be patched, ignore the errors
./kdesrc-build libintl-lite ki18n kcoreaddons kcompletion
# patches
sed -i -- 's/check_cxx_source_compiles/#check_cxx_source_compiles/g' kde/src/frameworks/ki18n/cmake/FindLibIntl.cmake
sed -i -- 's/target_link_libraries(ktranscript PRIVATE Qt5::Qml Qt5::Core)/target_link_libraries(ktranscript PRIVATE Qt5::Qml Qt5::Core -l:libc.a -Wl,--exclude-libs=ALL)/g' $CURDIR/kf5/kde/src/frameworks/ki18n/src/CMakeLists.txt
sed -i 's/static \(.*getpwent()\)/\1/' $CURDIR/kf5/kde/src/frameworks/kcoreaddons/src/lib/util/kuser_unix.cpp
sed -i 's/static \(.*setgrent()\)/\1/' $CURDIR/kf5/kde/src/frameworks/kcoreaddons/src/lib/util/kuser_unix.cpp
sed -i 's/static \(.*getgrent()\)/\1/' $CURDIR/kf5/kde/src/frameworks/kcoreaddons/src/lib/util/kuser_unix.cpp
sed -i 's/static \(.*endgrent()\)/\1/' $CURDIR/kf5/kde/src/frameworks/kcoreaddons/src/lib/util/kuser_unix.cpp
sed -i 's/KF5::WidgetsAddons/& -l:libc.a -Wl,--exclude-libs=ALL/' $CURDIR/kf5/kde/src/frameworks/kcompletion/src/CMakeLists.txt
sed -i '/add_subdirectory(tests)/s/^/#/' $CURDIR/kf5/kde/src/frameworks/kitemmodels/CMakeLists.txt
sed -i '/add_subdirectory(autotests)/s/^/#/' $CURDIR/kf5/kde/src/frameworks/kitemmodels/CMakeLists.txt
./kdesrc-build kcoreaddons \
frameworks-android \
kwidgetsaddons kcompletion \
kguiaddons ki18n \
kitemmodels kitemviews \
kwindowsystem
# Fix some config files
sed -i '/find_package(PythonInterp/ s/^/#/' kde/install/lib/cmake/KF5I18n/KF5I18nMacros.cmake
cp /usr/lib/x86_64-linux-gnu/libexec/kf5/kconfig_compiler_kf5 $CURDIR/kf5/kde/install/lib/libexec/kf5/kconfig_compiler_kf5
cd $CURDIR
#!/bin/sh
: ${KRITA_ROOT?"Project root path must be set"}
: ${CMAKE_ANDROID_NDK?"Android NDK path must be set"}
: ${ANDROID_SDK_ROOT?"Android SDK path must be set"}
: ${ANDROID_API_LEVEL?"API level required"}
: ${QT_ANDROID?"path to qt android required"}
CURDIR="$(pwd)"/
export ANDROID_ARCHITECTURE=arm
export ANDROID_ABI=armeabi-v7a