1 #ifndef __DALI_SDL_APPLICATION_H__
2 #define __DALI_SDL_APPLICATION_H__
5 Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
7 This file is part of Dali
9 PROPRIETARY/CONFIDENTIAL
11 This software is the confidential and proprietary information of
12 SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
13 disclose such Confidential Information and shall use it only in
14 accordance with the terms of the license agreement you entered
15 into with SAMSUNG ELECTRONICS.
17 SAMSUNG make no representations or warranties about the suitability
18 of the software, either express or implied, including but not limited
19 to the implied warranties of merchantability, fitness for a particular
20 purpose, or non-infringement. SAMSUNG shall not be liable for any
21 damages suffered by licensee as a result of using, modifying or
22 distributing this software or its derivatives.
26 #include "platform-abstractions/emscripten/emscripten-platform-abstraction.h"
27 #include "sdl-gesture-manager.h"
28 #include "adaptors/common/gl/gl-implementation.h"
29 #include "sdl-gl-sync-abstraction.h"
30 #include "sdl-render-controller.h"
31 #include <dali/public-api/common/dali-common.h>
32 #include <dali/public-api/signals/connection-tracker.h>
33 #include <dali/integration-api/core.h>
34 #include <gl/egl-implementation.h>
41 * An SdlApplication object for Emscripten main()
43 * This provides libSDL calls for creating the application surface and running
44 * the update and rendering.
45 * The libSDL calls are stubbed by Emscripten into browser canvas construction
46 * calls. The update and rendering are exposed as we are in a single threaded
47 * environment and the browser needs to control the main loop.
48 * Emscripten provides emscripten_set_main_loop() for the 'loop' function which
49 * should render one frame and return
52 class DALI_IMPORT_API SdlApplication : public ConnectionTracker
56 // Default values derived from H2 device.
57 static const unsigned int DEFAULT_SURFACE_WIDTH;
58 static const unsigned int DEFAULT_SURFACE_HEIGHT;
61 static constexpr float DEFAULT_HORIZONTAL_DPI = 220.0f;
62 static constexpr float DEFAULT_VERTICAL_DPI = 217.0f;
64 static const float DEFAULT_HORIZONTAL_DPI = 220.0f;
65 static const float DEFAULT_VERTICAL_DPI = 217.0f;
68 static const unsigned int DEFAULT_RENDER_INTERVAL = 1;
73 * @param[in] surfaceWidth Initial width of the browser canvas
74 * @param[in] surfaceHeight Initial height of the browser canvas
75 * @param[in] horizontalDpi Horizontal Dpi
76 * @param[in] verticalDpi Vertical Dpi
78 SdlApplication( size_t surfaceWidth = DEFAULT_SURFACE_WIDTH,
79 size_t surfaceHeight = DEFAULT_SURFACE_HEIGHT,
80 float horizontalDpi = DEFAULT_HORIZONTAL_DPI,
81 float verticalDpi = DEFAULT_VERTICAL_DPI );
86 virtual ~SdlApplication();
89 * Run the update once.
90 * The browser is a single threaded environment and this is called on a browser callback.
95 * Render once. The browser is a single threaded environment.
96 * The browser is a single threaded environment and this is called on a browser callback.
101 * Send Touch event into Dali event loop.
102 * The allows the browser to supply touch events.
104 void SendTouchEvent(double x, double y, int downUpMotion);
108 * The allows the browser to tell Dali that the rendering canvas has changed size.
110 * @param[in] width The surface/canvas width
111 * @param[in] height The surface/canvas height
113 void SetSurfaceWidth( unsigned int width, unsigned height );
116 EmscriptenPlatformAbstraction mPlatformAbstraction;
117 SdlGlSyncAbstraction mGlSyncAbstraction;
118 SdlRenderController mRenderController;
119 Internal::Adaptor::GlImplementation mGlAbstraction;
120 SdlGestureManager mGestureManager;
122 Integration::UpdateStatus mStatus;
123 Integration::RenderStatus mRenderStatus;
125 Integration::Core* mCore;
126 Internal::Adaptor::EglImplementation mEglImplementation;
128 unsigned int mSurfaceWidth;
129 unsigned int mSurfaceHeight;
132 unsigned int mSeconds;
133 unsigned int mMicroSeconds;
135 void SdlCreateWindow(size_t surfaceWidth,
136 size_t surfaceHeight,
137 const std::string &title);