From c1bb1606717a5a831a0e7bdaca8b4eb86dc5a89e Mon Sep 17 00:00:00 2001 From: Seoyeon Kim Date: Mon, 17 Dec 2018 14:06:00 +0900 Subject: [PATCH] [Tizen] Add codes for Dali Windows Backend This reverts commit a914d0739c13d3ccaa0b844cfdd4205cc61201d6. Change-Id: Ie4497bd4add93e539c380ca3f1ce645da00b3884 --- CMakeLists.txt | 388 +++++++++ .../adaptor-framework/input-method-context.h | 1 - .../windows/accessibility-adaptor-impl-win.cpp | 69 ++ .../common/combined-update-render-controller.cpp | 4 + dali/internal/adaptor/windows/adaptor-impl-win.cpp | 52 ++ dali/internal/adaptor/windows/framework-win.cpp | 313 +++++++ .../clipboard/windows/clipboard-impl-win.cpp | 131 +++ dali/internal/graphics/gles/egl-implementation.cpp | 1 - .../graphics/windows-gl/egl-image-extensions.cpp | 242 ++++++ .../graphics/windows/vsync-monitor-win.cpp | 106 +++ dali/internal/imaging/common/file-download.h | 4 + dali/internal/imaging/common/image-loader.cpp | 7 +- dali/internal/imaging/common/loader-astc.cpp | 14 +- dali/internal/imaging/common/loader-bmp.cpp | 82 +- dali/internal/imaging/common/loader-gif.cpp | 6 +- dali/internal/imaging/common/loader-ico.cpp | 12 +- dali/internal/imaging/common/loader-jpeg-turbo.cpp | 20 +- dali/internal/imaging/common/loader-ktx.cpp | 12 +- dali/internal/imaging/common/loader-png.cpp | 6 +- dali/internal/imaging/common/loader-wbmp.cpp | 20 +- .../imaging/windows/curl-environment-win.cpp | 76 ++ .../internal/imaging/windows/file-download-win.cpp | 291 +++++++ .../windows/input-method-context-factory-win.cpp | 46 ++ .../windows/input-method-context-impl-win.cpp | 865 ++++++++++++++++++++ .../input/windows/input-method-context-impl-win.h | 293 +++++++ dali/internal/input/windows/key-mapping-win.cpp | 101 +++ .../input/windows/virtual-keyboard-impl-win.cpp | 165 ++++ dali/internal/system/common/abort-handler.h | 2 +- dali/internal/system/common/file-closer.h | 22 +- dali/internal/system/file.list | 3 +- dali/internal/system/linux/file-closer-linux.cpp | 52 ++ .../system/windows/callback-manager-win.cpp | 96 +++ .../internal/system/windows/callback-manager-win.h | 95 +++ dali/internal/system/windows/file-closer-win.cpp | 70 ++ dali/internal/system/windows/timer-impl-win.cpp | 162 ++++ dali/internal/system/windows/trigger-event.cpp | 132 +++ .../system/windows/widget-application-impl-win.cpp | 74 ++ .../system/windows/widget-application-impl-win.h | 86 ++ .../system/windows/widget-controller-win.cpp | 46 ++ .../system/windows/widget-controller-win.h | 66 ++ .../text-abstraction/font-client-plugin-impl.cpp | 4 +- .../window-system/common/event-handler.cpp | 2 +- .../windows/display-connection-factory-win.cpp | 44 + .../windows/display-connection-factory-win.h | 46 ++ .../windows/display-connection-impl-win.cpp | 107 +++ .../windows/display-connection-impl-win.h | 101 +++ .../window-system/windows/event-system-win.cpp | 78 ++ .../window-system/windows/event-system-win.h | 284 +++++++ .../windows/pixmap-render-surface-win.cpp | 254 ++++++ .../windows/pixmap-render-surface-win.h | 197 +++++ .../windows/platform-implement-win.cpp | 398 +++++++++ .../window-system/windows/platform-implement-win.h | 104 +++ .../windows/render-surface-factory-win.cpp | 58 ++ .../windows/render-surface-factory-win.h | 44 + .../window-system/windows/window-base-win.cpp | 904 +++++++++++++++++++++ .../window-system/windows/window-base-win.h | 415 ++++++++++ .../window-system/windows/window-factory-win.cpp | 51 ++ .../window-system/windows/window-factory-win.h | 42 + .../window-system/windows/window-system-win.cpp | 65 ++ dali/public-api/dali-adaptor-common.h | 2 +- 60 files changed, 7349 insertions(+), 84 deletions(-) create mode 100755 CMakeLists.txt create mode 100755 dali/internal/accessibility/windows/accessibility-adaptor-impl-win.cpp mode change 100644 => 100755 dali/internal/adaptor/common/combined-update-render-controller.cpp create mode 100755 dali/internal/adaptor/windows/adaptor-impl-win.cpp create mode 100755 dali/internal/adaptor/windows/framework-win.cpp create mode 100755 dali/internal/clipboard/windows/clipboard-impl-win.cpp create mode 100755 dali/internal/graphics/windows-gl/egl-image-extensions.cpp create mode 100755 dali/internal/graphics/windows/vsync-monitor-win.cpp mode change 100644 => 100755 dali/internal/imaging/common/file-download.h create mode 100755 dali/internal/imaging/windows/curl-environment-win.cpp create mode 100755 dali/internal/imaging/windows/file-download-win.cpp create mode 100755 dali/internal/input/windows/input-method-context-factory-win.cpp create mode 100755 dali/internal/input/windows/input-method-context-impl-win.cpp create mode 100755 dali/internal/input/windows/input-method-context-impl-win.h create mode 100755 dali/internal/input/windows/key-mapping-win.cpp create mode 100755 dali/internal/input/windows/virtual-keyboard-impl-win.cpp mode change 100644 => 100755 dali/internal/system/common/abort-handler.h mode change 100644 => 100755 dali/internal/system/common/file-closer.h mode change 100644 => 100755 dali/internal/system/file.list create mode 100755 dali/internal/system/linux/file-closer-linux.cpp create mode 100755 dali/internal/system/windows/callback-manager-win.cpp create mode 100755 dali/internal/system/windows/callback-manager-win.h create mode 100755 dali/internal/system/windows/file-closer-win.cpp create mode 100755 dali/internal/system/windows/timer-impl-win.cpp create mode 100755 dali/internal/system/windows/trigger-event.cpp create mode 100755 dali/internal/system/windows/widget-application-impl-win.cpp create mode 100755 dali/internal/system/windows/widget-application-impl-win.h create mode 100755 dali/internal/system/windows/widget-controller-win.cpp create mode 100755 dali/internal/system/windows/widget-controller-win.h mode change 100644 => 100755 dali/internal/text/text-abstraction/font-client-plugin-impl.cpp create mode 100755 dali/internal/window-system/windows/display-connection-factory-win.cpp create mode 100755 dali/internal/window-system/windows/display-connection-factory-win.h create mode 100755 dali/internal/window-system/windows/display-connection-impl-win.cpp create mode 100755 dali/internal/window-system/windows/display-connection-impl-win.h create mode 100755 dali/internal/window-system/windows/event-system-win.cpp create mode 100755 dali/internal/window-system/windows/event-system-win.h create mode 100755 dali/internal/window-system/windows/pixmap-render-surface-win.cpp create mode 100755 dali/internal/window-system/windows/pixmap-render-surface-win.h create mode 100755 dali/internal/window-system/windows/platform-implement-win.cpp create mode 100755 dali/internal/window-system/windows/platform-implement-win.h create mode 100755 dali/internal/window-system/windows/render-surface-factory-win.cpp create mode 100755 dali/internal/window-system/windows/render-surface-factory-win.h create mode 100755 dali/internal/window-system/windows/window-base-win.cpp create mode 100755 dali/internal/window-system/windows/window-base-win.h create mode 100755 dali/internal/window-system/windows/window-factory-win.cpp create mode 100755 dali/internal/window-system/windows/window-factory-win.h create mode 100644 dali/internal/window-system/windows/window-system-win.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100755 index 0000000..ef11ba6 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,388 @@ +cmake_minimum_required(VERSION 3.11) + +PROJECT (dali-adaptor) + +SET(adaptor_devel_api_dir dali/devel-api) + +SET( devel_api_src_files + ${adaptor_devel_api_dir}/adaptor-framework/accessibility-adaptor.cpp + ${adaptor_devel_api_dir}/adaptor-framework/application-devel.cpp + ${adaptor_devel_api_dir}/adaptor-framework/application-extensions.cpp + ${adaptor_devel_api_dir}/adaptor-framework/bitmap-saver.cpp + ${adaptor_devel_api_dir}/adaptor-framework/clipboard.cpp + ${adaptor_devel_api_dir}/adaptor-framework/clipboard-event-notifier.cpp + ${adaptor_devel_api_dir}/adaptor-framework/color-controller.cpp + ${adaptor_devel_api_dir}/adaptor-framework/drag-and-drop-detector.cpp + ${adaptor_devel_api_dir}/adaptor-framework/environment-variable.cpp + ${adaptor_devel_api_dir}/adaptor-framework/event-feeder.cpp + ${adaptor_devel_api_dir}/adaptor-framework/event-thread-callback.cpp + ${adaptor_devel_api_dir}/adaptor-framework/feedback-player.cpp + ${adaptor_devel_api_dir}/adaptor-framework/file-loader.cpp + ${adaptor_devel_api_dir}/adaptor-framework/image-loading.cpp + ${adaptor_devel_api_dir}/adaptor-framework/gif-loading.cpp + ${adaptor_devel_api_dir}/adaptor-framework/input-method-context.cpp + ${adaptor_devel_api_dir}/adaptor-framework/input-method-options.cpp + ${adaptor_devel_api_dir}/adaptor-framework/orientation.cpp + ${adaptor_devel_api_dir}/adaptor-framework/performance-logger.cpp + ${adaptor_devel_api_dir}/adaptor-framework/physical-keyboard.cpp + ${adaptor_devel_api_dir}/adaptor-framework/pixel-buffer.cpp + ${adaptor_devel_api_dir}/adaptor-framework/singleton-service.cpp + ${adaptor_devel_api_dir}/adaptor-framework/sound-player.cpp + ${adaptor_devel_api_dir}/adaptor-framework/style-monitor.cpp + ${adaptor_devel_api_dir}/adaptor-framework/tilt-sensor.cpp + ${adaptor_devel_api_dir}/adaptor-framework/lifecycle-controller.cpp + ${adaptor_devel_api_dir}/adaptor-framework/video-player.cpp + ${adaptor_devel_api_dir}/adaptor-framework/virtual-keyboard.cpp + ) + +SET( devel_api_adaptor_framework_header_files + ${adaptor_devel_api_dir}/adaptor-framework/accessibility-adaptor.h + ${adaptor_devel_api_dir}/adaptor-framework/accessibility-action-handler.h + ${adaptor_devel_api_dir}/adaptor-framework/accessibility-gesture-handler.h + ${adaptor_devel_api_dir}/adaptor-framework/application-devel.h + ${adaptor_devel_api_dir}/adaptor-framework/application-extensions.h + ${adaptor_devel_api_dir}/adaptor-framework/bitmap-saver.h + ${adaptor_devel_api_dir}/adaptor-framework/clipboard-event-notifier.h + ${adaptor_devel_api_dir}/adaptor-framework/clipboard.h + ${adaptor_devel_api_dir}/adaptor-framework/color-controller.h + ${adaptor_devel_api_dir}/adaptor-framework/drag-and-drop-detector.h + ${adaptor_devel_api_dir}/adaptor-framework/environment-variable.h + ${adaptor_devel_api_dir}/adaptor-framework/event-feeder.h + ${adaptor_devel_api_dir}/adaptor-framework/event-thread-callback.h + ${adaptor_devel_api_dir}/adaptor-framework/feedback-plugin.h + ${adaptor_devel_api_dir}/adaptor-framework/feedback-player.h + ${adaptor_devel_api_dir}/adaptor-framework/file-loader.h + ${adaptor_devel_api_dir}/adaptor-framework/image-loading.h + ${adaptor_devel_api_dir}/adaptor-framework/gif-loading.h + ${adaptor_devel_api_dir}/adaptor-framework/imf-manager.h + ${adaptor_devel_api_dir}/adaptor-framework/input-method-devel.h + ${adaptor_devel_api_dir}/adaptor-framework/input-method-options.h + ${adaptor_devel_api_dir}/adaptor-framework/keyboard.h + ${adaptor_devel_api_dir}/adaptor-framework/lifecycle-controller.h + ${adaptor_devel_api_dir}/adaptor-framework/orientation.h + ${adaptor_devel_api_dir}/adaptor-framework/performance-logger.h + ${adaptor_devel_api_dir}/adaptor-framework/pixel-buffer.h + ${adaptor_devel_api_dir}/adaptor-framework/render-surface.h + ${adaptor_devel_api_dir}/adaptor-framework/singleton-service.h + ${adaptor_devel_api_dir}/adaptor-framework/sound-player.h + ${adaptor_devel_api_dir}/adaptor-framework/style-monitor.h + ${adaptor_devel_api_dir}/adaptor-framework/tilt-sensor.h + ${adaptor_devel_api_dir}/adaptor-framework/video-player.h + ${adaptor_devel_api_dir}/adaptor-framework/video-player-plugin.h + ${adaptor_devel_api_dir}/adaptor-framework/key-extension-plugin.h + ${adaptor_devel_api_dir}/adaptor-framework/virtual-keyboard.h + ${adaptor_devel_api_dir}/adaptor-framework/physical-keyboard.h + ${adaptor_devel_api_dir}/adaptor-framework/key-devel.h + ) + +SET ( devel_api_text_abstraction_src_files + ${adaptor_devel_api_dir}/text-abstraction/bidirectional-support.cpp + ${adaptor_devel_api_dir}/text-abstraction/font-client.cpp + ${adaptor_devel_api_dir}/text-abstraction/font-list.cpp + ${adaptor_devel_api_dir}/text-abstraction/font-metrics.cpp + ${adaptor_devel_api_dir}/text-abstraction/glyph-info.cpp + ${adaptor_devel_api_dir}/text-abstraction/script.cpp + ${adaptor_devel_api_dir}/text-abstraction/segmentation.cpp + ${adaptor_devel_api_dir}/text-abstraction/shaping.cpp + ) + +SET( text_abstraction_header_files + ${adaptor_devel_api_dir}/text-abstraction/bidirectional-support.h + ${adaptor_devel_api_dir}/text-abstraction/font-client.h + ${adaptor_devel_api_dir}/text-abstraction/font-list.h + ${adaptor_devel_api_dir}/text-abstraction/font-metrics.h + ${adaptor_devel_api_dir}/text-abstraction/glyph-info.h + ${adaptor_devel_api_dir}/text-abstraction/script.h + ${adaptor_devel_api_dir}/text-abstraction/segmentation.h + ${adaptor_devel_api_dir}/text-abstraction/shaping.h + ${adaptor_devel_api_dir}/text-abstraction/text-abstraction.h + ${adaptor_devel_api_dir}/text-abstraction/text-abstraction-definitions.h + ) + +SET( SOURCES ${SOURCES} + ${devel_api_src_files} + ${devel_api_text_abstraction_src_files} +) + +SET( INCLUDE ${INCLUDE} + ${devel_api_adaptor_framework_header_files} + ${text_abstraction_header_files} +) + +SET(adaptor_integration_api_dir dali/integration-api) + +SET(adaptor_integration_api_header_files + ${adaptor_integration_api_dir}/adaptor.h + ${adaptor_integration_api_dir}/egl-interface.h + ${adaptor_integration_api_dir}/log-factory-interface.h + ${adaptor_integration_api_dir}/thread-synchronization-interface.h + ${adaptor_integration_api_dir}/trigger-event-interface.h + ${adaptor_integration_api_dir}/trigger-event-factory-interface.h + ${adaptor_integration_api_dir}/trigger-event-factory.h) + +SET (adaptor_integration_win_api_header_files + ${adaptor_integration_api_dir}/windows/win-render-surface.h + ${adaptor_integration_api_dir}/windows/pixmap-render-surface.h + ${adaptor_integration_api_dir}/windows/imf-manager-impl.h + ${adaptor_integration_api_dir}/pixmap-render-surface-factory.h) + +SET( INCLUDE ${INCLUDE} +${adaptor_integration_api_header_files} +${adaptor_integration_win_api_header_files} +) + +SET( adaptor_internal_dir dali/internal/ ) + +SET( SOURCES ${SOURCES} + #accessibility + ${adaptor_internal_dir}/accessibility/common/tts-player-factory.cpp + ${adaptor_internal_dir}/accessibility/common/tts-player-impl.cpp + ${adaptor_internal_dir}/accessibility/common/accessibility-adaptor-impl.cpp + ${adaptor_internal_dir}/accessibility/common/accessibility-gesture-detector.cpp + ${adaptor_internal_dir}/accessibility/windows/accessibility-adaptor-impl-win.cpp + + #adaptor + ${adaptor_internal_dir}/adaptor/common/adaptor.cpp + ${adaptor_internal_dir}/adaptor/common/lifecycle-controller-impl.cpp + ${adaptor_internal_dir}/adaptor/common/adaptor-impl.cpp + ${adaptor_internal_dir}/adaptor/common/adaptor.cpp + ${adaptor_internal_dir}/adaptor/common/application-impl.cpp + ${adaptor_internal_dir}/adaptor/common/combined-update-render-controller.cpp + ${adaptor_internal_dir}/adaptor/windows/adaptor-impl-win.cpp + ${adaptor_internal_dir}/adaptor/windows/framework-win.cpp + + #clipboard + ${adaptor_internal_dir}/clipboard/common/clipboard-event-notifier-impl.cpp + ${adaptor_internal_dir}/clipboard/windows/clipboard-impl-win.cpp + + #graphics + ${adaptor_internal_dir}/graphics/common/render-helper.cpp + ${adaptor_internal_dir}/graphics/gles20/egl-debug.cpp + ${adaptor_internal_dir}/graphics/gles20/egl-factory.cpp + ${adaptor_internal_dir}/graphics/gles20/egl-implementation.cpp + ${adaptor_internal_dir}/graphics/gles20/egl-sync-implementation.cpp + ${adaptor_internal_dir}/graphics/gles20/gl-extensions.cpp + ${adaptor_internal_dir}/graphics/gles20/gl-proxy-implementation.cpp + ${adaptor_internal_dir}/graphics/windows/vsync-monitor-win.cpp + ${adaptor_internal_dir}/graphics/windows-gl/egl-image-extensions.cpp + + #haptics + ${adaptor_internal_dir}/haptics/common/feedback-player-impl.cpp + ${adaptor_internal_dir}/haptics/common/feedback-plugin-proxy.cpp + + #imaging + ${adaptor_internal_dir}/imaging/common/native-bitmap-buffer-impl.cpp + ${adaptor_internal_dir}/imaging/common/native-image-source-factory.cpp + ${adaptor_internal_dir}/imaging/common/native-image-source-impl.cpp + ${adaptor_internal_dir}/imaging/common/pixel-buffer-impl.cpp + ${adaptor_internal_dir}/imaging/common/alpha-mask.cpp + ${adaptor_internal_dir}/imaging/common/gaussian-blur.cpp + ${adaptor_internal_dir}/imaging/common/http-utils.cpp + ${adaptor_internal_dir}/imaging/common/image-loader.cpp + ${adaptor_internal_dir}/imaging/common/image-operations.cpp + ${adaptor_internal_dir}/imaging/common/loader-astc.cpp + ${adaptor_internal_dir}/imaging/common/loader-bmp.cpp + ${adaptor_internal_dir}/imaging/common/loader-gif.cpp + ${adaptor_internal_dir}/imaging/common/loader-ico.cpp + ${adaptor_internal_dir}/imaging/common/loader-jpeg-turbo.cpp + ${adaptor_internal_dir}/imaging/common/loader-ktx.cpp + ${adaptor_internal_dir}/imaging/common/loader-png.cpp + ${adaptor_internal_dir}/imaging/common/loader-wbmp.cpp + ${adaptor_internal_dir}/imaging/common/pixel-manipulation.cpp + ${adaptor_internal_dir}/imaging/windows/file-download-win.cpp + ${adaptor_internal_dir}/imaging/windows/curl-environment-win.cpp + ${adaptor_internal_dir}/input/common/drag-and-drop-detector-impl.cpp + ${adaptor_internal_dir}/input/common/gesture-manager.cpp + ${adaptor_internal_dir}/input/common/input-method-context-impl.cpp + ${adaptor_internal_dir}/input/common/key-grab.cpp + ${adaptor_internal_dir}/input/common/key-impl.cpp + ${adaptor_internal_dir}/input/common/keyboard.cpp + ${adaptor_internal_dir}/input/common/long-press-gesture-detector.cpp + ${adaptor_internal_dir}/input/common/pan-gesture-detector-base.cpp + ${adaptor_internal_dir}/input/common/pan-gesture-detector.cpp + ${adaptor_internal_dir}/input/common/physical-keyboard-impl.cpp + ${adaptor_internal_dir}/input/common/pinch-gesture-detector.cpp + ${adaptor_internal_dir}/input/common/tap-gesture-detector.cpp + ${adaptor_internal_dir}/input/windows/input-method-context-factory-win.cpp + ${adaptor_internal_dir}/input/windows/input-method-context-impl-win.cpp + ${adaptor_internal_dir}/input/windows/key-mapping-win.cpp + ${adaptor_internal_dir}/input/windows/virtual-keyboard-impl-win.cpp + + #legacy + ${adaptor_internal_dir}/legacy/common/tizen-platform-abstraction.cpp + ${adaptor_internal_dir}/legacy/tizen/data-compression.cpp + + #network + ${adaptor_internal_dir}/network/common/socket-factory.cpp + ${adaptor_internal_dir}/network/common/socket-impl.cpp + + #sensor + ${adaptor_internal_dir}/sensor/common/tilt-sensor-factory.cpp + ${adaptor_internal_dir}/sensor/common/tilt-sensor-impl.cpp + + #styling + ${adaptor_internal_dir}/styling/common/style-monitor-impl.cpp + + #system + ${adaptor_internal_dir}/system/common/abort-handler.cpp + ${adaptor_internal_dir}/system/common/command-line-options.cpp + ${adaptor_internal_dir}/system/common/environment-options.cpp + ${adaptor_internal_dir}/system/common/fps-tracker.cpp + ${adaptor_internal_dir}/system/common/frame-time-stamp.cpp + ${adaptor_internal_dir}/system/common/frame-time-stats.cpp + ${adaptor_internal_dir}/system/common/kernel-trace.cpp + ${adaptor_internal_dir}/system/common/locale-utils.cpp + ${adaptor_internal_dir}/system/common/object-profiler.cpp + ${adaptor_internal_dir}/system/common/performance-interface-factory.cpp + ${adaptor_internal_dir}/system/common/performance-logger-impl.cpp + ${adaptor_internal_dir}/system/common/performance-marker.cpp + ${adaptor_internal_dir}/system/common/performance-server.cpp + ${adaptor_internal_dir}/system/common/singleton-service-impl.cpp + ${adaptor_internal_dir}/system/common/sound-player-impl.cpp + ${adaptor_internal_dir}/system/common/stat-context.cpp + ${adaptor_internal_dir}/system/common/stat-context-manager.cpp + ${adaptor_internal_dir}/system/common/system-trace.cpp + ${adaptor_internal_dir}/system/common/thread-controller.cpp + ${adaptor_internal_dir}/system/common/time-service.cpp + ${adaptor_internal_dir}/system/common/trigger-event-factory.cpp + ${adaptor_internal_dir}/system/common/update-status-logger.cpp + ${adaptor_internal_dir}/system/common/widget-application-impl.cpp + ${adaptor_internal_dir}/system/common/logging.cpp + ${adaptor_internal_dir}/system/generic/color-controller-impl.cpp + ${adaptor_internal_dir}/system/generic/system-settings.cpp + ${adaptor_internal_dir}/system/windows/callback-manager-win.cpp + ${adaptor_internal_dir}/system/windows/file-closer-win.cpp + ${adaptor_internal_dir}/system/windows/timer-impl-win.cpp + ${adaptor_internal_dir}/system/windows/trigger-event.cpp + ${adaptor_internal_dir}/system/windows/widget-application-impl-win.cpp + ${adaptor_internal_dir}/system/windows/widget-controller-win.cpp + + #text + ${adaptor_internal_dir}/text/text-abstraction/bidirectional-support-impl.cpp + ${adaptor_internal_dir}/text/text-abstraction/font-client-helper.cpp + ${adaptor_internal_dir}/text/text-abstraction/font-client-impl.cpp + ${adaptor_internal_dir}/text/text-abstraction/font-client-plugin-impl.cpp + ${adaptor_internal_dir}/text/text-abstraction/segmentation-impl.cpp + ${adaptor_internal_dir}/text/text-abstraction/shaping-impl.cpp + + #trace + ${adaptor_internal_dir}/trace/common/trace-factory.cpp + ${adaptor_internal_dir}/trace/common/trace-manager-impl.cpp + + #video + ${adaptor_internal_dir}/video/common/video-player-impl.cpp + + #window-system + ${adaptor_internal_dir}/window-system/common/display-connection.cpp + ${adaptor_internal_dir}/window-system/common/event-handler.cpp + ${adaptor_internal_dir}/window-system/common/indicator-buffer.cpp + ${adaptor_internal_dir}/window-system/common/native-render-surface-factory.cpp + ${adaptor_internal_dir}/window-system/common/orientation-impl.cpp + ${adaptor_internal_dir}/window-system/common/window-base.cpp + ${adaptor_internal_dir}/window-system/common/window-impl.cpp + ${adaptor_internal_dir}/window-system/common/window-render-surface.cpp + ${adaptor_internal_dir}/window-system/windows/display-connection-factory-win.cpp + ${adaptor_internal_dir}/window-system/windows/display-connection-impl-win.cpp + ${adaptor_internal_dir}/window-system/windows/pixmap-render-surface-win.cpp + ${adaptor_internal_dir}/window-system/windows/render-surface-factory-win.cpp + ${adaptor_internal_dir}/window-system/windows/event-system-win.cpp + ${adaptor_internal_dir}/window-system/windows/platform-implement-win.cpp + ${adaptor_internal_dir}/window-system/windows/window-base-win.cpp + ${adaptor_internal_dir}/window-system/windows/window-factory-win.cpp + ${adaptor_internal_dir}/window-system/windows/window-system-win.cpp +) + +SET( adaptor_public_api_dir dali/public-api ) + +SET( SOURCES ${SOURCES} + ${adaptor_public_api_dir}/adaptor-framework/application.cpp + ${adaptor_public_api_dir}/adaptor-framework/key.cpp + ${adaptor_public_api_dir}/adaptor-framework/window.cpp + ${adaptor_public_api_dir}/adaptor-framework/timer.cpp + ${adaptor_public_api_dir}/adaptor-framework/tts-player.cpp + ${adaptor_public_api_dir}/adaptor-framework/timer.cpp + ${adaptor_public_api_dir}/adaptor-framework/widget.cpp + ${adaptor_public_api_dir}/adaptor-framework/timer.cpp + ${adaptor_public_api_dir}/adaptor-framework/widget-application.cpp + ${adaptor_public_api_dir}/adaptor-framework/timer.cpp + ${adaptor_public_api_dir}/adaptor-framework/widget-impl.cpp + ${adaptor_public_api_dir}/adaptor-framework/native-image-source.cpp + ${adaptor_public_api_dir}/dali-adaptor-version.cpp +) + +SET( SOURCES ${SOURCES} + third-party/glyphy/glyphy-arcs.cc + third-party/glyphy/glyphy-blob-impl.cc + third-party/glyphy/glyphy-extents.cc + third-party/glyphy/glyphy-outline.cc + third-party/glyphy/glyphy-sdf.cc + third-party/glyphy/vector-font-cache.cpp + + third-party/libunibreak/linebreak.c + third-party/libunibreak/linebreakdata.c + third-party/libunibreak/linebreakdef.c + third-party/libunibreak/wordbreak.c + + third-party/resampler/resampler.cpp +) + +ADD_DEFINITIONS( +-D "DALI_ADAPTOR_COMPILATION" +-D "_NSIG=65" +-D "FT_FACE_FLAG_COLOR=16384" +-D "NON_POWER_OF_TWO_TEXTURES" +-D "HAVE_STRUCT_TIMESPEC" +-D "CURL_STATICLIB=0" +-D "LC_MESSAGES=0" +/DBUILDING_DALI_ADAPTOR +/FI"../windows-dependencies/ExInclude/PreprocessorDefinitions.h" +/FI"../windows-dependencies/ExInclude/AdaptorPreDefine.h" +/NODEFAULTLIB:"libcmt.lib" +/vmg +/MP +/Gz +) + +link_directories( +../windows-dependencies/ExLib +../bin +) + +#head file path +INCLUDE_DIRECTORIES( +./ +../dali-core +../windows-dependencies/ExInclude +../windows-dependencies/ExInclude/OpenGL/Include +) + +set(LIBRARY_OUTPUT_PATH ../../../bin) + +#set(BUILD_SHARED_LIBS "On") + +#SET_TARGET_PROPERTIES (dali-core123_static PROPERTIES LINKER_LANGUAGE C++) + +ADD_LIBRARY(dali-adaptor SHARED ${SOURCES}) + +target_link_libraries(dali-adaptor dali-core.lib) +target_link_libraries(dali-adaptor libjpeg.lib) +target_link_libraries(dali-adaptor libcurl_a.lib) +target_link_libraries(dali-adaptor turbojpeg.lib) +target_link_libraries(dali-adaptor getopt.lib) +target_link_libraries(dali-adaptor giflib.lib) +target_link_libraries(dali-adaptor libEGL.lib) +target_link_libraries(dali-adaptor libexif.lib) +target_link_libraries(dali-adaptor libGLESv2.lib) +target_link_libraries(dali-adaptor pthread.lib) +target_link_libraries(dali-adaptor libpng.lib) +target_link_libraries(dali-adaptor zlibstat.lib) +target_link_libraries(dali-adaptor freetype.lib) +target_link_libraries(dali-adaptor FontConfig.lib) +target_link_libraries(dali-adaptor libexpat.lib) +target_link_libraries(dali-adaptor fribidi.lib) +target_link_libraries(dali-adaptor harfbuzz-1.4.7.lib) +target_link_libraries(dali-adaptor dlfcn.lib) +target_link_libraries(dali-adaptor Win32File.lib) +target_link_libraries(dali-adaptor WindowsPlatform.lib) + +add_dependencies(dali-adaptor dali-core) diff --git a/dali/devel-api/adaptor-framework/input-method-context.h b/dali/devel-api/adaptor-framework/input-method-context.h index 6775ef2..be9c81e 100755 --- a/dali/devel-api/adaptor-framework/input-method-context.h +++ b/dali/devel-api/adaptor-framework/input-method-context.h @@ -42,7 +42,6 @@ class InputMethodContext; * * Specifically manages the ecore input method framework which enables the virtual or hardware keyboards. */ - class DALI_ADAPTOR_API InputMethodContext : public BaseHandle { public: diff --git a/dali/internal/accessibility/windows/accessibility-adaptor-impl-win.cpp b/dali/internal/accessibility/windows/accessibility-adaptor-impl-win.cpp new file mode 100755 index 0000000..f9e8a9d --- /dev/null +++ b/dali/internal/accessibility/windows/accessibility-adaptor-impl-win.cpp @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +Dali::AccessibilityAdaptor AccessibilityAdaptor::Get() +{ + Dali::AccessibilityAdaptor adaptor; + + Dali::SingletonService service( SingletonService::Get() ); + if ( service ) + { + // Check whether the singleton is already created + Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::AccessibilityAdaptor ) ); + if(handle) + { + // If so, downcast the handle + adaptor = Dali::AccessibilityAdaptor( dynamic_cast< AccessibilityAdaptor* >( handle.GetObjectPtr() ) ); + } + else + { + adaptor = Dali::AccessibilityAdaptor( new AccessibilityAdaptor() ); + service.Register( typeid( adaptor ), adaptor ); + } + } + + return adaptor; +} + +void AccessibilityAdaptor::OnDestroy() +{ + // Nothing to do here +} + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali diff --git a/dali/internal/adaptor/common/combined-update-render-controller.cpp b/dali/internal/adaptor/common/combined-update-render-controller.cpp old mode 100644 new mode 100755 index 4c7b79f..5ae0ecc --- a/dali/internal/adaptor/common/combined-update-render-controller.cpp +++ b/dali/internal/adaptor/common/combined-update-render-controller.cpp @@ -28,7 +28,9 @@ #include #include #include +#if defined(__GNUC__) #include +#endif namespace Dali { @@ -397,7 +399,9 @@ void CombinedUpdateRenderController::ProcessSleepRequest() void CombinedUpdateRenderController::UpdateRenderThread() { +#if defined(__GNUC__) SetThreadName("RenderThread\0"); +#endif // Install a function for logging mEnvironmentOptions.InstallLogFunction(); diff --git a/dali/internal/adaptor/windows/adaptor-impl-win.cpp b/dali/internal/adaptor/windows/adaptor-impl-win.cpp new file mode 100755 index 0000000..993082d --- /dev/null +++ b/dali/internal/adaptor/windows/adaptor-impl-win.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +void Adaptor::GetDataStoragePath( std::string& path) +{ + //path = DALI_SHADERBIN_DIR; +} + +void Adaptor::GetAppId( std::string& appId ) +{ + appId = ""; +} + +void Adaptor::SurfaceInitialized() +{ +} + +void Adaptor::SetupSystemInformation() +{ +} + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali diff --git a/dali/internal/adaptor/windows/framework-win.cpp b/dali/internal/adaptor/windows/framework-win.cpp new file mode 100755 index 0000000..03a75a1 --- /dev/null +++ b/dali/internal/adaptor/windows/framework-win.cpp @@ -0,0 +1,313 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include +#include + +int64_t counter = 0; + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +namespace +{ + +/// Application Status Enum +enum +{ + APP_CREATE, + APP_TERMINATE, + APP_PAUSE, + APP_RESUME, + APP_RESET, + APP_LANGUAGE_CHANGE, +}; + +} // Unnamed namespace +/** + * Impl to hide WindowsSystem data members + */ +struct Framework::Impl +{ + // Constructor + + Impl(void* data) + : mAbortCallBack( NULL ), + mCallbackManager( CallbackManager::New() ), + mLanguage( "NOT_SUPPORTED" ), + mRegion( "NOT_SUPPORTED" ) + { + } + + ~Impl() + { + delete mAbortCallBack; + + // we're quiting the main loop so + // mCallbackManager->RemoveAllCallBacks() does not need to be called + // to delete our abort handler + delete mCallbackManager; + } + + std::string GetLanguage() const + { + return mLanguage; + } + + std::string GetRegion() const + { + return mRegion; + } + + // Data + CallbackBase* mAbortCallBack; + CallbackManager *mCallbackManager; + std::string mLanguage; + std::string mRegion; + + // Static methods + + /** + * Called by AppCore on application creation. + */ + static bool AppCreate(void *data) + { + return static_cast(data)->AppStatusHandler(APP_CREATE, NULL); + } + + /** + * Called by AppCore when the application should terminate. + */ + static void AppTerminate(void *data) + { + static_cast(data)->AppStatusHandler(APP_TERMINATE, NULL); + } + + /** + * Called by AppCore when the application is paused. + */ + static void AppPause(void *data) + { + static_cast(data)->AppStatusHandler(APP_PAUSE, NULL); + } + + /** + * Called by AppCore when the application is resumed. + */ + static void AppResume(void *data) + { + static_cast(data)->AppStatusHandler(APP_RESUME, NULL); + } + + /** + * Called by AppCore when the language changes on the device. + */ + static void AppLanguageChange(void* data) + { + static_cast(data)->AppStatusHandler(APP_LANGUAGE_CHANGE, NULL); + } + + void Run() + { + WindowsPlatformImplement::RunLoop(); + } + + void Quit() + { + int temp = 0; + //uv_stop( mMainLoop ); + } + + +private: + // Undefined + Impl( const Impl& impl ); + + // Undefined + Impl& operator=( const Impl& impl ); +}; + +Framework::Framework( Framework::Observer& observer, int *argc, char ***argv, Type type ) +: mObserver(observer), + mInitialised(false), + mRunning(false), + mArgc(argc), + mArgv(argv), + mBundleName(""), + mBundleId(""), + mAbortHandler( MakeCallback( this, &Framework::AbortCallback ) ), + mImpl(NULL) +{ + InitThreads(); + mImpl = new Impl(this); +} + +Framework::~Framework() +{ + if (mRunning) + { + Quit(); + } + + delete mImpl; +} + +void Framework::Run() +{ + mRunning = true; + + Impl::AppCreate(this); + mImpl->Run(); + mRunning = false; +} + +void Framework::Quit() +{ + Impl::AppTerminate(this); +// mImpl->Quit(); +} + +bool Framework::IsMainLoopRunning() +{ + return mRunning; +} + +void Framework::AddAbortCallback( CallbackBase* callback ) +{ + mImpl->mAbortCallBack = callback; +} + +std::string Framework::GetBundleName() const +{ + return mBundleName; +} + +void Framework::SetBundleName(const std::string& name) +{ + mBundleName = name; +} + +std::string Framework::GetBundleId() const +{ + return mBundleId; +} + +std::string Framework::GetResourcePath() +{ + // "DALI_APPLICATION_PACKAGE" is used by Ubuntu specifically to get the already configured Application package path. + const char* ubuntuEnvironmentVariable = "DALI_APPLICATION_PACKAGE"; + char* value = getenv( ubuntuEnvironmentVariable ); + printf( "DALI_APPLICATION_PACKAGE is %s\n", value ); + std::string resourcePath; + if ( value != NULL ) + { + resourcePath = value; + } + + return resourcePath; +} + +void Framework::SetBundleId(const std::string& id) +{ + mBundleId = id; +} + +void Framework::AbortCallback( ) +{ + // if an abort call back has been installed run it. + if (mImpl->mAbortCallBack) + { + CallbackBase::Execute( *mImpl->mAbortCallBack ); + } + else + { + Quit(); + } +} + +bool Framework::AppStatusHandler(int type, void *bundleData) +{ + switch (type) + { + case APP_CREATE: + { + mInitialised = true; + + mObserver.OnInit(); + break; + } + + case APP_RESET: + mObserver.OnReset(); + break; + + case APP_RESUME: + mObserver.OnResume(); + break; + + case APP_TERMINATE: + mObserver.OnTerminate(); + break; + + case APP_PAUSE: + mObserver.OnPause(); + break; + + case APP_LANGUAGE_CHANGE: + mObserver.OnLanguageChanged(); + break; + + default: + break; + } + + return true; +} + +void Framework::InitThreads() +{ +// XInitThreads(); +} + +std::string Framework::GetLanguage() const +{ + return mImpl->GetLanguage(); +} + +std::string Framework::GetRegion() const +{ + return mImpl->GetRegion(); +} + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali diff --git a/dali/internal/clipboard/windows/clipboard-impl-win.cpp b/dali/internal/clipboard/windows/clipboard-impl-win.cpp new file mode 100755 index 0000000..806af79 --- /dev/null +++ b/dali/internal/clipboard/windows/clipboard-impl-win.cpp @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +#include +#include + +// INTERNAL INCLUDES +#include + + +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Clipboard +/////////////////////////////////////////////////////////////////////////////////////////////////// + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +struct Clipboard::Impl +{ + Impl() + { + } + + // Put implementation here. +}; + +Clipboard::Clipboard(Impl* impl) +: mImpl(impl) +{ +} + +Clipboard::~Clipboard() +{ +} + +Dali::Clipboard Clipboard::Get() +{ + Dali::Clipboard clipboard; + + Dali::SingletonService service( SingletonService::Get() ); + if ( service ) + { + // Check whether the singleton is already created + Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::Clipboard ) ); + if(handle) + { + // If so, downcast the handle + clipboard = Dali::Clipboard( dynamic_cast< Clipboard* >( handle.GetObjectPtr() ) ); + } + else + { + Clipboard::Impl* impl( new Clipboard::Impl() ); + clipboard = Dali::Clipboard( new Clipboard(impl) ); + service.Register( typeid(Dali::Clipboard), clipboard ); + } + } + + return clipboard; +} +bool Clipboard::SetItem(const std::string &itemData ) +{ + return true; +} + +/* + * Request clipboard service to retrieve an item + */ +void Clipboard::RequestItem() +{ +} + +/* + * Get number of items in clipboard + */ +unsigned int Clipboard::NumberOfItems() +{ + return -1; +} + +/** + * Show clipboard window + * Function to send message to show the Clipboard (cbhm) as no direct API available + * Reference elementary/src/modules/ctxpopup_copypasteUI/cbhm_helper.c + */ +void Clipboard::ShowClipboard() +{ +} + +void Clipboard::HideClipboard(bool skipFirstHide) +{ +} + +bool Clipboard::IsVisible() const +{ + return false; +} + +char* Clipboard::ExcuteBuffered( bool type, void *event ) +{ + return NULL; +} + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali diff --git a/dali/internal/graphics/gles/egl-implementation.cpp b/dali/internal/graphics/gles/egl-implementation.cpp index 783c06a..479d19d 100755 --- a/dali/internal/graphics/gles/egl-implementation.cpp +++ b/dali/internal/graphics/gles/egl-implementation.cpp @@ -21,7 +21,6 @@ // EXTERNAL INCLUDES #include - #include // INTERNAL INCLUDES diff --git a/dali/internal/graphics/windows-gl/egl-image-extensions.cpp b/dali/internal/graphics/windows-gl/egl-image-extensions.cpp new file mode 100755 index 0000000..7d390c9 --- /dev/null +++ b/dali/internal/graphics/windows-gl/egl-image-extensions.cpp @@ -0,0 +1,242 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +#if DALI_GLES_VERSION >= 30 +#include +#include + +#else +#include +#endif // DALI_GLES_VERSION >= 30 + +#include + +#include + +#include + +// INTERNAL INCLUDES +#include + + +namespace +{ +// function pointers assigned in InitializeEglImageKHR +PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHRProc = 0; +PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHRProc = 0; +PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOESProc = 0; +} // unnamed namespace + + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +EglImageExtensions::EglImageExtensions(EglImplementation* eglImpl) +: mEglImplementation(eglImpl), + mImageKHRInitialized(false), + mImageKHRInitializeFailed(false) +{ + DALI_ASSERT_ALWAYS( eglImpl && "EGL Implementation not instantiated" ); +} + +EglImageExtensions::~EglImageExtensions() +{ +} + +void* EglImageExtensions::CreateImageKHR(EGLClientBuffer clientBuffer) +{ + if (mImageKHRInitialized == false) + { + InitializeEglImageKHR(); + } + + if (mImageKHRInitialized == false) + { + return NULL; + } + + // Use the EGL image extension + const EGLint attribs[] = + { + EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, + EGL_NONE + }; + +// EGL constants use C casts +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wold-style-cast" + EGLImageKHR eglImage = eglCreateImageKHRProc( mEglImplementation->GetDisplay(), + EGL_NO_CONTEXT, + EGL_NATIVE_PIXMAP_KHR, + clientBuffer, + attribs ); + + DALI_ASSERT_DEBUG( EGL_NO_IMAGE_KHR != eglImage && "WindowsImage::GlExtensionCreate eglCreateImageKHR failed!\n"); + if( EGL_NO_IMAGE_KHR == eglImage ) + { + switch( eglGetError() ) + { + case EGL_SUCCESS : + { + break; + } + case EGL_BAD_DISPLAY: + { + DALI_LOG_ERROR( "EGL_BAD_DISPLAY: Invalid EGLDisplay object\n" ); + break; + } + case EGL_BAD_CONTEXT: + { + DALI_LOG_ERROR( "EGL_BAD_CONTEXT: Invalid EGLContext object\n" ); + break; + } + case EGL_BAD_PARAMETER: + { + DALI_LOG_ERROR( "EGL_BAD_PARAMETER: Invalid target parameter or attribute in attrib_list\n" ); + break; + } + case EGL_BAD_MATCH: + { + DALI_LOG_ERROR( "EGL_BAD_MATCH: attrib_list does not match target\n" ); + break; + } + case EGL_BAD_ACCESS: + { + DALI_LOG_ERROR( "EGL_BAD_ACCESS: Previously bound off-screen, or EGLImage sibling error\n" ); + break; + } + case EGL_BAD_ALLOC: + { + DALI_LOG_ERROR( "EGL_BAD_ALLOC: Insufficient memory is available\n" ); + break; + } + default: + { + break; + } + } + } +#pragma GCC diagnostic pop + + return eglImage; +} + +void EglImageExtensions::DestroyImageKHR(void* eglImageKHR) +{ + DALI_ASSERT_DEBUG( mImageKHRInitialized ); + + if( ! mImageKHRInitialized ) + { + return; + } + + if( eglImageKHR == NULL ) + { + return; + } + + EGLImageKHR eglImage = static_cast(eglImageKHR); + + EGLBoolean result = eglDestroyImageKHRProc(mEglImplementation->GetDisplay(), eglImage); + + if( EGL_FALSE == result ) + { + switch( eglGetError() ) + { + case EGL_BAD_DISPLAY: + { + DALI_LOG_ERROR( "EGL_BAD_DISPLAY: Invalid EGLDisplay object\n" ); + break; + } + case EGL_BAD_PARAMETER: + { + DALI_LOG_ERROR( "EGL_BAD_PARAMETER: eglImage is not a valid EGLImageKHR object created with respect to EGLDisplay\n" ); + break; + } + case EGL_BAD_ACCESS: + { + DALI_LOG_ERROR( "EGL_BAD_ACCESS: EGLImage sibling error\n" ); + break; + } + default: + { + break; + } + } + } +} + +void EglImageExtensions::TargetTextureKHR(void* eglImageKHR) +{ + DALI_ASSERT_DEBUG( mImageKHRInitialized ); + + if( eglImageKHR != NULL ) + { + EGLImageKHR eglImage = static_cast(eglImageKHR); + +#ifdef EGL_ERROR_CHECKING + GLint glError = glGetError(); +#endif + + glEGLImageTargetTexture2DOESProc(GL_TEXTURE_2D, reinterpret_cast< GLeglImageOES >( eglImage ) ); + +#ifdef EGL_ERROR_CHECKING + glError = glGetError(); + if( GL_NO_ERROR != glError ) + { + DALI_LOG_ERROR(" glEGLImageTargetTexture2DOES returned error %0x04x\n", glError ); + } +#endif + } +} + +void EglImageExtensions::InitializeEglImageKHR() +{ + // avoid trying to reload extended KHR functions, if it fails the first time + if( ! mImageKHRInitializeFailed ) + { + eglCreateImageKHRProc = reinterpret_cast< PFNEGLCREATEIMAGEKHRPROC >( eglGetProcAddress("eglCreateImageKHR") ); + eglDestroyImageKHRProc = reinterpret_cast< PFNEGLDESTROYIMAGEKHRPROC >( eglGetProcAddress("eglDestroyImageKHR") ); + glEGLImageTargetTexture2DOESProc = reinterpret_cast< PFNGLEGLIMAGETARGETTEXTURE2DOESPROC >( eglGetProcAddress("glEGLImageTargetTexture2DOES") ); + } + + if (eglCreateImageKHRProc && eglDestroyImageKHRProc && glEGLImageTargetTexture2DOESProc) + { + mImageKHRInitialized = true; + } + else + { + mImageKHRInitializeFailed = true; + } +} + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali diff --git a/dali/internal/graphics/windows/vsync-monitor-win.cpp b/dali/internal/graphics/windows/vsync-monitor-win.cpp new file mode 100755 index 0000000..b92844f --- /dev/null +++ b/dali/internal/graphics/windows/vsync-monitor-win.cpp @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +#include +#include +#include +#include + +#include + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +namespace +{ +// constants to keep code readability with unsigned int has to be used as boolean (due to multithreading) +const unsigned int TRUE = 1u; +const unsigned int FALSE = 0u; + +const int FD_NONE( -1 ); + +} // unnamed namespace + +VSyncMonitor::VSyncMonitor() +: mFileDescriptor( FD_NONE ), + mUseHardwareVSync( FALSE ), + mHardwareVSyncAvailable( FALSE ) +{ +} + +VSyncMonitor::~VSyncMonitor() +{ + Terminate(); +} + +void VSyncMonitor::SetUseHardwareVSync( bool useHardware ) +{ + mUseHardwareVSync = useHardware; +} + +void VSyncMonitor::SetHardwareVSyncAvailable( bool hardwareVSyncAvailable ) +{ + mHardwareVSyncAvailable = hardwareVSyncAvailable; +} + +void VSyncMonitor::Initialize() +{ + DALI_ASSERT_DEBUG( mFileDescriptor == FD_NONE && "VSyncMonitor::Initialize() called twice" ); + + // setup vblank request - block and wait for next vblank + mVBlankInfo.request.type = DRM_VBLANK_NEXTONMISS; + mVBlankInfo.request.sequence = 0; + mVBlankInfo.request.signal = 0; + + // setup vblank reply - block and wait for next vblank + mVBlankInfo.reply.type = DRM_VBLANK_NEXTONMISS; + mVBlankInfo.reply.sequence = 0; + mVBlankInfo.reply.tval_sec = 0; + mVBlankInfo.reply.tval_usec = 0; +} + +void VSyncMonitor::Terminate() +{ +} + +bool VSyncMonitor::UseHardware() +{ + return mUseHardwareVSync && mHardwareVSyncAvailable && (FD_NONE != mFileDescriptor ); +} + + +bool VSyncMonitor::DoSync( unsigned int& frameNumber, unsigned int& seconds, unsigned int& microseconds ) +{ + DALI_ASSERT_DEBUG( mFileDescriptor != FD_NONE && "ECoreX::VSyncMonitor is not initialized" ); + return false; +} + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali diff --git a/dali/internal/imaging/common/file-download.h b/dali/internal/imaging/common/file-download.h old mode 100644 new mode 100755 index c7fb345..9c6d419 --- a/dali/internal/imaging/common/file-download.h +++ b/dali/internal/imaging/common/file-download.h @@ -69,6 +69,10 @@ public: */ static unsigned long GetThreadId(); + static void ConfigureCurlOptions( void* curlHandle, const std::string& url ); + + static void InitWriteFunction( void* curlHandle ); + private: void SetLockingFunction(); diff --git a/dali/internal/imaging/common/image-loader.cpp b/dali/internal/imaging/common/image-loader.cpp index b83878e..e8b3b79 100755 --- a/dali/internal/imaging/common/image-loader.cpp +++ b/dali/internal/imaging/common/image-loader.cpp @@ -33,6 +33,7 @@ #include using namespace Dali::Integration; +using namespace Dali::Internal::Platform; namespace Dali { @@ -147,10 +148,10 @@ bool GetBitmapLoaderFunctions( FILE *fp, const std::string& filename ) { unsigned char magic[MAGIC_LENGTH]; - size_t read = fread(magic, sizeof(unsigned char), MAGIC_LENGTH, fp); + size_t read = InternalFile::fread(magic, sizeof(unsigned char), MAGIC_LENGTH, fp); // Reset to the start of the file. - if( fseek(fp, 0, SEEK_SET) ) + if( InternalFile::fseek(fp, 0, SEEK_SET) ) { DALI_LOG_ERROR("Error seeking to start of file\n"); } @@ -235,7 +236,7 @@ bool GetBitmapLoaderFunctions( FILE *fp, } // Reset to the start of the file. - if( fseek(fp, 0, SEEK_SET) ) + if( InternalFile::fseek(fp, 0, SEEK_SET) ) { DALI_LOG_ERROR("Error seeking to start of file\n"); } diff --git a/dali/internal/imaging/common/loader-astc.cpp b/dali/internal/imaging/common/loader-astc.cpp index 4765bf9..6720082 100755 --- a/dali/internal/imaging/common/loader-astc.cpp +++ b/dali/internal/imaging/common/loader-astc.cpp @@ -26,6 +26,10 @@ #include #include +#include + +using namespace Dali::Internal::Platform; + namespace Dali { namespace TizenPlatform @@ -120,7 +124,7 @@ bool LoadAstcHeader( FILE * const filePointer, unsigned int& width, unsigned int { // Pull the bytes of the file header in as a block: const unsigned int readLength = sizeof( AstcFileHeader ); - if( fread( &fileHeader, 1, readLength, filePointer ) != readLength ) + if( InternalFile::fread( &fileHeader, 1, readLength, filePointer ) != readLength ) { return false; } @@ -196,20 +200,20 @@ bool LoadBitmapFromAstc( const Dali::ImageLoader::Input& input, Dali::Devel::Pix } // Retrieve the file size. - if( fseek( filePointer, 0L, SEEK_END ) ) + if( InternalFile::fseek( filePointer, 0L, SEEK_END ) ) { DALI_LOG_ERROR( "Could not seek through file.\n" ); return false; } - off_t fileSize = ftell( filePointer ); + off_t fileSize = InternalFile::ftell( filePointer ); if( fileSize == -1L ) { DALI_LOG_ERROR( "Could not determine ASTC file size.\n" ); return false; } - if( fseek( filePointer, sizeof( AstcFileHeader ), SEEK_SET ) ) + if( InternalFile::fseek( filePointer, sizeof( AstcFileHeader ), SEEK_SET ) ) { DALI_LOG_ERROR( "Could not seek through file.\n" ); return false; @@ -239,7 +243,7 @@ bool LoadBitmapFromAstc( const Dali::ImageLoader::Input& input, Dali::Devel::Pix } // Load the image data. - const size_t bytesRead = fread( pixels, 1, imageByteCount, filePointer ); + const size_t bytesRead = InternalFile::fread( pixels, 1, imageByteCount, filePointer ); // Check the size of loaded data is what we expected. if( bytesRead != imageByteCount ) diff --git a/dali/internal/imaging/common/loader-bmp.cpp b/dali/internal/imaging/common/loader-bmp.cpp index 65120f2..faf35ab 100755 --- a/dali/internal/imaging/common/loader-bmp.cpp +++ b/dali/internal/imaging/common/loader-bmp.cpp @@ -21,6 +21,10 @@ #include #include +#include + +using namespace Dali::Internal::Platform; + namespace Dali { @@ -84,7 +88,7 @@ inline bool ReadHeader(FILE* fp, T& header) const unsigned int readLength = sizeof(T); // Load the information directly into our structure - if ( fread( &header, 1, readLength, fp ) != readLength ) + if ( InternalFile::fread( &header, 1, readLength, fp ) != readLength ) { return false; } @@ -140,7 +144,7 @@ bool DecodeRGB24V5(FILE *fp, DALI_LOG_ERROR("Error decoding BMP_RGB24V5 format\n"); return false; } - if ( fseek(fp, offset, SEEK_SET) ) + if ( InternalFile::fseek(fp, offset, SEEK_SET) ) { DALI_LOG_ERROR("Error seeking BMP_RGB24V5 data\n"); return false; @@ -157,7 +161,7 @@ bool DecodeRGB24V5(FILE *fp, { pixelsPtr = pixels + (((height-1)-yPos) * rowStride); } - if (fread(pixelsPtr, 1, rowStride, fp) != rowStride) + if (InternalFile::fread(pixelsPtr, 1, rowStride, fp) != rowStride) { DALI_LOG_ERROR("Error reading the BMP image\n"); return false; @@ -172,7 +176,7 @@ bool DecodeRGB24V5(FILE *fp, if (padding) { // move past the padding. - if( fseek(fp, padding, SEEK_CUR) ) + if( InternalFile::fseek(fp, padding, SEEK_CUR) ) { DALI_LOG_ERROR("Error moving past BMP_RGB24V5 padding\n"); } @@ -207,7 +211,7 @@ bool DecodeBF32V4(FILE *fp, DALI_LOG_ERROR("Error decoding BMP_BITFIELDS32V4 format\n"); return false; } - if( fseek(fp, offset, SEEK_SET) ) + if( InternalFile::fseek(fp, offset, SEEK_SET) ) { DALI_LOG_ERROR("Error seeking BMP_BITFIELDS32V4 data\n"); return false; @@ -224,7 +228,7 @@ bool DecodeBF32V4(FILE *fp, { pixelsPtr = pixels + (((height-1)-yPos) * rowStride); } - if (fread(pixelsPtr, 1, rowStride, fp) != rowStride) + if (InternalFile::fread(pixelsPtr, 1, rowStride, fp) != rowStride) { DALI_LOG_ERROR("Error reading the BMP image\n"); return false; @@ -238,7 +242,7 @@ bool DecodeBF32V4(FILE *fp, if (padding) { // move past the padding. - if( fseek(fp, padding, SEEK_CUR) ) + if( InternalFile::fseek(fp, padding, SEEK_CUR) ) { DALI_LOG_ERROR("Error moving past BMP_BITFIELDS32V4 padding\n"); } @@ -274,7 +278,7 @@ bool DecodeBF32(FILE *fp, DALI_LOG_ERROR("Error decoding BMP_BITFIELDS32 format\n"); return false; } - if( fseek(fp, offset, SEEK_SET) ) + if( InternalFile::fseek(fp, offset, SEEK_SET) ) { DALI_LOG_ERROR("Error seeking BMP_BITFIELDS32 data\n"); return false; @@ -294,7 +298,7 @@ bool DecodeBF32(FILE *fp, pixelsPtr = pixels + (((height-1)-yPos) * rowStride); } - if (fread(pixelsPtr, 1, rowStride, fp) != rowStride) + if (InternalFile::fread(pixelsPtr, 1, rowStride, fp) != rowStride) { DALI_LOG_ERROR("Error reading the BMP image\n"); return false; @@ -309,7 +313,7 @@ bool DecodeBF32(FILE *fp, if (padding) { // move past the padding. - if( fseek(fp, padding, SEEK_CUR) ) + if( InternalFile::fseek(fp, padding, SEEK_CUR) ) { DALI_LOG_ERROR("Error moving past BMP_BITFIELDS32 padding\n"); } @@ -340,7 +344,7 @@ bool DecodeBF565(FILE *fp, DALI_LOG_ERROR("Error decoding RGB565 format\n"); return false; } - if( fseek(fp, offset, SEEK_SET) ) + if( InternalFile::fseek(fp, offset, SEEK_SET) ) { DALI_LOG_ERROR("Error seeking RGB565 data\n"); return false; @@ -362,7 +366,7 @@ bool DecodeBF565(FILE *fp, // the data in the file is bottom up, and we store the data top down pixelsPtr = pixels + (((height - 1) - i) * rowStride); } - if(fread(pixelsPtr, 1, rowStride, fp) != rowStride) + if(InternalFile::fread(pixelsPtr, 1, rowStride, fp) != rowStride) { return false; } @@ -394,7 +398,7 @@ bool DecodeBF555(FILE *fp, return false; } - if( fseek(fp, offset, SEEK_SET) ) + if( InternalFile::fseek(fp, offset, SEEK_SET) ) { DALI_LOG_ERROR("Error seeking BMP_BITFIELDS555 data\n"); return false; @@ -410,7 +414,7 @@ bool DecodeBF555(FILE *fp, for(unsigned int j = 0; j < height; j ++) { rawPtr = &raw[0] + ( j * rawStride); - if(fread(rawPtr, 1, rawStride, fp) != rawStride) + if(InternalFile::fread(rawPtr, 1, rawStride, fp) != rawStride) { return false; } @@ -463,7 +467,7 @@ bool DecodeRGB555(FILE *fp, DALI_LOG_ERROR("Error decoding BMP_RGB555 format\n"); return false; } - if( fseek(fp, offset, SEEK_SET) ) + if( InternalFile::fseek(fp, offset, SEEK_SET) ) { DALI_LOG_ERROR("Error seeking BMP_RGB555 data\n"); return false; @@ -478,7 +482,7 @@ bool DecodeRGB555(FILE *fp, for(unsigned int j = 0; j < height; j ++) { rawPtr = &raw[0] + ( j * rawStride); - if(fread(rawPtr, 1, rawStride, fp) != rawStride) + if(InternalFile::fread(rawPtr, 1, rawStride, fp) != rawStride) { return false; } @@ -530,7 +534,7 @@ bool DecodeRGB1(FILE *fp, DALI_LOG_ERROR("Error decoding BMP_RGB1 format\n"); return false; } - if( fseek(fp, offset, SEEK_SET) ) + if( InternalFile::fseek(fp, offset, SEEK_SET) ) { DALI_LOG_ERROR("Error seeking BMP_RGB1 data\n"); return false; @@ -543,14 +547,14 @@ bool DecodeRGB1(FILE *fp, unsigned int rowStride = fillw * 3; // RGB - if(fread(colorTable, 1, 8, fp) != 8) + if(InternalFile::fread(colorTable, 1, 8, fp) != 8) { return false; } for(unsigned int i = 0; i < fillw * height; i += 8) { - if(fread(&cmd, 1, 1, fp) != 1) + if(InternalFile::fread(&cmd, 1, 1, fp) != 1) { return false; } @@ -623,7 +627,7 @@ bool DecodeRGB4(FILE *fp, DALI_LOG_ERROR("Error decoding BMP_RGB4 format\n"); return false; } - if( fseek(fp, offset, SEEK_SET) ) + if( InternalFile::fseek(fp, offset, SEEK_SET) ) { DALI_LOG_ERROR("Error seeking BMP_RGB4 data\n"); return false; @@ -635,14 +639,14 @@ bool DecodeRGB4(FILE *fp, std::vector colorIndex(fillw * height); unsigned int rowStride = fillw * 3; - if(fread(colorTable, 1, 64, fp) != 64) + if(InternalFile::fread(colorTable, 1, 64, fp) != 64) { return false; } for(unsigned int i = 0; i < fillw * height; i += 2) { - if (fread(&cmd, 1, 1, fp) != 1) + if (InternalFile::fread(&cmd, 1, 1, fp) != 1) { return false; } @@ -699,7 +703,7 @@ bool DecodeRGB8(FILE *fp, DALI_LOG_ERROR("Error decoding BMP_RGB8 format\n"); return false; } - if( fseek(fp, offset, SEEK_SET) ) + if( InternalFile::fseek(fp, offset, SEEK_SET) ) { DALI_LOG_ERROR("Error seeking BMP_RGB8 data\n"); return false; @@ -711,13 +715,13 @@ bool DecodeRGB8(FILE *fp, std::vector colorIndex(width * height); unsigned int rowStride = width * 3;//RGB8->RGB24 - if(fread(&colorTable[0], 1, 1024, fp) != 1024) + if(InternalFile::fread(&colorTable[0], 1, 1024, fp) != 1024) { return false; } for(unsigned int i = 0; i < width * height; i ++) { - if (fread(&cmd, 1, 1, fp) != 1) + if (InternalFile::fread(&cmd, 1, 1, fp) != 1) { return false; } @@ -787,13 +791,13 @@ bool DecodeRLE4(FILE *fp, bool finish = false; - if( fseek(fp, offset, SEEK_SET) ) + if( InternalFile::fseek(fp, offset, SEEK_SET) ) { DALI_LOG_ERROR("Error seeking BMP_RLE4 data\n"); return false; } - if (fread(colorTable, 1, 64, fp) != 64) + if (InternalFile::fread(colorTable, 1, 64, fp) != 64) { return false; } @@ -804,7 +808,7 @@ bool DecodeRLE4(FILE *fp, { break; } - if (fread(cmd, 1, cmdStride, fp) != cmdStride) + if (InternalFile::fread(cmd, 1, cmdStride, fp) != cmdStride) { return false; } @@ -820,7 +824,7 @@ bool DecodeRLE4(FILE *fp, y ++; break; case 2: // delta - if (fread(cmd, 1, cmdStride, fp) != cmdStride) + if (InternalFile::fread(cmd, 1, cmdStride, fp) != cmdStride) { DALI_LOG_ERROR("Error reading the BMP image\n"); return false; @@ -839,7 +843,7 @@ bool DecodeRLE4(FILE *fp, bytesize >>= 1; bytesize += (bytesize & 1); run.resize(bytesize); - if(fread(&run[0], 1, bytesize, fp) != bytesize) + if(InternalFile::fread(&run[0], 1, bytesize, fp) != bytesize) { DALI_LOG_ERROR("Error reading the BMP image\n"); return false; @@ -949,13 +953,13 @@ bool DecodeRLE8(FILE *fp, char cmd[2]; std::vector colorIndex(width * height); - if( fseek(fp, offset, SEEK_SET) ) + if( InternalFile::fseek(fp, offset, SEEK_SET) ) { DALI_LOG_ERROR("Error seeking BMP_RLE8 data\n"); return false; } - if (fread(&colorTable[0], 1, 1024, fp) != 1024) + if (InternalFile::fread(&colorTable[0], 1, 1024, fp) != 1024) { return false; } @@ -972,7 +976,7 @@ bool DecodeRLE8(FILE *fp, { break; } - if (fread(cmd, 1, cmdStride, fp) != cmdStride) + if (InternalFile::fread(cmd, 1, cmdStride, fp) != cmdStride) { return false; } @@ -989,7 +993,7 @@ bool DecodeRLE8(FILE *fp, y ++; break; case 2: // delta - if (fread(cmd, 1, cmdStride, fp) != cmdStride) + if (InternalFile::fread(cmd, 1, cmdStride, fp) != cmdStride) { DALI_LOG_ERROR("Error reading the BMP image\n"); return false; @@ -1006,7 +1010,7 @@ bool DecodeRLE8(FILE *fp, //absolute mode must be word-aligned length += (length & 1); run.resize(length); - if(fread(&run[0], 1, length, fp) != length) + if(InternalFile::fread(&run[0], 1, length, fp) != length) { DALI_LOG_ERROR("Error reading the BMP image\n"); return false; @@ -1135,13 +1139,13 @@ bool LoadBitmapFromBmp( const Dali::ImageLoader::Input& input, Dali::Devel::Pixe { if(infoHeader.bitsPerPixel == 16) { - if( fseek(fp, 14 + infoHeader.infoHeaderSize + 1, SEEK_SET) ) + if( InternalFile::fseek(fp, 14 + infoHeader.infoHeaderSize + 1, SEEK_SET) ) { return false; } char mask; - if(fread(&mask, 1, 1, fp) != 1) + if(InternalFile::fread(&mask, 1, 1, fp) != 1) { return false; } @@ -1330,7 +1334,7 @@ bool LoadBitmapFromBmp( const Dali::ImageLoader::Input& input, Dali::Devel::Pixe pixelsIterator = pixels + (((height-1)-yPos) * rowStride); } - if (fread(pixelsIterator, 1, rowStride, fp) != rowStride) + if (InternalFile::fread(pixelsIterator, 1, rowStride, fp) != rowStride) { DALI_LOG_ERROR("Error reading the BMP image\n"); break; @@ -1350,7 +1354,7 @@ bool LoadBitmapFromBmp( const Dali::ImageLoader::Input& input, Dali::Devel::Pixe if (padding) { - if( fseek(fp, padding, SEEK_CUR) ) // move past the padding. + if( InternalFile::fseek(fp, padding, SEEK_CUR) ) // move past the padding. { DALI_LOG_ERROR("Error moving past BMP padding\n"); } diff --git a/dali/internal/imaging/common/loader-gif.cpp b/dali/internal/imaging/common/loader-gif.cpp index cf9b010..e292318 100755 --- a/dali/internal/imaging/common/loader-gif.cpp +++ b/dali/internal/imaging/common/loader-gif.cpp @@ -23,6 +23,10 @@ #include #include +#include + +using namespace Dali::Internal::Platform; + // We need to check if giflib has the new open and close API (including error parameter). #ifdef GIFLIB_MAJOR #define LIBGIF_VERSION_5_1_OR_ABOVE @@ -89,7 +93,7 @@ const unsigned int INTERLACE_PAIR_TABLE_SIZE( sizeof( INTERLACE_PAIR_TABLE ) / s int ReadDataFromGif(GifFileType *gifInfo, GifByteType *data, int length) { FILE *fp = reinterpret_cast(gifInfo->UserData); - return fread( data, sizeof( GifByteType ), length, fp); + return InternalFile::fread( data, sizeof( GifByteType ), length, fp); } /// Loads the GIF Header. diff --git a/dali/internal/imaging/common/loader-ico.cpp b/dali/internal/imaging/common/loader-ico.cpp index dc99750..acb74f4 100755 --- a/dali/internal/imaging/common/loader-ico.cpp +++ b/dali/internal/imaging/common/loader-ico.cpp @@ -58,6 +58,10 @@ #include #include +#include + +using namespace Dali::Internal::Platform; + namespace Dali { @@ -174,13 +178,13 @@ bool LoadIcoHeaderHelper( FILE* fp, unsigned short word; unsigned char byte; - if( fseek(fp,0,SEEK_END) ) + if( InternalFile::fseek(fp,0,SEEK_END) ) { DALI_LOG_ERROR("Error seeking ICO data\n"); return false; } - long positionIndicator = ftell(fp); + long positionIndicator = InternalFile::ftell(fp); fsize = 0u; if( positionIndicator > -1L ) @@ -193,7 +197,7 @@ bool LoadIcoHeaderHelper( FILE* fp, return false; } - if( fseek(fp, 0, SEEK_SET) ) + if( InternalFile::fseek(fp, 0, SEEK_SET) ) { DALI_LOG_ERROR("Error seeking ICO data\n"); return false; @@ -205,7 +209,7 @@ bool LoadIcoHeaderHelper( FILE* fp, } map.Resize(fsize); - if(fread(&map[0], 1, fsize, fp) != fsize) + if(InternalFile::fread(&map[0], 1, fsize, fp) != fsize) { DALI_LOG_WARNING("image file read opeation error!\n"); return false; diff --git a/dali/internal/imaging/common/loader-jpeg-turbo.cpp b/dali/internal/imaging/common/loader-jpeg-turbo.cpp index 1fab9a2..f9f1d35 100755 --- a/dali/internal/imaging/common/loader-jpeg-turbo.cpp +++ b/dali/internal/imaging/common/loader-jpeg-turbo.cpp @@ -42,6 +42,10 @@ #include #include +#include + +using namespace Dali::Internal::Platform; + namespace { using Dali::Vector; @@ -533,13 +537,13 @@ bool LoadBitmapFromJpeg( const Dali::ImageLoader::Input& input, Dali::Devel::Pix const int flags= 0; FILE* const fp = input.file; - if( fseek(fp,0,SEEK_END) ) + if( InternalFile::fseek(fp,0,SEEK_END) ) { DALI_LOG_ERROR("Error seeking to end of file\n"); return false; } - long positionIndicator = ftell(fp); + long positionIndicator = InternalFile::ftell(fp); unsigned int jpegBufferSize = 0u; if( positionIndicator > -1L ) { @@ -551,7 +555,7 @@ bool LoadBitmapFromJpeg( const Dali::ImageLoader::Input& input, Dali::Devel::Pix return false; } - if( fseek(fp, 0, SEEK_SET) ) + if( InternalFile::fseek(fp, 0, SEEK_SET) ) { DALI_LOG_ERROR("Error seeking to start of file\n"); return false; @@ -570,13 +574,13 @@ bool LoadBitmapFromJpeg( const Dali::ImageLoader::Input& input, Dali::Devel::Pix unsigned char * const jpegBufferPtr = jpegBuffer.Begin(); // Pull the compressed JPEG image bytes out of a file and into memory: - if( fread( jpegBufferPtr, 1, jpegBufferSize, fp ) != jpegBufferSize ) + if( InternalFile::fread( jpegBufferPtr, 1, jpegBufferSize, fp ) != jpegBufferSize ) { DALI_LOG_WARNING("Error on image file read.\n"); return false; } - if( fseek(fp, 0, SEEK_SET) ) + if( InternalFile::fseek(fp, 0, SEEK_SET) ) { DALI_LOG_ERROR("Error seeking to start of file\n"); } @@ -1086,7 +1090,7 @@ ExifHandle LoadExifData( FILE* fp ) auto exifData = MakeNullExifData(); unsigned char dataBuffer[1024]; - if( fseek( fp, 0, SEEK_SET ) ) + if( InternalFile::fseek( fp, 0, SEEK_SET ) ) { DALI_LOG_ERROR("Error seeking to start of file\n"); } @@ -1095,9 +1099,9 @@ ExifHandle LoadExifData( FILE* fp ) auto exifLoader = std::unique_ptr{ exif_loader_new(), exif_loader_unref }; - while( !feof(fp) ) + while( !InternalFile::feof(fp) ) { - int size = fread( dataBuffer, 1, sizeof( dataBuffer ), fp ); + int size = InternalFile::fread( dataBuffer, 1, sizeof( dataBuffer ), fp ); if( size <= 0 ) { break; diff --git a/dali/internal/imaging/common/loader-ktx.cpp b/dali/internal/imaging/common/loader-ktx.cpp index e431239..0e0881b 100755 --- a/dali/internal/imaging/common/loader-ktx.cpp +++ b/dali/internal/imaging/common/loader-ktx.cpp @@ -25,6 +25,10 @@ #include #include +#include + +using namespace Dali::Internal::Platform; + namespace Dali { @@ -194,7 +198,7 @@ inline bool ReadHeader( FILE* filePointer, KtxFileHeader& header ) const unsigned int readLength = sizeof( KtxFileHeader ); // Load the information directly into our structure - if( fread( &header, 1, readLength, filePointer ) != readLength ) + if( InternalFile::fread( &header, 1, readLength, filePointer ) != readLength ) { return false; } @@ -556,7 +560,7 @@ bool LoadBitmapFromKtx( const Dali::ImageLoader::Input& input, Dali::Devel::Pixe // Skip the key-values: const long int imageSizeOffset = sizeof(KtxFileHeader) + fileHeader.bytesOfKeyValueData; - if(fseek(fp, imageSizeOffset, SEEK_SET)) + if(InternalFile::fseek(fp, imageSizeOffset, SEEK_SET)) { DALI_LOG_ERROR( "Seek past key/vals in KTX compressed bitmap file failed.\n" ); return false; @@ -564,7 +568,7 @@ bool LoadBitmapFromKtx( const Dali::ImageLoader::Input& input, Dali::Devel::Pixe // Load the size of the image data: uint32_t imageByteCount = 0; - if ( fread( &imageByteCount, 1, 4, fp ) != 4 ) + if ( InternalFile::fread( &imageByteCount, 1, 4, fp ) != 4 ) { DALI_LOG_ERROR( "Read of image size failed.\n" ); return false; @@ -605,7 +609,7 @@ bool LoadBitmapFromKtx( const Dali::ImageLoader::Input& input, Dali::Devel::Pixe return false; } - const size_t bytesRead = fread(pixels, 1, imageByteCount, fp); + const size_t bytesRead = InternalFile::fread(pixels, 1, imageByteCount, fp); if(bytesRead != imageByteCount) { DALI_LOG_ERROR( "Read of image pixel data failed.\n" ); diff --git a/dali/internal/imaging/common/loader-png.cpp b/dali/internal/imaging/common/loader-png.cpp index 4b51af3..4806fcb 100755 --- a/dali/internal/imaging/common/loader-png.cpp +++ b/dali/internal/imaging/common/loader-png.cpp @@ -27,6 +27,10 @@ #include #include +#include + +using namespace Dali::Internal::Platform; + namespace Dali { namespace TizenPlatform @@ -61,7 +65,7 @@ bool LoadPngHeader(FILE *fp, unsigned int &width, unsigned int &height, png_stru png_byte header[8] = { 0 }; // Check header to see if it is a PNG file - size_t size = fread(header, 1, 8, fp); + size_t size = InternalFile::fread(header, 1, 8, fp); if(size != 8) { return false; diff --git a/dali/internal/imaging/common/loader-wbmp.cpp b/dali/internal/imaging/common/loader-wbmp.cpp index 6942442..05d7aa0 100755 --- a/dali/internal/imaging/common/loader-wbmp.cpp +++ b/dali/internal/imaging/common/loader-wbmp.cpp @@ -27,6 +27,10 @@ #include #include +#include + +using namespace Dali::Internal::Platform; + namespace Dali { @@ -108,12 +112,12 @@ bool LoadBitmapFromWbmp( const Dali::ImageLoader::Input& input, Dali::Devel::Pix unsigned char *line = NULL; unsigned int cur = 0, x, y; - if( fseek(fp,0,SEEK_END) ) + if( InternalFile::fseek(fp,0,SEEK_END) ) { DALI_LOG_ERROR("Error seeking WBMP data\n"); return false; } - long positionIndicator = ftell(fp); + long positionIndicator = InternalFile::ftell(fp); unsigned int fsize( 0u ); if( positionIndicator > -1L ) @@ -127,7 +131,7 @@ bool LoadBitmapFromWbmp( const Dali::ImageLoader::Input& input, Dali::Devel::Pix return false; } - if( fseek(fp, 0, SEEK_SET) ) + if( InternalFile::fseek(fp, 0, SEEK_SET) ) { DALI_LOG_ERROR("Error seeking WBMP data\n"); return false; @@ -144,7 +148,7 @@ bool LoadBitmapFromWbmp( const Dali::ImageLoader::Input& input, Dali::Devel::Pix } map.Resize(fsize); - if(fread(&map[0], 1, fsize, fp) != fsize) + if( InternalFile::fread(&map[0], 1, fsize, fp) != fsize) { DALI_LOG_WARNING("image file read opeation error!\n"); return false; @@ -224,12 +228,12 @@ bool LoadWbmpHeader( const Dali::ImageLoader::Input& input, unsigned int& width, unsigned int w, h; unsigned int type; - if( fseek(fp,0,SEEK_END) ) + if( InternalFile::fseek(fp,0,SEEK_END) ) { DALI_LOG_ERROR("Error seeking WBMP data\n"); return false; } - long positionIndicator = ftell(fp); + long positionIndicator = InternalFile::ftell(fp); unsigned int fsize( 0u ); if( positionIndicator > -1L ) @@ -242,7 +246,7 @@ bool LoadWbmpHeader( const Dali::ImageLoader::Input& input, unsigned int& width, return false; } - if( fseek(fp, 0, SEEK_SET) ) + if( InternalFile::fseek(fp, 0, SEEK_SET) ) { DALI_LOG_ERROR("Error seeking WBMP data\n"); return false; @@ -258,7 +262,7 @@ bool LoadWbmpHeader( const Dali::ImageLoader::Input& input, unsigned int& width, headerSize = std::min(headerSize, fsize); map.Resize(headerSize); - if(fread(&map[0], 1, headerSize, fp) != headerSize) + if( InternalFile::fread(&map[0], 1, headerSize, fp) != headerSize) { DALI_LOG_WARNING("image file read opeation error!\n"); return false; diff --git a/dali/internal/imaging/windows/curl-environment-win.cpp b/dali/internal/imaging/windows/curl-environment-win.cpp new file mode 100755 index 0000000..8a294d1 --- /dev/null +++ b/dali/internal/imaging/windows/curl-environment-win.cpp @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// EXTERNAL INCLUDES +#include +#include + +// INTERNAL INCLUDES +#include +#include +#include +#include + +namespace Dali +{ + +namespace TizenPlatform +{ + +const int CONNECTION_TIMEOUT_SECONDS( 30L ); +const long VERBOSE_MODE = 0L; // 0 == off, 1 == on +const long CLOSE_CONNECTION_ON_ERROR = 1L; // 0 == off, 1 == on +const long EXCLUDE_HEADER = 0L; +const long INCLUDE_HEADER = 1L; +const long INCLUDE_BODY = 0L; +const long EXCLUDE_BODY = 1L; + +namespace Network +{ + +unsigned long CurlEnvironment::GetThreadId() +{ + // If dali uses c++ thread, we may replace pthread_self() to this_thread::get_id() + return Internal::Adaptor::WindowsPlatformImplement::GetCurrentThreadId(); +} + +void CurlEnvironment::ConfigureCurlOptions( void* curlHandle, const std::string& url ) +{ + curl_easy_setopt( curlHandle, CURLOPT_URL, url.c_str() ); + //curl_easy_setopt( curlHandle, CURLOPT_VERBOSE, VERBOSE_MODE ); + curl_easy_setopt( curlHandle, CURLOPT_PROXY, "109.123.100.31:3128" ); + + // CURLOPT_FAILONERROR is not fail-safe especially when authentication is involved ( see manual ) + // Removed CURLOPT_FAILONERROR option + curl_easy_setopt( curlHandle, CURLOPT_CONNECTTIMEOUT, CONNECTION_TIMEOUT_SECONDS ); + curl_easy_setopt( curlHandle, CURLOPT_HEADER, INCLUDE_HEADER ); + curl_easy_setopt( curlHandle, CURLOPT_NOBODY, EXCLUDE_BODY ); +} + +static size_t WriteFunction( void *input, size_t uSize, size_t uCount, void *avg ) +{ + Internal::Platform::InternalFile::fwrite( input, uSize, uCount, (FILE*)avg ); + return uSize * uCount; +} + +void CurlEnvironment::InitWriteFunction( void* curlHandle ) +{ + curl_easy_setopt( curlHandle, CURLOPT_WRITEFUNCTION, WriteFunction ); +} +} +} +} \ No newline at end of file diff --git a/dali/internal/imaging/windows/file-download-win.cpp b/dali/internal/imaging/windows/file-download-win.cpp new file mode 100755 index 0000000..c96a272 --- /dev/null +++ b/dali/internal/imaging/windows/file-download-win.cpp @@ -0,0 +1,291 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// HEADER +#include + +// EXTERNAL INCLUDES +#include +#include +#include +#include +#include + +// INTERNAL INCLUDES +#include + +#ifdef TPK_CURL_ENABLED +#include +#endif // TPK_CURL_ENABLED + +using namespace Dali::Integration; + +namespace Dali +{ + +namespace TizenPlatform +{ + +namespace // unnamed namespace +{ +const long EXCLUDE_HEADER = 0L; +const long INCLUDE_BODY = 0L; + +/** + * Curl library environment. Direct initialize ensures it's constructed before adaptor + * or application creates any threads. + */ +static Dali::TizenPlatform::Network::CurlEnvironment gCurlEnvironment; + +// Without a write function or a buffer (file descriptor) to write to, curl will pump out +// header/body contents to stdout +size_t __cdecl DummyWrite(char *ptr, size_t size, size_t nmemb, void *userdata) +{ + return size * nmemb; +} + +struct ChunkData +{ + std::vector< uint8_t > data; +}; + +size_t __cdecl ChunkLoader(char *ptr, size_t size, size_t nmemb, void *userdata) +{ + std::vector* chunks = static_cast*>( userdata ); + int numBytes = size*nmemb; + chunks->push_back( ChunkData() ); + ChunkData& chunkData = (*chunks)[chunks->size()-1]; + chunkData.data.reserve( numBytes ); + memcpy( chunkData.data.data(), ptr, numBytes ); + return numBytes; +} + + +CURLcode DownloadFileDataWithSize( CURL* curlHandle, Dali::Vector& dataBuffer, size_t dataSize ) +{ + CURLcode result( CURLE_OK ); + + // create + Dali::Internal::Platform::FileWriter fileWriter( dataBuffer, dataSize ); + FILE* dataBufferFilePointer = fileWriter.GetFile(); + if( NULL != dataBufferFilePointer ) + { + // we only want the body which contains the file data + curl_easy_setopt( curlHandle, CURLOPT_HEADER, EXCLUDE_HEADER ); + curl_easy_setopt( curlHandle, CURLOPT_NOBODY, INCLUDE_BODY ); + + // disable the write callback, and get curl to write directly into our data buffer + Network::CurlEnvironment::InitWriteFunction( curlHandle ); + + curl_easy_setopt( curlHandle, CURLOPT_WRITEDATA, dataBufferFilePointer ); + + // synchronous request of the body data + result = curl_easy_perform( curlHandle ); + } + return result; +} + +CURLcode DownloadFileDataByChunk( CURL* curlHandle, Dali::Vector& dataBuffer, size_t& dataSize ) +{ + // create + std::vector< ChunkData > chunks; + + // we only want the body which contains the file data + curl_easy_setopt( curlHandle, CURLOPT_HEADER, EXCLUDE_HEADER ); + curl_easy_setopt( curlHandle, CURLOPT_NOBODY, INCLUDE_BODY ); + + // Enable the write callback. + curl_easy_setopt( curlHandle, CURLOPT_WRITEFUNCTION, ChunkLoader ); + curl_easy_setopt( curlHandle, CURLOPT_WRITEDATA, &chunks ); + + // synchronous request of the body data + CURLcode result = curl_easy_perform( curlHandle ); + + // chunks should now contain all of the chunked data. Reassemble into a single vector + dataSize = 0; + for( size_t i=0; i& dataBuffer, + size_t& dataSize, + size_t maximumAllowedSizeBytes ) +{ + CURLcode result( CURLE_OK ); + double size(0); + + // setup curl to download just the header so we can extract the content length + Network::CurlEnvironment::ConfigureCurlOptions( curlHandle, url ); + + curl_easy_setopt( curlHandle, CURLOPT_WRITEFUNCTION, DummyWrite); + + // perform the request to get the header + result = curl_easy_perform( curlHandle ); + + if( result != CURLE_OK) + { + DALI_LOG_ERROR( "Failed to download http header for \"%s\" with error code %d\n", url.c_str(), result ); + return false; + } + + // get the content length, -1 == size is not known + curl_easy_getinfo( curlHandle,CURLINFO_CONTENT_LENGTH_DOWNLOAD , &size ); + + + if( size >= maximumAllowedSizeBytes ) + { + DALI_LOG_ERROR( "File content length %f > max allowed %zu \"%s\" \n", size, maximumAllowedSizeBytes, url.c_str() ); + return false; + } + else if( size > 0 ) + { + // If we know the size up front, allocate once and avoid chunk copies. + dataSize = static_cast( size ); + result = DownloadFileDataWithSize( curlHandle, dataBuffer, dataSize ); + } + else + { + result = DownloadFileDataByChunk( curlHandle, dataBuffer, dataSize ); + } + + if( result != CURLE_OK ) + { + DALI_LOG_ERROR( "Failed to download image file \"%s\" with error code %d\n", url.c_str(), result ); + return false; + } + return true; +} + + +} // unnamed namespace + + +namespace Network +{ + +std::mutex* CurlEnvironment::mMutexs = NULL; + +CurlEnvironment::CurlEnvironment() +{ + // Must be called before we attempt any loads. e.g. by using curl_easy_init() + // and before we start any threads. + curl_global_init(CURL_GLOBAL_ALL); + + // libcurl with openssl needs locking_function and thread id for threadsafe + // https://curl.haxx.se/libcurl/c/threadsafe.html + // https://www.openssl.org/docs/man1.0.2/crypto/threads.html#DESCRIPTION + // SetLockingFunction sets locking_function and get thread id by the guide. + SetLockingFunction(); +} + +CurlEnvironment::~CurlEnvironment() +{ + UnsetLockingFunction(); + + curl_global_cleanup(); +} + +// libcurl with openssl needs locking_function and thread id for threadsafe +// https://curl.haxx.se/libcurl/c/threadsafe.html +// https://www.openssl.org/docs/man1.0.2/crypto/threads.html#DESCRIPTION +void CurlEnvironment::OnOpenSSLLocking( int mode, int n, const char* file, int line ) +{ + if( mode & CRYPTO_LOCK ) + { + mMutexs[n].lock(); + } + else + { + mMutexs[n].unlock(); + } +} + +void CurlEnvironment::SetLockingFunction() +{ + if( mMutexs != NULL ) + { + return; + } + + mMutexs = new std::mutex[ CRYPTO_num_locks() ]; + + CRYPTO_set_id_callback( &CurlEnvironment::GetThreadId ); + CRYPTO_set_locking_callback( &CurlEnvironment::OnOpenSSLLocking ); +} + +void CurlEnvironment::UnsetLockingFunction() +{ + if( mMutexs == NULL ) + { + return; + } + + CRYPTO_set_id_callback( NULL ); + CRYPTO_set_locking_callback( NULL ); + + delete [] mMutexs; + mMutexs = NULL; +} + +bool DownloadRemoteFileIntoMemory( const std::string& url, + Dali::Vector& dataBuffer, + size_t& dataSize, + size_t maximumAllowedSizeBytes ) +{ + if( url.empty() ) + { + DALI_LOG_WARNING("empty url requested \n"); + return false; + } + + // start a libcurl easy session, this internally calls curl_global_init, if we ever have more than one download + // thread we need to explicity call curl_global_init() on startup from a single thread. + + CURL* curlHandle = curl_easy_init(); + + bool result = DownloadFile( curlHandle, url, dataBuffer, dataSize, maximumAllowedSizeBytes); + + // clean up session + curl_easy_cleanup( curlHandle ); + +#ifdef TPK_CURL_ENABLED + // Clean up tpkp(the module for certificate pinning) resources on Tizen + tpkp_curl_cleanup(); +#endif // TPK_CURL_ENABLED + + return result; +} + +} // namespace Network + +} // namespace TizenPlatform + +} // namespace Dali diff --git a/dali/internal/input/windows/input-method-context-factory-win.cpp b/dali/internal/input/windows/input-method-context-factory-win.cpp new file mode 100755 index 0000000..817dacb --- /dev/null +++ b/dali/internal/input/windows/input-method-context-factory-win.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ +class InputMethodContext; + +namespace InputMethodContextFactory +{ + +// InputMethodContext Factory to be implemented by the platform +InputMethodContextPtr CreateInputMethodContext() +{ + return Dali::Internal::Adaptor::InputMethodContextWin::New(); +} + +} + +} + + + +} +} \ No newline at end of file diff --git a/dali/internal/input/windows/input-method-context-impl-win.cpp b/dali/internal/input/windows/input-method-context-impl-win.cpp new file mode 100755 index 0000000..7c09270 --- /dev/null +++ b/dali/internal/input/windows/input-method-context-impl-win.cpp @@ -0,0 +1,865 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +//#include +//#include +#include +#include +#include +#include + +// INTERNAL INCLUDES +#include +#include +#include +#include +#include +#include +// Ecore is littered with C style cast +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wold-style-cast" +//#include + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +namespace +{ +#if defined(DEBUG_ENABLED) +Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_INPUT_METHOD_CONTEXT"); +#endif + +// Currently this code is internal to dali/dali/internal/event/text/utf8.h but should be made Public and used from there instead. +size_t Utf8SequenceLength(const unsigned char leadByte) +{ + size_t length = 0; + + if ((leadByte & 0x80) == 0 ) //ASCII character (lead bit zero) + { + length = 1; + } + else if (( leadByte & 0xe0 ) == 0xc0 ) //110x xxxx + { + length = 2; + } + else if (( leadByte & 0xf0 ) == 0xe0 ) //1110 xxxx + { + length = 3; + } + else if (( leadByte & 0xf8 ) == 0xf0 ) //1111 0xxx + { + length = 4; + } + + return length; +} +// +//// Static function calls used by ecore 'c' style callback registration +//void Commit( void *data, Ecore_IMF_Context *imfContext, void *event_info ) +//{ +// if ( data ) +// { +// InputMethodContextWin* inputMethodContext = reinterpret_cast< InputMethodContextWin* > ( data ); +// inputMethodContext->CommitReceived( data, imfContext, event_info ); +// } +//} +// +//void PreEdit( void *data, Ecore_IMF_Context *imfContext, void *event_info ) +//{ +// if ( data ) +// { +// InputMethodContextWin* inputMethodContext = reinterpret_cast< InputMethodContextWin* > ( data ); +// inputMethodContext->PreEditChanged( data, imfContext, event_info ); +// } +//} +// +//Eina_Bool ImfRetrieveSurrounding(void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition ) +//{ +// if ( data ) +// { +// InputMethodContextWin* inputMethodContext = reinterpret_cast< InputMethodContextWin* > ( data ); +// return inputMethodContext->RetrieveSurrounding( data, imfContext, text, cursorPosition ); +// } +// else +// { +// return false; +// } +//} +// +///** +// * Called when an InputMethodContext delete surrounding event is received. +// * Here we tell the application that it should delete a certain range. +// */ +//void ImfDeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info ) +//{ +// if ( data ) +// { +// InputMethodContextWin* inputMethodContext = reinterpret_cast< InputMethodContextWin* > ( data ); +// inputMethodContext->DeleteSurrounding( data, imfContext, event_info ); +// } +//} + +} // unnamed namespace + +InputMethodContextPtr InputMethodContextWin::New() +{ + InputMethodContextPtr manager; + + if ( Adaptor::IsAvailable() ) + { + // Create instance and register singleton only if the adaptor is available + Adaptor& adaptorImpl( Adaptor::GetImplementation( Adaptor::Get() ) ); + Any nativeWindow = adaptorImpl.GetNativeWindowHandle(); + + // The Win_Window_Handle needs to use the InputMethodContext. + // Only when the render surface is window, we can get the Win_Window_Handle. + Win_Window_Handle winWindow( AnyCast(nativeWindow) ); + if ( winWindow ) + { + // If we fail to get Win_Window_Handle, we can't use the InputMethodContext correctly. + // Thus you have to call "ecore_imf_context_client_window_set" somewhere. + // In EvasPlugIn, this function is called in EvasPlugin::ConnectEcoreEvent(). + + manager = new InputMethodContextWin( winWindow ); + } + else + { + DALI_LOG_ERROR("Failed to get native window handle\n"); + } + } + + return manager; +} + +void InputMethodContextWin::Finalize() +{ + //DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::Finalize\n" ); + //VirtualKeyboard::DisconnectCallbacks( mIMFContext ); + //DisconnectCallbacks(); + //DeleteContext(); +} + +InputMethodContextWin::InputMethodContextWin( Win_Window_Handle winWindow ) +: mWin32Window( winWindow ), + mIMFCursorPosition( 0 ), + mSurroundingText(), + mRestoreAfterFocusLost( false ), + mIdleCallbackConnected( false ) +{ + //ecore_imf_init(); +} + +InputMethodContextWin::~InputMethodContextWin() +{ + Finalize(); + //ecore_imf_shutdown(); +} + +void InputMethodContextWin::Initialize() +{ + CreateContext( mWin32Window ); + ConnectCallbacks(); + //VirtualKeyboard::ConnectCallbacks( mIMFContext ); +} + +void InputMethodContextWin::CreateContext( Win_Window_Handle ecoreXwin ) +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::CreateContext\n" ); + + //const char *contextId = ecore_imf_context_default_id_get(); + //if( contextId ) + //{ + // mIMFContext = ecore_imf_context_add( contextId ); + + // if( mIMFContext ) + // { + // if( ecoreXwin ) + // { + // ecore_imf_context_client_window_set( mIMFContext, reinterpret_cast( ecoreXwin ) ); + // } + // } + // else + // { + // DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContext Unable to get IMFContext\n"); + // } + //} + //else + //{ + // DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContext Unable to get IMFContext\n"); + //} +} + +void InputMethodContextWin::DeleteContext() +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::DeleteContext\n" ); + + //if ( mIMFContext ) + //{ + // ecore_imf_context_del( mIMFContext ); + // mIMFContext = NULL; + //} +} + +// Callbacks for predicitive text support. +void InputMethodContextWin::ConnectCallbacks() +{ + //if ( mIMFContext ) + //{ + // DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::ConnectCallbacks\n" ); + + // ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit, this ); + // ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit, this ); + // ecore_imf_context_event_callback_add( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding, this ); + + // ecore_imf_context_retrieve_surrounding_callback_set( mIMFContext, ImfRetrieveSurrounding, this); + //} +} + +void InputMethodContextWin::DisconnectCallbacks() +{ + //if ( mIMFContext ) + //{ + // DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::DisconnectCallbacks\n" ); + + // ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, PreEdit ); + // ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_COMMIT, Commit ); + // ecore_imf_context_event_callback_del( mIMFContext, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, ImfDeleteSurrounding ); + + // // We do not need to unset the retrieve surrounding callback. + //} +} + +void InputMethodContextWin::Activate() +{ + // Reset mIdleCallbackConnected + mIdleCallbackConnected = false; + + //if ( mIMFContext ) + //{ + // DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::Activate\n" ); + + // ecore_imf_context_focus_in( mIMFContext ); + + // // emit keyboard activated signal + // Dali::InputMethodContext handle( this ); + // mActivatedSignal.Emit( handle ); + //} +} + +void InputMethodContextWin::Deactivate() +{ + //if( mIMFContext ) + //{ + // DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::Deactivate\n" ); + + // Reset(); + // ecore_imf_context_focus_out( mIMFContext ); + //} + + // Reset mIdleCallbackConnected + mIdleCallbackConnected = false; +} + +void InputMethodContextWin::Reset() +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::Reset\n" ); + + //if ( mIMFContext ) + //{ + // ecore_imf_context_reset( mIMFContext ); + //} +} + +ImfContext* InputMethodContextWin::GetContext() +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetContext\n" ); + + //return mIMFContext; + return NULL; +} + +bool InputMethodContextWin::RestoreAfterFocusLost() const +{ + return mRestoreAfterFocusLost; +} + +void InputMethodContextWin::SetRestoreAfterFocusLost( bool toggle ) +{ + mRestoreAfterFocusLost = toggle; +} + +/** + * Called when an InputMethodContext Pre-Edit changed event is received. + * We are still predicting what the user is typing. The latest string is what the InputMethodContext module thinks + * the user wants to type. + */ +void InputMethodContextWin::PreEditChanged( void*, ImfContext* imfContext, void* event_info ) +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::PreEditChanged\n" ); +// auto context = reinterpret_cast(imfContext); +// +// char* preEditString( NULL ); +// int cursorPosition( 0 ); +// Eina_List* attrs = NULL; +// Eina_List* l = NULL; +// +// Ecore_IMF_Preedit_Attr* attr; +// +// // Retrieves attributes as well as the string the cursor position offset from start of pre-edit string. +// // the attributes (attrs) is used in languages that use the soft arrows keys to insert characters into a current pre-edit string. +// ecore_imf_context_preedit_string_with_attributes_get( context, &preEditString, &attrs, &cursorPosition ); +// +// if ( attrs ) +// { +// // iterate through the list of attributes getting the type, start and end position. +// for ( l = attrs, (attr = static_cast( eina_list_data_get(l) ) ); l; l = eina_list_next(l), ( attr = static_cast( eina_list_data_get(l) ) )) +// { +//#ifdef DALI_PROFILE_UBUNTU +// if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB3 ) // (Ecore_IMF) +//#else // DALI_PROFILE_UBUNTU +// if ( attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB4 ) // (Ecore_IMF) +//#endif // DALI_PROFILE_UBUNTU +// { +// // check first byte so know how many bytes a character is represented by as keyboard returns cursor position in bytes. Which is different for some languages. +// +// size_t visualCharacterIndex = 0; +// size_t byteIndex = 0; +// +// // iterate through null terminated string checking each character's position against the given byte position ( attr->end_index ). +// const char leadByte = preEditString[byteIndex]; +// while( leadByte != '\0' ) +// { +// // attr->end_index is provided as a byte position not character and we need to know the character position. +// const size_t currentSequenceLength = Utf8SequenceLength( leadByte ); // returns number of bytes used to represent character. +// if ( byteIndex == attr->end_index ) +// { +// cursorPosition = visualCharacterIndex; +// break; +// // end loop as found cursor position that matches byte position +// } +// else +// { +// byteIndex += currentSequenceLength; // jump to next character +// visualCharacterIndex++; // increment character count so we know our position for when we get a match +// } +// +// DALI_ASSERT_DEBUG( visualCharacterIndex < strlen( preEditString )); +// } +// } +// } +// } + + //if ( Dali::Adaptor::IsAvailable() ) + //{ + // Dali::InputMethodContext handle( this ); + // Dali::InputMethodContext::EventData eventData( Dali::InputMethodContext::PRE_EDIT, preEditString, cursorPosition, 0 ); + // Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, eventData ); + + // if( callbackData.update ) + // { + // mIMFCursorPosition = static_cast( callbackData.cursorPosition ); + + // NotifyCursorPosition(); + // } + + // if( callbackData.preeditResetRequired ) + // { + // Reset(); + // } + //} + //free( preEditString ); +} + +void InputMethodContextWin::CommitReceived( void*, ImfContext* imfContext, void* event_info ) +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::CommitReceived\n" ); + + if ( Dali::Adaptor::IsAvailable() ) + { + const std::string keyString( static_cast( event_info ) ); + + Dali::InputMethodContext handle( this ); + Dali::InputMethodContext::EventData eventData( Dali::InputMethodContext::COMMIT, keyString, 0, 0 ); + Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, eventData ); + + if( callbackData.update ) + { + mIMFCursorPosition = static_cast( callbackData.cursorPosition ); + + NotifyCursorPosition(); + } + } +} + +/** + * Called when an InputMethodContext retrieve surround event is received. + * Here the InputMethodContext module wishes to know the string we are working with and where within the string the cursor is + * We need to signal the application to tell us this information. + */ +bool InputMethodContextWin::RetrieveSurrounding( void* data, ImfContext* imfContext, char** text, int* cursorPosition ) +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::RetrieveSurrounding\n" ); + + Dali::InputMethodContext::EventData imfData( Dali::InputMethodContext::GET_SURROUNDING, std::string(), 0, 0 ); + Dali::InputMethodContext handle( this ); + Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, imfData ); + + if( callbackData.update ) + { + if( text ) + { + *text = strdup( callbackData.currentText.c_str() ); + } + + if( cursorPosition ) + { + mIMFCursorPosition = static_cast( callbackData.cursorPosition ); + *cursorPosition = mIMFCursorPosition; + } + } + + //return EINA_TRUE; + return true; +} + +/** + * Called when an InputMethodContext delete surrounding event is received. + * Here we tell the application that it should delete a certain range. + */ +void InputMethodContextWin::DeleteSurrounding( void* data, ImfContext* imfContext, void* event_info ) +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::DeleteSurrounding\n" ); + + //if( Dali::Adaptor::IsAvailable() ) + //{ + // Ecore_IMF_Event_Delete_Surrounding* deleteSurroundingEvent = static_cast( event_info ); + + // Dali::InputMethodContext::EventData imfData( Dali::InputMethodContext::DELETE_SURROUNDING, std::string(), deleteSurroundingEvent->offset, deleteSurroundingEvent->n_chars ); + // Dali::InputMethodContext handle( this ); + // Dali::InputMethodContext::CallbackData callbackData = mEventSignal.Emit( handle, imfData ); + + // if( callbackData.update ) + // { + // mIMFCursorPosition = static_cast( callbackData.cursorPosition ); + + // NotifyCursorPosition(); + // } + //} +} + +void InputMethodContextWin::NotifyCursorPosition() +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::NotifyCursorPosition\n" ); + + //if( mIMFContext ) + //{ + // ecore_imf_context_cursor_position_set( mIMFContext, mIMFCursorPosition ); + //} +} + +void InputMethodContextWin::SetCursorPosition( unsigned int cursorPosition ) +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetCursorPosition\n" ); + + mIMFCursorPosition = static_cast( cursorPosition ); +} + +unsigned int InputMethodContextWin::GetCursorPosition() const +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetCursorPosition\n" ); + + return static_cast( mIMFCursorPosition ); +} + +void InputMethodContextWin::SetSurroundingText( const std::string& text ) +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetSurroundingText\n" ); + + mSurroundingText = text; +} + +const std::string& InputMethodContextWin::GetSurroundingText() const +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetSurroundingText\n" ); + + return mSurroundingText; +} + +void InputMethodContextWin::NotifyTextInputMultiLine( bool multiLine ) +{ +} + +Dali::InputMethodContext::TextDirection InputMethodContextWin::GetTextDirection() +{ + Dali::InputMethodContext::TextDirection direction ( Dali::InputMethodContext::LeftToRight ); + + //if ( mIMFContext ) + //{ + // char* locale( NULL ); + // ecore_imf_context_input_panel_language_locale_get( mIMFContext, &locale ); + + // if ( locale ) + // { + // direction = static_cast< Dali::InputMethodContext::TextDirection >( Locale::GetDirection( std::string( locale ) ) ); + // free( locale ); + // } + //} + + return direction; +} + +Rect InputMethodContextWin::GetInputMethodArea() +{ + int xPos, yPos, width, height; + + width = height = xPos = yPos = 0; + + //if( mIMFContext ) + //{ + // ecore_imf_context_input_panel_geometry_get( mIMFContext, &xPos, &yPos, &width, &height ); + //} + //else + //{ + // DALI_LOG_WARNING("VKB Unable to get InputMethodContext Context so GetSize unavailable\n"); + //} + + return Rect(xPos,yPos,width,height); +} + +void InputMethodContextWin::ApplyOptions( const InputMethodOptions& options ) +{ + using namespace Dali::InputMethod::Category; + + int index; + + //if (mIMFContext == NULL) + //{ + // DALI_LOG_WARNING("VKB Unable to excute ApplyOptions with Null ImfContext\n"); + // return; + //} + + if ( mOptions.CompareAndSet(PANEL_LAYOUT, options, index) ) + { + } + if ( mOptions.CompareAndSet(BUTTON_ACTION, options, index) ) + { + } + if ( mOptions.CompareAndSet(AUTO_CAPITALIZE, options, index) ) + { + } + if ( mOptions.CompareAndSet(VARIATION, options, index) ) + { + } +} + +void InputMethodContextWin::SetInputPanelData( const std::string& data ) +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetInputPanelData\n" ); + + //if( mIMFContext ) + //{ + // int length = data.length(); + // ecore_imf_context_input_panel_imdata_set( mIMFContext, data.c_str(), length ); + //} +} + +void InputMethodContextWin::GetInputPanelData( std::string& data ) +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetInputPanelData\n" ); + + //if( mIMFContext ) + //{ + // int length = 4096; // The max length is 4096 bytes + // Dali::Vector< char > buffer; + // buffer.Resize( length ); + // ecore_imf_context_input_panel_imdata_get( mIMFContext, &buffer[0], &length ); + // data = std::string( buffer.Begin(), buffer.End() ); + //} +} + +Dali::InputMethodContext::State InputMethodContextWin::GetInputPanelState() +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetInputPanelState\n" ); + + //if( mIMFContext ) + //{ + // int value; + // value = ecore_imf_context_input_panel_state_get( mIMFContext ); + + // switch (value) + // { + // case ECORE_IMF_INPUT_PANEL_STATE_SHOW: + // { + // return Dali::InputMethodContext::SHOW; + // break; + // } + + // case ECORE_IMF_INPUT_PANEL_STATE_HIDE: + // { + // return Dali::InputMethodContext::HIDE; + // break; + // } + + // case ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW: + // { + // return Dali::InputMethodContext::WILL_SHOW; + // break; + // } + + // default: + // { + // return Dali::InputMethodContext::DEFAULT; + // } + // } + //} + return Dali::InputMethodContext::DEFAULT; +} + +void InputMethodContextWin::SetReturnKeyState( bool visible ) +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::SetReturnKeyState\n" ); + + //if( mIMFContext ) + //{ + // ecore_imf_context_input_panel_return_key_disabled_set( mIMFContext, !visible ); + //} +} + +void InputMethodContextWin::AutoEnableInputPanel( bool enabled ) +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::AutoEnableInputPanel\n" ); + + //if( mIMFContext ) + //{ + // ecore_imf_context_input_panel_enabled_set( mIMFContext, enabled ); + //} +} + +void InputMethodContextWin::ShowInputPanel() +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::ShowInputPanel\n" ); + + //if( mIMFContext ) + //{ + // ecore_imf_context_input_panel_show( mIMFContext ); + //} +} + +void InputMethodContextWin::HideInputPanel() +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::HideInputPanel\n" ); + + //if( mIMFContext ) + //{ + // ecore_imf_context_input_panel_hide( mIMFContext ); + //} +} + +Dali::InputMethodContext::KeyboardType InputMethodContextWin::GetKeyboardType() +{ + return Dali::InputMethodContext::KeyboardType::SOFTWARE_KEYBOARD; +} + +std::string InputMethodContextWin::GetInputPanelLocale() +{ + DALI_LOG_INFO( gLogFilter, Debug::General, "InputMethodContextWin::GetInputPanelLocale\n" ); + + std::string locale = ""; + + //if( mIMFContext ) + //{ + // char* value = NULL; + // ecore_imf_context_input_panel_language_locale_get( mIMFContext, &value ); + + // if( value ) + // { + // std::string valueCopy( value ); + // locale = valueCopy; + + // // The locale string retrieved must be freed with free(). + // free( value ); + // } + //} + return locale; +} + +bool InputMethodContextWin::FilterEventKey( const Dali::KeyEvent& keyEvent ) +{ + bool eventHandled( false ); + + // If a device key then skip ecore_imf_context_filter_event. + if ( ! KeyLookup::IsDeviceButton( keyEvent.keyPressedName.c_str() )) + { + //check whether it's key down or key up event + if ( keyEvent.state == KeyEvent::Down ) + { + eventHandled = ProcessEventKeyDown( keyEvent ); + } + else if ( keyEvent.state == KeyEvent::Up ) + { + eventHandled = ProcessEventKeyUp( keyEvent ); + } + } + + return eventHandled; +} + +bool InputMethodContextWin::ProcessEventKeyDown( const KeyEvent& keyEvent ) +{ + bool eventHandled( false ); +// if ( mIMFContext ) +// { +// // We're consuming key down event so we have to pass to InputMethodContext so that it can parse it as well. +// Ecore_IMF_Event_Key_Down ecoreKeyDownEvent; +// ecoreKeyDownEvent.keyname = keyEvent.keyPressedName.c_str(); +// ecoreKeyDownEvent.key = keyEvent.keyPressedName.c_str(); +// ecoreKeyDownEvent.string = keyEvent.keyPressed.c_str(); +// ecoreKeyDownEvent.compose = keyEvent.GetCompose().c_str(); +// ecoreKeyDownEvent.timestamp = keyEvent.time; +// ecoreKeyDownEvent.modifiers = EcoreInputModifierToEcoreIMFModifier( keyEvent.keyModifier ); +// ecoreKeyDownEvent.locks = EcoreInputModifierToEcoreIMFLock( keyEvent.keyModifier ); +//#ifdef ECORE_IMF_1_13 +// ecoreKeyDownEvent.dev_name = ""; +// ecoreKeyDownEvent.dev_class = ECORE_IMF_DEVICE_CLASS_KEYBOARD; +// ecoreKeyDownEvent.dev_subclass = ECORE_IMF_DEVICE_SUBCLASS_NONE; +//#endif // ECORE_IMF_1_13 +// +// // If the device is IME and the focused key is the direction keys, then we should send a key event to move a key cursor. +// if ((keyEvent.GetDeviceName() == "ime") && ((!strncmp(keyEvent.keyPressedName.c_str(), "Left", 4)) || +// (!strncmp(keyEvent.keyPressedName.c_str(), "Right", 5)) || +// (!strncmp(keyEvent.keyPressedName.c_str(), "Up", 2)) || +// (!strncmp(keyEvent.keyPressedName.c_str(), "Down", 4)))) +// { +// eventHandled = 0; +// } +// else +// { +// eventHandled = ecore_imf_context_filter_event(mIMFContext, +// ECORE_IMF_EVENT_KEY_DOWN, +// (Ecore_IMF_Event *) &ecoreKeyDownEvent); +// } +// +// // If the event has not been handled by InputMethodContext then check if we should reset our IMFcontext +// if (!eventHandled) +// { +// if (!strcmp(keyEvent.keyPressedName.c_str(), "Escape") || +// !strcmp(keyEvent.keyPressedName.c_str(), "Return") || +// !strcmp(keyEvent.keyPressedName.c_str(), "KP_Enter")) +// { +// ecore_imf_context_reset(mIMFContext); +// } +// } +// } + return eventHandled; +} + +bool InputMethodContextWin::ProcessEventKeyUp( const KeyEvent& keyEvent ) +{ + bool eventHandled( false ); +// if( mIMFContext ) +// { +// // We're consuming key up event so we have to pass to InputMethodContext so that it can parse it as well. +// Ecore_IMF_Event_Key_Up ecoreKeyUpEvent; +// ecoreKeyUpEvent.keyname = keyEvent.keyPressedName.c_str(); +// ecoreKeyUpEvent.key = keyEvent.keyPressedName.c_str(); +// ecoreKeyUpEvent.string = keyEvent.keyPressed.c_str(); +// ecoreKeyUpEvent.compose = keyEvent.GetCompose().c_str(); +// ecoreKeyUpEvent.timestamp = keyEvent.time; +// ecoreKeyUpEvent.modifiers = EcoreInputModifierToEcoreIMFModifier( keyEvent.keyModifier ); +// ecoreKeyUpEvent.locks = EcoreInputModifierToEcoreIMFLock( keyEvent.keyModifier ); +//#ifdef ECORE_IMF_1_13 +// ecoreKeyUpEvent.dev_name = ""; +//#endif // ECORE_IMF_1_13 +// +// eventHandled = ecore_imf_context_filter_event(mIMFContext, +// ECORE_IMF_EVENT_KEY_UP, +// (Ecore_IMF_Event *) &ecoreKeyUpEvent); +// } + return eventHandled; +} + +//Ecore_IMF_Keyboard_Modifiers InputMethodContextWin::EcoreInputModifierToEcoreIMFModifier( unsigned int ecoreModifier ) +//{ +// unsigned int modifier( ECORE_IMF_KEYBOARD_MODIFIER_NONE ); // If no other matches returns NONE. +// +// if ( ecoreModifier & ECORE_EVENT_MODIFIER_SHIFT ) // enums from ecore_input/Ecore_Input.h +// { +// modifier |= ECORE_IMF_KEYBOARD_MODIFIER_SHIFT; // enums from ecore_imf/ecore_imf.h +// } +// +// if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALT ) +// { +// modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALT; +// } +// +// if ( ecoreModifier & ECORE_EVENT_MODIFIER_CTRL ) +// { +// modifier |= ECORE_IMF_KEYBOARD_MODIFIER_CTRL; +// } +// +// if ( ecoreModifier & ECORE_EVENT_MODIFIER_WIN ) +// { +// modifier |= ECORE_IMF_KEYBOARD_MODIFIER_WIN; +// } +// +// if ( ecoreModifier & ECORE_EVENT_MODIFIER_ALTGR ) +// { +// modifier |= ECORE_IMF_KEYBOARD_MODIFIER_ALTGR; +// } +// +// return static_cast( modifier ); +//} +// +//Ecore_IMF_Keyboard_Locks InputMethodContextWin::EcoreInputModifierToEcoreIMFLock( unsigned int modifier ) +//{ +// unsigned int lock( ECORE_IMF_KEYBOARD_LOCK_NONE ); // If no other matches, returns NONE. +// +// if( modifier & ECORE_EVENT_LOCK_NUM ) +// { +// lock |= ECORE_IMF_KEYBOARD_LOCK_NUM; // Num lock is active. +// } +// +// if( modifier & ECORE_EVENT_LOCK_CAPS ) +// { +// lock |= ECORE_IMF_KEYBOARD_LOCK_CAPS; // Caps lock is active. +// } +// +// if( modifier & ECORE_EVENT_LOCK_SCROLL ) +// { +// lock |= ECORE_IMF_KEYBOARD_LOCK_SCROLL; // Scroll lock is active. +// } +// +// return static_cast( lock ); +//} + +} // Adaptor + +} // Internal + +} // Dali + +#pragma GCC diagnostic pop diff --git a/dali/internal/input/windows/input-method-context-impl-win.h b/dali/internal/input/windows/input-method-context-impl-win.h new file mode 100755 index 0000000..3d0d395 --- /dev/null +++ b/dali/internal/input/windows/input-method-context-impl-win.h @@ -0,0 +1,293 @@ +#ifndef DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_WIN_H +#define DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_WIN_H + +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include +#include +#include + +namespace Dali +{ + +class RenderSurface; + +namespace Internal +{ + +namespace Adaptor +{ + +class InputMethodContextWin : public Dali::Internal::Adaptor::InputMethodContext +{ +public: + /** + * @brief Creates a new InputMethodContext handle + * + * @return InputMethodContext pointer + */ + static InputMethodContextPtr New(); + + /** + * Constructor + * @param[in] win32Window, The window is created by application. + */ + explicit InputMethodContextWin( Win_Window_Handle win32Window ); + +public: + + /** + * @brief Initializes member data. + */ + void Initialize() override; + + /** + * Connect Callbacks required for InputMethodContext. + * If you don't connect InputMethodContext callbacks, you can't get the key events. + * The events are PreeditChanged, Commit and DeleteSurrounding. + */ + void ConnectCallbacks() override; + + /** + * Disconnect Callbacks attached to input method context. + */ + void DisconnectCallbacks() override; + + /** + * @copydoc Dali::InputMethodContext::Finalize() + */ + void Finalize() override; + + /** + * @copydoc Dali::InputMethodContext::Activate() + */ + void Activate() override; + + /** + * @copydoc Dali::InputMethodContext::Deactivate() + */ + void Deactivate() override; + + /** + * @copydoc Dali::InputMethodContext::Reset() + */ + void Reset() override; + + /** + * @copydoc Dali::InputMethodContext::GetContext() + */ + ImfContext* GetContext() override; + + /** + * @copydoc Dali::InputMethodContext::RestoreAfterFocusLost() + */ + bool RestoreAfterFocusLost() const override; + + /** + * @copydoc Dali::InputMethodContext::SetRestoreAfterFocusLost() + */ + void SetRestoreAfterFocusLost( bool toggle ) override; + + /** + * @copydoc Dali::InputMethodContext::PreEditChanged() + */ + void PreEditChanged( void* data, ImfContext* imfContext, void* event_info ) override; + + /** + * @copydoc Dali::InputMethodContext::NotifyCursorPosition() + */ + void CommitReceived( void* data, ImfContext* imfContext, void* event_info ) override; + + /** + * @copydoc Dali::InputMethodContext::NotifyCursorPosition() + */ + bool RetrieveSurrounding( void* data, ImfContext* imfContext, char** text, int* cursorPosition ) override; + + /** + * @copydoc Dali::InputMethodContext::DeleteSurrounding() + */ + void DeleteSurrounding( void* data, ImfContext* imfContext, void* event_info ) override; + + /** + * @copydoc Dali::InputMethodContext::SendPrivateCommand() + */ + void SendPrivateCommand( void* data, ImfContext* imfContext, void* event_info ) override + {} + + // Cursor related + /** + * @copydoc Dali::InputMethodContext::NotifyCursorPosition() + */ + void NotifyCursorPosition() override; + + /** + * @copydoc Dali::InputMethodContext::SetCursorPosition() + */ + void SetCursorPosition( unsigned int cursorPosition ) override; + + /** + * @copydoc Dali::InputMethodContext::GetCursorPosition() + */ + unsigned int GetCursorPosition() const override; + + /** + * @copydoc Dali::InputMethodContext::SetSurroundingText() + */ + void SetSurroundingText( const std::string& text ) override; + + /** + * @copydoc Dali::InputMethodContext::GetSurroundingText() + */ + const std::string& GetSurroundingText() const override; + + /** + * @copydoc Dali::InputMethodContext::NotifyTextInputMultiLine() + */ + void NotifyTextInputMultiLine( bool multiLine ) override; + + /** + * @copydoc Dali::InputMethodContext::GetTextDirection() + */ + Dali::InputMethodContext::TextDirection GetTextDirection() override; + + /** + * @copydoc Dali::InputMethodContext::GetInputMethodArea() + */ + Dali::Rect GetInputMethodArea() override; + + /** + * @copydoc Dali::InputMethodContext::ApplyOptions() + */ + void ApplyOptions( const InputMethodOptions& options ) override; + + /** + * @copydoc Dali::InputMethodContext::SetInputPanelData() + */ + void SetInputPanelData( const std::string& data ) override; + + /** + * @copydoc Dali::InputMethodContext::GetInputPanelData() + */ + void GetInputPanelData( std::string& data ) override; + + /** + * @copydoc Dali::InputMethodContext::GetInputPanelState() + */ + Dali::InputMethodContext::State GetInputPanelState() override; + + /** + * @copydoc Dali::InputMethodContext::SetReturnKeyState() + */ + void SetReturnKeyState( bool visible ) override; + + /** + * @copydoc Dali::InputMethodContext::AutoEnableInputPanel() + */ + void AutoEnableInputPanel( bool enabled ) override; + + /** + * @copydoc Dali::InputMethodContext::ShowInputPanel() + */ + void ShowInputPanel() override; + + /** + * @copydoc Dali::InputMethodContext::HideInputPanel() + */ + void HideInputPanel() override; + + /** + * @copydoc Dali::InputMethodContext::GetKeyboardType() + */ + Dali::InputMethodContext::KeyboardType GetKeyboardType() override; + + /** + * @copydoc Dali::InputMethodContext::GetInputPanelLocale() + */ + std::string GetInputPanelLocale() override; + + /** + * @copydoc Dali::InputMethodContext::FilterEventKey() + */ + bool FilterEventKey( const Dali::KeyEvent& keyEvent ) override; + +private: + /** + * Context created the first time and kept until deleted. + * @param[in] win32Window, The window is created by application. + */ + void CreateContext( Win_Window_Handle win32Window ); + + /** + * @copydoc Dali::InputMethodContext::DeleteContext() + */ + void DeleteContext(); + +private: + + /** + * @brief Process event key down, whether filter a key to isf. + * + * @param[in] keyEvent The event key to be handled. + * @return Whether the event key is handled. + */ + bool ProcessEventKeyDown( const KeyEvent& keyEvent ); + + /** + * @brief Process event key up, whether filter a key to isf. + * + * @param[in] keyEvent The event key to be handled. + * @return Whether the event key is handled. + */ + bool ProcessEventKeyUp( const KeyEvent& keyEvent ); + +public: + + /** + * Destructor. + */ + virtual ~InputMethodContextWin(); + +private: + + // Undefined copy constructor + InputMethodContextWin( const InputMethodContextWin& inputMethodContext) = delete; + + // Undefined assignment operator + InputMethodContextWin& operator=( const InputMethodContextWin& inputMethodContext ) = delete; + +private: + Win_Window_Handle mWin32Window; + int mIMFCursorPosition; + std::string mSurroundingText; + + bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained. + bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected. + InputMethodOptions mOptions; +}; + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali + +#endif // DALI_INTERNAL_INPUT_METHOD_CONTEXT_IMPL_WIN_H diff --git a/dali/internal/input/windows/key-mapping-win.cpp b/dali/internal/input/windows/key-mapping-win.cpp new file mode 100755 index 0000000..46a32a3 --- /dev/null +++ b/dali/internal/input/windows/key-mapping-win.cpp @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +namespace KeyLookup +{ + +// matches a DALI_KEY enum, to key name +KeyLookup KeyLookupTable[]= +{ + // more than one key name can be assigned to a single dali-key code + // e.g. "Menu" and "XF86Menu" are both assigned to DALI_KEY_MENU + + { "Escape", DALI_KEY_ESCAPE, false }, + { "Menu", DALI_KEY_MENU, false }, + + // Now literal strings are used as key names instead of defined symbols in utilX, + // since these definition in utilX.h is deprecated + { "XF86Camera", DALI_KEY_CAMERA, false }, + { "XF86Camera_Full", DALI_KEY_CONFIG, false }, + { "XF86PowerOff", DALI_KEY_POWER, true }, + { "XF86Standby", DALI_KEY_PAUSE, false }, + { "Cancel", DALI_KEY_CANCEL, false }, + { "XF86AudioPlay", DALI_KEY_PLAY_CD, false }, + { "XF86AudioStop", DALI_KEY_STOP_CD, false }, + { "XF86AudioPause", DALI_KEY_PAUSE_CD, false }, + { "XF86AudioNext", DALI_KEY_NEXT_SONG, false }, + { "XF86AudioPrev", DALI_KEY_PREVIOUS_SONG, false }, + { "XF86AudioRewind", DALI_KEY_REWIND, false }, + { "XF86AudioForward", DALI_KEY_FASTFORWARD, false }, + { "XF86AudioMedia", DALI_KEY_MEDIA, false }, + { "XF86AudioPlayPause", DALI_KEY_PLAY_PAUSE, false }, + { "XF86AudioMute", DALI_KEY_MUTE, false }, + { "XF86Menu", DALI_KEY_MENU, true }, + { "XF86Home", DALI_KEY_HOME, true }, + { "XF86Back", DALI_KEY_BACK, true }, + { "XF86Send", DALI_KEY_MENU, true }, + { "XF86Phone", DALI_KEY_HOME, true }, + { "XF86Stop", DALI_KEY_BACK, true }, + { "XF86HomePage", DALI_KEY_HOMEPAGE, false }, + { "XF86WWW", DALI_KEY_WEBPAGE, false }, + { "XF86Mail", DALI_KEY_MAIL, false }, + { "XF86ScreenSaver", DALI_KEY_SCREENSAVER, false }, + { "XF86MonBrightnessUp", DALI_KEY_BRIGHTNESS_UP, false }, + { "XF86MonBrightnessDown", DALI_KEY_BRIGHTNESS_DOWN, false }, + { "XF86SoftKBD", DALI_KEY_SOFT_KBD, false }, + { "XF86QuickPanel", DALI_KEY_QUICK_PANEL, false }, + { "XF86TaskPane", DALI_KEY_TASK_SWITCH, false }, + { "XF86Apps", DALI_KEY_APPS, false }, + { "XF86Search", DALI_KEY_SEARCH, false }, + { "XF86Voice", DALI_KEY_VOICE, false }, + { "Hangul", DALI_KEY_LANGUAGE, false }, + { "XF86AudioRaiseVolume", DALI_KEY_VOLUME_UP, true }, + { "XF86AudioLowerVolume", DALI_KEY_VOLUME_DOWN, true }, + + { "BackSpace", DALI_KEY_BACKSPACE, false }, + { "Up", DALI_KEY_CURSOR_UP, false }, // To be removed after the key name is fixed in the platform + { "Left", DALI_KEY_CURSOR_LEFT, false }, + { "Right", DALI_KEY_CURSOR_RIGHT, false }, + { "Down", DALI_KEY_CURSOR_DOWN, false }, // To be removed after the key name is fixed in the platform + { "Shift_L", DALI_KEY_SHIFT_LEFT, false }, + { "Shift_R", DALI_KEY_SHIFT_RIGHT, false }, + { "Delete", static_cast( DevelKey::DALI_KEY_DELETE ), false }, + { "Control_L", static_cast( DevelKey::DALI_KEY_CONTROL_LEFT ), false }, + { "Control_R", static_cast( DevelKey::DALI_KEY_CONTROL_RIGHT ), false } +}; + +const std::size_t KEY_LOOKUP_COUNT = (sizeof( KeyLookupTable ))/ (sizeof( KeyLookup )); + +} // namespace KeyLookup + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali diff --git a/dali/internal/input/windows/virtual-keyboard-impl-win.cpp b/dali/internal/input/windows/virtual-keyboard-impl-win.cpp new file mode 100755 index 0000000..da9d5c1 --- /dev/null +++ b/dali/internal/input/windows/virtual-keyboard-impl-win.cpp @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +//#include +//#include +#include + +#include + +// INTERNAL INCLUDES +#include +#include +#include + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +namespace VirtualKeyboard +{ +void Show() +{ +} + +void Hide() +{ + +} + +bool IsVisible() +{ + return false; +} + +void ApplySettings( const Property::Map& settingsMap ) +{ + +} + +void EnablePrediction( const bool enable ) +{ + +} + +bool IsPredictionEnabled() +{ + return false; +} + +Rect GetSizeAndPosition() +{ + Rect ret; + return ret; +} + +Dali::VirtualKeyboard::StatusSignalType& StatusChangedSignal() +{ + Dali::VirtualKeyboard::StatusSignalType ret; + return ret; +} + +Dali::VirtualKeyboard::KeyboardResizedSignalType& ResizedSignal() +{ + Dali::VirtualKeyboard::KeyboardResizedSignalType ret; + return ret; +} + +Dali::VirtualKeyboard::LanguageChangedSignalType& LanguageChangedSignal() +{ + Dali::VirtualKeyboard::LanguageChangedSignalType ret; + return ret; +} + +Dali::VirtualKeyboard::TextDirection GetTextDirection() +{ + return Dali::VirtualKeyboard::LeftToRight; +} + +Dali::InputMethod::ActionButton gActionButtonFunction = Dali::InputMethod::ACTION_DEFAULT; + +//Ecore_IMF_Input_Panel_Return_Key_Type buttonActionMapping(Dali::InputMethod::ButtonAction::Type buttonAction ) +//{ +// switch( buttonAction ) +// { +// case InputMethod::ButtonAction::DEFAULT: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT; +// case InputMethod::ButtonAction::DONE: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DONE; +// case InputMethod::ButtonAction::GO: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_GO; +// case InputMethod::ButtonAction::JOIN: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_JOIN; +// case InputMethod::ButtonAction::LOGIN: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_LOGIN; +// case InputMethod::ButtonAction::NEXT: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_NEXT; +// case InputMethod::ButtonAction::PREVIOUS: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT; +// case InputMethod::ButtonAction::SEARCH: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH; +// case InputMethod::ButtonAction::SEND: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_SEND; +// case InputMethod::ButtonAction::SIGNIN: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT; +// case InputMethod::ButtonAction::UNSPECIFIED: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT; +// case InputMethod::ButtonAction::NONE: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT; +// default: return ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT; +// } +//} + +void RotateTo(int angle) +{ + // Get focus window used by Keyboard and rotate it + //Display* display = XOpenDisplay(0); + //if (display) + //{ + // ::Window focusWindow; + // int revert; + // // Get Focus window + // XGetInputFocus(display, &focusWindow, &revert); + + // ecore_x_window_prop_property_set( focusWindow, + // ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE, + // ECORE_X_ATOM_CARDINAL, 32, &angle, 1 ); + // XCloseDisplay(display); + //} +} + +void SetReturnKeyType( const InputMethod::ButtonAction::Type type ) +{ + //Dali::ImfManager imfManager = ImfManager::Get(); // Create ImfManager instance (if required) when setting values + //Ecore_IMF_Context* imfContext = reinterpret_cast(ImfManager::GetImplementation( imfManager ).GetContext()); + + //if( imfContext ) + //{ + // gActionButtonFunction = type; + // ecore_imf_context_input_panel_return_key_type_set( imfContext, actionButtonMapping( type ) ); + //} +} + +Dali::InputMethod::ButtonAction::Type GetReturnKeyType() +{ + return Dali::InputMethod::ButtonAction::DEFAULT; +} + +} // namespace VirtualKeyboard + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali diff --git a/dali/internal/system/common/abort-handler.h b/dali/internal/system/common/abort-handler.h old mode 100644 new mode 100755 index 90b8aef..44475fa --- a/dali/internal/system/common/abort-handler.h +++ b/dali/internal/system/common/abort-handler.h @@ -86,7 +86,7 @@ private: AbortHandler& operator=(const AbortHandler& rhs); private: - typedef void (*SignalHandlerFuncPtr )( int ); + typedef void ( *SignalHandlerFuncPtr )( int ); // _NSIG comes from the signal.h linux system header, defining the number of signals. SignalHandlerFuncPtr mSignalOldHandlers[_NSIG-1]; diff --git a/dali/internal/system/common/file-closer.h b/dali/internal/system/common/file-closer.h old mode 100644 new mode 100755 index 78f6e5a..8a8a37d --- a/dali/internal/system/common/file-closer.h +++ b/dali/internal/system/common/file-closer.h @@ -28,7 +28,23 @@ namespace Internal { namespace Platform { +namespace InternalFile +{ + FILE *fmemopen( void *__s, size_t __len, const char *__modes ); + + size_t fread( void* _Buffer, size_t _ElementSize, size_t _ElementCount, FILE* _Stream ); + int fclose( FILE *__stream ); + + size_t fread( void* buf, size_t eleSize, size_t count, const FILE *fp ); + + void fwrite( void *buf, int size, int count, FILE *fp ); + int fseek( FILE *fp, int offset, int origin ); + + int ftell( FILE *fp ); + + bool feof( FILE *fp ); +}; /** * Opens files and closes them later even if an exception is thrown. */ @@ -55,7 +71,7 @@ protected: // prevent this class being directly instantiated * @brief Construct a FileCloser guarding a FILE* for reading out of the memory buffer passed in. */ FileCloser( uint8_t* buffer, size_t dataSize, const char * const mode ) - : mFile( fmemopen( buffer, dataSize, mode) ) + : mFile( InternalFile::fmemopen( buffer, dataSize, mode) ) { } @@ -71,7 +87,7 @@ protected: // prevent this class being directly instantiated vector.Resize( bufferSize ); void * const buffer = &vector[0]; - mFile = fmemopen( buffer, bufferSize, mode ); + mFile = InternalFile::fmemopen( buffer, bufferSize, mode ); DALI_ASSERT_DEBUG( buffer != 0 && "Cant open file on null buffer." ); DALI_ASSERT_DEBUG( dataSize > 0 && "Pointless to open file on empty buffer." ); @@ -90,7 +106,7 @@ protected: // prevent this class being directly instantiated { if( mFile != 0 ) { - const int closeFailed = fclose( mFile ); + const int closeFailed = InternalFile::fclose( mFile ); if ( closeFailed ) { diff --git a/dali/internal/system/file.list b/dali/internal/system/file.list old mode 100644 new mode 100755 index 62798c8..1fac295 --- a/dali/internal/system/file.list +++ b/dali/internal/system/file.list @@ -33,7 +33,8 @@ adaptor_system_common_src_files=\ adaptor_system_linux_src_files=\ ${adaptor_system_dir}/linux/callback-manager-ecore.cpp \ ${adaptor_system_dir}/linux/file-descriptor-monitor-ecore.cpp \ - ${adaptor_system_dir}/linux/timer-impl-ecore.cpp + ${adaptor_system_dir}/linux/timer-impl-ecore.cpp \ + ${adaptor_system_dir}/linux/file-closer-linux.cpp # module: system, backend: tizen-wayland adaptor_system_tizen_wayland_src_files=\ diff --git a/dali/internal/system/linux/file-closer-linux.cpp b/dali/internal/system/linux/file-closer-linux.cpp new file mode 100755 index 0000000..1c23b8e --- /dev/null +++ b/dali/internal/system/linux/file-closer-linux.cpp @@ -0,0 +1,52 @@ +#include +#include +#include + +#include + +namespace Dali +{ +namespace Internal +{ +namespace Platform +{ +namespace InternalFile +{ +FILE *fmemopen( void *__s, size_t __len, const char *__modes ) +{ + return ::fmemopen( __s, __len, __modes ); +} + +size_t fread( void* _Buffer, size_t _ElementSize, size_t _ElementCount, FILE* _Stream ) +{ + return ::fread( _Buffer, _ElementSize, _ElementCount, _Stream ); +} + +int fclose( FILE *__stream ) +{ + return ::fclose( __stream ); +} + +void fwrite( void *buf, int size, int count, FILE *fp ) +{ + ::fwrite( buf, size, count, fp ); +} + +int fseek( FILE *fp, int offset, int origin ) +{ + return ::fseek( fp, offset, origin ); +} + +int ftell( FILE *fp ) +{ + return ::ftell( fp ); +} + +bool feof( FILE *fp ) +{ + return ::feof( fp ); +} +} //InternalFile +} //Platform +} //Internal +} //Dali diff --git a/dali/internal/system/windows/callback-manager-win.cpp b/dali/internal/system/windows/callback-manager-win.cpp new file mode 100755 index 0000000..7651c6e --- /dev/null +++ b/dali/internal/system/windows/callback-manager-win.cpp @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +WinCallbackManager::WinCallbackManager() +:mRunning(false) +{ +} + +void WinCallbackManager::Start() +{ + DALI_ASSERT_DEBUG( mRunning == false ); + mRunning = true; +} + +void WinCallbackManager::Stop() +{ + // make sure we're not called twice + DALI_ASSERT_DEBUG( mRunning == true ); + + mRunning = false; +} + +#define WIN_CALLBACK_EVENT 9999 + +bool WinCallbackManager::AddIdleCallback( CallbackBase* callback, bool hasReturnValue) +{ + if( !mRunning ) + { + return false; + } + + WindowsPlatformImplement::AddListener( WIN_CALLBACK_EVENT, callback ); + WindowsPlatformImplement::PostWinMessage( WIN_CALLBACK_EVENT, (long)callback, 0 ); + return true; +} + +void WinCallbackManager::RemoveIdleCallback( CallbackBase* callback ) +{ + //Wait for deal +} + +bool WinCallbackManager::AddIdleEntererCallback(CallbackBase* callback) +{ + return true; +} + +void WinCallbackManager::RemoveIdleEntererCallback(CallbackBase* callback) +{ + +} + + +// Creates a concrete interface for CallbackManager +CallbackManager* CallbackManager::New() +{ + return new WinCallbackManager; +} + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali diff --git a/dali/internal/system/windows/callback-manager-win.h b/dali/internal/system/windows/callback-manager-win.h new file mode 100755 index 0000000..57c738b --- /dev/null +++ b/dali/internal/system/windows/callback-manager-win.h @@ -0,0 +1,95 @@ +#ifndef DALI_WIN_CALLBACK_MANAGER_H +#define DALI_WIN_CALLBACK_MANAGER_H + +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include + + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ +/** + * @brief LibUV callback manager used to install call backs in the applications main loop. + * The manager keeps track of all callbacks, so that if Stop() is called it can remove them. + */ +class WinCallbackManager : public CallbackManager +{ + +public: + + /** + * @brief constructor + */ + WinCallbackManager(); + + /** + * @brief destructor + */ + ~WinCallbackManager(){} + + /** + * @copydoc CallbackManager::AddIdleCallback() + */ + virtual bool AddIdleCallback( CallbackBase* callback, bool hasReturnValue ); + + /** + * @copydoc CallbackManager::RemoveIdleCallback() + */ + virtual void RemoveIdleCallback( CallbackBase* callback ); + + /** + * @copydoc CallbackManager::AddIdleEntererCallback() + */ + virtual bool AddIdleEntererCallback(CallbackBase* callback); + + /** + * @copydoc CallbackManager::RemoveIdleEntererCallback() + */ + virtual void RemoveIdleEntererCallback(CallbackBase* callback); + + /** + * @copydoc CallbackManager::Start() + */ + virtual void Start(); + + /** + * @copydoc CallbackManager::Stop() + */ + virtual void Stop(); + +private: + bool mRunning; ///< flag is set to true if when running +}; + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali + +#endif // __DALI_UV_CALLBACK_MANAGER_H__ diff --git a/dali/internal/system/windows/file-closer-win.cpp b/dali/internal/system/windows/file-closer-win.cpp new file mode 100755 index 0000000..b8abd82 --- /dev/null +++ b/dali/internal/system/windows/file-closer-win.cpp @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include +#include + +#include + +namespace Dali +{ +namespace Internal +{ +namespace Platform +{ +namespace InternalFile +{ +FILE *fmemopen( void *__s, size_t __len, const char *__modes ) +{ + FILE *ret = (FILE*)CustomFile::fmemopen( __s, __len, __modes ); + return ret; +} + +size_t fread( void* _Buffer, size_t _ElementSize, size_t _ElementCount, FILE* _Stream ) +{ + return CustomFile::fread( _Buffer, _ElementSize, _ElementCount, _Stream ); +} + +int fclose( FILE *__stream ) +{ + return CustomFile::fclose( __stream ); +} + +void fwrite( void *buf, int size, int count, FILE *fp ) +{ + CustomFile::fwrite( buf, size * count, fp ); +} + +int fseek( FILE *fp, int offset, int origin ) +{ + return CustomFile::fseek( fp, offset, origin ); +} + +int ftell( FILE *fp ) +{ + return CustomFile::ftell( fp ); +} + +bool feof( FILE *fp ) +{ + return CustomFile::feof( fp ); +} +} //InternalFile +} //Platform +} //Internal +} //Dali diff --git a/dali/internal/system/windows/timer-impl-win.cpp b/dali/internal/system/windows/timer-impl-win.cpp new file mode 100755 index 0000000..e7e4438 --- /dev/null +++ b/dali/internal/system/windows/timer-impl-win.cpp @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// Ecore is littered with C style cast +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wold-style-cast" + +// INTERNAL INCLUDES +#include + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +// LOCAL STUFF +namespace +{ +void TimerSourceFunc (void *data) +{ + Timer* timer = static_cast(data); + + bool keepRunning = timer->Tick(); +} +} + +/** + * Struct to hide away Ecore implementation details + */ +struct Timer::Impl +{ + Impl( unsigned int milliSec ) : + mId(-1), + mInterval(milliSec) + { + } + + int mId; + + unsigned int mInterval; +}; + +TimerPtr Timer::New( unsigned int milliSec ) +{ + TimerPtr timer( new Timer( milliSec ) ); + return timer; +} + +Timer::Timer( unsigned int milliSec ) +: mImpl(new Impl(milliSec)) +{ +} + +Timer::~Timer() +{ + // stop timers + Stop(); + + delete mImpl; + mImpl = NULL; +} + +void Timer::Start() +{ + if( 0 > mImpl->mId ) + { + mImpl->mId = WindowsPlatformImplement::SetTimer( mImpl->mInterval, TimerSourceFunc, this ); + } +} + +void Timer::Stop() +{ + if( 0 <= mImpl->mId ) + { + WindowsPlatformImplement::KillTimer( mImpl->mId ); + mImpl->mId = -1; + } +} + +void Timer::SetInterval( unsigned int interval ) +{ + // stop existing timer + Stop(); + mImpl->mInterval = interval; + // start new tick + Start(); +} + +unsigned int Timer::GetInterval() const +{ + return mImpl->mInterval; +} + +bool Timer::Tick() +{ + // Guard against destruction during signal emission + Dali::Timer handle( this ); + + bool retVal( false ); + + // Override with new signal if used + if( !mTickSignal.Empty() ) + { + retVal = mTickSignal.Emit(); + + // Timer stops if return value is false + if (retVal == false) + { + Stop(); + } + else + { + retVal = true; // continue emission + } + } + else // no callbacks registered + { + // periodic timer is started but nobody listens, continue + retVal = true; + } + + return retVal; +} + +Dali::Timer::TimerSignalType& Timer::TickSignal() +{ + return mTickSignal; +} + +bool Timer::IsRunning() const +{ + return 0 <= mImpl->mId; +} + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali + +#pragma GCC diagnostic pop diff --git a/dali/internal/system/windows/trigger-event.cpp b/dali/internal/system/windows/trigger-event.cpp new file mode 100755 index 0000000..88643a3 --- /dev/null +++ b/dali/internal/system/windows/trigger-event.cpp @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +#include + +#include + +// INTERNAL INCLUDES +#include +#include + +#define MESSAGE_TYPE_OFFSET 10000 + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ +TriggerEvent* triggerEventArray[10000] = { 0 }; + +int SetTriggerEvent(TriggerEvent *event) +{ + for (size_t i = 0; i < 10000; i++) + { + if (NULL == triggerEventArray[i]) + { + triggerEventArray[i] = event; + return i; + } + } + + return -1; +} + +TriggerEvent::TriggerEvent( CallbackBase* callback, TriggerEventInterface::Options options ) +: mCallback( callback ), + mFileDescriptor( -1 ), + mOptions( options ) +{ + // Create accompanying file descriptor. + mFileDescriptor = SetTriggerEvent( this ); + WindowsPlatformImplement::AddListener( mFileDescriptor + MESSAGE_TYPE_OFFSET, mCallback ); + + if (mFileDescriptor >= 0) + { + // Now Monitor the created event file descriptor + } + else + { + DALI_LOG_ERROR("Unable to create TriggerEvent File descriptor\n"); + } +} + +TriggerEvent::~TriggerEvent() +{ + delete mCallback; + + if (mFileDescriptor >= 0) + { + mFileDescriptor = 0; + } +} + +void TriggerEvent::Trigger() +{ + if (mFileDescriptor >= 0) + { + // Increment event counter by 1. + // Writing to the file descriptor triggers the Dispatch() method in the other thread + // (if in multi-threaded environment). + + WindowsPlatformImplement::PostWinMessage( mFileDescriptor + MESSAGE_TYPE_OFFSET, 0, 0 ); + } + else + { + DALI_LOG_WARNING("Attempting to write to an invalid file descriptor\n"); + } +} + +void TriggerEvent::Triggered( FileDescriptorMonitor::EventType eventBitMask ) +{ + if( !( eventBitMask & FileDescriptorMonitor::FD_READABLE ) ) + { + DALI_ASSERT_ALWAYS( 0 && "Trigger event file descriptor error"); + return; + } + + // Reading from the file descriptor resets the event counter, we can ignore the count. + uint64_t receivedData; + size_t size; + size = read(mFileDescriptor, &receivedData, sizeof(uint64_t)); + if (size != sizeof(uint64_t)) + { + DALI_LOG_WARNING("Unable to read to UpdateEvent File descriptor\n"); + } + + // Call the connected callback + CallbackBase::Execute( *mCallback ); + + //check if we should delete ourselves after the trigger + if( mOptions == TriggerEventInterface::DELETE_AFTER_TRIGGER ) + { + delete this; + } +} + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali diff --git a/dali/internal/system/windows/widget-application-impl-win.cpp b/dali/internal/system/windows/widget-application-impl-win.cpp new file mode 100755 index 0000000..57c38ee --- /dev/null +++ b/dali/internal/system/windows/widget-application-impl-win.cpp @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include +#include + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +WidgetApplicationPtr WidgetApplicationWin::New( + int* argc, + char **argv[], + const std::string& stylesheet) +{ + return new WidgetApplicationWin(argc, argv, stylesheet ); +} + +WidgetApplicationWin::WidgetApplicationWin( int* argc, char** argv[], const std::string& stylesheet ) +: WidgetApplication(argc, argv, stylesheet) +{ + DALI_LOG_ERROR("WidgetApplication is not implemented in UBUNTU profile.\n"); +} + +WidgetApplicationWin::~WidgetApplicationWin() +{ +} + + +void WidgetApplicationWin::RegisterWidgetCreatingFunction( const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction ) +{ +} + +// factory function, must be implemented +namespace WidgetApplicationFactory +{ +/** + * Create a new widget application + * @param[in] argc A pointer to the number of arguments + * @param[in] argv A pointer to the argument list + * @param[in] stylesheet The path to user defined theme file + */ +WidgetApplicationPtr Create( int* argc, char **argv[], const std::string& stylesheet ) +{ + return WidgetApplicationWin::New( argc, argv, stylesheet ); +} + +} // namespace Factory + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali diff --git a/dali/internal/system/windows/widget-application-impl-win.h b/dali/internal/system/windows/widget-application-impl-win.h new file mode 100755 index 0000000..fd3b1ab --- /dev/null +++ b/dali/internal/system/windows/widget-application-impl-win.h @@ -0,0 +1,86 @@ +#ifndef DALI_INTERNAL_WIDGET_APPLICATION_IMPL_WIN_H +#define DALI_INTERNAL_WIDGET_APPLICATION_IMPL_WIN_H + +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include +#include +#include + +namespace Dali +{ +class Widget; + +namespace Internal +{ + +namespace Adaptor +{ + +/** + * Implementation of the WidgetApplicationWin class. + */ +class WidgetApplicationWin : public WidgetApplication +{ +public: + + typedef std::pair CreateWidgetFunctionPair; + typedef std::vector< CreateWidgetFunctionPair > CreateWidgetFunctionContainer; + + /** + * Create a new widget application + * @param[in] argc A pointer to the number of arguments + * @param[in] argv A pointer to the argument list + * @param[in] stylesheet The path to user defined theme file + */ + static WidgetApplicationPtr New( int* argc, char **argv[], const std::string& stylesheet ); + +public: + + /** + * @copydoc Dali::WidgetApplication::RegisterWidgetCreator() + */ + void RegisterWidgetCreatingFunction( const std::string& widgetName, Dali::WidgetApplication::CreateWidgetFunction createFunction ) override; + +protected: + + /** + * Private Constructor + * @param[in] argc A pointer to the number of arguments + * @param[in] argv A pointer to the argument list + * @param[in] stylesheet The path to user defined theme file + */ + WidgetApplicationWin( int* argc, char **argv[], const std::string& stylesheet ); + + /** + * Destructor + */ + virtual ~WidgetApplicationWin(); + + WidgetApplicationWin(const Application&) = delete; + WidgetApplicationWin& operator=(Application&) = delete; +}; + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali + +#endif // DALI_INTERNAL_WIDGET_APPLICATION_IMPL_UBUNTU_H diff --git a/dali/internal/system/windows/widget-controller-win.cpp b/dali/internal/system/windows/widget-controller-win.cpp new file mode 100755 index 0000000..e98e29c --- /dev/null +++ b/dali/internal/system/windows/widget-controller-win.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +WidgetImplWin::WidgetImplWin() +{ +} + +WidgetImplWin::~WidgetImplWin() +{ +} + +void WidgetImplWin::SetContentInfo( const std::string& contentInfo ) +{ +} + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali diff --git a/dali/internal/system/windows/widget-controller-win.h b/dali/internal/system/windows/widget-controller-win.h new file mode 100755 index 0000000..c19de62 --- /dev/null +++ b/dali/internal/system/windows/widget-controller-win.h @@ -0,0 +1,66 @@ +#ifndef DALI_WIDGET_CONTROLLER_WIN_H +#define DALI_WIDGET_CONTROLLER_WIN_H + +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ +/** + * @brief Holds the Implementation for the internal WidgetImpl class + */ +class WidgetImplWin : public Widget::Impl +{ +public: + + /** + * Constructor + */ + WidgetImplWin(); + + /** + * Destructor + */ + ~WidgetImplWin() override; + +public: + + /** + * Set content information to widget framework + */ + void SetContentInfo( const std::string& contentInfo ) override; +}; + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali + +#endif // DALI_WIDGET_CONTROLLER_UBUNTU_H diff --git a/dali/internal/text/text-abstraction/font-client-plugin-impl.cpp b/dali/internal/text/text-abstraction/font-client-plugin-impl.cpp old mode 100644 new mode 100755 index 1d157c9..9079396 --- a/dali/internal/text/text-abstraction/font-client-plugin-impl.cpp +++ b/dali/internal/text/text-abstraction/font-client-plugin-impl.cpp @@ -1095,7 +1095,7 @@ void FontClient::Plugin::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, boo if( FT_Err_Ok == error ) { FT_Glyph glyph; - +#if defined(__GNUC__) if( softwareBold ) { FT_GlyphSlot_Embolden(ftFace->glyph); @@ -1107,7 +1107,7 @@ void FontClient::Plugin::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, boo FT_Matrix transform = {0x10000, FONT_SLANT_TANGENT, 0x00000, 0x10000}; FT_Outline_Transform(&ftFace->glyph->outline, &transform); } - +#endif error = FT_Get_Glyph( ftFace->glyph, &glyph ); // Convert to bitmap if necessary diff --git a/dali/internal/window-system/common/event-handler.cpp b/dali/internal/window-system/common/event-handler.cpp index a52915f..c9eaa31 100755 --- a/dali/internal/window-system/common/event-handler.cpp +++ b/dali/internal/window-system/common/event-handler.cpp @@ -119,8 +119,8 @@ EventHandler::EventHandler( RenderSurface* surface, CoreEventInterface& coreEven WindowBase* windowBase = windowRenderSurface->GetWindowBase(); // Connect signals - windowBase->FocusChangedSignal().Connect( this, &EventHandler::OnFocusChanged ); windowBase->WindowDamagedSignal().Connect( this, &EventHandler::OnWindowDamaged ); + windowBase->FocusChangedSignal().Connect( this, &EventHandler::OnFocusChanged ); windowBase->RotationSignal().Connect( this, &EventHandler::SendRotationPrepareEvent ); windowBase->TouchEventSignal().Connect( this, &EventHandler::OnTouchEvent ); windowBase->WheelEventSignal().Connect( this, &EventHandler::OnWheelEvent ); diff --git a/dali/internal/window-system/windows/display-connection-factory-win.cpp b/dali/internal/window-system/windows/display-connection-factory-win.cpp new file mode 100755 index 0000000..f37afb7 --- /dev/null +++ b/dali/internal/window-system/windows/display-connection-factory-win.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ + + + +std::unique_ptr DisplayConnectionFactoryWin::CreateDisplayConnection() +{ + return Utils::MakeUnique(); +} + +// this should be created from somewhere +std::unique_ptr GetDisplayConnectionFactory() +{ + // returns windows display factory + return Utils::MakeUnique(); +} + +} +} +} \ No newline at end of file diff --git a/dali/internal/window-system/windows/display-connection-factory-win.h b/dali/internal/window-system/windows/display-connection-factory-win.h new file mode 100755 index 0000000..72b73ab --- /dev/null +++ b/dali/internal/window-system/windows/display-connection-factory-win.h @@ -0,0 +1,46 @@ +#ifndef DALI_INTERNAL_WINDOWSYSTEM_WIN_DISPLAY_CONNECTION_FACTORY_WIN_H +#define DALI_INTERNAL_WINDOWSYSTEM_WIN_DISPLAY_CONNECTION_FACTORY_WIN_H + +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +class DisplayConnectionFactoryWin : public DisplayConnectionFactory +{ +public: + std::unique_ptr CreateDisplayConnection() override; +}; + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali + + +#endif // DALI_INTERNAL_WINDOWSYSTEM_WIN_DISPLAY_CONNECTION_FACTORY_WIN_H diff --git a/dali/internal/window-system/windows/display-connection-impl-win.cpp b/dali/internal/window-system/windows/display-connection-impl-win.cpp new file mode 100755 index 0000000..f989b08 --- /dev/null +++ b/dali/internal/window-system/windows/display-connection-impl-win.cpp @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// EXTERNAL_HEADERS +#include + +// INTERNAL HEADERS +#include + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +DisplayConnection* DisplayConnectionWin::New() +{ + DisplayConnection* pDisplayConnection(new DisplayConnectionWin()); + + return pDisplayConnection; +} + +DisplayConnectionWin::DisplayConnectionWin() +: mDisplay(NULL) +{ +} + +DisplayConnectionWin::~DisplayConnectionWin() +{ + if(mDisplay) + { + //XCloseDisplay(mDisplay); + } +} + +Any DisplayConnectionWin::GetDisplay() +{ + return Any(mDisplay); +} + +void DisplayConnectionWin::ConsumeEvents() +{ + // check events so that we can flush the queue and avoid any potential memory leaks in X + // looping if events remain + int events(0); + do + { + // Check if there are any events in the queue + //events = XEventsQueued(mDisplay, QueuedAfterFlush); + + //if (events > 0) + //{ + // // Just flush event to prevent memory leak from event queue as the events get built up in + // // memory but are only deleted when we retrieve them + // XEvent ev; + // XNextEvent(mDisplay, &ev); + //} + } + while (events > 0); +} + +bool DisplayConnectionWin::InitializeEgl(EglInterface& egl) +{ + EglImplementation& eglImpl = static_cast( egl ); + + if( !eglImpl.InitializeGles( reinterpret_cast( mDisplay ) ) ) + { + DALI_LOG_ERROR( "Failed to initialize GLES.\n" ); + return false; + } + + return true; +} + +void DisplayConnectionWin::SetSurfaceType( RenderSurface::Type type ) +{ + if( type == RenderSurface::WINDOW_RENDER_SURFACE ) + { + mDisplay = GetDC( GetForegroundWindow() ); + } +} + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali diff --git a/dali/internal/window-system/windows/display-connection-impl-win.h b/dali/internal/window-system/windows/display-connection-impl-win.h new file mode 100755 index 0000000..ef07ee7 --- /dev/null +++ b/dali/internal/window-system/windows/display-connection-impl-win.h @@ -0,0 +1,101 @@ +#ifndef DALI_INTERNAL_WIN_DIPLAY_CONNECTION_H +#define DALI_INTERNAL_WIN_DIPLAY_CONNECTION_H + +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include +#include +#include + +namespace Dali +{ + +class RenderSurface; +class DisplayConnection; + +namespace Internal +{ + +namespace Adaptor +{ + +/** + * DisplayConnection implementation + */ +class DisplayConnectionWin : public Dali::Internal::Adaptor::DisplayConnection +{ +public: + + /** + * @brief Default constructor + */ + DisplayConnectionWin(); + + /** + * @brief Create an initialized DisplayConnection. + * + * @return A handle to a newly allocated DisplayConnection resource. + */ + static DisplayConnection* New(); + +public: + + /** + * @copydoc Dali::DisplayConnection::GetDisplay + */ + Any GetDisplay(); + + /** + * @copydoc Dali::DisplayConnection::ConsumeEvents + */ + void ConsumeEvents(); + + /** + * @copydoc Dali::DisplayConnection::InitializeEgl + */ + bool InitializeEgl(EglInterface& egl); + + void SetSurfaceType( RenderSurface::Type type ); + +public: + + /** + * Destructor + */ + virtual ~DisplayConnectionWin(); + +protected: + + // Undefined + DisplayConnectionWin(const DisplayConnectionWin&) = delete; + + // Undefined + DisplayConnectionWin& operator=(const DisplayConnectionWin& rhs) = delete; + +private: + HDC mDisplay; +}; + +} // namespace Adaptor + +} // namespace internal + +} // namespace Dali + +#endif // DALI_INTERNAL_WIN_DIPLAY_CONNECTION_H diff --git a/dali/internal/window-system/windows/event-system-win.cpp b/dali/internal/window-system/windows/event-system-win.cpp new file mode 100755 index 0000000..7fab045 --- /dev/null +++ b/dali/internal/window-system/windows/event-system-win.cpp @@ -0,0 +1,78 @@ +#include +#include + +using namespace std; + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +struct TCallbackInfo +{ + TCallbackInfo(EventCallback callback, void* handler) + { + this->callback = callback; + this->handler = handler; + } + + EventCallback callback; + void* handler; +}; + +map eventTypeToCallbackInfo; + +Event_Handler event_handler_add(int eventType, EventCallback callback, void* handler) +{ + eventTypeToCallbackInfo.insert(make_pair(eventType, new TCallbackInfo(callback, handler))); + return eventType; +} + +void event_handler_del(Event_Handler handler) +{ + map::iterator x = eventTypeToCallbackInfo.find(handler); + + if (eventTypeToCallbackInfo.end() != x) + { + delete x->second; + eventTypeToCallbackInfo.erase( handler ); + } +} + +void* GetEventHandler(int eventType) +{ + map::iterator x = eventTypeToCallbackInfo.find(eventType); + + if (eventTypeToCallbackInfo.end() != x) + { + return x->second->handler; + } + else + { + return NULL; + } +} + +EventCallback GetCallback(int eventType) +{ + map::iterator x = eventTypeToCallbackInfo.find(eventType); + + if (eventTypeToCallbackInfo.end() != x) + { + return x->second->callback; + } + else + { + return NULL; + } +} + +} // namespace Adaptor + +} // namespace internal + +} // namespace Dali \ No newline at end of file diff --git a/dali/internal/window-system/windows/event-system-win.h b/dali/internal/window-system/windows/event-system-win.h new file mode 100755 index 0000000..d46a403 --- /dev/null +++ b/dali/internal/window-system/windows/event-system-win.h @@ -0,0 +1,284 @@ +#pragma once +#ifndef _WINDOWEVENTSYSTEM_H_ +#define _WINDOWEVENTSYSTEM_H_ + +#define EVENT_MOUSE_BUTTON_DOWN WM_LBUTTONDOWN +#define EVENT_MOUSE_BUTTON_UP WM_LBUTTONUP +#define EVENT_MOUSE_MOVE WM_MOUSEMOVE +#define EVENT_MOUSE_OUT WM_MOUSELEAVE +#define EVENT_MOUSE_WHEEL WM_MOUSEWHEEL + +#define EVENT_KEY_DOWN WM_KEYDOWN +#define EVENT_KEY_UP WM_KEYUP + +#define WIN_EVENT_WINDOW_FOCUS_IN WM_SETFOCUS +#define WIN_EVENT_WINDOW_FOCUS_OUT WM_KILLFOCUS + +#define WIN_EVENT_WINDOW_DAMAGE WM_PAINT + +#define WIN_EVENT_XDND_ENTER 0 +#define WIN_EVENT_XDND_POSITION 0 +#define WIN_EVENT_XDND_LEAVE 0 +#define WIN_EVENT_XDND_DROP 0 + +#define WIN_EVENT_XDND_FINISHED 0 +#define WIN_EVENT_XDND_STATUS 0 + +#define WIN_EVENT_CLIENT_MESSAGE 0 +#define WIN_EVENT_SELECTION_CLEAR 0 +#define WIN_EVENT_SELECTION_NOTIFY 0 + +#define CALLBACK_PASS_ON true; + +#define EVENT_MODIFIER_SHIFT 0x0001 +#define EVENT_MODIFIER_CTRL 0x0002 +#define EVENT_MODIFIER_ALT 0x0004 +#define EVENT_MODIFIER_WIN 0x0008 +#define EVENT_MODIFIER_SCROLL 0x0010 +#define EVENT_MODIFIER_NUM 0x0020 +#define EVENT_MODIFIER_CAPS 0x0040 +#define EVENT_LOCK_SCROLL 0x0080 +#define EVENT_LOCK_NUM 0x0100 +#define EVENT_LOCK_CAPS 0x0200 +#define EVENT_LOCK_SHIFT 0x0300 +#define EVENT_MODIFIER_ALTGR 0x0400 /**< @since 1.7 */ + +#define DEVICE_MOUSE 0 + +// INTERNAL INCLUDES +#include + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +typedef enum +{ + IMF_KEYBOARD_MODIFIER_NONE = 0, /**< No active modifiers */ + IMF_KEYBOARD_MODIFIER_CTRL = 1 << 0, /**< "Control" is pressed */ + IMF_KEYBOARD_MODIFIER_ALT = 1 << 1, /**< "Alt" is pressed */ + IMF_KEYBOARD_MODIFIER_SHIFT = 1 << 2, /**< "Shift" is pressed */ + IMF_KEYBOARD_MODIFIER_WIN = 1 << 3, /**< "Win" (between "Ctrl" and "Alt") is pressed */ + IMF_KEYBOARD_MODIFIER_ALTGR = 1 << 4 /**< "AltGr" is pressed @since 1.7 */ +} IMF_Keyboard_Modifiers; + +struct _Event_Key +{ + const char *keyname; /**< The key name */ + const char *key; /**< The key symbol */ + const char *string; + const char *compose; /**< final string corresponding to the key symbol composed */ + winWindow window; /**< The main window where event happened */ + winWindow root_window; /**< The root window where event happened */ + winWindow event_window; /**< The child window where event happened */ + + unsigned int timestamp; /**< Time when the event occurred */ + + unsigned int keycode; /**< Key scan code numeric value @since 1.10 */ + + void *data; /**< User data associated with an Event_Key @since 1.10 */ +}; + +/** +* @struct _Event_Mouse_Button +* Contains information about an Ecore mouse button event. +*/ + +struct _Event_Mouse_Button +{ + winWindow window; /**< The main window where event happened */ + + unsigned int timestamp; /**< Time when the event occurred */ + unsigned int buttons; /**< The button that was used */ + + int x; /**< x coordinate relative to window where event happened */ + int y; /**< y coordinate relative to window where event happened */ + + struct + { + int device; /**< 0 if normal mouse, 1+ for other mouse-devices (eg multi-touch - other fingers) */ + double radius, radius_x, radius_y; /**< radius of press point - radius_x and y if its an ellipse (radius is the average of the 2) */ + double pressure; /**< pressure - 1.0 == normal, > 1.0 == more, 0.0 == none */ + double angle; /**< angle relative to perpendicular (0.0 == perpendicular), in degrees */ + double x, y; /**< same as x, y, but with sub-pixel precision, if available */ + struct + { + double x, y; + } root; /**< same as root.x, root.y, but with sub-pixel precision, if available */ + } multi; +}; + +/** +* @struct _Event_Mouse_Wheel +* Contains information about an Ecore mouse wheel event. +*/ +struct _Event_Mouse_Wheel +{ + winWindow window; /**< The main window where event happened */ + winWindow root_window; /**< The root window where event happened */ + winWindow event_window; /**< The child window where event happened */ + + unsigned int timestamp; /**< Time when the event occurred */ + unsigned int modifiers; /**< The combination of modifiers key (SHIFT,CTRL,ALT,..)*/ + + int direction; /**< Orientation of the wheel (horizontal/vertical) */ + int z; /**< Value of the wheel event (+1/-1) */ + + int x; /**< x coordinate relative to window where event happened */ + int y; /**< y coordinate relative to window where event happened */ + struct + { + int x; + int y; + } root; /**< Coordinates relative to root window */ +}; + +/** +* @struct _Event_Mouse_Move +* Contains information about an Ecore mouse move event. +*/ +struct _Event_Mouse_Move +{ + winWindow window; /**< The main window where event happened */ + winWindow root_window; /**< The root window where event happened */ + winWindow event_window; /**< The child window where event happened */ + + unsigned int timestamp; /**< Time when the event occurred */ + unsigned int modifiers; /**< The combination of modifiers key (SHIFT,CTRL,ALT,..)*/ + + int x; /**< x coordinate relative to window where event happened */ + int y; /**< y coordinate relative to window where event happened */ + struct + { + int x; + int y; + } root; /**< Coordinates relative to root window */ + + struct + { + int device; /**< 0 if normal mouse, 1+ for other mouse-devices (eg multi-touch - other fingers) */ + double radius, radius_x, radius_y; /**< radius of press point - radius_x and y if its an ellipse (radius is the average of the 2) */ + double pressure; /**< pressure - 1.0 == normal, > 1.0 == more, 0.0 == none */ + double angle; /**< angle relative to perpendicular (0.0 == perpendicular), in degrees */ + double x, y; /**< same as x, y root.x, root.y, but with sub-pixel precision, if available */ + struct + { + double x, y; + } root; + } multi; +}; + +typedef enum _Win_Event_Mode +{ + WIN_EVENT_MODE_NORMAL, + WIN_EVENT_MODE_WHILE_GRABBED, + WIN_EVENT_MODE_GRAB, + WIN_EVENT_MODE_UNGRAB +} Win_Event_Mode; + +typedef enum _Win_Event_Detail +{ + WIN_EVENT_DETAIL_ANCESTOR, + WIN_EVENT_DETAIL_VIRTUAL, + WIN_EVENT_DETAIL_INFERIOR, + WIN_EVENT_DETAIL_NON_LINEAR, + WIN_EVENT_DETAIL_NON_LINEAR_VIRTUAL, + WIN_EVENT_DETAIL_POINTER, + WIN_EVENT_DETAIL_POINTER_ROOT, + WIN_EVENT_DETAIL_DETAIL_NONE +} Win_Event_Detail; + +typedef unsigned int Win_Time; + +struct _Win_Event_Mouse_In +{ + int modifiers; + int x, y; + + struct + { + int x, y; + } root; + winWindow win; + winWindow event_win; + winWindow root_win; + Win_Event_Mode mode; + Win_Event_Detail detail; + Win_Time time; +}; + +struct _Win_Event_Mouse_Out +{ + int modifiers; + int x, y; + + struct + { + int x, y; + } root; + winWindow win; + winWindow event_win; + winWindow root_win; + Win_Event_Mode mode; + Win_Event_Detail detail; + Win_Time time; +}; + +struct _Win_Event_Window_Focus_In +{ + winWindow win; +}; + +struct _Win_Event_Window_Focus_Out +{ + winWindow win; +}; + +typedef struct _Event_Key Event_Key; +typedef struct _Event_Mouse_Button Event_Mouse_Button; +typedef struct _Event_Mouse_Wheel Event_Mouse_Wheel; +typedef struct _Event_Mouse_Move Event_Mouse_Move; +typedef struct _Win_Event_Mouse_In Win_Event_Mouse_In; +typedef struct _Win_Event_Mouse_Out Win_Event_Mouse_Out; +typedef struct _Win_Event_Window_Focus_In Win_Event_Window_Focus_In; +typedef struct _Win_Event_Window_Focus_Out Win_Event_Window_Focus_Out; + +typedef int Event_Handler; + +struct TWinEventInfo +{ + TWinEventInfo(long hWnd, unsigned int uMsg, long wParam, long lParam) + { + this->mWindow = (winWindow)hWnd; + this->uMsg = uMsg; + this->wParam = wParam; + this->lParam = lParam; + } + + winWindow mWindow; + unsigned int uMsg; + long wParam; + long lParam; +}; + +typedef bool(*EventCallback)(void* data, int type, TWinEventInfo* event); + +Event_Handler event_handler_add(int eventType, EventCallback callback, void* handler); + +void event_handler_del(Event_Handler handler); + +void* GetEventHandler(int eventType); +EventCallback GetCallback(int eventType); + +} // namespace Adaptor + +} // namespace internal + +} // namespace Dali + +#endif diff --git a/dali/internal/window-system/windows/pixmap-render-surface-win.cpp b/dali/internal/window-system/windows/pixmap-render-surface-win.cpp new file mode 100755 index 0000000..ca9ff4b --- /dev/null +++ b/dali/internal/window-system/windows/pixmap-render-surface-win.cpp @@ -0,0 +1,254 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// EXTERNAL INCLUDES +#include +#include +#include + +// INTERNAL INCLUDES +#include +#include +#include +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ + +#if defined(DEBUG_ENABLED) +Debug::Filter* gPixmapRenderSurfaceLogFilter = Debug::Filter::New(Debug::Verbose, false, "LOG_PIXMAP_RENDER_SURFACE_WIN"); +#endif + +namespace +{ +static const int INITIAL_PRODUCE_BUFFER_INDEX = 0; +static const int INITIAL_CONSUME_BUFFER_INDEX = 1; +} + +PixmapRenderSurfaceEcoreWin::PixmapRenderSurfaceEcoreWin( Dali::PositionSize positionSize, Any surface, bool isTransparent ) +: mPosition( positionSize ), + mRenderNotification( NULL ), + mColorDepth( isTransparent ? COLOR_DEPTH_32 : COLOR_DEPTH_24 ), + mOwnSurface( false ), + mProduceBufferIndex( INITIAL_PRODUCE_BUFFER_INDEX ), + mConsumeBufferIndex( INITIAL_CONSUME_BUFFER_INDEX ), + mThreadSynchronization(NULL) +{ + for( int i = 0; i != BUFFER_COUNT; ++i ) + { + mWinPixmaps[i] = 0; + mEglSurfaces[i] = 0; + } + + Initialize( surface ); +} + +PixmapRenderSurfaceEcoreWin::~PixmapRenderSurfaceEcoreWin() +{ + // release the surface if we own one + //if( mOwnSurface ) + //{ + // for (int i = 0; i < BUFFER_COUNT; ++i) + // { + // Ecore_X_Pixmap pixmap = mWinPixmaps[i]; + + // // if we did create the pixmap, delete the pixmap + // DALI_LOG_INFO( gPixmapRenderSurfaceLogFilter, Debug::General, "Own pixmap (%x) freed\n", pixmap ); + // ecore_x_pixmap_free( pixmap ); + // } + //} +} + +void PixmapRenderSurfaceEcoreWin::Initialize( Any surface ) +{ + // see if there is a surface in Any surface + unsigned int surfaceId = GetSurfaceId( surface ); + + // if the surface is empty, create a new one. + if ( surfaceId == 0 ) + { + // we own the surface about to created + mOwnSurface = true; + CreateRenderable(); + } + else + { + // XLib should already be initialized so no point in calling XInitThreads + UseExistingRenderable( surfaceId ); + } +} + +Any PixmapRenderSurfaceEcoreWin::GetSurface() +{ + //Ecore_X_Pixmap pixmap = 0; + //{ + // ConditionalWait::ScopedLock lock( mPixmapCondition ); + // pixmap = mWinPixmaps[mProduceBufferIndex]; + //} + + return Any( 0 ); +} + +void PixmapRenderSurfaceEcoreWin::SetRenderNotification(TriggerEventInterface* renderNotification) +{ + mRenderNotification = renderNotification; +} + +PositionSize PixmapRenderSurfaceEcoreWin::GetPositionSize() const +{ + return mPosition; +} + +void PixmapRenderSurfaceEcoreWin::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) +{ + // calculate DPI + float xres, yres; + + //// 1 inch = 25.4 millimeters + WindowsPlatformImplement::GetDPI( xres, yres ); + + xres *= 1.5; + yres *= 1.5; + + dpiHorizontal = int( xres + 0.5f ); // rounding + dpiVertical = int( yres + 0.5f ); +} + +void PixmapRenderSurfaceEcoreWin::InitializeEgl( EglInterface& egl ) +{ + DALI_LOG_TRACE_METHOD( gPixmapRenderSurfaceLogFilter ); + + Internal::Adaptor::EglImplementation& eglImpl = static_cast( egl ); + + eglImpl.ChooseConfig(false, mColorDepth); +} + +void PixmapRenderSurfaceEcoreWin::CreateEglSurface( EglInterface& egl ) +{ + DALI_LOG_TRACE_METHOD( gPixmapRenderSurfaceLogFilter ); + + Internal::Adaptor::EglImplementation& eglImpl = static_cast( egl ); + + for (int i = 0; i < BUFFER_COUNT; ++i) + { + // create the EGL surface + // need to cast to X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit + WinPixmap pixmap = static_cast( mWinPixmaps[i] ); + mEglSurfaces[i] = eglImpl.CreateSurfacePixmap( EGLNativePixmapType( pixmap ), mColorDepth ); // reinterpret_cast does not compile + } +} + +void PixmapRenderSurfaceEcoreWin::DestroyEglSurface( EglInterface& egl ) +{ + DALI_LOG_TRACE_METHOD( gPixmapRenderSurfaceLogFilter ); + + Internal::Adaptor::EglImplementation& eglImpl = static_cast( egl ); + + for (int i = 0; i < BUFFER_COUNT; ++i) + { + // need to cast to X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit + WinPixmap pixmap = static_cast( mWinPixmaps[i] ); + eglImpl.MakeCurrent( EGLNativePixmapType( pixmap ), mEglSurfaces[i] ); + eglImpl.DestroySurface(); + } +} + +bool PixmapRenderSurfaceEcoreWin::ReplaceEGLSurface( EglInterface& egl ) +{ + DALI_LOG_TRACE_METHOD( gPixmapRenderSurfaceLogFilter ); + + bool contextLost = false; + + Internal::Adaptor::EglImplementation& eglImpl = static_cast( egl ); + + for (int i = 0; i < BUFFER_COUNT; ++i) + { + // a new surface for the new pixmap + // need to cast to X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit + WinPixmap pixmap = static_cast( mWinPixmaps[i] ); + contextLost = eglImpl.ReplaceSurfacePixmap( EGLNativePixmapType( pixmap ), mEglSurfaces[i] ); // reinterpret_cast does not compile + } + + // need to cast to X handle as in 64bit system ECore handle is 32 bit whereas EGLnative and XWindow are 64 bit + WinPixmap pixmap = static_cast( mWinPixmaps[mProduceBufferIndex] ); + eglImpl.MakeCurrent( EGLNativePixmapType( pixmap ), mEglSurfaces[mProduceBufferIndex] ); + + return contextLost; +} + +void PixmapRenderSurfaceEcoreWin::StartRender() +{ +} + +bool PixmapRenderSurfaceEcoreWin::PreRender( EglInterface& egl, Integration::GlAbstraction&, bool ) +{ + // Nothing to do for pixmaps + return true; +} + +void PixmapRenderSurfaceEcoreWin::PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, Dali::DisplayConnection* displayConnection, bool replacingSurface, bool resizingSurface ) +{ +} + +void PixmapRenderSurfaceEcoreWin::StopRender() +{ + ReleaseLock(); +} + +void PixmapRenderSurfaceEcoreWin::SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) +{ + mThreadSynchronization = &threadSynchronization; +} + +void PixmapRenderSurfaceEcoreWin::ReleaseLock() +{ + if( mThreadSynchronization ) + { + mThreadSynchronization->PostRenderComplete(); + } +} + +RenderSurface::Type PixmapRenderSurfaceEcoreWin::GetSurfaceType() +{ + return RenderSurface::PIXMAP_RENDER_SURFACE; +} + +void PixmapRenderSurfaceEcoreWin::CreateRenderable() +{ +} + +void PixmapRenderSurfaceEcoreWin::UseExistingRenderable( unsigned int surfaceId ) +{ +} + +unsigned int PixmapRenderSurfaceEcoreWin::GetSurfaceId( Any surface ) const +{ + return 0; +} + +} // namespace Adaptor + +} // namespace internal + +} // namespace Dali diff --git a/dali/internal/window-system/windows/pixmap-render-surface-win.h b/dali/internal/window-system/windows/pixmap-render-surface-win.h new file mode 100755 index 0000000..4ede5a4 --- /dev/null +++ b/dali/internal/window-system/windows/pixmap-render-surface-win.h @@ -0,0 +1,197 @@ +#ifndef DALI_WIN_PIXMAP_RENDER_SURFACE_H +#define DALI_WIN_PIXMAP_RENDER_SURFACE_H + +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include +#include +#include +#include + +// EXTERNAL INCLUDES +#include +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ + +/** + * Windows Pixmap implementation of render surface. + */ +class PixmapRenderSurfaceEcoreWin : public PixmapRenderSurface +{ +public: + + /** + * Uses an Windows surface to render to. + * @param [in] positionSize the position and size of the surface + * @param [in] surface can be a Win32-window or Win32-pixmap (type must be unsigned int). + * @param [in] name optional name of surface passed in + * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit + */ + PixmapRenderSurfaceEcoreWin( Dali::PositionSize positionSize, Any surface, bool isTransparent = false ); + + /** + * @brief Destructor + */ + virtual ~PixmapRenderSurfaceEcoreWin(); + +public: // from WindowRenderSurface + + /** + * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::GetSurface() + */ + virtual Any GetSurface() override; + + /** + * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::SetRenderNotification() + */ + virtual void SetRenderNotification( TriggerEventInterface* renderNotification ) override; + +public: // from Dali::RenderSurface + + /** + * @copydoc Dali::RenderSurface::GetPositionSize() + */ + virtual PositionSize GetPositionSize() const override; + + /** + * @copydoc Dali::RenderSurface::GetDpi() + */ + virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override; + + /** + * @copydoc Dali::RenderSurface::InitializeEgl() + */ + virtual void InitializeEgl( EglInterface& egl ) override; + + /** + * @copydoc Dali::RenderSurface::CreateEglSurface() + */ + virtual void CreateEglSurface( EglInterface& egl ) override; + + /** + * @copydoc Dali::RenderSurface::DestroyEglSurface() + */ + virtual void DestroyEglSurface( EglInterface& egl ) override; + + /** + * @copydoc Dali::RenderSurface::ReplaceEGLSurface() + */ + virtual bool ReplaceEGLSurface( EglInterface& egl ) override; + + /** + * @copydoc Dali::RenderSurface::MoveResize() + */ + virtual void MoveResize( Dali::PositionSize positionSize) override {} + + /** + * @copydoc Dali::RenderSurface::SetViewMode() + */ + void SetViewMode( ViewMode viewMode ) override {} + + /** + * @copydoc Dali::RenderSurface::StartRender() + */ + virtual void StartRender() override; + + /** + * @copydoc Dali::RenderSurface::PreRender() + */ + virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, bool resizingSurface ) override; + + /** + * @copydoc Dali::RenderSurface::PostRender() + */ + virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface, bool resizingSurface ); + + /** + * @copydoc Dali::RenderSurface::StopRender() + */ + virtual void StopRender() override; + + /** + * @copydoc Dali::RenderSurface::SetThreadSynchronization + */ + virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) override; + + /** + * @copydoc Dali::RenderSurface::GetSurfaceType() + */ + virtual RenderSurface::Type GetSurfaceType() override; + +private: // from PixmapRenderSurface + + /** + * @copydoc Dali::RenderSurface::ReleaseLock() + */ + virtual void ReleaseLock() override; + + /** + * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize() + */ + virtual void Initialize( Any surface ) override; + + /** + * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize() + */ + virtual void CreateRenderable() override; + + /** + * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize() + */ + virtual void UseExistingRenderable( unsigned int surfaceId ) override; + +private: + + /** + * Get the surface id if the surface parameter is not empty + * @param surface Any containing a surface id, or can be empty + * @return surface id, or zero if surface is empty + */ + unsigned int GetSurfaceId( Any surface ) const; + +private: // Data + + static const int BUFFER_COUNT = 2; + + PositionSize mPosition; ///< Position + TriggerEventInterface* mRenderNotification; ///< Render notification trigger + ColorDepth mColorDepth; ///< Color depth of surface (32 bit or 24 bit) + bool mOwnSurface; ///< Whether we own the surface (responsible for deleting it) + + int mProduceBufferIndex; + int mConsumeBufferIndex; + WinPixmap mWinPixmaps[BUFFER_COUNT]; ///< Win-Pixmap + EGLSurface mEglSurfaces[BUFFER_COUNT]; + ThreadSynchronizationInterface* mThreadSynchronization; ///< A pointer to the thread-synchronization + ConditionalWait mPixmapCondition; ///< condition to share pixmap +}; + +} // namespace Adaptor + +} // namespace internal + +} // namespace Dali + +#endif // DALI_WIN_PIXMAP_RENDER_SURFACE_H diff --git a/dali/internal/window-system/windows/platform-implement-win.cpp b/dali/internal/window-system/windows/platform-implement-win.cpp new file mode 100755 index 0000000..f122a43 --- /dev/null +++ b/dali/internal/window-system/windows/platform-implement-win.cpp @@ -0,0 +1,398 @@ +// CLASS HEADER +#include + +// EXTERNAL_HEADERS +#include +#include +#include + +using namespace std; + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +namespace WindowsPlatformImplement +{ + +HWND roothWnd = NULL; + +void RunLoop() +{ + MSG nMsg = { 0 }; + + while( GetMessage( &nMsg, 0, NULL, NULL ) ) + { + TranslateMessage( &nMsg ); + DispatchMessage( &nMsg ); + +#ifdef _WIN32 + //::Sleep( 20 ); +#endif + + if( WM_CLOSE == nMsg.message ) + { + break; + } + } +} + +void SetParent(long child, long parent) +{ + if (roothWnd == (HWND)child && NULL != (HWND)parent) + { + roothWnd = (HWND)parent; + } + + ::SetParent((HWND)child, (HWND)parent); +} + +#define INCH 25.4 + +void GetDPI(float &xDpi, float &yDpi) +{ + HDC hdcScreen = GetDC(roothWnd); + + int iX = GetDeviceCaps( hdcScreen, HORZRES ); // pixel + int iY = GetDeviceCaps( hdcScreen, VERTRES ); // pixel + int iPhsX = GetDeviceCaps( hdcScreen, HORZSIZE ); // mm + int iPhsY = GetDeviceCaps( hdcScreen, VERTSIZE ); // mm + + xDpi = (float)iX / (float)iPhsX * INCH; + yDpi = (float)iY / (float)iPhsY * INCH; +} + +map> callbackMap; +set listenerSet; + +LRESULT CALLBACK WinProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + for( set::iterator x = listenerSet.begin(); x != listenerSet.end(); ++x ) + { + ( *x )( (long)hWnd, (long)uMsg, (long)wParam, (long)lParam ); + } + + { + map>::iterator x = callbackMap.find( uMsg ); + + if( callbackMap.end() != x ) + { + set &cbSet = x->second; + for( set::iterator y = cbSet.begin(); cbSet.end() != y; ++y ) + { + Dali::CallbackBase::Execute(**y); + } + } + } + + LRESULT ret = DefWindowProc( hWnd, uMsg, wParam, lParam ); + return ret; +} + +DWORD windowStyle = WS_OVERLAPPED; + +int GetEdgeWidth() +{ + switch( windowStyle ) + { + case WS_OVERLAPPED: + return 8; + break; + + default: + return 0; + break; + } +} + +int GetEdgeHeight() +{ + switch( windowStyle ) + { + case WS_OVERLAPPED: + return 18; + break; + + default: + return 0; + break; + } +} + +long CreateHwnd( + _In_opt_ const char *lpClassName, + _In_opt_ const char *lpWindowName, + _In_ int X, + _In_ int Y, + _In_ int nWidth, + _In_ int nHeight, + _In_opt_ long parent) +{ + WNDCLASS cs = { 0 }; + cs.cbClsExtra = 0; + cs.cbWndExtra = 0; + cs.hbrBackground = (HBRUSH)( COLOR_WINDOW + 2 ); + cs.hCursor = NULL; + cs.hIcon = NULL; + cs.hInstance = GetModuleHandle( NULL ); + cs.lpfnWndProc = (WNDPROC)WinProc; + cs.lpszClassName = lpClassName; + cs.lpszMenuName = NULL; + cs.style = CS_VREDRAW | CS_HREDRAW; + RegisterClass( &cs );//ʵÏÖ×¢²á´°¿Ú + + HWND hWnd = CreateWindow( lpClassName, lpWindowName, windowStyle, X, Y, nWidth + 2 * GetEdgeWidth(), nHeight + 2 * GetEdgeHeight(), NULL, NULL, cs.hInstance, NULL ); + ShowWindow( hWnd, SW_SHOW ); + + if( hWnd != roothWnd ) + { + roothWnd = hWnd; + } + + return (long)hWnd; +} + +void AddListener(winEventCallback callback) +{ + listenerSet.insert(callback); +} + +void AddListener( int msgType, Dali::CallbackBase *callback ) +{ + map>::iterator x = callbackMap.find( msgType ); + if( callbackMap.end() == x ) + { + set callbackSet; + callbackSet.insert( callback ); + + callbackMap.insert( make_pair( msgType, callbackSet ) ); + } + else + { + set &callbackSet = x->second; + set::iterator y = callbackSet.find( callback ); + if( callbackSet.end() == y ) + { + callbackSet.insert( callback ); + } + } +} + +void RemoveListener(int msgType) +{ + callbackMap.erase(msgType); +} + +bool PostWinMessage( + _In_ unsigned int Msg, + _In_ long wParam, + _In_ long lParam, + _In_ long hWnd/* = 0*/) +{ + if( 0 == hWnd ) + { + return (bool)PostMessage( roothWnd, Msg, wParam, lParam ); + } + else + { + return (bool)PostMessage( (HWND)hWnd, Msg, wParam, lParam ); + } +} + +void ShowWindow(long hWnd) +{ + ::ShowWindow((HWND)hWnd, SW_SHOW); +} + +void HideWindow(long hWnd) +{ + ::ShowWindow((HWND)hWnd, SW_HIDE); +} + +long CreateWinSemaphore(_In_ long lInitialCount, _In_ long lMaximumCount) +{ + return (long)::CreateSemaphore(NULL, lInitialCount, lMaximumCount, NULL); +} + +unsigned long WaitForSingleObject(_In_ long hHandle, _In_ unsigned long dwMilliseconds) +{ + return ::WaitForSingleObject((HWND)hHandle, dwMilliseconds); +} + +bool ReleaseSemaphore(_In_ long hSemaphore, _In_ long lReleaseCount, _Out_opt_ long *lpPreviousCount) +{ + return ::ReleaseSemaphore((HWND)hSemaphore, lReleaseCount, lpPreviousCount); +} + +struct TTimerCallbackInfo +{ + void *data; + timerCallback callback; +}; + +map mapTimerIDToData; + +void CALLBACK TimerProc(HWND hWnd, UINT nMsg, UINT_PTR nTimerid, DWORD dwTime) +{ + map::iterator x = mapTimerIDToData.find( nTimerid ); + + if( mapTimerIDToData.end() == x ) + { + return; + } + + TTimerCallbackInfo &info = x->second; + + info.callback( info.data ); +} + +int SetTimer(int interval, timerCallback callback, void *data) +{ + int timerID = 0; + + for( map::iterator x = mapTimerIDToData.begin(); mapTimerIDToData.end() != x; ++x ) + { + int id = x->first; + + if( timerID < id ) + { + break; + } + else + { + timerID++; + } + } + + TTimerCallbackInfo callbackInfo; + callbackInfo.data = data; + callbackInfo.callback = callback; + + mapTimerIDToData.insert( make_pair( timerID, callbackInfo ) ); + + ::SetTimer( roothWnd, timerID, interval, TimerProc ); + + return timerID; +} + +void KillTimer(int id) +{ + mapTimerIDToData.erase(id); + ::KillTimer(roothWnd, id); +} + +const char* GetKeyName( int keyCode ) +{ + switch( keyCode ) + { + case VK_BACK: + return "Backspace"; + + case VK_TAB: + return "Tab"; + + case VK_RETURN: + return "Return"; + + case VK_ESCAPE: + return "Escape"; + + case VK_SPACE: + return "space"; + + case VK_LEFT: + return "Left"; + + case VK_UP: + return "Up"; + + case VK_RIGHT: + return "Right"; + + case VK_DOWN: + return "Down"; + + case 48: + return "0"; + + case 49: + return "1"; + + case 50: + return "2"; + + case 51: + return "3"; + + case 52: + return "4"; + + case 53: + return "5"; + + case 54: + return "6"; + + case 55: + return "7"; + + case 56: + return "8"; + + case 57: + return "9"; + + break; + } + + return ""; +} + +static LARGE_INTEGER _cpuFrequency; +static LARGE_INTEGER *_pCpuFrequency = NULL; + +long GetCurrentThreadId() +{ + return ::GetCurrentThreadId(); +} + +void GetNanoseconds( uint64_t& timeInNanoseconds ) +{ + if( NULL == _pCpuFrequency ) + { + _pCpuFrequency = &_cpuFrequency; + QueryPerformanceFrequency( _pCpuFrequency ); + } + + LARGE_INTEGER curTime; + QueryPerformanceCounter( &curTime ); + + timeInNanoseconds = (double)curTime.QuadPart / (double)_pCpuFrequency->QuadPart * 1000000000; +} + +unsigned int GetCurrentMilliSeconds( void ) +{ + if( NULL == _pCpuFrequency ) + { + _pCpuFrequency = &_cpuFrequency; + QueryPerformanceFrequency( _pCpuFrequency ); + } + + LARGE_INTEGER curTime; + QueryPerformanceCounter( &curTime ); + + return curTime.QuadPart * 1000 / _pCpuFrequency->QuadPart; +} + +} // namespace WindowsPlatformImplement + +} // namespace Adaptor + +} // namespace internal + +} // namespace Dali diff --git a/dali/internal/window-system/windows/platform-implement-win.h b/dali/internal/window-system/windows/platform-implement-win.h new file mode 100755 index 0000000..383d9a2 --- /dev/null +++ b/dali/internal/window-system/windows/platform-implement-win.h @@ -0,0 +1,104 @@ +#ifndef PLATFORM_IMPLEMENT_WIN_INCLUDE +#define PLATFORM_IMPLEMENT_WIN_INCLUDE + +/* +* Copyright (c) 2018 Samsung Electronics Co., Ltd. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +// EXTERNAL_HEADERS +#include +#include + +typedef bool Eina_Bool; + +typedef unsigned int winWindow; +typedef unsigned int Win_Window_Handle; +typedef unsigned int WinPixmap; + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +namespace WindowsPlatformImplement +{ + +void RunLoop(); + +void SetParent(long child, long parent); + +int GetEdgeHeight(); + +long CreateHwnd( + _In_opt_ const char *lpClassName, + _In_opt_ const char *lpWindowName, + _In_ int X, + _In_ int Y, + _In_ int nWidth, + _In_ int nHeight, + _In_opt_ long parent); + +typedef void (*winEventCallback)(long hWnd, unsigned int uMsg, long wParam, long lParam); + +void RemoveListener(int msgType); + +void AddListener( winEventCallback callback ); +void AddListener( int msgType, Dali::CallbackBase *callback ); + +bool PostWinMessage( + _In_ unsigned int Msg, + _In_ long wParam, + _In_ long lParam, + _In_ long hWnd = 0); + +void ShowWindow(long hWnd); +void HideWindow(long hWnd); + +long CreateWinSemaphore(_In_ long lInitialCount, _In_ long lMaximumCount); + +unsigned long WaitForSingleObject(_In_ long hHandle, _In_ unsigned long dwMilliseconds); + +bool ReleaseSemaphore(_In_ long hSemaphore, _In_ long lReleaseCount, _Out_opt_ long *lpPreviousCount); + +typedef void(*timerCallback)(void *data); + +int SetTimer(int interval, timerCallback callback, void *data); + +void KillTimer(int id); + +void GetDPI( float &xDpi, float &yDpi ); + +const char* GetKeyName( int keyCode ); + +long GetCurrentThreadId(); + +void GetNanoseconds( uint64_t& timeInNanoseconds ); + +unsigned int GetCurrentMilliSeconds( void ); + +} // namespace WindowsPlatformImplement + +} // namespace Adaptor + +} // namespace internal + +} // namespace Dali + +#endif // WIN32_WINDOWS_SYSTEM_INCLUDE diff --git a/dali/internal/window-system/windows/render-surface-factory-win.cpp b/dali/internal/window-system/windows/render-surface-factory-win.cpp new file mode 100755 index 0000000..0936c09 --- /dev/null +++ b/dali/internal/window-system/windows/render-surface-factory-win.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// INTERNAL HEADERS +#include +#include +#include +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ + +std::unique_ptr< WindowRenderSurface > RenderSurfaceFactoryWin::CreateWindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent ) +{ + return Utils::MakeUnique< WindowRenderSurface >( positionSize, surface, isTransparent ); +} + +std::unique_ptr< PixmapRenderSurface > RenderSurfaceFactoryWin::CreatePixmapRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent ) +{ + return Utils::MakeUnique< PixmapRenderSurfaceEcoreWin >( positionSize, surface, isTransparent ); +} + +std::unique_ptr< NativeRenderSurface > RenderSurfaceFactoryWin::CreateNativeRenderSurface( Dali::PositionSize positionSize, bool isTransparent ) +{ + return std::unique_ptr< NativeRenderSurface >( nullptr ); +} + +// this should be created from somewhere +std::unique_ptr< RenderSurfaceFactory > GetRenderSurfaceFactory() +{ + // returns Window factory + return Utils::MakeUnique< RenderSurfaceFactoryWin >(); +} + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali diff --git a/dali/internal/window-system/windows/render-surface-factory-win.h b/dali/internal/window-system/windows/render-surface-factory-win.h new file mode 100755 index 0000000..969f2b5 --- /dev/null +++ b/dali/internal/window-system/windows/render-surface-factory-win.h @@ -0,0 +1,44 @@ +#ifndef DALI_INTERNAL_WINDOWSYSTEM_WIN_RENDER_SURFACE_FACTORY_WIN_H +#define DALI_INTERNAL_WINDOWSYSTEM_WIN_RENDER_SURFACE_FACTORY_ECORE_ + +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ + +class RenderSurfaceFactoryWin : public RenderSurfaceFactory +{ +public: + std::unique_ptr< WindowRenderSurface > CreateWindowRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false ) override; + + std::unique_ptr< PixmapRenderSurface > CreatePixmapRenderSurface( Dali::PositionSize positionSize, Any surface, bool isTransparent = false ) override; + + std::unique_ptr< NativeRenderSurface > CreateNativeRenderSurface( Dali::PositionSize positionSize, bool isTransparent = false ) override; +}; + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali + +#endif // DALI_INTERNAL_WINDOWSYSTEM_WIN_RENDER_SURFACE_FACTORY_WIN_H diff --git a/dali/internal/window-system/windows/window-base-win.cpp b/dali/internal/window-system/windows/window-base-win.cpp new file mode 100755 index 0000000..98926f1 --- /dev/null +++ b/dali/internal/window-system/windows/window-base-win.cpp @@ -0,0 +1,904 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// INTERNAL HEADERS +#include +#include + +// EXTERNAL_HEADERS +#include +#include + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +namespace +{ + +const std::string DEFAULT_DEVICE_NAME = ""; +const Device::Class::Type DEFAULT_DEVICE_CLASS = Device::Class::NONE; +const Device::Subclass::Type DEFAULT_DEVICE_SUBCLASS = Device::Subclass::NONE; + +const unsigned int PRIMARY_TOUCH_BUTTON_ID( 1 ); + +#if defined(DEBUG_ENABLED) +Debug::Filter* gWindowBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_WINDOW_BASE" ); +#endif + +static bool EcoreEventWindowPropertyChanged( void* data, int type, TWinEventInfo *event ) +{ + WindowBaseWin* windowBase = static_cast< WindowBaseWin* >( data ); + if( windowBase ) + { + return windowBase->OnWindowPropertyChanged( data, type, event ); + } + + return true; +} + +/** + * Called when the window gains focus. + */ +static bool EcoreEventWindowFocusIn( void* data, int type, TWinEventInfo *event ) +{ + WindowBaseWin* windowBase = static_cast< WindowBaseWin* >( data ); + if( windowBase ) + { + windowBase->OnFocusIn( data, type, event ); + } + return true; +} + +/** + * Called when the window loses focus. + */ +static bool EcoreEventWindowFocusOut( void* data, int type, TWinEventInfo *event ) +{ + WindowBaseWin* windowBase = static_cast< WindowBaseWin* >( data ); + if( windowBase ) + { + windowBase->OnFocusOut( data, type, event ); + } + return true; +} + +/** + * Called when the window is damaged. + */ +static bool EcoreEventWindowDamaged( void* data, int type, TWinEventInfo *event ) +{ + WindowBaseWin* windowBase = static_cast< WindowBaseWin* >( data ); + if( windowBase ) + { + windowBase->OnWindowDamaged( data, type, event ); + } + + return true; +} + +///////////////////////////////////////////////////////////////////////////////////////////////// +// Selection Callbacks +///////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * Called when the source window notifies us the content in clipboard is selected. + */ +static bool EcoreEventSelectionClear( void* data, int type, TWinEventInfo *event ) +{ + WindowBaseWin* windowBase = static_cast< WindowBaseWin* >( data ); + if( windowBase ) + { + windowBase->OnSelectionClear( data, type, event ); + } + return true; +} + +/** + * Called when the source window sends us about the selected content. + * For example, when dragged items are dragged INTO our window or when items are selected in the clipboard. + */ +static bool EcoreEventSelectionNotify( void* data, int type, TWinEventInfo *event ) +{ + WindowBaseWin* windowBase = static_cast< WindowBaseWin* >( data ); + if( windowBase ) + { + windowBase->OnSelectionNotify( data, type, event ); + } + return true; +} + +///////////////////////////////////////////////////////////////////////////////////////////////// +// Touch Callbacks +///////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * Called when a touch down is received. + */ +static bool EcoreEventMouseButtonDown( void* data, int type, TWinEventInfo *event ) +{ + WindowBaseWin* windowBase = static_cast< WindowBaseWin* >( data ); + if( windowBase ) + { + windowBase->OnMouseButtonDown( data, type, event ); + } + return true; +} + +/** + * Called when a touch up is received. + */ +static bool EcoreEventMouseButtonUp( void* data, int type, TWinEventInfo *event ) +{ + WindowBaseWin* windowBase = static_cast< WindowBaseWin* >( data ); + if( windowBase ) + { + windowBase->OnMouseButtonUp( data, type, event ); + } + return true; +} + +/** + * Called when a touch motion is received. + */ +static bool EcoreEventMouseButtonMove( void* data, int type, TWinEventInfo *event ) +{ + WindowBaseWin* windowBase = static_cast< WindowBaseWin* >( data ); + if( windowBase ) + { + windowBase->OnMouseButtonMove( data, type, event ); + } + return true; +} + +///////////////////////////////////////////////////////////////////////////////////////////////// +// Wheel Callbacks +///////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * Called when a mouse wheel is received. + */ +static bool EcoreEventMouseWheel( void* data, int type, TWinEventInfo *event ) +{ + WindowBaseWin* windowBase = static_cast< WindowBaseWin* >( data ); + if( windowBase ) + { + windowBase->OnMouseWheel( data, type, event ); + } + return true; +} + +///////////////////////////////////////////////////////////////////////////////////////////////// +// Key Callbacks +///////////////////////////////////////////////////////////////////////////////////////////////// + +/** + * Called when a key down is received. + */ +static bool EcoreEventKeyDown( void* data, int type, TWinEventInfo *event ) +{ + WindowBaseWin* windowBase = static_cast< WindowBaseWin* >( data ); + if( windowBase ) + { + windowBase->OnKeyDown( data, type, event ); + } + return true; +} + +/** + * Called when a key up is received. + */ +static bool EcoreEventKeyUp( void* data, int type, TWinEventInfo *event ) +{ + WindowBaseWin* windowBase = static_cast< WindowBaseWin* >( data ); + if( windowBase ) + { + windowBase->OnKeyUp( data, type, event ); + } + return true; +} +} // unnamed namespace + +WindowBaseWin::WindowBaseWin( Dali::PositionSize positionSize, Any surface, bool isTransparent ) +: mEventHandler(), + mWin32Window( 0 ), + mOwnSurface( false ), + mIsTransparent( false ), // Should only be set to true once we actually create a transparent window regardless of what isTransparent is. + mRotationAppSet( false ) +{ + Initialize( positionSize, surface, isTransparent ); +} + +WindowBaseWin::~WindowBaseWin() +{ + for( Dali::Vector< Event_Handler >::Iterator iter = mEventHandler.Begin(), endIter = mEventHandler.End(); iter != endIter; ++iter ) + { + event_handler_del( *iter ); + } + mEventHandler.Clear(); + + WindowsPlatformImplement::PostWinMessage( WM_CLOSE, 0, 0, mWin32Window ); +} + +static void EventEntry( long hWnd, unsigned int uMsg, long wParam, long lParam ) +{ + EventCallback callback = GetCallback( uMsg ); + EventHandler *handler = (EventHandler*)GetEventHandler( uMsg ); + + if( NULL != callback ) + { + //EventHandler *handler = new EventHandler(); + TWinEventInfo eventInfo( hWnd, uMsg, wParam, lParam ); + callback( handler, uMsg, &eventInfo ); + } +} + +void WindowBaseWin::Initialize( PositionSize positionSize, Any surface, bool isTransparent ) +{ + // see if there is a surface in Any surface + unsigned int surfaceId = GetSurfaceId( surface ); + + // if the surface is empty, create a new one. + if( surfaceId == 0 ) + { + // we own the surface about to created + mOwnSurface = true; + CreateWinWindow( positionSize, isTransparent ); + } + else + { + // XLib should already be initialized so no point in calling XInitThreads + mWin32Window = static_cast< Win_Window_Handle >( surfaceId ); + } + + // Register window focus events + mEventHandler.PushBack( event_handler_add( WIN_EVENT_WINDOW_FOCUS_IN, EcoreEventWindowFocusIn, this ) ); + mEventHandler.PushBack( event_handler_add( WIN_EVENT_WINDOW_FOCUS_OUT, EcoreEventWindowFocusOut, this ) ); + + // Register Window damage events + mEventHandler.PushBack( event_handler_add( WIN_EVENT_WINDOW_DAMAGE, EcoreEventWindowDamaged, this ) ); + + // Register Touch events + mEventHandler.PushBack( event_handler_add( EVENT_MOUSE_BUTTON_DOWN, EcoreEventMouseButtonDown, this ) ); + mEventHandler.PushBack( event_handler_add( EVENT_MOUSE_BUTTON_UP, EcoreEventMouseButtonUp, this ) ); + mEventHandler.PushBack( event_handler_add( EVENT_MOUSE_MOVE, EcoreEventMouseButtonMove, this ) ); + mEventHandler.PushBack( event_handler_add( EVENT_MOUSE_OUT, EcoreEventMouseButtonUp, this ) ); // process mouse out event like up event + + // Register Mouse wheel events + mEventHandler.PushBack( event_handler_add( EVENT_MOUSE_WHEEL, EcoreEventMouseWheel, this ) ); + + // Register Key events + mEventHandler.PushBack( event_handler_add( EVENT_KEY_DOWN, EcoreEventKeyDown, this ) ); + mEventHandler.PushBack( event_handler_add( EVENT_KEY_UP, EcoreEventKeyUp, this ) ); + + // Register Selection event + mEventHandler.PushBack( event_handler_add( WIN_EVENT_SELECTION_CLEAR, EcoreEventSelectionClear, this ) ); + mEventHandler.PushBack( event_handler_add( WIN_EVENT_SELECTION_NOTIFY, EcoreEventSelectionNotify, this ) ); + + WindowsPlatformImplement::AddListener( EventEntry ); +} + +bool WindowBaseWin::OnWindowPropertyChanged( void* data, int type, TWinEventInfo *event ) +{ + //Ecore_X_Event_Window_Property* propertyChangedEvent = static_cast< Ecore_X_Event_Window_Property* >( event ); + //bool handled( true ); + + //if( propertyChangedEvent->win == mWin32Window ) + //{ + // Ecore_X_Window_State_Hint state( ecore_x_icccm_state_get( propertyChangedEvent->win ) ); + + // switch( state ) + // { + // case ECORE_X_WINDOW_STATE_HINT_WITHDRAWN: + // { + // // Window was hidden. + // mWindow->OnIconifyChanged( true ); + // DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%d) Withdrawn\n", mWindow ); + // handled = ECORE_CALLBACK_DONE; + // break; + // } + // case ECORE_X_WINDOW_STATE_HINT_ICONIC: + // { + // // Window was iconified (minimised). + // mWindow->OnIconifyChanged( true ); + // DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%d) Iconfied\n", mWindow ); + // handled = ECORE_CALLBACK_DONE; + // break; + // } + // case ECORE_X_WINDOW_STATE_HINT_NORMAL: + // { + // // Window was shown. + // mWindow->OnIconifyChanged( false ); + // DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window (%d) Shown\n", mWindow ); + // handled = ECORE_CALLBACK_DONE; + // break; + // } + // default: + // { + // // Ignore + // break; + // } + // } + //} + + //return handled; + return true; +} + +void WindowBaseWin::OnDeleteRequest() +{ + mDeleteRequestSignal.Emit(); +} + +void WindowBaseWin::OnFocusIn( void* data, int type, TWinEventInfo *event ) +{ + //Ecore_X_Event_Window_Focus_In* focusInEvent = static_cast< Ecore_X_Event_Window_Focus_In* >( event ); + + //if( focusInEvent->win == mWin32Window ) + //{ + // DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusIn\n" ); + + // mFocusChangedSignal.Emit( true ); + //} +} + +void WindowBaseWin::OnFocusOut( void* data, int type, TWinEventInfo *event ) +{ + //Ecore_X_Event_Window_Focus_Out* focusOutEvent = static_cast< Ecore_X_Event_Window_Focus_Out* >( event ); + + //// If the window loses focus then hide the keyboard. + //if( focusOutEvent->win == mWin32Window ) + //{ + // DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "Window EcoreEventWindowFocusOut\n" ); + + // mFocusChangedSignal.Emit( false ); + //} +} + +void WindowBaseWin::OnWindowDamaged( void* data, int type, TWinEventInfo *event ) +{ + Event_Mouse_Button* windowDamagedEvent( (Event_Mouse_Button*)event ); + EventHandler* handler( (EventHandler*)data ); + + if( windowDamagedEvent->window == mWin32Window ) + { + DamageArea area; + area.x = 0; + area.y = 0; + area.width = 480; + area.height = 800; + + //handler->SendEvent( area ); + mWindowDamagedSignal.Emit( area ); + } +} + +void WindowBaseWin::OnMouseButtonDown( void* data, int type, TWinEventInfo *event ) +{ + Event_Mouse_Button touchEvent = *((Event_Mouse_Button*)event); + touchEvent.x = LOWORD( event->lParam ); + touchEvent.y = HIWORD( event->lParam ); + touchEvent.multi.device = DEVICE_MOUSE; + + if( touchEvent.window == mWin32Window ) + { + PointState::Type state ( PointState::DOWN ); + + // Check if the buttons field is set and ensure it's the primary touch button. + // If this event was triggered by buttons other than the primary button (used for touch), then + // just send an interrupted event to Core. + if( touchEvent.buttons && ( touchEvent.buttons != PRIMARY_TOUCH_BUTTON_ID ) ) + { + state = PointState::INTERRUPTED; + } + + Integration::Point point; + point.SetDeviceId( touchEvent.multi.device ); + point.SetState( state ); + point.SetScreenPosition( Vector2( touchEvent.x, touchEvent.y + WindowsPlatformImplement::GetEdgeHeight() ) ); + point.SetRadius( touchEvent.multi.radius, Vector2( touchEvent.multi.radius_x, touchEvent.multi.radius_y ) ); + point.SetPressure( touchEvent.multi.pressure ); + point.SetAngle( Degree( touchEvent.multi.angle ) ); + + mTouchEventSignal.Emit( point, touchEvent.timestamp ); + } +} + +void WindowBaseWin::OnMouseButtonUp( void* data, int type, TWinEventInfo *event ) +{ + Event_Mouse_Button touchEvent = *( (Event_Mouse_Button*)event ); + touchEvent.x = LOWORD( event->lParam ); + touchEvent.y = HIWORD( event->lParam ); + touchEvent.multi.device = DEVICE_MOUSE; + + if( touchEvent.window == mWin32Window ) + { + PointState::Type state( PointState::UP ); + + // Check if the buttons field is set and ensure it's the primary touch button. + // If this event was triggered by buttons other than the primary button (used for touch), then + // just send an interrupted event to Core. + if( touchEvent.buttons && ( touchEvent.buttons != PRIMARY_TOUCH_BUTTON_ID ) ) + { + state = PointState::INTERRUPTED; + } + + Integration::Point point; + point.SetDeviceId( touchEvent.multi.device ); + point.SetState( state ); + point.SetScreenPosition( Vector2( touchEvent.x, touchEvent.y + WindowsPlatformImplement::GetEdgeHeight() ) ); + point.SetRadius( touchEvent.multi.radius, Vector2( touchEvent.multi.radius_x, touchEvent.multi.radius_y ) ); + point.SetPressure( touchEvent.multi.pressure ); + point.SetAngle( Degree( touchEvent.multi.angle ) ); + + mTouchEventSignal.Emit( point, touchEvent.timestamp ); + } +} + +void WindowBaseWin::OnMouseButtonMove( void* data, int type, TWinEventInfo *event ) +{ + Event_Mouse_Button touchEvent = *((Event_Mouse_Button*)event); + touchEvent.timestamp = GetTickCount(); + touchEvent.x = LOWORD( event->lParam ); + touchEvent.y = HIWORD( event->lParam ); + touchEvent.multi.device = DEVICE_MOUSE; + + if( touchEvent.window == mWin32Window ) + { + PointState::Type state( PointState::MOTION ); + + // Check if the buttons field is set and ensure it's the primary touch button. + // If this event was triggered by buttons other than the primary button (used for touch), then + // just send an interrupted event to Core. + if( touchEvent.buttons && ( touchEvent.buttons != PRIMARY_TOUCH_BUTTON_ID ) ) + { + state = PointState::INTERRUPTED; + } + + Integration::Point point; + point.SetDeviceId( touchEvent.multi.device ); + point.SetState( state ); + point.SetScreenPosition( Vector2( touchEvent.x, touchEvent.y + WindowsPlatformImplement::GetEdgeHeight() ) ); + point.SetRadius( touchEvent.multi.radius, Vector2( touchEvent.multi.radius_x, touchEvent.multi.radius_y ) ); + point.SetPressure( touchEvent.multi.pressure ); + point.SetAngle( Degree( touchEvent.multi.angle ) ); + + mTouchEventSignal.Emit( point, touchEvent.timestamp ); + } +} + +void WindowBaseWin::OnMouseWheel( void* data, int type, TWinEventInfo *event ) +{ + Event_Mouse_Wheel mouseWheelEvent = *((Event_Mouse_Wheel*)( event )); + + if( mouseWheelEvent.window == mWin32Window ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseWin::OnMouseWheel: direction: %d, modifiers: %d, x: %d, y: %d, z: %d\n", mouseWheelEvent.direction, mouseWheelEvent.modifiers, mouseWheelEvent.x, mouseWheelEvent.y, mouseWheelEvent.z ); + + WheelEvent wheelEvent( WheelEvent::MOUSE_WHEEL, mouseWheelEvent.direction, mouseWheelEvent.modifiers, Vector2( mouseWheelEvent.x, mouseWheelEvent.y ), mouseWheelEvent.z, mouseWheelEvent.timestamp ); + + mWheelEventSignal.Emit( wheelEvent ); + } +} + +void WindowBaseWin::OnKeyDown( void* data, int type, TWinEventInfo *event ) +{ + if( event->mWindow == mWin32Window ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseWin::OnKeyDown\n" ); + + int keyCode = event->wParam; + std::string keyName( WindowsPlatformImplement::GetKeyName( keyCode ) ); + std::string keyString( "" ); + std::string compose( "" ); + + int modifier( 0 ); + unsigned long time( 0 ); + + // Ensure key event string is not NULL as keys like SHIFT have a null string. + keyString.push_back( event->wParam ); + + Integration::KeyEvent keyEvent( keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Down, compose, DEFAULT_DEVICE_NAME, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS ); + + mKeyEventSignal.Emit( keyEvent ); + } +} + +void WindowBaseWin::OnKeyUp( void* data, int type, TWinEventInfo *event ) +{ + if( event->mWindow == mWin32Window ) + { + DALI_LOG_INFO( gWindowBaseLogFilter, Debug::General, "WindowBaseWin::OnKeyDown\n" ); + + int keyCode = event->wParam; + std::string keyName( WindowsPlatformImplement::GetKeyName( keyCode ) ); + std::string keyString( "" ); + std::string compose( "" ); + + int modifier( 0 ); + unsigned long time( 0 ); + + // Ensure key event string is not NULL as keys like SHIFT have a null string. + keyString.push_back( event->wParam ); + + Integration::KeyEvent keyEvent( keyName, keyString, keyCode, modifier, time, Integration::KeyEvent::Up, compose, DEFAULT_DEVICE_NAME, DEFAULT_DEVICE_CLASS, DEFAULT_DEVICE_SUBCLASS ); + + mKeyEventSignal.Emit( keyEvent ); + } +} + +void WindowBaseWin::OnSelectionClear( void* data, int type, TWinEventInfo *event ) +{ + //Ecore_X_Event_Selection_Clear* selectionClearEvent = static_cast< Ecore_X_Event_Selection_Clear* >( event ); + + //if( selectionClearEvent->win == mWin32Window ) + //{ + // DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, " WindowBaseWin::OnSelectionClear\n" ); + + // if( selectionClearEvent->selection == ECORE_X_SELECTION_SECONDARY ) + // { + // // Request to get the content from Ecore. + // ecore_x_selection_secondary_request( selectionClearEvent->win, ECORE_X_SELECTION_TARGET_TEXT ); + // } + //} +} + +void WindowBaseWin::OnSelectionNotify( void* data, int type, TWinEventInfo *event ) +{ + //Ecore_X_Event_Selection_Notify* selectionNotifyEvent = static_cast< Ecore_X_Event_Selection_Notify* >( event ); + + //if( selectionNotifyEvent->win == mWin32Window ) + //{ + // DALI_LOG_INFO( gWindowBaseLogFilter, Debug::Concise, " WindowBaseWin::OnSelectionNotify\n" ); + + // Ecore_X_Selection_Data* selectionData = static_cast< Ecore_X_Selection_Data* >( selectionNotifyEvent->data ); + // if( selectionData->data ) + // { + // if( selectionNotifyEvent->selection == ECORE_X_SELECTION_SECONDARY ) + // { + // mSelectionDataReceivedSignal.Emit( event ); + // } + // } + //} +} + +Any WindowBaseWin::GetNativeWindow() +{ + return mWin32Window; +} + +int WindowBaseWin::GetNativeWindowId() +{ + return mWin32Window; +} + +EGLNativeWindowType WindowBaseWin::CreateEglWindow( int width, int height ) +{ + return reinterpret_cast< EGLNativeWindowType >( mWin32Window ); +} + +void WindowBaseWin::DestroyEglWindow() +{ +} + +void WindowBaseWin::SetEglWindowRotation( int angle ) +{ +} + +void WindowBaseWin::SetEglWindowBufferTransform( int angle ) +{ +} + +void WindowBaseWin::SetEglWindowTransform( int angle ) +{ +} + +void WindowBaseWin::ResizeEglWindow( PositionSize positionSize ) +{ +} + +bool WindowBaseWin::IsEglWindowRotationSupported() +{ + return false; +} + +void WindowBaseWin::Move( PositionSize positionSize ) +{ + //ecore_x_window_move( mWin32Window, positionSize.x, positionSize.y ); +} + +void WindowBaseWin::Resize( PositionSize positionSize ) +{ + //ecore_x_window_resize( mWin32Window, positionSize.width, positionSize.height ); +} + +void WindowBaseWin::MoveResize( PositionSize positionSize ) +{ + //ecore_x_window_move_resize( mWin32Window, positionSize.x, positionSize.y, positionSize.width, positionSize.height ); +} + +void WindowBaseWin::ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode, Dali::Window::IndicatorBgOpacity opacityMode ) +{ +// DALI_LOG_TRACE_METHOD_FMT( gWindowBaseLogFilter, "visible : %d\n", visibleMode ); +// +// if( visibleMode == Dali::Window::VISIBLE ) +// { +// // when the indicator is visible, set proper mode for indicator server according to bg mode +// if( opacityMode == Dali::Window::OPAQUE ) +// { +// ecore_x_e_illume_indicator_opacity_set( mWin32Window, ECORE_X_ILLUME_INDICATOR_OPAQUE ); +// } +// else if( opacityMode == Dali::Window::TRANSLUCENT ) +// { +// ecore_x_e_illume_indicator_opacity_set( mWin32Window, ECORE_X_ILLUME_INDICATOR_TRANSLUCENT ); +// } +//#if defined (DALI_PROFILE_MOBILE) +// else if( opacityMode == Dali::Window::TRANSPARENT ) +// { +// ecore_x_e_illume_indicator_opacity_set( mWin32Window, ECORE_X_ILLUME_INDICATOR_OPAQUE ); +// } +//#endif +// } +// else +// { +// // when the indicator is not visible, set TRANSPARENT mode for indicator server +// ecore_x_e_illume_indicator_opacity_set( mWin32Window, ECORE_X_ILLUME_INDICATOR_TRANSPARENT ); // it means hidden indicator +// } +} + +void WindowBaseWin::SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation ) +{ + /*int show_state = static_cast< int >( isShow ); + ecore_x_window_prop_property_set( mWin32Window, ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE, + ECORE_X_ATOM_CARDINAL, 32, &show_state, 1 ); + + if( isShow ) + { + ecore_x_e_illume_indicator_state_set( mWin32Window, ECORE_X_ILLUME_INDICATOR_STATE_ON ); + } + else + { + ecore_x_e_illume_indicator_state_set( mWin32Window, ECORE_X_ILLUME_INDICATOR_STATE_OFF ); + }*/ +} + +void WindowBaseWin::IndicatorTypeChanged( IndicatorInterface::Type type ) +{ +} + +void WindowBaseWin::SetClass( const std::string& name, const std::string& className ) +{ + //ecore_x_icccm_name_class_set( mWin32Window, name.c_str(), className.c_str() ); +} + +void WindowBaseWin::Raise() +{ + //ecore_x_window_raise( mWin32Window ); +} + +void WindowBaseWin::Lower() +{ + //ecore_x_window_lower( mWin32Window ); +} + +void WindowBaseWin::Activate() +{ + //ecore_x_netwm_client_active_request( ecore_x_window_root_get( mWin32Window ), mWin32Window, 1 /* request type, 1:application, 2:pager */, 0 ); +} + +void WindowBaseWin::SetAvailableOrientations( const std::vector< Dali::Window::WindowOrientation >& orientations ) +{ +} + +void WindowBaseWin::SetPreferredOrientation( Dali::Window::WindowOrientation orientation ) +{ +} + +void WindowBaseWin::SetAcceptFocus( bool accept ) +{ +} + +void WindowBaseWin::Show() +{ + //ecore_x_window_show( mWin32Window ); +} + +void WindowBaseWin::Hide() +{ + //ecore_x_window_hide( mWin32Window ); +} + +unsigned int WindowBaseWin::GetSupportedAuxiliaryHintCount() const +{ + return 0; +} + +std::string WindowBaseWin::GetSupportedAuxiliaryHint( unsigned int index ) const +{ + return std::string(); +} + +unsigned int WindowBaseWin::AddAuxiliaryHint( const std::string& hint, const std::string& value ) +{ + return 0; +} + +bool WindowBaseWin::RemoveAuxiliaryHint( unsigned int id ) +{ + return false; +} + +bool WindowBaseWin::SetAuxiliaryHintValue( unsigned int id, const std::string& value ) +{ + return false; +} + +std::string WindowBaseWin::GetAuxiliaryHintValue( unsigned int id ) const +{ + return std::string(); +} + +unsigned int WindowBaseWin::GetAuxiliaryHintId( const std::string& hint ) const +{ + return 0; +} + +void WindowBaseWin::SetInputRegion( const Rect< int >& inputRegion ) +{ +} + +void WindowBaseWin::SetType( Dali::Window::Type type ) +{ +} + +bool WindowBaseWin::SetNotificationLevel( Dali::Window::NotificationLevel::Type level ) +{ + return false; +} + +Dali::Window::NotificationLevel::Type WindowBaseWin::GetNotificationLevel() const +{ + return Dali::Window::NotificationLevel::NONE; +} + +void WindowBaseWin::SetOpaqueState( bool opaque ) +{ +} + +bool WindowBaseWin::SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode) +{ + return false; +} + +Dali::Window::ScreenOffMode::Type WindowBaseWin::GetScreenOffMode() const +{ + return Dali::Window::ScreenOffMode::TIMEOUT; +} + +bool WindowBaseWin::SetBrightness( int brightness ) +{ + return false; +} + +int WindowBaseWin::GetBrightness() const +{ + return 0; +} + +bool WindowBaseWin::GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) +{ + return false; +} + +bool WindowBaseWin::UngrabKey( Dali::KEY key ) +{ + return false; +} + +bool WindowBaseWin::GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) +{ + return false; +} + +bool WindowBaseWin::UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) +{ + return false; +} + +void WindowBaseWin::GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) +{ + // calculate DPI + float xres, yres; + + //// 1 inch = 25.4 millimeters + WindowsPlatformImplement::GetDPI( xres, yres ); + + xres *= 1.5; + yres *= 1.5; + + dpiHorizontal = int( xres + 0.5f ); // rounding + dpiVertical = int( yres + 0.5f ); +} + +void WindowBaseWin::SetViewMode( ViewMode viewMode ) +{ +} + +int WindowBaseWin::GetScreenRotationAngle() +{ + return 0; +} + +void WindowBaseWin::SetWindowRotationAngle( int degree ) +{ +} + +void WindowBaseWin::WindowRotationCompleted( int degree, int width, int height ) +{ +} + +void WindowBaseWin::SetTransparency( bool transparent ) +{ +} + +unsigned int WindowBaseWin::GetSurfaceId( Any surface ) const +{ + unsigned int surfaceId = 0; + + if ( surface.Empty() == false ) + { + // check we have a valid type + DALI_ASSERT_ALWAYS( ( (surface.GetType() == typeid ( winWindow ) ) || (surface.GetType() == typeid ( Win_Window_Handle ) ) ) + && "Surface type is invalid" ); + + if ( surface.GetType() == typeid ( Win_Window_Handle ) ) + { + surfaceId = AnyCast< Win_Window_Handle >( surface ); + } + else + { + surfaceId = AnyCast< winWindow >( surface ); + } + } + return surfaceId; +} + +void WindowBaseWin::CreateWinWindow( PositionSize positionSize, bool isTransparent ) +{ + long hWnd = WindowsPlatformImplement::CreateHwnd( "Demo", "Demo", positionSize.x, positionSize.y, positionSize.width, positionSize.height, NULL ); + + WindowsPlatformImplement::ShowWindow( hWnd ); + + mWin32Window = (Win_Window_Handle)hWnd; + DALI_ASSERT_ALWAYS( mWin32Window != 0 && "There is no EcoreWin window" ); +} + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali + +#pragma GCC diagnostic pop diff --git a/dali/internal/window-system/windows/window-base-win.h b/dali/internal/window-system/windows/window-base-win.h new file mode 100755 index 0000000..381def3 --- /dev/null +++ b/dali/internal/window-system/windows/window-base-win.h @@ -0,0 +1,415 @@ +#ifndef DALI_INTERNAL_WINDOWSYSTEM_WINDOW_BASE_WIN_H +#define DALI_INTERNAL_WINDOWSYSTEM_WINDOW_BASE_WIN_H + +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include +#include +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ + +class Window; +class WindowRenderSurface; +class WindowRenderSurfaceWin; + +/** + * WindowBaseWin class provides an WindowBase Win32 implementation. + */ +class WindowBaseWin : public WindowBase +{ +public: + + /** + * @brief Constructor + */ + WindowBaseWin( PositionSize positionSize, Any surface, bool isTransparent ); + + /** + * @brief Destructor + */ + virtual ~WindowBaseWin(); + +public: + + /** + * @brief Called when the window property is changed. + */ + bool OnWindowPropertyChanged( void* data, int type, TWinEventInfo *event ); + + /** + * Called when the window receives a delete request + */ + void OnDeleteRequest(); + + /** + * @brief Called when the window gains focus. + */ + void OnFocusIn( void* data, int type, TWinEventInfo *event ); + + /** + * @brief Called when the window loses focus. + */ + void OnFocusOut( void* data, int type, TWinEventInfo *event ); + + /** + * @brief Called when the window is damaged. + */ + void OnWindowDamaged( void* data, int type, TWinEventInfo *event ); + + /** + * @brief Called when a touch down is received. + */ + void OnMouseButtonDown( void* data, int type, TWinEventInfo *event ); + + /** + * @brief Called when a touch up is received. + */ + void OnMouseButtonUp( void* data, int type, TWinEventInfo *event ); + + /** + * @brief Called when a touch motion is received. + */ + void OnMouseButtonMove( void* data, int type, TWinEventInfo *event ); + + /** + * @brief Called when a mouse wheel is received. + */ + void OnMouseWheel( void* data, int type, TWinEventInfo *event ); + + /** + * @brief Called when a key down is received. + */ + void OnKeyDown( void* data, int type, TWinEventInfo *event ); + + /** + * @brief Called when a key up is received. + */ + void OnKeyUp( void* data, int type, TWinEventInfo *event ); + + /** + * @brief Called when the source window notifies us the content in clipboard is selected. + */ + void OnSelectionClear( void* data, int type, TWinEventInfo *event ); + + /** + * @brief Called when the source window sends us about the selected content. + */ + void OnSelectionNotify( void* data, int type, TWinEventInfo *event ); + +public: + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow() + */ + virtual Any GetNativeWindow() override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId() + */ + virtual int GetNativeWindowId() override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow() + */ + virtual EGLNativeWindowType CreateEglWindow( int width, int height ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow() + */ + virtual void DestroyEglWindow() override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation() + */ + virtual void SetEglWindowRotation( int angle ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform() + */ + virtual void SetEglWindowBufferTransform( int angle ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform() + */ + virtual void SetEglWindowTransform( int angle ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow() + */ + virtual void ResizeEglWindow( PositionSize positionSize ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported() + */ + virtual bool IsEglWindowRotationSupported() override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::Move() + */ + virtual void Move( PositionSize positionSize ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::Resize() + */ + virtual void Resize( PositionSize positionSize ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize() + */ + virtual void MoveResize( PositionSize positionSize ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::ShowIndicator() + */ + virtual void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode, Dali::Window::IndicatorBgOpacity opacityMode ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetIndicatorProperties() + */ + virtual void SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::IndicatorTypeChanged() + */ + virtual void IndicatorTypeChanged( IndicatorInterface::Type type ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass() + */ + virtual void SetClass( const std::string& name, const std::string& className ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::Raise() + */ + virtual void Raise() override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::Lower() + */ + virtual void Lower() override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::Activate() + */ + virtual void Activate() override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableOrientations() + */ + virtual void SetAvailableOrientations( const std::vector< Dali::Window::WindowOrientation >& orientations ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredOrientation() + */ + virtual void SetPreferredOrientation( Dali::Window::WindowOrientation orientation ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus() + */ + virtual void SetAcceptFocus( bool accept ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::Show() + */ + virtual void Show() override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::Hide() + */ + virtual void Hide() override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount() + */ + virtual unsigned int GetSupportedAuxiliaryHintCount() const override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint() + */ + virtual std::string GetSupportedAuxiliaryHint( unsigned int index ) const override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint() + */ + virtual unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint() + */ + virtual bool RemoveAuxiliaryHint( unsigned int id ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue() + */ + virtual bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue() + */ + virtual std::string GetAuxiliaryHintValue( unsigned int id ) const override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId() + */ + virtual unsigned int GetAuxiliaryHintId( const std::string& hint ) const override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion() + */ + virtual void SetInputRegion( const Rect< int >& inputRegion ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetType() + */ + virtual void SetType( Dali::Window::Type type ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel() + */ + virtual bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel() + */ + virtual Dali::Window::NotificationLevel::Type GetNotificationLevel() const override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState() + */ + virtual void SetOpaqueState( bool opaque ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode() + */ + virtual bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode() + */ + virtual Dali::Window::ScreenOffMode::Type GetScreenOffMode() const override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness() + */ + virtual bool SetBrightness( int brightness ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness() + */ + virtual int GetBrightness() const override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey() + */ + virtual bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey() + */ + virtual bool UngrabKey( Dali::KEY key ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList() + */ + virtual bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList() + */ + virtual bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi() + */ + virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetViewMode() + */ + virtual void SetViewMode( ViewMode viewMode ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle() + */ + virtual int GetScreenRotationAngle() override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle() + */ + virtual void SetWindowRotationAngle( int degree ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted() + */ + virtual void WindowRotationCompleted( int degree, int width, int height ) override; + + /** + * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency() + */ + virtual void SetTransparency( bool transparent ) override; + +private: + + /** + * Second stage initialization + */ + void Initialize( PositionSize positionSize, Any surface, bool isTransparent ); + + /** + * @brief Get the surface id if the surface parameter is not empty + * @param surface Any containing a surface id, or can be empty + * @return surface id, or zero if surface is empty + */ + unsigned int GetSurfaceId( Any surface ) const; + + /** + * @brief Create window + */ + void CreateWinWindow( PositionSize positionSize, bool isTransparent ); + +protected: + + // Undefined + WindowBaseWin(const WindowBaseWin&) = delete; + + // Undefined + WindowBaseWin& operator=(const WindowBaseWin& rhs) = delete; + +private: + + Dali::Vector< Event_Handler > mEventHandler; + Win_Window_Handle mWin32Window; ///< Native window handle + bool mOwnSurface:1; ///< Whether we own the surface (responsible for deleting it) + bool mIsTransparent; ///< Whether the window is transparent (32 bit or 24 bit) + bool mRotationAppSet:1; +}; + +} // namespace Adaptor + +} // namespace internal + +} // namespace Dali + +#endif // DALI_INTERNAL_WINDOWSYSTEM_WINDOW_BASE_WIN_H diff --git a/dali/internal/window-system/windows/window-factory-win.cpp b/dali/internal/window-system/windows/window-factory-win.cpp new file mode 100755 index 0000000..7359548 --- /dev/null +++ b/dali/internal/window-system/windows/window-factory-win.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// CLASS HEADER +#include + +// INTERNAL HEADERS +#include +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ + +std::unique_ptr< WindowBase > WindowFactoryWin::CreateWindowBase( Dali::PositionSize positionSize, Any surface, bool isTransparent ) +{ + return Utils::MakeUnique< WindowBaseWin >( positionSize, surface, isTransparent ); +} + +std::unique_ptr< IndicatorInterface > WindowFactoryWin::CreateIndicator( Adaptor* adaptor, Dali::Window::WindowOrientation orientation, IndicatorInterface::Observer* observer ) +{ + return std::unique_ptr< IndicatorInterface >( nullptr ); +} + +// this should be created from Window impl +std::unique_ptr< WindowFactory > GetWindowFactory() +{ + // returns Window factory + return Utils::MakeUnique< WindowFactoryWin >(); +} + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali diff --git a/dali/internal/window-system/windows/window-factory-win.h b/dali/internal/window-system/windows/window-factory-win.h new file mode 100755 index 0000000..ca88e1d --- /dev/null +++ b/dali/internal/window-system/windows/window-factory-win.h @@ -0,0 +1,42 @@ +#ifndef DALI_INTERNAL_WINDOWSYSTEM_WINDOW_FACTORY_WIN_H +#define DALI_INTERNAL_WINDOWSYSTEM_WINDOW_FACTORY_WIN_H + +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +namespace Dali +{ +namespace Internal +{ +namespace Adaptor +{ + +class WindowFactoryWin : public WindowFactory +{ +public: + std::unique_ptr< WindowBase > CreateWindowBase( Dali::PositionSize positionSize, Any surface, bool isTransparent ) override; + + std::unique_ptr< IndicatorInterface > CreateIndicator( Adaptor* adaptor, Dali::Window::WindowOrientation orientation, IndicatorInterface::Observer* observer ) override; +}; + +} // namespace Adaptor +} // namespace Internal +} // namespace Dali + +#endif // DALI_INTERNAL_WINDOWSYSTEM_WINDOW_FACTORY_WIN_H diff --git a/dali/internal/window-system/windows/window-system-win.cpp b/dali/internal/window-system/windows/window-system-win.cpp new file mode 100644 index 0000000..929a26d --- /dev/null +++ b/dali/internal/window-system/windows/window-system-win.cpp @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL HEADERS +#include +#include + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +namespace WindowSystem +{ + +void Initialize() +{ +} + + +void GetScreenSize( int& width, int& height ) +{ + const char* widthValue = std::getenv( "DALI_WINDOW_WIDTH" ); + width = widthValue ? std::atoi( widthValue ) : 720; + + const char* heightValue = std::getenv( "DALI_WINDOW_WIDTH" ); + height = heightValue ? std::atoi( heightValue ) : 480; +} + +bool SetKeyboardRepeatInfo( float rate, float delay ) +{ + return false; +} + +bool GetKeyboardRepeatInfo( float& rate, float& delay ) +{ + return false; +} + +} // namespace WindowSystem + +} // namespace Adaptor + +} // namespace Internal + +} // namespace Dali + diff --git a/dali/public-api/dali-adaptor-common.h b/dali/public-api/dali-adaptor-common.h index c0a5651..fddd3aa 100755 --- a/dali/public-api/dali-adaptor-common.h +++ b/dali/public-api/dali-adaptor-common.h @@ -52,4 +52,4 @@ #endif #endif -#endif // DALI_ADAPTOR_COMMON_H +#endif //DALI_ADAPTOR_COMMON_H -- 2.7.4