Skip to content

Commit 52e1e0c

Browse files
jpouderouxkwrobot
authored andcommittedJul 27, 2021
Merge topic 'FixAndroidBuild'
2ed358c Merge branch 'upstream-diy2' into FixAndroidBuild bc9d43d diy2 2021-07-21 (e47b2b29) e5535c7 Update diy2 to fix some Android builds 912a276 Fix Android build Acked-by: Kitware Robot <[email protected]> Acked-by: Tim Thirion <[email protected]> Acked-by: Mathieu Westphal <[email protected]> Acked-by: Ben Boeckel <[email protected]> Merge-request: !8163
2 parents 0bda4b1 + 2ed358c commit 52e1e0c

9 files changed

+73
-32
lines changed
 

‎CMake/vtkAndroid.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ set(ANDROID_NDK ${_ANDROID_NDK_DEFAULT} CACHE PATH
2727
if (NOT EXISTS "${ANDROID_NDK}/platforms")
2828
message(FATAL_ERROR "Please set a valid ANDROID_NDK path")
2929
endif()
30-
set(ANDROID_NATIVE_API_LEVEL "21" CACHE STRING "Android Native API Level")
30+
set(ANDROID_NATIVE_API_LEVEL "27" CACHE STRING "Android Native API Level")
3131
set(ANDROID_ARCH_ABI "armeabi" CACHE STRING "Target Android architecture/abi")
3232

3333
# find android

‎CMake/vtkMobileDevices.cmake

+7-4
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@ if (ANDROID OR APPLE_IOS)
2121
)
2222
elseif (ANDROID)
2323
unset(OPENGL_INCLUDE_DIR CACHE)
24-
unset(OPENGL_gl_LIBRARY CACHE)
24+
unset(OPENGL_gles3_LIBRARY CACHE)
2525
unset(OPENGL_egl_LIBRARY CACHE)
2626

27-
find_path(OPENGL_INCLUDE_DIR GLES3/gl3.h)
28-
find_library(OPENGL_gl_LIBRARY NAMES GLESv3)
29-
find_library(OPENGL_egl_LIBRARY NAMES EGL)
27+
set(_ANDROID_INC_PATH ${CMAKE_ANDROID_NDK}/sysroot/usr/include)
28+
set(_ANDROID_LIB_PATH ${CMAKE_ANDROID_NDK}/platforms/android-${CMAKE_SYSTEM_VERSION}/arch-${CMAKE_ANDROID_ARCH}/usr/lib)
29+
30+
find_path(OPENGL_INCLUDE_DIR GLES3/gl3.h ${_ANDROID_INC_PATH})
31+
find_library(OPENGL_gles3_LIBRARY NAMES GLESv3 PATHS ${_ANDROID_LIB_PATH})
32+
find_library(OPENGL_egl_LIBRARY NAMES EGL PATHS ${_ANDROID_LIB_PATH})
3033
endif()
3134
else()
3235
# Choose static or shared libraries.

‎Common/Core/vtkAndroidOutputWindow.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ class VTKCOMMONCORE_EXPORT vtkAndroidOutputWindow : public vtkOutputWindow
4848
* New lines are converted to carriage return new lines.
4949
*/
5050
void DisplayText(const char*) override;
51-
virtual void DisplayErrorText(const char*);
52-
virtual void DisplayWarningText(const char*);
53-
virtual void DisplayGenericWarningText(const char*);
51+
void DisplayErrorText(const char*) override;
52+
void DisplayWarningText(const char*) override;
53+
void DisplayGenericWarningText(const char*) override;
5454
///@}
5555

56-
virtual void DisplayDebugText(const char*);
56+
void DisplayDebugText(const char*) override;
5757

5858
protected:
5959
vtkAndroidOutputWindow();

‎Common/Core/vtkOutputWindow.cxx

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#if defined(_WIN32) && !defined(VTK_USE_X)
1818
#include "vtkWin32OutputWindow.h"
1919
#endif
20-
#if defined(ANDROID)
20+
#if defined(__ANDROID__) || defined(ANDROID)
2121
#include "vtkAndroidOutputWindow.h"
2222
#endif
2323

‎Rendering/OpenGL2/vtkEGLRenderWindow.cxx

+38-10
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@
3131
#include <cassert>
3232
#include <sstream>
3333

34-
#ifdef ANDROID
34+
#if defined(__ANDROID__) || defined(ANDROID)
3535
#include <android/native_window.h>
36+
#include <vtkAndroidRenderWindowInteractor.h>
3637
#endif
3738

3839
namespace
@@ -139,7 +140,7 @@ struct vtkEGLRenderWindow::vtkInternals
139140
vtkEGLRenderWindow::vtkEGLRenderWindow()
140141
{
141142
this->Internals = new vtkInternals();
142-
this->OwnWindow = 1;
143+
this->OwnWindow = true;
143144
this->ScreenSize[0] = 1920;
144145
this->ScreenSize[1] = 1080;
145146

@@ -338,7 +339,7 @@ void vtkEGLRenderWindow::ResizeWindow(int width, int height)
338339
*/
339340
EGLint surfaceType, clientAPI;
340341
const EGLint* contextAttribs;
341-
#ifdef ANDROID
342+
#if defined(__ANDROID__) || defined(ANDROID)
342343
surfaceType = EGL_WINDOW_BIT;
343344
clientAPI = EGL_OPENGL_ES2_BIT;
344345
const EGLint contextES2[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
@@ -354,7 +355,7 @@ void vtkEGLRenderWindow::ResizeWindow(int width, int height)
354355
EGL_RED_SIZE, 8, EGL_ALPHA_SIZE, 8, EGL_DEPTH_SIZE, 8, EGL_RENDERABLE_TYPE, clientAPI,
355356
EGL_NONE };
356357

357-
#if !defined(ANDROID)
358+
#if !defined(__ANDROID__) && !defined(ANDROID)
358359
const EGLint surface_attribs[] = { EGL_WIDTH, width, EGL_HEIGHT, height, EGL_NONE };
359360
#endif
360361

@@ -375,7 +376,7 @@ void vtkEGLRenderWindow::ResizeWindow(int width, int height)
375376

376377
EGLint major = 0, minor = 0;
377378
vtkEGLDisplayInitializationHelper::Initialize(impl->Display, &major, &minor);
378-
#if !defined(ANDROID)
379+
#if !defined(__ANDROID__) && !defined(ANDROID)
379380
if (major <= 1 && minor < 4)
380381
{
381382
vtkErrorMacro("Only EGL 1.4 and greater allows OpenGL as client API. "
@@ -396,7 +397,7 @@ void vtkEGLRenderWindow::ResizeWindow(int width, int height)
396397
return;
397398
}
398399

399-
#ifdef ANDROID
400+
#if defined(__ANDROID__) || defined(ANDROID)
400401
EGLint format = 0;
401402
/* EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is
402403
* guaranteed to be accepted by ANativeWindow_setBuffersGeometry().
@@ -417,13 +418,22 @@ void vtkEGLRenderWindow::ResizeWindow(int width, int height)
417418
eglDestroySurface(impl->Display, impl->Surface);
418419
}
419420

420-
#ifdef ANDROID
421+
#if defined(__ANDROID__) || defined(ANDROID)
421422
impl->Surface = eglCreateWindowSurface(impl->Display, config, impl->Window, nullptr);
422423
#else
423424
impl->Surface = eglCreatePbufferSurface(impl->Display, config, surface_attribs);
424425
#endif
425426
this->Mapped = this->ShowWindow;
426-
this->OwnWindow = 1;
427+
this->OwnWindow = true;
428+
429+
#if defined(__ANDROID__) || defined(ANDROID)
430+
vtkAndroidRenderWindowInteractor* interactor =
431+
vtkAndroidRenderWindowInteractor::SafeDownCast(this->Interactor);
432+
if (interactor)
433+
{
434+
interactor->SetOwnWindow(this->OwnWindow);
435+
}
436+
#endif
427437

428438
this->MakeCurrent();
429439

@@ -485,9 +495,18 @@ void vtkEGLRenderWindow::WindowInitialize(void)
485495
this->OpenGLInit();
486496

487497
// for offscreen EGL always turn on point sprites
488-
#if !defined(ANDROID) && defined(GL_POINT_SPRITE)
498+
#if !defined(__ANDROID__) && !defined(ANDROID) && defined(GL_POINT_SPRITE)
489499
glEnable(GL_POINT_SPRITE);
490500
#endif
501+
502+
#if defined(__ANDROID__) || defined(ANDROID)
503+
vtkAndroidRenderWindowInteractor* interactor =
504+
vtkAndroidRenderWindowInteractor::SafeDownCast(this->Interactor);
505+
if (interactor)
506+
{
507+
interactor->SetOwnWindow(this->OwnWindow);
508+
}
509+
#endif
491510
}
492511

493512
// Initialize the rendering window.
@@ -608,8 +627,17 @@ void vtkEGLRenderWindow::SetPosition(int x, int y)
608627
// Set this RenderWindow to a pre-existing window.
609628
void vtkEGLRenderWindow::SetWindowInfo(const char*)
610629
{
611-
this->OwnWindow = 0;
612630
this->Mapped = 1;
631+
this->OwnWindow = false;
632+
633+
#if defined(__ANDROID__) || defined(ANDROID)
634+
vtkAndroidRenderWindowInteractor* interactor =
635+
vtkAndroidRenderWindowInteractor::SafeDownCast(this->Interactor);
636+
if (interactor)
637+
{
638+
interactor->SetOwnWindow(this->OwnWindow);
639+
}
640+
#endif
613641
}
614642

615643
void vtkEGLRenderWindow::SetWindowName(const char* name)

‎Rendering/UI/vtkAndroidRenderWindowInteractor.cxx

+1-1
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ void vtkAndroidRenderWindowInteractor::Initialize()
537537
// get the info we need from the RenderingWindow
538538
ren = this->RenderWindow;
539539

540-
if (ren->GetOwnWindow())
540+
if (this->GetOwnWindow())
541541
{
542542
this->AndroidApplication->userData = this;
543543
this->AndroidApplication->onAppCmd = android_handle_cmd;

‎Rendering/UI/vtkAndroidRenderWindowInteractor.h

+19-9
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ class VTKRENDERINGUI_EXPORT vtkAndroidRenderWindowInteractor : public vtkRenderW
4444
static vtkAndroidRenderWindowInteractor* New();
4545

4646
vtkTypeMacro(vtkAndroidRenderWindowInteractor, vtkRenderWindowInteractor);
47-
void PrintSelf(ostream& os, vtkIndent indent);
47+
void PrintSelf(ostream& os, vtkIndent indent) override;
4848

4949
/**
5050
* Initialize the event handler
5151
*/
52-
virtual void Initialize();
52+
void Initialize() override;
5353

5454
///@{
5555
/**
@@ -61,16 +61,16 @@ class VTKRENDERINGUI_EXPORT vtkAndroidRenderWindowInteractor : public vtkRenderW
6161
* and all other interactors associated with the widget are disabled
6262
* when their data is not displayed.
6363
*/
64-
virtual void Enable();
65-
virtual void Disable();
64+
void Enable() override;
65+
void Disable() override;
6666
///@}
6767

6868
/**
6969
* Android specific application terminate, calls ClassExitMethod then
7070
* calls PostQuitMessage(0) to terminate the application. An application can Specify
7171
* ExitMethod for alternative behavior (i.e. suppression of keyboard exit)
7272
*/
73-
void TerminateApp(void);
73+
void TerminateApp(void) override;
7474

7575
///@{
7676
/**
@@ -87,7 +87,7 @@ class VTKRENDERINGUI_EXPORT vtkAndroidRenderWindowInteractor : public vtkRenderW
8787
* These methods correspond to the Exit, User and Pick
8888
* callbacks. They allow for the Style to invoke them.
8989
*/
90-
virtual void ExitCallback();
90+
void ExitCallback() override;
9191

9292
virtual void SetAndroidApplication(struct android_app* app) { this->AndroidApplication = app; }
9393

@@ -110,6 +110,14 @@ class VTKRENDERINGUI_EXPORT vtkAndroidRenderWindowInteractor : public vtkRenderW
110110
void HandleCommand(int32_t cmd);
111111
int32_t HandleInput(AInputEvent* event);
112112

113+
///@{
114+
/**
115+
* Returns true if the window is owned by VTK.
116+
*/
117+
vtkSetMacro(OwnWindow, bool);
118+
vtkGetMacro(OwnWindow, bool);
119+
///@}
120+
113121
protected:
114122
vtkAndroidRenderWindowInteractor();
115123
~vtkAndroidRenderWindowInteractor() override;
@@ -138,16 +146,18 @@ class VTKRENDERINGUI_EXPORT vtkAndroidRenderWindowInteractor : public vtkRenderW
138146
* Win32-specific internal timer methods. See the superclass for detailed
139147
* documentation.
140148
*/
141-
virtual int InternalCreateTimer(int timerId, int timerType, unsigned long duration);
142-
virtual int InternalDestroyTimer(int platformTimerId);
149+
int InternalCreateTimer(int timerId, int timerType, unsigned long duration) override;
150+
int InternalDestroyTimer(int platformTimerId) override;
143151
///@}
144152

145153
/**
146154
* This will start up the event loop and never return. If you
147155
* call this method it will loop processing events until the
148156
* application is exited.
149157
*/
150-
virtual void StartEventLoop();
158+
void StartEventLoop() override;
159+
160+
vtkTypeBool OwnWindow;
151161

152162
private:
153163
vtkAndroidRenderWindowInteractor(const vtkAndroidRenderWindowInteractor&) = delete;

‎ThirdParty/diy2/update.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ readonly name="diy2"
88
readonly ownership="Diy2 Upstream <kwrobot@kitware.com>"
99
readonly subtree="ThirdParty/$name/vtk$name"
1010
readonly repo="https://gitlab.kitware.com/third-party/diy2.git"
11-
readonly tag="for/vtk-20191127-gd6d04d0d"
11+
readonly tag="for/vtk-20210721-gd6d04d0d"
1212
readonly paths="
1313
.gitattributes
1414
CMakeLists.vtk.txt

‎ThirdParty/diy2/vtkdiy2/include/vtkdiy2/io/utils.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ namespace utils
115115
s_template[filename.size()] = 0;
116116

117117
int handle = -1;
118-
#if defined(__MACH__)
118+
#if defined(__MACH__) || defined(__ANDROID_API__)
119119
// TODO: figure out how to open with O_SYNC
120120
handle = ::mkstemp(s_template.get());
121121
#else

0 commit comments

Comments
 (0)
Please sign in to comment.