From f24c14c80919972c2f41235f0ed5989d776b14a1 Mon Sep 17 00:00:00 2001 From: David Steele Date: Wed, 9 Sep 2020 18:28:27 +0100 Subject: [PATCH] Formatted API Change-Id: I46852b09a374bb8115a2ce12959800f030e54c60 --- .clang-format | 10 +- dali/devel-api/actors/actor-devel.cpp | 26 +- dali/devel-api/actors/actor-devel.h | 156 ++-- dali/devel-api/actors/camera-actor-devel.h | 2 +- dali/devel-api/actors/custom-actor-devel.cpp | 6 +- dali/devel-api/actors/custom-actor-devel.h | 6 +- dali/devel-api/actors/layer-devel.h | 30 +- dali/devel-api/addons/addon-base.h | 93 +- dali/devel-api/addons/addon-dispatch-table.h | 42 +- dali/devel-api/animation/animation-data.cpp | 30 +- dali/devel-api/animation/animation-data.h | 31 +- dali/devel-api/animation/animation-devel.cpp | 18 +- dali/devel-api/animation/animation-devel.h | 10 +- dali/devel-api/animation/path-constrainer.cpp | 20 +- dali/devel-api/animation/path-constrainer.h | 18 +- dali/devel-api/common/addon-binder.cpp | 4 +- dali/devel-api/common/addon-binder.h | 28 +- dali/devel-api/common/bitwise-enum.h | 23 +- dali/devel-api/common/circular-queue.h | 49 +- dali/devel-api/common/hash.cpp | 22 +- dali/devel-api/common/hash.h | 7 +- dali/devel-api/common/map-wrapper.h | 12 +- dali/devel-api/common/owner-container.h | 87 +- dali/devel-api/common/ref-counted-dali-vector.h | 16 +- dali/devel-api/common/set-wrapper.h | 12 +- dali/devel-api/common/singleton-service.cpp | 15 +- dali/devel-api/common/singleton-service.h | 11 +- dali/devel-api/common/stage-devel.cpp | 24 +- dali/devel-api/common/stage-devel.h | 14 +- dali/devel-api/common/stage.cpp | 21 +- dali/devel-api/common/stage.h | 15 +- dali/devel-api/events/hit-test-algorithm.cpp | 14 +- dali/devel-api/events/hit-test-algorithm.h | 21 +- dali/devel-api/events/hover-event-devel.cpp | 7 +- dali/devel-api/events/hover-event-devel.h | 5 +- dali/devel-api/events/key-event-devel.cpp | 53 +- dali/devel-api/events/key-event-devel.h | 36 +- .../events/long-press-gesture-detector-devel.cpp | 8 +- .../events/long-press-gesture-detector-devel.h | 4 +- dali/devel-api/events/long-press-gesture-devel.cpp | 7 +- dali/devel-api/events/long-press-gesture-devel.h | 4 +- dali/devel-api/events/pan-gesture-devel.cpp | 39 +- dali/devel-api/events/pan-gesture-devel.h | 2 - dali/devel-api/events/pinch-gesture-devel.cpp | 7 +- dali/devel-api/events/pinch-gesture-devel.h | 4 +- dali/devel-api/events/rotation-gesture-devel.cpp | 7 +- dali/devel-api/events/rotation-gesture-devel.h | 4 +- dali/devel-api/events/tap-gesture-devel.cpp | 7 +- dali/devel-api/events/tap-gesture-devel.h | 4 +- dali/devel-api/events/touch-point.cpp | 1 - dali/devel-api/events/touch-point.h | 2 +- dali/devel-api/events/wheel-event-devel.cpp | 11 +- dali/devel-api/events/wheel-event-devel.h | 5 +- dali/devel-api/images/distance-field.cpp | 207 +++-- dali/devel-api/images/distance-field.h | 16 +- dali/devel-api/images/pixel-data-devel.cpp | 10 +- dali/devel-api/images/pixel-data-devel.h | 18 +- dali/devel-api/object/csharp-type-info.h | 10 +- dali/devel-api/object/csharp-type-registry.cpp | 29 +- dali/devel-api/object/csharp-type-registry.h | 31 +- dali/devel-api/object/handle-devel.cpp | 8 +- dali/devel-api/object/handle-devel.h | 4 +- dali/devel-api/object/property-helper-devel.h | 32 +- dali/devel-api/rendering/frame-buffer-devel.cpp | 40 +- dali/devel-api/rendering/frame-buffer-devel.h | 16 +- dali/devel-api/rendering/renderer-devel.cpp | 12 +- dali/devel-api/rendering/renderer-devel.h | 88 +- dali/devel-api/scripting/enum-helper.h | 16 +- dali/devel-api/scripting/scripting.cpp | 184 ++-- dali/devel-api/scripting/scripting.h | 92 +- dali/devel-api/signals/signal-delegate.cpp | 21 +- dali/devel-api/signals/signal-delegate.h | 41 +- dali/devel-api/threading/conditional-wait.cpp | 53 +- dali/devel-api/threading/conditional-wait.h | 22 +- dali/devel-api/threading/mutex.cpp | 11 +- dali/devel-api/threading/mutex.h | 14 +- dali/devel-api/threading/thread-pool.cpp | 136 ++- dali/devel-api/threading/thread-pool.h | 30 +- dali/devel-api/threading/thread.cpp | 19 +- dali/devel-api/threading/thread.h | 18 +- dali/devel-api/update/frame-callback-interface.cpp | 11 +- dali/devel-api/update/frame-callback-interface.h | 9 +- dali/devel-api/update/update-proxy.cpp | 59 +- dali/devel-api/update/update-proxy.h | 42 +- dali/integration-api/addon-manager.cpp | 4 +- dali/integration-api/addon-manager.h | 68 +- dali/integration-api/bitmap.cpp | 211 +++-- dali/integration-api/bitmap.h | 102 +-- dali/integration-api/context-notifier.h | 10 +- dali/integration-api/core-enumerations.h | 6 +- dali/integration-api/core.cpp | 86 +- dali/integration-api/core.h | 110 +-- dali/integration-api/debug.cpp | 85 +- dali/integration-api/debug.h | 212 ++--- dali/integration-api/events/event.cpp | 2 - dali/integration-api/events/event.h | 13 +- dali/integration-api/events/hover-event-integ.cpp | 10 +- dali/integration-api/events/hover-event-integ.h | 6 +- dali/integration-api/events/key-event-integ.cpp | 58 +- dali/integration-api/events/key-event-integ.h | 32 +- .../events/multi-point-event-integ.cpp | 24 +- .../events/multi-point-event-integ.h | 12 +- dali/integration-api/events/point.cpp | 61 +- dali/integration-api/events/point.h | 49 +- .../events/touch-event-combiner.cpp | 200 +++-- dali/integration-api/events/touch-event-combiner.h | 41 +- dali/integration-api/events/touch-event-integ.cpp | 10 +- dali/integration-api/events/touch-event-integ.h | 2 - dali/integration-api/events/touch-integ.cpp | 11 +- dali/integration-api/events/touch-integ.h | 8 +- dali/integration-api/events/wheel-event-integ.cpp | 32 +- dali/integration-api/events/wheel-event-integ.h | 9 +- dali/integration-api/gl-abstraction.h | 16 +- .../gl-context-helper-abstraction.h | 2 - dali/integration-api/gl-defines.h | 4 +- dali/integration-api/gl-sync-abstraction.h | 13 +- dali/integration-api/input-options.cpp | 81 +- dali/integration-api/input-options.h | 48 +- dali/integration-api/lockless-buffer.cpp | 48 +- dali/integration-api/lockless-buffer.h | 31 +- dali/integration-api/platform-abstraction.h | 43 +- dali/integration-api/processor-interface.h | 13 +- dali/integration-api/profiling.cpp | 60 +- dali/integration-api/profiling.h | 33 +- dali/integration-api/render-controller.h | 15 +- dali/integration-api/render-task-list-integ.cpp | 13 +- dali/integration-api/render-task-list-integ.h | 13 +- dali/integration-api/resource-policies.h | 1 - dali/integration-api/resource-types.h | 33 +- dali/integration-api/scene.cpp | 78 +- dali/integration-api/scene.h | 45 +- dali/integration-api/trace.cpp | 75 +- dali/integration-api/trace.h | 91 +- dali/public-api/actors/actor-enumerations.h | 60 +- dali/public-api/actors/actor.cpp | 85 +- dali/public-api/actors/actor.h | 60 +- dali/public-api/actors/camera-actor.cpp | 50 +- dali/public-api/actors/camera-actor.h | 39 +- dali/public-api/actors/custom-actor-impl.cpp | 29 +- dali/public-api/actors/custom-actor-impl.h | 50 +- dali/public-api/actors/custom-actor.cpp | 16 +- dali/public-api/actors/custom-actor.h | 8 +- dali/public-api/actors/draw-mode.h | 3 +- dali/public-api/actors/layer.cpp | 25 +- dali/public-api/actors/layer.h | 22 +- dali/public-api/animation/alpha-function.cpp | 63 +- dali/public-api/animation/alpha-function.h | 61 +- dali/public-api/animation/animation.cpp | 63 +- dali/public-api/animation/animation.h | 59 +- dali/public-api/animation/constraint-source.cpp | 37 +- dali/public-api/animation/constraint-source.h | 15 +- dali/public-api/animation/constraint.cpp | 140 ++-- dali/public-api/animation/constraint.h | 143 ++-- dali/public-api/animation/constraints.h | 58 +- dali/public-api/animation/key-frames.cpp | 17 +- dali/public-api/animation/key-frames.h | 9 +- dali/public-api/animation/linear-constrainer.cpp | 21 +- dali/public-api/animation/linear-constrainer.h | 17 +- dali/public-api/animation/path.cpp | 38 +- dali/public-api/animation/path.h | 23 +- dali/public-api/animation/time-period.cpp | 3 +- dali/public-api/common/constants.h | 89 +- dali/public-api/common/dali-common.cpp | 59 +- dali/public-api/common/dali-common.h | 80 +- dali/public-api/common/dali-vector.cpp | 103 ++- dali/public-api/common/dali-vector.h | 264 +++--- dali/public-api/common/extents.cpp | 47 +- dali/public-api/common/extents.h | 25 +- dali/public-api/common/intrusive-ptr.h | 87 +- dali/public-api/common/list-wrapper.h | 10 +- dali/public-api/common/type-traits.h | 13 +- dali/public-api/common/vector-wrapper.h | 12 +- dali/public-api/dali-core-version.cpp | 9 +- dali/public-api/dali-core-version.h | 10 +- dali/public-api/dali-core.h | 10 +- dali/public-api/events/device.h | 49 +- dali/public-api/events/gesture-detector.cpp | 7 +- dali/public-api/events/gesture-detector.h | 7 +- dali/public-api/events/gesture-enumerations.h | 1 - dali/public-api/events/gesture.cpp | 9 +- dali/public-api/events/gesture.h | 12 +- dali/public-api/events/hover-event.cpp | 39 +- dali/public-api/events/hover-event.h | 26 +- dali/public-api/events/key-event.cpp | 41 +- dali/public-api/events/key-event.h | 22 +- .../events/long-press-gesture-detector.cpp | 7 +- .../events/long-press-gesture-detector.h | 12 +- dali/public-api/events/long-press-gesture.cpp | 19 +- dali/public-api/events/long-press-gesture.h | 14 +- dali/public-api/events/mouse-button.h | 13 +- dali/public-api/events/pan-gesture-detector.cpp | 41 +- dali/public-api/events/pan-gesture-detector.h | 26 +- dali/public-api/events/pan-gesture.cpp | 37 +- dali/public-api/events/pan-gesture.h | 16 +- dali/public-api/events/pinch-gesture-detector.cpp | 6 +- dali/public-api/events/pinch-gesture-detector.h | 9 +- dali/public-api/events/pinch-gesture.cpp | 23 +- dali/public-api/events/pinch-gesture.h | 16 +- dali/public-api/events/point-state.h | 21 +- .../events/rotation-gesture-detector.cpp | 21 +- dali/public-api/events/rotation-gesture-detector.h | 10 +- dali/public-api/events/rotation-gesture.cpp | 21 +- dali/public-api/events/rotation-gesture.h | 15 +- dali/public-api/events/tap-gesture-detector.cpp | 10 +- dali/public-api/events/tap-gesture-detector.h | 16 +- dali/public-api/events/tap-gesture.cpp | 23 +- dali/public-api/events/tap-gesture.h | 13 +- dali/public-api/events/touch-event.cpp | 67 +- dali/public-api/events/touch-event.h | 43 +- dali/public-api/events/wheel-event.cpp | 31 +- dali/public-api/events/wheel-event.h | 18 +- dali/public-api/images/image-operations.h | 106 +-- dali/public-api/images/native-image-interface.h | 7 +- dali/public-api/images/pixel-data.cpp | 25 +- dali/public-api/images/pixel-data.h | 24 +- dali/public-api/images/pixel.cpp | 35 +- dali/public-api/images/pixel.h | 114 +-- dali/public-api/math/angle-axis.h | 33 +- dali/public-api/math/compile-time-math.cpp | 43 +- dali/public-api/math/compile-time-math.h | 63 +- dali/public-api/math/degree.cpp | 5 +- dali/public-api/math/degree.h | 38 +- dali/public-api/math/math-utils.h | 94 +-- dali/public-api/math/matrix.cpp | 558 ++++++------ dali/public-api/math/matrix.h | 76 +- dali/public-api/math/matrix3.cpp | 129 +-- dali/public-api/math/matrix3.h | 43 +- dali/public-api/math/quaternion.cpp | 334 ++++---- dali/public-api/math/quaternion.h | 89 +- dali/public-api/math/radian.h | 108 +-- dali/public-api/math/random.h | 19 +- dali/public-api/math/rect.cpp | 1 - dali/public-api/math/rect.h | 124 ++- dali/public-api/math/uint-16-pair.h | 63 +- dali/public-api/math/vector2.cpp | 30 +- dali/public-api/math/vector2.h | 76 +- dali/public-api/math/vector3.cpp | 72 +- dali/public-api/math/vector3.h | 114 ++- dali/public-api/math/vector4.cpp | 76 +- dali/public-api/math/vector4.h | 91 +- dali/public-api/object/any.cpp | 32 +- dali/public-api/object/any.h | 147 ++-- dali/public-api/object/base-handle.cpp | 13 +- dali/public-api/object/base-handle.h | 34 +- dali/public-api/object/base-object.cpp | 34 +- dali/public-api/object/base-object.h | 27 +- dali/public-api/object/handle.cpp | 124 ++- dali/public-api/object/handle.h | 98 ++- dali/public-api/object/indirect-value.cpp | 15 +- dali/public-api/object/indirect-value.h | 16 +- dali/public-api/object/object-registry.cpp | 5 +- dali/public-api/object/object-registry.h | 11 +- dali/public-api/object/property-array.cpp | 70 +- dali/public-api/object/property-array.h | 42 +- dali/public-api/object/property-conditions.cpp | 91 +- dali/public-api/object/property-conditions.h | 25 +- dali/public-api/object/property-index-ranges.h | 40 +- dali/public-api/object/property-input.cpp | 3 +- dali/public-api/object/property-input.h | 3 +- dali/public-api/object/property-key.cpp | 58 +- dali/public-api/object/property-key.h | 35 +- dali/public-api/object/property-map.cpp | 245 +++--- dali/public-api/object/property-map.h | 72 +- .../object/property-notification-declarations.h | 5 +- dali/public-api/object/property-notification.cpp | 17 +- dali/public-api/object/property-notification.h | 20 +- dali/public-api/object/property-types.cpp | 13 +- dali/public-api/object/property-types.h | 122 ++- dali/public-api/object/property-value.cpp | 533 ++++++------ dali/public-api/object/property-value.h | 117 ++- dali/public-api/object/property.cpp | 5 +- dali/public-api/object/property.h | 56 +- dali/public-api/object/ref-object.cpp | 9 +- dali/public-api/object/ref-object.h | 5 +- dali/public-api/object/type-info.cpp | 33 +- dali/public-api/object/type-info.h | 30 +- dali/public-api/object/type-registry-helper.h | 88 +- dali/public-api/object/type-registry.cpp | 97 +-- dali/public-api/object/type-registry.h | 55 +- dali/public-api/object/weak-handle.cpp | 58 +- dali/public-api/object/weak-handle.h | 40 +- dali/public-api/render-tasks/render-task-list.cpp | 26 +- dali/public-api/render-tasks/render-task-list.h | 14 +- dali/public-api/render-tasks/render-task.cpp | 112 ++- dali/public-api/render-tasks/render-task.h | 49 +- dali/public-api/rendering/frame-buffer.cpp | 57 +- dali/public-api/rendering/frame-buffer.h | 36 +- dali/public-api/rendering/geometry.cpp | 39 +- dali/public-api/rendering/geometry.h | 27 +- dali/public-api/rendering/renderer.cpp | 53 +- dali/public-api/rendering/renderer.h | 53 +- dali/public-api/rendering/sampler.cpp | 31 +- dali/public-api/rendering/sampler.h | 23 +- dali/public-api/rendering/shader.cpp | 31 +- dali/public-api/rendering/shader.h | 26 +- dali/public-api/rendering/texture-set.cpp | 55 +- dali/public-api/rendering/texture-set.h | 23 +- dali/public-api/rendering/texture.cpp | 55 +- dali/public-api/rendering/texture.h | 56 +- dali/public-api/rendering/vertex-buffer.cpp | 32 +- dali/public-api/rendering/vertex-buffer.h | 18 +- dali/public-api/signals/base-signal.cpp | 166 ++-- dali/public-api/signals/base-signal.h | 156 ++-- dali/public-api/signals/callback.cpp | 58 +- dali/public-api/signals/callback.h | 932 +++++++++++---------- .../signals/connection-tracker-interface.cpp | 3 +- .../signals/connection-tracker-interface.h | 12 +- dali/public-api/signals/connection-tracker.cpp | 25 +- dali/public-api/signals/connection-tracker.h | 17 +- dali/public-api/signals/dali-signal.h | 406 +++++---- dali/public-api/signals/functor-delegate.cpp | 22 +- dali/public-api/signals/functor-delegate.h | 43 +- .../public-api/signals/signal-slot-connections.cpp | 27 +- dali/public-api/signals/signal-slot-connections.h | 30 +- dali/public-api/signals/signal-slot-observers.cpp | 3 +- dali/public-api/signals/signal-slot-observers.h | 8 +- dali/public-api/signals/slot-delegate.h | 17 +- .../size-negotiation/relayout-container.h | 14 +- 318 files changed, 7453 insertions(+), 7867 deletions(-) mode change 100755 => 100644 dali/devel-api/common/singleton-service.h mode change 100755 => 100644 dali/devel-api/images/distance-field.cpp mode change 100755 => 100644 dali/devel-api/images/pixel-data-devel.h mode change 100755 => 100644 dali/devel-api/threading/conditional-wait.h mode change 100755 => 100644 dali/devel-api/threading/mutex.h mode change 100755 => 100644 dali/integration-api/events/key-event-integ.cpp mode change 100755 => 100644 dali/integration-api/events/key-event-integ.h mode change 100755 => 100644 dali/integration-api/events/point.cpp mode change 100755 => 100644 dali/integration-api/events/point.h mode change 100755 => 100644 dali/integration-api/render-task-list-integ.cpp mode change 100755 => 100644 dali/integration-api/render-task-list-integ.h mode change 100755 => 100644 dali/public-api/animation/alpha-function.cpp mode change 100755 => 100644 dali/public-api/common/dali-common.h mode change 100755 => 100644 dali/public-api/events/key-event.cpp mode change 100755 => 100644 dali/public-api/events/key-event.h mode change 100755 => 100644 dali/public-api/events/mouse-button.h mode change 100755 => 100644 dali/public-api/events/touch-event.cpp mode change 100755 => 100644 dali/public-api/math/matrix.h mode change 100755 => 100644 dali/public-api/math/matrix3.h mode change 100755 => 100644 dali/public-api/object/property-value.h mode change 100755 => 100644 dali/public-api/signals/base-signal.h diff --git a/.clang-format b/.clang-format index f983424..d314ca1 100644 --- a/.clang-format +++ b/.clang-format @@ -34,7 +34,6 @@ BraceWrapping: IndentBraces: false SplitEmptyFunction: true SplitEmptyRecord: true -SpacesInConditionalStatement : true BreakBeforeBinaryOperators: None BreakBeforeBraces: Allman BreakBeforeTernaryOperators: true @@ -46,7 +45,7 @@ ColumnLimit: 0 CommentPragmas: '^ IWYU pragma:' ContinuationIndentWidth: 2 Cpp11BracedListStyle: true -DerivePointerAlignment: true +DerivePointerAlignment: false DisableFormat: false ExperimentalAutoDetectBinPacking: false ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] @@ -63,8 +62,8 @@ IndentCaseLabels: true IndentWidth: 2 IndentWrappedFunctionNames: false KeepEmptyLinesAtTheStartOfBlocks: false -MacroBlockBegin: '' -MacroBlockEnd: '' +MacroBlockBegin: '^DALI_ENUM_TO_STRING_TABLE_BEGIN' +MacroBlockEnd: 'DALI_ENUM_TO_STRING_TABLE_END' MaxEmptyLinesToKeep: 1 NamespaceIndentation: None ObjCBlockIndentWidth: 2 @@ -76,13 +75,14 @@ PenaltyBreakFirstLessLess: 120 PenaltyBreakString: 1000 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 200 -PointerAlignment: Right +PointerAlignment: Left ReflowComments: true SortIncludes: true SpaceAfterCStyleCast: false SpaceBeforeAssignmentOperators: true SpaceBeforeParens: Never SpaceInEmptyParentheses: false +SpacesInConditionalStatement : false SpacesBeforeTrailingComments: 1 SpacesInAngles: false SpacesInContainerLiterals: true diff --git a/dali/devel-api/actors/actor-devel.cpp b/dali/devel-api/actors/actor-devel.cpp index 3f3b9ab..68a5205 100644 --- a/dali/devel-api/actors/actor-devel.cpp +++ b/dali/devel-api/actors/actor-devel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -21,37 +21,33 @@ namespace Dali { - namespace DevelActor { - -Rect<> CalculateScreenExtents( Actor actor ) +Rect<> CalculateScreenExtents(Actor actor) { - return GetImplementation( actor ).CalculateScreenExtents(); + return GetImplementation(actor).CalculateScreenExtents(); } -VisibilityChangedSignalType& VisibilityChangedSignal( Actor actor ) +VisibilityChangedSignalType& VisibilityChangedSignal(Actor actor) { - return GetImplementation( actor ).VisibilityChangedSignal(); + return GetImplementation(actor).VisibilityChangedSignal(); } -ChildChangedSignalType& ChildAddedSignal( Actor actor ) +ChildChangedSignalType& ChildAddedSignal(Actor actor) { - return GetImplementation( actor ).ChildAddedSignal(); + return GetImplementation(actor).ChildAddedSignal(); } -ChildChangedSignalType& ChildRemovedSignal( Actor actor ) +ChildChangedSignalType& ChildRemovedSignal(Actor actor) { - return GetImplementation( actor ).ChildRemovedSignal(); + return GetImplementation(actor).ChildRemovedSignal(); } -ChildOrderChangedSignalType& ChildOrderChangedSignal( Actor actor ) +ChildOrderChangedSignalType& ChildOrderChangedSignal(Actor actor) { - return GetImplementation( actor ).ChildOrderChangedSignal(); + return GetImplementation(actor).ChildOrderChangedSignal(); } - - } // namespace DevelActor } // namespace Dali diff --git a/dali/devel-api/actors/actor-devel.h b/dali/devel-api/actors/actor-devel.h index a55bb0e..43b44f7 100644 --- a/dali/devel-api/actors/actor-devel.h +++ b/dali/devel-api/actors/actor-devel.h @@ -24,80 +24,77 @@ namespace Dali { - namespace DevelActor { - namespace Property { - enum Type { - PARENT_ORIGIN = Dali::Actor::Property::PARENT_ORIGIN, - PARENT_ORIGIN_X = Dali::Actor::Property::PARENT_ORIGIN_X, - PARENT_ORIGIN_Y = Dali::Actor::Property::PARENT_ORIGIN_Y, - PARENT_ORIGIN_Z = Dali::Actor::Property::PARENT_ORIGIN_Z, - ANCHOR_POINT = Dali::Actor::Property::ANCHOR_POINT, - ANCHOR_POINT_X = Dali::Actor::Property::ANCHOR_POINT_X, - ANCHOR_POINT_Y = Dali::Actor::Property::ANCHOR_POINT_Y, - ANCHOR_POINT_Z = Dali::Actor::Property::ANCHOR_POINT_Z, - SIZE = Dali::Actor::Property::SIZE, - SIZE_WIDTH = Dali::Actor::Property::SIZE_WIDTH, - SIZE_HEIGHT = Dali::Actor::Property::SIZE_HEIGHT, - SIZE_DEPTH = Dali::Actor::Property::SIZE_DEPTH, - POSITION = Dali::Actor::Property::POSITION, - POSITION_X = Dali::Actor::Property::POSITION_X, - POSITION_Y = Dali::Actor::Property::POSITION_Y, - POSITION_Z = Dali::Actor::Property::POSITION_Z, - WORLD_POSITION = Dali::Actor::Property::WORLD_POSITION, - WORLD_POSITION_X = Dali::Actor::Property::WORLD_POSITION_X, - WORLD_POSITION_Y = Dali::Actor::Property::WORLD_POSITION_Y, - WORLD_POSITION_Z = Dali::Actor::Property::WORLD_POSITION_Z, - ORIENTATION = Dali::Actor::Property::ORIENTATION, - WORLD_ORIENTATION = Dali::Actor::Property::WORLD_ORIENTATION, - SCALE = Dali::Actor::Property::SCALE, - SCALE_X = Dali::Actor::Property::SCALE_X, - SCALE_Y = Dali::Actor::Property::SCALE_Y, - SCALE_Z = Dali::Actor::Property::SCALE_Z, - WORLD_SCALE = Dali::Actor::Property::WORLD_SCALE, - VISIBLE = Dali::Actor::Property::VISIBLE, - COLOR = Dali::Actor::Property::COLOR, - COLOR_RED = Dali::Actor::Property::COLOR_RED, - COLOR_GREEN = Dali::Actor::Property::COLOR_GREEN, - COLOR_BLUE = Dali::Actor::Property::COLOR_BLUE, - COLOR_ALPHA = Dali::Actor::Property::COLOR_ALPHA, - WORLD_COLOR = Dali::Actor::Property::WORLD_COLOR, - WORLD_MATRIX = Dali::Actor::Property::WORLD_MATRIX, - NAME = Dali::Actor::Property::NAME, - SENSITIVE = Dali::Actor::Property::SENSITIVE, - LEAVE_REQUIRED = Dali::Actor::Property::LEAVE_REQUIRED, - INHERIT_ORIENTATION = Dali::Actor::Property::INHERIT_ORIENTATION, - INHERIT_SCALE = Dali::Actor::Property::INHERIT_SCALE, - COLOR_MODE = Dali::Actor::Property::COLOR_MODE, - DRAW_MODE = Dali::Actor::Property::DRAW_MODE, - SIZE_MODE_FACTOR = Dali::Actor::Property::SIZE_MODE_FACTOR, - WIDTH_RESIZE_POLICY = Dali::Actor::Property::WIDTH_RESIZE_POLICY, - HEIGHT_RESIZE_POLICY = Dali::Actor::Property::HEIGHT_RESIZE_POLICY, - SIZE_SCALE_POLICY = Dali::Actor::Property::SIZE_SCALE_POLICY, - WIDTH_FOR_HEIGHT = Dali::Actor::Property::WIDTH_FOR_HEIGHT, - HEIGHT_FOR_WIDTH = Dali::Actor::Property::HEIGHT_FOR_WIDTH, - PADDING = Dali::Actor::Property::PADDING, - MINIMUM_SIZE = Dali::Actor::Property::MINIMUM_SIZE, - MAXIMUM_SIZE = Dali::Actor::Property::MAXIMUM_SIZE, - INHERIT_POSITION = Dali::Actor::Property::INHERIT_POSITION, - CLIPPING_MODE = Dali::Actor::Property::CLIPPING_MODE, - LAYOUT_DIRECTION = Dali::Actor::Property::LAYOUT_DIRECTION, - INHERIT_LAYOUT_DIRECTION = Dali::Actor::Property::INHERIT_LAYOUT_DIRECTION, - OPACITY = Dali::Actor::Property::OPACITY, - SCREEN_POSITION = Dali::Actor::Property::SCREEN_POSITION, - POSITION_USES_ANCHOR_POINT = Dali::Actor::Property::POSITION_USES_ANCHOR_POINT, - CULLED = Dali::Actor::Property::CULLED, - ID = Dali::Actor::Property::ID, - HIERARCHY_DEPTH = Dali::Actor::Property::HIERARCHY_DEPTH, - IS_ROOT = Dali::Actor::Property::IS_ROOT, - IS_LAYER = Dali::Actor::Property::IS_LAYER, - CONNECTED_TO_SCENE = Dali::Actor::Property::CONNECTED_TO_SCENE, - KEYBOARD_FOCUSABLE = Dali::Actor::Property::KEYBOARD_FOCUSABLE, + PARENT_ORIGIN = Dali::Actor::Property::PARENT_ORIGIN, + PARENT_ORIGIN_X = Dali::Actor::Property::PARENT_ORIGIN_X, + PARENT_ORIGIN_Y = Dali::Actor::Property::PARENT_ORIGIN_Y, + PARENT_ORIGIN_Z = Dali::Actor::Property::PARENT_ORIGIN_Z, + ANCHOR_POINT = Dali::Actor::Property::ANCHOR_POINT, + ANCHOR_POINT_X = Dali::Actor::Property::ANCHOR_POINT_X, + ANCHOR_POINT_Y = Dali::Actor::Property::ANCHOR_POINT_Y, + ANCHOR_POINT_Z = Dali::Actor::Property::ANCHOR_POINT_Z, + SIZE = Dali::Actor::Property::SIZE, + SIZE_WIDTH = Dali::Actor::Property::SIZE_WIDTH, + SIZE_HEIGHT = Dali::Actor::Property::SIZE_HEIGHT, + SIZE_DEPTH = Dali::Actor::Property::SIZE_DEPTH, + POSITION = Dali::Actor::Property::POSITION, + POSITION_X = Dali::Actor::Property::POSITION_X, + POSITION_Y = Dali::Actor::Property::POSITION_Y, + POSITION_Z = Dali::Actor::Property::POSITION_Z, + WORLD_POSITION = Dali::Actor::Property::WORLD_POSITION, + WORLD_POSITION_X = Dali::Actor::Property::WORLD_POSITION_X, + WORLD_POSITION_Y = Dali::Actor::Property::WORLD_POSITION_Y, + WORLD_POSITION_Z = Dali::Actor::Property::WORLD_POSITION_Z, + ORIENTATION = Dali::Actor::Property::ORIENTATION, + WORLD_ORIENTATION = Dali::Actor::Property::WORLD_ORIENTATION, + SCALE = Dali::Actor::Property::SCALE, + SCALE_X = Dali::Actor::Property::SCALE_X, + SCALE_Y = Dali::Actor::Property::SCALE_Y, + SCALE_Z = Dali::Actor::Property::SCALE_Z, + WORLD_SCALE = Dali::Actor::Property::WORLD_SCALE, + VISIBLE = Dali::Actor::Property::VISIBLE, + COLOR = Dali::Actor::Property::COLOR, + COLOR_RED = Dali::Actor::Property::COLOR_RED, + COLOR_GREEN = Dali::Actor::Property::COLOR_GREEN, + COLOR_BLUE = Dali::Actor::Property::COLOR_BLUE, + COLOR_ALPHA = Dali::Actor::Property::COLOR_ALPHA, + WORLD_COLOR = Dali::Actor::Property::WORLD_COLOR, + WORLD_MATRIX = Dali::Actor::Property::WORLD_MATRIX, + NAME = Dali::Actor::Property::NAME, + SENSITIVE = Dali::Actor::Property::SENSITIVE, + LEAVE_REQUIRED = Dali::Actor::Property::LEAVE_REQUIRED, + INHERIT_ORIENTATION = Dali::Actor::Property::INHERIT_ORIENTATION, + INHERIT_SCALE = Dali::Actor::Property::INHERIT_SCALE, + COLOR_MODE = Dali::Actor::Property::COLOR_MODE, + DRAW_MODE = Dali::Actor::Property::DRAW_MODE, + SIZE_MODE_FACTOR = Dali::Actor::Property::SIZE_MODE_FACTOR, + WIDTH_RESIZE_POLICY = Dali::Actor::Property::WIDTH_RESIZE_POLICY, + HEIGHT_RESIZE_POLICY = Dali::Actor::Property::HEIGHT_RESIZE_POLICY, + SIZE_SCALE_POLICY = Dali::Actor::Property::SIZE_SCALE_POLICY, + WIDTH_FOR_HEIGHT = Dali::Actor::Property::WIDTH_FOR_HEIGHT, + HEIGHT_FOR_WIDTH = Dali::Actor::Property::HEIGHT_FOR_WIDTH, + PADDING = Dali::Actor::Property::PADDING, + MINIMUM_SIZE = Dali::Actor::Property::MINIMUM_SIZE, + MAXIMUM_SIZE = Dali::Actor::Property::MAXIMUM_SIZE, + INHERIT_POSITION = Dali::Actor::Property::INHERIT_POSITION, + CLIPPING_MODE = Dali::Actor::Property::CLIPPING_MODE, + LAYOUT_DIRECTION = Dali::Actor::Property::LAYOUT_DIRECTION, + INHERIT_LAYOUT_DIRECTION = Dali::Actor::Property::INHERIT_LAYOUT_DIRECTION, + OPACITY = Dali::Actor::Property::OPACITY, + SCREEN_POSITION = Dali::Actor::Property::SCREEN_POSITION, + POSITION_USES_ANCHOR_POINT = Dali::Actor::Property::POSITION_USES_ANCHOR_POINT, + CULLED = Dali::Actor::Property::CULLED, + ID = Dali::Actor::Property::ID, + HIERARCHY_DEPTH = Dali::Actor::Property::HIERARCHY_DEPTH, + IS_ROOT = Dali::Actor::Property::IS_ROOT, + IS_LAYER = Dali::Actor::Property::IS_LAYER, + CONNECTED_TO_SCENE = Dali::Actor::Property::CONNECTED_TO_SCENE, + KEYBOARD_FOCUSABLE = Dali::Actor::Property::KEYBOARD_FOCUSABLE, /** * @brief Sets the sibling order of the actor so depth position can be defined within the same parent. @@ -127,16 +124,15 @@ enum Type namespace VisibilityChange { - enum Type { - SELF, ///< The visibility of the actor itself has changed. - PARENT ///< The visibility of a parent has changed. + SELF, ///< The visibility of the actor itself has changed. + PARENT ///< The visibility of a parent has changed. }; } // namespace VisibilityChange -using VisibilityChangedSignalType = Signal; ///< Signal type of VisibilityChangedSignalType +using VisibilityChangedSignalType = Signal; ///< Signal type of VisibilityChangedSignalType /** * @brief This signal is emitted when the visible property of this or a parent actor is changed. @@ -152,16 +148,16 @@ using VisibilityChangedSignalType = Signal CalculateScreenExtents( Actor actor ); +DALI_CORE_API Rect<> CalculateScreenExtents(Actor actor); -using ChildChangedSignalType = Signal; ///< Called when the actor has a child added or removed +using ChildChangedSignalType = Signal; ///< Called when the actor has a child added or removed /** * @brief This signal is emitted when a child is added to this actor. @@ -179,7 +175,7 @@ using ChildChangedSignalType = Signal; ///< Called when the actor * @return The signal to connect to * @pre The Actor has been initialized */ -DALI_CORE_API ChildChangedSignalType& ChildAddedSignal( Actor actor ); +DALI_CORE_API ChildChangedSignalType& ChildAddedSignal(Actor actor); /** * @brief This signal is emitted when a child is removed from this actor. @@ -201,9 +197,9 @@ DALI_CORE_API ChildChangedSignalType& ChildAddedSignal( Actor actor ); * @return The signal to connect to * @pre The Actor has been initialized */ -DALI_CORE_API ChildChangedSignalType& ChildRemovedSignal( Actor actor ); +DALI_CORE_API ChildChangedSignalType& ChildRemovedSignal(Actor actor); -using ChildOrderChangedSignalType = Signal; ///< Used when the actor's children have changed order +using ChildOrderChangedSignalType = Signal; ///< Used when the actor's children have changed order /** * @brief This signal is emitted when an actor's children change their sibling order @@ -217,9 +213,7 @@ using ChildOrderChangedSignalType = Signal; ///< Used when the ac * @return The signal to connect to * @pre The Actor has been initialized */ -DALI_CORE_API ChildOrderChangedSignalType& ChildOrderChangedSignal( Actor actor ); - - +DALI_CORE_API ChildOrderChangedSignalType& ChildOrderChangedSignal(Actor actor); } // namespace DevelActor diff --git a/dali/devel-api/actors/camera-actor-devel.h b/dali/devel-api/actors/camera-actor-devel.h index 0f5d975..b95600f 100644 --- a/dali/devel-api/actors/camera-actor-devel.h +++ b/dali/devel-api/actors/camera-actor-devel.h @@ -37,7 +37,7 @@ enum }; } // Namespace Property -} // Namesapce DevelCameraActor +} // namespace DevelCameraActor } // Namespace Dali #endif // DALI_CAMERA_ACTOR_DEVEL_H diff --git a/dali/devel-api/actors/custom-actor-devel.cpp b/dali/devel-api/actors/custom-actor-devel.cpp index 3c1d7bb..b5f2932 100644 --- a/dali/devel-api/actors/custom-actor-devel.cpp +++ b/dali/devel-api/actors/custom-actor-devel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -23,11 +23,9 @@ namespace Dali { - namespace DevelCustomActor { - -const Dali::TypeInfo GetTypeInfo( CustomActor actor ) +const Dali::TypeInfo GetTypeInfo(CustomActor actor) { return actor.GetImplementation().GetOwner()->GetTypeInfo(); } diff --git a/dali/devel-api/actors/custom-actor-devel.h b/dali/devel-api/actors/custom-actor-devel.h index 674acc4..d4a4c54 100644 --- a/dali/devel-api/actors/custom-actor-devel.h +++ b/dali/devel-api/actors/custom-actor-devel.h @@ -2,7 +2,7 @@ #define DALI_CUSTOM_ACTOR_DEVEL_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -23,10 +23,8 @@ namespace Dali { - namespace DevelCustomActor { - /** * Get the type info for the CustomActor. * This is useful when the type information has been set via @@ -34,7 +32,7 @@ namespace DevelCustomActor * @param[in] actor The custom actor of which to get the type information * @return the TypeInfo of this actor */ -DALI_CORE_API const Dali::TypeInfo GetTypeInfo( CustomActor actor ); +DALI_CORE_API const Dali::TypeInfo GetTypeInfo(CustomActor actor); } // namespace DevelCustomActor diff --git a/dali/devel-api/actors/layer-devel.h b/dali/devel-api/actors/layer-devel.h index a8637b7..7896b78 100644 --- a/dali/devel-api/actors/layer-devel.h +++ b/dali/devel-api/actors/layer-devel.h @@ -2,7 +2,7 @@ #define DALI_LAYER_DEVEL_H /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -23,30 +23,28 @@ namespace Dali { - namespace DevelLayer { - - /** +/** * @brief ACTOR_DEPTH_MULTIPLIER is used by the rendering sorting algorithm to decide which actors to render first. * @SINCE_1_0.0 */ - enum ActorDepthMultiplier - { - ACTOR_DEPTH_MULTIPLIER = 1000000, - }; +enum ActorDepthMultiplier +{ + ACTOR_DEPTH_MULTIPLIER = 1000000, +}; - /** +/** * @brief SIBLING_ORDER_MULTIPLIER is used by the rendering sorting algorithm to decide which actors to render first. * @SINCE_1_2.16 */ - enum SiblingOrderMultiplier - { - SIBLING_ORDER_MULTIPLIER = 1000, - }; +enum SiblingOrderMultiplier +{ + SIBLING_ORDER_MULTIPLIER = 1000, +}; -} +} // namespace DevelLayer -} +} // namespace Dali -#endif //DALI_LAYER_DEVEL_H +#endif //DALI_LAYER_DEVEL_H diff --git a/dali/devel-api/addons/addon-base.h b/dali/devel-api/addons/addon-base.h index f3c3279..e4fe1de 100644 --- a/dali/devel-api/addons/addon-base.h +++ b/dali/devel-api/addons/addon-base.h @@ -18,15 +18,14 @@ * */ -#include #include +#include #include namespace Dali { namespace AddOns { - /** * @class AddOnBase * @@ -37,7 +36,6 @@ namespace AddOns class AddOnBase { protected: - /** * @brief Constructor */ @@ -47,7 +45,6 @@ protected: } public: - /** * @brief Destructor */ @@ -57,7 +54,7 @@ public: * @brief Retrieves AddOn info * @param[out] addonInfo AddOnInfo structure to fill by the function */ - virtual void GetAddOnInfo( Dali::AddOnInfo& addonInfo ) = 0; + virtual void GetAddOnInfo(Dali::AddOnInfo& addonInfo) = 0; /** * @brief Returns a dispatch table for global functions. @@ -75,25 +72,33 @@ public: * @brief OnStart event. * It's optional and should be implemented by the AddOn when it's required to handle the event. */ - virtual void OnStart() {} + virtual void OnStart() + { + } /** * @brief OnResume event. * It's optional and should be implemented by the AddOn when it's required to handle the event. */ - virtual void OnResume() {} + virtual void OnResume() + { + } /** * @brief OnPause event. * It's optional and should be implemented by the AddOn when it's required to handle the event. */ - virtual void OnPause() {} + virtual void OnPause() + { + } /** * @brief OnStop event. * It's optional and should be implemented by the AddOn when it's required to handle the event. */ - virtual void OnStop() {} + virtual void OnStop() + { + } /** * @brief Getter of static singleton @@ -105,7 +110,6 @@ public: } private: - static AddOnBase* mSingleton; }; @@ -121,10 +125,10 @@ extern Dali::AddOns::AddOnBase* CreateAddOn(); * @param[out] info Reference to AddOnInfo structure */ template -void GetAddOnInfo( Dali::AddOnInfo& info ) +void GetAddOnInfo(Dali::AddOnInfo& info) { auto* addon = Dali::AddOns::AddOnBase::Get(); - addon->GetAddOnInfo( info ); + addon->GetAddOnInfo(info); } /** @@ -133,25 +137,25 @@ void GetAddOnInfo( Dali::AddOnInfo& info ) * @return Valid pointer or nullptr if function not found. */ template -void* GetGlobalProc( const char* funcname ) +void* GetGlobalProc(const char* funcname) { - if( !funcname ) + if(!funcname) { return nullptr; } auto* addon = Dali::AddOns::AddOnBase::Get(); // AddOn must be initialised up to this point! - if( !addon ) + if(!addon) { return nullptr; } static Dali::AddOns::DispatchTable* globalDispatchTable = addon->GetGlobalDispatchTable(); - if( globalDispatchTable ) + if(globalDispatchTable) { - return globalDispatchTable->Find( funcname ); + return globalDispatchTable->Find(funcname); } return nullptr; } @@ -162,9 +166,9 @@ void* GetGlobalProc( const char* funcname ) * @return Valid pointer or nullptr if function not found. */ template -void* GetInstanceProc( const char* funcname ) +void* GetInstanceProc(const char* funcname) { - if( !funcname ) + if(!funcname) { return nullptr; } @@ -172,16 +176,16 @@ void* GetInstanceProc( const char* funcname ) auto* addon = Dali::AddOns::AddOnBase::Get(); // AddOn must be initialised up to this point! - if( !addon ) + if(!addon) { return nullptr; } static Dali::AddOns::DispatchTable* instanceDispatchTable = addon->GetInstanceDispatchTable(); - if( instanceDispatchTable ) + if(instanceDispatchTable) { - return instanceDispatchTable->Find( funcname ); + return instanceDispatchTable->Find(funcname); } return nullptr; } @@ -226,7 +230,7 @@ inline void AddOnConstructorInternal() auto* addon = Dali::AddOns::CreateAddOn(); Dali::AddOnInfo info{}; - addon->GetAddOnInfo( info ); + addon->GetAddOnInfo(info); // Generate dispatch tables addon->GetGlobalDispatchTable(); @@ -234,17 +238,17 @@ inline void AddOnConstructorInternal() // Bind basic functions Dali::AddOnDispatchTable table; - table.name = info.name; - table.GetAddOnInfo = GetAddOnInfo; - table.GetGlobalProc = GetGlobalProc; + table.name = info.name; + table.GetAddOnInfo = GetAddOnInfo; + table.GetGlobalProc = GetGlobalProc; table.GetInstanceProc = GetInstanceProc; - table.OnStart = OnStart; - table.OnStop = OnStop; - table.OnResume = OnResume; - table.OnPause = OnPause; + table.OnStart = OnStart; + table.OnStop = OnStop; + table.OnResume = OnResume; + table.OnPause = OnPause; // Register dispatch table - Dali::Integration::AddOnManager::Get()->RegisterAddOnDispatchTable( &table ); + Dali::Integration::AddOnManager::Get()->RegisterAddOnDispatchTable(&table); } } // namespace AddOns @@ -255,16 +259,21 @@ inline void AddOnConstructorInternal() * Note: The macro requires GCC/Clang compiler and currently only Linux-based environment * is supported. */ -#define REGISTER_ADDON_CLASS( ADDON_CLASS_WITH_FULL_NAMESPACE ) \ -namespace Dali { namespace AddOns { \ -__attribute__((constructor)) void AddOnConstructor() { \ - AddOnConstructorInternal();\ -}\ -AddOnBase* AddOnBase::mSingleton = nullptr; \ -AddOnBase* CreateAddOn() \ -{\ - return new ADDON_CLASS_WITH_FULL_NAMESPACE();\ -}\ -}} +#define REGISTER_ADDON_CLASS(ADDON_CLASS_WITH_FULL_NAMESPACE) \ + namespace Dali \ + { \ + namespace AddOns \ + { \ + __attribute__((constructor)) void AddOnConstructor() \ + { \ + AddOnConstructorInternal(); \ + } \ + AddOnBase* AddOnBase::mSingleton = nullptr; \ + AddOnBase* CreateAddOn() \ + { \ + return new ADDON_CLASS_WITH_FULL_NAMESPACE(); \ + } \ + } \ + } #endif // DALI_ADDON_BASE_H diff --git a/dali/devel-api/addons/addon-dispatch-table.h b/dali/devel-api/addons/addon-dispatch-table.h index 1699a5c..8e326d1 100644 --- a/dali/devel-api/addons/addon-dispatch-table.h +++ b/dali/devel-api/addons/addon-dispatch-table.h @@ -18,11 +18,14 @@ * */ +#include +#include +#include + namespace Dali { namespace AddOns { - /** * DispatchTable contains essential function pointers * needed to register the AddOn with AddOnManager. @@ -42,25 +45,25 @@ struct DispatchTable * @return Reference to self */ template - Entry &operator=(T funcPtr) + Entry& operator=(T funcPtr) { - functionPtr = reinterpret_cast( funcPtr ); - if (index < 0) + functionPtr = reinterpret_cast(funcPtr); + if(index < 0) { index = int32_t(table->entries.size()); table->entries.emplace_back(*this); } else { - table->entries[index].functionPtr = reinterpret_cast( funcPtr ); + table->entries[index].functionPtr = reinterpret_cast(funcPtr); } return *this; } - std::string functionName{}; ///< Name of function - void* functionPtr{nullptr}; ///< Function pointer - DispatchTable* table{nullptr}; ///< DispatchTable associated with entry - int32_t index = -1; ///< Index within the dispatch table + std::string functionName{}; ///< Name of function + void* functionPtr{nullptr}; ///< Function pointer + DispatchTable* table{nullptr}; ///< DispatchTable associated with entry + int32_t index = -1; ///< Index within the dispatch table }; /** @@ -68,17 +71,17 @@ struct DispatchTable * @param[in] functionName name of function * @return Returns Entry object */ - Entry operator[](const char *functionName) + Entry operator[](const char* functionName) { - auto iter = std::find_if(entries.begin(), entries.end(), [functionName](Entry &entry) - { - if (entry.functionName == functionName) + auto iter = std::find_if(entries.begin(), entries.end(), [functionName](Entry& entry) { + if(entry.functionName == functionName) { return true; } return false; }); - if (iter == entries.end()) + + if(iter == entries.end()) { Entry retval; retval.table = this; @@ -111,25 +114,24 @@ struct DispatchTable * @param[in] funcName Name of function * @return valid pointer or nullptr if function not found */ - FunctionPointer Find(const char *funcName) + FunctionPointer Find(const char* funcName) { - if (entries.empty()) + if(entries.empty()) { return nullptr; } - auto iter = std::find_if(entries.begin(), entries.end(), [funcName, entries = &this->entries](Entry &entry) - { + auto iter = std::find_if(entries.begin(), entries.end(), [funcName, entries = &this->entries](Entry& entry) { return (entry.functionName == funcName); }); - if (iter != entries.end()) + if(iter != entries.end()) { return iter->functionPtr; } return nullptr; } - std::vector entries; + std::vector entries; }; } // namespace AddOns diff --git a/dali/devel-api/animation/animation-data.cpp b/dali/devel-api/animation/animation-data.cpp index bd8c067..844240a 100644 --- a/dali/devel-api/animation/animation-data.cpp +++ b/dali/devel-api/animation/animation-data.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -20,8 +20,6 @@ namespace Dali { - - AnimationData::AnimationData() { } @@ -31,44 +29,42 @@ AnimationData::~AnimationData() Clear(); } - -void AnimationData::Add( AnimationDataElement* animationDataElement ) +void AnimationData::Add(AnimationDataElement* animationDataElement) { - mAnimationDataList.PushBack( animationDataElement ); + mAnimationDataList.PushBack(animationDataElement); } - -Dali::Animation AnimationData::CreateAnimation( Dali::Actor targetActor, float duration ) +Dali::Animation AnimationData::CreateAnimation(Dali::Actor targetActor, float duration) { Dali::Animation animation; - if( mAnimationDataList.Size() > 0 ) + if(mAnimationDataList.Size() > 0) { - animation = Dali::Animation::New( duration ); + animation = Dali::Animation::New(duration); // Setup an Animation from AnimationData. AnimationData::AnimationDataList::Iterator end = mAnimationDataList.End(); - for( AnimationData::AnimationDataList::Iterator iter = mAnimationDataList.Begin(); iter != end; ++iter ) + for(AnimationData::AnimationDataList::Iterator iter = mAnimationDataList.Begin(); iter != end; ++iter) { // Override the actor in the animation. - animation.AnimateTo( Property( targetActor, ( *iter )->property ), ( *iter )->value, - ( *iter )->alphaFunction, TimePeriod( ( *iter )->timePeriodDelay, ( *iter )->timePeriodDuration ) ); + animation.AnimateTo(Property(targetActor, (*iter)->property), + (*iter)->value, + (*iter)->alphaFunction, + TimePeriod((*iter)->timePeriodDelay, (*iter)->timePeriodDuration)); } } return animation; } - void AnimationData::Clear() { AnimationData::AnimationDataList::Iterator end = mAnimationDataList.End(); - for( AnimationData::AnimationDataList::Iterator iter = mAnimationDataList.Begin(); iter != end; ++iter ) + for(AnimationData::AnimationDataList::Iterator iter = mAnimationDataList.Begin(); iter != end; ++iter) { - delete ( *iter ); + delete(*iter); } mAnimationDataList.Clear(); } - } // namespace Dali diff --git a/dali/devel-api/animation/animation-data.h b/dali/devel-api/animation/animation-data.h index de8e06f..00e5bd4 100644 --- a/dali/devel-api/animation/animation-data.h +++ b/dali/devel-api/animation/animation-data.h @@ -2,7 +2,7 @@ #define DALI_ANIMATION_DATA_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -30,7 +30,6 @@ namespace Dali { - /** * @brief This object stores description data that can be used to generate an Animation. * This data can be produced from passing JSON. @@ -40,7 +39,6 @@ namespace Dali class DALI_CORE_API AnimationData { public: - AnimationData(); ~AnimationData(); @@ -50,22 +48,21 @@ public: */ struct AnimationDataElement { - std::string actor; - std::string property; - Property::Value value; + std::string actor; + std::string property; + Property::Value value; AlphaFunction::BuiltinFunction alphaFunction; - float timePeriodDelay; - float timePeriodDuration; + float timePeriodDelay; + float timePeriodDuration; AnimationDataElement() - : alphaFunction( AlphaFunction::DEFAULT ), - timePeriodDelay( 0.0f ), - timePeriodDuration( 1.0f ) + : alphaFunction(AlphaFunction::DEFAULT), + timePeriodDelay(0.0f), + timePeriodDuration(1.0f) { } }; - /** * @brief AnimationData holds the required data required to define an * animation to be performed on an actor or actors. @@ -77,8 +74,7 @@ public: * @param[in] animationDataElement A pre-populated struct to add * @note This class takes ownership of animationDataElement */ - void Add( AnimationDataElement* animationDataElement ); - + void Add(AnimationDataElement* animationDataElement); /** * @brief Creates a Dali::Animation from this AnimationData object. @@ -90,8 +86,7 @@ public: * @param[in] duration The duration of the animation to create. * @return A ready-to-go Dali::Animation, or an invalid handle if there was no data. */ - Dali::Animation CreateAnimation( Dali::Actor targetActor, float duration ); - + Dali::Animation CreateAnimation(Dali::Actor targetActor, float duration); /** * @brief Empties this AnimationData object (and frees all memory). @@ -99,13 +94,9 @@ public: void Clear(); private: - AnimationDataList mAnimationDataList; ///< A vector of individual property animations from which to generate a Dali::Animation. - }; - } // namespace Dali #endif // DALI_ANIMATION_DATA_H - diff --git a/dali/devel-api/animation/animation-devel.cpp b/dali/devel-api/animation/animation-devel.cpp index 4fba68b..83a442a 100644 --- a/dali/devel-api/animation/animation-devel.cpp +++ b/dali/devel-api/animation/animation-devel.cpp @@ -18,28 +18,26 @@ // INTERNAL INCLUDES #include #include -#include #include +#include namespace Dali { - namespace DevelAnimation { - -void SetProgressNotification( Animation animation, float progress ) +void SetProgressNotification(Animation animation, float progress) { - GetImplementation(animation).SetProgressNotification( progress ); + GetImplementation(animation).SetProgressNotification(progress); } -float GetProgressNotification( Animation animation ) +float GetProgressNotification(Animation animation) { return GetImplementation(animation).GetProgressNotification(); } -Animation::AnimationSignalType& ProgressReachedSignal( Animation animation ) +Animation::AnimationSignalType& ProgressReachedSignal(Animation animation) { - return GetImplementation( animation ).ProgressReachedSignal(); + return GetImplementation(animation).ProgressReachedSignal(); } uint32_t GetAnimationCount() @@ -48,10 +46,10 @@ uint32_t GetAnimationCount() return tls.GetAnimationPlaylist().GetAnimationCount(); } -Animation GetAnimationAt( uint32_t index ) +Animation GetAnimationAt(uint32_t index) { Dali::Internal::ThreadLocalStorage& tls = Dali::Internal::ThreadLocalStorage::Get(); - return tls.GetAnimationPlaylist().GetAnimationAt( index ); + return tls.GetAnimationPlaylist().GetAnimationAt(index); } } // namespace DevelAnimation diff --git a/dali/devel-api/animation/animation-devel.h b/dali/devel-api/animation/animation-devel.h index b7b6019..6db8a88 100644 --- a/dali/devel-api/animation/animation-devel.h +++ b/dali/devel-api/animation/animation-devel.h @@ -23,17 +23,15 @@ namespace Dali { - namespace DevelAnimation { - /** * @brief Set progress percentage marker to trigger ProgressHasBeenReachedSignal * * @param[in] animation the animation object to perform this operation on * @param[in] progress the progress percentage to trigger the signal at, e.g .3 for 30%. */ -DALI_CORE_API void SetProgressNotification( Animation animation, float progress ); +DALI_CORE_API void SetProgressNotification(Animation animation, float progress); /** * @brief Get progress percentage marker that has been set to trigger ProgressHasBeenReachedSignal @@ -41,14 +39,14 @@ DALI_CORE_API void SetProgressNotification( Animation animation, float progress * @param[in] animation the animation object to perform this operation on * @return the percentage to trigger at eg 0.3 for 30% */ -DALI_CORE_API float GetProgressNotification( Animation animation ); +DALI_CORE_API float GetProgressNotification(Animation animation); /** * @brief Connects to this signal to be notified when an Animation's animations have reached set progress. * * @return A signal object to connect with */ -DALI_CORE_API Animation::AnimationSignalType& ProgressReachedSignal( Animation animation ); +DALI_CORE_API Animation::AnimationSignalType& ProgressReachedSignal(Animation animation); /** * @brief Retrive the number of Animations. @@ -63,7 +61,7 @@ DALI_CORE_API uint32_t GetAnimationCount(); * @param[in] index The index of the Animation to retrieve * @return The animation for the given index or empty handle */ -DALI_CORE_API Animation GetAnimationAt( uint32_t index ); +DALI_CORE_API Animation GetAnimationAt(uint32_t index); } // namespace DevelAnimation diff --git a/dali/devel-api/animation/path-constrainer.cpp b/dali/devel-api/animation/path-constrainer.cpp index cb32010..47ae9d7 100644 --- a/dali/devel-api/animation/path-constrainer.cpp +++ b/dali/devel-api/animation/path-constrainer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -24,16 +24,15 @@ namespace Dali { - PathConstrainer PathConstrainer::New() { Internal::PathConstrainer* internal = Internal::PathConstrainer::New(); return PathConstrainer(internal); } -PathConstrainer PathConstrainer::DownCast( BaseHandle handle ) +PathConstrainer PathConstrainer::DownCast(BaseHandle handle) { - return PathConstrainer( dynamic_cast(handle.GetObjectPtr()) ); + return PathConstrainer(dynamic_cast(handle.GetObjectPtr())); } PathConstrainer::PathConstrainer() @@ -45,7 +44,7 @@ PathConstrainer::~PathConstrainer() } PathConstrainer::PathConstrainer(const PathConstrainer& handle) -:Handle(handle) +: Handle(handle) { } @@ -60,15 +59,14 @@ PathConstrainer& PathConstrainer::operator=(const PathConstrainer& rhs) return *this; } -void PathConstrainer::Apply( Dali::Property target, Dali::Property source, const Vector2& range, const Vector2& wrap ) +void PathConstrainer::Apply(Dali::Property target, Dali::Property source, const Vector2& range, const Vector2& wrap) { - GetImplementation(*this).Apply( target, source, range, wrap ); + GetImplementation(*this).Apply(target, source, range, wrap); } -void PathConstrainer::Remove( Dali::Handle& target ) +void PathConstrainer::Remove(Dali::Handle& target) { - GetImplementation(*this).Remove( target ); + GetImplementation(*this).Remove(target); } - -} // Dali +} // namespace Dali diff --git a/dali/devel-api/animation/path-constrainer.h b/dali/devel-api/animation/path-constrainer.h index 2531108..3115626 100644 --- a/dali/devel-api/animation/path-constrainer.h +++ b/dali/devel-api/animation/path-constrainer.h @@ -2,7 +2,7 @@ #define DALI_PATH_CONSTRAINER_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -28,10 +28,9 @@ namespace Dali { - namespace Internal DALI_INTERNAL { - class PathConstrainer; +class PathConstrainer; } /** * @brief @@ -44,7 +43,6 @@ namespace Internal DALI_INTERNAL class DALI_CORE_API PathConstrainer : public Handle { public: - /** * @brief An enumeration of properties belonging to the PathConstrainer class. */ @@ -52,9 +50,9 @@ public: { enum { - FORWARD = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "forward" type Vector3 - POINTS, ///< name "points" type Array of Vector3 - CONTROL_POINTS ///< name "controlPoints" type Array of Vector3 + FORWARD = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "forward" type Vector3 + POINTS, ///< name "points" type Array of Vector3 + CONTROL_POINTS ///< name "controlPoints" type Array of Vector3 }; }; @@ -73,7 +71,7 @@ public: * @param[in] handle to An object * @return handle to a PathConstrainer object or an uninitialized handle */ - static PathConstrainer DownCast( BaseHandle handle ); + static PathConstrainer DownCast(BaseHandle handle); /** * @brief Create an uninitialized PathConstrainer handle. @@ -113,14 +111,14 @@ public: * @param[in] range The range of values in the source property which will be mapped to [0,1] * @param[in] wrap Wrapping domain. Source property will be wrapped in the domain [wrap.x,wrap.y] before mapping to [0,1] */ - void Apply( Dali::Property target, Dali::Property source, const Vector2& range, const Vector2& wrap = Vector2(-FLT_MAX, FLT_MAX) ); + void Apply(Dali::Property target, Dali::Property source, const Vector2& range, const Vector2& wrap = Vector2(-FLT_MAX, FLT_MAX)); /** * @brief Removes the path constraint in the target object * * @param[in] target A handle to an object constrained by the PathConstrainer */ - void Remove( Dali::Handle& target ); + void Remove(Dali::Handle& target); public: // Not intended for application developers /** diff --git a/dali/devel-api/common/addon-binder.cpp b/dali/devel-api/common/addon-binder.cpp index 3f56e79..ee1a8aa 100644 --- a/dali/devel-api/common/addon-binder.cpp +++ b/dali/devel-api/common/addon-binder.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -18,10 +18,8 @@ namespace Dali { - namespace AddOn { - Dali::Integration::AddOnManager* AddOnBinder::mAddOnManager = nullptr; } // namespace AddOn diff --git a/dali/devel-api/common/addon-binder.h b/dali/devel-api/common/addon-binder.h index b43a90e..86086b4 100644 --- a/dali/devel-api/common/addon-binder.h +++ b/dali/devel-api/common/addon-binder.h @@ -23,7 +23,6 @@ namespace Dali { namespace AddOn { - /** * Class automates binding an AddOn interface. * @@ -65,19 +64,18 @@ namespace AddOn class AddOnBinder { public: - /** * @brief Constructor. Opens an AddOn and creates interface * @param[in] addonName Name of AddOn * @param[in] version Version of AddOn */ - explicit AddOnBinder( const char* addonName, uint32_t version = 0u ) + explicit AddOnBinder(const char* addonName, uint32_t version = 0u) { mAddOnManager = Dali::Integration::AddOnManager::Get(); - if (mAddOnManager) + if(mAddOnManager) { mAddOnHandle = mAddOnManager->GetAddOn(addonName); - if (mAddOnHandle) + if(mAddOnHandle) { mAddOnManager->GetAddOnInfo(addonName, mAddOnInfo); } @@ -95,7 +93,7 @@ public: * @return Returns a new pointer */ template - T* ConvertFunction( const std::string& funcName ) + T* ConvertFunction(const std::string& funcName) { if(mAddOnHandle) { @@ -119,9 +117,9 @@ public: * @param[in] name Name of the function * @return Valid pointer or nullptr */ - void* GetGlobalProc( const char* name ) + void* GetGlobalProc(const char* name) { - return mAddOnManager ? mAddOnManager->GetGlobalProc( mAddOnHandle, name ) : nullptr; + return mAddOnManager ? mAddOnManager->GetGlobalProc(mAddOnHandle, name) : nullptr; } /** @@ -129,9 +127,9 @@ public: * @param[in] name Name of the function * @return Valid pointer or nullptr */ - void* GetInstanceProc( const char* name ) + void* GetInstanceProc(const char* name) { - return mAddOnManager ? mAddOnManager->GetInstanceProc( mAddOnHandle, name ) : nullptr; + return mAddOnManager ? mAddOnManager->GetInstanceProc(mAddOnHandle, name) : nullptr; } /** @@ -153,14 +151,12 @@ public: } protected: - static DALI_CORE_API Dali::Integration::AddOnManager* mAddOnManager; ///< Pointer to the AddOn manager - Dali::AddOnLibrary mAddOnHandle { nullptr }; ///< Handle to the AddOn library - Dali::AddOnInfo mAddOnInfo {}; ///< Stored AddOnInfo structure + Dali::AddOnLibrary mAddOnHandle{nullptr}; ///< Handle to the AddOn library + Dali::AddOnInfo mAddOnInfo{}; ///< Stored AddOnInfo structure }; - /** * Macro binds function as a member function of the class, for example, the call: * @@ -168,8 +164,8 @@ protected: * * will create a std::function object named SomeAddOnFunction and bound to the AddOn library. */ -#define ADDON_BIND_FUNCTION( FUNCNAME, FUNCTYPE ) \ -std::function FUNCNAME{ConvertFunction( std::string(#FUNCNAME) )}; +#define ADDON_BIND_FUNCTION(FUNCNAME, FUNCTYPE) \ + std::function FUNCNAME{ConvertFunction(std::string(#FUNCNAME))}; } // namespace AddOn } // namespace Dali diff --git a/dali/devel-api/common/bitwise-enum.h b/dali/devel-api/common/bitwise-enum.h index 2717a92..b382d49 100644 --- a/dali/devel-api/common/bitwise-enum.h +++ b/dali/devel-api/common/bitwise-enum.h @@ -2,7 +2,7 @@ #define DALI_BITWISE_ENUM_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -21,7 +21,6 @@ namespace Dali { - /** * Type traits and methods to enable type safe bit field operators for an enum. * usage: @@ -32,7 +31,7 @@ namespace Dali * if( myFlag & FLAG2 ) * // do something */ -template< typename Enum > +template struct EnableBitMaskOperators { static const bool ENABLE = false; // can't be constexpr as it's a data member @@ -44,11 +43,11 @@ struct EnableBitMaskOperators * @param rhs bitfield to or * @return EnumType with both flags set */ -template < typename EnumType > -inline typename std::enable_if< EnableBitMaskOperators< EnumType >::ENABLE, EnumType >::type operator|( EnumType lhs, EnumType rhs ) +template +inline typename std::enable_if::ENABLE, EnumType>::type operator|(EnumType lhs, EnumType rhs) { using UnderlyingType = typename std::underlying_type::type; - return static_cast( static_cast( lhs ) | static_cast(rhs ) ); + return static_cast(static_cast(lhs) | static_cast(rhs)); } /** @@ -57,11 +56,11 @@ inline typename std::enable_if< EnableBitMaskOperators< EnumType >::ENABLE, Enum * @param rhs bitfield to or * @return reference to lhs with both flags set */ -template < typename EnumType > -inline typename std::enable_if< EnableBitMaskOperators< EnumType >::ENABLE, EnumType& >::type operator|=( EnumType& lhs, EnumType rhs ) +template +inline typename std::enable_if::ENABLE, EnumType&>::type operator|=(EnumType& lhs, EnumType rhs) { using UnderlyingType = typename std::underlying_type::type; - lhs = static_cast(static_cast( lhs ) | static_cast( rhs ) ); + lhs = static_cast(static_cast(lhs) | static_cast(rhs)); return lhs; } @@ -71,11 +70,11 @@ inline typename std::enable_if< EnableBitMaskOperators< EnumType >::ENABLE, Enum * @param rhs bitfield to AND * @return true if at least one flag is same in both */ -template < typename EnumType > -inline typename std::enable_if< EnableBitMaskOperators< EnumType >::ENABLE, bool >::type operator&( EnumType lhs, EnumType rhs ) +template +inline typename std::enable_if::ENABLE, bool>::type operator&(EnumType lhs, EnumType rhs) { using UnderlyingType = typename std::underlying_type::type; - return static_cast( static_cast( lhs ) & static_cast(rhs ) ); + return static_cast(static_cast(lhs) & static_cast(rhs)); } } // namespace Dali diff --git a/dali/devel-api/common/circular-queue.h b/dali/devel-api/common/circular-queue.h index 589bdaa..25b6c1e 100644 --- a/dali/devel-api/common/circular-queue.h +++ b/dali/devel-api/common/circular-queue.h @@ -2,7 +2,7 @@ #define DALI_CIRCULAR_QUEUE_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -20,13 +20,12 @@ namespace Dali { - /** * Class to provide a circular growable queue on top of Dali::Vector * It is designed to occupy a fixed block of memory. It does not allow * addition of elements past the start; i.e. it doesn't overwrite. */ -template +template class CircularQueue { public: @@ -36,7 +35,7 @@ public: * Constructor * @param[in] maximumSize The maximum number of elements that the queue can contain */ - CircularQueue( int maximumSize ) + CircularQueue(int maximumSize) : mMaximumSize(maximumSize), mStartMarker(0), mEndMarker(0), @@ -56,14 +55,14 @@ public: ElementType& operator[](unsigned int index) { unsigned int actualIndex = (mStartMarker + index) % mMaximumSize; - DALI_ASSERT_ALWAYS( actualIndex 1 ) + else if(mNumberOfElements > 1) { element = mQueue[mStartMarker]; ++mStartMarker; @@ -133,25 +132,25 @@ public: ElementType& Front() { - DALI_ASSERT_ALWAYS( !IsEmpty() && "Reading from empty queue" ); + DALI_ASSERT_ALWAYS(!IsEmpty() && "Reading from empty queue"); return mQueue[mStartMarker]; } const ElementType& Front() const { - DALI_ASSERT_ALWAYS( !IsEmpty() && "Reading from empty queue" ); + DALI_ASSERT_ALWAYS(!IsEmpty() && "Reading from empty queue"); return mQueue[mStartMarker]; } ElementType& Back() { - DALI_ASSERT_ALWAYS( !IsEmpty() && "Reading from empty queue" ); + DALI_ASSERT_ALWAYS(!IsEmpty() && "Reading from empty queue"); return mQueue[mEndMarker]; } const ElementType& Back() const { - DALI_ASSERT_ALWAYS( !IsEmpty() && "Reading from empty queue" ); + DALI_ASSERT_ALWAYS(!IsEmpty() && "Reading from empty queue"); return mQueue[mEndMarker]; } @@ -172,9 +171,9 @@ public: */ bool IsFull() const { - return ( mQueue.Count() == mMaximumSize && - mNumberOfElements > 0 && - (mEndMarker + 1) % mMaximumSize == mStartMarker ); + return (mQueue.Count() == mMaximumSize && + mNumberOfElements > 0 && + (mEndMarker + 1) % mMaximumSize == mStartMarker); } /** @@ -195,6 +194,6 @@ private: int mNumberOfElements; ///< Number of valid elements in the queue }; -} // Dali +} // namespace Dali #endif // DALI_CIRCULAR_QUEUE_H diff --git a/dali/devel-api/common/hash.cpp b/dali/devel-api/common/hash.cpp index 3b8b3bd..cc2740f 100644 --- a/dali/devel-api/common/hash.cpp +++ b/dali/devel-api/common/hash.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -20,17 +20,15 @@ namespace Dali { - namespace //unnamed namespace { - /* * djb2 (http://www.cse.yorku.ca/~oz/hash.html) */ -inline void HashString( const char* string, std::size_t& hash ) +inline void HashString(const char* string, std::size_t& hash) { - while( int c = *string++ ) + while(int c = *string++) { hash = hash * 33 + c; } @@ -38,21 +36,21 @@ inline void HashString( const char* string, std::size_t& hash ) } // unnamed namespace -std::size_t CalculateHash( const std::string& toHash) +std::size_t CalculateHash(const std::string& toHash) { - std::size_t hash( INITIAL_HASH_VALUE ); + std::size_t hash(INITIAL_HASH_VALUE); - HashString( toHash.c_str(), hash ); + HashString(toHash.c_str(), hash); return hash; } -std::size_t CalculateHash( const std::string& string1, const std::string& string2 ) +std::size_t CalculateHash(const std::string& string1, const std::string& string2) { - std::size_t hash( INITIAL_HASH_VALUE ); + std::size_t hash(INITIAL_HASH_VALUE); - HashString( string1.c_str(), hash); - HashString( string2.c_str(), hash ); + HashString(string1.c_str(), hash); + HashString(string2.c_str(), hash); return hash; } diff --git a/dali/devel-api/common/hash.h b/dali/devel-api/common/hash.h index 3d4ae62..94ccad7 100644 --- a/dali/devel-api/common/hash.h +++ b/dali/devel-api/common/hash.h @@ -2,7 +2,7 @@ #define DALI_HASH /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -26,7 +26,6 @@ namespace Dali { - enum { INITIAL_HASH_VALUE = 5381 @@ -37,7 +36,7 @@ enum * @param toHash string to hash * @return hash code */ -DALI_CORE_API std::size_t CalculateHash( const std::string& toHash ); +DALI_CORE_API std::size_t CalculateHash(const std::string& toHash); /** * @brief Create a hash code for 2 strings combined. @@ -46,7 +45,7 @@ DALI_CORE_API std::size_t CalculateHash( const std::string& toHash ); * @param string2 second string * @return hash code */ -DALI_CORE_API std::size_t CalculateHash( const std::string& string1, const std::string& string2 ); +DALI_CORE_API std::size_t CalculateHash(const std::string& string1, const std::string& string2); } // namespace Dali diff --git a/dali/devel-api/common/map-wrapper.h b/dali/devel-api/common/map-wrapper.h index c02dd39..a88d423 100644 --- a/dali/devel-api/common/map-wrapper.h +++ b/dali/devel-api/common/map-wrapper.h @@ -2,7 +2,7 @@ #define DALI_MAP_WRAPPER_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -39,7 +39,7 @@ #include #undef _LIBCPP_INLINE_VISIBILITY -#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__)) +#define _LIBCPP_INLINE_VISIBILITY __attribute__((__visibility__("hidden"), __always_inline__)) #undef _LIBCPP_EXTERN_TEMPLATE #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; @@ -49,13 +49,13 @@ #include #undef _GLIBCXX_VISIBILITY_ATTR #undef _GLIBCXX_VISIBILITY -#define _GLIBCXX_VISIBILITY_ATTR(V) __attribute__ ((__visibility__ ("hidden"))) -#define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ ("hidden"))) +#define _GLIBCXX_VISIBILITY_ATTR(V) __attribute__((__visibility__("hidden"))) +#define _GLIBCXX_VISIBILITY(V) __attribute__((__visibility__("hidden"))) #include #undef _GLIBCXX_VISIBILITY_ATTR #undef _GLIBCXX_VISIBILITY -#define _GLIBCXX_VISIBILITY_ATTR(V) __attribute__ ((__visibility__ (#V))) // restore `_GLIBCXX_VISIBILITY_ATTR` -#define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V))) // restore `_GLIBCXX_VISIBILITY` +#define _GLIBCXX_VISIBILITY_ATTR(V) __attribute__((__visibility__(#V))) // restore `_GLIBCXX_VISIBILITY_ATTR` +#define _GLIBCXX_VISIBILITY(V) __attribute__((__visibility__(#V))) // restore `_GLIBCXX_VISIBILITY` #endif // #ifdef __clang__ diff --git a/dali/devel-api/common/owner-container.h b/dali/devel-api/common/owner-container.h index c6be817..d276cd7 100644 --- a/dali/devel-api/common/owner-container.h +++ b/dali/devel-api/common/owner-container.h @@ -24,7 +24,6 @@ namespace Dali { - /** * OwnerContainer is a vector which own heap-allocated objects. * Unlike vector this will call delete on the stored pointers during destruction. @@ -38,8 +37,8 @@ namespace Dali * * @endcode */ -template< class T > -class OwnerContainer : public Dali::Vector< T > +template +class OwnerContainer : public Dali::Vector { public: using SizeType = typename Dali::Vector::SizeType; @@ -50,7 +49,8 @@ public: * Create a pointer-container. */ OwnerContainer() - { } + { + } /** * Non-virtual destructor; OwnerContainer is not suitable as base class. @@ -62,10 +62,10 @@ public: } // Not copyable or movable - OwnerContainer( const OwnerContainer& ) = delete; ///< Deleted copy constructor - OwnerContainer( OwnerContainer&& ) = delete; ///< Deleted move constructor - OwnerContainer& operator=( const OwnerContainer& ) = delete; ///< Deleted copy assignment operator - OwnerContainer& operator=( OwnerContainer&& ) = delete; ///< Deleted move assignment operator + OwnerContainer(const OwnerContainer&) = delete; ///< Deleted copy constructor + OwnerContainer(OwnerContainer&&) = delete; ///< Deleted move constructor + OwnerContainer& operator=(const OwnerContainer&) = delete; ///< Deleted copy assignment operator + OwnerContainer& operator=(OwnerContainer&&) = delete; ///< Deleted move assignment operator /** * Test whether the container is empty. @@ -81,27 +81,27 @@ public: * @param[in] position A dereferencable iterator to an element in mContainer. * @return iterator pointing to next element */ - Iterator Erase( Iterator position ) + Iterator Erase(Iterator position) { - Delete (*position); - return Vector< T >::Erase( position ); + Delete(*position); + return Vector::Erase(position); } /** * Erase an object from OwnerContainer * @param object to remove */ - inline void EraseObject( T object ) + inline void EraseObject(T object) { - DALI_ASSERT_DEBUG( object && "NULL object not allowed" ); + DALI_ASSERT_DEBUG(object && "NULL object not allowed"); - Iterator iter = Vector< T >::Begin(); - const ConstIterator endIter = Vector< T >::End(); - for ( ; iter != endIter; ++iter ) + Iterator iter = Vector::Begin(); + const ConstIterator endIter = Vector::End(); + for(; iter != endIter; ++iter) { - if ( *iter == object ) + if(*iter == object) { - Erase( iter ); + Erase(iter); return; } } @@ -113,10 +113,10 @@ public: * @post iterators are invalidated by this method. * @return pointer to the released item */ - T Release( Iterator position ) + T Release(Iterator position) { T pointer = *position; - Vector< T >::Erase( position ); + Vector::Erase(position); return pointer; } @@ -125,30 +125,30 @@ public: */ void Clear() { - ConstIterator end = Vector< T >::End(); - for( Iterator iter = Vector< T >::Begin(); iter != end; ++iter ) + ConstIterator end = Vector::End(); + for(Iterator iter = Vector::Begin(); iter != end; ++iter) { - Delete (*iter); + Delete(*iter); } - Vector< T >::Clear(); + Vector::Clear(); } /** * Resizes the container to hold specific amount of elements * @param size to resize to */ - void Resize( SizeType size ) + void Resize(SizeType size) { - if( size < VectorBase::Count() ) + if(size < VectorBase::Count()) { // OwnerContainer owns these heap-allocated objects - ConstIterator end = Vector< T >::End(); - for( Iterator iter = Vector< T >::Begin() + size; iter != end; ++iter ) + ConstIterator end = Vector::End(); + for(Iterator iter = Vector::Begin() + size; iter != end; ++iter) { - Delete (*iter); + Delete(*iter); } } - Vector< T >::Resize( size ); + Vector::Resize(size); } /** @@ -156,47 +156,44 @@ public: * without deleting them. It will keep the original items here as well. * @param[in] source where to move elements from to this OwnerContainer */ - void MoveFrom( OwnerContainer& source ) + void MoveFrom(OwnerContainer& source) { - typename Vector< T >::SizeType sourceCount = source.Count(); + typename Vector::SizeType sourceCount = source.Count(); // if source is empty, nothing to move - if( sourceCount > 0u ) + if(sourceCount > 0u) { // Optimisation for the case that this is empty - if( IsEmpty() ) + if(IsEmpty()) { - VectorBase::Swap( source ); + VectorBase::Swap(source); } else { // make space for new items - Vector< T >::Reserve( VectorBase::Count() + sourceCount ); - Iterator iter = source.Begin(); - ConstIterator end = source.End(); - for( ; iter != end; ++iter ) + Vector::Reserve(VectorBase::Count() + sourceCount); + Iterator iter = source.Begin(); + ConstIterator end = source.End(); + for(; iter != end; ++iter) { T pointer = *iter; - Vector< T >::PushBack( pointer ); + Vector::PushBack(pointer); } // cannot call Clear on OwnerContainer as that deletes the elements - source.Vector< T >::Clear(); + source.Vector::Clear(); } } } private: - /** * @brief delete the contents of the pointer * Function provided to allow classes to provide a custom destructor through template specialisation * @param pointer to the object */ - void Delete( T pointer ) + void Delete(T pointer) { delete pointer; } - - }; } // namespace Dali diff --git a/dali/devel-api/common/ref-counted-dali-vector.h b/dali/devel-api/common/ref-counted-dali-vector.h index 0c869c7..892cda4 100644 --- a/dali/devel-api/common/ref-counted-dali-vector.h +++ b/dali/devel-api/common/ref-counted-dali-vector.h @@ -24,7 +24,6 @@ namespace Dali { - /** * @brief A reference counting wrapper for a vector class that allows * a set of referencing smart pointers to collaborate in managing its @@ -34,7 +33,7 @@ namespace Dali * stack. * @tparam T type of the data that the vector holds */ -template< typename T > +template class RefCountedVector : public RefObject { public: @@ -50,16 +49,16 @@ public: * * @return A reference to the vector that this object wraps. */ - Vector< T >& GetVector() + Vector& GetVector() { return mVector; } // Not copyable or movable - RefCountedVector( const RefCountedVector& ) = delete; ///< Deleted copy constructor - RefCountedVector( RefCountedVector&& ) = delete; ///< Deleted move constructor - RefCountedVector& operator=( const RefCountedVector& ) = delete; ///< Deleted copy assignment operator - RefCountedVector& operator=( RefCountedVector&& ) = delete; ///< Deleted move assignment operator + RefCountedVector(const RefCountedVector&) = delete; ///< Deleted copy constructor + RefCountedVector(RefCountedVector&&) = delete; ///< Deleted move constructor + RefCountedVector& operator=(const RefCountedVector&) = delete; ///< Deleted copy assignment operator + RefCountedVector& operator=(RefCountedVector&&) = delete; ///< Deleted move assignment operator protected: virtual ~RefCountedVector() @@ -67,8 +66,7 @@ protected: } private: - - Vector< T > mVector; ///< The vector of data + Vector mVector; ///< The vector of data }; } // namespace Dali diff --git a/dali/devel-api/common/set-wrapper.h b/dali/devel-api/common/set-wrapper.h index 13ad9f1..f6dbb66 100644 --- a/dali/devel-api/common/set-wrapper.h +++ b/dali/devel-api/common/set-wrapper.h @@ -2,7 +2,7 @@ #define DALI_SET_WRAPPER_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -39,7 +39,7 @@ #include #undef _LIBCPP_INLINE_VISIBILITY -#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__)) +#define _LIBCPP_INLINE_VISIBILITY __attribute__((__visibility__("hidden"), __always_inline__)) #undef _LIBCPP_EXTERN_TEMPLATE #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; @@ -49,13 +49,13 @@ #include #undef _GLIBCXX_VISIBILITY_ATTR #undef _GLIBCXX_VISIBILITY -#define _GLIBCXX_VISIBILITY_ATTR(V) __attribute__ ((__visibility__ ("hidden"))) -#define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ ("hidden"))) +#define _GLIBCXX_VISIBILITY_ATTR(V) __attribute__((__visibility__("hidden"))) +#define _GLIBCXX_VISIBILITY(V) __attribute__((__visibility__("hidden"))) #include #undef _GLIBCXX_VISIBILITY_ATTR #undef _GLIBCXX_VISIBILITY -#define _GLIBCXX_VISIBILITY_ATTR(V) __attribute__ ((__visibility__ (#V))) // restore `_GLIBCXX_VISIBILITY_ATTR` -#define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V))) // restore `_GLIBCXX_VISIBILITY` +#define _GLIBCXX_VISIBILITY_ATTR(V) __attribute__((__visibility__(#V))) // restore `_GLIBCXX_VISIBILITY_ATTR` +#define _GLIBCXX_VISIBILITY(V) __attribute__((__visibility__(#V))) // restore `_GLIBCXX_VISIBILITY` #endif // #ifdef __clang__ diff --git a/dali/devel-api/common/singleton-service.cpp b/dali/devel-api/common/singleton-service.cpp index 715e3ed..49ff27e 100644 --- a/dali/devel-api/common/singleton-service.cpp +++ b/dali/devel-api/common/singleton-service.cpp @@ -23,7 +23,6 @@ namespace Dali { - SingletonService::SingletonService() { } @@ -37,23 +36,23 @@ SingletonService::~SingletonService() { } -void SingletonService::Register( const std::type_info& info, BaseHandle singleton ) +void SingletonService::Register(const std::type_info& info, BaseHandle singleton) { - GetImplementation( *this ).Register( info, singleton ); + GetImplementation(*this).Register(info, singleton); } void SingletonService::UnregisterAll() { - GetImplementation( *this ).UnregisterAll(); + GetImplementation(*this).UnregisterAll(); } -BaseHandle SingletonService::GetSingleton( const std::type_info& info ) const +BaseHandle SingletonService::GetSingleton(const std::type_info& info) const { - return GetImplementation( *this ).GetSingleton( info ); + return GetImplementation(*this).GetSingleton(info); } -SingletonService::SingletonService( Internal::ThreadLocalStorage* tls ) -: BaseHandle( tls ) +SingletonService::SingletonService(Internal::ThreadLocalStorage* tls) +: BaseHandle(tls) { } diff --git a/dali/devel-api/common/singleton-service.h b/dali/devel-api/common/singleton-service.h old mode 100755 new mode 100644 index 7677487..554b218 --- a/dali/devel-api/common/singleton-service.h +++ b/dali/devel-api/common/singleton-service.h @@ -19,12 +19,11 @@ */ // EXTERNAL INCLUDES -#include #include +#include namespace Dali { - namespace Internal DALI_INTERNAL { class ThreadLocalStorage; @@ -40,7 +39,6 @@ class ThreadLocalStorage; class DALI_CORE_API SingletonService : public BaseHandle { public: - /** * @brief Create an uninitialized handle. * @@ -72,7 +70,7 @@ public: * @param[in] info The type info of the Dali handle generated by the compiler. * @param[in] singleton The Dali handle to be registered */ - void Register( const std::type_info& info, BaseHandle singleton ); + void Register(const std::type_info& info, BaseHandle singleton); /** * @brief Unregisters all singletons. @@ -88,15 +86,14 @@ public: * @param[in] info The type info of the given type. * @return the Dali handle if it is registered as a singleton or an uninitialized handle. */ - BaseHandle GetSingleton( const std::type_info& info ) const; + BaseHandle GetSingleton(const std::type_info& info) const; public: // Not intended for application developers - /** * @brief This constructor is used by SingletonService::Get(). * @param[in] singletonService A pointer to the internal singleton-service object. */ - explicit DALI_INTERNAL SingletonService( Internal::ThreadLocalStorage* singletonService ); + explicit DALI_INTERNAL SingletonService(Internal::ThreadLocalStorage* singletonService); }; } // namespace Dali diff --git a/dali/devel-api/common/stage-devel.cpp b/dali/devel-api/common/stage-devel.cpp index 0046d40..6025e79 100644 --- a/dali/devel-api/common/stage-devel.cpp +++ b/dali/devel-api/common/stage-devel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -21,33 +21,31 @@ namespace Dali { - namespace DevelStage { - -KeyEventGeneratedSignalType& KeyEventGeneratedSignal( Dali::Stage stage ) +KeyEventGeneratedSignalType& KeyEventGeneratedSignal(Dali::Stage stage) { - return GetImplementation( stage ).KeyEventGeneratedSignal(); + return GetImplementation(stage).KeyEventGeneratedSignal(); } -void SetRenderingBehavior( Dali::Stage stage, Rendering renderingBehavior ) +void SetRenderingBehavior(Dali::Stage stage, Rendering renderingBehavior) { - GetImplementation( stage ).SetRenderingBehavior( renderingBehavior ); + GetImplementation(stage).SetRenderingBehavior(renderingBehavior); } -Rendering GetRenderingBehavior( Dali::Stage stage ) +Rendering GetRenderingBehavior(Dali::Stage stage) { - return GetImplementation( stage ).GetRenderingBehavior(); + return GetImplementation(stage).GetRenderingBehavior(); } -void AddFrameCallback( Dali::Stage stage, FrameCallbackInterface& frameCallback, Actor rootActor ) +void AddFrameCallback(Dali::Stage stage, FrameCallbackInterface& frameCallback, Actor rootActor) { - GetImplementation( stage ).AddFrameCallback( frameCallback, GetImplementation( rootActor ) ); + GetImplementation(stage).AddFrameCallback(frameCallback, GetImplementation(rootActor)); } -void RemoveFrameCallback( Dali::Stage stage, FrameCallbackInterface& frameCallback ) +void RemoveFrameCallback(Dali::Stage stage, FrameCallbackInterface& frameCallback) { - GetImplementation( stage ).RemoveFrameCallback( frameCallback ); + GetImplementation(stage).RemoveFrameCallback(frameCallback); } } // namespace DevelStage diff --git a/dali/devel-api/common/stage-devel.h b/dali/devel-api/common/stage-devel.h index fd93853..8941928 100644 --- a/dali/devel-api/common/stage-devel.h +++ b/dali/devel-api/common/stage-devel.h @@ -23,12 +23,10 @@ namespace Dali { - class FrameCallbackInterface; namespace DevelStage { - /** * @brief The DALi rendering behavior. */ @@ -38,7 +36,7 @@ enum class Rendering CONTINUOUSLY, ///< Will render continuously. }; -using KeyEventGeneratedSignalType = Signal; ///< Stage key event generated signal type +using KeyEventGeneratedSignalType = Signal; ///< Stage key event generated signal type /** * @brief The user would connect to this signal to get a KeyEvent when KeyEvent is generated. @@ -46,7 +44,7 @@ using KeyEventGeneratedSignalType = Signal; ///< Stage * @param[in] stage The stage to emit a signal * @return The return is true if KeyEvent is consumed, otherwise false. */ -DALI_CORE_API KeyEventGeneratedSignalType& KeyEventGeneratedSignal( Dali::Stage stage ); +DALI_CORE_API KeyEventGeneratedSignalType& KeyEventGeneratedSignal(Dali::Stage stage); /** * @brief Gives the user the ability to set the rendering behavior of DALi. @@ -57,7 +55,7 @@ DALI_CORE_API KeyEventGeneratedSignalType& KeyEventGeneratedSignal( Dali::Stage * @note By default, DALi uses Rendering::IF_REQUIRED. * @see Rendering */ -DALI_CORE_API void SetRenderingBehavior( Dali::Stage stage, Rendering renderingBehavior ); +DALI_CORE_API void SetRenderingBehavior(Dali::Stage stage, Rendering renderingBehavior); /** * @brief Retrieves the rendering behavior of DALi. @@ -65,7 +63,7 @@ DALI_CORE_API void SetRenderingBehavior( Dali::Stage stage, Rendering renderingB * @param[in] stage The stage * @return The rendering behavior of DALi. */ -DALI_CORE_API Rendering GetRenderingBehavior( Dali::Stage stage ); +DALI_CORE_API Rendering GetRenderingBehavior(Dali::Stage stage); /* * @brief The FrameCallbackInterface implementation added gets called on every frame from the update-thread. @@ -79,7 +77,7 @@ DALI_CORE_API Rendering GetRenderingBehavior( Dali::Stage stage ); * @note If the rootActor is destroyed, then the callback is automatically removed * @see FrameCallbackInterface */ -DALI_CORE_API void AddFrameCallback( Dali::Stage stage, FrameCallbackInterface& frameCallback, Actor rootActor ); +DALI_CORE_API void AddFrameCallback(Dali::Stage stage, FrameCallbackInterface& frameCallback, Actor rootActor); /** * @brief Removes the specified FrameCallbackInterface implementation from being called on every frame. @@ -90,7 +88,7 @@ DALI_CORE_API void AddFrameCallback( Dali::Stage stage, FrameCallbackInterface& * @note This function will block if the FrameCallbackInterface::Update method is being processed in the update-thread. * @note If the callback implementation has already been removed, then this is a no-op. */ -DALI_CORE_API void RemoveFrameCallback( Dali::Stage stage, FrameCallbackInterface& frameCallback ); +DALI_CORE_API void RemoveFrameCallback(Dali::Stage stage, FrameCallbackInterface& frameCallback); } // namespace DevelStage diff --git a/dali/devel-api/common/stage.cpp b/dali/devel-api/common/stage.cpp index 826ec0d..07c2deb 100644 --- a/dali/devel-api/common/stage.cpp +++ b/dali/devel-api/common/stage.cpp @@ -19,16 +19,15 @@ #include // INTERNAL INCLUDES -#include -#include -#include #include +#include +#include #include #include +#include namespace Dali { - using Internal::Core; Stage::Stage() @@ -58,8 +57,8 @@ Stage::Stage(Internal::Stage* internal) Stage Stage::GetCurrent() { Internal::Stage* stage = Internal::Stage::GetCurrent(); - DALI_ASSERT_ALWAYS( stage && "Stage doesn't exist" ); - return Stage( stage ); + DALI_ASSERT_ALWAYS(stage && "Stage doesn't exist"); + return Stage(stage); } bool Stage::IsInstalled() @@ -79,7 +78,7 @@ void Stage::Remove(Actor& actor) RenderTaskList Stage::GetRenderTaskList() const { - return RenderTaskList( &GetImplementation(*this).GetRenderTaskList() ); + return RenderTaskList(&GetImplementation(*this).GetRenderTaskList()); } Vector2 Stage::GetSize() const @@ -120,15 +119,15 @@ Vector2 Stage::GetDpi() const ObjectRegistry Stage::GetObjectRegistry() const { Internal::Stage* stage = Internal::Stage::GetCurrent(); - DALI_ASSERT_ALWAYS( stage && "GetObjectRegistry() : Stage is null" ); + DALI_ASSERT_ALWAYS(stage && "GetObjectRegistry() : Stage is null"); Internal::ObjectRegistry& internal = stage->GetObjectRegistry(); return ObjectRegistry(&internal); } -void Stage::KeepRendering( float durationSeconds ) +void Stage::KeepRendering(float durationSeconds) { - GetImplementation(*this).KeepRendering( durationSeconds ); + GetImplementation(*this).KeepRendering(durationSeconds); } Stage::KeyEventSignalType& Stage::KeyEventSignal() @@ -143,7 +142,7 @@ Stage::EventProcessingFinishedSignalType& Stage::EventProcessingFinishedSignal() Stage::TouchEventSignalType& Stage::TouchedSignal() { - return GetImplementation( *this ).TouchedSignal(); + return GetImplementation(*this).TouchedSignal(); } Stage::WheelEventSignalType& Stage::WheelEventSignal() diff --git a/dali/devel-api/common/stage.h b/dali/devel-api/common/stage.h index 7c8dffa..32f7bd4 100644 --- a/dali/devel-api/common/stage.h +++ b/dali/devel-api/common/stage.h @@ -85,12 +85,12 @@ class KeyEvent; class DALI_CORE_API Stage : public BaseHandle { public: - using KeyEventSignalType = Signal; ///< Key event signal type - using EventProcessingFinishedSignalType = Signal; ///< Event Processing finished signal type - using TouchEventSignalType = Signal; ///< Touch signal type - using WheelEventSignalType = Signal; ///< Wheel signal type - using ContextStatusSignal = Signal; ///< Context status signal type - using SceneCreatedSignalType = Signal; ///< Scene created signal type + using KeyEventSignalType = Signal; ///< Key event signal type + using EventProcessingFinishedSignalType = Signal; ///< Event Processing finished signal type + using TouchEventSignalType = Signal; ///< Touch signal type + using WheelEventSignalType = Signal; ///< Wheel signal type + using ContextStatusSignal = Signal; ///< Context status signal type + using SceneCreatedSignalType = Signal; ///< Scene created signal type /** * @brief Allows the creation of an empty stage handle. @@ -240,7 +240,7 @@ public: * This method is useful to force screen refreshes e.g. when updating a NativeImage. * @param[in] durationSeconds Time to keep rendering, 0 means render at least one more frame */ - void KeepRendering( float durationSeconds ); + void KeepRendering(float durationSeconds); // Signals @@ -324,7 +324,6 @@ public: SceneCreatedSignalType& SceneCreatedSignal(); public: // Not intended for application developers - /// @cond internal /** * @brief This constructor is used by Stage::GetCurrent() methods. diff --git a/dali/devel-api/events/hit-test-algorithm.cpp b/dali/devel-api/events/hit-test-algorithm.cpp index 70377fe..5f0ba26 100644 --- a/dali/devel-api/events/hit-test-algorithm.cpp +++ b/dali/devel-api/events/hit-test-algorithm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -19,21 +19,19 @@ #include // INTERNAL INCLUDES -#include -#include #include +#include +#include #include namespace Dali { - namespace HitTestAlgorithm { - -bool HitTest( Stage stage, const Vector2& screenCoordinates, Results& results, HitTestFunction func ) +bool HitTest(Stage stage, const Vector2& screenCoordinates, Results& results, HitTestFunction func) { - Internal::Stage& stageImpl = GetImplementation( stage ); - return Internal::HitTestAlgorithm::HitTest( stageImpl.GetSize(), stageImpl.GetRenderTaskList(), stageImpl.GetLayerList(), screenCoordinates, results, func ); + Internal::Stage& stageImpl = GetImplementation(stage); + return Internal::HitTestAlgorithm::HitTest(stageImpl.GetSize(), stageImpl.GetRenderTaskList(), stageImpl.GetLayerList(), screenCoordinates, results, func); } } // namespace HitTestAlgorithm diff --git a/dali/devel-api/events/hit-test-algorithm.h b/dali/devel-api/events/hit-test-algorithm.h index c3f1c5a..1417f6e 100644 --- a/dali/devel-api/events/hit-test-algorithm.h +++ b/dali/devel-api/events/hit-test-algorithm.h @@ -1,5 +1,5 @@ -#ifndef __DALI_HIT_TEST_ALGORITHM_H__ -#define __DALI_HIT_TEST_ALGORITHM_H__ +#ifndef __DALI_HIT_TEST_ALGORITHM_H__ +#define __DALI_HIT_TEST_ALGORITHM_H__ /* * Copyright (c) 2020 Samsung Electronics Co., Ltd. @@ -18,14 +18,12 @@ * */ -#include #include #include - +#include namespace Dali { - class RenderTask; /** @@ -102,14 +100,13 @@ class RenderTask; */ namespace HitTestAlgorithm { - /** * @brief How the actor tree should be traversed. */ enum TraverseType { - CHECK_ACTOR, ///< Hit test the given actor. - DESCEND_ACTOR_TREE ///< Check whether the actor tree should be descended to hit-test its children. + CHECK_ACTOR, ///< Hit test the given actor. + DESCEND_ACTOR_TREE ///< Check whether the actor tree should be descended to hit-test its children. }; /** @@ -117,8 +114,8 @@ enum TraverseType */ struct Results { - Actor actor; ///< The hit actor. - Vector2 actorCoordinates; ///< The actor coordinates. + Actor actor; ///< The hit actor. + Vector2 actorCoordinates; ///< The actor coordinates. }; /** @@ -126,7 +123,7 @@ struct Results * * @return true, if the actor is hittable, false otherwise. */ -using HitTestFunction = bool ( * )( Actor, TraverseType ); +using HitTestFunction = bool (*)(Actor, TraverseType); /** * @brief Given screen coordinates, this method returns the hit actor & the local coordinates relative to @@ -144,7 +141,7 @@ using HitTestFunction = bool ( * )( Actor, TraverseType ); * @param[in] func The function to use in the hit-test algorithm. * @return true if something was hit */ -DALI_CORE_API bool HitTest( Stage stage, const Vector2& screenCoordinates, Results& results, HitTestFunction func ); +DALI_CORE_API bool HitTest(Stage stage, const Vector2& screenCoordinates, Results& results, HitTestFunction func); } // namespace HitTestAlgorithm diff --git a/dali/devel-api/events/hover-event-devel.cpp b/dali/devel-api/events/hover-event-devel.cpp index 7f67b81..63a1107 100644 --- a/dali/devel-api/events/hover-event-devel.cpp +++ b/dali/devel-api/events/hover-event-devel.cpp @@ -21,16 +21,13 @@ namespace Dali { - namespace DevelHoverEvent { - -HoverEvent New( uint32_t time ) +HoverEvent New(uint32_t time) { - return HoverEvent( new Internal::HoverEvent( time ) ); + return HoverEvent(new Internal::HoverEvent(time)); } } // namespace DevelHoverEvent } // namespace Dali - diff --git a/dali/devel-api/events/hover-event-devel.h b/dali/devel-api/events/hover-event-devel.h index 13f2c0a..62bc89f 100644 --- a/dali/devel-api/events/hover-event-devel.h +++ b/dali/devel-api/events/hover-event-devel.h @@ -23,10 +23,8 @@ namespace Dali { - namespace DevelHoverEvent { - /** * @brief Creates an initialized HoverEvent. * @@ -34,8 +32,7 @@ namespace DevelHoverEvent * @param[in] time The time the event occurred. * @return A handle to a newly allocated Dali resource */ -DALI_CORE_API HoverEvent New( uint32_t time ); - +DALI_CORE_API HoverEvent New(uint32_t time); } // namespace DevelHoverEvent diff --git a/dali/devel-api/events/key-event-devel.cpp b/dali/devel-api/events/key-event-devel.cpp index 6b6d336..70ac649 100644 --- a/dali/devel-api/events/key-event-devel.cpp +++ b/dali/devel-api/events/key-event-devel.cpp @@ -21,58 +21,55 @@ namespace Dali { - namespace DevelKeyEvent { - -KeyEvent New( const std::string& keyName, - const std::string& logicalKey, - const std::string& keyString, - int keyCode, - int keyModifier, - unsigned long timeStamp, - const Dali::KeyEvent::State& keyState, - const std::string& compose, - const std::string& deviceName, - const Device::Class::Type deviceClass, - const Device::Subclass::Type deviceSubclass ) +KeyEvent New(const std::string& keyName, + const std::string& logicalKey, + const std::string& keyString, + int keyCode, + int keyModifier, + unsigned long timeStamp, + const Dali::KeyEvent::State& keyState, + const std::string& compose, + const std::string& deviceName, + const Device::Class::Type deviceClass, + const Device::Subclass::Type deviceSubclass) { - Internal::KeyEventPtr internal = Internal::KeyEvent::New( keyName, logicalKey, keyString, keyCode, keyModifier, timeStamp, keyState, compose, deviceName, deviceClass, deviceSubclass ); + Internal::KeyEventPtr internal = Internal::KeyEvent::New(keyName, logicalKey, keyString, keyCode, keyModifier, timeStamp, keyState, compose, deviceName, deviceClass, deviceSubclass); - return KeyEvent( internal.Get() ); + return KeyEvent(internal.Get()); } -void SetKeyName( KeyEvent keyEvent, const std::string& keyName ) +void SetKeyName(KeyEvent keyEvent, const std::string& keyName) { - GetImplementation( keyEvent ).SetKeyName( keyName ); + GetImplementation(keyEvent).SetKeyName(keyName); } -void SetKeyString( KeyEvent keyEvent, const std::string& keyString ) +void SetKeyString(KeyEvent keyEvent, const std::string& keyString) { - GetImplementation( keyEvent ).SetKeyString( keyString ); + GetImplementation(keyEvent).SetKeyString(keyString); } -void SetKeyCode( KeyEvent keyEvent, int32_t keyCode ) +void SetKeyCode(KeyEvent keyEvent, int32_t keyCode) { - GetImplementation( keyEvent ).SetKeyCode( keyCode ); + GetImplementation(keyEvent).SetKeyCode(keyCode); } -void SetKeyModifier( KeyEvent keyEvent, int32_t keyModifier ) +void SetKeyModifier(KeyEvent keyEvent, int32_t keyModifier) { - GetImplementation( keyEvent ).SetKeyModifier( keyModifier ); + GetImplementation(keyEvent).SetKeyModifier(keyModifier); } -void SetTime( KeyEvent keyEvent, unsigned long time ) +void SetTime(KeyEvent keyEvent, unsigned long time) { - GetImplementation( keyEvent ).SetTime( time ); + GetImplementation(keyEvent).SetTime(time); } -void SetState( KeyEvent keyEvent, const KeyEvent::State& state ) +void SetState(KeyEvent keyEvent, const KeyEvent::State& state) { - GetImplementation( keyEvent ).SetState( state ); + GetImplementation(keyEvent).SetState(state); } } // namespace DevelKeyEvent } // namespace Dali - diff --git a/dali/devel-api/events/key-event-devel.h b/dali/devel-api/events/key-event-devel.h index d19c4ee..1b1caac 100644 --- a/dali/devel-api/events/key-event-devel.h +++ b/dali/devel-api/events/key-event-devel.h @@ -23,10 +23,8 @@ namespace Dali { - namespace DevelKeyEvent { - /** * @brief Creates an initialized KeyEvent. * @@ -44,17 +42,17 @@ namespace DevelKeyEvent * @param[in] deviceSubclass The subclass of device the key event originated from * @return A handle to a newly allocated Dali resource */ -DALI_CORE_API KeyEvent New( const std::string& keyName, - const std::string& logicalKey, - const std::string& keyString, - int keyCode, - int keyModifier, - unsigned long timeStamp, - const Dali::KeyEvent::State& keyState, - const std::string& compose, - const std::string& deviceName, - const Device::Class::Type deviceClass, - const Device::Subclass::Type deviceSubclass ); +DALI_CORE_API KeyEvent New(const std::string& keyName, + const std::string& logicalKey, + const std::string& keyString, + int keyCode, + int keyModifier, + unsigned long timeStamp, + const Dali::KeyEvent::State& keyState, + const std::string& compose, + const std::string& deviceName, + const Device::Class::Type deviceClass, + const Device::Subclass::Type deviceSubclass); /** * @brief Set the name given to the key pressed @@ -63,7 +61,7 @@ DALI_CORE_API KeyEvent New( const std::string& keyName, * @param[in] keyEvent The instance of KeyEvent. * @param[in] keyName The name given to the key pressed. */ -DALI_CORE_API void SetKeyName( KeyEvent keyEvent, const std::string& keyName ); +DALI_CORE_API void SetKeyName(KeyEvent keyEvent, const std::string& keyName); /** * @brief Set the actual string of input characters that should be used for input editors. @@ -72,7 +70,7 @@ DALI_CORE_API void SetKeyName( KeyEvent keyEvent, const std::string& keyName ); * @param[in] keyEvent The instance of KeyEvent. * @param[in] keyString The actual string of input characters */ -DALI_CORE_API void SetKeyString( KeyEvent keyEvent, const std::string& keyString ); +DALI_CORE_API void SetKeyString(KeyEvent keyEvent, const std::string& keyString); /** * @brief Set the unique key code for the key pressed. @@ -81,7 +79,7 @@ DALI_CORE_API void SetKeyString( KeyEvent keyEvent, const std::string& keyString * @param[in] keyEvent The instance of KeyEvent. * @param[in] keyCode The unique key code for the key pressed */ -DALI_CORE_API void SetKeyCode( KeyEvent keyEvent, int32_t keyCode ); +DALI_CORE_API void SetKeyCode(KeyEvent keyEvent, int32_t keyCode); /** * @brief Set the key modifier for special keys like Shift, Alt and Ctrl which modify the next key pressed. @@ -90,7 +88,7 @@ DALI_CORE_API void SetKeyCode( KeyEvent keyEvent, int32_t keyCode ); * @param[in] keyEvent The instance of KeyEvent. * @param[in] keyModifier The key modifier */ -DALI_CORE_API void SetKeyModifier( KeyEvent keyEvent, int32_t keyModifier ); +DALI_CORE_API void SetKeyModifier(KeyEvent keyEvent, int32_t keyModifier); /** * @brief Set the time (in ms) that the key event occurred. @@ -99,7 +97,7 @@ DALI_CORE_API void SetKeyModifier( KeyEvent keyEvent, int32_t keyModifier ); * @param[in] keyEvent The instance of KeyEvent. * @param[in] time The time (in ms) */ -DALI_CORE_API void SetTime( KeyEvent keyEvent, unsigned long time ); +DALI_CORE_API void SetTime(KeyEvent keyEvent, unsigned long time); /** * @brief Set the state of the key event. @@ -108,7 +106,7 @@ DALI_CORE_API void SetTime( KeyEvent keyEvent, unsigned long time ); * @param[in] keyEvent The instance of KeyEvent. * @param[in] state The state of the key event */ -DALI_CORE_API void SetState( KeyEvent keyEvent, const KeyEvent::State& state ); +DALI_CORE_API void SetState(KeyEvent keyEvent, const KeyEvent::State& state); } // namespace DevelKeyEvent diff --git a/dali/devel-api/events/long-press-gesture-detector-devel.cpp b/dali/devel-api/events/long-press-gesture-detector-devel.cpp index 6d11fb2..d7f1389 100644 --- a/dali/devel-api/events/long-press-gesture-detector-devel.cpp +++ b/dali/devel-api/events/long-press-gesture-detector-devel.cpp @@ -26,17 +26,13 @@ namespace Dali { - namespace DevelLongPressGestureDetector { - -uint32_t GetMinimumHoldingTime( LongPressGestureDetector longPressGestureDetector ) +uint32_t GetMinimumHoldingTime(LongPressGestureDetector longPressGestureDetector) { - return GetImplementation( longPressGestureDetector ).GetMinimumHoldingTime(); + return GetImplementation(longPressGestureDetector).GetMinimumHoldingTime(); } - } // namespace DevelLongPressGestureDetector } // namespace Dali - diff --git a/dali/devel-api/events/long-press-gesture-detector-devel.h b/dali/devel-api/events/long-press-gesture-detector-devel.h index f757b21..2511e50 100644 --- a/dali/devel-api/events/long-press-gesture-detector-devel.h +++ b/dali/devel-api/events/long-press-gesture-detector-devel.h @@ -23,19 +23,17 @@ namespace Dali { - class LongPressGestureDetector; namespace DevelLongPressGestureDetector { - /** * @brief Get the minimum holding time required to be recognized as a long press gesture in milliseconds * * @param[in] longPressGestureDetector The target LongPressGestureDetector instance * @return The time value in milliseconds */ -DALI_CORE_API uint32_t GetMinimumHoldingTime( LongPressGestureDetector longPressGestureDetector ); +DALI_CORE_API uint32_t GetMinimumHoldingTime(LongPressGestureDetector longPressGestureDetector); } // namespace DevelLongPressGestureDetector diff --git a/dali/devel-api/events/long-press-gesture-devel.cpp b/dali/devel-api/events/long-press-gesture-devel.cpp index 57bd719..3b4ff37 100644 --- a/dali/devel-api/events/long-press-gesture-devel.cpp +++ b/dali/devel-api/events/long-press-gesture-devel.cpp @@ -21,16 +21,13 @@ namespace Dali { - namespace DevelLongPressGesture { - -LongPressGesture New( GestureState state ) +LongPressGesture New(GestureState state) { - return LongPressGesture( new Internal::LongPressGesture( state ) ); + return LongPressGesture(new Internal::LongPressGesture(state)); } } // namespace DevelLongPressGesture } // namespace Dali - diff --git a/dali/devel-api/events/long-press-gesture-devel.h b/dali/devel-api/events/long-press-gesture-devel.h index 7d0e580..cf5549c 100644 --- a/dali/devel-api/events/long-press-gesture-devel.h +++ b/dali/devel-api/events/long-press-gesture-devel.h @@ -23,17 +23,15 @@ namespace Dali { - namespace DevelLongPressGesture { - /** * @brief Creates an initialized LongPressGesture. * * @param[in] state The state of the LongPressGesture * @return A handle to a newly allocated Dali resource */ -DALI_CORE_API LongPressGesture New( GestureState state ); +DALI_CORE_API LongPressGesture New(GestureState state); } // namespace DevelLongPressGesture diff --git a/dali/devel-api/events/pan-gesture-devel.cpp b/dali/devel-api/events/pan-gesture-devel.cpp index e750480..02c33b5 100644 --- a/dali/devel-api/events/pan-gesture-devel.cpp +++ b/dali/devel-api/events/pan-gesture-devel.cpp @@ -21,56 +21,53 @@ // INTERNAL INCLUDES #include - namespace Dali { - namespace DevelPanGesture { - -Dali::PanGesture New( GestureState state ) +Dali::PanGesture New(GestureState state) { - return PanGesture( new Internal::PanGesture( state ) ); + return PanGesture(new Internal::PanGesture(state)); } -void SetTime( Dali::PanGesture& gesture, uint32_t time ) +void SetTime(Dali::PanGesture& gesture, uint32_t time) { - GetImplementation( gesture ).SetTime( time ); + GetImplementation(gesture).SetTime(time); } -void SetVelocity( Dali::PanGesture& gesture, const Vector2& velocity) +void SetVelocity(Dali::PanGesture& gesture, const Vector2& velocity) { - GetImplementation( gesture ).SetVelocity( velocity ); + GetImplementation(gesture).SetVelocity(velocity); } -void SetDisplacement( Dali::PanGesture& gesture, const Vector2& displacement) +void SetDisplacement(Dali::PanGesture& gesture, const Vector2& displacement) { - GetImplementation( gesture ).SetDisplacement( displacement ); + GetImplementation(gesture).SetDisplacement(displacement); } -void SetPosition( Dali::PanGesture& gesture, const Vector2& position) +void SetPosition(Dali::PanGesture& gesture, const Vector2& position) { - GetImplementation( gesture ).SetPosition( position ); + GetImplementation(gesture).SetPosition(position); } -void SetScreenVelocity( Dali::PanGesture& gesture, const Vector2& screenVelocity) +void SetScreenVelocity(Dali::PanGesture& gesture, const Vector2& screenVelocity) { - GetImplementation( gesture ).SetScreenVelocity( screenVelocity ); + GetImplementation(gesture).SetScreenVelocity(screenVelocity); } -void SetScreenDisplacement( Dali::PanGesture& gesture, const Vector2& screenDisplacement) +void SetScreenDisplacement(Dali::PanGesture& gesture, const Vector2& screenDisplacement) { - GetImplementation( gesture ).SetScreenDisplacement( screenDisplacement ); + GetImplementation(gesture).SetScreenDisplacement(screenDisplacement); } -void SetScreenPosition( Dali::PanGesture& gesture, const Vector2& screenPosition) +void SetScreenPosition(Dali::PanGesture& gesture, const Vector2& screenPosition) { - GetImplementation( gesture ).SetScreenPosition( screenPosition ); + GetImplementation(gesture).SetScreenPosition(screenPosition); } -void SetNumberOfTouches( Dali::PanGesture& gesture, uint32_t numberOfTouches ) +void SetNumberOfTouches(Dali::PanGesture& gesture, uint32_t numberOfTouches) { - GetImplementation( gesture ).SetNumberOfTouches( numberOfTouches ); + GetImplementation(gesture).SetNumberOfTouches(numberOfTouches); } } // namespace DevelPanGesture diff --git a/dali/devel-api/events/pan-gesture-devel.h b/dali/devel-api/events/pan-gesture-devel.h index f204fcb..9272148 100644 --- a/dali/devel-api/events/pan-gesture-devel.h +++ b/dali/devel-api/events/pan-gesture-devel.h @@ -24,10 +24,8 @@ namespace Dali { - namespace DevelPanGesture { - /** * @brief Create a PanGeture for internal. * @param[in] state The state of the PanGesture diff --git a/dali/devel-api/events/pinch-gesture-devel.cpp b/dali/devel-api/events/pinch-gesture-devel.cpp index f59dfbc..259163c 100644 --- a/dali/devel-api/events/pinch-gesture-devel.cpp +++ b/dali/devel-api/events/pinch-gesture-devel.cpp @@ -21,16 +21,13 @@ namespace Dali { - namespace DevelPinchGesture { - -PinchGesture New( GestureState state ) +PinchGesture New(GestureState state) { - return PinchGesture( new Internal::PinchGesture( state ) ); + return PinchGesture(new Internal::PinchGesture(state)); } } // namespace DevelPinchGesture } // namespace Dali - diff --git a/dali/devel-api/events/pinch-gesture-devel.h b/dali/devel-api/events/pinch-gesture-devel.h index fc2a47f..3f118e6 100644 --- a/dali/devel-api/events/pinch-gesture-devel.h +++ b/dali/devel-api/events/pinch-gesture-devel.h @@ -23,17 +23,15 @@ namespace Dali { - namespace DevelPinchGesture { - /** * @brief Creates an initialized PinchGesture. * * @param[in] state The state of the PinchGesture * @return A handle to a newly allocated Dali resource */ -DALI_CORE_API PinchGesture New( GestureState state ); +DALI_CORE_API PinchGesture New(GestureState state); } // namespace DevelPinchGesture diff --git a/dali/devel-api/events/rotation-gesture-devel.cpp b/dali/devel-api/events/rotation-gesture-devel.cpp index a72ced6..8563844 100644 --- a/dali/devel-api/events/rotation-gesture-devel.cpp +++ b/dali/devel-api/events/rotation-gesture-devel.cpp @@ -21,16 +21,13 @@ namespace Dali { - namespace DevelRotationGesture { - -RotationGesture New( GestureState state ) +RotationGesture New(GestureState state) { - return RotationGesture( new Internal::RotationGesture( state ) ); + return RotationGesture(new Internal::RotationGesture(state)); } } // namespace DevelRotationGesture } // namespace Dali - diff --git a/dali/devel-api/events/rotation-gesture-devel.h b/dali/devel-api/events/rotation-gesture-devel.h index cb51486..3cd4d81 100644 --- a/dali/devel-api/events/rotation-gesture-devel.h +++ b/dali/devel-api/events/rotation-gesture-devel.h @@ -23,17 +23,15 @@ namespace Dali { - namespace DevelRotationGesture { - /** * @brief Creates an initialized RotationGesture. * * @param[in] state The state of the RotationGesture * @return A handle to a newly allocated Dali resource */ -DALI_CORE_API RotationGesture New( GestureState state ); +DALI_CORE_API RotationGesture New(GestureState state); } // namespace DevelRotationGesture diff --git a/dali/devel-api/events/tap-gesture-devel.cpp b/dali/devel-api/events/tap-gesture-devel.cpp index eb220a0..55c1149 100644 --- a/dali/devel-api/events/tap-gesture-devel.cpp +++ b/dali/devel-api/events/tap-gesture-devel.cpp @@ -21,16 +21,13 @@ namespace Dali { - namespace DevelTapGesture { - -TapGesture New( GestureState state ) +TapGesture New(GestureState state) { - return TapGesture( new Internal::TapGesture( state ) ); + return TapGesture(new Internal::TapGesture(state)); } } // namespace DevelTapGesture } // namespace Dali - diff --git a/dali/devel-api/events/tap-gesture-devel.h b/dali/devel-api/events/tap-gesture-devel.h index dc63289..496bde9 100644 --- a/dali/devel-api/events/tap-gesture-devel.h +++ b/dali/devel-api/events/tap-gesture-devel.h @@ -23,17 +23,15 @@ namespace Dali { - namespace DevelTapGesture { - /** * @brief Creates an initialized TapGesture. * * @param[in] state The state of the TapGesture * @return A handle to a newly allocated Dali resource */ -DALI_CORE_API TapGesture New( GestureState state ); +DALI_CORE_API TapGesture New(GestureState state); } // namespace DevelTapGesture diff --git a/dali/devel-api/events/touch-point.cpp b/dali/devel-api/events/touch-point.cpp index bcfbea2..eba10cb 100644 --- a/dali/devel-api/events/touch-point.cpp +++ b/dali/devel-api/events/touch-point.cpp @@ -20,7 +20,6 @@ namespace Dali { - TouchPoint::TouchPoint(int32_t id, PointState::Type state, float screenX, float screenY) : deviceId(id), state(state), diff --git a/dali/devel-api/events/touch-point.h b/dali/devel-api/events/touch-point.h index 414e630..620a918 100644 --- a/dali/devel-api/events/touch-point.h +++ b/dali/devel-api/events/touch-point.h @@ -22,8 +22,8 @@ #include // uint32_t // INTERNAL INCLUDES -#include #include +#include #include #include diff --git a/dali/devel-api/events/wheel-event-devel.cpp b/dali/devel-api/events/wheel-event-devel.cpp index 83ca780..324743a 100644 --- a/dali/devel-api/events/wheel-event-devel.cpp +++ b/dali/devel-api/events/wheel-event-devel.cpp @@ -21,18 +21,15 @@ namespace Dali { - namespace DevelWheelEvent { - -WheelEvent New( WheelEvent::Type type, int32_t direction, uint32_t modifiers, Vector2 point, int32_t delta, uint32_t timeStamp ) +WheelEvent New(WheelEvent::Type type, int32_t direction, uint32_t modifiers, Vector2 point, int32_t delta, uint32_t timeStamp) { - Internal::WheelEventPtr internal = Internal::WheelEvent::New( type, direction, modifiers, point, delta, timeStamp ); + Internal::WheelEventPtr internal = Internal::WheelEvent::New(type, direction, modifiers, point, delta, timeStamp); - return WheelEvent( internal.Get() ); + return WheelEvent(internal.Get()); } -} // namespace DevelKeyEvent +} // namespace DevelWheelEvent } // namespace Dali - diff --git a/dali/devel-api/events/wheel-event-devel.h b/dali/devel-api/events/wheel-event-devel.h index 36f9b79..1748980 100644 --- a/dali/devel-api/events/wheel-event-devel.h +++ b/dali/devel-api/events/wheel-event-devel.h @@ -23,10 +23,8 @@ namespace Dali { - namespace DevelWheelEvent { - /** * @brief Creates an initialized WheelEvent. * @@ -39,8 +37,7 @@ namespace DevelWheelEvent * @param[in] timeStamp The time the wheel is being rolled * @return A handle to a newly allocated Dali resource */ -DALI_CORE_API WheelEvent New( WheelEvent::Type type, int32_t direction, uint32_t modifiers, Vector2 point, int32_t delta, uint32_t timeStamp ); - +DALI_CORE_API WheelEvent New(WheelEvent::Type type, int32_t direction, uint32_t modifiers, Vector2 point, int32_t delta, uint32_t timeStamp); } // namespace DevelWheelEvent diff --git a/dali/devel-api/images/distance-field.cpp b/dali/devel-api/images/distance-field.cpp old mode 100755 new mode 100644 index 7c2a524..c6de04a --- a/dali/devel-api/images/distance-field.cpp +++ b/dali/devel-api/images/distance-field.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -19,140 +19,141 @@ #include // EXTERNAL INCLUDES -#include #include #include #include +#include // INTERNAL INCLUDES #include #include -#include #include +#include namespace Dali { - namespace { - -float Interpolate( float a, float b, float factor ) +float Interpolate(float a, float b, float factor) { return a * (1.0f - factor) + b * factor; } -float Bilinear( float a, float b, float c, float d, float dx, float dy ) +float Bilinear(float a, float b, float c, float d, float dx, float dy) { - return Interpolate( Interpolate( a, b, dx), Interpolate( c, d, dx ), dy ); + return Interpolate(Interpolate(a, b, dx), Interpolate(c, d, dx), dy); } -void ScaleField( int width, int height, float* in, uint32_t targetWidth, uint32_t targetHeight, float* out ) +void ScaleField(int width, int height, float* in, uint32_t targetWidth, uint32_t targetHeight, float* out) { - float xScale = static_cast( width ) / static_cast( targetWidth ); - float yScale = static_cast( height ) / static_cast( targetHeight ); + float xScale = static_cast(width) / static_cast(targetWidth); + float yScale = static_cast(height) / static_cast(targetHeight); // for each row in target for(uint32_t y = 0; y < targetHeight; ++y) { - const int32_t sampleY = static_cast< int32_t >( yScale * static_cast( y ) ); - const int32_t otherY = std::min( sampleY + 1, height - 1 ); - const float dy = (yScale * static_cast( y ) ) - static_cast( sampleY ); + const int32_t sampleY = static_cast(yScale * static_cast(y)); + const int32_t otherY = std::min(sampleY + 1, height - 1); + const float dy = (yScale * static_cast(y)) - static_cast(sampleY); // for each column in target - for (uint32_t x = 0; x < targetWidth; ++x) + for(uint32_t x = 0; x < targetWidth; ++x) { - const int32_t sampleX = static_cast< int32_t >( xScale * static_cast( x ) ); - const int32_t otherX = std::min( sampleX + 1, width - 1 ); - const float dx = (xScale * static_cast( x ) ) - static_cast( sampleX ); - - float value = Bilinear( in[ sampleY * width + sampleX ], - in[ sampleY * width + otherX ], - in[ otherY * width + sampleX ], - in[ otherY * width + otherX ], - dx, dy ); - - out[y * targetWidth + x] = std::min( value, 1.0f ); + const int32_t sampleX = static_cast(xScale * static_cast(x)); + const int32_t otherX = std::min(sampleX + 1, width - 1); + const float dx = (xScale * static_cast(x)) - static_cast(sampleX); + + float value = Bilinear(in[sampleY * width + sampleX], + in[sampleY * width + otherX], + in[otherY * width + sampleX], + in[otherY * width + otherX], + dx, + dy); + + out[y * targetWidth + x] = std::min(value, 1.0f); } } } #define SQUARE(a) ((a) * (a)) -const float MAX_DISTANCE = static_cast( 1e20 ); +const float MAX_DISTANCE = static_cast(1e20); /** * Distance transform of 1D function using squared distance */ -void DistanceTransform( float *source, float* dest, uint32_t length ) +void DistanceTransform(float* source, float* dest, uint32_t length) { - std::vector parabolas(length); // Locations of parabolas in lower envelope - std::vector edge(length + 1); // Locations of boundaries between parabolas + std::vector parabolas(length); // Locations of parabolas in lower envelope + std::vector edge(length + 1); // Locations of boundaries between parabolas - int32_t rightmost(0); // Index of rightmost parabola in lower envelope + int32_t rightmost(0); // Index of rightmost parabola in lower envelope parabolas[0] = 0; - edge[0] = -MAX_DISTANCE; - edge[1] = +MAX_DISTANCE; - for( uint32_t i = 1; i <= length - 1; i++ ) + edge[0] = -MAX_DISTANCE; + edge[1] = +MAX_DISTANCE; + for(uint32_t i = 1; i <= length - 1; i++) { - const float initialDistance( source[i] + static_cast( i*i ) ); - int32_t parabola = parabolas[rightmost]; - float newDistance( (initialDistance - (source[parabola] + static_cast( parabola * parabola ))) / static_cast(2 * i - 2 * parabola) ); - while( rightmost > 0 && newDistance <= edge[rightmost] ) + const float initialDistance(source[i] + static_cast(i * i)); + int32_t parabola = parabolas[rightmost]; + + float newDistance((initialDistance - (source[parabola] + static_cast(parabola * parabola))) / static_cast(2 * i - 2 * parabola)); + + while(rightmost > 0 && newDistance <= edge[rightmost]) { rightmost--; - parabola = parabolas[rightmost]; - newDistance = (initialDistance - (source[parabola] + static_cast( parabola * parabola ))) / static_cast(2 * i - 2 * parabola); + parabola = parabolas[rightmost]; + newDistance = (initialDistance - (source[parabola] + static_cast(parabola * parabola))) / static_cast(2 * i - 2 * parabola); } rightmost++; parabolas[rightmost] = i; - edge[rightmost] = newDistance; - edge[rightmost + 1] = MAX_DISTANCE; + edge[rightmost] = newDistance; + edge[rightmost + 1] = MAX_DISTANCE; } rightmost = 0; - for( uint32_t i = 0; i <= length - 1; ++i ) + for(uint32_t i = 0; i <= length - 1; ++i) { - while( edge[rightmost + 1] < static_cast( i ) ) + while(edge[rightmost + 1] < static_cast(i)) { ++rightmost; } - dest[i] = static_cast( SQUARE( static_cast< int32_t >( i ) - parabolas[rightmost] ) ) + source[parabolas[rightmost]]; + dest[i] = static_cast(SQUARE(static_cast(i) - parabolas[rightmost])) + source[parabolas[rightmost]]; } } /** * Distance transform of 2D function using squared distance */ -void DistanceTransform( float* data, uint32_t width, uint32_t height, float* sourceBuffer, float* destBuffer ) +void DistanceTransform(float* data, uint32_t width, uint32_t height, float* sourceBuffer, float* destBuffer) { // transform along columns - for( uint32_t x = 0; x < width; ++x ) + for(uint32_t x = 0; x < width; ++x) { - for( uint32_t y = 0; y < height; ++y ) + for(uint32_t y = 0; y < height; ++y) { - sourceBuffer[y] = data[ y * width + x ]; + sourceBuffer[y] = data[y * width + x]; } - DistanceTransform( sourceBuffer, destBuffer, height ); + DistanceTransform(sourceBuffer, destBuffer, height); - for( uint32_t y = 0; y < height; y++ ) + for(uint32_t y = 0; y < height; y++) { data[y * width + x] = destBuffer[y]; } } // transform along rows - for( uint32_t y = 0; y < height; ++y ) + for(uint32_t y = 0; y < height; ++y) { - for( uint32_t x = 0; x < width; ++x ) + for(uint32_t x = 0; x < width; ++x) { - sourceBuffer[x] = data[ y * width + x ]; + sourceBuffer[x] = data[y * width + x]; } - DistanceTransform( sourceBuffer, destBuffer, width ); + DistanceTransform(sourceBuffer, destBuffer, width); - for( uint32_t x = 0; x < width; x++ ) + for(uint32_t x = 0; x < width; x++) { data[y * width + x] = destBuffer[x]; } @@ -161,95 +162,91 @@ void DistanceTransform( float* data, uint32_t width, uint32_t height, float* sou } // namespace -void GenerateDistanceFieldMap(const uint8_t* const imagePixels, const Size& imageSize, - uint8_t* const distanceMap, const Size& distanceMapSize, - const float fieldRadius, const uint32_t fieldBorder, bool highQuality) +void GenerateDistanceFieldMap(const uint8_t* const imagePixels, const Size& imageSize, uint8_t* const distanceMap, const Size& distanceMapSize, const float fieldRadius, const uint32_t fieldBorder, bool highQuality) { - GenerateDistanceFieldMap( imagePixels, imageSize, distanceMap, distanceMapSize, fieldBorder, imageSize, highQuality ); + GenerateDistanceFieldMap(imagePixels, imageSize, distanceMap, distanceMapSize, fieldBorder, imageSize, highQuality); } -void GenerateDistanceFieldMap( const uint8_t* const imagePixels, const Size& imageSize, - uint8_t* const distanceMap, const Size& distanceMapSize, - const uint32_t fieldBorder, - const Vector2& maxSize, - bool highQuality ) +void GenerateDistanceFieldMap(const uint8_t* const imagePixels, const Size& imageSize, uint8_t* const distanceMap, const Size& distanceMapSize, const uint32_t fieldBorder, const Vector2& maxSize, bool highQuality) { // constants to reduce redundant calculations - const uint32_t originalWidth( static_cast(imageSize.width) ); - const uint32_t originalHeight( static_cast(imageSize.height) ); - const uint32_t paddedWidth( originalWidth + (fieldBorder * 2 ) ); - const uint32_t paddedHeight( originalHeight + (fieldBorder * 2 ) ); - const uint32_t scaledWidth( static_cast(distanceMapSize.width) ); - const uint32_t scaledHeight( static_cast(distanceMapSize.height) ); - const uint32_t maxWidth( static_cast(maxSize.width) + (fieldBorder * 2 )); - const uint32_t maxHeight( static_cast(maxSize.height) + (fieldBorder * 2 ) ); + const uint32_t originalWidth(static_cast(imageSize.width)); + const uint32_t originalHeight(static_cast(imageSize.height)); + const uint32_t paddedWidth(originalWidth + (fieldBorder * 2)); + const uint32_t paddedHeight(originalHeight + (fieldBorder * 2)); + const uint32_t scaledWidth(static_cast(distanceMapSize.width)); + const uint32_t scaledHeight(static_cast(distanceMapSize.height)); + const uint32_t maxWidth(static_cast(maxSize.width) + (fieldBorder * 2)); + const uint32_t maxHeight(static_cast(maxSize.height) + (fieldBorder * 2)); - const uint32_t bufferLength( std::max( maxWidth, std::max(paddedWidth, scaledWidth) ) * - std::max( maxHeight, std::max(paddedHeight, scaledHeight) ) ); + const uint32_t bufferLength(std::max(maxWidth, std::max(paddedWidth, scaledWidth)) * + std::max(maxHeight, std::max(paddedHeight, scaledHeight))); - std::vector outsidePixels( bufferLength, 0.0f ); - std::vector insidePixels( bufferLength, 0.0f ); + std::vector outsidePixels(bufferLength, 0.0f); + std::vector insidePixels(bufferLength, 0.0f); - float* outside( outsidePixels.data() ); - float* inside( insidePixels.data() ); + float* outside(outsidePixels.data()); + float* inside(insidePixels.data()); - for( uint32_t y = 0; y < paddedHeight; ++y ) + for(uint32_t y = 0; y < paddedHeight; ++y) { - for ( uint32_t x = 0; x < paddedWidth; ++x) + for(uint32_t x = 0; x < paddedWidth; ++x) { - if( y < static_cast< uint32_t >( fieldBorder ) || y >= ( paddedHeight - static_cast< uint32_t >( fieldBorder ) ) || - x < static_cast< uint32_t >( fieldBorder ) || x >= ( paddedWidth - static_cast< uint32_t >( fieldBorder ) ) ) + if(y < static_cast(fieldBorder) || + y >= (paddedHeight - static_cast(fieldBorder)) || + x < static_cast(fieldBorder) || + x >= (paddedWidth - static_cast(fieldBorder))) { - outside[ y * paddedWidth + x ] = MAX_DISTANCE; - inside[ y * paddedWidth + x ] = 0.0f; + outside[y * paddedWidth + x] = MAX_DISTANCE; + inside[y * paddedWidth + x] = 0.0f; } else { - uint32_t pixel( imagePixels[ (y - fieldBorder) * originalWidth + (x - fieldBorder) ] ); - outside[ y * paddedWidth + x ] = (pixel == 0) ? MAX_DISTANCE : SQUARE( static_cast(255 - pixel) / 255.0f); - inside[ y * paddedWidth + x ] = (pixel == 255) ? MAX_DISTANCE : SQUARE( static_cast(pixel) / 255.0f); + uint32_t pixel(imagePixels[(y - fieldBorder) * originalWidth + (x - fieldBorder)]); + outside[y * paddedWidth + x] = (pixel == 0) ? MAX_DISTANCE : SQUARE(static_cast(255 - pixel) / 255.0f); + inside[y * paddedWidth + x] = (pixel == 255) ? MAX_DISTANCE : SQUARE(static_cast(pixel) / 255.0f); } } } // perform distance transform if high quality requested, else use original figure - if( highQuality ) + if(highQuality) { // create temporary buffers for DistanceTransform() - const uint32_t tempBufferLength( std::max(paddedWidth, paddedHeight) ); - std::vector tempSourceBuffer( tempBufferLength, 0.0f ); - std::vector tempDestBuffer( tempBufferLength, 0.0f ); + const uint32_t tempBufferLength(std::max(paddedWidth, paddedHeight)); + std::vector tempSourceBuffer(tempBufferLength, 0.0f); + std::vector tempDestBuffer(tempBufferLength, 0.0f); // Perform distance transform for pixels 'outside' the figure - DistanceTransform( outside, paddedWidth, paddedHeight, tempSourceBuffer.data(), tempDestBuffer.data() ); + DistanceTransform(outside, paddedWidth, paddedHeight, tempSourceBuffer.data(), tempDestBuffer.data()); // Perform distance transform for pixels 'inside' the figure - DistanceTransform( inside, paddedWidth, paddedHeight, tempSourceBuffer.data(), tempDestBuffer.data() ); + DistanceTransform(inside, paddedWidth, paddedHeight, tempSourceBuffer.data(), tempDestBuffer.data()); } // distmap = outside - inside; % Bipolar distance field - for( uint32_t y = 0; y < paddedHeight; ++y) + for(uint32_t y = 0; y < paddedHeight; ++y) { - for( uint32_t x = 0; x < paddedWidth; ++x ) + for(uint32_t x = 0; x < paddedWidth; ++x) { - const int32_t offset( y * paddedWidth + x ); - float pixel( sqrtf(outside[offset]) - sqrtf(inside[offset]) ); - pixel = 128.0f + pixel * 16.0f; - pixel = Clamp( pixel, 0.0f, 255.0f ); + const int32_t offset(y * paddedWidth + x); + float pixel(sqrtf(outside[offset]) - sqrtf(inside[offset])); + pixel = 128.0f + pixel * 16.0f; + pixel = Clamp(pixel, 0.0f, 255.0f); outside[offset] = (255.0f - pixel) / 255.0f; } } // scale the figure to the distance field tile size - ScaleField( paddedWidth, paddedHeight, outside, scaledWidth, scaledHeight, inside ); + ScaleField(paddedWidth, paddedHeight, outside, scaledWidth, scaledHeight, inside); // convert from floats to integers - for( uint32_t y = 0; y < scaledHeight; ++y ) + for(uint32_t y = 0; y < scaledHeight; ++y) { - for( uint32_t x = 0; x < scaledWidth; ++x ) + for(uint32_t x = 0; x < scaledWidth; ++x) { - float pixel( inside[ y * scaledWidth + x ] ); - distanceMap[y * scaledWidth + x ] = static_cast< uint8_t >(pixel * 255.0f); + float pixel(inside[y * scaledWidth + x]); + distanceMap[y * scaledWidth + x] = static_cast(pixel * 255.0f); } } } diff --git a/dali/devel-api/images/distance-field.h b/dali/devel-api/images/distance-field.h index 884a76d..375b73e 100644 --- a/dali/devel-api/images/distance-field.h +++ b/dali/devel-api/images/distance-field.h @@ -2,7 +2,7 @@ #define DALI_DISTANCE_FIELD_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -26,7 +26,6 @@ namespace Dali { - struct Vector2; /** @@ -41,11 +40,14 @@ struct Vector2; * @param[in] maxSize The image is scaled from this size to distanceMapSize * @param[in] highQuality Set true to generate high quality distance fields */ -DALI_CORE_API void GenerateDistanceFieldMap( const uint8_t* const imagePixels, const Vector2& imageSize, - uint8_t* const distanceMap, const Vector2& distanceMapSize, - const uint32_t fieldBorder, - const Vector2& maxSize, - bool highQuality = true ); +DALI_CORE_API void GenerateDistanceFieldMap( + const uint8_t* const imagePixels, + const Vector2& imageSize, + uint8_t* const distanceMap, + const Vector2& distanceMapSize, + const uint32_t fieldBorder, + const Vector2& maxSize, + bool highQuality = true); } //namespace Dali diff --git a/dali/devel-api/images/pixel-data-devel.cpp b/dali/devel-api/images/pixel-data-devel.cpp index eb0ac1f..6a3c495 100644 --- a/dali/devel-api/images/pixel-data-devel.cpp +++ b/dali/devel-api/images/pixel-data-devel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -23,14 +23,12 @@ namespace Dali { - namespace DevelPixelData { - -PixelDataBuffer ReleasePixelDataBuffer( PixelData& pixelData ) +PixelDataBuffer ReleasePixelDataBuffer(PixelData& pixelData) { - Internal::PixelData& pixelDataImpl = GetImplementation( pixelData ); - PixelDataBuffer pixelDataBuffer = pixelDataImpl.ReleaseBuffer(); + Internal::PixelData& pixelDataImpl = GetImplementation(pixelData); + PixelDataBuffer pixelDataBuffer = pixelDataImpl.ReleaseBuffer(); pixelData.Reset(); return pixelDataBuffer; } diff --git a/dali/devel-api/images/pixel-data-devel.h b/dali/devel-api/images/pixel-data-devel.h old mode 100755 new mode 100644 index 5e1a659..52af2e2 --- a/dali/devel-api/images/pixel-data-devel.h +++ b/dali/devel-api/images/pixel-data-devel.h @@ -2,7 +2,7 @@ #define DALI_PIXEL_DATA_DEVEL_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -27,10 +27,8 @@ namespace Dali { - namespace DevelPixelData { - /** * Struct to keep the buffer pointer and the allocation method. * @@ -40,13 +38,13 @@ namespace DevelPixelData */ struct PixelDataBuffer { - uint8_t* buffer; - uint32_t bufferSize; + uint8_t* buffer; + uint32_t bufferSize; PixelData::ReleaseFunction releaseFunction; - PixelDataBuffer( uint8_t* buffer, - uint32_t bufferSize, - PixelData::ReleaseFunction releaseFunction ) + PixelDataBuffer(uint8_t* buffer, + uint32_t bufferSize, + PixelData::ReleaseFunction releaseFunction) : buffer(buffer), bufferSize(bufferSize), releaseFunction(releaseFunction) @@ -60,10 +58,10 @@ struct PixelDataBuffer * @param[in,out] pixelData The pixel data object to take the buffer from * @return the buffer and the data release mechanism */ -DALI_CORE_API PixelDataBuffer ReleasePixelDataBuffer( PixelData& pixelData ); +DALI_CORE_API PixelDataBuffer ReleasePixelDataBuffer(PixelData& pixelData); } // namespace DevelPixelData -} // Dali +} // namespace Dali #endif // DALI_PIXEL_DATA_DEVEL_H diff --git a/dali/devel-api/object/csharp-type-info.h b/dali/devel-api/object/csharp-type-info.h index 0408bd9..e28bd31 100644 --- a/dali/devel-api/object/csharp-type-info.h +++ b/dali/devel-api/object/csharp-type-info.h @@ -24,17 +24,15 @@ namespace Dali { - namespace CSharpTypeInfo { - /** * @brief Call back used to create an instance of the associated object type * * @param[in] typeName The type name of the object to be created. * @return Pointer to a BaseHandle */ -using CreateFunction = BaseHandle *(*)( const char *const ); +using CreateFunction = BaseHandle* (*)(const char* const); /** * @brief Callback to set an event-thread only property. @@ -44,7 +42,7 @@ using CreateFunction = BaseHandle *(*)( const char *const ); * @param[in] value The new value of the property for the object specified. * @see PropertyRegistration. */ -using SetPropertyFunction = void ( * )( BaseObject *, const char *const, Property::Value * ); +using SetPropertyFunction = void (*)(BaseObject*, const char* const, Property::Value*); /** * @brief Callback to get the value of an event-thread only property. @@ -54,8 +52,8 @@ using SetPropertyFunction = void ( * )( BaseObject *, const char *const, Propert * @return The current value of the property for the object specified. * @see PropertyRegistration. */ -using GetPropertyFunction = Property::Value *(*)( BaseObject *, const char *const ); -} +using GetPropertyFunction = Property::Value* (*)(BaseObject*, const char* const); +} // namespace CSharpTypeInfo } // namespace Dali diff --git a/dali/devel-api/object/csharp-type-registry.cpp b/dali/devel-api/object/csharp-type-registry.cpp index 20186d6..40e6525 100644 --- a/dali/devel-api/object/csharp-type-registry.cpp +++ b/dali/devel-api/object/csharp-type-registry.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -23,32 +23,29 @@ namespace Dali { - namespace CSharpTypeRegistry { - -bool RegisterType( const std::string& name, const std::type_info& baseType, CSharpTypeInfo::CreateFunction f ) +bool RegisterType(const std::string& name, const std::type_info& baseType, CSharpTypeInfo::CreateFunction f) { - Internal::TypeRegistry *impl = Internal::TypeRegistry::Get(); + Internal::TypeRegistry* impl = Internal::TypeRegistry::Get(); - impl->Register( name, baseType, f ); + impl->Register(name, baseType, f); return true; } -bool RegisterProperty( const std::string& objectName, - const std::string& name, - Property::Index index, - Property::Type type, - CSharpTypeInfo::SetPropertyFunction setFunc, - CSharpTypeInfo::GetPropertyFunction getFunc ) +bool RegisterProperty(const std::string& objectName, + const std::string& name, + Property::Index index, + Property::Type type, + CSharpTypeInfo::SetPropertyFunction setFunc, + CSharpTypeInfo::GetPropertyFunction getFunc) { + Internal::TypeRegistry* impl = Internal::TypeRegistry::Get(); - Internal::TypeRegistry *impl = Internal::TypeRegistry::Get(); - - return impl->RegisterProperty( objectName, name, index, type, setFunc, getFunc ); + return impl->RegisterProperty(objectName, name, index, type, setFunc, getFunc); } -} +} // namespace CSharpTypeRegistry } // namespace Dali diff --git a/dali/devel-api/object/csharp-type-registry.h b/dali/devel-api/object/csharp-type-registry.h index 0f28e32..871e668 100644 --- a/dali/devel-api/object/csharp-type-registry.h +++ b/dali/devel-api/object/csharp-type-registry.h @@ -2,7 +2,7 @@ #define DALI_CSHARP_TYPE_REGISTRY_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -18,26 +18,21 @@ * */ - // EXTERNAL INCLUDES #include - // INTERNAL INCLUDES -#include #include +#include namespace Dali { - - /** * Custom static functions for registering C# custom controls and properties * */ namespace CSharpTypeRegistry { - /** * @brief Constructor registers the type creation function for a named class or type. * @@ -48,11 +43,11 @@ namespace CSharpTypeRegistry * @param [in] f registerType instance creation function * @return true if the name could be registered. */ - DALI_CORE_API bool RegisterType( const std::string& name, - const std::type_info& baseType, - CSharpTypeInfo::CreateFunction f ); +DALI_CORE_API bool RegisterType(const std::string& name, + const std::type_info& baseType, + CSharpTypeInfo::CreateFunction f); - /** +/** * Register an event-thread only property with a type (used by C# Custom controls) * @param [in] objectName name of the object used to register the type * @param [in] name Property name @@ -62,13 +57,13 @@ namespace CSharpTypeRegistry * @param [in] getFunc The function to get the value of a property. * @return true if the property could be registered. */ - DALI_CORE_API bool RegisterProperty( const std::string& objectName, - const std::string& name, - Property::Index index, - Property::Type type, - CSharpTypeInfo::SetPropertyFunction setFunc, - CSharpTypeInfo::GetPropertyFunction getFunc ); -} +DALI_CORE_API bool RegisterProperty(const std::string& objectName, + const std::string& name, + Property::Index index, + Property::Type type, + CSharpTypeInfo::SetPropertyFunction setFunc, + CSharpTypeInfo::GetPropertyFunction getFunc); +} // namespace CSharpTypeRegistry } // namespace Dali diff --git a/dali/devel-api/object/handle-devel.cpp b/dali/devel-api/object/handle-devel.cpp index d062531..8600816 100644 --- a/dali/devel-api/object/handle-devel.cpp +++ b/dali/devel-api/object/handle-devel.cpp @@ -19,19 +19,17 @@ #include // INTERNAL INCLUDES -#include #include #include +#include namespace Dali { - namespace DevelHandle { - -void SetTypeInfo( Handle& handle, const TypeInfo& typeInfo ) +void SetTypeInfo(Handle& handle, const TypeInfo& typeInfo) { - GetImplementation( handle ).SetTypeInfo( &GetImplementation( typeInfo ) ); + GetImplementation(handle).SetTypeInfo(&GetImplementation(typeInfo)); } } // namespace DevelHandle diff --git a/dali/devel-api/object/handle-devel.h b/dali/devel-api/object/handle-devel.h index d6b6530..19d08a7 100644 --- a/dali/devel-api/object/handle-devel.h +++ b/dali/devel-api/object/handle-devel.h @@ -23,10 +23,8 @@ namespace Dali { - namespace DevelHandle { - /** * @brief Set the type-info that the object is created by. * @@ -35,7 +33,7 @@ namespace DevelHandle * @param[in] handle The handle created by this TypeInfo. * @param[in] typeInfo The TypeInfo that creates the handle. */ -DALI_CORE_API void SetTypeInfo( Handle& handle, const TypeInfo& typeInfo ); +DALI_CORE_API void SetTypeInfo(Handle& handle, const TypeInfo& typeInfo); } // namespace DevelHandle diff --git a/dali/devel-api/object/property-helper-devel.h b/dali/devel-api/object/property-helper-devel.h index fc93ecf..c1e70d1 100644 --- a/dali/devel-api/object/property-helper-devel.h +++ b/dali/devel-api/object/property-helper-devel.h @@ -27,13 +27,13 @@ * These internal macros exist as to perform the compile-time check on the enumeration order, the __COUNTER__ macro is used twice. * Using it twice within the same macro would result in two different values. */ -#define DALI_DEVEL_PROPERTY_REGISTRATION_INTERNAL( count, typeRegistrationObject, objectNamespace, objectType, develNamespace, text, valueType, enumIndex ) \ - Dali::PropertyRegistration DALI_TOKEN_PASTE( property, count ) ( typeRegistrationObject, text, objectNamespace:: develNamespace ::Property::enumIndex, Dali::Property::valueType, &objectType::SetProperty, &objectType::GetProperty ); \ - static_assert( ( objectNamespace:: develNamespace ::Property::enumIndex - objectNamespace::objectType::PROPERTY_START_INDEX ) == count ); +#define DALI_DEVEL_PROPERTY_REGISTRATION_INTERNAL(count, typeRegistrationObject, objectNamespace, objectType, develNamespace, text, valueType, enumIndex) \ + Dali::PropertyRegistration DALI_TOKEN_PASTE(property, count)(typeRegistrationObject, text, objectNamespace::develNamespace ::Property::enumIndex, Dali::Property::valueType, &objectType::SetProperty, &objectType::GetProperty); \ + static_assert((objectNamespace::develNamespace ::Property::enumIndex - objectNamespace::objectType::PROPERTY_START_INDEX) == count); -#define DALI_DEVEL_PROPERTY_REGISTRATION_INTERNAL_READ_ONLY( count, typeRegistrationObject, objectNamespace, objectType, develNamespace, text, valueType, enumIndex ) \ - Dali::PropertyRegistration DALI_TOKEN_PASTE( property, count ) ( typeRegistrationObject, text, objectNamespace:: develNamespace ::Property::enumIndex, Dali::Property::valueType, NULL, &objectType::GetProperty ); \ - static_assert( ( objectNamespace:: develNamespace ::Property::enumIndex - objectNamespace::objectType::PROPERTY_START_INDEX ) == count ); +#define DALI_DEVEL_PROPERTY_REGISTRATION_INTERNAL_READ_ONLY(count, typeRegistrationObject, objectNamespace, objectType, develNamespace, text, valueType, enumIndex) \ + Dali::PropertyRegistration DALI_TOKEN_PASTE(property, count)(typeRegistrationObject, text, objectNamespace::develNamespace ::Property::enumIndex, Dali::Property::valueType, NULL, &objectType::GetProperty); \ + static_assert((objectNamespace::develNamespace ::Property::enumIndex - objectNamespace::objectType::PROPERTY_START_INDEX) == count); /** * @brief These macros are used to define properties for implementations of CustomActor. @@ -85,24 +85,24 @@ * Using these macros have certain prerequisites on how the property enumeration is defined. * Please see the Programming Guide (within the generated Doxygen) for full details. */ -#define DALI_DEVEL_PROPERTY_REGISTRATION( objectNamespace, objectType, text, valueType, enumIndex ) \ - DALI_DEVEL_PROPERTY_REGISTRATION_INTERNAL( __COUNTER__, typeRegistration, objectNamespace, objectType, DALI_TOKEN_PASTE( Devel, objectType ), text, valueType, enumIndex ) +#define DALI_DEVEL_PROPERTY_REGISTRATION(objectNamespace, objectType, text, valueType, enumIndex) \ + DALI_DEVEL_PROPERTY_REGISTRATION_INTERNAL(__COUNTER__, typeRegistration, objectNamespace, objectType, DALI_TOKEN_PASTE(Devel, objectType), text, valueType, enumIndex) /** * @copydoc DALI_DEVEL_PROPERTY_REGISTRATION * * @note For Read Only properties */ -#define DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY( objectNamespace, objectType, text, valueType, enumIndex ) \ - DALI_DEVEL_PROPERTY_REGISTRATION_INTERNAL_READ_ONLY( __COUNTER__, typeRegistration, objectNamespace, objectType, DALI_TOKEN_PASTE( Devel, objectType ), text, valueType, enumIndex ) +#define DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY(objectNamespace, objectType, text, valueType, enumIndex) \ + DALI_DEVEL_PROPERTY_REGISTRATION_INTERNAL_READ_ONLY(__COUNTER__, typeRegistration, objectNamespace, objectType, DALI_TOKEN_PASTE(Devel, objectType), text, valueType, enumIndex) /** * @copydoc DALI_DEVEL_PROPERTY_REGISTRATION * * @note Animatable property registration */ -#define DALI_DEVEL_ANIMATABLE_PROPERTY_REGISTRATION( objectNamespace, objectType, text, valueType, enumIndex ) \ - DALI_ANIMATABLE_PROPERTY_REGISTRATION_INTERNAL( __COUNTER__, typeRegistration, objectNamespace, objectType, DALI_TOKEN_PASTE( Devel, objectType ), text, valueType, enumIndex ) +#define DALI_DEVEL_ANIMATABLE_PROPERTY_REGISTRATION(objectNamespace, objectType, text, valueType, enumIndex) \ + DALI_ANIMATABLE_PROPERTY_REGISTRATION_INTERNAL(__COUNTER__, typeRegistration, objectNamespace, objectType, DALI_TOKEN_PASTE(Devel, objectType), text, valueType, enumIndex) /** * @copydoc DALI_DEVEL_PROPERTY_REGISTRATION @@ -110,8 +110,8 @@ * @note Animatable property registration with default value * */ -#define DALI_DEVEL_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT( objectNamespace, objectType, text, value, enumIndex ) \ - DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT_INTERNAL( __COUNTER__, typeRegistration, objectNamespace, DALI_TOKEN_PASTE( Devel, objectType ) , text, value, enumIndex ) +#define DALI_DEVEL_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT(objectNamespace, objectType, text, value, enumIndex) \ + DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT_INTERNAL(__COUNTER__, typeRegistration, objectNamespace, DALI_TOKEN_PASTE(Devel, objectType), text, value, enumIndex) /** * @copydoc DALI_DEVEL_PROPERTY_REGISTRATION @@ -119,7 +119,7 @@ * @note Component registration for a Devel Animatable property * */ -#define DALI_DEVEL_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( objectNamespace, objectType, text, enumIndex, baseEnumIndex, componentIndex ) \ - DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION_INTERNAL( __COUNTER__, typeRegistration, objectNamespace, DALI_TOKEN_PASTE( Devel, objectType ), text, enumIndex, baseEnumIndex, componentIndex ) +#define DALI_DEVEL_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION(objectNamespace, objectType, text, enumIndex, baseEnumIndex, componentIndex) \ + DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION_INTERNAL(__COUNTER__, typeRegistration, objectNamespace, DALI_TOKEN_PASTE(Devel, objectType), text, enumIndex, baseEnumIndex, componentIndex) #endif // DALI_PROPERTY_HELPER_DEVEL_H diff --git a/dali/devel-api/rendering/frame-buffer-devel.cpp b/dali/devel-api/rendering/frame-buffer-devel.cpp index d79ded7..fe0d072 100644 --- a/dali/devel-api/rendering/frame-buffer-devel.cpp +++ b/dali/devel-api/rendering/frame-buffer-devel.cpp @@ -23,54 +23,52 @@ namespace Dali { - namespace DevelFrameBuffer { - -void AttachDepthTexture( FrameBuffer frameBuffer, Texture& texture ) +void AttachDepthTexture(FrameBuffer frameBuffer, Texture& texture) { - AttachDepthTexture( frameBuffer, texture, 0u ); + AttachDepthTexture(frameBuffer, texture, 0u); } -void AttachDepthTexture( FrameBuffer frameBuffer, Texture& texture, uint32_t mipmapLevel ) +void AttachDepthTexture(FrameBuffer frameBuffer, Texture& texture, uint32_t mipmapLevel) { - if( texture ) + if(texture) { - Internal::TexturePtr texturePtr( &GetImplementation( texture ) ); - GetImplementation( frameBuffer ).AttachDepthTexture( texturePtr, mipmapLevel ); + Internal::TexturePtr texturePtr(&GetImplementation(texture)); + GetImplementation(frameBuffer).AttachDepthTexture(texturePtr, mipmapLevel); } } -void AttachDepthStencilTexture( FrameBuffer frameBuffer, Texture& texture ) +void AttachDepthStencilTexture(FrameBuffer frameBuffer, Texture& texture) { - AttachDepthStencilTexture( frameBuffer, texture, 0u ); + AttachDepthStencilTexture(frameBuffer, texture, 0u); } -void AttachDepthStencilTexture( FrameBuffer frameBuffer, Texture& texture, uint32_t mipmapLevel ) +void AttachDepthStencilTexture(FrameBuffer frameBuffer, Texture& texture, uint32_t mipmapLevel) { - if( texture ) + if(texture) { - Internal::TexturePtr texturePtr( &GetImplementation( texture ) ); - GetImplementation( frameBuffer ).AttachDepthStencilTexture( texturePtr, mipmapLevel ); + Internal::TexturePtr texturePtr(&GetImplementation(texture)); + GetImplementation(frameBuffer).AttachDepthStencilTexture(texturePtr, mipmapLevel); } } -Texture GetColorTexture( const FrameBuffer frameBuffer, uint8_t index ) +Texture GetColorTexture(const FrameBuffer frameBuffer, uint8_t index) { - Internal::Texture* texturePtr = GetImplementation( frameBuffer ).GetColorTexture(index); - return Dali::Texture( texturePtr ); + Internal::Texture* texturePtr = GetImplementation(frameBuffer).GetColorTexture(index); + return Dali::Texture(texturePtr); } -Texture GetDepthTexture( FrameBuffer frameBuffer ) +Texture GetDepthTexture(FrameBuffer frameBuffer) { Internal::Texture* texturePtr = GetImplementation(frameBuffer).GetDepthTexture(); - return Dali::Texture( texturePtr ); + return Dali::Texture(texturePtr); } -Texture GetDepthStencilTexture( FrameBuffer frameBuffer ) +Texture GetDepthStencilTexture(FrameBuffer frameBuffer) { Internal::Texture* texturePtr = GetImplementation(frameBuffer).GetDepthStencilTexture(); - return Dali::Texture( texturePtr ); + return Dali::Texture(texturePtr); } } // namespace DevelFrameBuffer diff --git a/dali/devel-api/rendering/frame-buffer-devel.h b/dali/devel-api/rendering/frame-buffer-devel.h index 64d58a4..2799887 100644 --- a/dali/devel-api/rendering/frame-buffer-devel.h +++ b/dali/devel-api/rendering/frame-buffer-devel.h @@ -23,10 +23,8 @@ namespace Dali { - namespace DevelFrameBuffer { - /** * @brief Maximum number of color attachments supported. */ @@ -41,7 +39,7 @@ constexpr uint8_t MAX_COLOR_ATTACHMENTS = 8; * @note The size of the texture has to be same as that of the frame buffer. * Otherwise, it won't be attached. */ -DALI_CORE_API void AttachDepthTexture( FrameBuffer frameBuffer, Texture& texture ); +DALI_CORE_API void AttachDepthTexture(FrameBuffer frameBuffer, Texture& texture); /** * @brief Attaches a depth texture to the frame buffer. @@ -53,7 +51,7 @@ DALI_CORE_API void AttachDepthTexture( FrameBuffer frameBuffer, Texture& texture * @note The size of the mipmapped texture has to be same as that of the frame buffer. * Otherwise, it won't be attached. */ -DALI_CORE_API void AttachDepthTexture( FrameBuffer frameBuffer, Texture& texture, uint32_t mipmapLevel ); +DALI_CORE_API void AttachDepthTexture(FrameBuffer frameBuffer, Texture& texture, uint32_t mipmapLevel); /** * @brief Attaches the base LOD of a stencil texture to the frame buffer. @@ -64,7 +62,7 @@ DALI_CORE_API void AttachDepthTexture( FrameBuffer frameBuffer, Texture& texture * @note The size of the texture has to be same as that of the frame buffer. * Otherwise, it won't be attached. */ -DALI_CORE_API void AttachDepthStencilTexture( FrameBuffer frameBuffer, Texture& texture ); +DALI_CORE_API void AttachDepthStencilTexture(FrameBuffer frameBuffer, Texture& texture); /** * @brief Attaches a depth/stencil texture to the frame buffer. @@ -76,7 +74,7 @@ DALI_CORE_API void AttachDepthStencilTexture( FrameBuffer frameBuffer, Texture& * @note The size of the mipmapped texture has to be same as that of the frame buffer. * Otherwise, it won't be attached. */ -DALI_CORE_API void AttachDepthStencilTexture( FrameBuffer frameBuffer, Texture& texture, uint32_t mipmapLevel ); +DALI_CORE_API void AttachDepthStencilTexture(FrameBuffer frameBuffer, Texture& texture, uint32_t mipmapLevel); /** * @brief Gets the color texture at the given @a index used as output in the frame buffer. @@ -89,7 +87,7 @@ DALI_CORE_API void AttachDepthStencilTexture( FrameBuffer frameBuffer, Texture& * @note A maximum of 8 color attachments are supported. Passing an invalid index will return * an uninitialized handle. */ -DALI_CORE_API Texture GetColorTexture( const FrameBuffer frameBuffer, uint8_t index ); +DALI_CORE_API Texture GetColorTexture(const FrameBuffer frameBuffer, uint8_t index); /** * @brief Gets the depth texture used as output in the frame buffer. @@ -98,7 +96,7 @@ DALI_CORE_API Texture GetColorTexture( const FrameBuffer frameBuffer, uint8_t in * * @return A handle of the texture used as depth output, or an uninitialized handle */ -DALI_CORE_API Texture GetDepthTexture( FrameBuffer frameBuffer ); +DALI_CORE_API Texture GetDepthTexture(FrameBuffer frameBuffer); /** * @brief Gets the depth/stencil texture used as output in the frame buffer. @@ -107,7 +105,7 @@ DALI_CORE_API Texture GetDepthTexture( FrameBuffer frameBuffer ); * * @return A handle of the texture used as depth/stencil output, or an uninitialized handle */ -DALI_CORE_API Texture GetDepthStencilTexture( FrameBuffer frameBuffer ); +DALI_CORE_API Texture GetDepthStencilTexture(FrameBuffer frameBuffer); } // namespace DevelFrameBuffer diff --git a/dali/devel-api/rendering/renderer-devel.cpp b/dali/devel-api/rendering/renderer-devel.cpp index 0d987cb..303f389 100644 --- a/dali/devel-api/rendering/renderer-devel.cpp +++ b/dali/devel-api/rendering/renderer-devel.cpp @@ -20,15 +20,13 @@ namespace Dali { - namespace DevelRenderer { - -void AddDrawCommand( Dali::Renderer renderer, const DrawCommand& drawCommand ) +void AddDrawCommand(Dali::Renderer renderer, const DrawCommand& drawCommand) { - auto& impl = GetImplementation( renderer ); - impl.AddDrawCommand( drawCommand ); + auto& impl = GetImplementation(renderer); + impl.AddDrawCommand(drawCommand); } -} // DevelRenderer -} // Dali \ No newline at end of file +} // namespace DevelRenderer +} // namespace Dali \ No newline at end of file diff --git a/dali/devel-api/rendering/renderer-devel.h b/dali/devel-api/rendering/renderer-devel.h index 8fb2032..59d9247 100644 --- a/dali/devel-api/rendering/renderer-devel.h +++ b/dali/devel-api/rendering/renderer-devel.h @@ -2,7 +2,7 @@ #define DALI_RENDERER_DEVEL_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -23,18 +23,16 @@ namespace Dali { - namespace DevelRenderer { - /** * The index of render queue used by the DrawCommand */ using RenderQueueIndex = uint32_t; -constexpr RenderQueueIndex RENDER_QUEUE_OPAQUE = 0; ///< Queue for opaque elements +constexpr RenderQueueIndex RENDER_QUEUE_OPAQUE = 0; ///< Queue for opaque elements constexpr RenderQueueIndex RENDER_QUEUE_TRANSPARENT = 1; ///( sizeof( t##_TABLE ) / sizeof( t##_TABLE[0] ) ); -#define DALI_ENUM_TO_STRING( s ) { #s, s }, +#define DALI_ENUM_TO_STRING_TABLE_BEGIN_WITH_TYPE(type, t) const type t##_TABLE[] = { +#define DALI_ENUM_TO_STRING_TABLE_BEGIN(t) DALI_ENUM_TO_STRING_TABLE_BEGIN_WITH_TYPE(Dali::Scripting::StringEnum, t) +#define DALI_ENUM_TO_STRING_TABLE_END(t) \ + } \ + ; \ + const uint32_t t##_TABLE_COUNT = static_cast(sizeof(t##_TABLE) / sizeof(t##_TABLE[0])); +#define DALI_ENUM_TO_STRING(s) {#s, s}, /** * Adds a value, typically an enum, to the table within a scope but without the scope name * Example converts ( Layer, LAYER_UI ) to ( "LAYER_UI", Layer::LayerUI ) */ -#define DALI_ENUM_TO_STRING_WITH_SCOPE( className, enumName ) { #enumName, className::enumName }, +#define DALI_ENUM_TO_STRING_WITH_SCOPE(className, enumName) {#enumName, className::enumName}, } // namespace Dali diff --git a/dali/devel-api/scripting/scripting.cpp b/dali/devel-api/scripting/scripting.cpp index ae05409..0e57935 100644 --- a/dali/devel-api/scripting/scripting.cpp +++ b/dali/devel-api/scripting/scripting.cpp @@ -19,25 +19,23 @@ #include // INTERNAL INCLUDES +#include #include -#include #include -#include +#include namespace Dali { - namespace Scripting { - -bool EnumStringToInteger( const char * const value, const StringEnum* const enumTable, uint32_t tableCount, int& integerEnum ) +bool EnumStringToInteger(const char* const value, const StringEnum* const enumTable, uint32_t tableCount, int& integerEnum) { int ret = 0; bool found = false; - bool done = false; + bool done = false; - if( value && enumTable && tableCount ) + if(value && enumTable && tableCount) { const char* pValue = value; @@ -47,9 +45,9 @@ bool EnumStringToInteger( const char * const value, const StringEnum* const enum const StringEnum* table = enumTable; - for ( uint32_t i = 0; i < tableCount; ++i ) + for(uint32_t i = 0; i < tableCount; ++i) { - if( Internal::CompareTokens( pValue, table->string, size ) ) + if(Internal::CompareTokens(pValue, table->string, size)) { found = true; ret |= table->value; @@ -63,103 +61,102 @@ bool EnumStringToInteger( const char * const value, const StringEnum* const enum if(found) { // allow comma separated or'd value - if( *(pValue+size) == ',' ) + if(*(pValue + size) == ',') { pValue += size + 1; done = false; } } - } integerEnum = ret; } - if ( !found ) + if(!found) { - DALI_LOG_ERROR( "Unknown enumeration string %s\n", value ); + DALI_LOG_ERROR("Unknown enumeration string %s\n", value); } return found; } -uint32_t FindEnumIndex( const char* value, const StringEnum* table, uint32_t tableCount ) +uint32_t FindEnumIndex(const char* value, const StringEnum* table, uint32_t tableCount) { uint32_t index = 0; - bool found = false; - for ( uint32_t i = 0; i < tableCount; ++i, ++index ) + bool found = false; + for(uint32_t i = 0; i < tableCount; ++i, ++index) { uint32_t sizeIgnored = 0; - if( Internal::CompareTokens( value, table->string, sizeIgnored ) ) + if(Internal::CompareTokens(value, table->string, sizeIgnored)) { found = true; break; } ++table; } - if ( !found ) + if(!found) { - DALI_LOG_ERROR( "Unknown enumeration string %s\n", value ); + DALI_LOG_ERROR("Unknown enumeration string %s\n", value); } return index; } -Actor NewActor( const Property::Map& map ) +Actor NewActor(const Property::Map& map) { BaseHandle handle; // First find type and create Actor - Property::Value* typeValue = map.Find( "type" ); - if ( typeValue ) + Property::Value* typeValue = map.Find("type"); + if(typeValue) { - TypeInfo type = TypeRegistry::Get().GetTypeInfo( typeValue->Get< std::string >() ); - if ( type ) + TypeInfo type = TypeRegistry::Get().GetTypeInfo(typeValue->Get()); + if(type) { handle = type.CreateInstance(); } } - if ( !handle ) + if(!handle) { - DALI_LOG_ERROR( "Actor type not provided\n" ); + DALI_LOG_ERROR("Actor type not provided\n"); return Actor(); } - Actor actor( Actor::DownCast( handle ) ); + Actor actor(Actor::DownCast(handle)); - if ( actor ) + if(actor) { // Now set the properties, or create children - for ( Property::Map::SizeType i = 0, mapCount = map.Count(); i < mapCount; ++i ) + for(Property::Map::SizeType i = 0, mapCount = map.Count(); i < mapCount; ++i) { - const KeyValuePair pair( map.GetKeyValue( i ) ); - if( pair.first.type == Property::Key::INDEX ) + const KeyValuePair pair(map.GetKeyValue(i)); + if(pair.first.type == Property::Key::INDEX) { continue; } - const std::string& key( pair.first.stringKey ); - if ( key == "type" ) + const std::string& key(pair.first.stringKey); + if(key == "type") { continue; } - const Property::Value& value( pair.second ); + const Property::Value& value(pair.second); - if ( key == "actors" ) + if(key == "actors") { // Create children - Property::Array actorArray = value.Get< Property::Array >(); - for ( Property::Array::SizeType i = 0; i < actorArray.Size(); ++i) + Property::Array actorArray = value.Get(); + for(Property::Array::SizeType i = 0; i < actorArray.Size(); ++i) { - actor.Add( NewActor( actorArray[i].Get< Property::Map >() ) ); + actor.Add(NewActor(actorArray[i].Get())); } } else { - Property::Index index( actor.GetPropertyIndex( key ) ); + Property::Index index(actor.GetPropertyIndex(key)); - if ( index != Property::INVALID_INDEX ) + if(index != Property::INVALID_INDEX) { - actor.SetProperty( index, value ); + actor.SetProperty(index, value); } } } @@ -168,156 +165,157 @@ Actor NewActor( const Property::Map& map ) return actor; } -void CreatePropertyMap( Actor actor, Property::Map& map ) +void CreatePropertyMap(Actor actor, Property::Map& map) { map.Clear(); - if ( actor ) + if(actor) { - map[ "type" ] = actor.GetTypeName(); + map["type"] = actor.GetTypeName(); // Default properties Property::IndexContainer indices; - actor.GetPropertyIndices( indices ); + actor.GetPropertyIndices(indices); const Property::IndexContainer::ConstIterator endIter = indices.End(); - for ( Property::IndexContainer::Iterator iter = indices.Begin(); iter != endIter; ++iter ) + for(Property::IndexContainer::Iterator iter = indices.Begin(); iter != endIter; ++iter) { - map[ actor.GetPropertyName( *iter ) ] = actor.GetProperty( *iter ); + map[actor.GetPropertyName(*iter)] = actor.GetProperty(*iter); } // Children - std::size_t childCount( actor.GetChildCount() ); - if ( childCount ) + std::size_t childCount(actor.GetChildCount()); + if(childCount) { Property::Array childArray; - for ( uint32_t child = 0; child < childCount; ++child ) + for(uint32_t child = 0; child < childCount; ++child) { Property::Map childMap; - CreatePropertyMap( actor.GetChildAt( child ), childMap ); - childArray.PushBack( childMap ); + CreatePropertyMap(actor.GetChildAt(child), childMap); + childArray.PushBack(childMap); } - map[ "actors" ] = childArray; + map["actors"] = childArray; } } } -void NewAnimation( const Property::Map& map, Dali::AnimationData& outputAnimationData ) +void NewAnimation(const Property::Map& map, Dali::AnimationData& outputAnimationData) { // Note: Builder cannot currently pass generic Property::Maps "{" that are nested, so currently we can only have one AnimateTo per animation. Dali::AnimationData::AnimationDataElement* element = new Dali::AnimationData::AnimationDataElement(); - element->alphaFunction = AlphaFunction::LINEAR; - element->timePeriodDelay = 0.0f; + + element->alphaFunction = AlphaFunction::LINEAR; + element->timePeriodDelay = 0.0f; element->timePeriodDuration = 1.0f; // Now set the properties, or create children - for( Property::Map::SizeType i = 0, animationMapCount = map.Count(); i < animationMapCount; ++i ) + for(Property::Map::SizeType i = 0, animationMapCount = map.Count(); i < animationMapCount; ++i) { - const KeyValuePair pair( map.GetKeyValue( i ) ); - if( pair.first.type == Property::Key::INDEX ) + const KeyValuePair pair(map.GetKeyValue(i)); + if(pair.first.type == Property::Key::INDEX) { continue; // We don't consider index keys. } - const std::string& key( pair.first.stringKey ); + const std::string& key(pair.first.stringKey); - const Property::Value& value( pair.second ); + const Property::Value& value(pair.second); - if( key == "actor" ) + if(key == "actor") { - element->actor = value.Get< std::string >(); + element->actor = value.Get(); } - else if( key == "property" ) + else if(key == "property") { - element->property = value.Get< std::string >(); + element->property = value.Get(); } - else if( key == "value" ) + else if(key == "value") { element->value = value; } - else if( key == "alphaFunction" ) + else if(key == "alphaFunction") { - std::string alphaFunctionValue = value.Get< std::string >(); + std::string alphaFunctionValue = value.Get(); - if( alphaFunctionValue == "LINEAR" ) + if(alphaFunctionValue == "LINEAR") { element->alphaFunction = AlphaFunction::LINEAR; } - else if( alphaFunctionValue == "REVERSE" ) + else if(alphaFunctionValue == "REVERSE") { element->alphaFunction = AlphaFunction::REVERSE; } - else if( alphaFunctionValue == "EASE_IN_SQUARE" ) + else if(alphaFunctionValue == "EASE_IN_SQUARE") { element->alphaFunction = AlphaFunction::EASE_IN_SQUARE; } - else if( alphaFunctionValue == "EASE_OUT_SQUARE" ) + else if(alphaFunctionValue == "EASE_OUT_SQUARE") { element->alphaFunction = AlphaFunction::EASE_OUT_SQUARE; } - else if( alphaFunctionValue == "EASE_IN" ) + else if(alphaFunctionValue == "EASE_IN") { element->alphaFunction = AlphaFunction::EASE_IN; } - else if( alphaFunctionValue == "EASE_OUT" ) + else if(alphaFunctionValue == "EASE_OUT") { element->alphaFunction = AlphaFunction::EASE_OUT; } - else if( alphaFunctionValue == "EASE_IN_OUT" ) + else if(alphaFunctionValue == "EASE_IN_OUT") { element->alphaFunction = AlphaFunction::EASE_IN_OUT; } - else if( alphaFunctionValue == "EASE_IN_SINE" ) + else if(alphaFunctionValue == "EASE_IN_SINE") { element->alphaFunction = AlphaFunction::EASE_IN_SINE; } - else if( alphaFunctionValue == "EASE_OUT_SINE" ) + else if(alphaFunctionValue == "EASE_OUT_SINE") { element->alphaFunction = AlphaFunction::EASE_OUT_SINE; } - else if( alphaFunctionValue == "EASE_IN_OUT_SINE" ) + else if(alphaFunctionValue == "EASE_IN_OUT_SINE") { element->alphaFunction = AlphaFunction::EASE_IN_OUT_SINE; } - else if( alphaFunctionValue == "BOUNCE" ) + else if(alphaFunctionValue == "BOUNCE") { element->alphaFunction = AlphaFunction::BOUNCE; } - else if( alphaFunctionValue == "SIN" ) + else if(alphaFunctionValue == "SIN") { element->alphaFunction = AlphaFunction::SIN; } - else if( alphaFunctionValue == "EASE_OUT_BACK" ) + else if(alphaFunctionValue == "EASE_OUT_BACK") { element->alphaFunction = AlphaFunction::EASE_OUT_BACK; } } - else if( key == "timePeriod" ) + else if(key == "timePeriod") { - Property::Map timeMap = value.Get< Property::Map >(); - for( Property::Map::SizeType i = 0; i < timeMap.Count(); ++i ) + Property::Map timeMap = value.Get(); + for(Property::Map::SizeType i = 0; i < timeMap.Count(); ++i) { - const KeyValuePair timePair( timeMap.GetKeyValue( i ) ); - if( timePair.first.type == Property::Key::INDEX ) + const KeyValuePair timePair(timeMap.GetKeyValue(i)); + if(timePair.first.type == Property::Key::INDEX) { continue; } - const std::string& key( timePair.first.stringKey ); + const std::string& key(timePair.first.stringKey); - if( key == "delay" ) + if(key == "delay") { - element->timePeriodDelay = timePair.second.Get< float >(); + element->timePeriodDelay = timePair.second.Get(); } - else if( key == "duration" ) + else if(key == "duration") { - element->timePeriodDuration = timePair.second.Get< float >(); + element->timePeriodDuration = timePair.second.Get(); } } } } - outputAnimationData.Add( element ); + outputAnimationData.Add(element); } -} // namespace scripting +} // namespace Scripting } // namespace Dali diff --git a/dali/devel-api/scripting/scripting.h b/dali/devel-api/scripting/scripting.h index c2f79d2..cc6a3f2 100644 --- a/dali/devel-api/scripting/scripting.h +++ b/dali/devel-api/scripting/scripting.h @@ -19,16 +19,15 @@ */ // INTERNAL INCLUDES +#include #include #include -#include #include #include #include namespace Dali { - class Actor; /** @@ -36,14 +35,13 @@ class Actor; */ namespace Scripting { - /** * @brief Structure which stores an enumeration and its string equivalent. */ struct StringEnum { - const char* string; ///< The string representation - const int32_t value; ///< The enumeration value wrapped in int + const char* string; ///< The string representation + const int32_t value; ///< The enumeration value wrapped in int }; /** @@ -54,7 +52,7 @@ struct StringEnum * @param[in] tableCount Number of items in the array. * @return The index of the enumeration. If enumeration is not found, logs an error and returns tableCount. */ -DALI_CORE_API uint32_t FindEnumIndex( const char* value, const StringEnum* table, uint32_t tableCount ); +DALI_CORE_API uint32_t FindEnumIndex(const char* value, const StringEnum* table, uint32_t tableCount); /** * @brief Find the enum as an integer from the table @@ -67,7 +65,7 @@ DALI_CORE_API uint32_t FindEnumIndex( const char* value, const StringEnum* table * @param[out] integerEnum The value of the enum. * @return true if one or more enums in value. */ -DALI_CORE_API bool EnumStringToInteger( const char* const value, const StringEnum* const table, uint32_t tableCount, int& integerEnum ); +DALI_CORE_API bool EnumStringToInteger(const char* const value, const StringEnum* const table, uint32_t tableCount, int& integerEnum); /** * @brief Chooses the appropriate enumeration for the provided string from the given table. @@ -79,17 +77,17 @@ DALI_CORE_API bool EnumStringToInteger( const char* const value, const StringEnu * * @return True if the value was found from the table */ -template< typename T > -bool GetEnumeration( const char* value, const StringEnum* table, uint32_t tableCount, T& result ) +template +bool GetEnumeration(const char* value, const StringEnum* table, uint32_t tableCount, T& result) { - bool retVal( false ); - if( table ) + bool retVal(false); + if(table) { int integerEnum = 0; // check to avoid crash, not asserting on purpose, error is logged instead - if( EnumStringToInteger( value, table, tableCount, integerEnum ) ) + if(EnumStringToInteger(value, table, tableCount, integerEnum)) { - result = static_cast( integerEnum ); + result = static_cast(integerEnum); retVal = true; } } @@ -106,27 +104,27 @@ bool GetEnumeration( const char* value, const StringEnum* table, uint32_t tableC * @param[out] result The enum value. This is not modified if the enumeration could not be converted. * @return True if the value was found successfully AND the value has changed. This is to allow the caller to do nothing if there is no change. */ -template< typename T > -bool GetEnumerationProperty( const Property::Value& propertyValue, const StringEnum* table, uint32_t tableCount, T& result ) +template +bool GetEnumerationProperty(const Property::Value& propertyValue, const StringEnum* table, uint32_t tableCount, T& result) { - int newValue; - bool set = false; + int newValue; + bool set = false; Property::Type type = propertyValue.GetType(); - if( type == Property::INTEGER ) + if(type == Property::INTEGER) { // Attempt to fetch the property as an INTEGER type. - if( propertyValue.Get( newValue ) ) + if(propertyValue.Get(newValue)) { // Success. set = true; } } - else if( type == Property::STRING ) + else if(type == Property::STRING) { // Attempt to fetch the property as an STRING type, and convert it from string to enumeration value. std::string propertyString; - if( table && propertyValue.Get( propertyString ) && EnumStringToInteger( propertyString.c_str(), table, tableCount, newValue ) ) + if(table && propertyValue.Get(propertyString) && EnumStringToInteger(propertyString.c_str(), table, tableCount, newValue)) { // Success. set = true; @@ -134,9 +132,9 @@ bool GetEnumerationProperty( const Property::Value& propertyValue, const StringE } // If the property was converted OK, AND the value has changed, update the result and return true. - if( set && ( result != static_cast( newValue ) ) ) + if(set && (result != static_cast(newValue))) { - result = static_cast( newValue ); + result = static_cast(newValue); return true; } @@ -154,27 +152,27 @@ bool GetEnumerationProperty( const Property::Value& propertyValue, const StringE * @param[out] result The enum value. This is not modified if the enumeration could not be converted. * @return True if the value was found successfully AND the value has changed. This is to allow the caller to do nothing if there is no change. */ -template< typename T > -bool GetBitmaskEnumerationProperty( const Property::Value& propertyValue, const Scripting::StringEnum* table, uint32_t tableCount, T& result ) +template +bool GetBitmaskEnumerationProperty(const Property::Value& propertyValue, const Scripting::StringEnum* table, uint32_t tableCount, T& result) { bool returnValue = true; // Evaluate as a single INTEGER or STRING first. - if( !GetEnumerationProperty( propertyValue, table, tableCount, result ) ) + if(!GetEnumerationProperty(propertyValue, table, tableCount, result)) { // If not, then check if it's an ARRAY - if ( propertyValue.GetType() == Property::ARRAY ) + if(propertyValue.GetType() == Property::ARRAY) { - int newValue = 0; + int newValue = 0; Property::Array array; - propertyValue.Get( array ); - for( Property::Array::SizeType i = 0; i < array.Count(); ++i ) + propertyValue.Get(array); + for(Property::Array::SizeType i = 0; i < array.Count(); ++i) { - Property::Value currentValue = array[ i ]; + Property::Value currentValue = array[i]; // Use an initial value of -1 so any successful property conversion // causes a change (and true to be returned). - T current = static_cast< T >( -1 ); - if( GetEnumerationProperty( currentValue, table, tableCount, current ) ) + T current = static_cast(-1); + if(GetEnumerationProperty(currentValue, table, tableCount, current)) { newValue |= current; } @@ -187,9 +185,9 @@ bool GetBitmaskEnumerationProperty( const Property::Value& propertyValue, const } // If we didn't hit an invalid type and the value has changed, update the result. - if( returnValue && ( result != static_cast( newValue ) ) ) + if(returnValue && (result != static_cast(newValue))) { - result = static_cast( newValue ); + result = static_cast(newValue); } } else @@ -213,16 +211,16 @@ bool GetBitmaskEnumerationProperty( const Property::Value& propertyValue, const * * @note The caller is NOT responsible for cleaning up the returned pointer as it is statically allocated. */ -template< typename T > -const char* GetEnumerationName( T value, const StringEnum* table, uint32_t tableCount ) +template +const char* GetEnumerationName(T value, const StringEnum* table, uint32_t tableCount) { - if( table ) + if(table) { - for ( uint32_t i = 0; i < tableCount; ++i ) + for(uint32_t i = 0; i < tableCount; ++i) { - if ( value == T(table[ i ].value) ) + if(value == T(table[i].value)) { - return table[ i ].string; + return table[i].string; } } } @@ -241,10 +239,10 @@ const char* GetEnumerationName( T value, const StringEnum* table, uint32_t table * * @note The caller is NOT responsible for cleaning up the returned pointer as it is statically allocated. */ -template< typename T > -const char * GetLinearEnumerationName( T value, const StringEnum* table, uint32_t tableCount ) +template +const char* GetLinearEnumerationName(T value, const StringEnum* table, uint32_t tableCount) { - if ( table && ( value > 0 || value <= static_cast( tableCount ) ) ) + if(table && (value > 0 || value <= static_cast(tableCount))) { return table[value].string; } @@ -272,7 +270,7 @@ const char * GetLinearEnumerationName( T value, const StringEnum* table, uint32_ * * @return A handle to the newly created actor. */ -DALI_CORE_API Actor NewActor( const Property::Map& map ); +DALI_CORE_API Actor NewActor(const Property::Map& map); /** * @brief Creates a Property::Map from the actor provided. @@ -280,7 +278,7 @@ DALI_CORE_API Actor NewActor( const Property::Map& map ); * @param[in] actor The base-actor from which a Property::Map should be created * @param[out] map This map is cleared and a property map of actor and its children is filled in */ -DALI_CORE_API void CreatePropertyMap( Actor actor, Property::Map& map ); +DALI_CORE_API void CreatePropertyMap(Actor actor, Property::Map& map); /** * @brief Creates description data required to create an Animation object from a property map. @@ -288,7 +286,7 @@ DALI_CORE_API void CreatePropertyMap( Actor actor, Property::Map& map ); * @param[in] map The property value map containing the animation description * @param[out] outputAnimationData Resultant data retrieved from the property map is written here */ -DALI_CORE_API void NewAnimation( const Property::Map& map, Dali::AnimationData& outputAnimationData ); +DALI_CORE_API void NewAnimation(const Property::Map& map, Dali::AnimationData& outputAnimationData); } // namespace Scripting diff --git a/dali/devel-api/signals/signal-delegate.cpp b/dali/devel-api/signals/signal-delegate.cpp index 8e3a462..8898014 100644 --- a/dali/devel-api/signals/signal-delegate.cpp +++ b/dali/devel-api/signals/signal-delegate.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -20,19 +20,18 @@ namespace Dali { - // CallbackBaseFunctor methods: -SignalDelegate::CallbackBaseFunctor::CallbackBaseFunctor( CallbackBase* callback ) -: mCallback( callback ) +SignalDelegate::CallbackBaseFunctor::CallbackBaseFunctor(CallbackBase* callback) +: mCallback(callback) { } void SignalDelegate::CallbackBaseFunctor::operator()() { - if( mCallback ) + if(mCallback) { - CallbackBase::Execute( *mCallback ); + CallbackBase::Execute(*mCallback); } } @@ -42,13 +41,12 @@ SignalDelegate::CallbackBaseFunctor::~CallbackBaseFunctor() delete mCallback; } - // SignalDelegate methods: -SignalDelegate::SignalDelegate( Dali::Actor connectActor, const std::string& signalName ) -: mIsConnected( false ), - mConnectActor( connectActor ), - mSignalName( signalName ) +SignalDelegate::SignalDelegate(Dali::Actor connectActor, const std::string& signalName) +: mIsConnected(false), + mConnectActor(connectActor), + mSignalName(signalName) { } @@ -57,5 +55,4 @@ bool SignalDelegate::IsConnected() return mIsConnected; } - } // namespace Dali diff --git a/dali/devel-api/signals/signal-delegate.h b/dali/devel-api/signals/signal-delegate.h index 8d57176..18a5286 100644 --- a/dali/devel-api/signals/signal-delegate.h +++ b/dali/devel-api/signals/signal-delegate.h @@ -2,7 +2,7 @@ #define DALI_SIGNAL_DELEGATE_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -24,7 +24,6 @@ namespace Dali { - /** * @brief The SignalDelegate object allows direct connection to a signal that has been pre-configured internally. * @@ -34,14 +33,13 @@ namespace Dali class DALI_CORE_API SignalDelegate { public: - /** * @brief Create and set up a signal delegate. * * @param[in] connectActor The actor whose signal should be connected to. * @param[in] signalName The name of the signal within the actor to connect to. */ - SignalDelegate( Dali::Actor connectActor, const std::string& signalName ); + SignalDelegate(Dali::Actor connectActor, const std::string& signalName); /** * @brief Destructor. @@ -51,7 +49,6 @@ public: } public: - /** * @brief Connect to a FunctorDelegate as received from a type-registry signal connection call. * @@ -63,15 +60,15 @@ public: * @param[in] functorDelegate A functor delegate object that must be executed when the signal is emitted. * @return True of the connection was made, false otherwise. */ - bool Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* functorDelegate ) + bool Connect(ConnectionTrackerInterface* connectionTracker, FunctorDelegate* functorDelegate) { - if( !mIsConnected ) + if(!mIsConnected) { // Note: We have to new the CallbackBaseFunctor rather than have it as a concrete object, as it // is converted to a FunctorDelegate again within ConnectSignal. FunctorDelegates gain ownership // of any functor they are created from and therefore always attempt to delete them. - CallbackBaseFunctor* callbackFunctor = new CallbackBaseFunctor( new CallbackFunctorDelegate0( functorDelegate ) ); - mConnectActor.ConnectSignal( connectionTracker, mSignalName, *callbackFunctor ); + CallbackBaseFunctor* callbackFunctor = new CallbackBaseFunctor(new CallbackFunctorDelegate0(functorDelegate)); + mConnectActor.ConnectSignal(connectionTracker, mSignalName, *callbackFunctor); mIsConnected = true; return true; @@ -89,13 +86,13 @@ public: * @param[in] memberFunction The member-function to call when the signal is emitted. * @return True of the connection was made, false otherwise. */ - template< class T > - bool Connect( T* object, void ( T::*memberFunction )( void ) ) + template + bool Connect(T* object, void (T::*memberFunction)(void)) { - if( !mIsConnected ) + if(!mIsConnected) { - CallbackBaseFunctor* callbackFunctor = new CallbackBaseFunctor( MakeCallback( object, memberFunction ) ); - mConnectActor.ConnectSignal( object, mSignalName, *callbackFunctor ); + CallbackBaseFunctor* callbackFunctor = new CallbackBaseFunctor(MakeCallback(object, memberFunction)); + mConnectActor.ConnectSignal(object, mSignalName, *callbackFunctor); mIsConnected = true; return true; @@ -112,9 +109,7 @@ public: */ bool IsConnected(); - private: - /** * This functor is used by SignalDelegate in order to callback to a non-static member function * (after it has been converted to a CallbackBase). @@ -128,7 +123,7 @@ private: * * @param[in] callback A CallbackBase which can be created from a member function, or a FunctorDelegate. */ - CallbackBaseFunctor( CallbackBase* callback ); + CallbackBaseFunctor(CallbackBase* callback); /** * @brief Executes the functor. @@ -143,25 +138,23 @@ private: */ ~CallbackBaseFunctor(); - private: - - CallbackBase* mCallback; ///< Stores (and owns) the callback to be called on execution. + private: + CallbackBase* mCallback; ///< Stores (and owns) the callback to be called on execution. }; private: - /** * @brief Not defined. */ - SignalDelegate( const SignalDelegate& rhs ); + SignalDelegate(const SignalDelegate& rhs); /** * @brief Not defined. */ - const SignalDelegate& operator=( const SignalDelegate& rhs ); + const SignalDelegate& operator=(const SignalDelegate& rhs); private: - bool mIsConnected; ///< Boolean to know if it is connected already. + bool mIsConnected; ///< Boolean to know if it is connected already. Dali::Actor mConnectActor; ///< The actor owning the signal to connect to. std::string mSignalName; ///< The name of the signal to connect to. }; diff --git a/dali/devel-api/threading/conditional-wait.cpp b/dali/devel-api/threading/conditional-wait.cpp index fa0a86c..3259203 100644 --- a/dali/devel-api/threading/conditional-wait.cpp +++ b/dali/devel-api/threading/conditional-wait.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -19,8 +19,8 @@ #include // EXTERNAL INCLUDES -#include #include +#include // INTERNAL INCLUDES #include @@ -33,9 +33,9 @@ namespace Dali */ struct ConditionalWait::ConditionalWaitImpl { - std::mutex mutex; + std::mutex mutex; std::condition_variable condition; - volatile unsigned int count; + volatile unsigned int count; }; /** @@ -43,16 +43,17 @@ struct ConditionalWait::ConditionalWaitImpl */ struct ConditionalWait::ScopedLock::ScopedLockImpl { - ScopedLockImpl( ConditionalWait& wait ) - : wait( wait ), - lock( wait.mImpl->mutex ) // locks for the lifecycle of this object - { } - ConditionalWait& wait; + ScopedLockImpl(ConditionalWait& wait) + : wait(wait), + lock(wait.mImpl->mutex) // locks for the lifecycle of this object + { + } + ConditionalWait& wait; std::unique_lock lock; }; -ConditionalWait::ScopedLock::ScopedLock( ConditionalWait& wait ) -: mImpl( new ConditionalWait::ScopedLock::ScopedLockImpl( wait ) ) +ConditionalWait::ScopedLock::ScopedLock(ConditionalWait& wait) +: mImpl(new ConditionalWait::ScopedLock::ScopedLockImpl(wait)) { Internal::MutexTrace::Lock(); // matching sequence in mutex.cpp } @@ -69,7 +70,7 @@ ConditionalWait& ConditionalWait::ScopedLock::GetLockedWait() const } ConditionalWait::ConditionalWait() -: mImpl( new ConditionalWaitImpl ) +: mImpl(new ConditionalWaitImpl) { mImpl->count = 0; } @@ -82,27 +83,29 @@ ConditionalWait::~ConditionalWait() void ConditionalWait::Notify() { // conditional wait requires a lock to be held - ScopedLock lock( *this ); + ScopedLock lock(*this); volatile unsigned int previousCount = mImpl->count; + mImpl->count = 0; // change state before broadcast as that may wake clients immediately // notify does nothing if the thread is not waiting but still has a system call overhead // notify all threads to continue - if( 0 != previousCount ) + if(0 != previousCount) { mImpl->condition.notify_all(); // no return value } } -void ConditionalWait::Notify( const ScopedLock& scope ) +void ConditionalWait::Notify(const ScopedLock& scope) { // Scope must be locked: - DALI_ASSERT_DEBUG( &scope.GetLockedWait() == this ); + DALI_ASSERT_DEBUG(&scope.GetLockedWait() == this); volatile unsigned int previousCount = mImpl->count; + mImpl->count = 0; // change state before broadcast as that may wake clients immediately // notify does nothing if the thread is not waiting but still has a system call overhead // notify all threads to continue - if( 0 != previousCount ) + if(0 != previousCount) { mImpl->condition.notify_all(); // no return value } @@ -111,21 +114,20 @@ void ConditionalWait::Notify( const ScopedLock& scope ) void ConditionalWait::Wait() { // conditional wait requires a lock to be held - ScopedLock scope( *this ); + ScopedLock scope(*this); ++(mImpl->count); // conditional wait may wake up without anyone calling Notify do { // wait while condition changes - mImpl->condition.wait( scope.mImpl->lock ); // need to pass in the std::unique_lock - } - while( 0 != mImpl->count ); + mImpl->condition.wait(scope.mImpl->lock); // need to pass in the std::unique_lock + } while(0 != mImpl->count); } -void ConditionalWait::Wait( const ScopedLock& scope ) +void ConditionalWait::Wait(const ScopedLock& scope) { // Scope must be locked: - DALI_ASSERT_DEBUG( &scope.GetLockedWait() == this ); + DALI_ASSERT_DEBUG(&scope.GetLockedWait() == this); ++(mImpl->count); @@ -133,9 +135,8 @@ void ConditionalWait::Wait( const ScopedLock& scope ) do { // wait while condition changes - mImpl->condition.wait( scope.mImpl->lock ); // need to pass in the std::unique_lock - } - while( 0 != mImpl->count ); + mImpl->condition.wait(scope.mImpl->lock); // need to pass in the std::unique_lock + } while(0 != mImpl->count); // We return with our mutex locked safe in the knowledge that the ScopedLock // passed in will unlock it in the caller. diff --git a/dali/devel-api/threading/conditional-wait.h b/dali/devel-api/threading/conditional-wait.h old mode 100755 new mode 100644 index d1c1d76..a18b93f --- a/dali/devel-api/threading/conditional-wait.h +++ b/dali/devel-api/threading/conditional-wait.h @@ -2,7 +2,7 @@ #define DALI_CONDITIONAL_WAIT_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -23,14 +23,12 @@ namespace Dali { - /** * Helper class to allow conditional waiting and notifications between multiple threads. */ class DALI_CORE_API ConditionalWait { public: - /** * @brief Allows client code to synchronize updates to its own state with the * internal state of a ConditionalWait object. @@ -43,7 +41,7 @@ public: * @brief Will acquire the internal mutex of the ConditionalWait object passed in. * @param[in] wait The ConditionalWait object to lock. */ - ScopedLock( ConditionalWait& wait ); + ScopedLock(ConditionalWait& wait); /** * Destructor @@ -58,15 +56,13 @@ public: ConditionalWait& GetLockedWait() const; public: // Data, public to allow nesting class to access - struct ScopedLockImpl; ScopedLockImpl* mImpl; private: - // Not implemented as ScopedLock cannot be copied: - ScopedLock( const ScopedLock& ); - const ScopedLock& operator=( const ScopedLock& ); + ScopedLock(const ScopedLock&); + const ScopedLock& operator=(const ScopedLock&); }; /** @@ -97,7 +93,7 @@ public: * * @param[in] scope A pre-existing lock on the internal state of this object. */ - void Notify( const ScopedLock& scope ); + void Notify(const ScopedLock& scope); /** * @brief Wait for another thread to notify us when the condition is true and we can continue @@ -116,7 +112,7 @@ public: * @param[in] scope A pre-existing lock on the internal state of this object. * @pre scope must have been passed this ConditionalWait during its construction. */ - void Wait( const ScopedLock& scope ); + void Wait(const ScopedLock& scope); /** * @brief Return the count of threads waiting for this conditional @@ -125,14 +121,12 @@ public: unsigned int GetWaitCount() const; private: - // Not implemented as ConditionalWait is not copyable - ConditionalWait( const ConditionalWait& ); - const ConditionalWait& operator=( const ConditionalWait& ); + ConditionalWait(const ConditionalWait&); + const ConditionalWait& operator=(const ConditionalWait&); struct ConditionalWaitImpl; ConditionalWaitImpl* mImpl; - }; } // namespace Dali diff --git a/dali/devel-api/threading/mutex.cpp b/dali/devel-api/threading/mutex.cpp index 0f1770a..31c29b3 100644 --- a/dali/devel-api/threading/mutex.cpp +++ b/dali/devel-api/threading/mutex.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -27,15 +27,14 @@ namespace Dali { - struct Mutex::MutexImpl { std::mutex mutex; - bool locked; + bool locked; }; Mutex::Mutex() -: mImpl( new MutexImpl ) +: mImpl(new MutexImpl) { mImpl->locked = false; } @@ -52,8 +51,8 @@ bool Mutex::IsLocked() return mImpl->locked; } -Mutex::ScopedLock::ScopedLock( Mutex& mutex ) -: mMutex( mutex ) +Mutex::ScopedLock::ScopedLock(Mutex& mutex) +: mMutex(mutex) { mMutex.mImpl->mutex.lock(); Internal::MutexTrace::Lock(); // matching sequence in conditional-wait.cpp diff --git a/dali/devel-api/threading/mutex.h b/dali/devel-api/threading/mutex.h old mode 100755 new mode 100644 index d07ef8e..b829b8b --- a/dali/devel-api/threading/mutex.h +++ b/dali/devel-api/threading/mutex.h @@ -2,7 +2,7 @@ #define DALI_MUTEX_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -26,14 +26,12 @@ */ namespace Dali { - /** * Class to synchronize access to critical resources from multiple threads */ class DALI_CORE_API Mutex { public: - /** * @brief Constructor, acquires the mutex from the underlying OS */ @@ -51,7 +49,6 @@ public: bool IsLocked(); public: - /** * Helper class to do a scoped lock on a mutex implementing the RAII idiom. * Note! this class *does not* prevent a deadlock in the case when same thread is @@ -60,12 +57,11 @@ public: class DALI_CORE_API ScopedLock { public: - /** * Constructor * @param mutex to lock */ - ScopedLock( Mutex& mutex ); + ScopedLock(Mutex& mutex); /** * Destructor, releases the lock @@ -77,14 +73,12 @@ public: }; private: - /// Not implemented as Mutex is not copyable - Mutex( const Mutex& ); - const Mutex& operator= ( const Mutex& ); + Mutex(const Mutex&); + const Mutex& operator=(const Mutex&); struct MutexImpl; MutexImpl* mImpl; - }; } // namespace Dali diff --git a/dali/devel-api/threading/thread-pool.cpp b/dali/devel-api/threading/thread-pool.cpp index bf55715..3ac7134 100644 --- a/dali/devel-api/threading/thread-pool.cpp +++ b/dali/devel-api/threading/thread-pool.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -18,8 +18,6 @@ #include "thread-pool.h" #include - - namespace Dali { namespace @@ -29,7 +27,7 @@ std::unique_ptr make_unique(Args&&... args) { return std::unique_ptr(new T(std::forward(args)...)); } -} +} // namespace /** * WorkerThread executes tasks submitted to the pool @@ -37,26 +35,25 @@ std::unique_ptr make_unique(Args&&... args) class WorkerThread { public: - /** * @brief Constructor of worker thread * @param index Thread index assigned to the object during pool initialisation */ - explicit WorkerThread( uint32_t index ); + explicit WorkerThread(uint32_t index); /** * @brief Destructor of the worker thread */ ~WorkerThread(); - WorkerThread(const WorkerThread &other) = delete; - WorkerThread &operator=(const WorkerThread &other) = delete; + WorkerThread(const WorkerThread& other) = delete; + WorkerThread& operator=(const WorkerThread& other) = delete; /** * @brief Adds task to the task queue * @param task Task to be executed by the thread */ - void AddTask( Task task ); + void AddTask(Task task); /** * @brief Wakes up thread. @@ -69,35 +66,34 @@ public: void Wait(); private: - /** * @brief Internal thread loop function */ void WaitAndExecute(); - std::thread mWorker; - uint32_t mIndex; - TaskQueue mTaskQueue; - std::mutex mTaskQueueMutex; + std::thread mWorker; + uint32_t mIndex; + TaskQueue mTaskQueue; + std::mutex mTaskQueueMutex; std::condition_variable mConditionVariable; - bool mTerminating {false} ; + bool mTerminating{false}; }; void WorkerThread::WaitAndExecute() { - while( true ) + while(true) { Task task; { - std::unique_lock< std::mutex > lock{ mTaskQueueMutex }; + std::unique_lock lock{mTaskQueueMutex}; - mConditionVariable.wait( lock, [ this ]() -> bool { + mConditionVariable.wait(lock, [this]() -> bool { return !mTaskQueue.empty() || mTerminating; - } ); + }); - if( mTerminating ) + if(mTerminating) { break; } @@ -105,10 +101,10 @@ void WorkerThread::WaitAndExecute() task = mTaskQueue.front(); } - task( mIndex ); + task(mIndex); { - std::lock_guard< std::mutex > lock{ mTaskQueueMutex }; + std::lock_guard lock{mTaskQueueMutex}; mTaskQueue.pop(); @@ -117,21 +113,22 @@ void WorkerThread::WaitAndExecute() } } -WorkerThread::WorkerThread(uint32_t index) : mIndex( index ) +WorkerThread::WorkerThread(uint32_t index) +: mIndex(index) { // Have to pass "this" as an argument because WaitAndExecute is a member function. - mWorker = std::thread{ &WorkerThread::WaitAndExecute, this }; + mWorker = std::thread{&WorkerThread::WaitAndExecute, this}; } WorkerThread::~WorkerThread() { - if( mWorker.joinable() ) + if(mWorker.joinable()) { Notify(); Wait(); { - std::lock_guard< std::mutex > lock{ mTaskQueueMutex }; + std::lock_guard lock{mTaskQueueMutex}; mTerminating = true; mConditionVariable.notify_one(); } @@ -140,25 +137,25 @@ WorkerThread::~WorkerThread() } } -void WorkerThread::AddTask( Task task ) +void WorkerThread::AddTask(Task task) { - std::lock_guard< std::mutex > lock{ mTaskQueueMutex }; - mTaskQueue.push( std::move( task ) ); + std::lock_guard lock{mTaskQueueMutex}; + mTaskQueue.push(std::move(task)); mConditionVariable.notify_one(); } void WorkerThread::Notify() { - std::lock_guard< std::mutex > lock{ mTaskQueueMutex }; + std::lock_guard lock{mTaskQueueMutex}; mConditionVariable.notify_one(); } void WorkerThread::Wait() { - std::unique_lock< std::mutex > lock{ mTaskQueueMutex }; - mConditionVariable.wait( lock, [ this ]() -> bool { + std::unique_lock lock{mTaskQueueMutex}; + mConditionVariable.wait(lock, [this]() -> bool { return mTaskQueue.empty(); - } ); + }); } // ThreadPool ----------------------------------------------------------------------------------------------- @@ -166,7 +163,7 @@ void WorkerThread::Wait() struct ThreadPool::Impl { std::vector> mWorkers; - uint32_t mWorkerIndex{ 0u }; + uint32_t mWorkerIndex{0u}; }; ThreadPool::ThreadPool() @@ -176,16 +173,16 @@ ThreadPool::ThreadPool() ThreadPool::~ThreadPool() = default; -bool ThreadPool::Initialize( uint32_t threadCount ) +bool ThreadPool::Initialize(uint32_t threadCount) { /** * Get the system's supported thread count. */ auto thread_count = threadCount + 1; - if( !threadCount ) + if(!threadCount) { thread_count = std::thread::hardware_concurrency(); - if( !thread_count ) + if(!thread_count) { return false; } @@ -194,60 +191,57 @@ bool ThreadPool::Initialize( uint32_t threadCount ) /** * Spawn the worker threads. */ - for( auto i = 0u; i < thread_count - 1; i++ ) + for(auto i = 0u; i < thread_count - 1; i++) { /** * The workers will execute an infinite loop function * and will wait for a job to enter the job queue. Once a job is in the the queue * the threads will wake up to acquire and execute it. */ - mImpl->mWorkers.push_back( make_unique< WorkerThread >( i ) ); + mImpl->mWorkers.push_back(make_unique(i)); } return true; } - void ThreadPool::Wait() { - for( auto& worker : mImpl->mWorkers ) + for(auto& worker : mImpl->mWorkers) { worker->Wait(); } } -SharedFuture ThreadPool::SubmitTask( uint32_t workerIndex, const Task& task ) +SharedFuture ThreadPool::SubmitTask(uint32_t workerIndex, const Task& task) { - auto future = std::shared_ptr< Future< void > >( new Future< void > ); - mImpl->mWorkers[workerIndex]->AddTask( [task, future]( uint32_t index ) - { - task( index ); + auto future = std::shared_ptr>(new Future); + mImpl->mWorkers[workerIndex]->AddTask([task, future](uint32_t index) { + task(index); - future->mPromise.set_value(); - }); + future->mPromise.set_value(); + }); return future; } -SharedFuture ThreadPool::SubmitTasks( const std::vector< Task >& tasks ) +SharedFuture ThreadPool::SubmitTasks(const std::vector& tasks) { - auto future = std::shared_ptr< Future< void > >( new Future< void > ); + auto future = std::shared_ptr>(new Future); - mImpl->mWorkers[ mImpl->mWorkerIndex++ % static_cast< uint32_t >( mImpl->mWorkers.size() )]->AddTask( - [ future, tasks ]( uint32_t index ) { - for( auto& task : tasks ) + mImpl->mWorkers[mImpl->mWorkerIndex++ % static_cast(mImpl->mWorkers.size())]->AddTask( + [future, tasks](uint32_t index) { + for(auto& task : tasks) { - task( index ); + task(index); } future->mPromise.set_value(); - - } ); + }); return future; } -UniqueFutureGroup ThreadPool::SubmitTasks( const std::vector< Task >& tasks, uint32_t threadMask ) +UniqueFutureGroup ThreadPool::SubmitTasks(const std::vector& tasks, uint32_t threadMask) { auto retval = make_unique>(); @@ -257,40 +251,40 @@ UniqueFutureGroup ThreadPool::SubmitTasks( const std::vector< Task >& tasks, uin */ auto threads = uint32_t(std::log2(float(tasks.size()))); - if( threadMask != 0 ) + if(threadMask != 0) { threads = threadMask; } - if( threads > mImpl->mWorkers.size() ) + if(threads > mImpl->mWorkers.size()) { threads = uint32_t(mImpl->mWorkers.size()); } - else if( !threads ) + else if(!threads) { threads = 1; } auto payloadPerThread = uint32_t(tasks.size() / threads); - auto remaining = uint32_t(tasks.size() % threads); + auto remaining = uint32_t(tasks.size() % threads); uint32_t taskIndex = 0; - uint32_t taskSize = uint32_t(remaining + payloadPerThread); // add 'remaining' tasks to the very first job list + uint32_t taskSize = uint32_t(remaining + payloadPerThread); // add 'remaining' tasks to the very first job list - for( auto wt = 0u; wt < threads; ++wt ) + for(auto wt = 0u; wt < threads; ++wt) { - auto future = std::shared_ptr< Future< void > >( new Future< void > ); - retval->mFutures.emplace_back( future ); - mImpl->mWorkers[ mImpl->mWorkerIndex++ % static_cast< uint32_t >( mImpl->mWorkers.size() )]->AddTask( - [ future, tasks, taskIndex, taskSize ]( uint32_t index ) { + auto future = std::shared_ptr>(new Future); + retval->mFutures.emplace_back(future); + mImpl->mWorkers[mImpl->mWorkerIndex++ % static_cast(mImpl->mWorkers.size())]->AddTask( + [future, tasks, taskIndex, taskSize](uint32_t index) { auto begin = tasks.begin() + int(taskIndex); - auto end = begin + int(taskSize); - for( auto it = begin; it < end; ++it ) + auto end = begin + int(taskSize); + for(auto it = begin; it < end; ++it) { - (*it)( index ); + (*it)(index); } future->mPromise.set_value(); - } ); + }); taskIndex += taskSize; taskSize = payloadPerThread; diff --git a/dali/devel-api/threading/thread-pool.h b/dali/devel-api/threading/thread-pool.h index b90fb28..c506133 100644 --- a/dali/devel-api/threading/thread-pool.h +++ b/dali/devel-api/threading/thread-pool.h @@ -2,7 +2,7 @@ #define DALI_THREAD_POOL_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -22,15 +22,15 @@ #include // EXTERNAL INCLUDES -#include -#include -#include -#include +#include #include +#include #include -#include #include #include +#include +#include +#include namespace Dali { @@ -49,7 +49,6 @@ class DALI_INTERNAL Future final friend class ThreadPool; public: - /** * @brief Constructor of Future */ @@ -81,7 +80,7 @@ public: */ void Wait() const { - if( IsValid() ) + if(IsValid()) { mFuture.wait(); } @@ -107,7 +106,6 @@ public: } private: - std::promise mPromise{}; std::future mFuture{}; }; @@ -123,34 +121,29 @@ class FutureGroup final friend class ThreadPool; public: - /** * Waits for all the Futures to complete. */ void Wait() { - for (auto &future : mFutures) + for(auto& future : mFutures) { future->Wait(); } } private: - - std::vector > > mFutures; + std::vector>> mFutures; }; using UniqueFutureGroup = std::unique_ptr>; - - /** * ThreadPool creates and manages worker threads and tasks submitted for execution. */ class DALI_CORE_API ThreadPool final { public: - /** * @brief Constructor of thread pool. */ @@ -166,7 +159,7 @@ public: * @param threadCount Number of worker threads to use. If 0 then thread count equals hardware thread count. * @return True if success */ - bool Initialize( uint32_t threadCount = 0u ); + bool Initialize(uint32_t threadCount = 0u); /** * @brief Waits until all threads finish execution and go back to the idle state. @@ -179,7 +172,7 @@ public: * @param task Task submitted for execution * @return Shared pointer to the Future object */ - SharedFuture SubmitTask(uint32_t workerIndex, const Task &task); + SharedFuture SubmitTask(uint32_t workerIndex, const Task& task); /** * @brief Submits vector of tasks to the pool @@ -203,7 +196,6 @@ public: size_t GetWorkerCount() const; private: - struct Impl; std::unique_ptr mImpl; }; diff --git a/dali/devel-api/threading/thread.cpp b/dali/devel-api/threading/thread.cpp index be4077d..8d261a5 100644 --- a/dali/devel-api/threading/thread.cpp +++ b/dali/devel-api/threading/thread.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -19,21 +19,20 @@ #include // EXTERNAL INCLUDES +#include #include #include -#include namespace Dali { - struct Thread::ThreadImpl { - ThreadImpl( Thread& aThis ) - : thread( &Thread::InternalThreadEntryFunc, std::ref( aThis ) ) + ThreadImpl(Thread& aThis) + : thread(&Thread::InternalThreadEntryFunc, std::ref(aThis)) { // std::thread starts execution immediately } - ~ThreadImpl( ) + ~ThreadImpl() { thread.join(); } @@ -41,7 +40,7 @@ struct Thread::ThreadImpl }; Thread::Thread() -: mImpl( nullptr ) +: mImpl(nullptr) { } @@ -52,9 +51,9 @@ Thread::~Thread() void Thread::Start() { - if( !mImpl ) + if(!mImpl) { - mImpl = new Thread::ThreadImpl( *this ); + mImpl = new Thread::ThreadImpl(*this); } } @@ -64,7 +63,7 @@ void Thread::Join() mImpl = nullptr; } -void Thread::InternalThreadEntryFunc( Thread& aThis ) +void Thread::InternalThreadEntryFunc(Thread& aThis) { aThis.Run(); } diff --git a/dali/devel-api/threading/thread.h b/dali/devel-api/threading/thread.h index 1427482..cca1125 100644 --- a/dali/devel-api/threading/thread.h +++ b/dali/devel-api/threading/thread.h @@ -26,14 +26,12 @@ */ namespace Dali { - /* * @brief Abstract class for thread functionality. Can be used for worker threads. */ class DALI_CORE_API Thread { public: - /** * @brief Creates a new thread and make it executable. */ @@ -45,7 +43,6 @@ public: void Join(); protected: - /** * @brief Constructor */ @@ -62,26 +59,23 @@ protected: virtual void Run() = 0; private: - /** * Helper for the thread calling the entry function. * @param[in] This A pointer to the current thread object */ - static void InternalThreadEntryFunc( Thread& This ); + static void InternalThreadEntryFunc(Thread& This); // Not copyable or movable - Thread( const Thread& ) = delete; ///< Deleted copy constructor - Thread( Thread&& ) = delete; ///< Deleted move constructor - Thread& operator=( const Thread& ) = delete; ///< Deleted copy assignment operator - Thread& operator=( Thread&& ) = delete; ///< Deleted move assignment operator + Thread(const Thread&) = delete; ///< Deleted copy constructor + Thread(Thread&&) = delete; ///< Deleted move constructor + Thread& operator=(const Thread&) = delete; ///< Deleted copy assignment operator + Thread& operator=(Thread&&) = delete; ///< Deleted move assignment operator private: - struct ThreadImpl; ThreadImpl* mImpl; - }; -} +} // namespace Dali #endif // DALI_THREAD_H diff --git a/dali/devel-api/update/frame-callback-interface.cpp b/dali/devel-api/update/frame-callback-interface.cpp index 238f881..f7497c8 100644 --- a/dali/devel-api/update/frame-callback-interface.cpp +++ b/dali/devel-api/update/frame-callback-interface.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -25,21 +25,20 @@ namespace Dali { - FrameCallbackInterface::FrameCallbackInterface() -: mImpl( std::unique_ptr< Impl >( new Impl ) ) +: mImpl(std::unique_ptr(new Impl)) { } FrameCallbackInterface::~FrameCallbackInterface() { - if( Internal::Stage::IsInstalled() ) + if(Internal::Stage::IsInstalled()) { Internal::StagePtr stage = Internal::Stage::GetCurrent(); - if( stage ) + if(stage) { // This will be a no-op if the callback has already been removed - stage->RemoveFrameCallback( *this ); + stage->RemoveFrameCallback(*this); } } } diff --git a/dali/devel-api/update/frame-callback-interface.h b/dali/devel-api/update/frame-callback-interface.h index eed5ad3..fa9fec5 100644 --- a/dali/devel-api/update/frame-callback-interface.h +++ b/dali/devel-api/update/frame-callback-interface.h @@ -2,7 +2,7 @@ #define DALI_FRAME_CALLBACK_INTERFACE_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -26,7 +26,6 @@ namespace Dali { - class UpdateProxy; /** @@ -48,17 +47,15 @@ class UpdateProxy; class DALI_CORE_API FrameCallbackInterface { public: - /** * @brief Called from the update-thread after the scene has been updated, and is ready to render. * @param[in] updateProxy Use this to get/set required values for the Actor. * @param[in] elapsedSeconds Time elapsed time since the last frame (in seconds) * @see FrameCallbackInterface */ - virtual void Update( UpdateProxy& updateProxy, float elapsedSeconds ) = 0; + virtual void Update(UpdateProxy& updateProxy, float elapsedSeconds) = 0; protected: - /** * @brief Protected constructor. */ @@ -74,7 +71,7 @@ public: class Impl; private: - std::unique_ptr< Impl > mImpl; + std::unique_ptr mImpl; /// @endcond }; diff --git a/dali/devel-api/update/update-proxy.cpp b/dali/devel-api/update/update-proxy.cpp index 92b788c..c2ba2ad 100644 --- a/dali/devel-api/update/update-proxy.cpp +++ b/dali/devel-api/update/update-proxy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -23,74 +23,73 @@ namespace Dali { - -bool UpdateProxy::GetPosition( uint32_t id, Vector3& position ) const +bool UpdateProxy::GetPosition(uint32_t id, Vector3& position) const { - return mImpl.GetPosition( id, position ); + return mImpl.GetPosition(id, position); } -bool UpdateProxy::SetPosition( uint32_t id, const Vector3& position ) +bool UpdateProxy::SetPosition(uint32_t id, const Vector3& position) { - return mImpl.SetPosition( id, position ); + return mImpl.SetPosition(id, position); } -bool UpdateProxy::BakePosition( uint32_t id, const Vector3& position ) +bool UpdateProxy::BakePosition(uint32_t id, const Vector3& position) { - return mImpl.BakePosition( id, position ); + return mImpl.BakePosition(id, position); } -bool UpdateProxy::GetSize( uint32_t id, Vector3& size ) const +bool UpdateProxy::GetSize(uint32_t id, Vector3& size) const { - return mImpl.GetSize( id, size ); + return mImpl.GetSize(id, size); } -bool UpdateProxy::SetSize( uint32_t id, const Vector3& size ) +bool UpdateProxy::SetSize(uint32_t id, const Vector3& size) { - return mImpl.SetSize( id, size ); + return mImpl.SetSize(id, size); } -bool UpdateProxy::BakeSize( uint32_t id, const Vector3& size ) +bool UpdateProxy::BakeSize(uint32_t id, const Vector3& size) { - return mImpl.BakeSize( id, size ); + return mImpl.BakeSize(id, size); } -bool UpdateProxy::GetPositionAndSize( uint32_t id, Vector3& position, Vector3& size ) const +bool UpdateProxy::GetPositionAndSize(uint32_t id, Vector3& position, Vector3& size) const { - return mImpl.GetPositionAndSize( id, position, size ); + return mImpl.GetPositionAndSize(id, position, size); } -bool UpdateProxy::GetScale( uint32_t id, Vector3& scale ) const +bool UpdateProxy::GetScale(uint32_t id, Vector3& scale) const { - return mImpl.GetScale( id, scale ); + return mImpl.GetScale(id, scale); } -bool UpdateProxy::SetScale( uint32_t id, const Vector3& scale ) +bool UpdateProxy::SetScale(uint32_t id, const Vector3& scale) { - return mImpl.SetScale( id, scale ); + return mImpl.SetScale(id, scale); } -bool UpdateProxy::BakeScale( uint32_t id, const Vector3& scale ) +bool UpdateProxy::BakeScale(uint32_t id, const Vector3& scale) { - return mImpl.BakeScale( id, scale ); + return mImpl.BakeScale(id, scale); } -bool UpdateProxy::GetColor( uint32_t id, Vector4& color ) const +bool UpdateProxy::GetColor(uint32_t id, Vector4& color) const { - return mImpl.GetColor( id, color ); + return mImpl.GetColor(id, color); } -bool UpdateProxy::SetColor( uint32_t id, const Vector4& color ) +bool UpdateProxy::SetColor(uint32_t id, const Vector4& color) { - return mImpl.SetColor( id, color ); + return mImpl.SetColor(id, color); } -bool UpdateProxy::BakeColor( uint32_t id, const Vector4& color ) +bool UpdateProxy::BakeColor(uint32_t id, const Vector4& color) { - return mImpl.BakeColor( id, color ); + return mImpl.BakeColor(id, color); } -UpdateProxy::UpdateProxy( Internal::UpdateProxy& impl ) -: mImpl( impl ) +UpdateProxy::UpdateProxy(Internal::UpdateProxy& impl) +: mImpl(impl) { } diff --git a/dali/devel-api/update/update-proxy.h b/dali/devel-api/update/update-proxy.h index 40be070..8a66dab 100644 --- a/dali/devel-api/update/update-proxy.h +++ b/dali/devel-api/update/update-proxy.h @@ -2,7 +2,7 @@ #define DALI_UPDATE_PROXY_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -28,7 +28,6 @@ namespace Dali { - namespace Internal DALI_INTERNAL { class UpdateProxy; @@ -46,14 +45,13 @@ class UpdateProxy; class DALI_CORE_API UpdateProxy { public: - /** * @brief Given the Actor ID, this retrieves that Actor's local position. * @param[in] id The Actor ID * @param[out] position Set to the Actor's current position, if Actor ID is valid * @return Whether the method call was successful or not. */ - bool GetPosition( uint32_t id, Vector3& position ) const; + bool GetPosition(uint32_t id, Vector3& position) const; /** * @brief Allows setting an Actor's local position from the Frame callback function for the current frame only. @@ -62,7 +60,7 @@ public: * @return Whether the method call was successful or not. * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again. */ - bool SetPosition( uint32_t id, const Vector3& position ); + bool SetPosition(uint32_t id, const Vector3& position); /** * @brief Allows baking an Actor's local position from the Frame callback function. @@ -71,7 +69,7 @@ public: * @return Whether the method call was successful or not. * @note The value is saved so will cause undesired effects if this property is being animated. */ - bool BakePosition( uint32_t id, const Vector3& position ); + bool BakePosition(uint32_t id, const Vector3& position); /** * @brief Given the Actor ID, this retrieves that Actor's size. @@ -79,7 +77,7 @@ public: * @param[out] size Set to the Actor's current size, if Actor ID is valid * @return Whether the method call was successful or not. */ - bool GetSize( uint32_t id, Vector3& size ) const; + bool GetSize(uint32_t id, Vector3& size) const; /** * @brief Allows setting an Actor's size from the Frame callback function for the current frame only. @@ -88,7 +86,7 @@ public: * @return Whether the method call was successful or not. * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again. */ - bool SetSize( uint32_t id, const Vector3& size ); + bool SetSize(uint32_t id, const Vector3& size); /** * @brief Allows baking an Actor's size from the Frame callback function. @@ -97,7 +95,7 @@ public: * @return Whether the method call was successful or not. * @note The value is saved so will cause undesired effects if this property is being animated. */ - bool BakeSize( uint32_t id, const Vector3& size ); + bool BakeSize(uint32_t id, const Vector3& size); /** * @brief Given the Actor ID, this retrieves that Actor's local position and size. @@ -106,7 +104,7 @@ public: * @param[out] size Set to the Actor's current size, if Actor ID is valid * @return Whether the method call was successful or not. */ - bool GetPositionAndSize( uint32_t id, Vector3& position, Vector3& size ) const; + bool GetPositionAndSize(uint32_t id, Vector3& position, Vector3& size) const; /** * @brief Given the Actor ID, this retrieves that Actor's local scale. @@ -114,7 +112,7 @@ public: * @param[out] scale Set to the Actor's current scale, if Actor ID is valid * @return Whether the method call was successful or not. */ - bool GetScale( uint32_t id, Vector3& scale ) const; + bool GetScale(uint32_t id, Vector3& scale) const; /** * @brief Allows setting an Actor's local scale from the Frame callback function for the current frame only. @@ -123,7 +121,7 @@ public: * @return Whether the method call was successful or not. * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again. */ - bool SetScale( uint32_t id, const Vector3& scale ); + bool SetScale(uint32_t id, const Vector3& scale); /** * @brief Allows baking an Actor's local scale from the Frame callback function. @@ -132,7 +130,7 @@ public: * @return Whether the method call was successful or not. * @note The value is saved so will cause undesired effects if this property is being animated. */ - bool BakeScale( uint32_t id, const Vector3& scale ); + bool BakeScale(uint32_t id, const Vector3& scale); /** * @brief Given the Actor ID, this retrieves that Actor's local color. @@ -140,7 +138,7 @@ public: * @param[out] color Set to the Actor's current color, if Actor ID is valid * @return Whether the method call was successful or not. */ - bool GetColor( uint32_t id, Vector4& color ) const; + bool GetColor(uint32_t id, Vector4& color) const; /** * @brief Allows setting an Actor's local color from the Frame callback function for the current frame only. @@ -149,7 +147,7 @@ public: * @return Whether the method call was successful or not. * @note This will get reset to the internally calculated or previously baked value in the next frame, so will have to be set again. */ - bool SetColor( uint32_t id, const Vector4& color ); + bool SetColor(uint32_t id, const Vector4& color); /** * @brief Allows baking an Actor's local color from the Frame callback function. @@ -158,17 +156,16 @@ public: * @return Whether the method call was successful or not. * @note The value is saved so will cause undesired effects if this property is being animated. */ - bool BakeColor( uint32_t id, const Vector4& color ); + bool BakeColor(uint32_t id, const Vector4& color); public: // Not intended for application developers - /// @cond internal /** * @brief Constructor. * @param[in] impl A reference to the internal object. */ - DALI_INTERNAL UpdateProxy( Internal::UpdateProxy& impl ); + DALI_INTERNAL UpdateProxy(Internal::UpdateProxy& impl); /** * @brief Destructor. @@ -177,15 +174,14 @@ public: // Not intended for application developers // Not copyable or movable - UpdateProxy( const UpdateProxy& ) = delete; ///< Deleted copy constructor - UpdateProxy( UpdateProxy&& ) = delete; ///< Deleted move constructor - UpdateProxy& operator=( const UpdateProxy& ) = delete; ///< Deleted copy assignment operator - UpdateProxy& operator=( UpdateProxy&& ) = delete; ///< Deleted move assignment operator + UpdateProxy(const UpdateProxy&) = delete; ///< Deleted copy constructor + UpdateProxy(UpdateProxy&&) = delete; ///< Deleted move constructor + UpdateProxy& operator=(const UpdateProxy&) = delete; ///< Deleted copy assignment operator + UpdateProxy& operator=(UpdateProxy&&) = delete; ///< Deleted move assignment operator /// @endcond private: - /// @cond internal Internal::UpdateProxy& mImpl; /// @endcond diff --git a/dali/integration-api/addon-manager.cpp b/dali/integration-api/addon-manager.cpp index 1376386..52161ab 100644 --- a/dali/integration-api/addon-manager.cpp +++ b/dali/integration-api/addon-manager.cpp @@ -34,5 +34,5 @@ AddOnManager* AddOnManager::Get() { return mSingleton; } -} -} +} // namespace Integration +} // namespace Dali diff --git a/dali/integration-api/addon-manager.h b/dali/integration-api/addon-manager.h index f957f62..aac8d47 100644 --- a/dali/integration-api/addon-manager.h +++ b/dali/integration-api/addon-manager.h @@ -22,11 +22,11 @@ #include // EXTERNAL EXCLUDES -#include +#include +#include #include +#include #include -#include -#include namespace Dali { @@ -46,9 +46,9 @@ enum class AddOnType * @param[in] rev Revision version number * @return returns 32-bit version number */ -constexpr uint32_t DALI_ADDON_VERSION( uint32_t maj, uint32_t min, uint32_t rev ) +constexpr uint32_t DALI_ADDON_VERSION(uint32_t maj, uint32_t min, uint32_t rev) { - return ((maj&0xff) << 24) | ((min & 0xfff) << 16); + return ((maj & 0xff) << 24) | ((min & 0xfff) << 16); } /** @@ -56,10 +56,10 @@ constexpr uint32_t DALI_ADDON_VERSION( uint32_t maj, uint32_t min, uint32_t rev */ struct AddOnInfo { - AddOnType type; /// may be use in order to classify extension - void* next; /// holds pointer to additional data-structures + AddOnType type; /// may be use in order to classify extension + void* next; /// holds pointer to additional data-structures - std::string name; /// Name of the extension + std::string name; /// Name of the extension uint32_t version; /** @@ -80,15 +80,15 @@ struct AddOnInfo struct AddOnDispatchTable { std::string name; - void (*GetAddOnInfo)( Dali::AddOnInfo&) = nullptr; - void*(*GetGlobalProc)(const char*) = nullptr; - void*(*GetInstanceProc)(const char*) = nullptr; + void (*GetAddOnInfo)(Dali::AddOnInfo&) = nullptr; + void* (*GetGlobalProc)(const char*) = nullptr; + void* (*GetInstanceProc)(const char*) = nullptr; // Lifecycle callbacks - void(*OnStart)() = nullptr; - void(*OnResume)() = nullptr; - void(*OnPause)() = nullptr; - void(*OnStop)() = nullptr; + void (*OnStart)() = nullptr; + void (*OnResume)() = nullptr; + void (*OnPause)() = nullptr; + void (*OnStop)() = nullptr; }; /** @@ -121,7 +121,6 @@ protected: AddOnManager(); public: - /** * @brief Destructor */ @@ -141,23 +140,23 @@ public: * @param[out]] info Output reference * @return True on success, False if extension info cannot be retrieved */ - virtual bool GetAddOnInfo(const std::string& name, AddOnInfo& info ) = 0; + virtual bool GetAddOnInfo(const std::string& name, AddOnInfo& info) = 0; /** * @brief Loads and initialises specified extensions * @param[in] extensionNames Array of extension names * @return vector of initialised extension handles */ - virtual std::vector LoadAddOns( const std::vector& addonNames ) = 0; + virtual std::vector LoadAddOns(const std::vector& addonNames) = 0; /** * @brief Loads AddOn with specified name * @param[in] addOnName Name of AddOn to be acquired * @return Returns a valid handle or nullptr */ - inline AddOnLibrary GetAddOn( const std::string& addonName ) + inline AddOnLibrary GetAddOn(const std::string& addonName) { - return LoadAddOns( { addonName } )[0]; + return LoadAddOns({addonName})[0]; } /** @@ -166,7 +165,7 @@ public: * @param[in] procName Name of the function to retrieve * @return Pointer to the function or null if function doesn't exist */ - virtual void* GetGlobalProc( const Dali::AddOnLibrary& addOnLibrary, const char* procName ) = 0; + virtual void* GetGlobalProc(const Dali::AddOnLibrary& addOnLibrary, const char* procName) = 0; /** * @brief Returns addon instance function pointer @@ -174,7 +173,7 @@ public: * @param[in] procName Name of the function to retrieve * @return Pointer to the function or null if function doesn't exist */ - virtual void* GetInstanceProc( const Dali::AddOnLibrary& addOnLibrary, const char* procName ) = 0; + virtual void* GetInstanceProc(const Dali::AddOnLibrary& addOnLibrary, const char* procName) = 0; /** * @brief Returns addon global function of specified type @@ -183,12 +182,12 @@ public: * @return std::function object or null if function doesn't exist */ template - DALI_INTERNAL std::function GetGlobalProc( const Dali::AddOnLibrary& addonlibrary, const char* procName ) + DALI_INTERNAL std::function GetGlobalProc(const Dali::AddOnLibrary& addonlibrary, const char* procName) { - auto ptr = GetGlobalProc( addonlibrary, procName ); - if( ptr ) + auto ptr = GetGlobalProc(addonlibrary, procName); + if(ptr) { - return std::function( *reinterpret_cast(&ptr) ); + return std::function(*reinterpret_cast(&ptr)); } return {}; }; @@ -200,12 +199,12 @@ public: * @return std::function object or null if function doesn't exist */ template - DALI_INTERNAL std::function GetInstanceProc( const Dali::AddOnLibrary& addOnLibrary, const char* procName ) + DALI_INTERNAL std::function GetInstanceProc(const Dali::AddOnLibrary& addOnLibrary, const char* procName) { - auto ptr = GetInstanceProc( addOnLibrary, procName ); - if( ptr ) + auto ptr = GetInstanceProc(addOnLibrary, procName); + if(ptr) { - return std::function( *reinterpret_cast(&ptr) ); + return std::function(*reinterpret_cast(&ptr)); } return {}; }; @@ -218,14 +217,13 @@ public: * @return Result of called function */ template - DALI_INTERNAL R InvokeGlobalProc( AddOnLibrary addOnLibrary, const char* functionName, Args&&... args) + DALI_INTERNAL R InvokeGlobalProc(AddOnLibrary addOnLibrary, const char* functionName, Args&&... args) { - return std::move(GetGlobalProc( addOnLibrary, functionName )( args... )); + return std::move(GetGlobalProc(addOnLibrary, functionName)(args...)); } // Lifecycle events, functions are called by the Adaptor public: - /** * @brief Lifecycle pause function */ @@ -248,7 +246,6 @@ public: // Functions called by the AddOn public: - /** * @brief Registers the dispatch table with AddOnManager. * @@ -259,7 +256,7 @@ public: * * @param[in] dispatchTable Pointer to the valid dispatch table */ - virtual void RegisterAddOnDispatchTable( const AddOnDispatchTable* dispatchTable ) = 0; + virtual void RegisterAddOnDispatchTable(const AddOnDispatchTable* dispatchTable) = 0; /** * @brief Retrieves AddOnManager singleton @@ -268,7 +265,6 @@ public: static AddOnManager* Get(); protected: - static AddOnManager* mSingleton; ///< Singleton storing an instance of AddOnManager }; } // namespace Integration diff --git a/dali/integration-api/bitmap.cpp b/dali/integration-api/bitmap.cpp index 794be95..dbebee5 100644 --- a/dali/integration-api/bitmap.cpp +++ b/dali/integration-api/bitmap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -20,116 +20,115 @@ // INTERNAL INCLUDES #include +#include +#include #include #include -#include #include -#include -#include +#include namespace Dali { - namespace Integration { using namespace Dali::Pixel; -void ConvertToGlFormat( Format pixelformat, unsigned& pixelDataType, unsigned& internalFormat ) +void ConvertToGlFormat(Format pixelformat, unsigned& pixelDataType, unsigned& internalFormat) { // Compressed textures have no pixelDataType, so init to an invalid value: - pixelDataType = -1; + pixelDataType = -1; - switch( pixelformat ) + switch(pixelformat) { case A8: { - pixelDataType = GL_UNSIGNED_BYTE; - internalFormat= GL_ALPHA; + pixelDataType = GL_UNSIGNED_BYTE; + internalFormat = GL_ALPHA; break; } case L8: { - pixelDataType = GL_UNSIGNED_BYTE; - internalFormat= GL_LUMINANCE; + pixelDataType = GL_UNSIGNED_BYTE; + internalFormat = GL_LUMINANCE; break; } case LA88: { - pixelDataType = GL_UNSIGNED_BYTE; - internalFormat= GL_LUMINANCE_ALPHA; + pixelDataType = GL_UNSIGNED_BYTE; + internalFormat = GL_LUMINANCE_ALPHA; break; } case RGB565: { - pixelDataType = GL_UNSIGNED_SHORT_5_6_5; - internalFormat= GL_RGB; + pixelDataType = GL_UNSIGNED_SHORT_5_6_5; + internalFormat = GL_RGB; break; } case BGR565: { DALI_LOG_ERROR("Pixel format BGR565 is not supported by GLES.\n"); - pixelDataType = GL_UNSIGNED_SHORT_5_6_5; + pixelDataType = GL_UNSIGNED_SHORT_5_6_5; #ifdef _ARCH_ARM_ - internalFormat= GL_BGRA_EXT; // alpha is reserved but not used + internalFormat = GL_BGRA_EXT; // alpha is reserved but not used #else - internalFormat= GL_RGBA; // alpha is reserved but not used + internalFormat = GL_RGBA; // alpha is reserved but not used #endif break; } case RGBA4444: { - pixelDataType = GL_UNSIGNED_SHORT_4_4_4_4; - internalFormat= GL_RGBA; + pixelDataType = GL_UNSIGNED_SHORT_4_4_4_4; + internalFormat = GL_RGBA; break; } case BGRA4444: { DALI_LOG_ERROR("Pixel format BGRA4444 is not supported by GLES.\n"); - pixelDataType = GL_UNSIGNED_SHORT_4_4_4_4; + pixelDataType = GL_UNSIGNED_SHORT_4_4_4_4; #ifdef _ARCH_ARM_ - internalFormat= GL_BGRA_EXT; // alpha is reserved but not used + internalFormat = GL_BGRA_EXT; // alpha is reserved but not used #else - internalFormat= GL_RGBA; // alpha is reserved but not used + internalFormat = GL_RGBA; // alpha is reserved but not used #endif break; } case RGBA5551: { - pixelDataType = GL_UNSIGNED_SHORT_5_5_5_1; - internalFormat= GL_RGBA; + pixelDataType = GL_UNSIGNED_SHORT_5_5_5_1; + internalFormat = GL_RGBA; break; } case BGRA5551: { DALI_LOG_ERROR("Pixel format BGRA5551 is not supported by GLES.\n"); - pixelDataType = GL_UNSIGNED_SHORT_5_5_5_1; + pixelDataType = GL_UNSIGNED_SHORT_5_5_5_1; #ifdef _ARCH_ARM_ - internalFormat= GL_BGRA_EXT; // alpha is reserved but not used + internalFormat = GL_BGRA_EXT; // alpha is reserved but not used #else - internalFormat= GL_RGBA; // alpha is reserved but not used + internalFormat = GL_RGBA; // alpha is reserved but not used #endif break; } case RGB888: { - pixelDataType = GL_UNSIGNED_BYTE; - internalFormat= GL_RGB; + pixelDataType = GL_UNSIGNED_BYTE; + internalFormat = GL_RGB; break; } case RGB8888: { - pixelDataType = GL_UNSIGNED_BYTE; - internalFormat= GL_RGBA; // alpha is reserved but not used + pixelDataType = GL_UNSIGNED_BYTE; + internalFormat = GL_RGBA; // alpha is reserved but not used break; } @@ -137,17 +136,17 @@ void ConvertToGlFormat( Format pixelformat, unsigned& pixelDataType, unsigned& i { pixelDataType = GL_UNSIGNED_BYTE; #ifdef GL_BGRA_EXT - internalFormat= GL_BGRA_EXT; // alpha is reserved but not used + internalFormat = GL_BGRA_EXT; // alpha is reserved but not used #else - internalFormat= GL_RGBA; // alpha is reserved but not used + internalFormat = GL_RGBA; // alpha is reserved but not used #endif - break; + break; } case RGBA8888: { - pixelDataType = GL_UNSIGNED_BYTE; - internalFormat= GL_RGBA; + pixelDataType = GL_UNSIGNED_BYTE; + internalFormat = GL_RGBA; break; } @@ -155,9 +154,9 @@ void ConvertToGlFormat( Format pixelformat, unsigned& pixelDataType, unsigned& i { pixelDataType = GL_UNSIGNED_BYTE; #ifdef GL_BGRA_EXT - internalFormat= GL_BGRA_EXT; // alpha is reserved but not used + internalFormat = GL_BGRA_EXT; // alpha is reserved but not used #else - internalFormat= GL_RGBA; // alpha is reserved but not used + internalFormat = GL_RGBA; // alpha is reserved but not used #endif break; } @@ -165,13 +164,13 @@ void ConvertToGlFormat( Format pixelformat, unsigned& pixelDataType, unsigned& i // GLES 2 extension compressed formats: case COMPRESSED_RGB8_ETC1: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using non-standard GLES 2.0 extension compressed pixel format COMPRESSED_RGB8_ETC1.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using non-standard GLES 2.0 extension compressed pixel format COMPRESSED_RGB8_ETC1.\n"); internalFormat = 0x8D64; ///! < Hardcoded so we can test before we move to GLES 3.0 or greater. break; } case COMPRESSED_RGB_PVRTC_4BPPV1: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using non-standard GLES 2.0 extension compressed pixel format COMPRESSED_RGB_PVRTC_4BPPV1.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using non-standard GLES 2.0 extension compressed pixel format COMPRESSED_RGB_PVRTC_4BPPV1.\n"); internalFormat = 0x8C00; ///! < Hardcoded so we can test before we move to GLES 3.0 or greater. break; } @@ -185,55 +184,55 @@ void ConvertToGlFormat( Format pixelformat, unsigned& pixelDataType, unsigned& i } case COMPRESSED_SIGNED_R11_EAC: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SIGNED_R11_EAC.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SIGNED_R11_EAC.\n"); internalFormat = GL_COMPRESSED_SIGNED_R11_EAC; break; } case COMPRESSED_RG11_EAC: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RG11_EAC.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RG11_EAC.\n"); internalFormat = GL_COMPRESSED_RG11_EAC; break; } case COMPRESSED_SIGNED_RG11_EAC: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SIGNED_RG11_EAC.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SIGNED_RG11_EAC.\n"); internalFormat = GL_COMPRESSED_SIGNED_RG11_EAC; break; } case COMPRESSED_RGB8_ETC2: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RGB8_ETC2.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RGB8_ETC2.\n"); internalFormat = GL_COMPRESSED_RGB8_ETC2; break; } case COMPRESSED_SRGB8_ETC2: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_ETC2.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_ETC2.\n"); internalFormat = GL_COMPRESSED_SRGB8_ETC2; break; } case COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2.\n"); internalFormat = GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2; break; } case COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2.\n"); internalFormat = GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2; break; } case COMPRESSED_RGBA8_ETC2_EAC: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RGBA8_ETC2_EAC.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_RGBA8_ETC2_EAC.\n"); internalFormat = GL_COMPRESSED_RGBA8_ETC2_EAC; break; } case COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ETC2_EAC.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ETC2_EAC.\n"); internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC; break; } @@ -241,169 +240,169 @@ void ConvertToGlFormat( Format pixelformat, unsigned& pixelDataType, unsigned& i // GLES 3.1 extension compressed formats: case COMPRESSED_RGBA_ASTC_4x4_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_4x4_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_4x4_KHR.\n"); internalFormat = GL_COMPRESSED_RGBA_ASTC_4x4_KHR; break; } case COMPRESSED_RGBA_ASTC_5x4_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_5x4_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_5x4_KHR.\n"); internalFormat = GL_COMPRESSED_RGBA_ASTC_5x4_KHR; break; } case COMPRESSED_RGBA_ASTC_5x5_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_5x5_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_5x5_KHR.\n"); internalFormat = GL_COMPRESSED_RGBA_ASTC_5x5_KHR; break; } case COMPRESSED_RGBA_ASTC_6x5_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_6x5_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_6x5_KHR.\n"); internalFormat = GL_COMPRESSED_RGBA_ASTC_6x5_KHR; break; } case COMPRESSED_RGBA_ASTC_6x6_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_6x6_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_6x6_KHR.\n"); internalFormat = GL_COMPRESSED_RGBA_ASTC_6x6_KHR; break; } case COMPRESSED_RGBA_ASTC_8x5_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x5_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x5_KHR.\n"); internalFormat = GL_COMPRESSED_RGBA_ASTC_8x5_KHR; break; } case COMPRESSED_RGBA_ASTC_8x6_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x6_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x6_KHR.\n"); internalFormat = GL_COMPRESSED_RGBA_ASTC_8x6_KHR; break; } case COMPRESSED_RGBA_ASTC_8x8_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x8_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_8x8_KHR.\n"); internalFormat = GL_COMPRESSED_RGBA_ASTC_8x8_KHR; break; } case COMPRESSED_RGBA_ASTC_10x5_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x5_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x5_KHR.\n"); internalFormat = GL_COMPRESSED_RGBA_ASTC_10x5_KHR; break; } case COMPRESSED_RGBA_ASTC_10x6_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x6_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x6_KHR.\n"); internalFormat = GL_COMPRESSED_RGBA_ASTC_10x6_KHR; break; } case COMPRESSED_RGBA_ASTC_10x8_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x8_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x8_KHR.\n"); internalFormat = GL_COMPRESSED_RGBA_ASTC_10x8_KHR; break; } case COMPRESSED_RGBA_ASTC_10x10_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x10_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_10x10_KHR.\n"); internalFormat = GL_COMPRESSED_RGBA_ASTC_10x10_KHR; break; } case COMPRESSED_RGBA_ASTC_12x10_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_12x10_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_12x10_KHR.\n"); internalFormat = GL_COMPRESSED_RGBA_ASTC_12x10_KHR; break; } case COMPRESSED_RGBA_ASTC_12x12_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_12x12_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_RGBA_ASTC_12x12_KHR.\n"); internalFormat = GL_COMPRESSED_RGBA_ASTC_12x12_KHR; break; } case COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR.\n"); internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR; break; } case COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR.\n"); internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR; break; } case COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR.\n"); internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR; break; } case COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR.\n"); internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR; break; } case COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR.\n"); internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR; break; } case COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR.\n"); internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR; break; } case COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR.\n"); internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR; break; } case COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR.\n"); internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR; break; } case COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR.\n"); internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR; break; } case COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR.\n"); internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR; break; } case COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR.\n"); internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR; break; } case COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR.\n"); internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR; break; } case COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR.\n"); internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR; break; } case COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR.\n" ); + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.1 standard compressed pixel format COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR.\n"); internalFormat = GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR; break; } @@ -411,54 +410,54 @@ void ConvertToGlFormat( Format pixelformat, unsigned& pixelDataType, unsigned& i // GLES 3.0 floating point formats. case RGB16F: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 GLES 3.0 floating point format.\n" ); - pixelDataType = GL_HALF_FLOAT; - internalFormat= GL_RGB; + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 GLES 3.0 floating point format.\n"); + pixelDataType = GL_HALF_FLOAT; + internalFormat = GL_RGB; break; } case RGB32F: { - DALI_LOG_INFO( Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 GLES 3.0 floating point format.\n" ); - pixelDataType = GL_FLOAT; - internalFormat= GL_RGB; + DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Using GLES 3.0 GLES 3.0 floating point format.\n"); + pixelDataType = GL_FLOAT; + internalFormat = GL_RGB; break; } // GLES 3.0 depth and stencil formats case Pixel::DEPTH_UNSIGNED_INT: { - pixelDataType = GL_UNSIGNED_INT; + pixelDataType = GL_UNSIGNED_INT; internalFormat = GL_DEPTH_COMPONENT; break; } case Pixel::DEPTH_FLOAT: { - pixelDataType = GL_FLOAT; + pixelDataType = GL_FLOAT; internalFormat = GL_DEPTH_COMPONENT; break; } case Pixel::DEPTH_STENCIL: { - pixelDataType = GL_UNSIGNED_INT_24_8; + pixelDataType = GL_UNSIGNED_INT_24_8; internalFormat = GL_DEPTH_STENCIL; break; } case INVALID: { - DALI_LOG_ERROR( "Invalid pixel format for bitmap\n" ); + DALI_LOG_ERROR("Invalid pixel format for bitmap\n"); internalFormat = 0; break; } } } -Bitmap* Bitmap::New( const Profile profile = BITMAP_2D_PACKED_PIXELS, - ResourcePolicy::Discardable discardable = ResourcePolicy::OWNED_DISCARD ) +Bitmap* Bitmap::New(const Profile profile = BITMAP_2D_PACKED_PIXELS, + ResourcePolicy::Discardable discardable = ResourcePolicy::OWNED_DISCARD) { DALI_ASSERT_DEBUG(profile == BITMAP_2D_PACKED_PIXELS || profile == BITMAP_COMPRESSED); - switch( profile ) + switch(profile) { /** A 2D array of pixels where each pixel is a whole number of bytes * and each scanline of the backing memory buffer may have additional @@ -466,21 +465,20 @@ Bitmap* Bitmap::New( const Profile profile = BITMAP_2D_PACKED_PIXELS, * scanlines past the bottom of the image in the buffer if requested.*/ case BITMAP_2D_PACKED_PIXELS: { - Bitmap * const bitmap = new Dali::Internal::BitmapPackedPixel( discardable ); + Bitmap* const bitmap = new Dali::Internal::BitmapPackedPixel(discardable); return bitmap; } /** The data for the bitmap is buffered in an opaque form.*/ case BITMAP_COMPRESSED: { - return new Dali::Internal::BitmapCompressed( discardable ); + return new Dali::Internal::BitmapCompressed(discardable); } } return nullptr; } - -Bitmap::Bitmap( ResourcePolicy::Discardable discardable, Dali::Integration::PixelBuffer* pixBuf) +Bitmap::Bitmap(ResourcePolicy::Discardable discardable, Dali::Integration::PixelBuffer* pixBuf) : mImageWidth(0), mImageHeight(0), mPixelFormat(Pixel::RGBA8888), @@ -494,13 +492,13 @@ Bitmap::Bitmap( ResourcePolicy::Discardable discardable, Dali::Integration::Pixe PixelBuffer* Bitmap::GetBufferOwnership() { PixelBuffer* buffer = mData; - mData = nullptr; + mData = nullptr; return buffer; } void Bitmap::DiscardBuffer() { - if( mDiscardable == ResourcePolicy::OWNED_DISCARD ) + if(mDiscardable == ResourcePolicy::OWNED_DISCARD) { DeletePixelBuffer(); } @@ -516,23 +514,22 @@ Bitmap::~Bitmap() * */ void Bitmap::DeletePixelBuffer() { - if( !mData ) + if(!mData) { return; } - free ( mData ); + free(mData); mData = nullptr; } - -void Bitmap::Initialize( Pixel::Format pixelFormat, - unsigned int width, - unsigned int height) +void Bitmap::Initialize(Pixel::Format pixelFormat, + unsigned int width, + unsigned int height) { DALI_ASSERT_DEBUG(width * height < (32 * 1024) * (32 * 1024) && "The total area of the bitmap is too great.\n"); - mImageWidth = width; - mImageHeight = height; - mPixelFormat = pixelFormat; + mImageWidth = width; + mImageHeight = height; + mPixelFormat = pixelFormat; mHasAlphaChannel = Pixel::HasAlpha(pixelFormat); } diff --git a/dali/integration-api/bitmap.h b/dali/integration-api/bitmap.h index f9952c2..7a21048 100644 --- a/dali/integration-api/bitmap.h +++ b/dali/integration-api/bitmap.h @@ -2,7 +2,7 @@ #define DALI_INTEGRATION_BITMAP_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -22,17 +22,15 @@ // INTERNAL INCLUDES #include +#include #include #include #include -#include namespace Dali { - namespace Integration { - /** * Returns GL data type and internal format for specified pixel format * @param[in] pixelformat pixel format (eg. Pixel::RGBA32) @@ -52,14 +50,13 @@ using PixelBuffer = uint8_t; ///< Pixel data buffers are composed of these class DALI_CORE_API Bitmap : public Dali::RefObject { protected: - /** * Constructor * Use the static function Bitmap::New() to create instances. * @param[in] discardable Flag to tell the bitmap if it can delete the buffer with the pixel data. * @param[in] pixBuf External buffer of pixel data or null. */ - Bitmap( ResourcePolicy::Discardable discardable = ResourcePolicy::OWNED_RETAIN, Dali::Integration::PixelBuffer* pixBuf = nullptr ); + Bitmap(ResourcePolicy::Discardable discardable = ResourcePolicy::OWNED_RETAIN, Dali::Integration::PixelBuffer* pixBuf = nullptr); /** * Initializes internal class members @@ -68,9 +65,8 @@ protected: * @param[in] height Image height in pixels */ void Initialize(Pixel::Format pixelFormat, - uint32_t width, - uint32_t height); - + uint32_t width, + uint32_t height); public: /** Defines the characteristics of the Bitmap returned from the factory @@ -88,8 +84,8 @@ public: enum ReleaseFunction { - FREE, ///< Use free function to release the buffer - DELETE_ARRAY, ///< Use delete[] operator to release the buffer + FREE, ///< Use free function to release the buffer + DELETE_ARRAY, ///< Use delete[] operator to release the buffer }; /** @@ -103,7 +99,7 @@ public: * OWNED_RETAIN means that the data is owned and must be kept in CPU memory * e.g. for an image that cannot be reloaded from disk. */ - static Bitmap* New( Profile profile, ResourcePolicy::Discardable discardable ); + static Bitmap* New(Profile profile, ResourcePolicy::Discardable discardable); /** \name GeneralFeatures * Features that are generic between profiles. */ @@ -188,7 +184,6 @@ public: /**@}*/ ///< End of generic features - /** \name PackedPixelsProfile * Features that are active only if the Bitmap was created with a * BITMAP_2D_PACKED_PIXELS profile. */ @@ -197,7 +192,6 @@ public: class PackedPixelsProfile { public: - /** * (Re-)Allocate pixel buffer for the Bitmap. Any previously allocated pixel buffer is deleted. * Dali has ownership of the buffer, but its contents can be modified. @@ -211,10 +205,10 @@ public: * @return pixel buffer pointer */ virtual PixelBuffer* ReserveBuffer(Pixel::Format pixelFormat, - uint32_t width, - uint32_t height, - uint32_t bufferWidth = 0, - uint32_t bufferHeight = 0) = 0; + uint32_t width, + uint32_t height, + uint32_t bufferWidth = 0, + uint32_t bufferHeight = 0) = 0; /** * Assign a pixel buffer. Any previously allocated pixel buffer is deleted. @@ -237,12 +231,12 @@ public: * @param[in] bufferHeight Buffer height in pixels */ virtual void AssignBuffer(Pixel::Format pixelFormat, - PixelBuffer* buffer, - uint32_t bufferSize, - uint32_t width, - uint32_t height, - uint32_t bufferWidth = 0, - uint32_t bufferHeight = 0) = 0; + PixelBuffer* buffer, + uint32_t bufferSize, + uint32_t width, + uint32_t height, + uint32_t bufferWidth = 0, + uint32_t bufferHeight = 0) = 0; /** * Get the width of the buffer (stride) * @return The width of the buffer in pixels @@ -269,25 +263,31 @@ public: virtual void TestForTransparency() = 0; protected: - /** * Virtual destructor, no deletion through this interface */ - virtual ~PackedPixelsProfile() {} + virtual ~PackedPixelsProfile() + { + } }; /** * Get interface to features that are active only if the Bitmap was created * with a BITMAP_2D_PACKED_PIXELS profile. */ - virtual const PackedPixelsProfile* GetPackedPixelsProfile() const { return nullptr; } + virtual const PackedPixelsProfile* GetPackedPixelsProfile() const + { + return nullptr; + } /** * Get interface to features that are active only if the Bitmap was created * with a BITMAP_2D_PACKED_PIXELS profile. */ - virtual PackedPixelsProfile* GetPackedPixelsProfile() { return nullptr; } + virtual PackedPixelsProfile* GetPackedPixelsProfile() + { + return nullptr; + } /**@}*/ ///< End of packed pixel features. - /** \name CompressedProfile * Features that only apply to opaque/compressed formats. */ /**@{*/ @@ -307,23 +307,30 @@ public: * @param[in] bufferSize Buffer size in bytes * @return pixel buffer pointer */ - virtual PixelBuffer* ReserveBufferOfSize( Pixel::Format pixelFormat, - const unsigned width, - const unsigned height, - const uint32_t numBytes ) = 0; - protected: + virtual PixelBuffer* ReserveBufferOfSize(Pixel::Format pixelFormat, + const unsigned width, + const unsigned height, + const uint32_t numBytes) = 0; + protected: /** * Virtual destructor, no deletion through this interface */ - virtual ~CompressedProfile() {} + virtual ~CompressedProfile() + { + } }; - virtual const CompressedProfile* GetCompressedProfile() const { return nullptr; } - virtual CompressedProfile* GetCompressedProfile() { return nullptr; } + virtual const CompressedProfile* GetCompressedProfile() const + { + return nullptr; + } + virtual CompressedProfile* GetCompressedProfile() + { + return nullptr; + } /**@}*/ - /** * Inform the bitmap that its pixel buffer is no longer required and can be * deleted to free up memory if the bitmap owns the buffer. @@ -345,27 +352,24 @@ public: void DeletePixelBuffer(); protected: - /** * A reference counted object may only be deleted by calling Unreference() */ ~Bitmap() override; protected: - - uint32_t mImageWidth; ///< Image width in pixels - uint32_t mImageHeight; ///< Image height in pixels - Pixel::Format mPixelFormat; ///< Pixel format - bool mHasAlphaChannel; ///< Whether the image has an alpha channel - bool mAlphaChannelUsed; ///< Whether the alpha channel is used in case the image owns one. - PixelBuffer* mData; ///< Raw pixel data + uint32_t mImageWidth; ///< Image width in pixels + uint32_t mImageHeight; ///< Image height in pixels + Pixel::Format mPixelFormat; ///< Pixel format + bool mHasAlphaChannel; ///< Whether the image has an alpha channel + bool mAlphaChannelUsed; ///< Whether the alpha channel is used in case the image owns one. + PixelBuffer* mData; ///< Raw pixel data private: - ResourcePolicy::Discardable mDiscardable; ///< Should delete the buffer when discard buffer is called. - Bitmap(const Bitmap& other); ///< defined private to prevent use - Bitmap& operator = (const Bitmap& other); ///< defined private to prevent use + Bitmap(const Bitmap& other); ///< defined private to prevent use + Bitmap& operator=(const Bitmap& other); ///< defined private to prevent use // Changes scope, should be at end of class DALI_LOG_OBJECT_STRING_DECLARATION; diff --git a/dali/integration-api/context-notifier.h b/dali/integration-api/context-notifier.h index 905b503..cd437e1 100644 --- a/dali/integration-api/context-notifier.h +++ b/dali/integration-api/context-notifier.h @@ -2,7 +2,7 @@ #define DALI_INTEGRATION_CONTEXT_NOTIFIER_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -21,7 +21,6 @@ namespace Dali { namespace Integration { - /** * Interface to inform dali core of context loss and regain */ @@ -48,16 +47,15 @@ public: virtual void NotifyContextRegained() = 0; protected: - /** * Virtual destructor, no deletion through this interface */ - virtual ~ContextNotifierInterface() {} - + virtual ~ContextNotifierInterface() + { + } }; } // namespace Integration } // namespace Dali - #endif // DALI_INTEGRATION_CONTEXT_NOTIFIER_H diff --git a/dali/integration-api/core-enumerations.h b/dali/integration-api/core-enumerations.h index ff6153c..6417561 100644 --- a/dali/integration-api/core-enumerations.h +++ b/dali/integration-api/core-enumerations.h @@ -2,7 +2,7 @@ #define DALI_INTEGRATION_CORE_ENUMERATIONS_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -19,19 +19,17 @@ */ // EXTERNAL INCLUDES -#include #include #include +#include #undef FALSE #undef TRUE namespace Dali { - namespace Integration { - /** * @brief Enumerations to specify whether we should render to the frame-buffer. */ diff --git a/dali/integration-api/core.cpp b/dali/integration-api/core.cpp index ecac451..83cfedf 100644 --- a/dali/integration-api/core.cpp +++ b/dali/integration-api/core.cpp @@ -19,41 +19,39 @@ #include // INTERNAL INCLUDES -#include -#include -#include #include -#include #include +#include #include #include +#include +#include +#include namespace Dali { - namespace Integration { - -Core* Core::New( RenderController& renderController, - PlatformAbstraction& platformAbstraction, - GlAbstraction& glAbstraction, - GlSyncAbstraction& glSyncAbstraction, - GlContextHelperAbstraction& glContextHelperAbstraction, - RenderToFrameBuffer renderToFboEnabled, - DepthBufferAvailable depthBufferAvailable, - StencilBufferAvailable stencilBufferAvailable, - PartialUpdateAvailable partialUpdateAvailable ) -{ - Core* instance = new Core; - instance->mImpl = new Internal::Core( renderController, - platformAbstraction, - glAbstraction, - glSyncAbstraction, - glContextHelperAbstraction, - renderToFboEnabled, - depthBufferAvailable, - stencilBufferAvailable, - partialUpdateAvailable ); +Core* Core::New(RenderController& renderController, + PlatformAbstraction& platformAbstraction, + GlAbstraction& glAbstraction, + GlSyncAbstraction& glSyncAbstraction, + GlContextHelperAbstraction& glContextHelperAbstraction, + RenderToFrameBuffer renderToFboEnabled, + DepthBufferAvailable depthBufferAvailable, + StencilBufferAvailable stencilBufferAvailable, + PartialUpdateAvailable partialUpdateAvailable) +{ + Core* instance = new Core; + instance->mImpl = new Internal::Core(renderController, + platformAbstraction, + glAbstraction, + glSyncAbstraction, + glContextHelperAbstraction, + renderToFboEnabled, + depthBufferAvailable, + stencilBufferAvailable, + partialUpdateAvailable); return instance; } @@ -108,53 +106,53 @@ uint32_t Core::GetMaximumUpdateCount() const return mImpl->GetMaximumUpdateCount(); } -void Core::Update( float elapsedSeconds, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds, UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo ) +void Core::Update(float elapsedSeconds, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds, UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo) { - mImpl->Update( elapsedSeconds, lastVSyncTimeMilliseconds, nextVSyncTimeMilliseconds, status, renderToFboEnabled, isRenderingToFbo ); + mImpl->Update(elapsedSeconds, lastVSyncTimeMilliseconds, nextVSyncTimeMilliseconds, status, renderToFboEnabled, isRenderingToFbo); } -void Core::PreRender( RenderStatus& status, bool forceClear, bool uploadOnly ) +void Core::PreRender(RenderStatus& status, bool forceClear, bool uploadOnly) { - mImpl->PreRender( status, forceClear, uploadOnly ); + mImpl->PreRender(status, forceClear, uploadOnly); } -void Core::PreRender( Integration::Scene& scene, std::vector>& damagedRects ) +void Core::PreRender(Integration::Scene& scene, std::vector>& damagedRects) { - mImpl->PreRender( scene, damagedRects ); + mImpl->PreRender(scene, damagedRects); } -void Core::RenderScene( RenderStatus& status, Integration::Scene& scene, bool renderToFbo ) +void Core::RenderScene(RenderStatus& status, Integration::Scene& scene, bool renderToFbo) { - mImpl->RenderScene( status, scene, renderToFbo ); + mImpl->RenderScene(status, scene, renderToFbo); } -void Core::RenderScene( RenderStatus& status, Integration::Scene& scene, bool renderToFbo, Rect& clippingRect ) +void Core::RenderScene(RenderStatus& status, Integration::Scene& scene, bool renderToFbo, Rect& clippingRect) { - mImpl->RenderScene( status, scene, renderToFbo, clippingRect ); + mImpl->RenderScene(status, scene, renderToFbo, clippingRect); } -void Core::PostRender( bool uploadOnly ) +void Core::PostRender(bool uploadOnly) { - mImpl->PostRender( uploadOnly ); + mImpl->PostRender(uploadOnly); } -void Core::RegisterProcessor( Processor& processor ) +void Core::RegisterProcessor(Processor& processor) { - mImpl->RegisterProcessor( processor ); + mImpl->RegisterProcessor(processor); } -void Core::UnregisterProcessor( Processor& processor ) +void Core::UnregisterProcessor(Processor& processor) { - mImpl->UnregisterProcessor( processor ); + mImpl->UnregisterProcessor(processor); } ObjectRegistry Core::GetObjectRegistry() const { - return ObjectRegistry( &mImpl->GetObjectRegistry() ); + return ObjectRegistry(&mImpl->GetObjectRegistry()); } Core::Core() -: mImpl( nullptr ) +: mImpl(nullptr) { } diff --git a/dali/integration-api/core.h b/dali/integration-api/core.h index 3cfd089..97ebcef 100644 --- a/dali/integration-api/core.h +++ b/dali/integration-api/core.h @@ -22,15 +22,14 @@ #include // uint32_t // INTERNAL INCLUDES +#include +#include #include #include #include -#include -#include namespace Dali { - class Layer; class ObjectRegistry; class RenderTaskList; @@ -53,7 +52,6 @@ class Scene; struct Event; struct TouchEvent; - /** * The reasons why further updates are required. */ @@ -61,11 +59,11 @@ namespace KeepUpdating { enum Reasons { - NOT_REQUESTED = 0, ///< Zero means that no further updates are required - STAGE_KEEP_RENDERING = 1<<1, ///< - Stage::KeepRendering() is being used - ANIMATIONS_RUNNING = 1<<2, ///< - Animations are ongoing - MONITORING_PERFORMANCE = 1<<3, ///< - The --enable-performance-monitor option is being used - RENDER_TASK_SYNC = 1<<4 ///< - A render task is waiting for render sync + NOT_REQUESTED = 0, ///< Zero means that no further updates are required + STAGE_KEEP_RENDERING = 1 << 1, ///< - Stage::KeepRendering() is being used + ANIMATIONS_RUNNING = 1 << 2, ///< - Animations are ongoing + MONITORING_PERFORMANCE = 1 << 3, ///< - The --enable-performance-monitor option is being used + RENDER_TASK_SYNC = 1 << 4 ///< - A render task is waiting for render sync }; } @@ -75,7 +73,6 @@ enum Reasons class UpdateStatus { public: - /** * Constructor */ @@ -83,44 +80,54 @@ public: : keepUpdating(false), needsNotification(false), surfaceRectChanged(false), - secondsFromLastFrame( 0.0f ) + secondsFromLastFrame(0.0f) { } public: - /** * Query whether the Core has further frames to update & render e.g. when animations are ongoing. * @return A bitmask of KeepUpdating values */ - uint32_t KeepUpdating() { return keepUpdating; } + uint32_t KeepUpdating() + { + return keepUpdating; + } /** * Query whether the Core requires an Notification event. * This should be sent through the same mechanism (e.g. event loop) as input events. * @return True if an Notification event should be sent. */ - bool NeedsNotification() { return needsNotification; } + bool NeedsNotification() + { + return needsNotification; + } /** * Query wheter the default surface rect is changed or not. * @return true if the default surface rect is changed. */ - bool SurfaceRectChanged() { return surfaceRectChanged; } + bool SurfaceRectChanged() + { + return surfaceRectChanged; + } /** * This method is provided so that FPS can be easily calculated with a release version * of Core. * @return the seconds from last frame as float */ - float SecondsFromLastFrame() { return secondsFromLastFrame; } + float SecondsFromLastFrame() + { + return secondsFromLastFrame; + } public: - uint32_t keepUpdating; ///< A bitmask of KeepUpdating values - bool needsNotification; - bool surfaceRectChanged; - float secondsFromLastFrame; + bool needsNotification; + bool surfaceRectChanged; + float secondsFromLastFrame; }; /** @@ -129,13 +136,12 @@ public: class RenderStatus { public: - /** * Constructor */ RenderStatus() - : needsUpdate( false ), - needsPostRender( false ) + : needsUpdate(false), + needsPostRender(false) { } @@ -143,7 +149,7 @@ public: * Set whether update needs to run following a render. * @param[in] updateRequired Set to true if an update is required to be run */ - void SetNeedsUpdate( bool updateRequired ) + void SetNeedsUpdate(bool updateRequired) { needsUpdate = updateRequired; } @@ -162,7 +168,7 @@ public: * If nothing is rendered this frame, we can skip post-render. * @param[in] postRenderRequired Set to True if post-render is required to be run */ - void SetNeedsPostRender( bool postRenderRequired ) + void SetNeedsPostRender(bool postRenderRequired) { needsPostRender = postRenderRequired; } @@ -177,12 +183,10 @@ public: } private: - - bool needsUpdate :1; ///< True if update is required to be run - bool needsPostRender :1; ///< True if post-render is required to be run. + bool needsUpdate : 1; ///< True if update is required to be run + bool needsPostRender : 1; ///< True if post-render is required to be run. }; - /** * Integration::Core is used for integration with the native windowing system. * The following integration tasks must be completed: @@ -219,7 +223,6 @@ private: class DALI_CORE_API Core { public: - /** * Create a new Core. * This object is used for integration with the native windowing system. @@ -234,15 +237,15 @@ public: * @param[in] partialUpdateAvailable Whether the partial update is available * @return A newly allocated Core. */ - static Core* New( RenderController& renderController, - PlatformAbstraction& platformAbstraction, - GlAbstraction& glAbstraction, - GlSyncAbstraction& glSyncAbstraction, - GlContextHelperAbstraction& glContextHelperAbstraction, - RenderToFrameBuffer renderToFboEnabled, - DepthBufferAvailable depthBufferAvailable, - StencilBufferAvailable stencilBufferAvailable, - PartialUpdateAvailable partialUpdateAvailable); + static Core* New(RenderController& renderController, + PlatformAbstraction& platformAbstraction, + GlAbstraction& glAbstraction, + GlSyncAbstraction& glSyncAbstraction, + GlContextHelperAbstraction& glContextHelperAbstraction, + RenderToFrameBuffer renderToFboEnabled, + DepthBufferAvailable depthBufferAvailable, + StencilBufferAvailable stencilBufferAvailable, + PartialUpdateAvailable partialUpdateAvailable); /** * Non-virtual destructor. Core is not intended as a base class. @@ -335,12 +338,12 @@ public: * @param[in] renderToFboEnabled Whether rendering into the Frame Buffer Object is enabled. * @param[in] isRenderingToFbo Whether this frame is being rendered into the Frame Buffer Object. */ - void Update( float elapsedSeconds, - uint32_t lastVSyncTimeMilliseconds, - uint32_t nextVSyncTimeMilliseconds, - UpdateStatus& status, - bool renderToFboEnabled, - bool isRenderingToFbo ); + void Update(float elapsedSeconds, + uint32_t lastVSyncTimeMilliseconds, + uint32_t nextVSyncTimeMilliseconds, + UpdateStatus& status, + bool renderToFboEnabled, + bool isRenderingToFbo); /** * This is called before rendering any scene in the next frame. This method should be preceded @@ -351,7 +354,7 @@ public: * @param[in] forceClear force the Clear on the framebuffer even if nothing is rendered. * @param[in] uploadOnly uploadOnly Upload the resource only without rendering. */ - void PreRender( RenderStatus& status, bool forceClear, bool uploadOnly ); + void PreRender(RenderStatus& status, bool forceClear, bool uploadOnly); /** * This is called before rendering any scene in the next frame. This method should be preceded @@ -361,7 +364,7 @@ public: * @param[in] scene The scene to be rendered. * @param[out] damagedRects containing damaged render items rects for this pass. */ - void PreRender( Integration::Scene& scene, std::vector>& damagedRects ); + void PreRender(Integration::Scene& scene, std::vector>& damagedRects); /** * Render a scene in the next frame. This method should be preceded by a call up PreRender. @@ -373,7 +376,7 @@ public: * @param[in] scene The scene to be rendered. * @param[in] renderToFbo True to render off-screen frame buffers only if any, and False to render the surface only. */ - void RenderScene( RenderStatus& status, Integration::Scene& scene, bool renderToFbo ); + void RenderScene(RenderStatus& status, Integration::Scene& scene, bool renderToFbo); /** * Render a scene in the next frame. This method should be preceded by a call up PreRender. @@ -386,7 +389,7 @@ public: * @param[in] renderToFbo True to render off-screen frame buffers only if any, and False to render the surface only. * @param[in] clippingRect The rect to clip rendered scene. */ - void RenderScene( RenderStatus& status, Integration::Scene& scene, bool renderToFbo, Rect& clippingRect ); + void RenderScene(RenderStatus& status, Integration::Scene& scene, bool renderToFbo, Rect& clippingRect); /** * This is called after rendering all the scenes in the next frame. This method should be @@ -395,7 +398,7 @@ public: * @pre The GL context must have been created, and made current. * @param[in] uploadOnly uploadOnly Upload the resource only without rendering. */ - void PostRender( bool uploadOnly ); + void PostRender(bool uploadOnly); /** * @brief Register a processor @@ -403,13 +406,13 @@ public: * Note, Core does not take ownership of this processor. * @param[in] processor The process to register */ - void RegisterProcessor( Processor& processor ); + void RegisterProcessor(Processor& processor); /** * @brief Unregister a processor * @param[in] processor The process to unregister */ - void UnregisterProcessor( Processor& processor ); + void UnregisterProcessor(Processor& processor); /** * @brief Gets the Object registry. @@ -418,7 +421,6 @@ public: ObjectRegistry GetObjectRegistry() const; private: - /** * Private constructor; see also Core::New() */ @@ -439,9 +441,7 @@ private: Core& operator=(const Core& rhs); private: - Internal::Core* mImpl; - }; } // namespace Integration diff --git a/dali/integration-api/debug.cpp b/dali/integration-api/debug.cpp index 7e635d5..53df468 100644 --- a/dali/integration-api/debug.cpp +++ b/dali/integration-api/debug.cpp @@ -19,26 +19,25 @@ #include // EXTERNAL INCLUDES -#include #include -#include +#include #include -#include -#include +#include #include +#include +#include // INTERNAL INCLUDES +#include #include -#include #include +#include +#include #include #include -#include -#include namespace Dali { - #ifdef DEBUG_ENABLED // Fake globals for gdb typedefs @@ -47,29 +46,25 @@ Dali::DebugPropertyValueMap gValueMap; #endif - namespace // unnamed namespace { - const uint64_t NANOSECONDS_PER_SECOND = 1e+9; } namespace Integration { - namespace Log { - thread_local LogFunction gthreadLocalLogFunction = nullptr; /* Forward declarations */ -std::string FormatToString(const char *format, ...); -std::string ArgListToString(const char *format, va_list args); +std::string FormatToString(const char* format, ...); +std::string ArgListToString(const char* format, va_list args); void LogMessage(DebugPriority priority, const char* format, ...) { - if ( !gthreadLocalLogFunction ) + if(!gthreadLocalLogFunction) { return; } @@ -79,7 +74,7 @@ void LogMessage(DebugPriority priority, const char* format, ...) std::string message = ArgListToString(format, arg); va_end(arg); - gthreadLocalLogFunction(priority,message); + gthreadLocalLogFunction(priority, message); } void InstallLogFunction(const LogFunction& logFunction) @@ -115,27 +110,27 @@ Filter::FilterList* Filter::GetActiveFilters() return activeFilters; } -Filter* Filter::New( LogLevel level, bool trace, const char * environmentVariableName ) +Filter* Filter::New(LogLevel level, bool trace, const char* environmentVariableName) { - char * environmentVariableValue = getenv( environmentVariableName ); - if ( environmentVariableValue ) + char* environmentVariableValue = getenv(environmentVariableName); + if(environmentVariableValue) { unsigned int envLevel(0); - char envTraceString(0); - sscanf( environmentVariableValue, "%u,%c", &envLevel, &envTraceString ); + char envTraceString(0); + sscanf(environmentVariableValue, "%u,%c", &envLevel, &envTraceString); - if ( envLevel > Verbose ) + if(envLevel > Verbose) { envLevel = Verbose; } - level = LogLevel( envLevel ); + level = LogLevel(envLevel); // Just use 'f' and 't' as it's faster than doing full string comparisons - if ( envTraceString == 't' ) + if(envTraceString == 't') { trace = true; } - else if ( envTraceString == 'f' ) + else if(envTraceString == 'f') { trace = false; } @@ -169,11 +164,11 @@ void Filter::DisableGlobalTrace() } } -void Filter::SetGlobalLogLevel( LogLevel level ) +void Filter::SetGlobalLogLevel(LogLevel level) { for(FilterIter iter = GetActiveFilters()->begin(); iter != GetActiveFilters()->end(); iter++) { - (*iter)->SetLogLevel( level ); + (*iter)->SetLogLevel(level); } } @@ -184,28 +179,28 @@ void Filter::Log(LogLevel level, const char* format, ...) va_list arg; va_start(arg, format); - if( mTraceEnabled ) + if(mTraceEnabled) { - char *buffer = nullptr; - int numChars = asprintf( &buffer, " %-*c %s", mNesting, ':', format ); - if( numChars >= 0 ) // No error + char* buffer = nullptr; + int numChars = asprintf(&buffer, " %-*c %s", mNesting, ':', format); + if(numChars >= 0) // No error { - std::string message = ArgListToString( buffer, arg ); - LogMessage( DebugInfo, message.c_str() ); - free( buffer ); + std::string message = ArgListToString(buffer, arg); + LogMessage(DebugInfo, message.c_str()); + free(buffer); } } else { - std::string message = ArgListToString( format, arg ); - LogMessage( DebugInfo, message.c_str() ); + std::string message = ArgListToString(format, arg); + LogMessage(DebugInfo, message.c_str()); } va_end(arg); } } - -TraceObj::TraceObj(Filter* filter, const char*format, ...) : mFilter(filter) +TraceObj::TraceObj(Filter* filter, const char* format, ...) +: mFilter(filter) { if(mFilter && mFilter->IsTraceEnabled()) { @@ -223,7 +218,7 @@ TraceObj::~TraceObj() { if(mFilter && mFilter->IsTraceEnabled()) { - if (mFilter->mNesting) + if(mFilter->mNesting) { --mFilter->mNesting; } @@ -233,13 +228,13 @@ TraceObj::~TraceObj() #endif // DEBUG_ENABLED -std::string ArgListToString(const char *format, va_list args) +std::string ArgListToString(const char* format, va_list args) { std::string str; // empty string if(format != nullptr) { char* buffer = nullptr; - int err = vasprintf(&buffer, format, args); + int err = vasprintf(&buffer, format, args); if(err >= 0) // No error { str = buffer; @@ -249,7 +244,7 @@ std::string ArgListToString(const char *format, va_list args) return str; } -std::string FormatToString(const char *format, ...) +std::string FormatToString(const char* format, ...) { va_list arg; va_start(arg, format); @@ -258,13 +253,13 @@ std::string FormatToString(const char *format, ...) return s; } -void GetNanoseconds( uint64_t& timeInNanoseconds ) +void GetNanoseconds(uint64_t& timeInNanoseconds) { timespec timeSpec; - clock_gettime( CLOCK_MONOTONIC, &timeSpec ); + clock_gettime(CLOCK_MONOTONIC, &timeSpec); // Convert all values to uint64_t to match our return type - timeInNanoseconds = ( static_cast< uint64_t >( timeSpec.tv_sec ) * NANOSECONDS_PER_SECOND ) + static_cast< uint64_t >( timeSpec.tv_nsec ); + timeInNanoseconds = (static_cast(timeSpec.tv_sec) * NANOSECONDS_PER_SECOND) + static_cast(timeSpec.tv_nsec); } } // namespace Log diff --git a/dali/integration-api/debug.h b/dali/integration-api/debug.h index e95bebf..5b2f40c 100644 --- a/dali/integration-api/debug.h +++ b/dali/integration-api/debug.h @@ -19,11 +19,11 @@ */ // EXTERNAL INCLUDES -#include -#include +#include #include #include -#include +#include +#include #include #include @@ -32,12 +32,19 @@ #include // Using Debug namespace alias shortens the log usage significantly -namespace Dali{namespace Integration{namespace Log{}}} +namespace Dali +{ +namespace Integration +{ +namespace Log +{ +} +} // namespace Integration +} // namespace Dali namespace Debug = Dali::Integration::Log; namespace Dali { - struct Vector2; struct Vector3; struct Vector4; @@ -69,7 +76,6 @@ namespace Integration { namespace Log { - enum DebugPriority { DebugInfo, @@ -82,12 +88,12 @@ enum DebugPriority * @param level debug level * @param format string format */ -DALI_CORE_API void LogMessage(enum DebugPriority level,const char *format, ...); +DALI_CORE_API void LogMessage(enum DebugPriority level, const char* format, ...); /** * typedef for the logging function. */ -using LogFunction = void ( * )( DebugPriority, std::string & ); +using LogFunction = void (*)(DebugPriority, std::string&); /** * A log function has to be installed for every thread that wants to use logging. @@ -111,39 +117,38 @@ DALI_CORE_API void UninstallLogFunction(); /** * Provides unfiltered logging for global error level messages */ -#define DALI_LOG_ERROR(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugError, "%s " format, __FUNCTION__, ## __VA_ARGS__) +#define DALI_LOG_ERROR(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugError, "%s " format, __FUNCTION__, ##__VA_ARGS__) -#define DALI_LOG_ERROR_NOFN(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugError, format, ## __VA_ARGS__) +#define DALI_LOG_ERROR_NOFN(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugError, format, ##__VA_ARGS__) -#define DALI_LOG_WARNING_NOFN(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugWarning, format, ## __VA_ARGS__) +#define DALI_LOG_WARNING_NOFN(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugWarning, format, ##__VA_ARGS__) /** * Provides unfiltered logging for fps monitor */ -#define DALI_LOG_FPS(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, format, ## __VA_ARGS__) +#define DALI_LOG_FPS(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, format, ##__VA_ARGS__) /** * Provides unfiltered logging for update status */ -#define DALI_LOG_UPDATE_STATUS(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, format, ## __VA_ARGS__) +#define DALI_LOG_UPDATE_STATUS(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, format, ##__VA_ARGS__) /** * Provides unfiltered logging for render information */ -#define DALI_LOG_RENDER_INFO(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, format, ## __VA_ARGS__) +#define DALI_LOG_RENDER_INFO(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, format, ##__VA_ARGS__) /** * Provides unfiltered logging for release */ -#define DALI_LOG_RELEASE_INFO(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, format, ## __VA_ARGS__) +#define DALI_LOG_RELEASE_INFO(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, format, ##__VA_ARGS__) #ifdef DEBUG_ENABLED /** * Provides unfiltered logging for global warning level messages */ -#define DALI_LOG_WARNING(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugWarning, "%s " format, ASSERT_LOCATION, ## __VA_ARGS__) - +#define DALI_LOG_WARNING(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugWarning, "%s " format, ASSERT_LOCATION, ##__VA_ARGS__) #else // DEBUG_ENABLED @@ -165,13 +170,12 @@ DALI_CORE_API void UninstallLogFunction(); */ enum LogLevel { - NoLogging = 0, - Concise = 1, - General = 2, - Verbose = 3 + NoLogging = 0, + Concise = 1, + General = 2, + Verbose = 3 }; - /** * The Filter object is used by the DALI_LOG_INFO macro and others to determine if the logging * should take place, and routes the logging via the platform abstraction's LogMessage. @@ -183,39 +187,53 @@ enum LogLevel class DALI_CORE_API Filter { public: - using FilterList = std::list; - using FilterIter = std::list::iterator; + using FilterList = std::list; + using FilterIter = std::list::iterator; public: - /** * Test if the filter is enabled for the given logging level * @param[in] level - the level to test. * @return true if this level of logging is enabled. */ - bool IsEnabledFor(LogLevel level) { return level != Debug::NoLogging && level <= mLoggingLevel;} + bool IsEnabledFor(LogLevel level) + { + return level != Debug::NoLogging && level <= mLoggingLevel; + } /** * Test if trace is enabled for this filter. * @return true if trace is enabled; */ - bool IsTraceEnabled() { return mTraceEnabled; } + bool IsTraceEnabled() + { + return mTraceEnabled; + } /** * Enable tracing on this filter. */ - void EnableTrace() { mTraceEnabled = true; } + void EnableTrace() + { + mTraceEnabled = true; + } /** * Disable tracing on this filter. */ - void DisableTrace() { mTraceEnabled = false; } + void DisableTrace() + { + mTraceEnabled = false; + } /** * Set the log level for this filter. Setting to a higher value than Debug::General also * enables General; */ - void SetLogLevel(LogLevel level) { mLoggingLevel = level; } + void SetLogLevel(LogLevel level) + { + mLoggingLevel = level; + } /** * Perform the logging for this filter. @@ -245,7 +263,7 @@ public: * FILTER_ENV=0,true dali-demo // LogLevel NoLogging, Trace ON * @endcode */ - static Filter* New(LogLevel level, bool trace, const char * environmentVariableName ); + static Filter* New(LogLevel level, bool trace, const char* environmentVariableName); /** * Enable trace on all filters. @@ -262,16 +280,20 @@ public: * * @param[in] level The log level */ - static void SetGlobalLogLevel( LogLevel level ); + static void SetGlobalLogLevel(LogLevel level); private: - /** * Constructor. * @param[in] level - the highest log level. * @param[in] trace - whether this filter allows tracing. */ - Filter(LogLevel level, bool trace) : mLoggingLevel(level), mTraceEnabled(trace), mNesting(0) {} + Filter(LogLevel level, bool trace) + : mLoggingLevel(level), + mTraceEnabled(trace), + mNesting(0) + { + } static FilterList* GetActiveFilters(); @@ -280,35 +302,34 @@ public: // you can add a filter to your own class or source file. If you do, use Filter::New() // to tell this class about it. - static Filter *gRender; - static Filter *gResource; - static Filter *gGLResource; - static Filter *gObject; - static Filter *gImage; - static Filter *gModel; - static Filter *gNode; - static Filter *gElement; - static Filter *gActor; - static Filter *gShader; + static Filter* gRender; + static Filter* gResource; + static Filter* gGLResource; + static Filter* gObject; + static Filter* gImage; + static Filter* gModel; + static Filter* gNode; + static Filter* gElement; + static Filter* gActor; + static Filter* gShader; private: LogLevel mLoggingLevel; bool mTraceEnabled; -public: - int mNesting; +public: + int mNesting; }; - -#define DALI_LOG_FILTER_SET_LEVEL(filter, level) filter->SetLogLevel(level) -#define DALI_LOG_FILTER_ENABLE_TRACE(filter) filter->EnableTrace() -#define DALI_LOG_FILTER_DISABLE_TRACE(filter) filter->DisableTrace() +#define DALI_LOG_FILTER_SET_LEVEL(filter, level) filter->SetLogLevel(level) +#define DALI_LOG_FILTER_ENABLE_TRACE(filter) filter->EnableTrace() +#define DALI_LOG_FILTER_DISABLE_TRACE(filter) filter->DisableTrace() #else -#define DALI_LOG_FILTER_SET_LEVEL(filter, level) -#define DALI_LOG_FILTER_ENABLE_TRACE(filter) -#define DALI_LOG_FILTER_DISABLE_TRACE(filter) +#define DALI_LOG_FILTER_SET_LEVEL(filter, level) +#define DALI_LOG_FILTER_ENABLE_TRACE(filter) +#define DALI_LOG_FILTER_DISABLE_TRACE(filter) #endif @@ -318,25 +339,27 @@ public: #ifdef DEBUG_ENABLED -#define DALI_LOG_INFO(filter, level, format, ...) \ - if(filter && filter->IsEnabledFor(level)) { filter->Log(level, format, ## __VA_ARGS__); } - -#define DALI_LOG_STREAM( filter, level, stream ) \ +#define DALI_LOG_INFO(filter, level, format, ...) \ if(filter && filter->IsEnabledFor(level)) \ { \ - std::ostringstream o; \ - o << stream << std::endl; \ - filter->Log(level, "%s", o.str().c_str()); \ + filter->Log(level, format, ##__VA_ARGS__); \ + } + +#define DALI_LOG_STREAM(filter, level, stream) \ + if(filter && filter->IsEnabledFor(level)) \ + { \ + std::ostringstream o; \ + o << stream << std::endl; \ + filter->Log(level, "%s", o.str().c_str()); \ } #else // DEBUG_ENABLED #define DALI_LOG_INFO(filter, level, format, ...) -#define DALI_LOG_STREAM( filter, level, stream ) +#define DALI_LOG_STREAM(filter, level, stream) #endif // DEBUG_ENABLED - /******************************************************************************** * Trace Macros * ********************************************************************************/ @@ -356,23 +379,20 @@ public: public: std::string mMessage; - Filter* mFilter; + Filter* mFilter; }; +#define DALI_LOG_TRACE_METHOD_FMT(filter, format, ...) \ + Dali::Integration::Log::TraceObj debugTraceObj(filter, "%s: " format, ASSERT_LOCATION, ##__VA_ARGS__) -#define DALI_LOG_TRACE_METHOD_FMT(filter, format, ...) \ - Dali::Integration::Log::TraceObj debugTraceObj(filter, "%s: " format, ASSERT_LOCATION, ## __VA_ARGS__) - -#define DALI_LOG_TRACE_METHOD(filter) \ +#define DALI_LOG_TRACE_METHOD(filter) \ Dali::Integration::Log::TraceObj debugTraceObj(filter, ASSERT_LOCATION) - #else // DEBUG_ENABLED #define DALI_LOG_TRACE_METHOD_FMT(filter, format, ...) #define DALI_LOG_TRACE_METHOD(filter) - #endif /******************************************************************************** @@ -389,21 +409,23 @@ public: * Warning - this will increase the size of the object for a debug build. */ #define DALI_LOG_OBJECT_STRING_DECLARATION \ -public: \ +public: \ std::string mDebugString; /** * Print all the actor tree names **/ -#define DALI_LOG_ACTOR_TREE( node ) { \ - std::stringstream branch; \ - Node* tempNode = node; \ - while( tempNode ) { \ - branch << "<" << tempNode->mDebugString << ">::"; \ - tempNode = tempNode->GetParent(); \ - } \ - DALI_LOG_ERROR_NOFN("Actor tree: %s\n", branch.str().c_str()); \ -} +#define DALI_LOG_ACTOR_TREE(node) \ + { \ + std::stringstream branch; \ + Node* tempNode = node; \ + while(tempNode) \ + { \ + branch << "<" << tempNode->mDebugString << ">::"; \ + tempNode = tempNode->GetParent(); \ + } \ + DALI_LOG_ERROR_NOFN("Actor tree: %s\n", branch.str().c_str()); \ + } /** * Allows one object to set another object's debug string @@ -413,7 +435,7 @@ public: \ /** * Allows one object to set another object's std::string easily */ -#define DALI_LOG_FMT_OBJECT_STRING(object, fmt, ...) (object->mDebugString = FormatToString(fmt, ## __VA_ARGS__)) +#define DALI_LOG_FMT_OBJECT_STRING(object, fmt, ...) (object->mDebugString = FormatToString(fmt, ##__VA_ARGS__)) /** * Allows one object to get another object's debug string @@ -428,8 +450,7 @@ public: \ /** * Filtered logging of the object's debug string */ -#define DALI_LOG_OBJECT(filter, object) DALI_LOG_INFO(filter, Debug::General, object->mDebugString) - +#define DALI_LOG_OBJECT(filter, object) DALI_LOG_INFO(filter, Debug::General, object->mDebugString) #else // DEBUG_ENABLED @@ -449,27 +470,26 @@ public: \ #if defined(DEBUG_ENABLED) -void GetNanoseconds( uint64_t& timeInNanoseconds ); +void GetNanoseconds(uint64_t& timeInNanoseconds); -#define DALI_LOG_TIMER_START( timeVariable ) \ - uint64_t timeVariable##1; \ - Debug::GetNanoseconds( timeVariable##1 ); +#define DALI_LOG_TIMER_START(timeVariable) \ + uint64_t timeVariable##1; \ + Debug::GetNanoseconds(timeVariable##1); -#define DALI_LOG_TIMER_END( timeVariable, filter, level, preString) \ - uint64_t timeVariable##2; \ - Debug::GetNanoseconds( timeVariable##2 ); \ - DALI_LOG_INFO( filter, level, preString " %ld uSec\n", ((timeVariable##2-timeVariable##1)/1000)); +#define DALI_LOG_TIMER_END(timeVariable, filter, level, preString) \ + uint64_t timeVariable##2; \ + Debug::GetNanoseconds(timeVariable##2); \ + DALI_LOG_INFO(filter, level, preString " %ld uSec\n", ((timeVariable##2 - timeVariable##1) / 1000)); #else // DEBUG_ENABLED -#define DALI_LOG_TIMER_START( timeVariable ) -#define DALI_LOG_TIMER_END( timeVariable, filter, level, preString) +#define DALI_LOG_TIMER_START(timeVariable) +#define DALI_LOG_TIMER_END(timeVariable, filter, level, preString) #endif -} // Debug -} // Integration -} // Dali - +} // namespace Log +} // namespace Integration +} // namespace Dali #endif // DALI_INTEGRATION_DEBUG_H diff --git a/dali/integration-api/events/event.cpp b/dali/integration-api/events/event.cpp index 381de18..c14a78c 100644 --- a/dali/integration-api/events/event.cpp +++ b/dali/integration-api/events/event.cpp @@ -20,10 +20,8 @@ namespace Dali { - namespace Integration { - Event::~Event() { } diff --git a/dali/integration-api/events/event.h b/dali/integration-api/events/event.h index bf56300..d13bedf 100644 --- a/dali/integration-api/events/event.h +++ b/dali/integration-api/events/event.h @@ -2,7 +2,7 @@ #define DALI_INTEGRATION_EVENT_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -23,10 +23,8 @@ namespace Dali { - namespace Integration { - /** * Base structure for events passed to Dali::Integration::Core::QueueEvent() * An instance of this class cannot be created. @@ -44,10 +42,10 @@ struct DALI_CORE_API Event enum Type { - Touch, ///< A touch event, when the user interacts with the screen. - Key, ///< A key pressed event, from the virtual or external keyboard. - Wheel, ///< A wheel event, when the wheel is being rolled from an external mouse. - Hover ///< A hover event, when the user hovers above the screen. + Touch, ///< A touch event, when the user interacts with the screen. + Key, ///< A key pressed event, from the virtual or external keyboard. + Wheel, ///< A wheel event, when the wheel is being rolled from an external mouse. + Hover ///< A hover event, when the user hovers above the screen. }; // Data @@ -58,7 +56,6 @@ struct DALI_CORE_API Event Type type; protected: // Constructors only to be used by derived structures. - /** * This constructor is only used by derived classes. * @param[in] eventType The type of event. diff --git a/dali/integration-api/events/hover-event-integ.cpp b/dali/integration-api/events/hover-event-integ.cpp index 50c62ae..cdbae9a 100644 --- a/dali/integration-api/events/hover-event-integ.cpp +++ b/dali/integration-api/events/hover-event-integ.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -20,17 +20,15 @@ namespace Dali { - namespace Integration { - HoverEvent::HoverEvent() -: MultiPointEvent( Hover ) +: MultiPointEvent(Hover) { } -HoverEvent::HoverEvent( uint32_t time ) -: MultiPointEvent( Hover, time ) +HoverEvent::HoverEvent(uint32_t time) +: MultiPointEvent(Hover, time) { } diff --git a/dali/integration-api/events/hover-event-integ.h b/dali/integration-api/events/hover-event-integ.h index 94f6b28..dacc03d 100644 --- a/dali/integration-api/events/hover-event-integ.h +++ b/dali/integration-api/events/hover-event-integ.h @@ -2,7 +2,7 @@ #define DALI_INTEGRATION_HOVER_EVENT_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -19,15 +19,13 @@ */ // INTERNAL INCLUDES -#include #include +#include namespace Dali { - namespace Integration { - /** * An instance of this structure should be used by the adaptor to send a hover event to Dali core. * diff --git a/dali/integration-api/events/key-event-integ.cpp b/dali/integration-api/events/key-event-integ.cpp old mode 100755 new mode 100644 index 276c6ec..0e09d2a --- a/dali/integration-api/events/key-event-integ.cpp +++ b/dali/integration-api/events/key-event-integ.cpp @@ -23,41 +23,47 @@ namespace Dali { - namespace Integration { - KeyEvent::KeyEvent() -: Event( Key ), +: Event(Key), keyName(), logicalKey(), keyString(), - keyCode( -1 ), - keyModifier( 0 ), - time( 0 ), - state( KeyEvent::DOWN ), - compose( "" ), - deviceName( "" ), - deviceClass( Device::Class::NONE ), - deviceSubclass( Device::Subclass::NONE ) + keyCode(-1), + keyModifier(0), + time(0), + state(KeyEvent::DOWN), + compose(""), + deviceName(""), + deviceClass(Device::Class::NONE), + deviceSubclass(Device::Subclass::NONE) { } -KeyEvent::KeyEvent( const std::string& keyName, const std::string& logicalKey, const std::string& keyString, int keyCode, int keyModifier, - unsigned long timeStamp, const State& keyState, const std::string& compose, const std::string& deviceName, - const Device::Class::Type deviceClass, const Device::Subclass::Type deviceSubclass ) -: Event( Key ), - keyName( keyName ), - logicalKey( logicalKey ), - keyString( keyString ), - keyCode( keyCode ), - keyModifier( keyModifier ), - time( timeStamp ), - state( keyState ), - compose( compose ), - deviceName( deviceName ), - deviceClass( deviceClass ), - deviceSubclass( deviceSubclass ) +KeyEvent::KeyEvent(const std::string& keyName, + const std::string& logicalKey, + const std::string& keyString, + int keyCode, + int keyModifier, + unsigned long timeStamp, + const State& keyState, + const std::string& compose, + const std::string& deviceName, + const Device::Class::Type deviceClass, + const Device::Subclass::Type deviceSubclass) +: Event(Key), + keyName(keyName), + logicalKey(logicalKey), + keyString(keyString), + keyCode(keyCode), + keyModifier(keyModifier), + time(timeStamp), + state(keyState), + compose(compose), + deviceName(deviceName), + deviceClass(deviceClass), + deviceSubclass(deviceSubclass) { } diff --git a/dali/integration-api/events/key-event-integ.h b/dali/integration-api/events/key-event-integ.h old mode 100755 new mode 100644 index 31a8dfd..a990d35 --- a/dali/integration-api/events/key-event-integ.h +++ b/dali/integration-api/events/key-event-integ.h @@ -27,10 +27,8 @@ namespace Dali { - namespace Integration { - /** * An instance of this class should be used by the adaptor to send a key event to * the Dali core. @@ -42,8 +40,8 @@ struct DALI_CORE_API KeyEvent : public Event // Specifies the state of the key event. enum State { - DOWN, /**< Key down */ - UP, /**< Key up */ + DOWN, /**< Key down */ + UP, /**< Key up */ }; /** @@ -65,17 +63,17 @@ struct DALI_CORE_API KeyEvent : public Event * @param[in] deviceClass The class of device KeyEvent originated from * @param[in] deviceSubclass The subclass of device KeyEvent originated from */ - KeyEvent(const std::string& keyName, - const std::string& logicalKey, - const std::string& keyString, - int keyCode, - int keyModifier, - unsigned long timeStamp, - const State& keyState, - const std::string& compose, - const std::string& deviceName, - const Device::Class::Type deviceClass, - const Device::Subclass::Type deviceSubclass ); + KeyEvent(const std::string& keyName, + const std::string& logicalKey, + const std::string& keyString, + int keyCode, + int keyModifier, + unsigned long timeStamp, + const State& keyState, + const std::string& compose, + const std::string& deviceName, + const Device::Class::Type deviceClass, + const Device::Subclass::Type deviceSubclass); /** * Virtual destructor @@ -102,12 +100,12 @@ struct DALI_CORE_API KeyEvent : public Event /** * The unique key code for the key pressed. */ - int keyCode; + int keyCode; /** * The key modifier for special keys like shift and alt */ - int keyModifier; + int keyModifier; /** * The time (in ms) that the key event occurred. diff --git a/dali/integration-api/events/multi-point-event-integ.cpp b/dali/integration-api/events/multi-point-event-integ.cpp index b0f2d6f..f06994f 100644 --- a/dali/integration-api/events/multi-point-event-integ.cpp +++ b/dali/integration-api/events/multi-point-event-integ.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -23,19 +23,17 @@ namespace Dali { - namespace Integration { - -MultiPointEvent::MultiPointEvent( Type eventType ) -: Event( eventType ), - time( 0 ) +MultiPointEvent::MultiPointEvent(Type eventType) +: Event(eventType), + time(0) { } -MultiPointEvent::MultiPointEvent( Type eventType, uint32_t time ) -: Event( eventType ), - time( time ) +MultiPointEvent::MultiPointEvent(Type eventType, uint32_t time) +: Event(eventType), + time(time) { } @@ -43,18 +41,18 @@ MultiPointEvent::~MultiPointEvent() { } -void MultiPointEvent::AddPoint( const Point& point ) +void MultiPointEvent::AddPoint(const Point& point) { points.push_back(point); } -Point& MultiPointEvent::GetPoint( uint32_t point ) +Point& MultiPointEvent::GetPoint(uint32_t point) { DALI_ASSERT_ALWAYS(point < points.size() && "MultiPointEvent: Point index out of bounds"); return points[point]; } -const Point& MultiPointEvent::GetPoint( uint32_t point ) const +const Point& MultiPointEvent::GetPoint(uint32_t point) const { DALI_ASSERT_ALWAYS(point < points.size() && "MultiPointEvent: Point index out of bounds"); return points[point]; @@ -62,7 +60,7 @@ const Point& MultiPointEvent::GetPoint( uint32_t point ) const uint32_t MultiPointEvent::GetPointCount() const { - return static_cast( points.size() ); // not going to overflow in practice + return static_cast(points.size()); // not going to overflow in practice } } // namespace Integration diff --git a/dali/integration-api/events/multi-point-event-integ.h b/dali/integration-api/events/multi-point-event-integ.h index 84d7799..69fcfce 100644 --- a/dali/integration-api/events/multi-point-event-integ.h +++ b/dali/integration-api/events/multi-point-event-integ.h @@ -2,7 +2,7 @@ #define DALI_INTEGRATION_MULTI_POINT_EVENT_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -19,13 +19,12 @@ */ // INTERNAL INCLUDES -#include #include #include +#include namespace Dali { - namespace Integration { using PointContainer = std::vector; ///< Container of points @@ -61,7 +60,6 @@ protected: MultiPointEvent(Type eventType, uint32_t time); public: - // Data /** @@ -80,19 +78,19 @@ public: * @brief Adds a point to the MultiPointEvent. * @param[in] point The point to add. */ - void AddPoint( const Point& point ); + void AddPoint(const Point& point); /** * @brief Retrieves the Point at position point. * @return The Point at position point. */ - Point& GetPoint( uint32_t point ); + Point& GetPoint(uint32_t point); /** * @brief Retrieves a const ref of the Point at position point. * @return The const ref of the Point at position point. */ - const Point& GetPoint( uint32_t point ) const; + const Point& GetPoint(uint32_t point) const; /** * @brief The total number of Points in this TouchEvent. diff --git a/dali/integration-api/events/point.cpp b/dali/integration-api/events/point.cpp old mode 100755 new mode 100644 index ee61baf..6ce4e16 --- a/dali/integration-api/events/point.cpp +++ b/dali/integration-api/events/point.cpp @@ -21,31 +21,29 @@ namespace Dali { - namespace Integration { - Point::Point() -: mTouchPoint( 0, PointState::STARTED, 0.0f, 0.0f ), +: mTouchPoint(0, PointState::STARTED, 0.0f, 0.0f), mEllipseRadius(), - mAngle( 0.0f ), - mDeviceClass( Device::Class::NONE ), - mDeviceSubclass( Device::Subclass::NONE ), - mPressure( 1.0f ), - mRadius( 0.0f ), - mMouseButton( MouseButton::INVALID ) + mAngle(0.0f), + mDeviceClass(Device::Class::NONE), + mDeviceSubclass(Device::Subclass::NONE), + mPressure(1.0f), + mRadius(0.0f), + mMouseButton(MouseButton::INVALID) { } -Point::Point( const TouchPoint& touchPoint ) -: mTouchPoint( touchPoint ), +Point::Point(const TouchPoint& touchPoint) +: mTouchPoint(touchPoint), mEllipseRadius(), - mAngle( 0.0f ), - mDeviceClass( Device::Class::NONE ), - mDeviceSubclass( Device::Subclass::NONE ), - mPressure( 1.0f ), - mRadius( 0.0f ), - mMouseButton( MouseButton::INVALID ) + mAngle(0.0f), + mDeviceClass(Device::Class::NONE), + mDeviceSubclass(Device::Subclass::NONE), + mPressure(1.0f), + mRadius(0.0f), + mMouseButton(MouseButton::INVALID) { } @@ -53,38 +51,38 @@ Point::~Point() { } -void Point::SetDeviceId( int32_t deviceId ) +void Point::SetDeviceId(int32_t deviceId) { mTouchPoint.deviceId = deviceId; } -void Point::SetState( PointState::Type state ) +void Point::SetState(PointState::Type state) { - mTouchPoint.state = static_cast< PointState::Type >( state ); + mTouchPoint.state = static_cast(state); } -void Point::SetScreenPosition( const Vector2& screenPosition ) +void Point::SetScreenPosition(const Vector2& screenPosition) { mTouchPoint.screen = screenPosition; } -void Point::SetRadius( float radius ) +void Point::SetRadius(float radius) { mRadius = mEllipseRadius.x = mEllipseRadius.y = radius; } -void Point::SetRadius( float radius, Vector2 ellipseRadius ) +void Point::SetRadius(float radius, Vector2 ellipseRadius) { - mRadius = radius; + mRadius = radius; mEllipseRadius = ellipseRadius; } -void Point::SetPressure( float pressure ) +void Point::SetPressure(float pressure) { mPressure = pressure; } -void Point::SetAngle( Degree angle ) +void Point::SetAngle(Degree angle) { mAngle = angle; } @@ -96,7 +94,7 @@ int Point::GetDeviceId() const PointState::Type Point::GetState() const { - return static_cast< PointState::Type >( mTouchPoint.state ); + return static_cast(mTouchPoint.state); } const Vector2& Point::GetScreenPosition() const @@ -124,12 +122,12 @@ Degree Point::GetAngle() const return mAngle; } -void Point::SetHitActor( Actor hitActor ) +void Point::SetHitActor(Actor hitActor) { mTouchPoint.hitActor = hitActor; } -void Point::SetLocalPosition( const Vector2& localPosition ) +void Point::SetLocalPosition(const Vector2& localPosition) { mTouchPoint.local = localPosition; } @@ -149,12 +147,12 @@ const TouchPoint& Point::GetTouchPoint() const return mTouchPoint; } -void Point::SetDeviceClass( Device::Class::Type deviceClass ) +void Point::SetDeviceClass(Device::Class::Type deviceClass) { mDeviceClass = deviceClass; } -void Point::SetDeviceSubclass( Device::Subclass::Type deviceSubclass ) +void Point::SetDeviceSubclass(Device::Subclass::Type deviceSubclass) { mDeviceSubclass = deviceSubclass; } @@ -179,7 +177,6 @@ void Point::SetMouseButton(MouseButton::Type button) mMouseButton = button; } - } // namespace Integration } // namespace Dali diff --git a/dali/integration-api/events/point.h b/dali/integration-api/events/point.h old mode 100755 new mode 100644 index f1e9112..315a7b1 --- a/dali/integration-api/events/point.h +++ b/dali/integration-api/events/point.h @@ -19,19 +19,17 @@ */ // INTERNAL INCLUDES -#include -#include -#include #include #include #include +#include +#include +#include namespace Dali { - namespace Integration { - /** * @brief A Point represents a point on the screen that is currently being touched or where touch has stopped. */ @@ -46,7 +44,7 @@ struct DALI_CORE_API Point * @brief Constructor which creates a Point instance from a TouchPoint. * @param[in] touchPoint The touch-point to copy from. */ - explicit Point( const TouchPoint& touchPoint ); + explicit Point(const TouchPoint& touchPoint); /** * @brief Destructor @@ -60,19 +58,19 @@ struct DALI_CORE_API Point * * @param[in] deviceId The Unique Device ID. */ - void SetDeviceId( int32_t deviceId ); + void SetDeviceId(int32_t deviceId); /** * @brief Set the state of the point. * @param[in] state The state of the point. */ - void SetState( PointState::Type state ); + void SetState(PointState::Type state); /** * @brief Set the screen position of the point from the top-left of the screen. * @param[in] screenPosition The screen position of the point from the top-left of the screen. */ - void SetScreenPosition( const Vector2& screenPosition ); + void SetScreenPosition(const Vector2& screenPosition); /** * @brief Set the radius of the press point. @@ -80,14 +78,14 @@ struct DALI_CORE_API Point * This is the average of both the horizontal and vertical radii of the press point. * @param[in] radius The average of both the horizontal and vertical radii. */ - void SetRadius( float radius ); + void SetRadius(float radius); /** * @brief Set the radius of the press point as an ellipse. * @param[in] radius The average of both the horizontal and vertical radii. * @param[in] ellipseRadius The horizontal and vertical radii of the press point (different if an ellipse). */ - void SetRadius( float radius, Vector2 ellipseRadius ); + void SetRadius(float radius, Vector2 ellipseRadius); /** * @brief Sets the touch pressure. @@ -99,25 +97,25 @@ struct DALI_CORE_API Point * * @param[in] pressure The touch pressure. */ - void SetPressure( float pressure ); + void SetPressure(float pressure); /** * @brief Sets the angle of the press point relative to the Y-Axis. * @param[in] angle The angle of the press point relative to the Y-Axis. */ - void SetAngle( Degree angle ); + void SetAngle(Degree angle); /** * @brief Sets the class of the device for the event * @param[in] deviceClass The class of the device. */ - void SetDeviceClass( Device::Class::Type deviceClass ); + void SetDeviceClass(Device::Class::Type deviceClass); /** * @brief Sets the subclass of the device for the event * @param[in] deviceSubclass The subclass of the device. */ - void SetDeviceSubclass( Device::Subclass::Type deviceSubclass ); + void SetDeviceSubclass(Device::Subclass::Type deviceSubclass); /** * @brief Retrieve the Unique Device ID of the point. @@ -190,21 +188,19 @@ struct DALI_CORE_API Point */ void SetMouseButton(MouseButton::Type button); - public: // Not intended for Integration API developers - /** * @brief Sets the hit actor under this point. * @param[in] hitActor The hit actor. */ - DALI_INTERNAL void SetHitActor( Actor hitActor ); + DALI_INTERNAL void SetHitActor(Actor hitActor); /** * @brief Set the co-ordinates relative to the top-left of the hit-actor. * @param[in] localPosition The local position. * @note The top-left of an actor is (0.0, 0.0, 0.5). */ - DALI_INTERNAL void SetLocalPosition( const Vector2& localPosition ); + DALI_INTERNAL void SetLocalPosition(const Vector2& localPosition); /** * @brief Retrieve the Hit Actor. @@ -226,15 +222,14 @@ public: // Not intended for Integration API developers DALI_INTERNAL const TouchPoint& GetTouchPoint() const; private: - - TouchPoint mTouchPoint; ///< Stores screen position, device Id, local & screen positions and the hit-actor. @see TouchPoint - Vector2 mEllipseRadius; ///< Radius of both the horizontal and vertical radius (useful if an ellipse). - Degree mAngle; ///< The angle of the press point, relative to the Y-Axis. - Device::Class::Type mDeviceClass; + TouchPoint mTouchPoint; ///< Stores screen position, device Id, local & screen positions and the hit-actor. @see TouchPoint + Vector2 mEllipseRadius; ///< Radius of both the horizontal and vertical radius (useful if an ellipse). + Degree mAngle; ///< The angle of the press point, relative to the Y-Axis. + Device::Class::Type mDeviceClass; Device::Subclass::Type mDeviceSubclass; - float mPressure; ///< The touch pressure. - float mRadius; ///< Radius of the press point, an average of the ellipse radius. - MouseButton::Type mMouseButton; /// < mouse button value. + float mPressure; ///< The touch pressure. + float mRadius; ///< Radius of the press point, an average of the ellipse radius. + MouseButton::Type mMouseButton; /// < mouse button value. }; } // namespace Integration diff --git a/dali/integration-api/events/touch-event-combiner.cpp b/dali/integration-api/events/touch-event-combiner.cpp index d73291b..b38510b 100644 --- a/dali/integration-api/events/touch-event-combiner.cpp +++ b/dali/integration-api/events/touch-event-combiner.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -23,20 +23,18 @@ #include // abs // INTERNAL INCLUDES -#include #include +#include #include namespace Dali { - namespace Integration { - namespace { -const unsigned long DEFAULT_MINIMUM_MOTION_TIME( 1u ); -const Vector2 DEFAULT_MINIMUM_MOTION_DISTANCE( 1.0f, 1.0f ); +const unsigned long DEFAULT_MINIMUM_MOTION_TIME(1u); +const Vector2 DEFAULT_MINIMUM_MOTION_DISTANCE(1.0f, 1.0f); } // unnamed namespace struct TouchEventCombiner::PointInfo @@ -48,61 +46,61 @@ struct TouchEventCombiner::PointInfo * @param[in] touchPoint The point to add. * @param[in] pointTime The time of the point event. */ - PointInfo( const Point& touchPoint, uint32_t pointTime ) - : point( touchPoint ), - time( pointTime ) + PointInfo(const Point& touchPoint, uint32_t pointTime) + : point(touchPoint), + time(pointTime) { } // Data - Point point; ///< The point. - uint32_t time; ///< The time the point event took place. + Point point; ///< The point. + uint32_t time; ///< The time the point event took place. }; TouchEventCombiner::TouchEventCombiner() -: mMinMotionTime( DEFAULT_MINIMUM_MOTION_TIME ), - mMinMotionDistance( DEFAULT_MINIMUM_MOTION_DISTANCE ) +: mMinMotionTime(DEFAULT_MINIMUM_MOTION_TIME), + mMinMotionDistance(DEFAULT_MINIMUM_MOTION_DISTANCE) { } -TouchEventCombiner::TouchEventCombiner( uint32_t minMotionTime, float minMotionXDistance, float minMotionYDistance ) -: mMinMotionTime( minMotionTime ), - mMinMotionDistance( minMotionXDistance, minMotionYDistance ) +TouchEventCombiner::TouchEventCombiner(uint32_t minMotionTime, float minMotionXDistance, float minMotionYDistance) +: mMinMotionTime(minMotionTime), + mMinMotionDistance(minMotionXDistance, minMotionYDistance) { - DALI_ASSERT_ALWAYS( minMotionXDistance >= 0.0f && minMotionYDistance >= 0.0f && "Negative values not allowed\n" ); + DALI_ASSERT_ALWAYS(minMotionXDistance >= 0.0f && minMotionYDistance >= 0.0f && "Negative values not allowed\n"); } -TouchEventCombiner::TouchEventCombiner( uint32_t minMotionTime, Vector2 minMotionDistance ) -: mMinMotionTime( minMotionTime ), - mMinMotionDistance( minMotionDistance ) +TouchEventCombiner::TouchEventCombiner(uint32_t minMotionTime, Vector2 minMotionDistance) +: mMinMotionTime(minMotionTime), + mMinMotionDistance(minMotionDistance) { - DALI_ASSERT_ALWAYS( minMotionDistance.x >= 0.0f && minMotionDistance.y >= 0.0f && "Negative values not allowed\n" ); + DALI_ASSERT_ALWAYS(minMotionDistance.x >= 0.0f && minMotionDistance.y >= 0.0f && "Negative values not allowed\n"); } TouchEventCombiner::~TouchEventCombiner() { } -TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( const Point& point, uint32_t time, TouchEvent& touchEvent, HoverEvent& hoverEvent ) +TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent(const Point& point, uint32_t time, TouchEvent& touchEvent, HoverEvent& hoverEvent) { - TouchEventCombiner::EventDispatchType dispatchEvent( TouchEventCombiner::DISPATCH_NONE ); - const PointState::Type state = point.GetState(); - const int deviceId = point.GetDeviceId(); + TouchEventCombiner::EventDispatchType dispatchEvent(TouchEventCombiner::DISPATCH_NONE); + const PointState::Type state = point.GetState(); + const int deviceId = point.GetDeviceId(); - switch ( state ) + switch(state) { case PointState::STARTED: { touchEvent.time = time; - bool addToContainer( true ); + bool addToContainer(true); // Iterate through already stored touch points and add to TouchEvent - for ( PointInfoContainer::iterator iter = mPressedPoints.begin(), endIter = mPressedPoints.end(); iter != endIter; ++iter ) + for(PointInfoContainer::iterator iter = mPressedPoints.begin(), endIter = mPressedPoints.end(); iter != endIter; ++iter) { - if ( iter->point.GetDeviceId() != deviceId ) + if(iter->point.GetDeviceId() != deviceId) { - iter->point.SetState( PointState::STATIONARY ); + iter->point.SetState(PointState::STATIONARY); } else { @@ -110,44 +108,44 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( con // We do not want to emit another down event for this Point Device ID. addToContainer = false; - iter->point = point; - iter->time = time; + iter->point = point; + iter->time = time; } - touchEvent.AddPoint( iter->point ); + touchEvent.AddPoint(iter->point); } // Add new touch point to the list and to the TouchEvent - if (addToContainer) + if(addToContainer) { - mPressedPoints.push_back( PointInfo( point, time ) ); - touchEvent.AddPoint( point ); + mPressedPoints.push_back(PointInfo(point, time)); + touchEvent.AddPoint(point); dispatchEvent = TouchEventCombiner::DISPATCH_TOUCH; // Only dispatch touch event if just added to container // Check whether hover event was dispatched previously - if ( !mHoveredPoints.empty() ) + if(!mHoveredPoints.empty()) { hoverEvent.time = time; - PointInfoContainer::iterator match( mHoveredPoints.end() ); - for ( PointInfoContainer::iterator iter = mHoveredPoints.begin(), endIter = mHoveredPoints.end(); iter != endIter; ++iter ) + PointInfoContainer::iterator match(mHoveredPoints.end()); + for(PointInfoContainer::iterator iter = mHoveredPoints.begin(), endIter = mHoveredPoints.end(); iter != endIter; ++iter) { - if ( deviceId == iter->point.GetDeviceId() ) + if(deviceId == iter->point.GetDeviceId()) { match = iter; // Add new point to the HoverEvent - iter->point.SetState( PointState::FINISHED ); - hoverEvent.AddPoint( iter->point ); + iter->point.SetState(PointState::FINISHED); + hoverEvent.AddPoint(iter->point); } else { - iter->point.SetState( PointState::STATIONARY ); - hoverEvent.AddPoint( iter->point ); + iter->point.SetState(PointState::STATIONARY); + hoverEvent.AddPoint(iter->point); } } - if ( match != mHoveredPoints.end() ) + if(match != mHoveredPoints.end()) { - mHoveredPoints.erase( match ); + mHoveredPoints.erase(match); dispatchEvent = TouchEventCombiner::DISPATCH_BOTH; // We should only dispatch hover events if the point was actually hovered in this window } } @@ -161,34 +159,34 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( con touchEvent.time = time; // Find pressed touch point in local list (while also adding the stored points to the touchEvent) - PointInfoContainer::iterator match( mPressedPoints.end() ); - for ( PointInfoContainer::iterator iter = mPressedPoints.begin(), endIter = mPressedPoints.end(); iter != endIter; ++iter ) + PointInfoContainer::iterator match(mPressedPoints.end()); + for(PointInfoContainer::iterator iter = mPressedPoints.begin(), endIter = mPressedPoints.end(); iter != endIter; ++iter) { - if ( deviceId == iter->point.GetDeviceId() ) + if(deviceId == iter->point.GetDeviceId()) { match = iter; // Add new point to the TouchEvent - touchEvent.AddPoint( point ); + touchEvent.AddPoint(point); } else { - iter->point.SetState( PointState::STATIONARY ); - touchEvent.AddPoint( iter->point ); + iter->point.SetState(PointState::STATIONARY); + touchEvent.AddPoint(iter->point); } } - if ( match != mPressedPoints.end() ) + if(match != mPressedPoints.end()) { - mPressedPoints.erase( match ); + mPressedPoints.erase(match); dispatchEvent = TouchEventCombiner::DISPATCH_TOUCH; // We should only dispatch touch events if the point was actually pressed in this window // Iterate through already stored touch points for HoverEvent and delete them - for ( PointInfoContainer::iterator iter = mHoveredPoints.begin(), endIter = mHoveredPoints.end(); iter != endIter; ++iter ) + for(PointInfoContainer::iterator iter = mHoveredPoints.begin(), endIter = mHoveredPoints.end(); iter != endIter; ++iter) { - if ( iter->point.GetDeviceId() == deviceId ) + if(iter->point.GetDeviceId() == deviceId) { - iter = mHoveredPoints.erase( iter ); + iter = mHoveredPoints.erase(iter); } } } @@ -199,20 +197,20 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( con { bool fromNewDeviceId = false; - if ( !mPressedPoints.empty() ) + if(!mPressedPoints.empty()) { touchEvent.time = time; - bool ignore = false; - PointInfoContainer::iterator match = mPressedPoints.end(); - const Vector2& pointScreenPosition = point.GetScreenPosition(); - for ( PointInfoContainer::iterator iter = mPressedPoints.begin(), endIter = mPressedPoints.end(); iter != endIter; ++iter ) + bool ignore = false; + PointInfoContainer::iterator match = mPressedPoints.end(); + const Vector2& pointScreenPosition = point.GetScreenPosition(); + for(PointInfoContainer::iterator iter = mPressedPoints.begin(), endIter = mPressedPoints.end(); iter != endIter; ++iter) { - if ( deviceId == iter->point.GetDeviceId() ) + if(deviceId == iter->point.GetDeviceId()) { - uint32_t timeDiff( time - iter->time ); + uint32_t timeDiff(time - iter->time); - if ( timeDiff < mMinMotionTime ) + if(timeDiff < mMinMotionTime) { // Motion event sent too soon after previous event so ignore ignore = true; @@ -220,8 +218,8 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( con } const Vector2& currentScreenPosition = iter->point.GetScreenPosition(); - if ( ( std::abs( pointScreenPosition.x - currentScreenPosition.x ) < mMinMotionDistance.x ) && - ( std::abs( pointScreenPosition.y - currentScreenPosition.y ) < mMinMotionDistance.y ) ) + if((std::abs(pointScreenPosition.x - currentScreenPosition.x) < mMinMotionDistance.x) && + (std::abs(pointScreenPosition.y - currentScreenPosition.y) < mMinMotionDistance.y)) { // Not enough positional change from last event so ignore ignore = true; @@ -231,19 +229,19 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( con match = iter; // Add new touch point to the TouchEvent - touchEvent.AddPoint( point ); + touchEvent.AddPoint(point); } else { - iter->point.SetState( PointState::STATIONARY ); - touchEvent.AddPoint( iter->point ); + iter->point.SetState(PointState::STATIONARY); + touchEvent.AddPoint(iter->point); } } - if ( match != mPressedPoints.end() ) + if(match != mPressedPoints.end()) { - PointInfo matchedPoint( point, time ); - std::swap( *match, matchedPoint ); + PointInfo matchedPoint(point, time); + std::swap(*match, matchedPoint); dispatchEvent = TouchEventCombiner::DISPATCH_TOUCH; // Dispatch touch event } @@ -259,16 +257,16 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( con hoverEvent.time = time; // Iterate through already stored touch points and add to HoverEvent - bool ignore = false; - PointInfoContainer::iterator match = mHoveredPoints.end(); - const Vector2& pointScreenPosition = point.GetScreenPosition(); - for ( PointInfoContainer::iterator iter = mHoveredPoints.begin(), endIter = mHoveredPoints.end(); iter != endIter; ++iter ) + bool ignore = false; + PointInfoContainer::iterator match = mHoveredPoints.end(); + const Vector2& pointScreenPosition = point.GetScreenPosition(); + for(PointInfoContainer::iterator iter = mHoveredPoints.begin(), endIter = mHoveredPoints.end(); iter != endIter; ++iter) { - if ( iter->point.GetDeviceId() == deviceId ) + if(iter->point.GetDeviceId() == deviceId) { - uint32_t timeDiff( time - iter->time ); + uint32_t timeDiff(time - iter->time); - if ( timeDiff < mMinMotionTime ) + if(timeDiff < mMinMotionTime) { // Motion event sent too soon after previous event so ignore ignore = true; @@ -276,8 +274,8 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( con } const Vector2& currentScreenPosition = iter->point.GetScreenPosition(); - if ( ( std::abs( pointScreenPosition.x - currentScreenPosition.x ) < mMinMotionDistance.x ) && - ( std::abs( pointScreenPosition.y - currentScreenPosition.y ) < mMinMotionDistance.y ) ) + if((std::abs(pointScreenPosition.x - currentScreenPosition.x) < mMinMotionDistance.x) && + (std::abs(pointScreenPosition.y - currentScreenPosition.y) < mMinMotionDistance.y)) { // Not enough positional change from last event so ignore ignore = true; @@ -287,29 +285,29 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( con match = iter; // Add new touch point to the HoverEvent - hoverEvent.AddPoint( point ); + hoverEvent.AddPoint(point); } else { - iter->point.SetState( PointState::STATIONARY ); - hoverEvent.AddPoint( iter->point ); + iter->point.SetState(PointState::STATIONARY); + hoverEvent.AddPoint(iter->point); } } // Add new hover point to the list and to the HoverEvent - if ( !ignore ) // Only dispatch hover event when it should not be ignored + if(!ignore) // Only dispatch hover event when it should not be ignored { - if( match == mHoveredPoints.end() ) + if(match == mHoveredPoints.end()) { Point hoverPoint(point); - hoverPoint.SetState( PointState::STARTED ); // The first hover event received - mHoveredPoints.push_back( PointInfo( hoverPoint, time ) ); - hoverEvent.AddPoint( hoverPoint ); + hoverPoint.SetState(PointState::STARTED); // The first hover event received + mHoveredPoints.push_back(PointInfo(hoverPoint, time)); + hoverEvent.AddPoint(hoverPoint); } else { - PointInfo matchedPoint( point, time ); - std::swap( *match, matchedPoint ); + PointInfo matchedPoint(point, time); + std::swap(*match, matchedPoint); } if(dispatchEvent == TouchEventCombiner::DISPATCH_TOUCH) @@ -330,8 +328,8 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( con Reset(); // We should still tell core about the interruption. - touchEvent.AddPoint( point ); - hoverEvent.AddPoint( point ); + touchEvent.AddPoint(point); + hoverEvent.AddPoint(point); dispatchEvent = TouchEventCombiner::DISPATCH_BOTH; break; } @@ -343,29 +341,29 @@ TouchEventCombiner::EventDispatchType TouchEventCombiner::GetNextTouchEvent( con return dispatchEvent; } -void TouchEventCombiner::SetMinimumMotionTimeThreshold( uint32_t minTime ) +void TouchEventCombiner::SetMinimumMotionTimeThreshold(uint32_t minTime) { mMinMotionTime = minTime; } -void TouchEventCombiner::SetMinimumMotionDistanceThreshold( float minDistance ) +void TouchEventCombiner::SetMinimumMotionDistanceThreshold(float minDistance) { - DALI_ASSERT_ALWAYS( minDistance >= 0.0f && "Negative values not allowed\n" ); + DALI_ASSERT_ALWAYS(minDistance >= 0.0f && "Negative values not allowed\n"); mMinMotionDistance.x = mMinMotionDistance.y = minDistance; } -void TouchEventCombiner::SetMinimumMotionDistanceThreshold( float minXDistance, float minYDistance ) +void TouchEventCombiner::SetMinimumMotionDistanceThreshold(float minXDistance, float minYDistance) { - DALI_ASSERT_ALWAYS( minXDistance >= 0.0f && minYDistance >= 0.0f && "Negative values not allowed\n" ); + DALI_ASSERT_ALWAYS(minXDistance >= 0.0f && minYDistance >= 0.0f && "Negative values not allowed\n"); mMinMotionDistance.x = minXDistance; mMinMotionDistance.y = minYDistance; } -void TouchEventCombiner::SetMinimumMotionDistanceThreshold( Vector2 minDistance ) +void TouchEventCombiner::SetMinimumMotionDistanceThreshold(Vector2 minDistance) { - DALI_ASSERT_ALWAYS( minDistance.x >= 0.0f && minDistance.y >= 0.0f && "Negative values not allowed\n" ); + DALI_ASSERT_ALWAYS(minDistance.x >= 0.0f && minDistance.y >= 0.0f && "Negative values not allowed\n"); mMinMotionDistance = minDistance; } diff --git a/dali/integration-api/events/touch-event-combiner.h b/dali/integration-api/events/touch-event-combiner.h index 6ed9402..95a49fb 100644 --- a/dali/integration-api/events/touch-event-combiner.h +++ b/dali/integration-api/events/touch-event-combiner.h @@ -2,7 +2,7 @@ #define DALI_INTEGRATION_TOUCH_EVENT_COMBINER_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -19,16 +19,14 @@ */ // INTERNAL INCLUDES +#include #include #include -#include namespace Dali { - namespace Integration { - struct TouchEvent; struct HoverEvent; @@ -49,15 +47,14 @@ struct HoverEvent; class DALI_CORE_API TouchEventCombiner { public: - // Enumerations enum EventDispatchType { - DISPATCH_TOUCH, ///< The touch event should be dispatched. - DISPATCH_HOVER, ///< The hover event should be dispatched. - DISPATCH_BOTH, ///< Both touch event and hover event should be dispatched. - DISPATCH_NONE ///< Neither touch event nor hover event should be dispatched. + DISPATCH_TOUCH, ///< The touch event should be dispatched. + DISPATCH_HOVER, ///< The hover event should be dispatched. + DISPATCH_BOTH, ///< Both touch event and hover event should be dispatched. + DISPATCH_NONE ///< Neither touch event nor hover event should be dispatched. }; /** @@ -74,7 +71,7 @@ public: * @param[in] minMotionYDistance The minimum distance a finger has to be moved between vertical motion events. * @note Will assert if any of the parameters is negative. */ - TouchEventCombiner( uint32_t minMotionTime, float minMotionXDistance, float minMotionYDistance ); + TouchEventCombiner(uint32_t minMotionTime, float minMotionXDistance, float minMotionYDistance); /** * Construction with parameters. @@ -82,7 +79,7 @@ public: * @param[in] minMotionDistance A Vector2 representing the minimum distance a finger has to be moved between horizontal and vertical motion events. * @note Will assert if any of the parameters is negative. */ - TouchEventCombiner( uint32_t minMotionTime, Vector2 minMotionDistance ); + TouchEventCombiner(uint32_t minMotionTime, Vector2 minMotionDistance); /** * Non virtual destructor @@ -90,7 +87,6 @@ public: ~TouchEventCombiner(); public: - /** * Allows the caller to pass in a point which is processed and the TouchEvent and/or HoverEvent is appropriately filled with the new, * and previously stored Point information. @@ -105,20 +101,20 @@ public: * * @return true if the point is beyond the different thresholds set thus, should be sent to core, false otherwise. */ - EventDispatchType GetNextTouchEvent( const Point& point, uint32_t time, TouchEvent& touchEvent, HoverEvent& hoverEvent ); + EventDispatchType GetNextTouchEvent(const Point& point, uint32_t time, TouchEvent& touchEvent, HoverEvent& hoverEvent); /** * Sets the minimum time (in ms) that should occur between motion events. * @param[in] minTime Minimum time between motion events. */ - void SetMinimumMotionTimeThreshold( uint32_t minTime ); + void SetMinimumMotionTimeThreshold(uint32_t minTime); /** * Sets the minimum distance a finger has to be moved (both X and Y) between motion events. * @param[in] minDistance The minimum distance between motion events. * @note Will assert if parameter is negative. */ - void SetMinimumMotionDistanceThreshold( float minDistance ); + void SetMinimumMotionDistanceThreshold(float minDistance); /** * Sets the minimum distance a finger has to be moved between motion events. @@ -127,7 +123,7 @@ public: * @note Use this method if the X and Y threshold required is different. * @note Will assert if any of the parameters is negative. */ - void SetMinimumMotionDistanceThreshold( float minXDistance, float minYDistance ); + void SetMinimumMotionDistanceThreshold(float minXDistance, float minYDistance); /** * Sets the minimum distance a finger has to be moved between motion events. @@ -135,7 +131,7 @@ public: * @note Use this method if the X and Y threshold required is different. * @note Will assert if any of the parameters is negative. */ - void SetMinimumMotionDistanceThreshold( Vector2 minDistance ); + void SetMinimumMotionDistanceThreshold(Vector2 minDistance); /** * Retrieves the minimum motion time threshold. @@ -157,14 +153,13 @@ public: void Reset(); private: - struct PointInfo; - typedef std::vector< PointInfo > PointInfoContainer; - PointInfoContainer mPressedPoints; ///< A container of touched point and time. - PointInfoContainer mHoveredPoints; ///< A container of hovered point and time. + typedef std::vector PointInfoContainer; + PointInfoContainer mPressedPoints; ///< A container of touched point and time. + PointInfoContainer mHoveredPoints; ///< A container of hovered point and time. - uint32_t mMinMotionTime; ///< The minimum time that should elapse before considering a new motion event. - Vector2 mMinMotionDistance; ///< The minimum distance in the X and Y direction before considering a new motion event. + uint32_t mMinMotionTime; ///< The minimum time that should elapse before considering a new motion event. + Vector2 mMinMotionDistance; ///< The minimum distance in the X and Y direction before considering a new motion event. }; } // namespace Integration diff --git a/dali/integration-api/events/touch-event-integ.cpp b/dali/integration-api/events/touch-event-integ.cpp index a660660..ea2e516 100644 --- a/dali/integration-api/events/touch-event-integ.cpp +++ b/dali/integration-api/events/touch-event-integ.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -20,17 +20,15 @@ namespace Dali { - namespace Integration { - TouchEvent::TouchEvent() -: MultiPointEvent( Touch ) +: MultiPointEvent(Touch) { } -TouchEvent::TouchEvent( uint32_t time ) -: MultiPointEvent( Touch, time ) +TouchEvent::TouchEvent(uint32_t time) +: MultiPointEvent(Touch, time) { } diff --git a/dali/integration-api/events/touch-event-integ.h b/dali/integration-api/events/touch-event-integ.h index 1dc354e..d31000e 100644 --- a/dali/integration-api/events/touch-event-integ.h +++ b/dali/integration-api/events/touch-event-integ.h @@ -23,10 +23,8 @@ namespace Dali { - namespace Integration { - /** * An instance of this structure should be used by the adaptor to send a touch event to Dali core. * diff --git a/dali/integration-api/events/touch-integ.cpp b/dali/integration-api/events/touch-integ.cpp index a5e4e3e..efab5f3 100644 --- a/dali/integration-api/events/touch-integ.cpp +++ b/dali/integration-api/events/touch-integ.cpp @@ -21,17 +21,16 @@ namespace Dali { namespace Integration { - Dali::TouchEvent NewTouchEvent(uint32_t timeStamp, const TouchPoint& point) { - return NewTouchEvent( timeStamp, Integration::Point( point ) ); + return NewTouchEvent(timeStamp, Integration::Point(point)); } -Dali::TouchEvent NewTouchEvent( uint32_t timeStamp, const Dali::Integration::Point& point ) +Dali::TouchEvent NewTouchEvent(uint32_t timeStamp, const Dali::Integration::Point& point) { - Internal::TouchEventPtr touchEventImpl( new Internal::TouchEvent( timeStamp ) ); - touchEventImpl->AddPoint( point ); - Dali::TouchEvent handle( touchEventImpl.Get() ); + Internal::TouchEventPtr touchEventImpl(new Internal::TouchEvent(timeStamp)); + touchEventImpl->AddPoint(point); + Dali::TouchEvent handle(touchEventImpl.Get()); return handle; } diff --git a/dali/integration-api/events/touch-integ.h b/dali/integration-api/events/touch-integ.h index ae96fe9..6552fb9 100644 --- a/dali/integration-api/events/touch-integ.h +++ b/dali/integration-api/events/touch-integ.h @@ -18,17 +18,15 @@ */ // INTERNAL INCLUDES -#include -#include #include #include +#include +#include namespace Dali { - namespace Integration { - /** * Create a new touch data handle from timestamp and touch point. * @@ -45,7 +43,7 @@ DALI_CORE_API Dali::TouchEvent NewTouchEvent(uint32_t timeStamp, const TouchPoin * @param[in] point The point on screen where the touch occurred. * @return A new touch data handle. */ -DALI_CORE_API Dali::TouchEvent NewTouchEvent( uint32_t timeStamp, const Dali::Integration::Point& point ); +DALI_CORE_API Dali::TouchEvent NewTouchEvent(uint32_t timeStamp, const Dali::Integration::Point& point); } // namespace Integration diff --git a/dali/integration-api/events/wheel-event-integ.cpp b/dali/integration-api/events/wheel-event-integ.cpp index cf0d7ab..efb3132 100644 --- a/dali/integration-api/events/wheel-event-integ.cpp +++ b/dali/integration-api/events/wheel-event-integ.cpp @@ -20,29 +20,27 @@ namespace Dali { - namespace Integration { - WheelEvent::WheelEvent() -: Event( Wheel ), - type( MOUSE_WHEEL ), - direction( 0 ), - modifiers( 0 ), - point( Vector2::ZERO ), - delta( 0 ), - timeStamp( 0 ) +: Event(Wheel), + type(MOUSE_WHEEL), + direction(0), + modifiers(0), + point(Vector2::ZERO), + delta(0), + timeStamp(0) { } -WheelEvent::WheelEvent( Type type, int direction, unsigned int modifiers, Vector2 point, int delta, unsigned int timeStamp ) -: Event( Wheel ), - type( type ), - direction( direction ), - modifiers( modifiers ), - point( point ), - delta( delta ), - timeStamp( timeStamp ) +WheelEvent::WheelEvent(Type type, int direction, unsigned int modifiers, Vector2 point, int delta, unsigned int timeStamp) +: Event(Wheel), + type(type), + direction(direction), + modifiers(modifiers), + point(point), + delta(delta), + timeStamp(timeStamp) { } diff --git a/dali/integration-api/events/wheel-event-integ.h b/dali/integration-api/events/wheel-event-integ.h index a5758b6..aa66080 100644 --- a/dali/integration-api/events/wheel-event-integ.h +++ b/dali/integration-api/events/wheel-event-integ.h @@ -27,10 +27,8 @@ namespace Dali { - namespace Integration { - /** * An instance of this class should be used by the adaptor to send a wheel event to * the Dali core. @@ -45,8 +43,8 @@ struct DALI_CORE_API WheelEvent : public Event */ enum Type { - MOUSE_WHEEL, ///< Mouse wheel event - CUSTOM_WHEEL ///< Custom wheel event + MOUSE_WHEEL, ///< Mouse wheel event + CUSTOM_WHEEL ///< Custom wheel event }; /** @@ -63,7 +61,7 @@ struct DALI_CORE_API WheelEvent : public Event * @param[in] delta The offset of rolling (positive value means roll down, and negative value means roll up) * @param[in] timeStamp The time the wheel is being rolled. */ - WheelEvent( Type type, int direction, unsigned int modifiers, Vector2 point, int delta, unsigned int timeStamp ); + WheelEvent(Type type, int direction, unsigned int modifiers, Vector2 point, int delta, unsigned int timeStamp); /** * Virtual destructor @@ -101,7 +99,6 @@ struct DALI_CORE_API WheelEvent : public Event *@copydoc Dali::WheelEvent::GetTime */ unsigned int timeStamp; - }; } // namespace Integration diff --git a/dali/integration-api/gl-abstraction.h b/dali/integration-api/gl-abstraction.h index bffcd67..8ce11d0 100644 --- a/dali/integration-api/gl-abstraction.h +++ b/dali/integration-api/gl-abstraction.h @@ -2,7 +2,7 @@ #define DALI_INTEGRATION_GL_ABSTRACTION_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -46,13 +46,11 @@ ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ - /* OpenGL ES 3.0 */ struct __GLsync; namespace Dali { - /** * These types are equivalent to those in the GLES2 API. * Dali objects should only access GL indirectly, through the Context API. @@ -87,7 +85,6 @@ using GLsync = __GLsync*; namespace Integration { - /** * GlAbstraction is an abstract interface, used to access OpenGL services. * A concrete implementation must be created for each platform, and provided when creating the @@ -96,11 +93,12 @@ namespace Integration class GlAbstraction { protected: - /** * Virtual protected destructor, no deletion through this interface */ - virtual ~GlAbstraction() {} + virtual ~GlAbstraction() + { + } public: /** @@ -128,7 +126,7 @@ public: * @param[in] isSubImage Boolian value for the whether the image is subimage or not * @return Whether the texture will be convert or not. */ - virtual bool TextureRequiresConverting( const GLenum imageGlFormat, const GLenum textureGlFormat, const bool isSubImage ) const = 0; + virtual bool TextureRequiresConverting(const GLenum imageGlFormat, const GLenum textureGlFormat, const bool isSubImage) const = 0; /** * The number of texture units an implementation supports is implementation dependent, but must be at least 8. @@ -136,7 +134,7 @@ public: static const unsigned int MIN_TEXTURE_UNIT_LIMIT = 8; /* OpenGL ES 2.0 */ - + // clang-format off virtual void ActiveTexture (GLenum texture) = 0; virtual void AttachShader (GLuint program, GLuint shader) = 0; virtual void BindAttribLocation (GLuint program, GLuint index, const char* name) = 0; @@ -386,7 +384,7 @@ public: virtual void TexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) = 0; virtual void TexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) = 0; virtual void GetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) = 0; - + // clang-format on }; } // namespace Integration diff --git a/dali/integration-api/gl-context-helper-abstraction.h b/dali/integration-api/gl-context-helper-abstraction.h index 91b1dcc..4e2e4e7 100644 --- a/dali/integration-api/gl-context-helper-abstraction.h +++ b/dali/integration-api/gl-context-helper-abstraction.h @@ -25,7 +25,6 @@ namespace Dali { namespace Integration { - /** * This abstraction defines the interface for accessing GL context. */ @@ -38,7 +37,6 @@ protected: virtual ~GlContextHelperAbstraction() = default; public: - /** * @brief Switch to the surfaceless GL context */ diff --git a/dali/integration-api/gl-defines.h b/dali/integration-api/gl-defines.h index 3d71156..ab7e5e2 100644 --- a/dali/integration-api/gl-defines.h +++ b/dali/integration-api/gl-defines.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_GL_DEFINES_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -46,6 +46,8 @@ ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ +// clang-format off + /* OpenGL ES 2.0 */ /* ClearBufferMask */ diff --git a/dali/integration-api/gl-sync-abstraction.h b/dali/integration-api/gl-sync-abstraction.h index e4edabf..398d297 100644 --- a/dali/integration-api/gl-sync-abstraction.h +++ b/dali/integration-api/gl-sync-abstraction.h @@ -2,7 +2,7 @@ #define DALI_INTEGRATION_GL_SYNC_ABSTRACTION_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -24,7 +24,6 @@ namespace Dali { namespace Integration { - /** * This abstraction defines an API for syncing CPU with GPU. * A typical use case is to determine when GL draw calls have finished drawing @@ -36,10 +35,11 @@ protected: /** * Virtual protected destructor, no deletion through this interface */ - virtual ~GlSyncAbstraction() {} + virtual ~GlSyncAbstraction() + { + } public: - class SyncObject { protected: @@ -48,10 +48,11 @@ public: * Core from deleting SyncObjects - only Adaptor implementation is able to delete * them. */ - virtual ~SyncObject() {} + virtual ~SyncObject() + { + } public: - /** * Determine if the synchronisation object has been signalled. * @return false if the sync object has not been signalled, true if it has been signalled (and diff --git a/dali/integration-api/input-options.cpp b/dali/integration-api/input-options.cpp index 1a8bc5f..3dfca89 100644 --- a/dali/integration-api/input-options.cpp +++ b/dali/integration-api/input-options.cpp @@ -8,149 +8,146 @@ using Dali::Internal::ThreadLocalStorage; namespace Dali { - namespace Integration { - -void SetPanGesturePredictionMode( int mode ) +void SetPanGesturePredictionMode(int mode) { GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor(); eventProcessor.SetPanGesturePredictionMode(mode); } -void SetPanGesturePredictionAmount( unsigned int amount ) +void SetPanGesturePredictionAmount(unsigned int amount) { GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor(); eventProcessor.SetPanGesturePredictionAmount(amount); } -void SetPanGestureMaximumPredictionAmount( unsigned int amount ) +void SetPanGestureMaximumPredictionAmount(unsigned int amount) { GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor(); eventProcessor.SetPanGestureMaximumPredictionAmount(amount); } -void SetPanGestureMinimumPredictionAmount( unsigned int amount ) +void SetPanGestureMinimumPredictionAmount(unsigned int amount) { GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor(); eventProcessor.SetPanGestureMinimumPredictionAmount(amount); } -void SetPanGesturePredictionAmountAdjustment( unsigned int amount ) +void SetPanGesturePredictionAmountAdjustment(unsigned int amount) { GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor(); eventProcessor.SetPanGesturePredictionAmountAdjustment(amount); } -void SetPanGestureSmoothingMode( int mode ) +void SetPanGestureSmoothingMode(int mode) { GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor(); eventProcessor.SetPanGestureSmoothingMode(mode); } -void SetPanGestureSmoothingAmount( float amount ) +void SetPanGestureSmoothingAmount(float amount) { GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor(); eventProcessor.SetPanGestureSmoothingAmount(amount); } -void SetPanGestureUseActualTimes( bool value ) +void SetPanGestureUseActualTimes(bool value) { GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor(); - eventProcessor.SetPanGestureUseActualTimes( value ); + eventProcessor.SetPanGestureUseActualTimes(value); } -void SetPanGestureInterpolationTimeRange( int value ) +void SetPanGestureInterpolationTimeRange(int value) { GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor(); - eventProcessor.SetPanGestureInterpolationTimeRange( value ); + eventProcessor.SetPanGestureInterpolationTimeRange(value); } -void SetPanGestureScalarOnlyPredictionEnabled( bool value ) +void SetPanGestureScalarOnlyPredictionEnabled(bool value) { GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor(); - eventProcessor.SetPanGestureScalarOnlyPredictionEnabled( value ); + eventProcessor.SetPanGestureScalarOnlyPredictionEnabled(value); } -void SetPanGestureTwoPointPredictionEnabled( bool value ) +void SetPanGestureTwoPointPredictionEnabled(bool value) { GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor(); - eventProcessor.SetPanGestureTwoPointPredictionEnabled( value ); + eventProcessor.SetPanGestureTwoPointPredictionEnabled(value); } -void SetPanGestureTwoPointInterpolatePastTime( int value ) +void SetPanGestureTwoPointInterpolatePastTime(int value) { GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor(); - eventProcessor.SetPanGestureTwoPointInterpolatePastTime( value ); + eventProcessor.SetPanGestureTwoPointInterpolatePastTime(value); } -void SetPanGestureTwoPointVelocityBias( float value ) +void SetPanGestureTwoPointVelocityBias(float value) { GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor(); - eventProcessor.SetPanGestureTwoPointVelocityBias( value ); + eventProcessor.SetPanGestureTwoPointVelocityBias(value); } -void SetPanGestureTwoPointAccelerationBias( float value ) +void SetPanGestureTwoPointAccelerationBias(float value) { GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor(); - eventProcessor.SetPanGestureTwoPointAccelerationBias( value ); + eventProcessor.SetPanGestureTwoPointAccelerationBias(value); } -void SetPanGestureMultitapSmoothingRange( int value ) +void SetPanGestureMultitapSmoothingRange(int value) { GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor(); - eventProcessor.SetPanGestureMultitapSmoothingRange( value ); + eventProcessor.SetPanGestureMultitapSmoothingRange(value); } -void SetPanGestureMinimumDistance( int value ) +void SetPanGestureMinimumDistance(int value) { GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor(); - eventProcessor.SetPanGestureMinimumDistance( value ); + eventProcessor.SetPanGestureMinimumDistance(value); } -void SetPanGestureMinimumPanEvents( int value ) +void SetPanGestureMinimumPanEvents(int value) { GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor(); - eventProcessor.SetPanGestureMinimumPanEvents( value ); + eventProcessor.SetPanGestureMinimumPanEvents(value); } -void SetPinchGestureMinimumDistance( float value ) +void SetPinchGestureMinimumDistance(float value) { GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor(); - eventProcessor.SetPinchGestureMinimumDistance( value ); + eventProcessor.SetPinchGestureMinimumDistance(value); } -void SetPinchGestureMinimumTouchEvents( uint32_t value ) +void SetPinchGestureMinimumTouchEvents(uint32_t value) { GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor(); - eventProcessor.SetPinchGestureMinimumTouchEvents( value ); + eventProcessor.SetPinchGestureMinimumTouchEvents(value); } -void SetPinchGestureMinimumTouchEventsAfterStart( uint32_t value ) +void SetPinchGestureMinimumTouchEventsAfterStart(uint32_t value) { GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor(); - eventProcessor.SetPinchGestureMinimumTouchEventsAfterStart( value ); + eventProcessor.SetPinchGestureMinimumTouchEventsAfterStart(value); } -void SetRotationGestureMinimumTouchEvents( uint32_t value ) +void SetRotationGestureMinimumTouchEvents(uint32_t value) { GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor(); - eventProcessor.SetRotationGestureMinimumTouchEvents( value ); + eventProcessor.SetRotationGestureMinimumTouchEvents(value); } -void SetRotationGestureMinimumTouchEventsAfterStart( uint32_t value ) +void SetRotationGestureMinimumTouchEventsAfterStart(uint32_t value) { GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor(); - eventProcessor.SetRotationGestureMinimumTouchEventsAfterStart( value ); + eventProcessor.SetRotationGestureMinimumTouchEventsAfterStart(value); } -void SetLongPressMinimumHoldingTime( unsigned int value ) +void SetLongPressMinimumHoldingTime(unsigned int value) { GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor(); - eventProcessor.SetLongPressMinimumHoldingTime( value ); + eventProcessor.SetLongPressMinimumHoldingTime(value); } - } // namespace Integration } // namespace Dali diff --git a/dali/integration-api/input-options.h b/dali/integration-api/input-options.h index c64ee4b..3789cc9 100644 --- a/dali/integration-api/input-options.h +++ b/dali/integration-api/input-options.h @@ -2,7 +2,7 @@ #define DALI_INTEGRATION_INPUT_OPTIONS_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -26,10 +26,8 @@ namespace Dali { - namespace Integration { - /** * @brief Called by adaptor to set the pan gesture prediction mode from * an environment variable @@ -37,7 +35,7 @@ namespace Integration * @pre Should be called after Core creation. * @param mode The pan gesture prediction mode. */ -DALI_CORE_API void SetPanGesturePredictionMode( int mode ); +DALI_CORE_API void SetPanGesturePredictionMode(int mode); /** * @brief Called by adaptor to set the prediction amount of the pan gesture @@ -53,7 +51,7 @@ DALI_CORE_API void SetPanGesturePredictionAmount(unsigned int amount); * * @param[in] amount The prediction amount in milliseconds */ -DALI_CORE_API void SetPanGestureMaximumPredictionAmount( unsigned int amount ); +DALI_CORE_API void SetPanGestureMaximumPredictionAmount(unsigned int amount); /** * @brief Sets the lower bound of the prediction amount for clamping @@ -61,7 +59,7 @@ DALI_CORE_API void SetPanGestureMaximumPredictionAmount( unsigned int amount ); * * @param[in] amount The prediction amount in milliseconds */ -DALI_CORE_API void SetPanGestureMinimumPredictionAmount( unsigned int amount ); +DALI_CORE_API void SetPanGestureMinimumPredictionAmount(unsigned int amount); /** * @brief Sets the prediction amount to adjust when the pan velocity is changed @@ -72,133 +70,133 @@ DALI_CORE_API void SetPanGestureMinimumPredictionAmount( unsigned int amount ); * * @param[in] amount The prediction amount in milliseconds */ -DALI_CORE_API void SetPanGesturePredictionAmountAdjustment( unsigned int amount ); +DALI_CORE_API void SetPanGesturePredictionAmountAdjustment(unsigned int amount); /** * @brief Called to set how pan gestures smooth input * * @param[in] mode The smoothing mode to use */ -DALI_CORE_API void SetPanGestureSmoothingMode( int mode ); +DALI_CORE_API void SetPanGestureSmoothingMode(int mode); /** * @brief Sets the smoothing amount of the pan gesture * * @param[in] amount The smoothing amount [0.0f,1.0f] - 0.0f would be no smoothing, 1.0f maximum smoothing */ -DALI_CORE_API void SetPanGestureSmoothingAmount( float amount ); +DALI_CORE_API void SetPanGestureSmoothingAmount(float amount); /** * @brief Sets whether to use actual times of the real gesture and frames or not. * * @param[in] value True = use actual times, False = use perfect values */ -DALI_CORE_API void SetPanGestureUseActualTimes( bool value ); +DALI_CORE_API void SetPanGestureUseActualTimes(bool value); /** * @brief Sets the interpolation time range (ms) of past points to use (with weights) when interpolating. * * @param[in] value Time range in ms */ -DALI_CORE_API void SetPanGestureInterpolationTimeRange( int value ); +DALI_CORE_API void SetPanGestureInterpolationTimeRange(int value); /** * @brief Sets whether to use scalar only prediction, which when enabled, ignores acceleration. * * @param[in] value True = use scalar prediction only */ -DALI_CORE_API void SetPanGestureScalarOnlyPredictionEnabled( bool value ); +DALI_CORE_API void SetPanGestureScalarOnlyPredictionEnabled(bool value); /** * @brief Sets whether to use two point prediction. This combines two interpolated points to get more steady acceleration and velocity values. * * @param[in] value True = use two point prediction */ -DALI_CORE_API void SetPanGestureTwoPointPredictionEnabled( bool value ); +DALI_CORE_API void SetPanGestureTwoPointPredictionEnabled(bool value); /** * @brief Sets the time in the past to interpolate the second point when using two point interpolation. * * @param[in] value Time in past in ms */ -DALI_CORE_API void SetPanGestureTwoPointInterpolatePastTime( int value ); +DALI_CORE_API void SetPanGestureTwoPointInterpolatePastTime(int value); /** * @brief Sets the two point velocity bias. This is the ratio of first and second points to use for velocity. * * @param[in] value 0.0f = 100% first point. 1.0f = 100% of second point. */ -DALI_CORE_API void SetPanGestureTwoPointVelocityBias( float value ); +DALI_CORE_API void SetPanGestureTwoPointVelocityBias(float value); /** * @brief Sets the two point acceleration bias. This is the ratio of first and second points to use for acceleration. * * @param[in] value 0.0f = 100% first point. 1.0f = 100% of second point. */ -DALI_CORE_API void SetPanGestureTwoPointAccelerationBias( float value ); +DALI_CORE_API void SetPanGestureTwoPointAccelerationBias(float value); /** * @brief Sets the range of time (ms) of points in the history to perform multitap smoothing with (if enabled). * * @param[in] value Time in past in ms */ -DALI_CORE_API void SetPanGestureMultitapSmoothingRange( int value ); +DALI_CORE_API void SetPanGestureMultitapSmoothingRange(int value); /** * @brief Sets the minimum distance required to start a pan gesture * * @param[in] value Distance to move */ -DALI_CORE_API void SetPanGestureMinimumDistance( int value ); +DALI_CORE_API void SetPanGestureMinimumDistance(int value); /** * @brief Sets the minimum number of touch events to start a pan * * @param[in] value Number of pan events */ -DALI_CORE_API void SetPanGestureMinimumPanEvents( int value ); +DALI_CORE_API void SetPanGestureMinimumPanEvents(int value); /** * @brief Sets the minimum distance required to start a pinch gesture * * @param[in] value Distance to move in pixels */ -DALI_CORE_API void SetPinchGestureMinimumDistance( float value ); +DALI_CORE_API void SetPinchGestureMinimumDistance(float value); /** * @brief Sets the minimum touch events required before a pinch can be started * * @param[in] value The number of touch events */ -DALI_CORE_API void SetPinchGestureMinimumTouchEvents( uint32_t value ); +DALI_CORE_API void SetPinchGestureMinimumTouchEvents(uint32_t value); /** * @brief Sets the minimum touch events required after a pinch started * * @param[in] value The number of touch events */ -DALI_CORE_API void SetPinchGestureMinimumTouchEventsAfterStart( uint32_t value ); +DALI_CORE_API void SetPinchGestureMinimumTouchEventsAfterStart(uint32_t value); /** * @brief Sets the minimum touch events required before a rotation can be started * * @param[in] value The number of touch events */ -DALI_CORE_API void SetRotationGestureMinimumTouchEvents( uint32_t value ); +DALI_CORE_API void SetRotationGestureMinimumTouchEvents(uint32_t value); /** * @brief Sets the minimum touch events required after a rotation started * * @param[in] value The number of touch events */ -DALI_CORE_API void SetRotationGestureMinimumTouchEventsAfterStart( uint32_t value ); +DALI_CORE_API void SetRotationGestureMinimumTouchEventsAfterStart(uint32_t value); /** * @brief Sets the minimum holding time required to be recognized as a long press gesture * * @param[in] value The time value in milliseconds */ -DALI_CORE_API void SetLongPressMinimumHoldingTime( unsigned int value ); +DALI_CORE_API void SetLongPressMinimumHoldingTime(unsigned int value); } // namespace Integration diff --git a/dali/integration-api/lockless-buffer.cpp b/dali/integration-api/lockless-buffer.cpp index dd2217d..156ba6b 100644 --- a/dali/integration-api/lockless-buffer.cpp +++ b/dali/integration-api/lockless-buffer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -23,20 +23,18 @@ namespace Dali { - namespace Integration { - -LocklessBuffer::LocklessBuffer( uint32_t size ) -: mState( R0W1 ), - mSize( size ) +LocklessBuffer::LocklessBuffer(uint32_t size) +: mState(R0W1), + mSize(size) { // allocate memory to speed up operation mBuffer[0] = new uint8_t[size]; mBuffer[1] = new uint8_t[size]; - memset (mBuffer[0], 0, size ); - memset (mBuffer[1], 0, size ); + memset(mBuffer[0], 0, size); + memset(mBuffer[1], 0, size); } LocklessBuffer::~LocklessBuffer() @@ -45,40 +43,40 @@ LocklessBuffer::~LocklessBuffer() delete[] mBuffer[1]; } -void LocklessBuffer::Write( const uint8_t *src, uint32_t size ) +void LocklessBuffer::Write(const uint8_t* src, uint32_t size) { - DALI_ASSERT_ALWAYS( size <= mSize ); + DALI_ASSERT_ALWAYS(size <= mSize); // set WRITING bit - BufferState currentState( __sync_fetch_and_or( &mState, WRITING ) ); - DALI_ASSERT_DEBUG( !(currentState & WRITING_MASK) ); // WRITING bit should never be set when we get here + BufferState currentState(__sync_fetch_and_or(&mState, WRITING)); + DALI_ASSERT_DEBUG(!(currentState & WRITING_MASK)); // WRITING bit should never be set when we get here // copy data to current write buffer, negate state to get actual index (recap: R0W1 = 0, R1W0 = 1) const unsigned int index = (currentState & WRITE_BUFFER_MASK); - memcpy( mBuffer[index], src, size ); + memcpy(mBuffer[index], src, size); // unset WRITING bit, set UPDATED bit - BufferState checkState = __sync_val_compare_and_swap( &mState, - static_cast(currentState | WRITING), - static_cast(index | UPDATED) ); + BufferState checkState = __sync_val_compare_and_swap(&mState, + static_cast(currentState | WRITING), + static_cast(index | UPDATED)); - DALI_ASSERT_DEBUG( checkState & WRITING ); + DALI_ASSERT_DEBUG(checkState & WRITING); (void)checkState; // Avoid unused variable warning } const uint8_t* LocklessBuffer::Read() { // current state (only to avoid multiple memory reads with volatile variable) - BufferState currentState( mState ); - BufferState currentWriteBuf( static_cast( currentState & WRITE_BUFFER_MASK ) ); + BufferState currentState(mState); + BufferState currentWriteBuf(static_cast(currentState & WRITE_BUFFER_MASK)); - if( currentState & UPDATED_MASK ) + if(currentState & UPDATED_MASK) { // Try to swap buffers. // This will set mState to 1 if readbuffer 0 was updated, 0 if readbuffer 1 was updated and fail if WRITING is set - if( __sync_bool_compare_and_swap( &mState, - static_cast(currentWriteBuf | UPDATED), - static_cast(!currentWriteBuf) ) ) + if(__sync_bool_compare_and_swap(&mState, + static_cast(currentWriteBuf | UPDATED), + static_cast(!currentWriteBuf))) { // swap successful return mBuffer[currentWriteBuf]; @@ -95,6 +93,6 @@ uint32_t LocklessBuffer::GetSize() const return static_cast(mSize); } -} // Internal +} // namespace Integration -} // Dali +} // namespace Dali diff --git a/dali/integration-api/lockless-buffer.h b/dali/integration-api/lockless-buffer.h index a266a04..0263726 100644 --- a/dali/integration-api/lockless-buffer.h +++ b/dali/integration-api/lockless-buffer.h @@ -2,7 +2,7 @@ #define DALI_INTEGRATION_LOCKLESS_BUFFER_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -22,16 +22,14 @@ #include // uint32_t, uint8_t // INTERNAL INCLUDES -#include -#include #include +#include +#include namespace Dali { - namespace Integration { - /** * The LocklessBuffer class implements double buffering eligible for multi-(two) threaded use, * where it's possible to read from one thread and write from another @@ -47,13 +45,12 @@ namespace Integration */ class DALI_CORE_API LocklessBuffer { - public: /** * Constructor. * @param[in] size The size of buffers in bytes. */ - LocklessBuffer( uint32_t size ); + LocklessBuffer(uint32_t size); /** * Destructor. @@ -65,7 +62,7 @@ public: * @param[in] src data source * @param[in] size size of data in bytes */ - void Write( const uint8_t *src, uint32_t size ); + void Write(const uint8_t* src, uint32_t size); /** * Try to swap buffers and read data. @@ -87,19 +84,19 @@ private: */ enum BufferState { - R0W1 = 0, ///< Read from buffer 0 write to buffer 1 - R1W0 = 1, ///< Read from buffer 1 write to buffer 0 - WRITING = 2, ///< Currently writing to buffer - UPDATED = 4, ///< Swapping buffer required; there is new data available + R0W1 = 0, ///< Read from buffer 0 write to buffer 1 + R1W0 = 1, ///< Read from buffer 1 write to buffer 0 + WRITING = 2, ///< Currently writing to buffer + UPDATED = 4, ///< Swapping buffer required; there is new data available WRITE_BUFFER_MASK = 1, ///< indicates which buffer to write to WRITING_MASK = 2, ///< indicates whether currently writing UPDATED_MASK = 4 ///< indicates whether new data is available }; private: - LocklessBuffer(); ///< undefined default constructor, need to give size on construction - LocklessBuffer( const LocklessBuffer& ); ///< undefined copy constructor - LocklessBuffer& operator=( const LocklessBuffer& ); ///< undefined assignment operator + LocklessBuffer(); ///< undefined default constructor, need to give size on construction + LocklessBuffer(const LocklessBuffer&); ///< undefined copy constructor + LocklessBuffer& operator=(const LocklessBuffer&); ///< undefined assignment operator private: uint8_t* mBuffer[2]; ///< bitmap buffers @@ -107,8 +104,8 @@ private: uint32_t mSize; ///< size of buffers }; -} // Internal +} // namespace Integration -} // Dali +} // namespace Dali #endif // DALI_INTEGRATION_LOCKLESS_BUFFER_H diff --git a/dali/integration-api/platform-abstraction.h b/dali/integration-api/platform-abstraction.h index ab3341e..4bc3d09 100644 --- a/dali/integration-api/platform-abstraction.h +++ b/dali/integration-api/platform-abstraction.h @@ -2,7 +2,7 @@ #define DALI_INTEGRATION_PLATFORM_ABSTRACTION_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -22,13 +22,12 @@ #include #include -#include #include +#include #include namespace Dali { - namespace Integration { using ResourceId = uint32_t; @@ -42,7 +41,6 @@ using ResourcePointer = IntrusivePtr; class PlatformAbstraction { public: - // Resource Loading /** @@ -61,11 +59,11 @@ public: * flip the image, e.g., from portrait to landscape. * @return dimensions that image will have if it is loaded with given parameters. */ - virtual ImageDimensions GetClosestImageSize( const std::string& filename, - ImageDimensions size = ImageDimensions( 0, 0 ), - FittingMode::Type fittingMode = FittingMode::SHRINK_TO_FIT, - SamplingMode::Type samplingMode = SamplingMode::BOX, - bool orientationCorrection = true) = 0; + virtual ImageDimensions GetClosestImageSize(const std::string& filename, + ImageDimensions size = ImageDimensions(0, 0), + FittingMode::Type fittingMode = FittingMode::SHRINK_TO_FIT, + SamplingMode::Type samplingMode = SamplingMode::BOX, + bool orientationCorrection = true) = 0; /** * @brief Determine the size of an image the resource loaders will provide when @@ -83,11 +81,11 @@ public: * flip the image, e.g., from portrait to landscape. * @return dimensions that image will have if it is loaded with given parameters. */ - virtual ImageDimensions GetClosestImageSize( ResourcePointer resourceBuffer, - ImageDimensions size = ImageDimensions( 0, 0 ), - FittingMode::Type fittingMode = FittingMode::SHRINK_TO_FIT, - SamplingMode::Type samplingMode = SamplingMode::BOX, - bool orientationCorrection = true) = 0; + virtual ImageDimensions GetClosestImageSize(ResourcePointer resourceBuffer, + ImageDimensions size = ImageDimensions(0, 0), + FittingMode::Type fittingMode = FittingMode::SHRINK_TO_FIT, + SamplingMode::Type samplingMode = SamplingMode::BOX, + bool orientationCorrection = true) = 0; /** * Request an image from the native filesystem. This is a synchronous request, i.e. @@ -99,7 +97,7 @@ public: * @param[in] resourcePath The path to the resource * @return A pointer to a ref-counted resource */ - virtual ResourcePointer LoadImageSynchronously( const BitmapResourceType& resourceType, const std::string& resourcePath ) = 0; + virtual ResourcePointer LoadImageSynchronously(const BitmapResourceType& resourceType, const std::string& resourcePath) = 0; /** * Decode a buffer of data synchronously. @@ -109,7 +107,7 @@ public: * * @return A pointer to the decoded buffer. */ - virtual BitmapPtr DecodeBuffer( const BitmapResourceType& resourceType, uint8_t * buffer, size_t bufferSize ) = 0; + virtual BitmapPtr DecodeBuffer(const BitmapResourceType& resourceType, uint8_t* buffer, size_t bufferSize) = 0; /** * Load a shader binary file into a buffer @@ -117,7 +115,7 @@ public: * @param[out] buffer A buffer to receive the file. * @result true if the file is loaded. */ - virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< uint8_t >& buffer ) const = 0; + virtual bool LoadShaderBinaryFile(const std::string& filename, Dali::Vector& buffer) const = 0; /** * Save a shader binary file to the resource file system. @@ -126,7 +124,7 @@ public: * @param[in] numbytes Size of the buffer. * @result true if the file is saved, else false. */ - virtual bool SaveShaderBinaryFile( const std::string& filename, const uint8_t * buffer, uint32_t numBytes ) const = 0; + virtual bool SaveShaderBinaryFile(const std::string& filename, const uint8_t* buffer, uint32_t numBytes) const = 0; /** * Sets a callback to occur in the future @@ -134,20 +132,21 @@ public: * @param[in] callback function to call when the timer expires * @result a timer reference ID, to be used for cancelling the timer */ - virtual uint32_t StartTimer( uint32_t milliseconds, CallbackBase* callback ) = 0; + virtual uint32_t StartTimer(uint32_t milliseconds, CallbackBase* callback) = 0; /** * Cancels a running timer * @param[in] timerId the ID reference returned when the timer was started */ - virtual void CancelTimer ( uint32_t timerId ) = 0; + virtual void CancelTimer(uint32_t timerId) = 0; protected: - /** * Virtual destructor. */ - virtual ~PlatformAbstraction() {} + virtual ~PlatformAbstraction() + { + } }; // class PlatformAbstraction diff --git a/dali/integration-api/processor-interface.h b/dali/integration-api/processor-interface.h index 1043ac3..3334a6b 100644 --- a/dali/integration-api/processor-interface.h +++ b/dali/integration-api/processor-interface.h @@ -2,7 +2,7 @@ #define DALI_INTEGRATION_PROCESSOR_INTERFACE_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -23,10 +23,8 @@ namespace Dali { - namespace Integration { - /** * Interface to enable classes to be processed after the event loop. Classes are processed * in the order they are registered. @@ -40,15 +38,16 @@ public: virtual void Process() = 0; protected: - /** * Virtual protected destructor */ - virtual ~Processor() { } + virtual ~Processor() + { + } }; -} // Dali +} // namespace Integration -} // Integration +} // namespace Dali #endif // DALI_INTEGRATION_PROCESSOR_INTERFACE_H \ No newline at end of file diff --git a/dali/integration-api/profiling.cpp b/dali/integration-api/profiling.cpp index 03458cd..036fcd5 100644 --- a/dali/integration-api/profiling.cpp +++ b/dali/integration-api/profiling.cpp @@ -35,16 +35,15 @@ #include #include - #include #include #include #include -#include #include #include +#include #include using Dali::Internal::GestureEventProcessor; @@ -52,15 +51,13 @@ using Dali::Internal::ThreadLocalStorage; namespace Dali { - namespace Integration { - -void EnableProfiling( ProfilingType type ) +void EnableProfiling(ProfilingType type) { GestureEventProcessor& eventProcessor = ThreadLocalStorage::Get().GetGestureEventProcessor(); - switch( type ) + switch(type) { case PROFILING_TYPE_PAN_GESTURE: { @@ -77,43 +74,42 @@ void EnableProfiling( ProfilingType type ) namespace Profiling { - const std::size_t ANIMATION_MEMORY_SIZE( - sizeof( Internal::Animation ) + - sizeof( Internal::AnimatorConnector ) + - sizeof( Internal::SceneGraph::Animation ) ); + sizeof(Internal::Animation) + + sizeof(Internal::AnimatorConnector) + + sizeof(Internal::SceneGraph::Animation)); const std::size_t CONSTRAINT_MEMORY_SIZE( - sizeof( Internal::Constraint ) + - sizeof( Internal::SceneGraph::Constraint > ) ); + sizeof(Internal::Constraint) + + sizeof(Internal::SceneGraph::Constraint >)); const std::size_t ACTOR_MEMORY_SIZE( - sizeof( Internal::Actor ) + - sizeof( Internal::SceneGraph::Node ) ); + sizeof(Internal::Actor) + + sizeof(Internal::SceneGraph::Node)); const std::size_t CAMERA_ACTOR_MEMORY_SIZE( - sizeof( Internal::CameraActor ) + - sizeof( Internal::SceneGraph::Node ) + - sizeof( Internal::SceneGraph::Camera ) ); + sizeof(Internal::CameraActor) + + sizeof(Internal::SceneGraph::Node) + + sizeof(Internal::SceneGraph::Camera)); const std::size_t LAYER_MEMORY_SIZE( - sizeof( Internal::Layer ) + - sizeof( Internal::SceneGraph::Layer ) ); + sizeof(Internal::Layer) + + sizeof(Internal::SceneGraph::Layer)); const std::size_t RENDERER_MEMORY_SIZE( - sizeof( Internal::Renderer ) + - sizeof( Internal::SceneGraph::Renderer ) + - sizeof( Internal::Render::Renderer ) ); + sizeof(Internal::Renderer) + + sizeof(Internal::SceneGraph::Renderer) + + sizeof(Internal::Render::Renderer)); const std::size_t GEOMETRY_MEMORY_SIZE( - sizeof( Internal::Geometry ) + - sizeof( Internal::Render::Geometry) ); + sizeof(Internal::Geometry) + + sizeof(Internal::Render::Geometry)); const std::size_t PROPERTY_BUFFER_MEMORY_SIZE( - sizeof( Internal::VertexBuffer ) + - sizeof( Internal::Render::VertexBuffer ) ); + sizeof(Internal::VertexBuffer) + + sizeof(Internal::Render::VertexBuffer)); const std::size_t TEXTURE_SET_MEMORY_SIZE( - sizeof( Internal::TextureSet ) + - sizeof( Internal::SceneGraph::TextureSet ) ); + sizeof(Internal::TextureSet) + + sizeof(Internal::SceneGraph::TextureSet)); const std::size_t SAMPLER_MEMORY_SIZE( - sizeof( Internal::Sampler ) + - sizeof( Internal::Render::Sampler ) ); + sizeof(Internal::Sampler) + + sizeof(Internal::Render::Sampler)); const std::size_t SHADER_MEMORY_SIZE( - sizeof( Internal::Shader ) + - sizeof( Internal::SceneGraph::Shader ) ); + sizeof(Internal::Shader) + + sizeof(Internal::SceneGraph::Shader)); } // namespace Profiling diff --git a/dali/integration-api/profiling.h b/dali/integration-api/profiling.h index e7889f2..6f54eff 100644 --- a/dali/integration-api/profiling.h +++ b/dali/integration-api/profiling.h @@ -2,7 +2,7 @@ #define DALI_INTEGRATION_PROFILING_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -26,10 +26,8 @@ namespace Dali { - namespace Integration { - enum ProfilingType { PROFILING_TYPE_PAN_GESTURE, @@ -43,26 +41,23 @@ enum ProfilingType * @pre Should be called after Core creation. * @param type The type of profiling information to output. */ -DALI_CORE_API void EnableProfiling( ProfilingType type ); - +DALI_CORE_API void EnableProfiling(ProfilingType type); namespace Profiling { - -DALI_CORE_API extern const std::size_t ANIMATION_MEMORY_SIZE; ///< Total size of animation and associated internal objects -DALI_CORE_API extern const std::size_t CONSTRAINT_MEMORY_SIZE; ///< Total size of constraint and associated internal objects -DALI_CORE_API extern const std::size_t ACTOR_MEMORY_SIZE; ///< Total size of actor and associated internal objects -DALI_CORE_API extern const std::size_t CAMERA_ACTOR_MEMORY_SIZE; ///< Total size of camera actor and associated internal objects -DALI_CORE_API extern const std::size_t IMAGE_ACTOR_MEMORY_SIZE; ///< Total size of image actor and associated internal objects -DALI_CORE_API extern const std::size_t LAYER_MEMORY_SIZE; ///< Total size of layer and associated internal objects -DALI_CORE_API extern const std::size_t IMAGE_MEMORY_SIZE; ///< Total size of image and associated internal objects - -DALI_CORE_API extern const std::size_t RENDERER_MEMORY_SIZE; ///< Total size of renderer and associated internal objects -DALI_CORE_API extern const std::size_t GEOMETRY_MEMORY_SIZE; ///< Total size of geometry and associated internal objects -DALI_CORE_API extern const std::size_t PROPERTY_BUFFER_MEMORY_SIZE; ///< Total size of property-0buffer and associated internal objects +DALI_CORE_API extern const std::size_t ANIMATION_MEMORY_SIZE; ///< Total size of animation and associated internal objects +DALI_CORE_API extern const std::size_t CONSTRAINT_MEMORY_SIZE; ///< Total size of constraint and associated internal objects +DALI_CORE_API extern const std::size_t ACTOR_MEMORY_SIZE; ///< Total size of actor and associated internal objects +DALI_CORE_API extern const std::size_t CAMERA_ACTOR_MEMORY_SIZE; ///< Total size of camera actor and associated internal objects +DALI_CORE_API extern const std::size_t IMAGE_ACTOR_MEMORY_SIZE; ///< Total size of image actor and associated internal objects +DALI_CORE_API extern const std::size_t LAYER_MEMORY_SIZE; ///< Total size of layer and associated internal objects +DALI_CORE_API extern const std::size_t IMAGE_MEMORY_SIZE; ///< Total size of image and associated internal objects +DALI_CORE_API extern const std::size_t RENDERER_MEMORY_SIZE; ///< Total size of renderer and associated internal objects +DALI_CORE_API extern const std::size_t GEOMETRY_MEMORY_SIZE; ///< Total size of geometry and associated internal objects +DALI_CORE_API extern const std::size_t PROPERTY_BUFFER_MEMORY_SIZE; ///< Total size of property-0buffer and associated internal objects DALI_CORE_API extern const std::size_t TEXTURE_SET_MEMORY_SIZE; ///< Total size of TextureSet and associated internal objects -DALI_CORE_API extern const std::size_t SAMPLER_MEMORY_SIZE; ///< Total size of Sampler and associated internal objects -DALI_CORE_API extern const std::size_t SHADER_MEMORY_SIZE; ///< Total size of shader and associated internal objects +DALI_CORE_API extern const std::size_t SAMPLER_MEMORY_SIZE; ///< Total size of Sampler and associated internal objects +DALI_CORE_API extern const std::size_t SHADER_MEMORY_SIZE; ///< Total size of shader and associated internal objects } // namespace Profiling } // namespace Integration diff --git a/dali/integration-api/render-controller.h b/dali/integration-api/render-controller.h index 076fd55..30ab2d3 100644 --- a/dali/integration-api/render-controller.h +++ b/dali/integration-api/render-controller.h @@ -2,7 +2,7 @@ #define DALI_INTEGRATION_RENDER_CONTROLLER_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -20,10 +20,8 @@ namespace Dali { - namespace Integration { - /** * Abstract interface for an object which controls rendering. * This will be informed when Dali has new content to render. @@ -31,29 +29,28 @@ namespace Integration class RenderController { protected: - /** * Virtual protected destructor, no deletion through this interface */ - virtual ~RenderController() {} + virtual ~RenderController() + { + } public: - /** * Requests a future call to Dali::Integration::Core::Update(). * This is called when Dali has new content, typically in response to Actors/Animations being added. * Multi-threading note: this method will be called from the main thread only. * @param[in] forceUpdate true to update forcely. */ - virtual void RequestUpdate( bool forceUpdate ) = 0; + virtual void RequestUpdate(bool forceUpdate) = 0; /** * Requests a future call to Dali::Integration::Core::ProcessEvents(), when the application is idle. * Multi-threading note: this method will be called from the main thread only. * @param[in] forceProcess true to process events forcely. */ - virtual void RequestProcessEventsOnIdle( bool forceProcess ) = 0; - + virtual void RequestProcessEventsOnIdle(bool forceProcess) = 0; }; } // namespace Integration diff --git a/dali/integration-api/render-task-list-integ.cpp b/dali/integration-api/render-task-list-integ.cpp old mode 100755 new mode 100644 index d23b749..003c55e --- a/dali/integration-api/render-task-list-integ.cpp +++ b/dali/integration-api/render-task-list-integ.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -19,28 +19,25 @@ #include // INTERNAL INCLUDES -#include #include #include +#include namespace Dali { - namespace Integration { - namespace RenderTaskList { - Dali::RenderTaskList New() { Dali::Internal::RenderTaskListPtr renderTaskList = Dali::Internal::RenderTaskList::New(); - return Dali::RenderTaskList( renderTaskList.Get() ); + return Dali::RenderTaskList(renderTaskList.Get()); } -Dali::RenderTask CreateTask( Dali::RenderTaskList& taskList, Dali::Actor& sourceActor, Dali::CameraActor& cameraActor) +Dali::RenderTask CreateTask(Dali::RenderTaskList& taskList, Dali::Actor& sourceActor, Dali::CameraActor& cameraActor) { - return RenderTask( GetImplementation(taskList).CreateTask( &GetImplementation( sourceActor), &GetImplementation(cameraActor) ).Get() ); + return RenderTask(GetImplementation(taskList).CreateTask(&GetImplementation(sourceActor), &GetImplementation(cameraActor)).Get()); } } // namespace RenderTaskList diff --git a/dali/integration-api/render-task-list-integ.h b/dali/integration-api/render-task-list-integ.h old mode 100755 new mode 100644 index 3ef3c5d..708a9b5 --- a/dali/integration-api/render-task-list-integ.h +++ b/dali/integration-api/render-task-list-integ.h @@ -2,7 +2,7 @@ #define DALI_INTEGRATION_RENDER_TASK_LIST_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -23,17 +23,14 @@ namespace Dali { - class Actor; class CameraActor; namespace Integration { - namespace RenderTaskList { - - /** +/** * @brief Helper function to create a new RenderTaskList object. * * A RenderTaskList is an ordered list of render tasks that describes @@ -41,9 +38,9 @@ namespace RenderTaskList * * @return A handle to a newly allocated RenderTaskList */ - DALI_CORE_API Dali::RenderTaskList New(); +DALI_CORE_API Dali::RenderTaskList New(); - /** +/** * @brief Helper function to create a new RenderTask. * * The created task will be appended to the list of render-tasks. @@ -53,7 +50,7 @@ namespace RenderTaskList * @param[in] cameraActor The actor from which the scene is viewed for this render task. * @return A valid handle to a new RenderTask */ - DALI_CORE_API Dali::RenderTask CreateTask( Dali::RenderTaskList& taskList, Dali::Actor& sourceActor, Dali::CameraActor& cameraActor); +DALI_CORE_API Dali::RenderTask CreateTask(Dali::RenderTaskList& taskList, Dali::Actor& sourceActor, Dali::CameraActor& cameraActor); } // namespace RenderTaskList diff --git a/dali/integration-api/resource-policies.h b/dali/integration-api/resource-policies.h index c9e864a..6d037b2 100644 --- a/dali/integration-api/resource-policies.h +++ b/dali/integration-api/resource-policies.h @@ -21,7 +21,6 @@ namespace Dali { namespace ResourcePolicy { - /** * The discardable policy determines if a resource can be discarded. * Discarded means that it can be released after uploading to GPU. diff --git a/dali/integration-api/resource-types.h b/dali/integration-api/resource-types.h index 29e47bd..9d70589 100644 --- a/dali/integration-api/resource-types.h +++ b/dali/integration-api/resource-types.h @@ -2,7 +2,7 @@ #define DALI_INTEGRATION_RESOURCE_TYPES_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -31,7 +31,6 @@ using ImageDimensions = Uint16Pair; namespace Integration { - /** * BitmapResourceType describes a bitmap resource. */ @@ -47,38 +46,38 @@ struct BitmapResourceType * @param[in] orientationCorrection Whether to use bitmap metadata to rotate or * flip the bitmap, e.g., from portrait to landscape. */ - BitmapResourceType( ImageDimensions size = ImageDimensions( 0, 0 ), - FittingMode::Type scalingMode = FittingMode::DEFAULT, - SamplingMode::Type samplingMode = SamplingMode::DEFAULT, - bool orientationCorrection = true ) - : size( size ), - scalingMode( scalingMode ), - samplingMode( samplingMode ), - orientationCorrection( orientationCorrection ) - {} + BitmapResourceType(ImageDimensions size = ImageDimensions(0, 0), + FittingMode::Type scalingMode = FittingMode::DEFAULT, + SamplingMode::Type samplingMode = SamplingMode::DEFAULT, + bool orientationCorrection = true) + : size(size), + scalingMode(scalingMode), + samplingMode(samplingMode), + orientationCorrection(orientationCorrection) + { + } /** * Destructor. */ ~BitmapResourceType() - {} + { + } /** * Attributes are copied from the request. */ - ImageDimensions size; - FittingMode::Type scalingMode; + ImageDimensions size; + FittingMode::Type scalingMode; SamplingMode::Type samplingMode; - bool orientationCorrection; + bool orientationCorrection; private: - // Undefined copy constructor. BitmapResourceType(const BitmapResourceType& typePath); // Undefined assignment operator. BitmapResourceType& operator=(const BitmapResourceType& rhs); - }; } // namespace Integration diff --git a/dali/integration-api/scene.cpp b/dali/integration-api/scene.cpp index b40c303..d24d0ad 100644 --- a/dali/integration-api/scene.cpp +++ b/dali/integration-api/scene.cpp @@ -19,25 +19,23 @@ #include // INTERNAL INCLUDES +#include #include #include -#include namespace Dali { - namespace Integration { - -Scene Scene::New( Size size ) +Scene Scene::New(Size size) { - Internal::ScenePtr internal = Internal::Scene::New( size ); - return Scene( internal.Get() ); + Internal::ScenePtr internal = Internal::Scene::New(size); + return Scene(internal.Get()); } -Scene Scene::DownCast( BaseHandle handle ) +Scene Scene::DownCast(BaseHandle handle) { - return Scene( dynamic_cast( handle.GetObjectPtr()) ); + return Scene(dynamic_cast(handle.GetObjectPtr())); } Scene::Scene() @@ -48,30 +46,30 @@ Scene::~Scene() { } -Scene::Scene( const Scene& handle ) -:BaseHandle(handle) +Scene::Scene(const Scene& handle) +: BaseHandle(handle) { } -Scene::Scene( Internal::Scene* internal ) +Scene::Scene(Internal::Scene* internal) : BaseHandle(internal) { } -Scene& Scene::operator=( const Scene& rhs ) +Scene& Scene::operator=(const Scene& rhs) { BaseHandle::operator=(rhs); return *this; } -void Scene::Add( Actor actor ) +void Scene::Add(Actor actor) { - GetImplementation(*this).Add( GetImplementation(actor) ); + GetImplementation(*this).Add(GetImplementation(actor)); } -void Scene::Remove( Actor actor ) +void Scene::Remove(Actor actor) { - GetImplementation(*this).Remove( GetImplementation(actor) ); + GetImplementation(*this).Remove(GetImplementation(actor)); } Size Scene::GetSize() const @@ -79,9 +77,9 @@ Size Scene::GetSize() const return GetImplementation(*this).GetSize(); } -void Scene::SetDpi( Vector2 dpi ) +void Scene::SetDpi(Vector2 dpi) { - GetImplementation(*this).SetDpi( dpi ); + GetImplementation(*this).SetDpi(dpi); } Vector2 Scene::GetDpi() const @@ -89,9 +87,9 @@ Vector2 Scene::GetDpi() const return GetImplementation(*this).GetDpi(); } -void Scene::SetBackgroundColor( const Vector4& color ) +void Scene::SetBackgroundColor(const Vector4& color) { - GetImplementation(*this).SetBackgroundColor( color ); + GetImplementation(*this).SetBackgroundColor(color); } Vector4 Scene::GetBackgroundColor() const @@ -101,7 +99,7 @@ Vector4 Scene::GetBackgroundColor() const RenderTaskList Scene::GetRenderTaskList() const { - return RenderTaskList( &GetImplementation(*this).GetRenderTaskList() ); + return RenderTaskList(&GetImplementation(*this).GetRenderTaskList()); } Layer Scene::GetRootLayer() const @@ -114,19 +112,19 @@ uint32_t Scene::GetLayerCount() const return GetImplementation(*this).GetLayerCount(); } -Layer Scene::GetLayer( uint32_t depth ) const +Layer Scene::GetLayer(uint32_t depth) const { - return GetImplementation(*this).GetLayer( depth ); + return GetImplementation(*this).GetLayer(depth); } -void Scene::SurfaceResized( float width, float height ) +void Scene::SurfaceResized(float width, float height) { - GetImplementation( *this ).SurfaceResized( width, height ); + GetImplementation(*this).SurfaceResized(width, height); } void Scene::SurfaceReplaced() { - GetImplementation( *this ).SurfaceReplaced(); + GetImplementation(*this).SurfaceReplaced(); } void Scene::Discard() @@ -134,14 +132,14 @@ void Scene::Discard() GetImplementation(*this).Discard(); } -Integration::Scene Scene::Get( Actor actor ) +Integration::Scene Scene::Get(Actor actor) { - return Dali::Integration::Scene( &GetImplementation( actor ).GetScene() ); + return Dali::Integration::Scene(&GetImplementation(actor).GetScene()); } -void Scene::QueueEvent( const Integration::Event& event ) +void Scene::QueueEvent(const Integration::Event& event) { - GetImplementation(*this).QueueEvent( event ); + GetImplementation(*this).QueueEvent(event); } void Scene::ProcessEvents() @@ -149,24 +147,24 @@ void Scene::ProcessEvents() GetImplementation(*this).ProcessEvents(); } -void Scene::AddFrameRenderedCallback( std::unique_ptr< CallbackBase > callback, int32_t frameId ) +void Scene::AddFrameRenderedCallback(std::unique_ptr callback, int32_t frameId) { - GetImplementation( *this ).AddFrameRenderedCallback( std::move( callback ), frameId ); + GetImplementation(*this).AddFrameRenderedCallback(std::move(callback), frameId); } -void Scene::AddFramePresentedCallback( std::unique_ptr< CallbackBase > callback, int32_t frameId ) +void Scene::AddFramePresentedCallback(std::unique_ptr callback, int32_t frameId) { - GetImplementation( *this ).AddFramePresentedCallback( std::move( callback ), frameId ); + GetImplementation(*this).AddFramePresentedCallback(std::move(callback), frameId); } -void Scene::GetFrameRenderedCallback( FrameCallbackContainer& callbacks ) +void Scene::GetFrameRenderedCallback(FrameCallbackContainer& callbacks) { - GetImplementation( *this ).GetFrameRenderedCallback( callbacks ); + GetImplementation(*this).GetFrameRenderedCallback(callbacks); } -void Scene::GetFramePresentedCallback( FrameCallbackContainer& callbacks ) +void Scene::GetFramePresentedCallback(FrameCallbackContainer& callbacks) { - GetImplementation( *this ).GetFramePresentedCallback( callbacks ); + GetImplementation(*this).GetFramePresentedCallback(callbacks); } Scene::EventProcessingFinishedSignalType& Scene::EventProcessingFinishedSignal() @@ -194,6 +192,6 @@ Scene::WheelEventSignalType& Scene::WheelEventSignal() return GetImplementation(*this).WheelEventSignal(); } -} // Integration +} // namespace Integration -} // Dali +} // namespace Dali diff --git a/dali/integration-api/scene.h b/dali/integration-api/scene.h index 6225563..7d97dd3 100644 --- a/dali/integration-api/scene.h +++ b/dali/integration-api/scene.h @@ -22,14 +22,13 @@ #include // INTERNAL INCLUDES -#include +#include #include #include -#include +#include namespace Dali { - class Actor; class KeyEvent; class Layer; @@ -39,12 +38,11 @@ class WheelEvent; namespace Internal DALI_INTERNAL { - class Scene; +class Scene; } namespace Integration { - struct Event; /** @@ -56,13 +54,13 @@ struct Event; class DALI_CORE_API Scene : public BaseHandle { public: - using EventProcessingFinishedSignalType = Signal; ///< Event Processing finished signal type - using KeyEventSignalType = Signal; ///< Key event signal type - using KeyEventGeneratedSignalType = Signal; ///< key event generated signal type - using TouchEventSignalType = Signal; ///< Touch signal type - using WheelEventSignalType = Signal; ///< WheelEvent signal type + using EventProcessingFinishedSignalType = Signal; ///< Event Processing finished signal type + using KeyEventSignalType = Signal; ///< Key event signal type + using KeyEventGeneratedSignalType = Signal; ///< key event generated signal type + using TouchEventSignalType = Signal; ///< Touch signal type + using WheelEventSignalType = Signal; ///< WheelEvent signal type - using FrameCallbackContainer = std::vector< std::pair< std::unique_ptr< CallbackBase >, int32_t > >; + using FrameCallbackContainer = std::vector, int32_t> >; /** * @brief Create an initialized Scene handle. @@ -71,7 +69,7 @@ public: * * @return a handle to a newly allocated Dali resource. */ - static Scene New( Size size ); + static Scene New(Size size); /** * @brief Downcast an Object handle to Scene handle. @@ -81,7 +79,7 @@ public: * @param[in] handle to An object * @return handle to a Scene object or an uninitialized handle */ - static Scene DownCast( BaseHandle handle ); + static Scene DownCast(BaseHandle handle); /** * @brief Create an uninitialized Scene handle. @@ -146,7 +144,7 @@ public: * Sets horizontal and vertical pixels per inch value that is used by the display * @param[in] dpi Horizontal and vertical dpi value */ - void SetDpi( Vector2 dpi ); + void SetDpi(Vector2 dpi); /** * @brief Retrieves the DPI of the display device to which the scene is connected. @@ -160,7 +158,7 @@ public: * * @param[in] color The new background color */ - void SetBackgroundColor( const Vector4& color ); + void SetBackgroundColor(const Vector4& color); /** * @brief Gets the background color of the render surface. @@ -198,7 +196,7 @@ public: * @return The layer found at the given depth * @pre Depth is less than layer count; see GetLayerCount(). */ - Layer GetLayer( uint32_t depth ) const; + Layer GetLayer(uint32_t depth) const; /** * @brief Informs the scene that the set surface has been resized. @@ -206,7 +204,7 @@ public: * @param[in] width The new width of the set surface * @param[in] height The new height of the set surface */ - void SurfaceResized( float width, float height ); + void SurfaceResized(float width, float height); /** * @brief Informs the scene that the surface has been replaced. @@ -222,13 +220,13 @@ public: * @brief Retrieve the Scene that the given actor belongs to. * @return The Scene. */ - static Integration::Scene Get( Actor actor ); + static Integration::Scene Get(Actor actor); /** * This function is called when an event is queued. * @param[in] event A event to queue. */ - void QueueEvent( const Integration::Event& event ); + void QueueEvent(const Integration::Event& event); /** * This function is called by Core when events are processed. @@ -249,7 +247,7 @@ public: * * @note Ownership of the callback is passed onto this class. */ - void AddFrameRenderedCallback( std::unique_ptr< CallbackBase > callback, int32_t frameId ); + void AddFrameRenderedCallback(std::unique_ptr callback, int32_t frameId); /** * @brief Adds a callback that is called when the frame is displayed on the display. @@ -265,7 +263,7 @@ public: * * @note Ownership of the callback is passed onto this class. */ - void AddFramePresentedCallback( std::unique_ptr< CallbackBase > callback, int32_t frameId ); + void AddFramePresentedCallback(std::unique_ptr callback, int32_t frameId); /** * @brief Gets the callback list that is called when the frame rendering is done by the graphics driver. @@ -274,7 +272,7 @@ public: * * @note This is called in the update thread. */ - void GetFrameRenderedCallback( FrameCallbackContainer& callbacks ); + void GetFrameRenderedCallback(FrameCallbackContainer& callbacks); /** * @brief Gets the callback list that is called when the frame is displayed on the display. @@ -283,7 +281,7 @@ public: * * @note This is called in the update thread. */ - void GetFramePresentedCallback( FrameCallbackContainer& callbacks ); + void GetFramePresentedCallback(FrameCallbackContainer& callbacks); /** * @brief This signal is emitted just after the event processing is finished. @@ -348,7 +346,6 @@ public: WheelEventSignalType& WheelEventSignal(); public: // Not intended for application developers - /** * @brief This constructor is used by Dali::New() methods. * diff --git a/dali/integration-api/trace.cpp b/dali/integration-api/trace.cpp index b11777a..ac923a8 100644 --- a/dali/integration-api/trace.cpp +++ b/dali/integration-api/trace.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -19,32 +19,29 @@ #include // EXTERNAL INCLUDES -#include #include +#include namespace Dali { - namespace Integration { - namespace Trace { - thread_local LogContextFunction gThreadLocalLogContextFunction = nullptr; -void InstallLogContextFunction( const LogContextFunction& logContextFunction ) +void InstallLogContextFunction(const LogContextFunction& logContextFunction) { gThreadLocalLogContextFunction = logContextFunction; } -void LogContext( bool start, const char* tag ) +void LogContext(bool start, const char* tag) { - if ( !gThreadLocalLogContextFunction ) + if(!gThreadLocalLogContextFunction) { return; } - gThreadLocalLogContextFunction( start, tag ); + gThreadLocalLogContextFunction(start, tag); } #ifdef TRACE_ENABLED @@ -54,34 +51,34 @@ typedef std::list::iterator FilterIter; namespace { - static FilterList* GetActiveFilters() - { - static FilterList* activeFilters = new FilterList; - return activeFilters; - } +static FilterList* GetActiveFilters() +{ + static FilterList* activeFilters = new FilterList; + return activeFilters; } +} // namespace -Filter* Filter::New( bool trace, const char * environmentVariableName ) +Filter* Filter::New(bool trace, const char* environmentVariableName) { - char * environmentVariableValue = getenv( environmentVariableName ); - if ( environmentVariableValue ) + char* environmentVariableValue = getenv(environmentVariableName); + if(environmentVariableValue) { - char envTraceString( 0 ); - sscanf( environmentVariableValue, "%c", &envTraceString ); + char envTraceString(0); + sscanf(environmentVariableValue, "%c", &envTraceString); // Just use 'f' and 't' as it's faster than doing full string comparisons - if ( envTraceString == 't' ) + if(envTraceString == 't') { trace = true; } - else if ( envTraceString == 'f' ) + else if(envTraceString == 'f') { trace = false; } } - Filter* filter = new Filter( trace ); - GetActiveFilters()->push_back( filter ); + Filter* filter = new Filter(trace); + GetActiveFilters()->push_back(filter); return filter; } @@ -90,7 +87,7 @@ Filter* Filter::New( bool trace, const char * environmentVariableName ) */ void Filter::EnableGlobalTrace() { - for( FilterIter iter = GetActiveFilters()->begin(); iter != GetActiveFilters()->end(); iter++ ) + for(FilterIter iter = GetActiveFilters()->begin(); iter != GetActiveFilters()->end(); iter++) { (*iter)->EnableTrace(); } @@ -101,7 +98,7 @@ void Filter::EnableGlobalTrace() */ void Filter::DisableGlobalTrace() { - for( FilterIter iter = GetActiveFilters()->begin(); iter != GetActiveFilters()->end(); iter++ ) + for(FilterIter iter = GetActiveFilters()->begin(); iter != GetActiveFilters()->end(); iter++) { (*iter)->DisableTrace(); } @@ -110,29 +107,29 @@ void Filter::DisableGlobalTrace() /** * Begin Trace */ -void Filter::BeginTrace( const char* tagName ) +void Filter::BeginTrace(const char* tagName) { - Dali::Integration::Trace::LogContext( true, tagName ); + Dali::Integration::Trace::LogContext(true, tagName); } /** * End Trace */ -void Filter::EndTrace( const char* tagName ) +void Filter::EndTrace(const char* tagName) { - Dali::Integration::Trace::LogContext( false, tagName ); + Dali::Integration::Trace::LogContext(false, tagName); } /** * Tracer Constructor */ -Tracer::Tracer( Filter* filter, const char* tag ) -: mTag( tag ), - mFilter( filter ) +Tracer::Tracer(Filter* filter, const char* tag) +: mTag(tag), + mFilter(filter) { - if( mFilter && mFilter->IsTraceEnabled() ) + if(mFilter && mFilter->IsTraceEnabled()) { - mFilter->BeginTrace( mTag ); + mFilter->BeginTrace(mTag); } } @@ -141,16 +138,16 @@ Tracer::Tracer( Filter* filter, const char* tag ) */ Tracer::~Tracer() { - if( mFilter && mFilter->IsTraceEnabled() ) + if(mFilter && mFilter->IsTraceEnabled()) { - mFilter->EndTrace( mTag ); + mFilter->EndTrace(mTag); } } #endif //TRACE_ENABLED -} // Trace +} // namespace Trace -} // Integration +} // namespace Integration -} // Dali +} // namespace Dali diff --git a/dali/integration-api/trace.h b/dali/integration-api/trace.h index d9faf9f..b0ad6d8 100644 --- a/dali/integration-api/trace.h +++ b/dali/integration-api/trace.h @@ -2,7 +2,7 @@ #define DALI_INTEGRATION_TRACE_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -26,24 +26,21 @@ namespace Dali { - namespace Integration { - namespace Trace { - /** * Used by tracing macros to log a context message * @param start a bool to indicate start (true) or end (false) of the tracing / logging * @param tag a unique event tag name */ -DALI_CORE_API void LogContext( bool start, const char* tag ); +DALI_CORE_API void LogContext(bool start, const char* tag); /** * typedef for the LogContextFunction function. */ -using LogContextFunction = void ( * )( bool, const char* ); +using LogContextFunction = void (*)(bool, const char*); /** * A LogContextFunction function has to be installed for every thread that wants to use tracing. @@ -51,7 +48,7 @@ using LogContextFunction = void ( * )( bool, const char* ); * The LogContextFunction function can be different for each thread. * @param LogContextFunction the Log Context function to install */ -DALI_CORE_API void InstallLogContextFunction( const LogContextFunction& logContextFunction ); +DALI_CORE_API void InstallLogContextFunction(const LogContextFunction& logContextFunction); /******************************************************************************** * Filter * @@ -69,22 +66,30 @@ DALI_CORE_API void InstallLogContextFunction( const LogContextFunction& logConte class DALI_CORE_API Filter { public: - /** * Test if trace is enabled for this filter. * @return true if trace is enabled; */ - inline bool IsTraceEnabled() { return mTraceEnabled; } + inline bool IsTraceEnabled() + { + return mTraceEnabled; + } /** * Enable tracing on this filter. */ - inline void EnableTrace() { mTraceEnabled = true; } + inline void EnableTrace() + { + mTraceEnabled = true; + } /** * Disable tracing on this filter. */ - inline void DisableTrace() { mTraceEnabled = false; } + inline void DisableTrace() + { + mTraceEnabled = false; + } /** * Create a new filter whose trace can be modified through the use of an environment variable. @@ -104,19 +109,19 @@ public: * TRACE_ENV=0 dali-demo // Trace OFF * @endcode */ - static Filter* New( bool trace, const char * environmentVariableName ); + static Filter* New(bool trace, const char* environmentVariableName); /** * Begin trace. * @param[in] tagName - a unique event tag name. */ - void BeginTrace( const char* tagName ); + void BeginTrace(const char* tagName); /** * End trace. * @param[in] tagName - a unique event tag name. */ - void EndTrace( const char* tagName ); + void EndTrace(const char* tagName); /** * Enable trace on all filters. @@ -129,12 +134,14 @@ public: static void DisableGlobalTrace(); private: - /** * Constructor. * @param[in] trace - whether this filter allows tracing. */ - Filter( bool trace ) : mTraceEnabled( trace ) {} + Filter(bool trace) + : mTraceEnabled(trace) + { + } private: bool mTraceEnabled; @@ -156,12 +163,12 @@ private: class DALI_CORE_API Tracer final { public: - Tracer( Filter* filter, const char* tag ); + Tracer(Filter* filter, const char* tag); ~Tracer(); public: const char* mTag; - Filter* mFilter; + Filter* mFilter; }; /** @@ -176,50 +183,56 @@ public: * Initialization of trace filter * @ref Filter::New */ -#define DALI_INIT_TRACE_FILTER( name, environmentVariableName, enable ) \ -namespace \ -{ \ - Dali::Integration::Trace::Filter* name = Dali::Integration::Trace::Filter::New( enable, #environmentVariableName ); \ -} +#define DALI_INIT_TRACE_FILTER(name, environmentVariableName, enable) \ + namespace \ + { \ + Dali::Integration::Trace::Filter* name = Dali::Integration::Trace::Filter::New(enable, #environmentVariableName); \ + } /** * Start of tracing */ -#define DALI_TRACE_BEGIN( filter, tag ) \ - if( filter && filter->IsTraceEnabled() ) { filter->BeginTrace( tag ); } +#define DALI_TRACE_BEGIN(filter, tag) \ + if(filter && filter->IsTraceEnabled()) \ + { \ + filter->BeginTrace(tag); \ + } /** * End of tracing */ -#define DALI_TRACE_END( filter, tag ) \ - if( filter && filter->IsTraceEnabled() ) { filter->EndTrace( tag ); } +#define DALI_TRACE_END(filter, tag) \ + if(filter && filter->IsTraceEnabled()) \ + { \ + filter->EndTrace(tag); \ + } /** * Used for function tracing. It logs tracing of the fuction from start to end. */ -#define DALI_TRACE_FUNCTION( filter ) \ - Dali::Integration::Trace::Tracer logTraceFunction( filter, ASSERT_LOCATION ); +#define DALI_TRACE_FUNCTION(filter) \ + Dali::Integration::Trace::Tracer logTraceFunction(filter, ASSERT_LOCATION); /** * Used for scope tracing. It logs tracing around a scope. */ -#define DALI_TRACE_SCOPE( filter, tag ) \ - Dali::Integration::Trace::Tracer logTracerScope( filter, tag ); +#define DALI_TRACE_SCOPE(filter, tag) \ + Dali::Integration::Trace::Tracer logTracerScope(filter, tag); #else // TRACE_ENABLED -#define DALI_INIT_TRACE_FILTER( name, tag, enable ) -#define DALI_TRACE_BEGIN( filter, tag ) -#define DALI_TRACE_END( filter, tag ) -#define DALI_TRACE_FUNCTION( filter ) -#define DALI_TRACE_SCOPE( filter, tag ) +#define DALI_INIT_TRACE_FILTER(name, tag, enable) +#define DALI_TRACE_BEGIN(filter, tag) +#define DALI_TRACE_END(filter, tag) +#define DALI_TRACE_FUNCTION(filter) +#define DALI_TRACE_SCOPE(filter, tag) #endif -} // Trace +} // namespace Trace -} // Integration +} // namespace Integration -} // Dali +} // namespace Dali #endif // DALI_INTEGRATION_TRACE_H diff --git a/dali/public-api/actors/actor-enumerations.h b/dali/public-api/actors/actor-enumerations.h index 7b82148..5d51597 100644 --- a/dali/public-api/actors/actor-enumerations.h +++ b/dali/public-api/actors/actor-enumerations.h @@ -2,7 +2,7 @@ #define DALI_ACTOR_ENUMERATIONS_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -46,17 +46,16 @@ enum ColorMode */ namespace Dimension { - /** * @brief Enumeration for Dimension types. * @SINCE_1_0.0 */ enum Type { - WIDTH = 0x1, ///< Width dimension @SINCE_1_0.0 - HEIGHT = 0x2, ///< Height dimension @SINCE_1_0.0 + WIDTH = 0x1, ///< Width dimension @SINCE_1_0.0 + HEIGHT = 0x2, ///< Height dimension @SINCE_1_0.0 - ALL_DIMENSIONS = 0x3 ///< Mask to cover all flags @SINCE_1_0.0 + ALL_DIMENSIONS = 0x3 ///< Mask to cover all flags @SINCE_1_0.0 }; /** @@ -65,7 +64,7 @@ enum Type */ enum Meta { - DIMENSION_COUNT = 2 ///< Number of dimensions - update this if adding new dimension @SINCE_1_0.0 + DIMENSION_COUNT = 2 ///< Number of dimensions - update this if adding new dimension @SINCE_1_0.0 }; } // namespace Dimension @@ -76,21 +75,20 @@ enum Meta */ namespace ResizePolicy { - /** * @brief Enumeration for ResizePolicy types. * @SINCE_1_0.0 */ enum Type { - FIXED, ///< Size is fixed as set by SetSize @SINCE_1_0.0 - USE_NATURAL_SIZE, ///< Size is to use the actor's natural size @SINCE_1_0.0 @see Actor::GetNaturalSize() - FILL_TO_PARENT, ///< Size is to fill up to the actor's parent's bounds. Aspect ratio is not maintained. @SINCE_1_0.0 - SIZE_RELATIVE_TO_PARENT, ///< The actors size will be ( ParentSize * SizeRelativeToParentFactor ). @SINCE_1_0.0 - SIZE_FIXED_OFFSET_FROM_PARENT, ///< The actors size will be ( ParentSize + SizeRelativeToParentFactor ). @SINCE_1_0.0 - FIT_TO_CHILDREN, ///< Size will adjust to wrap around all children @SINCE_1_0.0 - DIMENSION_DEPENDENCY, ///< One dimension is dependent on the other @SINCE_1_0.0 - USE_ASSIGNED_SIZE ///< The size will be assigned to the actor @SINCE_1_0.0 + FIXED, ///< Size is fixed as set by SetSize @SINCE_1_0.0 + USE_NATURAL_SIZE, ///< Size is to use the actor's natural size @SINCE_1_0.0 @see Actor::GetNaturalSize() + FILL_TO_PARENT, ///< Size is to fill up to the actor's parent's bounds. Aspect ratio is not maintained. @SINCE_1_0.0 + SIZE_RELATIVE_TO_PARENT, ///< The actors size will be ( ParentSize * SizeRelativeToParentFactor ). @SINCE_1_0.0 + SIZE_FIXED_OFFSET_FROM_PARENT, ///< The actors size will be ( ParentSize + SizeRelativeToParentFactor ). @SINCE_1_0.0 + FIT_TO_CHILDREN, ///< Size will adjust to wrap around all children @SINCE_1_0.0 + DIMENSION_DEPENDENCY, ///< One dimension is dependent on the other @SINCE_1_0.0 + USE_ASSIGNED_SIZE ///< The size will be assigned to the actor @SINCE_1_0.0 }; const Type DEFAULT = USE_NATURAL_SIZE; ///< Default resize policy @@ -102,16 +100,15 @@ const Type DEFAULT = USE_NATURAL_SIZE; ///< Default resize policy */ namespace SizeScalePolicy { - /** * @brief Enumeration for SizeScalePolicy types. * @SINCE_1_0.0 */ enum Type { - USE_SIZE_SET, ///< Use the size that was set @SINCE_1_0.0 - FIT_WITH_ASPECT_RATIO, ///< Fit within the size set maintaining natural size aspect ratio @SINCE_1_0.0 - FILL_WITH_ASPECT_RATIO ///< Fill up the size set maintaining natural size aspect ratio. May exceed size bounds in one dimension. @SINCE_1_0.0 + USE_SIZE_SET, ///< Use the size that was set @SINCE_1_0.0 + FIT_WITH_ASPECT_RATIO, ///< Fit within the size set maintaining natural size aspect ratio @SINCE_1_0.0 + FILL_WITH_ASPECT_RATIO ///< Fill up the size set maintaining natural size aspect ratio. May exceed size bounds in one dimension. @SINCE_1_0.0 }; } // namespace SizeScalePolicy @@ -122,16 +119,15 @@ enum Type */ namespace HorizontalAlignment { - /** * @brief Enumeration for HorizontalAlignment types. * @SINCE_1_0.0 */ enum Type { - LEFT, ///< Align horizontally left @SINCE_1_0.0 - CENTER, ///< Align horizontally center @SINCE_1_0.0 - RIGHT ///< Align horizontally right @SINCE_1_0.0 + LEFT, ///< Align horizontally left @SINCE_1_0.0 + CENTER, ///< Align horizontally center @SINCE_1_0.0 + RIGHT ///< Align horizontally right @SINCE_1_0.0 }; } // namespace HorizontalAlignment @@ -142,16 +138,15 @@ enum Type */ namespace VerticalAlignment { - /** * @brief Enumeration for VerticalAlignment types. * @SINCE_1_0.0 */ enum Type { - TOP, ///< Align vertically top @SINCE_1_0.0 - CENTER, ///< Align vertically center @SINCE_1_0.0 - BOTTOM ///< Align vertically bottom @SINCE_1_0.0 + TOP, ///< Align vertically top @SINCE_1_0.0 + CENTER, ///< Align vertically center @SINCE_1_0.0 + BOTTOM ///< Align vertically bottom @SINCE_1_0.0 }; } // namespace VerticalAlignment @@ -168,9 +163,9 @@ namespace ClippingMode */ enum Type { - DISABLED, ///< This Actor will not clip its children. @SINCE_1_2_5 - CLIP_CHILDREN, ///< This Actor will clip itself and all children to within the pixel areas of this actors renderers. @SINCE_1_2_5 - CLIP_TO_BOUNDING_BOX ///< This Actor will clip itself and all children to within a screen-aligned rectangle encompassing its boundaries. @SINCE_1_2.61 + DISABLED, ///< This Actor will not clip its children. @SINCE_1_2_5 + CLIP_CHILDREN, ///< This Actor will clip itself and all children to within the pixel areas of this actors renderers. @SINCE_1_2_5 + CLIP_TO_BOUNDING_BOX ///< This Actor will clip itself and all children to within a screen-aligned rectangle encompassing its boundaries. @SINCE_1_2.61 }; } // namespace ClippingMode @@ -181,15 +176,14 @@ enum Type */ namespace LayoutDirection { - /** * @brief Enumeration for the LayoutDirection types. * @SINCE_1_2.60 */ enum Type { - LEFT_TO_RIGHT, ///< Layout direction is from Left to Right direction. @SINCE_1_2.60 - RIGHT_TO_LEFT ///< Layout direction is from Right to Left direction. @SINCE_1_2.60 + LEFT_TO_RIGHT, ///< Layout direction is from Left to Right direction. @SINCE_1_2.60 + RIGHT_TO_LEFT ///< Layout direction is from Right to Left direction. @SINCE_1_2.60 }; } // namespace LayoutDirection diff --git a/dali/public-api/actors/actor.cpp b/dali/public-api/actors/actor.cpp index b3e8cf7..ee06114 100644 --- a/dali/public-api/actors/actor.cpp +++ b/dali/public-api/actors/actor.cpp @@ -27,13 +27,12 @@ #include #include -#include #include +#include #include namespace Dali { - Actor::Actor() { } @@ -45,9 +44,9 @@ Actor Actor::New() return Actor(internal.Get()); } -Actor Actor::DownCast( BaseHandle handle ) +Actor Actor::DownCast(BaseHandle handle) { - return Actor( dynamic_cast(handle.GetObjectPtr()) ); + return Actor(dynamic_cast(handle.GetObjectPtr())); } Actor::~Actor() @@ -58,9 +57,9 @@ Actor::Actor(const Actor& copy) = default; Actor& Actor::operator=(const Actor& rhs) = default; -Actor::Actor( Actor&& rhs ) = default; +Actor::Actor(Actor&& rhs) = default; -Actor& Actor::operator=( Actor&& rhs ) = default; +Actor& Actor::operator=(Actor&& rhs) = default; Layer Actor::GetLayer() { @@ -87,22 +86,22 @@ uint32_t Actor::GetChildCount() const return GetImplementation(*this).GetChildCount(); } -Actor Actor::GetChildAt( uint32_t index ) const +Actor Actor::GetChildAt(uint32_t index) const { - Internal::ActorPtr child = GetImplementation(*this).GetChildAt( index ); - return Actor( child.Get() ); + Internal::ActorPtr child = GetImplementation(*this).GetChildAt(index); + return Actor(child.Get()); } Actor Actor::FindChildByName(const std::string& actorName) { - Internal::ActorPtr child = GetImplementation(*this).FindChildByName( actorName ); - return Actor( child.Get() ); + Internal::ActorPtr child = GetImplementation(*this).FindChildByName(actorName); + return Actor(child.Get()); } -Actor Actor::FindChildById( const uint32_t id ) +Actor Actor::FindChildById(const uint32_t id) { - Internal::ActorPtr child = GetImplementation(*this).FindChildById( id ); - return Actor( child.Get() ); + Internal::ActorPtr child = GetImplementation(*this).FindChildById(id); + return Actor(child.Get()); } Actor Actor::GetParent() const @@ -149,62 +148,62 @@ bool Actor::ScreenToLocal(float& localX, float& localY, float screenX, float scr void Actor::Raise() { - GetImplementation( *this ).Raise(); + GetImplementation(*this).Raise(); } void Actor::Lower() { - GetImplementation( *this ).Lower(); + GetImplementation(*this).Lower(); } void Actor::RaiseToTop() { - GetImplementation( *this ).RaiseToTop(); + GetImplementation(*this).RaiseToTop(); } void Actor::LowerToBottom() { - GetImplementation( *this ).LowerToBottom(); + GetImplementation(*this).LowerToBottom(); } -void Actor::RaiseAbove( Actor target ) +void Actor::RaiseAbove(Actor target) { - GetImplementation( *this ).RaiseAbove( GetImplementation( target ) ); + GetImplementation(*this).RaiseAbove(GetImplementation(target)); } -void Actor::LowerBelow( Actor target ) +void Actor::LowerBelow(Actor target) { - GetImplementation( *this ).LowerBelow( GetImplementation( target ) ); + GetImplementation(*this).LowerBelow(GetImplementation(target)); } -void Actor::SetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ) +void Actor::SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension) { - GetImplementation(*this).SetResizePolicy( policy, dimension ); + GetImplementation(*this).SetResizePolicy(policy, dimension); } -ResizePolicy::Type Actor::GetResizePolicy( Dimension::Type dimension ) const +ResizePolicy::Type Actor::GetResizePolicy(Dimension::Type dimension) const { - return GetImplementation(*this).GetResizePolicy( dimension ); + return GetImplementation(*this).GetResizePolicy(dimension); } -float Actor::GetHeightForWidth( float width ) +float Actor::GetHeightForWidth(float width) { - return GetImplementation(*this).GetHeightForWidth( width ); + return GetImplementation(*this).GetHeightForWidth(width); } -float Actor::GetWidthForHeight( float height ) +float Actor::GetWidthForHeight(float height) { - return GetImplementation(*this).GetWidthForHeight( height ); + return GetImplementation(*this).GetWidthForHeight(height); } -float Actor::GetRelayoutSize( Dimension::Type dimension ) const +float Actor::GetRelayoutSize(Dimension::Type dimension) const { - return GetImplementation(*this).GetRelayoutSize( dimension ); + return GetImplementation(*this).GetRelayoutSize(dimension); } Actor::TouchEventSignalType& Actor::TouchedSignal() { - return GetImplementation( *this ).TouchedSignal(); + return GetImplementation(*this).TouchedSignal(); } Actor::HoverSignalType& Actor::HoveredSignal() @@ -227,9 +226,9 @@ Actor::OffSceneSignalType& Actor::OffSceneSignal() return GetImplementation(*this).OffSceneSignal(); } -uint32_t Actor::AddRenderer( Renderer& renderer ) +uint32_t Actor::AddRenderer(Renderer& renderer) { - return GetImplementation(*this).AddRenderer( GetImplementation( renderer ) ); + return GetImplementation(*this).AddRenderer(GetImplementation(renderer)); } uint32_t Actor::GetRendererCount() const @@ -237,20 +236,20 @@ uint32_t Actor::GetRendererCount() const return GetImplementation(*this).GetRendererCount(); } -Renderer Actor::GetRendererAt( uint32_t index ) +Renderer Actor::GetRendererAt(uint32_t index) { - Internal::RendererPtr renderer = GetImplementation(*this).GetRendererAt( index ); - return Renderer( renderer.Get() ); + Internal::RendererPtr renderer = GetImplementation(*this).GetRendererAt(index); + return Renderer(renderer.Get()); } -void Actor::RemoveRenderer( Renderer& renderer ) +void Actor::RemoveRenderer(Renderer& renderer) { - GetImplementation(*this).RemoveRenderer( GetImplementation( renderer ) ); + GetImplementation(*this).RemoveRenderer(GetImplementation(renderer)); } -void Actor::RemoveRenderer( uint32_t index ) +void Actor::RemoveRenderer(uint32_t index) { - GetImplementation(*this).RemoveRenderer( index ); + GetImplementation(*this).RemoveRenderer(index); } Actor::OnRelayoutSignalType& Actor::OnRelayoutSignal() @@ -260,7 +259,7 @@ Actor::OnRelayoutSignalType& Actor::OnRelayoutSignal() Actor::LayoutDirectionChangedSignalType& Actor::LayoutDirectionChangedSignal() { - return GetImplementation( *this ).LayoutDirectionChangedSignal(); + return GetImplementation(*this).LayoutDirectionChangedSignal(); } Actor::Actor(Internal::Actor* internal) diff --git a/dali/public-api/actors/actor.h b/dali/public-api/actors/actor.h index da72ad2..71fa8c7 100644 --- a/dali/public-api/actors/actor.h +++ b/dali/public-api/actors/actor.h @@ -19,8 +19,8 @@ */ // EXTERNAL INCLUDES -#include #include // uint32_t +#include // INTERNAL INCLUDES #include @@ -238,7 +238,6 @@ using Padding = Rect; ///< Padding definition @SINCE_1_0.0 class DALI_CORE_API Actor : public Handle { public: - /** * @brief Enumeration for the instance of properties belonging to the Actor class. * @SINCE_1_0.0 @@ -730,13 +729,13 @@ public: // Typedefs - using TouchEventSignalType = Signal; ///< Touch signal type @SINCE_1_1.37 - using HoverSignalType = Signal; ///< Hover signal type @SINCE_1_0.0 - using WheelEventSignalType = Signal; ///< Wheel signal type @SINCE_1_0.0 - using OnSceneSignalType = Signal; ///< Scene connection signal type @SINCE_1_9.24 - using OffSceneSignalType = Signal; ///< Scene disconnection signal type @SINCE_1_9.24 - using OnRelayoutSignalType = Signal; ///< Called when the actor is relaid out @SINCE_1_0.0 - using LayoutDirectionChangedSignalType = Signal; ///< Layout direction changes signal type. @SINCE_1_2.60 + using TouchEventSignalType = Signal; ///< Touch signal type @SINCE_1_1.37 + using HoverSignalType = Signal; ///< Hover signal type @SINCE_1_0.0 + using WheelEventSignalType = Signal; ///< Wheel signal type @SINCE_1_0.0 + using OnSceneSignalType = Signal; ///< Scene connection signal type @SINCE_1_9.24 + using OffSceneSignalType = Signal; ///< Scene disconnection signal type @SINCE_1_9.24 + using OnRelayoutSignalType = Signal; ///< Called when the actor is relaid out @SINCE_1_0.0 + using LayoutDirectionChangedSignalType = Signal; ///< Layout direction changes signal type. @SINCE_1_2.60 // Creation @@ -766,7 +765,7 @@ public: * @param[in] handle to An object * @return handle to a Actor object or an uninitialized handle */ - static Actor DownCast( BaseHandle handle ); + static Actor DownCast(BaseHandle handle); /** * @brief Dali::Actor is intended as a base class. @@ -799,7 +798,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs A reference to the actor to move */ - Actor( Actor&& rhs ); + Actor(Actor&& rhs); /** * @brief Move assignment operator. @@ -808,7 +807,7 @@ public: * @param[in] rhs A reference to the actor to move * @return A reference to this */ - Actor& operator=( Actor&& rhs ); + Actor& operator=(Actor&& rhs); // Containment @@ -875,7 +874,7 @@ public: * @return The actor for the given index or empty handle if children not initialized * @pre The Actor has been initialized. */ - Actor GetChildAt( uint32_t index ) const; + Actor GetChildAt(uint32_t index) const; /** * @brief Search through this actor's hierarchy for an actor with the given name. @@ -897,7 +896,7 @@ public: * @return A handle to the actor if found, or an empty handle if not * @pre The Actor has been initialized. */ - Actor FindChildById( const uint32_t id ); + Actor FindChildById(const uint32_t id); /** * @brief Retrieves the actor's parent. @@ -948,9 +947,9 @@ public: * @param[in] axis The axis of the rotation to combine with the existing orientation * @pre The actor has been initialized. */ - void RotateBy( const Degree& angle, const Vector3& axis ) + void RotateBy(const Degree& angle, const Vector3& axis) { - RotateBy( Radian( angle ), axis ); + RotateBy(Radian(angle), axis); } /** @@ -1042,7 +1041,7 @@ public: * @pre The Actor has been parented. * @pre The target actor is a sibling. */ - void RaiseAbove( Actor target ); + void RaiseAbove(Actor target); /** * @brief Lower the actor to below the target actor. @@ -1053,7 +1052,7 @@ public: * @pre The Actor has been parented. * @pre The target actor is a sibling. */ - void LowerBelow( Actor target ); + void LowerBelow(Actor target); // SIZE NEGOTIATION @@ -1064,7 +1063,7 @@ public: * @param[in] policy The resize policy to use * @param[in] dimension The dimension(s) to set policy for. Can be a bitfield of multiple dimensions */ - void SetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ); + void SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension); /** * @brief Returns the resize policy used for a single dimension. @@ -1073,7 +1072,7 @@ public: * @param[in] dimension The dimension to get policy for * @return Return the dimension resize policy. If more than one dimension is requested, just return the first one found */ - ResizePolicy::Type GetResizePolicy( Dimension::Type dimension ) const; + ResizePolicy::Type GetResizePolicy(Dimension::Type dimension) const; /** * @brief Calculates the height of the actor given a width. @@ -1085,7 +1084,7 @@ public: * @param[in] width Width to use * @return Return the height based on the width */ - float GetHeightForWidth( float width ); + float GetHeightForWidth(float width); /** * @brief Calculates the width of the actor given a height. @@ -1097,7 +1096,7 @@ public: * @param[in] height Height to use * @return Return the width based on the height */ - float GetWidthForHeight( float height ); + float GetWidthForHeight(float height); /** * @brief Returns the value of negotiated dimension for the given dimension. @@ -1106,10 +1105,9 @@ public: * @param[in] dimension The dimension to retrieve * @return Return the value of the negotiated dimension. If more than one dimension is requested, just return the first one found */ - float GetRelayoutSize( Dimension::Type dimension ) const; + float GetRelayoutSize(Dimension::Type dimension) const; public: // Renderer - /** * @brief Adds a renderer to this actor. * @@ -1119,7 +1117,7 @@ public: // Renderer * @pre The renderer must be initialized. * */ - uint32_t AddRenderer( Renderer& renderer ); + uint32_t AddRenderer(Renderer& renderer); /** * @brief Gets the number of renderers on this actor. @@ -1138,7 +1136,7 @@ public: // Renderer * @pre The index must be between 0 and GetRendererCount()-1 * */ - Renderer GetRendererAt( uint32_t index ); + Renderer GetRendererAt(uint32_t index); /** * @brief Removes a renderer from the actor. @@ -1146,7 +1144,7 @@ public: // Renderer * @SINCE_1_0.0 * @param[in] renderer Handle to the renderer that is to be removed */ - void RemoveRenderer( Renderer& renderer ); + void RemoveRenderer(Renderer& renderer); /** * @brief Removes a renderer from the actor by index. @@ -1156,10 +1154,9 @@ public: // Renderer * @pre The index must be between 0 and GetRendererCount()-1 * */ - void RemoveRenderer( uint32_t index ); + void RemoveRenderer(uint32_t index); public: // Signals - /** * @brief This signal is emitted when touch input is received. * @@ -1279,7 +1276,6 @@ public: // Signals LayoutDirectionChangedSignalType& LayoutDirectionChangedSignal(); public: // Not intended for application developers - /// @cond internal /** * @brief This constructor is used by Actor::New() methods. @@ -1299,9 +1295,9 @@ public: // Not intended for application developers * @SINCE_1_0.0 * @param[in,out] actor A handle to an actor, or an empty handle */ -inline void UnparentAndReset( Actor& actor ) +inline void UnparentAndReset(Actor& actor) { - if( actor ) + if(actor) { actor.Unparent(); actor.Reset(); diff --git a/dali/public-api/actors/camera-actor.cpp b/dali/public-api/actors/camera-actor.cpp index f6aa02b..fab6bef 100644 --- a/dali/public-api/actors/camera-actor.cpp +++ b/dali/public-api/actors/camera-actor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -23,18 +23,16 @@ namespace Dali { - CameraActor CameraActor::New() { - Internal::CameraActorPtr internal = Internal::CameraActor::New( Size::ZERO ); + Internal::CameraActorPtr internal = Internal::CameraActor::New(Size::ZERO); return CameraActor(internal.Get()); } - -CameraActor CameraActor::New( const Size& size ) +CameraActor CameraActor::New(const Size& size) { - Internal::CameraActorPtr internal = Internal::CameraActor::New( size ); + Internal::CameraActorPtr internal = Internal::CameraActor::New(size); return CameraActor(internal.Get()); } @@ -44,9 +42,9 @@ CameraActor::CameraActor(Internal::CameraActor* internal) { } -CameraActor CameraActor::DownCast( BaseHandle handle ) +CameraActor CameraActor::DownCast(BaseHandle handle) { - return CameraActor( dynamic_cast(handle.GetObjectPtr()) ); + return CameraActor(dynamic_cast(handle.GetObjectPtr())); } CameraActor::CameraActor() @@ -68,7 +66,7 @@ CameraActor& CameraActor::operator=(const CameraActor& rhs) return *this; } -void CameraActor::SetType( Dali::Camera::Type type ) +void CameraActor::SetType(Dali::Camera::Type type) { GetImplementation(*this).SetType(type); } @@ -78,9 +76,9 @@ Dali::Camera::Type CameraActor::GetType() const return GetImplementation(*this).GetType(); } -void CameraActor::SetProjectionMode( Dali::Camera::ProjectionMode mode ) +void CameraActor::SetProjectionMode(Dali::Camera::ProjectionMode mode) { - GetImplementation(*this).SetProjectionMode( mode ); + GetImplementation(*this).SetProjectionMode(mode); } Dali::Camera::ProjectionMode CameraActor::GetProjectionMode() const @@ -88,47 +86,47 @@ Dali::Camera::ProjectionMode CameraActor::GetProjectionMode() const return GetImplementation(*this).GetProjectionMode(); } -void CameraActor::SetFieldOfView( float fieldOfView ) +void CameraActor::SetFieldOfView(float fieldOfView) { GetImplementation(*this).SetFieldOfView(fieldOfView); } -float CameraActor::GetFieldOfView( ) +float CameraActor::GetFieldOfView() { return GetImplementation(*this).GetFieldOfView(); } -void CameraActor::SetAspectRatio( float aspectRatio ) +void CameraActor::SetAspectRatio(float aspectRatio) { GetImplementation(*this).SetAspectRatio(aspectRatio); } -float CameraActor::GetAspectRatio( ) +float CameraActor::GetAspectRatio() { return GetImplementation(*this).GetAspectRatio(); } -void CameraActor::SetNearClippingPlane( float nearClippingPlane ) +void CameraActor::SetNearClippingPlane(float nearClippingPlane) { GetImplementation(*this).SetNearClippingPlane(nearClippingPlane); } -float CameraActor::GetNearClippingPlane( ) +float CameraActor::GetNearClippingPlane() { return GetImplementation(*this).GetNearClippingPlane(); } -void CameraActor::SetFarClippingPlane( float farClippingPlane ) +void CameraActor::SetFarClippingPlane(float farClippingPlane) { GetImplementation(*this).SetFarClippingPlane(farClippingPlane); } -float CameraActor::GetFarClippingPlane( ) +float CameraActor::GetFarClippingPlane() { return GetImplementation(*this).GetFarClippingPlane(); } -void CameraActor::SetTargetPosition( const Vector3& targetPosition ) +void CameraActor::SetTargetPosition(const Vector3& targetPosition) { GetImplementation(*this).SetTarget(targetPosition); } @@ -148,19 +146,19 @@ bool CameraActor::GetInvertYAxis() return GetImplementation(*this).GetInvertYAxis(); } -void CameraActor::SetPerspectiveProjection( const Size& size ) +void CameraActor::SetPerspectiveProjection(const Size& size) { - GetImplementation(*this).SetPerspectiveProjection( size ); + GetImplementation(*this).SetPerspectiveProjection(size); } -void CameraActor::SetOrthographicProjection( const Vector2& size ) +void CameraActor::SetOrthographicProjection(const Vector2& size) { - GetImplementation(*this).SetOrthographicProjection( size ); + GetImplementation(*this).SetOrthographicProjection(size); } -void CameraActor::SetOrthographicProjection( float left, float right, float top, float bottom, float near, float far ) +void CameraActor::SetOrthographicProjection(float left, float right, float top, float bottom, float near, float far) { - GetImplementation(*this).SetOrthographicProjection( left, right, top, bottom, near, far ); + GetImplementation(*this).SetOrthographicProjection(left, right, top, bottom, near, far); } } // namespace Dali diff --git a/dali/public-api/actors/camera-actor.h b/dali/public-api/actors/camera-actor.h index c1ceef5..25c6db7 100644 --- a/dali/public-api/actors/camera-actor.h +++ b/dali/public-api/actors/camera-actor.h @@ -2,7 +2,7 @@ #define DALI_CAMERA_ACTOR_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -54,8 +54,8 @@ enum Type */ enum ProjectionMode { - PERSPECTIVE_PROJECTION, ///< Distance causes foreshortening; objects further from the camera appear smaller @SINCE_1_0.0 - ORTHOGRAPHIC_PROJECTION, ///< Relative distance from the camera does not affect the size of objects @SINCE_1_0.0 + PERSPECTIVE_PROJECTION, ///< Distance causes foreshortening; objects further from the camera appear smaller @SINCE_1_0.0 + ORTHOGRAPHIC_PROJECTION, ///< Relative distance from the camera does not affect the size of objects @SINCE_1_0.0 }; } // namespace Camera @@ -89,7 +89,6 @@ enum ProjectionMode class DALI_CORE_API CameraActor : public Actor { public: - /** * @brief Enumeration for the instance of properties belonging to the CameraActor class. * @@ -152,7 +151,7 @@ public: * @param[in] size The canvas size * @return The newly created camera actor */ - static CameraActor New( const Size& size ); + static CameraActor New(const Size& size); /** * @brief Downcasts a handle to CameraActor handle. @@ -163,7 +162,7 @@ public: * @param[in] handle to An object * @return Handle to a CameraActor or an uninitialized handle */ - static CameraActor DownCast( BaseHandle handle ); + static CameraActor DownCast(BaseHandle handle); /** * @brief Destructor. @@ -196,7 +195,7 @@ public: * @SINCE_1_0.0 * @param[in] type The camera type */ - void SetType( Dali::Camera::Type type ); + void SetType(Dali::Camera::Type type); /** * @brief Gets the type of the camera. @@ -212,7 +211,7 @@ public: * @SINCE_1_0.0 * @param[in] mode One of PERSPECTIVE_PROJECTION or ORTHOGRAPHIC_PROJECTION */ - void SetProjectionMode( Dali::Camera::ProjectionMode mode ); + void SetProjectionMode(Dali::Camera::ProjectionMode mode); /** * @brief Gets the projection mode. @@ -228,7 +227,7 @@ public: * @SINCE_1_0.0 * @param[in] fieldOfView The field of view in radians */ - void SetFieldOfView( float fieldOfView ); + void SetFieldOfView(float fieldOfView); /** * @brief Gets the field of view in Radians. @@ -237,7 +236,7 @@ public: * @SINCE_1_0.0 * @return The field of view in radians */ - float GetFieldOfView( ); + float GetFieldOfView(); /** * @brief Sets the aspect ratio. @@ -245,7 +244,7 @@ public: * @SINCE_1_0.0 * @param[in] aspectRatio The aspect ratio */ - void SetAspectRatio( float aspectRatio ); + void SetAspectRatio(float aspectRatio); /** * @brief Gets the aspect ratio of the camera. @@ -254,7 +253,7 @@ public: * @SINCE_1_0.0 * @return The aspect ratio */ - float GetAspectRatio( ); + float GetAspectRatio(); /** * @brief Sets the near clipping plane distance. @@ -262,7 +261,7 @@ public: * @SINCE_1_0.0 * @param[in] nearClippingPlane Distance of the near clipping plane */ - void SetNearClippingPlane( float nearClippingPlane ); + void SetNearClippingPlane(float nearClippingPlane); /** * @brief Gets the near clipping plane distance. @@ -272,7 +271,7 @@ public: * @SINCE_1_0.0 * @return The near clipping plane value */ - float GetNearClippingPlane( ); + float GetNearClippingPlane(); /** * @brief Sets the far clipping plane distance. @@ -280,7 +279,7 @@ public: * @SINCE_1_0.0 * @param[in] farClippingPlane Distance of the far clipping plane */ - void SetFarClippingPlane( float farClippingPlane ); + void SetFarClippingPlane(float farClippingPlane); /** * @brief Gets the far clipping plane distance. @@ -289,7 +288,7 @@ public: * @SINCE_1_0.0 * @return The far clipping plane value */ - float GetFarClippingPlane( ); + float GetFarClippingPlane(); /** * @brief Sets the target position of the camera. @@ -298,7 +297,7 @@ public: * @param[in] targetPosition The position of the target to look at * @pre Camera type is LOOK_AT_TARGET. */ - void SetTargetPosition( const Vector3& targetPosition ); + void SetTargetPosition(const Vector3& targetPosition); /** * @brief Gets the Camera Target position. @@ -340,7 +339,7 @@ public: * @note If either of the values of size is 0.0f, then we use the default perspective projection for the size of the scene this actor is added to. * @note This modifies the Z position property of this actor as well. */ - void SetPerspectiveProjection( const Size& size ); + void SetPerspectiveProjection(const Size& size); /** * @brief Sets the camera projection to use orthographic projection. @@ -356,7 +355,7 @@ public: * @SINCE_1_0.0 * @param[in] size Size of XY plane (normal to camera axis) */ - void SetOrthographicProjection( const Size& size ); + void SetOrthographicProjection(const Size& size); /** * @brief Sets the camera projection to use orthographic projection with the given clip planes. @@ -371,7 +370,7 @@ public: * @param[in] near Distance to the near clip plane (along camera axis) * @param[in] far Distance to the far clip plane (along camera axis) */ - void SetOrthographicProjection( float left, float right, float top, float bottom, float near, float far ); + void SetOrthographicProjection(float left, float right, float top, float bottom, float near, float far); public: // Not intended for use by Application developers /// @cond internal diff --git a/dali/public-api/actors/custom-actor-impl.cpp b/dali/public-api/actors/custom-actor-impl.cpp index 292fec7..cd36dbd 100644 --- a/dali/public-api/actors/custom-actor-impl.cpp +++ b/dali/public-api/actors/custom-actor-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -19,24 +19,23 @@ #include // INTERNAL INCLUDES -#include #include +#include namespace Dali { - CustomActor CustomActorImpl::Self() const { return CustomActor(mOwner); } -void CustomActorImpl::OnPropertySet( Property::Index index, const Property::Value& propertyValue ) +void CustomActorImpl::OnPropertySet(Property::Index index, const Property::Value& propertyValue) { } -CustomActorImpl::CustomActorImpl( ActorFlags flags ) +CustomActorImpl::CustomActorImpl(ActorFlags flags) : mOwner(nullptr), - mFlags( flags ) + mFlags(flags) { } @@ -58,7 +57,7 @@ Internal::CustomActor* CustomActorImpl::GetOwner() const bool CustomActorImpl::IsRelayoutEnabled() const { - return ( mFlags & DISABLE_SIZE_NEGOTIATION ) == 0; + return (mFlags & DISABLE_SIZE_NEGOTIATION) == 0; } void CustomActorImpl::RelayoutRequest() @@ -66,24 +65,24 @@ void CustomActorImpl::RelayoutRequest() mOwner->RelayoutRequest(); } -float CustomActorImpl::GetHeightForWidthBase( float width ) +float CustomActorImpl::GetHeightForWidthBase(float width) { - return mOwner->GetHeightForWidthBase( width ); + return mOwner->GetHeightForWidthBase(width); } -float CustomActorImpl::GetWidthForHeightBase( float height ) +float CustomActorImpl::GetWidthForHeightBase(float height) { - return mOwner->GetWidthForHeightBase( height ); + return mOwner->GetWidthForHeightBase(height); } -float CustomActorImpl::CalculateChildSizeBase( const Dali::Actor& child, Dimension::Type dimension ) +float CustomActorImpl::CalculateChildSizeBase(const Dali::Actor& child, Dimension::Type dimension) { - return mOwner->CalculateChildSizeBase( child, dimension ); + return mOwner->CalculateChildSizeBase(child, dimension); } -bool CustomActorImpl::RelayoutDependentOnChildrenBase( Dimension::Type dimension ) +bool CustomActorImpl::RelayoutDependentOnChildrenBase(Dimension::Type dimension) { - return mOwner->RelayoutDependentOnChildrenBase( dimension ); + return mOwner->RelayoutDependentOnChildrenBase(dimension); } } // namespace Dali diff --git a/dali/public-api/actors/custom-actor-impl.h b/dali/public-api/actors/custom-actor-impl.h index a896c16..11bb9e4 100644 --- a/dali/public-api/actors/custom-actor-impl.h +++ b/dali/public-api/actors/custom-actor-impl.h @@ -22,10 +22,10 @@ #include // uint32_t // INTERNAL INCLUDES -#include -#include #include #include +#include +#include namespace Dali { @@ -66,7 +66,6 @@ using CustomActorImplPtr = IntrusivePtr; class DALI_CORE_API CustomActorImpl : public Dali::RefObject { public: - class Extension; ///< Forward declare future extension interface protected: @@ -108,7 +107,7 @@ public: * @endcode * @param[in] depth The depth in the hierarchy for the actor */ - virtual void OnSceneConnection( int32_t depth ) = 0; + virtual void OnSceneConnection(int32_t depth) = 0; /** * @brief Called after the actor has been disconnected from the Scene. @@ -155,7 +154,7 @@ public: * @param[in] index The Property index that was set * @param[in] propertyValue The value to set */ - virtual void OnPropertySet( Property::Index index, const Property::Value& propertyValue ); + virtual void OnPropertySet(Property::Index index, const Property::Value& propertyValue); /** * @brief Called when the owning actor's size is set e.g. using Actor::SetSize(). @@ -190,7 +189,7 @@ public: * @note As this function is called from inside the size negotiation algorithm, you cannot * call RequestRelayout (the call would just be ignored). */ - virtual void OnRelayout( const Vector2& size, RelayoutContainer& container ) = 0; + virtual void OnRelayout(const Vector2& size, RelayoutContainer& container) = 0; /** * @brief Notification for deriving classes. @@ -199,7 +198,7 @@ public: * @param[in] policy The policy being set * @param[in] dimension The dimension the policy is being set for */ - virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension ) = 0; + virtual void OnSetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension) = 0; /** * @brief Returns the natural size of the actor. @@ -217,7 +216,7 @@ public: * @param[in] dimension The dimension to calculate the size for. E.g. width or height * @return Return the calculated size for the given dimension */ - virtual float CalculateChildSize( const Dali::Actor& child, Dimension::Type dimension ) = 0; + virtual float CalculateChildSize(const Dali::Actor& child, Dimension::Type dimension) = 0; /** * @brief This method is called during size negotiation when a height is required for a given width. @@ -228,7 +227,7 @@ public: * @param[in] width Width to use * @return The height based on the width */ - virtual float GetHeightForWidth( float width ) = 0; + virtual float GetHeightForWidth(float width) = 0; /** * @brief This method is called during size negotiation when a width is required for a given height. @@ -239,7 +238,7 @@ public: * @param[in] height Height to use * @return The width based on the width */ - virtual float GetWidthForHeight( float height ) = 0; + virtual float GetWidthForHeight(float height) = 0; /** * @brief Determines if this actor is dependent on its children for relayout. @@ -248,7 +247,7 @@ public: * @param[in] dimension The dimension(s) to check for * @return Return if the actor is dependent on it's children */ - virtual bool RelayoutDependentOnChildren( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ) = 0; + virtual bool RelayoutDependentOnChildren(Dimension::Type dimension = Dimension::ALL_DIMENSIONS) = 0; /** * @brief Virtual method to notify deriving classes that relayout dependencies have been @@ -257,7 +256,7 @@ public: * @SINCE_1_0.0 * @param[in] dimension The dimension that is about to be calculated */ - virtual void OnCalculateRelayoutSize( Dimension::Type dimension ) = 0; + virtual void OnCalculateRelayoutSize(Dimension::Type dimension) = 0; /** * @brief Virtual method to notify deriving classes that the size for a dimension @@ -267,7 +266,7 @@ public: * @param[in] size The new size for the given dimension * @param[in] dimension The dimension that was just negotiated */ - virtual void OnLayoutNegotiated( float size, Dimension::Type dimension ) = 0; + virtual void OnLayoutNegotiated(float size, Dimension::Type dimension) = 0; /** * @brief Retrieves the extension for this control. @@ -281,27 +280,26 @@ public: } protected: // For derived classes - /** * @brief Enumeration for the constructor flags. * @SINCE_1_0.0 */ enum ActorFlags { - ACTOR_BEHAVIOUR_DEFAULT = 0, ///< Use to provide default behaviour (size negotiation is on, event callbacks are not called). @SINCE_1_2_10 - DISABLE_SIZE_NEGOTIATION = 1 << 0, ///< True if control does not need size negotiation, i.e. it can be skipped in the algorithm @SINCE_1_0.0 + ACTOR_BEHAVIOUR_DEFAULT = 0, ///< Use to provide default behaviour (size negotiation is on, event callbacks are not called). @SINCE_1_2_10 + DISABLE_SIZE_NEGOTIATION = 1 << 0, ///< True if control does not need size negotiation, i.e. it can be skipped in the algorithm @SINCE_1_0.0 - LAST_ACTOR_FLAG ///< Special marker for last actor flag @SINCE_1_0.0 + LAST_ACTOR_FLAG ///< Special marker for last actor flag @SINCE_1_0.0 }; - static constexpr int32_t ACTOR_FLAG_COUNT = Log< LAST_ACTOR_FLAG - 1 >::value + 1; ///< Value for deriving classes to continue on the flag enum + static constexpr int32_t ACTOR_FLAG_COUNT = Log::value + 1; ///< Value for deriving classes to continue on the flag enum /** * @brief Creates a CustomActorImpl. * @SINCE_1_0.0 * @param[in] flags Bitfield of ActorFlags to define behaviour */ - CustomActorImpl( ActorFlags flags ); + CustomActorImpl(ActorFlags flags); // Size negotiation helpers @@ -324,7 +322,7 @@ protected: // For derived classes * @param[in] width Width to use * @return The height based on the width */ - float GetHeightForWidthBase( float width ); + float GetHeightForWidthBase(float width); /** * @brief Provides the Actor implementation of GetWidthForHeight. @@ -332,7 +330,7 @@ protected: // For derived classes * @param[in] height Height to use * @return The width based on the height */ - float GetWidthForHeightBase( float height ); + float GetWidthForHeightBase(float height); /** * @brief Calculates the size for a child using the base actor object. @@ -342,7 +340,7 @@ protected: // For derived classes * @param[in] dimension The dimension to calculate the size for. E.g. width or height * @return Return the calculated size for the given dimension. If more than one dimension is requested, just return the first one found */ - float CalculateChildSizeBase( const Dali::Actor& child, Dimension::Type dimension ); + float CalculateChildSizeBase(const Dali::Actor& child, Dimension::Type dimension); /** * @brief Determines if this actor is dependent on its children for relayout from the base class. @@ -351,10 +349,9 @@ protected: // For derived classes * @param[in] dimension The dimension(s) to check for * @return Return if the actor is dependent on it's children */ - bool RelayoutDependentOnChildrenBase( Dimension::Type dimension = Dimension::ALL_DIMENSIONS ); + bool RelayoutDependentOnChildrenBase(Dimension::Type dimension = Dimension::ALL_DIMENSIONS); public: // Not intended for application developers - /** * @brief Initializes a CustomActor. * @SINCE_1_0.0 @@ -384,9 +381,8 @@ public: // Not intended for application developers bool IsRelayoutEnabled() const; private: - - Internal::CustomActor* mOwner; ///< Internal owner of this custom actor implementation - ActorFlags mFlags; ///< ActorFlags flags to determine behaviour + Internal::CustomActor* mOwner; ///< Internal owner of this custom actor implementation + ActorFlags mFlags; ///< ActorFlags flags to determine behaviour }; /** diff --git a/dali/public-api/actors/custom-actor.cpp b/dali/public-api/actors/custom-actor.cpp index c4cc18f..62de9b7 100644 --- a/dali/public-api/actors/custom-actor.cpp +++ b/dali/public-api/actors/custom-actor.cpp @@ -24,10 +24,8 @@ namespace Dali { - namespace { - using namespace Dali; BaseHandle Create() @@ -36,17 +34,17 @@ BaseHandle Create() return BaseHandle(); } -TypeRegistration mType( typeid(Dali::CustomActor), typeid(Dali::Actor), Create ); +TypeRegistration mType(typeid(Dali::CustomActor), typeid(Dali::Actor), Create); -} +} // namespace CustomActor::CustomActor() { } -CustomActor CustomActor::DownCast( BaseHandle handle ) +CustomActor CustomActor::DownCast(BaseHandle handle) { - return CustomActor( dynamic_cast(handle.GetObjectPtr()) ); + return CustomActor(dynamic_cast(handle.GetObjectPtr())); } CustomActor::~CustomActor() @@ -57,9 +55,9 @@ CustomActor::CustomActor(const CustomActor& copy) = default; CustomActor& CustomActor::operator=(const CustomActor& rhs) = default; -CustomActor::CustomActor( CustomActor&& rhs ) = default; +CustomActor::CustomActor(CustomActor&& rhs) = default; -CustomActor& CustomActor::operator=( CustomActor&& rhs ) = default; +CustomActor& CustomActor::operator=(CustomActor&& rhs) = default; CustomActorImpl& CustomActor::GetImplementation() { @@ -91,7 +89,7 @@ CustomActor::CustomActor(Internal::CustomActor* internal) // Without this check, the actor will be deleted a second time, when the handle is disposed of // causing a crash. - if (internal) + if(internal) { DALI_ASSERT_ALWAYS(internal->ReferenceCount() != 1 && "Are you trying to use CustomActorImpl::Self() inside a CustomActorImpl destructor?"); } diff --git a/dali/public-api/actors/custom-actor.h b/dali/public-api/actors/custom-actor.h index 8ab1a3a..5a4a98a 100644 --- a/dali/public-api/actors/custom-actor.h +++ b/dali/public-api/actors/custom-actor.h @@ -43,7 +43,6 @@ class CustomActor; class DALI_CORE_API CustomActor : public Actor { public: - /** * @brief Creates an uninitialized CustomActor handle. * @@ -63,7 +62,7 @@ public: * @param[in] handle Handle to an object * @return Handle to a CustomActor or an uninitialized handle */ - static CustomActor DownCast( BaseHandle handle ); + static CustomActor DownCast(BaseHandle handle); /** * @brief Destructor. @@ -121,7 +120,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs The actor to move */ - CustomActor( CustomActor&& rhs ); + CustomActor(CustomActor&& rhs); /** * @brief Move assignment operator. @@ -130,10 +129,9 @@ public: * @param[in] rhs The actor to move * @return A reference to this */ - CustomActor& operator=( CustomActor&& rhs ); + CustomActor& operator=(CustomActor&& rhs); public: // Not intended for application developers - /** * @brief This constructor is used internally to create additional CustomActor handles. * diff --git a/dali/public-api/actors/draw-mode.h b/dali/public-api/actors/draw-mode.h index a9b9c56..fe0eed5 100644 --- a/dali/public-api/actors/draw-mode.h +++ b/dali/public-api/actors/draw-mode.h @@ -2,7 +2,7 @@ #define DALI_DRAW_MODE_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -34,7 +34,6 @@ namespace Dali */ namespace DrawMode { - /** * @brief Enumeration for the instance of how the actor and it's children will be drawn. * diff --git a/dali/public-api/actors/layer.cpp b/dali/public-api/actors/layer.cpp index 4946570..3da3365 100644 --- a/dali/public-api/actors/layer.cpp +++ b/dali/public-api/actors/layer.cpp @@ -23,7 +23,6 @@ namespace Dali { - using Dali::Layer; Layer::Layer() @@ -37,9 +36,9 @@ Layer Layer::New() return Layer(internal.Get()); } -Layer Layer::DownCast( BaseHandle handle ) +Layer Layer::DownCast(BaseHandle handle) { - return Layer( dynamic_cast(handle.GetObjectPtr()) ); + return Layer(dynamic_cast(handle.GetObjectPtr())); } Layer::~Layer() @@ -50,9 +49,9 @@ Layer::Layer(const Layer& copy) = default; Layer& Layer::operator=(const Layer& rhs) = default; -Layer::Layer( Layer&& rhs ) = default; +Layer::Layer(Layer&& rhs) = default; -Layer& Layer::operator=( Layer&& rhs ) = default; +Layer& Layer::operator=(Layer&& rhs) = default; void Layer::Raise() { @@ -64,14 +63,14 @@ void Layer::Lower() GetImplementation(*this).Lower(); } -void Layer::RaiseAbove( Layer target ) +void Layer::RaiseAbove(Layer target) { - GetImplementation(*this).RaiseAbove( GetImplementation( target ) ); + GetImplementation(*this).RaiseAbove(GetImplementation(target)); } -void Layer::LowerBelow( Layer target ) +void Layer::LowerBelow(Layer target) { - GetImplementation(*this).LowerBelow( GetImplementation( target ) ); + GetImplementation(*this).LowerBelow(GetImplementation(target)); } void Layer::RaiseToTop() @@ -84,14 +83,14 @@ void Layer::LowerToBottom() GetImplementation(*this).LowerToBottom(); } -void Layer::MoveAbove( Layer target ) +void Layer::MoveAbove(Layer target) { - GetImplementation(*this).MoveAbove( GetImplementation( target ) ); + GetImplementation(*this).MoveAbove(GetImplementation(target)); } -void Layer::MoveBelow( Layer target ) +void Layer::MoveBelow(Layer target) { - GetImplementation(*this).MoveBelow( GetImplementation( target ) ); + GetImplementation(*this).MoveBelow(GetImplementation(target)); } void Layer::SetSortFunction(SortFunctionType function) diff --git a/dali/public-api/actors/layer.h b/dali/public-api/actors/layer.h index 5ae894b..13f5328 100644 --- a/dali/public-api/actors/layer.h +++ b/dali/public-api/actors/layer.h @@ -22,10 +22,10 @@ #include // uint32_t // INTERNAL INCLUDES -#include #include #include #include +#include namespace Dali { @@ -85,7 +85,6 @@ using ClippingBox = Rect; class DALI_CORE_API Layer : public Actor { public: - /** * @brief Enumeration for the instance of properties belonging to the Layer class. * @@ -218,7 +217,7 @@ public: * @SINCE_1_0.0 * @param[in] position This is the actor translation from camera */ - using SortFunctionType = float ( * )( const Vector3& ); + using SortFunctionType = float (*)(const Vector3&); /** * @brief Creates an empty Layer handle. @@ -245,7 +244,7 @@ public: * @param[in] handle Handle to an object * @return Handle to a Layer or an uninitialized handle */ - static Layer DownCast( BaseHandle handle ); + static Layer DownCast(BaseHandle handle); /** * @brief Destructor. @@ -278,7 +277,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs The layer to move */ - Layer( Layer&& rhs ); + Layer(Layer&& rhs); /** * @brief Move assignment operator. @@ -287,7 +286,7 @@ public: * @param[in] rhs The layer to move * @return A reference to this */ - Layer& operator=( Layer&& rhs ); + Layer& operator=(Layer&& rhs); /** * @brief Increments the depth of the layer. @@ -316,7 +315,7 @@ public: * @pre Target layer is on the stage. * @note All layers between this layer and target get new depth values. */ - void RaiseAbove( Layer target ); + void RaiseAbove(Layer target); /** * @brief Ensures the layers depth is less than the target layer. @@ -329,7 +328,7 @@ public: * @pre Target layer is on the stage. * @note All layers between this layer and target get new depth values. */ - void LowerBelow( Layer target ); + void LowerBelow(Layer target); /** * @brief Raises the layer to the top. @@ -355,7 +354,7 @@ public: * @pre Target layer is on the stage. * @note All layers between this layer and target get new depth values. */ - void MoveAbove( Layer target ); + void MoveAbove(Layer target); /** * @brief Moves the layer directly below the given layer. @@ -367,7 +366,7 @@ public: * @pre Target layer is on the stage. * @note All layers between this layer and target get new depth values. */ - void MoveBelow( Layer target ); + void MoveBelow(Layer target); // Sorting @@ -391,7 +390,7 @@ public: * layer, then the sort function used by the child layer will also be the same. * */ - void SetSortFunction( SortFunctionType function ); + void SetSortFunction(SortFunctionType function); /** * @brief Retrieves whether the layer consumes hover. @@ -402,7 +401,6 @@ public: bool IsHoverConsumed() const; public: // Not intended for application developers - /// @cond internal /** * @brief This constructor is used by Layer::New() methods. diff --git a/dali/public-api/animation/alpha-function.cpp b/dali/public-api/animation/alpha-function.cpp old mode 100755 new mode 100644 index b5aad8d..8952092 --- a/dali/public-api/animation/alpha-function.cpp +++ b/dali/public-api/animation/alpha-function.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -22,43 +22,48 @@ namespace Dali { - namespace { -constexpr uint32_t BitMaskOfN( uint32_t bits ) +constexpr uint32_t BitMaskOfN(uint32_t bits) { - return ( 1 << bits ) - 1; + return (1 << bits) - 1; } } // unnamed namespace AlphaFunction::AlphaFunction() -:mBezierControlPoints(Vector4::ZERO), - mCustom(nullptr), - mBuiltin(DEFAULT), - mMode(BUILTIN_FUNCTION) -{} +: mBezierControlPoints(Vector4::ZERO), + mCustom(nullptr), + mBuiltin(DEFAULT), + mMode(BUILTIN_FUNCTION) +{ +} -AlphaFunction::AlphaFunction( BuiltinFunction function) -:mBezierControlPoints(Vector4::ZERO), - mCustom(nullptr), - mBuiltin(function), - mMode(BUILTIN_FUNCTION) -{} +AlphaFunction::AlphaFunction(BuiltinFunction function) +: mBezierControlPoints(Vector4::ZERO), + mCustom(nullptr), + mBuiltin(function), + mMode(BUILTIN_FUNCTION) +{ +} -AlphaFunction::AlphaFunction( AlphaFunctionPrototype function) -:mBezierControlPoints(Vector4::ZERO), - mCustom(function), - mBuiltin(DEFAULT), - mMode(CUSTOM_FUNCTION) -{} +AlphaFunction::AlphaFunction(AlphaFunctionPrototype function) +: mBezierControlPoints(Vector4::ZERO), + mCustom(function), + mBuiltin(DEFAULT), + mMode(CUSTOM_FUNCTION) +{ +} -AlphaFunction::AlphaFunction( const Vector2& controlPoint0, const Vector2& controlPoint1 ) -:mBezierControlPoints(Vector4(Clamp(controlPoint0.x,0.0f,1.0f),controlPoint0.y, - Clamp(controlPoint1.x,0.0f,1.0f),controlPoint1.y)), - mCustom(nullptr), - mBuiltin(DEFAULT), - mMode(BEZIER) +AlphaFunction::AlphaFunction(const Vector2& controlPoint0, const Vector2& controlPoint1) +: mBezierControlPoints( + Vector4(Clamp(controlPoint0.x, 0.0f, 1.0f), + controlPoint0.y, + Clamp(controlPoint1.x, 0.0f, 1.0f), + controlPoint1.y)), + mCustom(nullptr), + mBuiltin(DEFAULT), + mMode(BEZIER) { } @@ -74,12 +79,12 @@ AlphaFunctionPrototype AlphaFunction::GetCustomFunction() const AlphaFunction::BuiltinFunction AlphaFunction::GetBuiltinFunction() const { - return static_cast( mBuiltin & BitMaskOfN( Log::value + 1 ) ); + return static_cast(mBuiltin & BitMaskOfN(Log::value + 1)); } AlphaFunction::Mode AlphaFunction::GetMode() const { - return static_cast( mMode & BitMaskOfN( 2 ) ); + return static_cast(mMode & BitMaskOfN(2)); } } // namespace Dali diff --git a/dali/public-api/animation/alpha-function.h b/dali/public-api/animation/alpha-function.h index 3f5ac1a..1ea2677 100644 --- a/dali/public-api/animation/alpha-function.h +++ b/dali/public-api/animation/alpha-function.h @@ -2,7 +2,7 @@ #define DALI_ALPHA_FUNCTION_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -19,8 +19,8 @@ */ // INTERNAL INCLUDES -#include #include +#include #include #include #include @@ -33,7 +33,7 @@ namespace Dali * @{ */ -using AlphaFunctionPrototype = float ( * )( float ); ///< Prototype of an alpha function @SINCE_1_0.0 +using AlphaFunctionPrototype = float (*)(float); ///< Prototype of an alpha function @SINCE_1_0.0 /** * @brief Alpha functions are used in animations to specify the rate of change of the animation parameter over time. @@ -45,32 +45,26 @@ using AlphaFunctionPrototype = float ( * )( float ); ///< Prototype of an alpha class DALI_CORE_API AlphaFunction { public: - /** * @brief Enumeration for built-in alpha functions. * @SINCE_1_0.0 */ enum BuiltinFunction { - DEFAULT, ///< Linear @SINCE_1_0.0 - LINEAR, ///< No transformation @SINCE_1_0.0 - REVERSE, ///< Reverse linear @SINCE_1_0.0 - - EASE_IN_SQUARE, ///< Speeds up and comes to a sudden stop (Square) @SINCE_1_0.0 - EASE_OUT_SQUARE, ///< Sudden start and slows to a gradual stop (Square) @SINCE_1_0.0 - - EASE_IN, ///< Speeds up and comes to a sudden stop (Cubic) @SINCE_1_0.0 - EASE_OUT, ///< Sudden start and slows to a gradual stop (Cubic) @SINCE_1_0.0 - EASE_IN_OUT, ///< Speeds up and slows to a gradual stop (Cubic) @SINCE_1_0.0 - - EASE_IN_SINE, ///< Speeds up and comes to a sudden stop (sinusoidal) @SINCE_1_0.0 - EASE_OUT_SINE, ///< Sudden start and slows to a gradual stop (sinusoidal) @SINCE_1_0.0 - EASE_IN_OUT_SINE, ///< Speeds up and slows to a gradual stop (sinusoidal) @SINCE_1_0.0 - - BOUNCE, ///< Sudden start, loses momentum and returns to start position @SINCE_1_0.0 - SIN, ///< Single revolution @SINCE_1_0.0 - EASE_OUT_BACK, ///< Sudden start, exceed end position and return to a gradual stop @SINCE_1_0.0 - + DEFAULT, ///< Linear @SINCE_1_0.0 + LINEAR, ///< No transformation @SINCE_1_0.0 + REVERSE, ///< Reverse linear @SINCE_1_0.0 + EASE_IN_SQUARE, ///< Speeds up and comes to a sudden stop (Square) @SINCE_1_0.0 + EASE_OUT_SQUARE, ///< Sudden start and slows to a gradual stop (Square) @SINCE_1_0.0 + EASE_IN, ///< Speeds up and comes to a sudden stop (Cubic) @SINCE_1_0.0 + EASE_OUT, ///< Sudden start and slows to a gradual stop (Cubic) @SINCE_1_0.0 + EASE_IN_OUT, ///< Speeds up and slows to a gradual stop (Cubic) @SINCE_1_0.0 + EASE_IN_SINE, ///< Speeds up and comes to a sudden stop (sinusoidal) @SINCE_1_0.0 + EASE_OUT_SINE, ///< Sudden start and slows to a gradual stop (sinusoidal) @SINCE_1_0.0 + EASE_IN_OUT_SINE, ///< Speeds up and slows to a gradual stop (sinusoidal) @SINCE_1_0.0 + BOUNCE, ///< Sudden start, loses momentum and returns to start position @SINCE_1_0.0 + SIN, ///< Single revolution @SINCE_1_0.0 + EASE_OUT_BACK, ///< Sudden start, exceed end position and return to a gradual stop @SINCE_1_0.0 COUNT }; @@ -80,9 +74,9 @@ public: */ enum Mode { - BUILTIN_FUNCTION, ///< The user has specified a built-in function @SINCE_1_0.0 - CUSTOM_FUNCTION, ///< The user has provided a custom function @SINCE_1_0.0 - BEZIER ///< The user has provided the control points of a bezier curve @SINCE_1_0.0 + BUILTIN_FUNCTION, ///< The user has specified a built-in function @SINCE_1_0.0 + CUSTOM_FUNCTION, ///< The user has provided a custom function @SINCE_1_0.0 + BEZIER ///< The user has provided the control points of a bezier curve @SINCE_1_0.0 }; /** @@ -101,7 +95,7 @@ public: * @param[in] function One of the built-in alpha functions * @return The alpha function */ - AlphaFunction( BuiltinFunction function); + AlphaFunction(BuiltinFunction function); /** * @brief Constructor. @@ -111,7 +105,7 @@ public: * @param[in] function A pointer to an alpha function * @return The alpha function */ - AlphaFunction( AlphaFunctionPrototype function); + AlphaFunction(AlphaFunctionPrototype function); /** * @brief Constructor. @@ -125,7 +119,7 @@ public: * @note The x components of the control points will be clamped to the range [0,1] to prevent * non monotonic curves. */ - AlphaFunction( const Dali::Vector2& controlPoint0, const Dali::Vector2& controlPoint1 ); + AlphaFunction(const Dali::Vector2& controlPoint0, const Dali::Vector2& controlPoint1); /** * @brief Returns the control points of the alpha function. @@ -158,11 +152,10 @@ public: Mode GetMode() const; private: - - Vector4 mBezierControlPoints; //< Control points for the bezier alpha function - AlphaFunctionPrototype mCustom; //< Pointer to an alpha function - BuiltinFunction mBuiltin : Log::value+1; //< Enum indicating the built-in alpha function - Mode mMode : 2; //< Enum indicating the functioning mode of the AlphaFunction + Vector4 mBezierControlPoints; //< Control points for the bezier alpha function + AlphaFunctionPrototype mCustom; //< Pointer to an alpha function + BuiltinFunction mBuiltin : Log::value + 1; //< Enum indicating the built-in alpha function + Mode mMode : 2; //< Enum indicating the functioning mode of the AlphaFunction }; /** diff --git a/dali/public-api/animation/animation.cpp b/dali/public-api/animation/animation.cpp index aea5404..1221a89 100644 --- a/dali/public-api/animation/animation.cpp +++ b/dali/public-api/animation/animation.cpp @@ -19,15 +19,14 @@ #include // INTERNAL INCLUDES -#include -#include #include #include #include +#include +#include namespace Dali { - Animation::Animation() { } @@ -44,9 +43,9 @@ Animation Animation::New(float durationSeconds) return Animation(internal.Get()); } -Animation Animation::DownCast( BaseHandle handle ) +Animation Animation::DownCast(BaseHandle handle) { - return Animation( dynamic_cast(handle.GetObjectPtr()) ); + return Animation(dynamic_cast(handle.GetObjectPtr())); } Animation::~Animation() @@ -57,9 +56,9 @@ Animation::Animation(const Animation& handle) = default; Animation& Animation::operator=(const Animation& rhs) = default; -Animation::Animation( Animation&& rhs ) = default; +Animation::Animation(Animation&& rhs) = default; -Animation& Animation::operator=( Animation&& rhs ) = default; +Animation& Animation::operator=(Animation&& rhs) = default; void Animation::SetDuration(float durationSeconds) { @@ -106,9 +105,9 @@ Dali::Animation::EndAction Animation::GetEndAction() const return GetImplementation(*this).GetEndAction(); } -void Animation::SetDisconnectAction( Animation::EndAction disconnectAction ) +void Animation::SetDisconnectAction(Animation::EndAction disconnectAction) { - GetImplementation(*this).SetDisconnectAction( disconnectAction ); + GetImplementation(*this).SetDisconnectAction(disconnectAction); } Animation::EndAction Animation::GetDisconnectAction() const @@ -136,9 +135,9 @@ void Animation::PlayFrom(float progress) GetImplementation(*this).PlayFrom(progress); } -void Animation::PlayAfter( float delaySeconds ) +void Animation::PlayAfter(float delaySeconds) { - GetImplementation( *this ).PlayAfter( delaySeconds ); + GetImplementation(*this).PlayAfter(delaySeconds); } void Animation::Pause() @@ -161,14 +160,14 @@ void Animation::Clear() GetImplementation(*this).Clear(); } -void Animation::SetLoopingMode( LoopingMode loopingMode ) +void Animation::SetLoopingMode(LoopingMode loopingMode) { - GetImplementation( *this ).SetLoopingMode( loopingMode ); + GetImplementation(*this).SetLoopingMode(loopingMode); } Animation::LoopingMode Animation::GetLoopingMode() const { - return GetImplementation( *this ).GetLoopingMode(); + return GetImplementation(*this).GetLoopingMode(); } Animation::AnimationSignalType& Animation::FinishedSignal() @@ -216,14 +215,14 @@ void Animation::AnimateTo(Property target, Property::Value destinationValue, Alp GetImplementation(*this).AnimateTo(target, destinationValue, alpha, period); } -void Animation::AnimateBetween(Property target, KeyFrames& keyFrames ) +void Animation::AnimateBetween(Property target, KeyFrames& keyFrames) { - GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames) ); + GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames)); } void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, Interpolation interpolation) { - GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), interpolation ); + GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), interpolation); } void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period) @@ -233,7 +232,7 @@ void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period, Interpolation interpolation) { - GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period, interpolation ); + GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), period, interpolation); } void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha) @@ -246,7 +245,6 @@ void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunct GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, interpolation); } - void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period) { GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period); @@ -257,27 +255,26 @@ void Animation::AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunct GetImplementation(*this).AnimateBetween(target, GetImplementation(keyFrames), alpha, period, interpolation); } - // Actor specific animations -void Animation::Animate( Actor actor, Path path, const Vector3& forward ) +void Animation::Animate(Actor actor, Path path, const Vector3& forward) { - GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward ); + GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation(path), forward); } -void Animation::Animate( Actor actor, Path path, const Vector3& forward, AlphaFunction alpha ) +void Animation::Animate(Actor actor, Path path, const Vector3& forward, AlphaFunction alpha) { - GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward, alpha ); + GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation(path), forward, alpha); } -void Animation::Animate( Actor actor, Path path, const Vector3& forward, TimePeriod period ) +void Animation::Animate(Actor actor, Path path, const Vector3& forward, TimePeriod period) { - GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward, period); + GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation(path), forward, period); } -void Animation::Animate( Actor actor, Path path, const Vector3& forward, AlphaFunction alpha, TimePeriod period) +void Animation::Animate(Actor actor, Path path, const Vector3& forward, AlphaFunction alpha, TimePeriod period) { - GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation( path ), forward, alpha, period ); + GetImplementation(*this).Animate(GetImplementation(actor), GetImplementation(path), forward, alpha, period); } void Animation::Show(Actor actor, float delaySeconds) @@ -290,9 +287,9 @@ void Animation::Hide(Actor actor, float delaySeconds) GetImplementation(*this).Hide(GetImplementation(actor), delaySeconds); } -void Animation::SetCurrentProgress( float progress ) +void Animation::SetCurrentProgress(float progress) { - return GetImplementation(*this).SetCurrentProgress( progress ); + return GetImplementation(*this).SetCurrentProgress(progress); } float Animation::GetCurrentProgress() @@ -300,9 +297,9 @@ float Animation::GetCurrentProgress() return GetImplementation(*this).GetCurrentProgress(); } -void Animation::SetSpeedFactor( float factor ) +void Animation::SetSpeedFactor(float factor) { - GetImplementation(*this).SetSpeedFactor( factor ); + GetImplementation(*this).SetSpeedFactor(factor); } float Animation::GetSpeedFactor() const @@ -310,7 +307,7 @@ float Animation::GetSpeedFactor() const return GetImplementation(*this).GetSpeedFactor(); } -void Animation::SetPlayRange( const Vector2& range ) +void Animation::SetPlayRange(const Vector2& range) { GetImplementation(*this).SetPlayRange(range); } diff --git a/dali/public-api/animation/animation.h b/dali/public-api/animation/animation.h index 8f3b187..f7ba6bc 100644 --- a/dali/public-api/animation/animation.h +++ b/dali/public-api/animation/animation.h @@ -123,7 +123,7 @@ class Animation; class DALI_CORE_API Animation : public BaseHandle { public: - using AnimationSignalType = Signal; ///< Animation finished signal type @SINCE_1_0.0 + using AnimationSignalType = Signal; ///< Animation finished signal type @SINCE_1_0.0 using AnyFunction = Any; ///< Interpolation function @SINCE_1_0.0 @@ -133,8 +133,8 @@ public: */ enum EndAction { - BAKE, ///< When the animation ends, the animated property values are saved. @SINCE_1_0.0 - DISCARD, ///< When the animation ends, the animated property values are forgotten. @SINCE_1_0.0 + BAKE, ///< When the animation ends, the animated property values are saved. @SINCE_1_0.0 + DISCARD, ///< When the animation ends, the animated property values are forgotten. @SINCE_1_0.0 BAKE_FINAL ///< If the animation is stopped, the animated property values are saved as if the animation had run to completion, otherwise behaves like Bake. @SINCE_1_0.0 }; @@ -144,8 +144,8 @@ public: */ enum Interpolation { - LINEAR, ///< Values in between key frames are interpolated using a linear polynomial. (Default) @SINCE_1_0.0 - CUBIC ///< Values in between key frames are interpolated using a cubic polynomial. @SINCE_1_0.0 + LINEAR, ///< Values in between key frames are interpolated using a linear polynomial. (Default) @SINCE_1_0.0 + CUBIC ///< Values in between key frames are interpolated using a cubic polynomial. @SINCE_1_0.0 }; /** @@ -157,9 +157,9 @@ public: */ enum State { - STOPPED, ///< Animation has stopped @SINCE_1_1.21 - PLAYING, ///< The animation is playing @SINCE_1_1.21 - PAUSED ///< The animation is paused @SINCE_1_1.21 + STOPPED, ///< Animation has stopped @SINCE_1_1.21 + PLAYING, ///< The animation is playing @SINCE_1_1.21 + PAUSED ///< The animation is paused @SINCE_1_1.21 }; /** @@ -169,8 +169,8 @@ public: */ enum LoopingMode { - RESTART, ///< When the animation arrives at the end in looping mode, the animation restarts from the beginning. @SINCE_1_2.60 - AUTO_REVERSE ///< When the animation arrives at the end in looping mode, the animation reverses direction and runs backwards again. @SINCE_1_2.60 + RESTART, ///< When the animation arrives at the end in looping mode, the animation restarts from the beginning. @SINCE_1_2.60 + AUTO_REVERSE ///< When the animation arrives at the end in looping mode, the animation reverses direction and runs backwards again. @SINCE_1_2.60 }; /** @@ -204,7 +204,7 @@ public: * @param[in] handle Handle to an object * @return Handle to an Animation object or an uninitialized handle */ - static Animation DownCast( BaseHandle handle ); + static Animation DownCast(BaseHandle handle); /** * @brief Destructor. @@ -237,7 +237,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs A reference to the moved handle */ - Animation( Animation&& rhs ); + Animation(Animation&& rhs); /** * @brief Move assignment operator. @@ -246,7 +246,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this handle */ - Animation& operator=( Animation&& rhs ); + Animation& operator=(Animation&& rhs); /** * @brief Sets the duration of an animation. @@ -286,7 +286,7 @@ public: * @SINCE_1_1.20 * @param[in] count The number of times to loop */ - void SetLoopCount(int32_t count); + void SetLoopCount(int32_t count); /** * @brief Gets the loop count. @@ -297,7 +297,7 @@ public: * @SINCE_1_1.20 * @return The number of times to loop */ - int32_t GetLoopCount(); + int32_t GetLoopCount(); /** * @brief Gets the current loop count. @@ -307,7 +307,7 @@ public: * @SINCE_1_1.20 * @return The current number of loops that have occured */ - int32_t GetCurrentLoop(); + int32_t GetCurrentLoop(); /** * @brief Queries whether the animation will loop. @@ -343,7 +343,7 @@ public: * @SINCE_1_0.0 * @param[in] disconnectAction The disconnect action */ - void SetDisconnectAction( EndAction disconnectAction ); + void SetDisconnectAction(EndAction disconnectAction); /** * @brief Returns the disconnect action. @@ -381,7 +381,7 @@ public: * @param[in] progress The new progress as a normalized value between [0,1] * or between the play range if specified */ - void SetCurrentProgress( float progress ); + void SetCurrentProgress(float progress); /** * @brief Retrieves the current progress of the animation. @@ -401,7 +401,7 @@ public: * @SINCE_1_0.0 * @param[in] factor A value which will multiply the velocity */ - void SetSpeedFactor( float factor ); + void SetSpeedFactor(float factor); /** * @brief Retrieves the speed factor of the animation. @@ -421,7 +421,7 @@ public: * @param[in] range Two values between [0,1] to specify minimum and maximum progress. The * animation will play between those values */ - void SetPlayRange( const Vector2& range ); + void SetPlayRange(const Vector2& range); /** * @brief Gets the playing range. @@ -446,7 +446,7 @@ public: * @SINCE_1_0.0 * @param[in] progress A value between [0,1], or between the play range if specified, from where the animation should start playing */ - void PlayFrom( float progress ); + void PlayFrom(float progress); /** * @brief Play the animation after a given delay time. @@ -456,7 +456,7 @@ public: * @SINCE_1_2.60 * @param[in] delaySeconds The delay time */ - void PlayAfter( float delaySeconds ); + void PlayAfter(float delaySeconds); /** * @brief Pauses the animation. @@ -492,7 +492,7 @@ public: * @SINCE_1_2.60 * @param[in] loopingMode The looping mode is one of RESTART and AUTO_REVERSE */ - void SetLoopingMode( LoopingMode loopingMode ); + void SetLoopingMode(LoopingMode loopingMode); /** * @brief Gets one of the current looping mode. @@ -598,7 +598,7 @@ public: */ void AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period); - /** + /** * @brief Animates a property between keyframes. * * @SINCE_1_0.0 @@ -682,7 +682,6 @@ public: */ void AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period, Interpolation interpolation); - // Actor-specific convenience methods /** @@ -696,7 +695,7 @@ public: * @param[in] path The path. It defines position and orientation * @param[in] forward The vector (in local space coordinate system) that will be oriented with the path's tangent direction */ - void Animate( Actor actor, Path path, const Vector3& forward ); + void Animate(Actor actor, Path path, const Vector3& forward); /** * @brief Animates an actor's position and orientation through a predefined path. @@ -710,7 +709,7 @@ public: * @param[in] forward The vector (in local space coordinate system) that will be oriented with the path's tangent direction * @param[in] alpha The alpha function to apply */ - void Animate( Actor actor, Path path, const Vector3& forward, AlphaFunction alpha ); + void Animate(Actor actor, Path path, const Vector3& forward, AlphaFunction alpha); /** * @brief Animates an actor's position and orientation through a predefined path. @@ -724,7 +723,7 @@ public: * @param[in] forward The vector (in local space coordinate system) that will be oriented with the path's tangent direction * @param[in] period The effect will occur during this time period */ - void Animate( Actor actor, Path path, const Vector3& forward, TimePeriod period ); + void Animate(Actor actor, Path path, const Vector3& forward, TimePeriod period); /** * @brief Animates an actor's position and orientation through a predefined path. @@ -739,7 +738,7 @@ public: * @param[in] alpha The alpha function to apply * @param[in] period The effect will occur during this time period */ - void Animate( Actor actor, Path path, const Vector3& forward, AlphaFunction alpha, TimePeriod period); + void Animate(Actor actor, Path path, const Vector3& forward, AlphaFunction alpha, TimePeriod period); /** * @brief Shows an actor during the animation. @@ -760,7 +759,6 @@ public: void Hide(Actor actor, float delaySeconds); public: // Not intended for use by Application developers - /// @cond internal /** * @brief This constructor is used by Animation::New() methods. @@ -769,7 +767,6 @@ public: // Not intended for use by Application developers */ explicit DALI_INTERNAL Animation(Internal::Animation* animation); /// @endcond - }; /** diff --git a/dali/public-api/animation/constraint-source.cpp b/dali/public-api/animation/constraint-source.cpp index c7fd48f..35c22a3 100644 --- a/dali/public-api/animation/constraint-source.cpp +++ b/dali/public-api/animation/constraint-source.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -20,39 +20,38 @@ namespace Dali { - -LocalSource::LocalSource( Property::Index index ) -: propertyIndex( index ) +LocalSource::LocalSource(Property::Index index) +: propertyIndex(index) { } -ParentSource::ParentSource( Property::Index index ) -: propertyIndex( index ) +ParentSource::ParentSource(Property::Index index) +: propertyIndex(index) { } -Source::Source( Handle& obj, Property::Index index ) -: propertyIndex( index ), - object( obj ) +Source::Source(Handle& obj, Property::Index index) +: propertyIndex(index), + object(obj) { } -ConstraintSource::ConstraintSource( Source source ) -: sourceType( OBJECT_PROPERTY ), - propertyIndex( source.propertyIndex ), - object( source.object ) +ConstraintSource::ConstraintSource(Source source) +: sourceType(OBJECT_PROPERTY), + propertyIndex(source.propertyIndex), + object(source.object) { } -ConstraintSource::ConstraintSource( LocalSource local ) -: sourceType( LOCAL_PROPERTY ), - propertyIndex( local.propertyIndex ) +ConstraintSource::ConstraintSource(LocalSource local) +: sourceType(LOCAL_PROPERTY), + propertyIndex(local.propertyIndex) { } -ConstraintSource::ConstraintSource( ParentSource parent ) -: sourceType( PARENT_PROPERTY ), - propertyIndex( parent.propertyIndex ) +ConstraintSource::ConstraintSource(ParentSource parent) +: sourceType(PARENT_PROPERTY), + propertyIndex(parent.propertyIndex) { } diff --git a/dali/public-api/animation/constraint-source.h b/dali/public-api/animation/constraint-source.h index b3b618f..9a73685 100644 --- a/dali/public-api/animation/constraint-source.h +++ b/dali/public-api/animation/constraint-source.h @@ -2,7 +2,7 @@ #define DALI_CONSTRAINT_SOURCE_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -42,7 +42,6 @@ enum SourceType PARENT_PROPERTY ///< The property comes from the parent of the object, which the constraint is applied to. @SINCE_1_0.0 }; - /** * @brief Identifies a property from an object. * @SINCE_1_0.0 @@ -55,7 +54,7 @@ struct DALI_CORE_API LocalSource * @SINCE_1_0.0 * @param[in] index The index of a property provided by the constrained object */ - LocalSource( Property::Index index ); + LocalSource(Property::Index index); Property::Index propertyIndex; ///< The index of a property provided by the constrained object. }; @@ -72,7 +71,7 @@ struct DALI_CORE_API ParentSource * @SINCE_1_0.0 * @param[in] index The index of a property, provided by the parent of the constrained object */ - ParentSource( Property::Index index ); + ParentSource(Property::Index index); Property::Index propertyIndex; ///< The index of a property provided by the parent of the constrained object. }; @@ -90,7 +89,7 @@ struct DALI_CORE_API Source * @param[in] object The object providing the property * @param[in] index The index of a property provided by object */ - Source( Handle& object, Property::Index index ); + Source(Handle& object, Property::Index index); Property::Index propertyIndex; ///< The index of a property provided by object. @@ -109,7 +108,7 @@ struct DALI_CORE_API ConstraintSource * @SINCE_1_0.0 * @param[in] source A constraint source from an arbitrary object */ - ConstraintSource( Source source ); + ConstraintSource(Source source); /** * @brief Creates a constraint source. @@ -117,7 +116,7 @@ struct DALI_CORE_API ConstraintSource * @SINCE_1_0.0 * @param[in] local A local constraint source */ - ConstraintSource( LocalSource local ); + ConstraintSource(LocalSource local); /** * @brief Creates a constraint source. @@ -125,7 +124,7 @@ struct DALI_CORE_API ConstraintSource * @SINCE_1_0.0 * @param[in] parent A parent constraint source */ - ConstraintSource( ParentSource parent ); + ConstraintSource(ParentSource parent); SourceType sourceType; ///< The source type diff --git a/dali/public-api/animation/constraint.cpp b/dali/public-api/animation/constraint.cpp index 8c2648d..2622943 100644 --- a/dali/public-api/animation/constraint.cpp +++ b/dali/public-api/animation/constraint.cpp @@ -26,14 +26,12 @@ namespace Dali { - namespace // unnamed namespace { - -template < class P > -Internal::PropertyConstraint< P >* CreatePropertyConstraint( CallbackBase* func ) +template +Internal::PropertyConstraint

* CreatePropertyConstraint(CallbackBase* func) { - return new Internal::PropertyConstraint< P >( reinterpret_cast< Dali::Constraint::Function< P >* >( func ) ); + return new Internal::PropertyConstraint

(reinterpret_cast*>(func)); } } // unnamed namespace @@ -44,41 +42,41 @@ Constraint::Constraint() { } -Constraint Constraint::Clone( Handle object ) +Constraint Constraint::Clone(Handle object) { - return Constraint( GetImplementation( *this ).Clone( GetImplementation( object ) ) ); + return Constraint(GetImplementation(*this).Clone(GetImplementation(object))); } Constraint::~Constraint() { } -Constraint::Constraint( const Constraint& constraint ) = default; +Constraint::Constraint(const Constraint& constraint) = default; -Constraint& Constraint::operator=( const Constraint& rhs ) = default; +Constraint& Constraint::operator=(const Constraint& rhs) = default; -Constraint::Constraint( Constraint&& rhs ) = default; +Constraint::Constraint(Constraint&& rhs) = default; -Constraint& Constraint::operator=( Constraint&& rhs ) = default; +Constraint& Constraint::operator=(Constraint&& rhs) = default; -Constraint Constraint::DownCast( BaseHandle baseHandle ) +Constraint Constraint::DownCast(BaseHandle baseHandle) { - return Constraint( dynamic_cast< Dali::Internal::ConstraintBase* >( baseHandle.GetObjectPtr() ) ); + return Constraint(dynamic_cast(baseHandle.GetObjectPtr())); } -void Constraint::AddSource( ConstraintSource source ) +void Constraint::AddSource(ConstraintSource source) { - GetImplementation( *this ).AddSource( Internal::Source( source ) ); + GetImplementation(*this).AddSource(Internal::Source(source)); } void Constraint::Apply() { - GetImplementation( *this ).Apply(); + GetImplementation(*this).Apply(); } void Constraint::Remove() { - GetImplementation( *this ).Remove(); + GetImplementation(*this).Remove(); } Handle Constraint::GetTargetObject() @@ -101,9 +99,9 @@ Constraint::RemoveAction Constraint::GetRemoveAction() const return GetImplementation(*this).GetRemoveAction(); } -void Constraint::SetTag( const uint32_t tag ) +void Constraint::SetTag(const uint32_t tag) { - GetImplementation(*this).SetTag( tag ); + GetImplementation(*this).SetTag(tag); } uint32_t Constraint::GetTag() const @@ -111,121 +109,121 @@ uint32_t Constraint::GetTag() const return GetImplementation(*this).GetTag(); } -Constraint::Constraint( Internal::ConstraintBase* constraint ) -: BaseHandle( constraint ) +Constraint::Constraint(Internal::ConstraintBase* constraint) +: BaseHandle(constraint) { } -Constraint Constraint::New( Handle handle, Property::Index targetIndex, Property::Type targetType, CallbackBase* function ) +Constraint Constraint::New(Handle handle, Property::Index targetIndex, Property::Type targetType, CallbackBase* function) { - Constraint constraint; + Constraint constraint; Internal::SourceContainer sources; - Internal::Object& object = GetImplementation( handle ); + Internal::Object& object = GetImplementation(handle); - switch ( targetType ) + switch(targetType) { case Property::BOOLEAN: { - Internal::PropertyConstraintPtr< bool >::Type funcPtr( CreatePropertyConstraint< bool >( function ) ); + Internal::PropertyConstraintPtr::Type funcPtr(CreatePropertyConstraint(function)); - constraint = Dali::Constraint( Internal::Constraint< bool >::New( object, - targetIndex, - sources, - funcPtr ) ); + constraint = Dali::Constraint(Internal::Constraint::New(object, + targetIndex, + sources, + funcPtr)); break; } case Property::FLOAT: { - Internal::PropertyConstraintPtr< float >::Type funcPtr( CreatePropertyConstraint< float >( function ) ); + Internal::PropertyConstraintPtr::Type funcPtr(CreatePropertyConstraint(function)); - constraint = Dali::Constraint( Internal::Constraint< float >::New( object, - targetIndex, - sources, - funcPtr ) ); + constraint = Dali::Constraint(Internal::Constraint::New(object, + targetIndex, + sources, + funcPtr)); break; } case Property::INTEGER: { - Internal::PropertyConstraintPtr< int >::Type funcPtr( CreatePropertyConstraint< int >( function ) ); + Internal::PropertyConstraintPtr::Type funcPtr(CreatePropertyConstraint(function)); - constraint = Dali::Constraint( Internal::Constraint< int >::New( object, - targetIndex, - sources, - funcPtr ) ); + constraint = Dali::Constraint(Internal::Constraint::New(object, + targetIndex, + sources, + funcPtr)); break; } case Property::VECTOR2: { - Internal::PropertyConstraintPtr< Vector2 >::Type funcPtr( CreatePropertyConstraint< Vector2 >( function ) ); + Internal::PropertyConstraintPtr::Type funcPtr(CreatePropertyConstraint(function)); - constraint = Dali::Constraint( Internal::Constraint< Vector2 >::New( object, - targetIndex, - sources, - funcPtr ) ); + constraint = Dali::Constraint(Internal::Constraint::New(object, + targetIndex, + sources, + funcPtr)); break; } case Property::VECTOR3: { - Internal::PropertyConstraintPtr< Vector3 >::Type funcPtr( CreatePropertyConstraint< Vector3 >( function ) ); + Internal::PropertyConstraintPtr::Type funcPtr(CreatePropertyConstraint(function)); - constraint = Dali::Constraint( Internal::Constraint< Vector3 >::New( object, - targetIndex, - sources, - funcPtr ) ); + constraint = Dali::Constraint(Internal::Constraint::New(object, + targetIndex, + sources, + funcPtr)); break; } case Property::VECTOR4: { - Internal::PropertyConstraintPtr< Vector4 >::Type funcPtr( CreatePropertyConstraint< Vector4 >( function ) ); + Internal::PropertyConstraintPtr::Type funcPtr(CreatePropertyConstraint(function)); - constraint = Dali::Constraint( Internal::Constraint< Vector4 >::New( object, - targetIndex, - sources, - funcPtr ) ); + constraint = Dali::Constraint(Internal::Constraint::New(object, + targetIndex, + sources, + funcPtr)); break; } case Property::ROTATION: { - Internal::PropertyConstraintPtr< Quaternion >::Type funcPtr( CreatePropertyConstraint< Quaternion >( function ) ); + Internal::PropertyConstraintPtr::Type funcPtr(CreatePropertyConstraint(function)); - constraint = Dali::Constraint( Internal::Constraint< Quaternion >::New( object, - targetIndex, - sources, - funcPtr ) ); + constraint = Dali::Constraint(Internal::Constraint::New(object, + targetIndex, + sources, + funcPtr)); break; } case Property::MATRIX: { - Internal::PropertyConstraintPtr< Matrix >::Type funcPtr( CreatePropertyConstraint< Matrix >( function ) ); + Internal::PropertyConstraintPtr::Type funcPtr(CreatePropertyConstraint(function)); - constraint = Dali::Constraint( Internal::Constraint< Matrix >::New( object, - targetIndex, - sources, - funcPtr ) ); + constraint = Dali::Constraint(Internal::Constraint::New(object, + targetIndex, + sources, + funcPtr)); break; } case Property::MATRIX3: { - Internal::PropertyConstraintPtr::Type funcPtr( CreatePropertyConstraint( function ) ); + Internal::PropertyConstraintPtr::Type funcPtr(CreatePropertyConstraint(function)); - constraint = Dali::Constraint( Internal::Constraint< Matrix3 >::New( object, - targetIndex, - sources, - funcPtr ) ); + constraint = Dali::Constraint(Internal::Constraint::New(object, + targetIndex, + sources, + funcPtr)); break; } default: { - DALI_ABORT( "Property not constrainable" ); + DALI_ABORT("Property not constrainable"); break; } } diff --git a/dali/public-api/animation/constraint.h b/dali/public-api/animation/constraint.h index d63fd7a..5a487ac 100644 --- a/dali/public-api/animation/constraint.h +++ b/dali/public-api/animation/constraint.h @@ -25,8 +25,8 @@ #include #include #include -#include #include +#include #include namespace Dali @@ -71,7 +71,6 @@ using PropertyInputContainer = Vector; class DALI_CORE_API Constraint : public BaseHandle { public: - /** * @brief Template for the Function that is called by the Constraint system. * @@ -94,11 +93,10 @@ public: * @SINCE_1_0.0 * @tparam P The property type to constrain */ - template< typename P > + template class DALI_INTERNAL Function : public CallbackBase { public: - /** * @brief Constructor which connects to the provided C function (or a static member function). * @@ -110,9 +108,9 @@ public: * @SINCE_1_0.0 * @param[in] function The function to call */ - Function( void( *function )( P&, const PropertyInputContainer& ) ) - : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) ), - mCopyConstructorDispatcher( NULL ) + Function(void (*function)(P&, const PropertyInputContainer&)) + : CallbackBase(reinterpret_cast(function)), + mCopyConstructorDispatcher(NULL) { } @@ -128,13 +126,13 @@ public: * @param[in] object The object to copy * @tparam T The type of the object */ - template< class T > - Function( const T& object ) - : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object - nullptr, // uses operator() instead of member function - reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher2< T, P&, const PropertyInputContainer& >::Dispatch ), - reinterpret_cast< CallbackBase::Destructor >( &Destroyer< T >::Delete ) ), - mCopyConstructorDispatcher( reinterpret_cast< CopyConstructorDispatcher >( &ObjectCopyConstructorDispatcher< T >::Copy ) ) + template + Function(const T& object) + : CallbackBase(reinterpret_cast(new T(object)), // copy the object + nullptr, // uses operator() instead of member function + reinterpret_cast(&FunctorDispatcher2::Dispatch), + reinterpret_cast(&Destroyer::Delete)), + mCopyConstructorDispatcher(reinterpret_cast(&ObjectCopyConstructorDispatcher::Copy)) { } @@ -151,13 +149,13 @@ public: * @param[in] memberFunction The member function to call. This has to be a member of the same class * @tparam T The type of the object */ - template< class T > - Function( const T& object, void ( T::*memberFunction ) ( P&, const PropertyInputContainer& ) ) - : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object - reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ), - reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher2< T, P&, const PropertyInputContainer& >::Dispatch ), - reinterpret_cast< CallbackBase::Destructor >( &Destroyer< T >::Delete ) ), - mCopyConstructorDispatcher( reinterpret_cast< CopyConstructorDispatcher >( &ObjectCopyConstructorDispatcher< T >::Copy ) ) + template + Function(const T& object, void (T::*memberFunction)(P&, const PropertyInputContainer&)) + : CallbackBase(reinterpret_cast(new T(object)), // copy the object + reinterpret_cast(memberFunction), + reinterpret_cast(&Dispatcher2::Dispatch), + reinterpret_cast(&Destroyer::Delete)), + mCopyConstructorDispatcher(reinterpret_cast(&ObjectCopyConstructorDispatcher::Copy)) { } @@ -172,23 +170,22 @@ public: CallbackBase* Clone() { CallbackBase* callback = nullptr; - if ( mImpl && mImpl->mObjectPointer && mCopyConstructorDispatcher ) + if(mImpl && mImpl->mObjectPointer && mCopyConstructorDispatcher) { - callback = new Function( mCopyConstructorDispatcher( reinterpret_cast< UndefinedClass* >( mImpl->mObjectPointer ) ) /* Copy the object */, - mMemberFunction, - mImpl->mMemberFunctionDispatcher, - mImpl->mDestructorDispatcher, - mCopyConstructorDispatcher ); + callback = new Function(mCopyConstructorDispatcher(reinterpret_cast(mImpl->mObjectPointer)) /* Copy the object */, + mMemberFunction, + mImpl->mMemberFunctionDispatcher, + mImpl->mDestructorDispatcher, + mCopyConstructorDispatcher); } else { - callback = new Function( mFunction ); + callback = new Function(mFunction); } return callback; } private: - /** * @brief Must not be declared. * @@ -200,7 +197,7 @@ public: * @brief Used to call the function to copy the stored object. * @SINCE_1_0.0 */ - using CopyConstructorDispatcher = UndefinedClass* (*)( UndefinedClass* ); + using CopyConstructorDispatcher = UndefinedClass* (*)(UndefinedClass*); /** * @brief Copies the actual object in Constraint::Function. @@ -208,7 +205,7 @@ public: * @SINCE_1_0.0 * @tparam T The type of the object */ - template< class T > + template struct ObjectCopyConstructorDispatcher { /** @@ -218,17 +215,17 @@ public: * @param[in] object The object to copy * @return Newly allocated clone of the object */ - static UndefinedClass* Copy( const UndefinedClass* object ) + static UndefinedClass* Copy(const UndefinedClass* object) { - T* copy = new T( *( reinterpret_cast< const T* >( object ) ) ); - return reinterpret_cast< UndefinedClass* >( copy ); + T* copy = new T(*(reinterpret_cast(object))); + return reinterpret_cast(copy); } }; - Function( const Function& ) = delete; ///< Deleted copy constructor. @SINCE_1_0.0 - Function( Function&& ) = delete; ///< Deleted move constructor. @SINCE_1_9.25 - Function& operator=( const Function& ) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0 - Function& operator=( Function&& ) = delete; ///< Deleted move assignment operator. @SINCE_1_9.25 + Function(const Function&) = delete; ///< Deleted copy constructor. @SINCE_1_0.0 + Function(Function&&) = delete; ///< Deleted move constructor. @SINCE_1_9.25 + Function& operator=(const Function&) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0 + Function& operator=(Function&&) = delete; ///< Deleted move assignment operator. @SINCE_1_9.25 /** * @brief Constructor used when copying the stored object. @@ -240,13 +237,13 @@ public: * @param[in] destructor Used to delete the owned object * @param[in] copyConstructorDispatcher Used to create a copy of the owned object */ - Function( void* object, - CallbackBase::MemberFunction memberFunction, - CallbackBase::Dispatcher dispatcher, - CallbackBase::Destructor destructor, - CopyConstructorDispatcher copyConstructorDispatcher ) - : CallbackBase( object, memberFunction, dispatcher, destructor ), - mCopyConstructorDispatcher( copyConstructorDispatcher ) + Function(void* object, + CallbackBase::MemberFunction memberFunction, + CallbackBase::Dispatcher dispatcher, + CallbackBase::Destructor destructor, + CopyConstructorDispatcher copyConstructorDispatcher) + : CallbackBase(object, memberFunction, dispatcher, destructor), + mCopyConstructorDispatcher(copyConstructorDispatcher) { } @@ -256,9 +253,9 @@ public: * @SINCE_1_0.0 * @param[in] function The function to call */ - Function( CallbackBase::Function function ) - : CallbackBase( function ), - mCopyConstructorDispatcher( nullptr ) + Function(CallbackBase::Function function) + : CallbackBase(function), + mCopyConstructorDispatcher(nullptr) { } @@ -280,7 +277,7 @@ public: DISCARD ///< When the constraint is removed, the constrained value is discarded. @SINCE_1_9.28 }; - static const RemoveAction DEFAULT_REMOVE_ACTION; ///< BAKE + static const RemoveAction DEFAULT_REMOVE_ACTION; ///< BAKE /** * @brief Creates an uninitialized Constraint; this can be initialized with Constraint::New(). @@ -312,11 +309,11 @@ public: * @tparam P The type of the property to constrain * @return The new constraint */ - template< class P > - static Constraint New( Handle handle, Property::Index targetIndex, void( *function )( P&, const PropertyInputContainer& ) ) + template + static Constraint New(Handle handle, Property::Index targetIndex, void (*function)(P&, const PropertyInputContainer&)) { - CallbackBase* callback = new Constraint::Function< P >( function ); - return New( handle, targetIndex, PropertyTypes::Get< P >(), callback ); + CallbackBase* callback = new Constraint::Function

(function); + return New(handle, targetIndex, PropertyTypes::Get

(), callback); } /** @@ -345,11 +342,11 @@ public: * @tparam T The type of the object * @return The new constraint */ - template< class P, class T > - static Constraint New( Handle handle, Property::Index targetIndex, const T& object ) + template + static Constraint New(Handle handle, Property::Index targetIndex, const T& object) { - CallbackBase* function = new Constraint::Function< P >( object ); - return New( handle, targetIndex, PropertyTypes::Get< P >(), function ); + CallbackBase* function = new Constraint::Function

(object); + return New(handle, targetIndex, PropertyTypes::Get

(), function); } /** @@ -379,11 +376,11 @@ public: * @tparam P The type of the property to constrain * @tparam T The type of the object */ - template< class P, class T > - static Constraint New( Handle handle, Property::Index targetIndex, const T& object, void ( T::*memberFunction ) ( P&, const PropertyInputContainer& ) ) + template + static Constraint New(Handle handle, Property::Index targetIndex, const T& object, void (T::*memberFunction)(P&, const PropertyInputContainer&)) { - CallbackBase* function = new Constraint::Function< P >( object, memberFunction ); - return New( handle, targetIndex, PropertyTypes::Get< P >(), function ); + CallbackBase* function = new Constraint::Function

(object, memberFunction); + return New(handle, targetIndex, PropertyTypes::Get

(), function); } /** @@ -393,7 +390,7 @@ public: * @param[in] handle The handle to the property-owning object this constraint is to be cloned for * @return The new constraint */ - Constraint Clone( Handle handle ); + Constraint Clone(Handle handle); /** * @brief Destructor. @@ -409,7 +406,7 @@ public: * @SINCE_1_0.0 * @param[in] constraint A reference to the copied handle */ - Constraint( const Constraint& constraint ); + Constraint(const Constraint& constraint); /** * @brief This assignment operator is required for (smart) pointer semantics. @@ -418,7 +415,7 @@ public: * @param[in] rhs A reference to the copied handle * @return A reference to this */ - Constraint& operator=( const Constraint& rhs ); + Constraint& operator=(const Constraint& rhs); /** * @brief Move constructor. @@ -426,7 +423,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs A reference to the moved handle */ - Constraint( Constraint&& rhs ); + Constraint(Constraint&& rhs); /** * @brief Move assignment operator. @@ -435,7 +432,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this handle */ - Constraint& operator=( Constraint&& rhs ); + Constraint& operator=(Constraint&& rhs); /** * @brief Downcasts a handle to Constraint handle. @@ -446,7 +443,7 @@ public: * @param[in] baseHandle BaseHandle to an object * @return Handle to a Constraint object or an uninitialized handle */ - static Constraint DownCast( BaseHandle baseHandle ); + static Constraint DownCast(BaseHandle baseHandle); /** * @brief Adds a constraint source to the constraint. @@ -454,7 +451,7 @@ public: * @SINCE_1_0.0 * @param[in] source The constraint source input to add */ - void AddSource( ConstraintSource source ); + void AddSource(ConstraintSource source); /** * @brief Applies this constraint. @@ -496,7 +493,7 @@ public: * @SINCE_1_0.0 * @param[in] action The remove-action */ - void SetRemoveAction( RemoveAction action ); + void SetRemoveAction(RemoveAction action); /** * @brief Retrieves the remove action that will happen when the constraint is removed. @@ -512,7 +509,7 @@ public: * @SINCE_1_0.0 * @param[in] tag An integer to identify the constraint */ - void SetTag( const uint32_t tag ); + void SetTag(const uint32_t tag); /** * @brief Gets the tag. @@ -523,18 +520,16 @@ public: uint32_t GetTag() const; public: // Not intended for use by Application developers - /// @cond internal /** * @brief This constructor is used by Constraint::New() methods. * @SINCE_1_0.0 * @param[in] constraint A pointer to a newly allocated Dali resource */ - explicit DALI_INTERNAL Constraint( Internal::ConstraintBase* constraint ); + explicit DALI_INTERNAL Constraint(Internal::ConstraintBase* constraint); /// @endcond private: // Not intended for use by Application developers - /// @cond internal /** * @brief Constructs a new constraint which targets a property. @@ -546,7 +541,7 @@ private: // Not intended for use by Application developers * @param[in] function The constraint function * @return The new constraint */ - static Constraint New( Handle handle, Property::Index targetIndex, Property::Type targetType, CallbackBase* function ); + static Constraint New(Handle handle, Property::Index targetIndex, Property::Type targetType, CallbackBase* function); /// @endcond }; diff --git a/dali/public-api/animation/constraints.h b/dali/public-api/animation/constraints.h index 2adc24f..63bcf0d 100644 --- a/dali/public-api/animation/constraints.h +++ b/dali/public-api/animation/constraints.h @@ -2,7 +2,7 @@ #define DALI_CONSTRAINTS_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -20,11 +20,11 @@ // INTERNAL INCLUDES #include -#include -#include -#include #include #include +#include +#include +#include #include namespace Dali @@ -48,7 +48,8 @@ struct EqualToConstraint * @SINCE_1_0.0 */ EqualToConstraint() - { } + { + } /** * @brief Overrides functor for float properties. @@ -57,7 +58,7 @@ struct EqualToConstraint * @param[in,out] current The current property value, the constrained value is set * @param[in] inputs Contains the property to copy */ - void operator()( float& current, const PropertyInputContainer& inputs ) + void operator()(float& current, const PropertyInputContainer& inputs) { current = inputs[0]->GetFloat(); } @@ -69,7 +70,7 @@ struct EqualToConstraint * @param[in,out] current The current property value, the constrained value is set * @param[in] inputs Contains the property to copy */ - void operator()( Vector2& current, const PropertyInputContainer& inputs ) + void operator()(Vector2& current, const PropertyInputContainer& inputs) { current = inputs[0]->GetVector2(); } @@ -81,7 +82,7 @@ struct EqualToConstraint * @param[in,out] current The current property value, the constrained value is set * @param[in] inputs Contains the property to copy */ - void operator()( Vector3& current, const PropertyInputContainer& inputs ) + void operator()(Vector3& current, const PropertyInputContainer& inputs) { current = inputs[0]->GetVector3(); } @@ -93,7 +94,7 @@ struct EqualToConstraint * @param[in,out] current The current property value, the constrained value is set * @param[in] inputs Contains the property to copy */ - void operator()( Vector4& current, const PropertyInputContainer& inputs ) + void operator()(Vector4& current, const PropertyInputContainer& inputs) { current = inputs[0]->GetVector4(); } @@ -105,7 +106,7 @@ struct EqualToConstraint * @param[in,out] current The current property value, the constrained value is set * @param[in] inputs Contains the property to copy */ - void operator()( Quaternion& current, const PropertyInputContainer& inputs ) + void operator()(Quaternion& current, const PropertyInputContainer& inputs) { current = inputs[0]->GetQuaternion(); } @@ -117,7 +118,7 @@ struct EqualToConstraint * @param[in,out] current The current property value * @param[in] inputs Contains the property to copy */ - void operator()( Matrix3& current, const PropertyInputContainer& inputs ) + void operator()(Matrix3& current, const PropertyInputContainer& inputs) { current = inputs[0]->GetMatrix3(); } @@ -129,11 +130,10 @@ struct EqualToConstraint * @param[in,out] current The current property value, the constrained value is set * @param[in] inputs Contains the property to copy */ - void operator()( Matrix& current, const PropertyInputContainer& inputs ) + void operator()(Matrix& current, const PropertyInputContainer& inputs) { current = inputs[0]->GetMatrix(); } - }; /** @@ -152,16 +152,20 @@ struct RelativeToConstraint * @SINCE_1_0.0 * @param[in] scale Scale factor */ - RelativeToConstraint( float scale ) - : mScale( scale, scale, scale ) { } + RelativeToConstraint(float scale) + : mScale(scale, scale, scale) + { + } /** * @brief Constructor. * @SINCE_1_0.0 * @param[in] scale Scale factor */ - RelativeToConstraint( const Vector3& scale ) - : mScale( scale ) { } + RelativeToConstraint(const Vector3& scale) + : mScale(scale) + { + } /** * @brief Functor. @@ -169,7 +173,7 @@ struct RelativeToConstraint * @param[in,out] current The current property value (vector3 property * scale factor) * @param[in] inputs Property container for current property calculation */ - void operator()( Vector3& current, const PropertyInputContainer& inputs ) + void operator()(Vector3& current, const PropertyInputContainer& inputs) { current = inputs[0]->GetVector3() * mScale; } @@ -192,8 +196,10 @@ struct RelativeToConstraintFloat * @SINCE_1_0.0 * @param[in] scale Scale factor */ - RelativeToConstraintFloat( float scale ) - : mScale( scale ) { } + RelativeToConstraintFloat(float scale) + : mScale(scale) + { + } /** * @brief Functor. @@ -201,7 +207,7 @@ struct RelativeToConstraintFloat * @param[in,out] current The current property value (float property * scale factor) * @param[in] inputs Property container for current property calculation */ - void operator()( float& current, const PropertyInputContainer& inputs ) + void operator()(float& current, const PropertyInputContainer& inputs) { current = inputs[0]->GetFloat() * mScale; } @@ -221,11 +227,11 @@ struct RelativeToConstraintFloat * @param[in,out] current The current orientation property value, the constrained value is set * @param[in] inputs Contains the world position of the target, the world position of the camera, and the world orientation of the target */ -inline void LookAt( Dali::Quaternion& current, const Dali::PropertyInputContainer& inputs ) +inline void LookAt(Dali::Quaternion& current, const Dali::PropertyInputContainer& inputs) { - const PropertyInput& targetPosition( *inputs[0] ); - const PropertyInput& cameraPosition( *inputs[1] ); - const PropertyInput& targetOrientation( *inputs[2] ); + const PropertyInput& targetPosition(*inputs[0]); + const PropertyInput& cameraPosition(*inputs[1]); + const PropertyInput& targetOrientation(*inputs[2]); Vector3 vForward = targetPosition.GetVector3() - cameraPosition.GetVector3(); vForward.Normalize(); @@ -243,7 +249,7 @@ inline void LookAt( Dali::Quaternion& current, const Dali::PropertyInputContaine Vector3 vY = vForward.Cross(vX); vY.Normalize(); - current = Quaternion( vX, vY, vForward ); + current = Quaternion(vX, vY, vForward); } /** diff --git a/dali/public-api/animation/key-frames.cpp b/dali/public-api/animation/key-frames.cpp index a4ef9bb..d2394dd 100644 --- a/dali/public-api/animation/key-frames.cpp +++ b/dali/public-api/animation/key-frames.cpp @@ -19,23 +19,22 @@ #include // INTERNAL INCLUDES +#include #include #include #include -#include namespace Dali { - KeyFrames KeyFrames::New() { Internal::KeyFrames* internal = Internal::KeyFrames::New(); return KeyFrames(internal); } -KeyFrames KeyFrames::DownCast( BaseHandle handle ) +KeyFrames KeyFrames::DownCast(BaseHandle handle) { - return KeyFrames( dynamic_cast(handle.GetObjectPtr()) ); + return KeyFrames(dynamic_cast(handle.GetObjectPtr())); } KeyFrames::KeyFrames() @@ -50,9 +49,9 @@ KeyFrames::KeyFrames(const KeyFrames& handle) = default; KeyFrames& KeyFrames::operator=(const KeyFrames& rhs) = default; -KeyFrames::KeyFrames( KeyFrames&& rhs ) = default; +KeyFrames::KeyFrames(KeyFrames&& rhs) = default; -KeyFrames& KeyFrames::operator=( KeyFrames&& rhs ) = default; +KeyFrames& KeyFrames::operator=(KeyFrames&& rhs) = default; Property::Type KeyFrames::GetType() const { @@ -70,10 +69,8 @@ void KeyFrames::Add(float time, Property::Value value, AlphaFunction alpha) } KeyFrames::KeyFrames(Internal::KeyFrames* internal) - : BaseHandle(internal) +: BaseHandle(internal) { } - - -} // Dali +} // namespace Dali diff --git a/dali/public-api/animation/key-frames.h b/dali/public-api/animation/key-frames.h index d033dd8..0d140b0 100644 --- a/dali/public-api/animation/key-frames.h +++ b/dali/public-api/animation/key-frames.h @@ -21,8 +21,8 @@ // INTERNAL INCLUDES #include #include -#include #include +#include namespace Dali { @@ -65,7 +65,7 @@ public: * @param[in] handle Handle to an object * @return Handle to a KeyFrames object or an uninitialized handle */ - static KeyFrames DownCast( BaseHandle handle ); + static KeyFrames DownCast(BaseHandle handle); /** * @brief Creates an uninitialized KeyFrame handle. @@ -107,7 +107,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs A reference to the moved handle */ - KeyFrames( KeyFrames&& rhs ); + KeyFrames(KeyFrames&& rhs); /** * @brief Move assignment operator. @@ -116,7 +116,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this */ - KeyFrames& operator=( KeyFrames&& rhs ); + KeyFrames& operator=(KeyFrames&& rhs); /** * @brief Gets the type of the key frame. @@ -148,7 +148,6 @@ public: */ void Add(float progress, Property::Value value, AlphaFunction alpha); - public: // Not intended for application developers /// @cond internal /** diff --git a/dali/public-api/animation/linear-constrainer.cpp b/dali/public-api/animation/linear-constrainer.cpp index 3c46654..8a99504 100644 --- a/dali/public-api/animation/linear-constrainer.cpp +++ b/dali/public-api/animation/linear-constrainer.cpp @@ -21,19 +21,17 @@ // INTERNAL INCLUDES #include - namespace Dali { - LinearConstrainer LinearConstrainer::New() { Internal::LinearConstrainer* internal = Internal::LinearConstrainer::New(); return LinearConstrainer(internal); } -LinearConstrainer LinearConstrainer::DownCast( BaseHandle handle ) +LinearConstrainer LinearConstrainer::DownCast(BaseHandle handle) { - return LinearConstrainer( dynamic_cast(handle.GetObjectPtr()) ); + return LinearConstrainer(dynamic_cast(handle.GetObjectPtr())); } LinearConstrainer::LinearConstrainer() @@ -53,19 +51,18 @@ LinearConstrainer::LinearConstrainer(Internal::LinearConstrainer* internal) LinearConstrainer& LinearConstrainer::operator=(const LinearConstrainer& rhs) = default; -LinearConstrainer::LinearConstrainer( LinearConstrainer&& rhs ) = default; +LinearConstrainer::LinearConstrainer(LinearConstrainer&& rhs) = default; -LinearConstrainer& LinearConstrainer::operator=( LinearConstrainer&& rhs ) = default; +LinearConstrainer& LinearConstrainer::operator=(LinearConstrainer&& rhs) = default; -void LinearConstrainer::Apply( Dali::Property target, Dali::Property source, const Vector2& range, const Vector2& wrap ) +void LinearConstrainer::Apply(Dali::Property target, Dali::Property source, const Vector2& range, const Vector2& wrap) { - GetImplementation(*this).Apply( target, source, range, wrap ); + GetImplementation(*this).Apply(target, source, range, wrap); } -void LinearConstrainer::Remove( Dali::Handle& target ) +void LinearConstrainer::Remove(Dali::Handle& target) { - GetImplementation(*this).Remove( target ); + GetImplementation(*this).Remove(target); } - -} // Dali +} // namespace Dali diff --git a/dali/public-api/animation/linear-constrainer.h b/dali/public-api/animation/linear-constrainer.h index e5b1834..3346b24 100644 --- a/dali/public-api/animation/linear-constrainer.h +++ b/dali/public-api/animation/linear-constrainer.h @@ -34,7 +34,7 @@ namespace Dali namespace Internal DALI_INTERNAL { - class LinearConstrainer; +class LinearConstrainer; } /** @@ -57,7 +57,6 @@ namespace Internal DALI_INTERNAL class DALI_CORE_API LinearConstrainer : public Handle { public: - /** * @brief Enumeration for the instance of properties belonging to the LinearConstrainer class. * @SINCE_1_0.0 @@ -70,8 +69,8 @@ public: */ enum { - VALUE = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "value" type Array of float @SINCE_1_0.0 - PROGRESS, ///< name "progress" type Array of float @SINCE_1_0.0 + VALUE = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "value" type Array of float @SINCE_1_0.0 + PROGRESS, ///< name "progress" type Array of float @SINCE_1_0.0 }; }; @@ -92,7 +91,7 @@ public: * @param[in] handle Handle to an object * @return Handle to a LinearConstrainer object or an uninitialized handle */ - static LinearConstrainer DownCast( BaseHandle handle ); + static LinearConstrainer DownCast(BaseHandle handle); /** * @brief Creates an uninitialized LinearConstrainer handle. @@ -134,7 +133,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs A reference to the moved handle */ - LinearConstrainer( LinearConstrainer&& rhs ); + LinearConstrainer(LinearConstrainer&& rhs); /** * @brief Move assignment operator. @@ -143,7 +142,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this */ - LinearConstrainer& operator=( LinearConstrainer&& rhs ); + LinearConstrainer& operator=(LinearConstrainer&& rhs); /** * @brief Applies the linear constraint to the target property. @@ -154,7 +153,7 @@ public: * @param[in] range The range of values in the source property which will be mapped to [0,1] * @param[in] wrap Wrapping domain. Source property will be wrapped in the domain [wrap.x,wrap.y] before mapping to [0,1]. See cfloat.h for FLT_MAX */ - void Apply( Dali::Property target, Dali::Property source, const Vector2& range, const Vector2& wrap = Vector2(-FLT_MAX, FLT_MAX) ); + void Apply(Dali::Property target, Dali::Property source, const Vector2& range, const Vector2& wrap = Vector2(-FLT_MAX, FLT_MAX)); /** * @brief Removes the linear constraint in the target object. @@ -162,7 +161,7 @@ public: * @SINCE_1_0.0 * @param[in] target A handle to an object constrained by the LinearConstrainer */ - void Remove( Dali::Handle& target ); + void Remove(Dali::Handle& target); public: // Not intended for application developers /// @cond internal diff --git a/dali/public-api/animation/path.cpp b/dali/public-api/animation/path.cpp index 4b868bd..f16b7ba 100644 --- a/dali/public-api/animation/path.cpp +++ b/dali/public-api/animation/path.cpp @@ -16,23 +16,22 @@ */ // CLASS HEADER -#include #include +#include // INTERNAL INCLUDES namespace Dali { - Path Path::New() { Internal::Path* internal = Internal::Path::New(); return Path(internal); } -Path Path::DownCast( BaseHandle handle ) +Path Path::DownCast(BaseHandle handle) { - return Path( dynamic_cast(handle.GetObjectPtr()) ); + return Path(dynamic_cast(handle.GetObjectPtr())); } Path::Path() @@ -52,39 +51,38 @@ Path::Path(Internal::Path* internal) Path& Path::operator=(const Path& rhs) = default; -Path::Path( Path&& rhs ) = default; +Path::Path(Path&& rhs) = default; -Path& Path::operator=( Path&& rhs ) = default; +Path& Path::operator=(Path&& rhs) = default; -void Path::AddPoint(const Vector3& point ) +void Path::AddPoint(const Vector3& point) { - GetImplementation(*this).AddPoint( point ); + GetImplementation(*this).AddPoint(point); } -void Path::AddControlPoint(const Vector3& point ) +void Path::AddControlPoint(const Vector3& point) { - GetImplementation(*this).AddControlPoint( point ); + GetImplementation(*this).AddControlPoint(point); } -void Path::GenerateControlPoints( float curvature ) +void Path::GenerateControlPoints(float curvature) { - GetImplementation(*this).GenerateControlPoints( curvature ); + GetImplementation(*this).GenerateControlPoints(curvature); } - -void Path::Sample( float progress, Vector3& position, Vector3& tangent ) const +void Path::Sample(float progress, Vector3& position, Vector3& tangent) const { - GetImplementation(*this).Sample( progress, position, tangent ); + GetImplementation(*this).Sample(progress, position, tangent); } -Vector3& Path::GetPoint( size_t index ) +Vector3& Path::GetPoint(size_t index) { - return GetImplementation(*this).GetPoint( static_cast( index ) ); + return GetImplementation(*this).GetPoint(static_cast(index)); } -Vector3& Path::GetControlPoint( size_t index ) +Vector3& Path::GetControlPoint(size_t index) { - return GetImplementation(*this).GetControlPoint( static_cast( index ) ); + return GetImplementation(*this).GetControlPoint(static_cast(index)); } size_t Path::GetPointCount() const @@ -92,4 +90,4 @@ size_t Path::GetPointCount() const return GetImplementation(*this).GetPointCount(); } -} // Dali +} // namespace Dali diff --git a/dali/public-api/animation/path.h b/dali/public-api/animation/path.h index b60254a..efb70bb 100644 --- a/dali/public-api/animation/path.h +++ b/dali/public-api/animation/path.h @@ -44,7 +44,6 @@ class Path; class DALI_CORE_API Path : public Handle { public: - /** * @brief Enumeration for the instance of properties belonging to the Path class. * @SINCE_1_0.0 @@ -57,8 +56,8 @@ public: */ enum { - POINTS = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "points", type Vector3 @SINCE_1_0.0 - CONTROL_POINTS, ///< name "controlPoints", type Vector3 @SINCE_1_0.0 + POINTS = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "points", type Vector3 @SINCE_1_0.0 + CONTROL_POINTS, ///< name "controlPoints", type Vector3 @SINCE_1_0.0 }; }; @@ -79,7 +78,7 @@ public: * @param[in] handle Handle to an object * @return Handle to a Path object or an uninitialized handle */ - static Path DownCast( BaseHandle handle ); + static Path DownCast(BaseHandle handle); /** * @brief Creates an uninitialized Path handle. @@ -121,7 +120,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs A reference to the moved handle */ - Path( Path&& rhs ); + Path(Path&& rhs); /** * @brief Move assignment operator. @@ -130,7 +129,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this */ - Path& operator=( Path&& rhs ); + Path& operator=(Path&& rhs); /** * @brief Adds an interpolation point. @@ -138,7 +137,7 @@ public: * @SINCE_1_0.0 * @param[in] point The new interpolation point to be added */ - void AddPoint(const Vector3& point ); + void AddPoint(const Vector3& point); /** * @brief Adds a control point. @@ -146,7 +145,7 @@ public: * @SINCE_1_0.0 * @param[in] point The new control point to be added */ - void AddControlPoint(const Vector3& point ); + void AddControlPoint(const Vector3& point); /** * @brief Automatic generation of control points. Generated control points which result in a smooth join between the splines of each segment. @@ -166,7 +165,7 @@ public: * @pre There are at least two points in the path ( one segment ). * */ - void GenerateControlPoints( float curvature ); + void GenerateControlPoints(float curvature); /** * @brief Sample path at a given progress. Calculates position and tangent at that point of the curve. @@ -176,7 +175,7 @@ public: * @param[out] position The interpolated position at that progress * @param[out] tangent The interpolated tangent at that progress */ - void Sample( float progress, Vector3& position, Vector3& tangent ) const; + void Sample(float progress, Vector3& position, Vector3& tangent) const; /** * @brief Accessor for the interpolation points. @@ -185,7 +184,7 @@ public: * @param[in] index The index of the interpolation point * @return A reference to the interpolation point */ - Vector3& GetPoint( size_t index ); + Vector3& GetPoint(size_t index); /** * @brief Accessor for the control points. @@ -194,7 +193,7 @@ public: * @param[in] index The index of the control point * @return A reference to the control point */ - Vector3& GetControlPoint( size_t index ); + Vector3& GetControlPoint(size_t index); /** * @brief Gets the number of interpolation points in the path. diff --git a/dali/public-api/animation/time-period.cpp b/dali/public-api/animation/time-period.cpp index 1006764..f8f5840 100644 --- a/dali/public-api/animation/time-period.cpp +++ b/dali/public-api/animation/time-period.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -20,7 +20,6 @@ namespace Dali { - TimePeriod::TimePeriod(float duration) : delaySeconds(0.0f), durationSeconds(duration) diff --git a/dali/public-api/common/constants.h b/dali/public-api/common/constants.h index d8e7515..7fbc204 100644 --- a/dali/public-api/common/constants.h +++ b/dali/public-api/common/constants.h @@ -41,22 +41,22 @@ namespace Dali */ namespace ParentOrigin { -static constexpr float TOP = 0.0f; -static constexpr float BOTTOM = 1.0f; -static constexpr float LEFT = 0.0f; -static constexpr float RIGHT = 1.0f; -static constexpr float MIDDLE = 0.5f; -static constexpr Vector3 TOP_LEFT (0.0f, 0.0f, 0.5f); -static constexpr Vector3 TOP_CENTER (0.5f, 0.0f, 0.5f); -static constexpr Vector3 TOP_RIGHT (1.0f, 0.0f, 0.5f); -static constexpr Vector3 CENTER_LEFT (0.0f, 0.5f, 0.5f); -static constexpr Vector3 CENTER (0.5f, 0.5f, 0.5f); -static constexpr Vector3 CENTER_RIGHT (1.0f, 0.5f, 0.5f); -static constexpr Vector3 BOTTOM_LEFT (0.0f, 1.0f, 0.5f); +static constexpr float TOP = 0.0f; +static constexpr float BOTTOM = 1.0f; +static constexpr float LEFT = 0.0f; +static constexpr float RIGHT = 1.0f; +static constexpr float MIDDLE = 0.5f; +static constexpr Vector3 TOP_LEFT(0.0f, 0.0f, 0.5f); +static constexpr Vector3 TOP_CENTER(0.5f, 0.0f, 0.5f); +static constexpr Vector3 TOP_RIGHT(1.0f, 0.0f, 0.5f); +static constexpr Vector3 CENTER_LEFT(0.0f, 0.5f, 0.5f); +static constexpr Vector3 CENTER(0.5f, 0.5f, 0.5f); +static constexpr Vector3 CENTER_RIGHT(1.0f, 0.5f, 0.5f); +static constexpr Vector3 BOTTOM_LEFT(0.0f, 1.0f, 0.5f); static constexpr Vector3 BOTTOM_CENTER(0.5f, 1.0f, 0.5f); -static constexpr Vector3 BOTTOM_RIGHT (1.0f, 1.0f, 0.5f); -static constexpr Vector3 DEFAULT( TOP_LEFT ); -} +static constexpr Vector3 BOTTOM_RIGHT(1.0f, 1.0f, 0.5f); +static constexpr Vector3 DEFAULT(TOP_LEFT); +} // namespace ParentOrigin /** * @brief AnchorPoint constants. @@ -66,23 +66,22 @@ static constexpr Vector3 DEFAULT( TOP_LEFT ); */ namespace AnchorPoint { -static constexpr float TOP = 0.0f; -static constexpr float BOTTOM = 1.0f; -static constexpr float LEFT = 0.0f; -static constexpr float RIGHT = 1.0f; -static constexpr float MIDDLE = 0.5f; -static constexpr Vector3 TOP_LEFT (0.0f, 0.0f, 0.5f); -static constexpr Vector3 TOP_CENTER (0.5f, 0.0f, 0.5f); -static constexpr Vector3 TOP_RIGHT (1.0f, 0.0f, 0.5f); -static constexpr Vector3 CENTER_LEFT (0.0f, 0.5f, 0.5f); -static constexpr Vector3 CENTER (0.5f, 0.5f, 0.5f); -static constexpr Vector3 CENTER_RIGHT (1.0f, 0.5f, 0.5f); -static constexpr Vector3 BOTTOM_LEFT (0.0f, 1.0f, 0.5f); +static constexpr float TOP = 0.0f; +static constexpr float BOTTOM = 1.0f; +static constexpr float LEFT = 0.0f; +static constexpr float RIGHT = 1.0f; +static constexpr float MIDDLE = 0.5f; +static constexpr Vector3 TOP_LEFT(0.0f, 0.0f, 0.5f); +static constexpr Vector3 TOP_CENTER(0.5f, 0.0f, 0.5f); +static constexpr Vector3 TOP_RIGHT(1.0f, 0.0f, 0.5f); +static constexpr Vector3 CENTER_LEFT(0.0f, 0.5f, 0.5f); +static constexpr Vector3 CENTER(0.5f, 0.5f, 0.5f); +static constexpr Vector3 CENTER_RIGHT(1.0f, 0.5f, 0.5f); +static constexpr Vector3 BOTTOM_LEFT(0.0f, 1.0f, 0.5f); static constexpr Vector3 BOTTOM_CENTER(0.5f, 1.0f, 0.5f); -static constexpr Vector3 BOTTOM_RIGHT (1.0f, 1.0f, 0.5f); -static constexpr Vector3 DEFAULT( CENTER ); -} - +static constexpr Vector3 BOTTOM_RIGHT(1.0f, 1.0f, 0.5f); +static constexpr Vector3 DEFAULT(CENTER); +} // namespace AnchorPoint /** * @brief Color Constants. @@ -92,15 +91,15 @@ static constexpr Vector3 DEFAULT( CENTER ); */ namespace Color { -static constexpr Vector4 BLACK( 0.0f, 0.0f, 0.0f, 1.0f ); -static constexpr Vector4 WHITE( 1.0f, 1.0f, 1.0f, 1.0f ); -static constexpr Vector4 RED( 1.0f, 0.0f, 0.0f, 1.0f ); -static constexpr Vector4 GREEN( 0.0f, 1.0f, 0.0f, 1.0f ); -static constexpr Vector4 BLUE( 0.0f, 0.0f, 1.0f, 1.0f ); -static constexpr Vector4 YELLOW( 1.0f, 1.0f, 0.0f, 1.0f ); -static constexpr Vector4 MAGENTA( 1.0f, 0.0f, 1.0f, 1.0f ); -static constexpr Vector4 CYAN( 0.0f, 1.0f, 1.0f, 1.0f ); -static constexpr Vector4 TRANSPARENT( 0.0f, 0.0f, 0.0f, 0.0f ); +static constexpr Vector4 BLACK(0.0f, 0.0f, 0.0f, 1.0f); +static constexpr Vector4 WHITE(1.0f, 1.0f, 1.0f, 1.0f); +static constexpr Vector4 RED(1.0f, 0.0f, 0.0f, 1.0f); +static constexpr Vector4 GREEN(0.0f, 1.0f, 0.0f, 1.0f); +static constexpr Vector4 BLUE(0.0f, 0.0f, 1.0f, 1.0f); +static constexpr Vector4 YELLOW(1.0f, 1.0f, 0.0f, 1.0f); +static constexpr Vector4 MAGENTA(1.0f, 0.0f, 1.0f, 1.0f); +static constexpr Vector4 CYAN(0.0f, 1.0f, 1.0f, 1.0f); +static constexpr Vector4 TRANSPARENT(0.0f, 0.0f, 0.0f, 0.0f); } // namespace Color @@ -118,11 +117,11 @@ static constexpr float MACHINE_EPSILON_1000 = Epsilon<1000>::value; static constexpr float MACHINE_EPSILON_10000 = Epsilon<10000>::value; // float is preferred to double for performance on ARM targets -static constexpr float PI = static_cast(M_PI); ///< Pi -static constexpr float PI_2 = static_cast(M_PI_2); ///< Pi/2 -static constexpr float PI_4 = static_cast(M_PI_4); ///< Pi/4 -static constexpr float PI_OVER_180 = Dali::Math::PI/180.0f; ///< Constant used to convert degree to radian -static constexpr float ONE80_OVER_PI = 180.0f/Dali::Math::PI; ///< Constant used to convert radian to degree +static constexpr float PI = static_cast(M_PI); ///< Pi +static constexpr float PI_2 = static_cast(M_PI_2); ///< Pi/2 +static constexpr float PI_4 = static_cast(M_PI_4); ///< Pi/4 +static constexpr float PI_OVER_180 = Dali::Math::PI / 180.0f; ///< Constant used to convert degree to radian +static constexpr float ONE80_OVER_PI = 180.0f / Dali::Math::PI; ///< Constant used to convert radian to degree } // namespace Math diff --git a/dali/public-api/common/dali-common.cpp b/dali/public-api/common/dali-common.cpp index 2db0945..486606a 100644 --- a/dali/public-api/common/dali-common.cpp +++ b/dali/public-api/common/dali-common.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -20,8 +20,8 @@ // EXTERNAL INCLUDES #include -#include #include +#include #if defined(BACKTRACE_ENABLED) #if defined(__GLIBC__) @@ -36,7 +36,6 @@ namespace Dali { - #if defined(BACKTRACE_ENABLED) namespace @@ -54,9 +53,9 @@ std::string Demangle(const char* symbol) if(openParen != NULL) { const char* startOfToken = openParen + 1; - const char* plus = strchr(startOfToken, '+'); - const char* closeParen = strchr(startOfToken, ')'); - const char* endOfToken = NULL; + const char* plus = strchr(startOfToken, '+'); + const char* closeParen = strchr(startOfToken, ')'); + const char* endOfToken = NULL; if(plus != NULL) { endOfToken = plus; @@ -70,17 +69,17 @@ std::string Demangle(const char* symbol) size_t tokenLength = endOfToken - startOfToken; // Allocate space for symbol - char *mangledSymbol = reinterpret_cast< char* >( malloc( tokenLength + 1u ) ); + char* mangledSymbol = reinterpret_cast(malloc(tokenLength + 1u)); if(mangledSymbol != NULL) { strncpy(mangledSymbol, startOfToken, tokenLength); mangledSymbol[tokenLength] = '\0'; - size_t size; - int32_t status; - char* demangled=NULL; - demangled = abi::__cxa_demangle( mangledSymbol, NULL, &size, &status ); - if( demangled != NULL ) + size_t size; + int32_t status; + char* demangled = NULL; + demangled = abi::__cxa_demangle(mangledSymbol, NULL, &size, &status); + if(demangled != NULL) { result = demangled; free(demangled); // demangle() allocates returned string, so free it @@ -97,8 +96,9 @@ std::string Demangle(const char* symbol) return result; } -DALI_CORE_API DaliException::DaliException( const char* location, const char* condition ) -: location( location ), condition( condition ) +DALI_CORE_API DaliException::DaliException(const char* location, const char* condition) +: location(location), + condition(condition) { // Note, if a memory error has occured, then the backtrace won't work - backtrace_symbols relies on // allocating memory. @@ -108,45 +108,44 @@ DALI_CORE_API DaliException::DaliException( const char* location, const char* co #if defined(DEBUG_ENABLED) fprintf(stderr, "Exception: \n%s\n thrown at %s\nSee dlog for backtrace\n", condition, location); #else - fprintf(stderr, "Exception: \n%s\n thrown\nSee dlog for backtrace\n", condition ); + fprintf(stderr, "Exception: \n%s\n thrown\nSee dlog for backtrace\n", condition); #endif DALI_LOG_ERROR_NOFN("Backtrace:\n"); - void* frameArray[MAX_NUM_STACK_FRAMES]; - int32_t nSize = backtrace(frameArray, MAX_NUM_STACK_FRAMES); - char** symbols = backtrace_symbols(frameArray, nSize); - for(int32_t i=1; i< nSize; i++) + void* frameArray[MAX_NUM_STACK_FRAMES]; + int32_t nSize = backtrace(frameArray, MAX_NUM_STACK_FRAMES); + char** symbols = backtrace_symbols(frameArray, nSize); + for(int32_t i = 1; i < nSize; i++) { std::string demangled_symbol = Demangle(symbols[i]); - DALI_LOG_ERROR_NOFN("[%02d] %s\n", i, demangled_symbol.c_str() ); + DALI_LOG_ERROR_NOFN("[%02d] %s\n", i, demangled_symbol.c_str()); } free(symbols); } - #else // BACKTRACE_ENABLED -DALI_CORE_API DaliException::DaliException( const char* location, const char* condition ) -: location( location ), condition( condition ) +DALI_CORE_API DaliException::DaliException(const char* location, const char* condition) +: location(location), + condition(condition) { #if defined(DEBUG_ENABLED) - printf("Exception: \n%s\n thrown at %s\n", condition, location ); + printf("Exception: \n%s\n thrown at %s\n", condition, location); #else - printf("Exception: \n%s\n thrown\n", condition ); + printf("Exception: \n%s\n thrown\n", condition); #endif } - #endif // BACKTRACE_ENABLED -DALI_CORE_API void DaliAssertMessage( const char* location, const char* condition ) +DALI_CORE_API void DaliAssertMessage(const char* location, const char* condition) { #if defined(DEBUG_ENABLED) - DALI_LOG_ERROR_NOFN( "Assert (%s) failed in: %s\n", condition, location ); + DALI_LOG_ERROR_NOFN("Assert (%s) failed in: %s\n", condition, location); #else - DALI_LOG_ERROR_NOFN( "Assert (%s) failed\n", condition ); + DALI_LOG_ERROR_NOFN("Assert (%s) failed\n", condition); #endif } -} // Dali +} // namespace Dali diff --git a/dali/public-api/common/dali-common.h b/dali/public-api/common/dali-common.h old mode 100755 new mode 100644 index c858328..a32e4a8 --- a/dali/public-api/common/dali-common.h +++ b/dali/public-api/common/dali-common.h @@ -31,43 +31,43 @@ * When building a library that uses DALI, HIDE_DALI_INTERNALS. */ #if __GNUC__ >= 4 -# ifndef HIDE_DALI_INTERNALS -# define DALI_EXPORT_API -# define DALI_NO_EXPORT_API -# define DALI_IMPORT_API -# define DALI_CORE_API -# define DALI_INTERNAL -# else -# define DALI_EXPORT_API __attribute__ ((visibility ("default"))) -# define DALI_NO_EXPORT_API __attribute__ ((visibility ("hidden"))) -# define DALI_IMPORT_API __attribute__ ((visibility ("default"))) -# define DALI_CORE_API __attribute__ ((visibility ("default"))) -# define DALI_INTERNAL __attribute__ ((visibility ("hidden"))) -# endif +#ifndef HIDE_DALI_INTERNALS +#define DALI_EXPORT_API +#define DALI_NO_EXPORT_API +#define DALI_IMPORT_API +#define DALI_CORE_API +#define DALI_INTERNAL +#else +#define DALI_EXPORT_API __attribute__((visibility("default"))) +#define DALI_NO_EXPORT_API __attribute__((visibility("hidden"))) +#define DALI_IMPORT_API __attribute__((visibility("default"))) +#define DALI_CORE_API __attribute__((visibility("default"))) +#define DALI_INTERNAL __attribute__((visibility("hidden"))) +#endif #else #ifdef WIN32 - /** Visibility attribute to show declarations */ -# define DALI_EXPORT_API __declspec(dllexport) +/** Visibility attribute to show declarations */ +#define DALI_EXPORT_API __declspec(dllexport) #ifdef BUILDING_DALI_CORE - /** Visibility attribute to hide declarations */ -# define DALI_CORE_API __declspec(dllexport) +/** Visibility attribute to hide declarations */ +#define DALI_CORE_API __declspec(dllexport) #else /** Visibility attribute to hide declarations */ -# define DALI_CORE_API __declspec(dllimport) +#define DALI_CORE_API __declspec(dllimport) #endif #else - /** Visibility attribute to show declarations */ -# define DALI_EXPORT_API /** Visibility attribute to show declarations */ -# define DALI_IMPORT_API +#define DALI_EXPORT_API +/** Visibility attribute to show declarations */ +#define DALI_IMPORT_API /** Visibility attribute to show declarations */ -# define DALI_CORE_API +#define DALI_CORE_API #endif /** Visibility attribute to hide declarations */ -# define DALI_INTERNAL -# define DALI_NO_EXPORT_API +#define DALI_INTERNAL +#define DALI_NO_EXPORT_API #endif #ifdef DEPRECATION_WARNING @@ -76,7 +76,7 @@ #define DALI_DEPRECATED_API #endif -#if defined (__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L) +#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L) // C++0x support #define _CPP11 #else @@ -91,10 +91,10 @@ * @SINCE_1_0.0 */ #ifdef __GNUC -#define DALI_LIKELY(expression) __builtin_expect( !!(expression), 1 ) -#define DALI_UNLIKELY(expression) __builtin_expect( !!(expression), 0 ) +#define DALI_LIKELY(expression) __builtin_expect(!!(expression), 1) +#define DALI_UNLIKELY(expression) __builtin_expect(!!(expression), 0) #else -#define DALI_LIKELY(expression) !!(expression) +#define DALI_LIKELY(expression) !!(expression) #define DALI_UNLIKELY(expression) !!(expression) #endif @@ -116,7 +116,7 @@ namespace Dali * @param[in] location Where the assertion occurred * @param[in] condition The assertion condition */ -DALI_CORE_API void DaliAssertMessage( const char* location, const char* condition ); +DALI_CORE_API void DaliAssertMessage(const char* location, const char* condition); /** * @brief Exception class for Dali Core library - Raised by assertions in codebase. @@ -134,7 +134,7 @@ public: * @param[in] location The location of the assertion * @param[in] condition The assertion condition */ - DaliException( const char* location, const char* condition ); + DaliException(const char* location, const char* condition); const char* location; const char* condition; @@ -143,7 +143,7 @@ public: /** * @} */ -}// Dali +} // namespace Dali /** * @brief An invariant concurrent assertion to ensure its argument always evaluates TRUE. @@ -181,17 +181,17 @@ public: #define ASSERT_LOCATION NULL #endif -#define DALI_ASSERT_ALWAYS(cond) \ - if(DALI_UNLIKELY(!(cond))) \ - { \ - Dali::DaliAssertMessage( ASSERT_LOCATION, #cond ); \ - throw Dali::DaliException( ASSERT_LOCATION, #cond ); \ +#define DALI_ASSERT_ALWAYS(cond) \ + if(DALI_UNLIKELY(!(cond))) \ + { \ + Dali::DaliAssertMessage(ASSERT_LOCATION, #cond); \ + throw Dali::DaliException(ASSERT_LOCATION, #cond); \ } -#define DALI_ABORT(message) \ - { \ - Dali::DaliAssertMessage( ASSERT_LOCATION, message ); \ - throw Dali::DaliException( ASSERT_LOCATION, message ); \ +#define DALI_ABORT(message) \ + { \ + Dali::DaliAssertMessage(ASSERT_LOCATION, message); \ + throw Dali::DaliException(ASSERT_LOCATION, message); \ } /** diff --git a/dali/public-api/common/dali-vector.cpp b/dali/public-api/common/dali-vector.cpp index 4acbe52..e12f4ab 100644 --- a/dali/public-api/common/dali-vector.cpp +++ b/dali/public-api/common/dali-vector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -23,9 +23,8 @@ namespace Dali { - VectorBase::VectorBase() - : mData( nullptr ) +: mData(nullptr) { } @@ -36,58 +35,57 @@ VectorBase::~VectorBase() VectorBase::SizeType VectorBase::Capacity() const { SizeType capacity = 0u; - if( mData ) + if(mData) { - SizeType* metadata = reinterpret_cast< SizeType* >( mData ); - capacity = *(metadata - 2u); + SizeType* metadata = reinterpret_cast(mData); + capacity = *(metadata - 2u); } return capacity; } - void VectorBase::Release() { - if( mData ) + if(mData) { // adjust pointer to real beginning - SizeType* metadata = reinterpret_cast< SizeType* >( mData ); + SizeType* metadata = reinterpret_cast(mData); - delete [] ( metadata - 2u ); + delete[](metadata - 2u); mData = nullptr; } } -void VectorBase::SetCount( SizeType count ) +void VectorBase::SetCount(SizeType count) { // someone can call Resize( 0u ) before ever populating the vector - if( mData ) + if(mData) { - SizeType* metadata = reinterpret_cast< SizeType* >( mData ); - *(metadata - 1u) = count; + SizeType* metadata = reinterpret_cast(mData); + *(metadata - 1u) = count; } } -void VectorBase::Reserve( SizeType capacity, SizeType elementSize ) +void VectorBase::Reserve(SizeType capacity, SizeType elementSize) { SizeType oldCapacity = Capacity(); - SizeType oldCount = Count(); - if( capacity > oldCapacity ) + SizeType oldCount = Count(); + if(capacity > oldCapacity) { const SizeType wholeAllocation = sizeof(SizeType) * 2u + capacity * elementSize; - void* wholeData = reinterpret_cast< void* >( new uint8_t[ wholeAllocation ] ); - DALI_ASSERT_ALWAYS( wholeData && "VectorBase::Reserve - Memory allocation failed" ); + void* wholeData = reinterpret_cast(new uint8_t[wholeAllocation]); + DALI_ASSERT_ALWAYS(wholeData && "VectorBase::Reserve - Memory allocation failed"); -#if defined( DEBUG_ENABLED ) +#if defined(DEBUG_ENABLED) // in debug build this will help identify a vector of uninitialized data - memset( wholeData, 0xaa, wholeAllocation ); + memset(wholeData, 0xaa, wholeAllocation); #endif - SizeType* metaData = reinterpret_cast< SizeType* >( wholeData ); - *metaData++ = capacity; - *metaData++ = oldCount; - if( mData ) + SizeType* metaData = reinterpret_cast(wholeData); + *metaData++ = capacity; + *metaData++ = oldCount; + if(mData) { // copy over the old data - memcpy( metaData, mData, oldCount * elementSize ); + memcpy(metaData, mData, oldCount * elementSize); // release old buffer Release(); } @@ -95,52 +93,52 @@ void VectorBase::Reserve( SizeType capacity, SizeType elementSize ) } } -void VectorBase::Copy( const VectorBase& vector, SizeType elementSize ) +void VectorBase::Copy(const VectorBase& vector, SizeType elementSize) { // release old data Release(); // reserve space based on source capacity const SizeType capacity = vector.Capacity(); - Reserve( capacity, elementSize ); + Reserve(capacity, elementSize); // copy over whole data const SizeType wholeAllocation = sizeof(SizeType) * 2u + capacity * elementSize; - SizeType* srcData = reinterpret_cast< SizeType* >( vector.mData ); - SizeType* dstData = reinterpret_cast< SizeType* >( mData ); - memcpy( dstData - 2u, srcData - 2u, wholeAllocation ); + SizeType* srcData = reinterpret_cast(vector.mData); + SizeType* dstData = reinterpret_cast(mData); + memcpy(dstData - 2u, srcData - 2u, wholeAllocation); } -void VectorBase::Swap( VectorBase& vector ) +void VectorBase::Swap(VectorBase& vector) { // just swap the data pointers, metadata will swap as side effect - std::swap( mData, vector.mData ); + std::swap(mData, vector.mData); } -void VectorBase::Erase( char* address, SizeType elementSize ) +void VectorBase::Erase(char* address, SizeType elementSize) { // erase can be called on an unallocated vector - if( mData ) + if(mData) { - uint8_t* startAddress = reinterpret_cast< uint8_t* >( address ) + elementSize; - const uint8_t* endAddress = reinterpret_cast< uint8_t* >( mData ) + Count() * elementSize; - SizeType numberOfBytes = endAddress - startAddress; + uint8_t* startAddress = reinterpret_cast(address) + elementSize; + const uint8_t* endAddress = reinterpret_cast(mData) + Count() * elementSize; + SizeType numberOfBytes = endAddress - startAddress; // addresses overlap so use memmove - memmove( address, startAddress, numberOfBytes ); - SetCount( Count() - 1u ); + memmove(address, startAddress, numberOfBytes); + SetCount(Count() - 1u); } } -char* VectorBase::Erase( char* first, char* last, SizeType elementSize ) +char* VectorBase::Erase(char* first, char* last, SizeType elementSize) { char* next = nullptr; - if( mData ) + if(mData) { - uint8_t* startAddress = reinterpret_cast< uint8_t* >( last ); - const uint8_t* endAddress = reinterpret_cast< uint8_t* >( mData ) + Count() * elementSize; - SizeType numberOfBytes = endAddress - startAddress; + uint8_t* startAddress = reinterpret_cast(last); + const uint8_t* endAddress = reinterpret_cast(mData) + Count() * elementSize; + SizeType numberOfBytes = endAddress - startAddress; // addresses overlap so use memmove - memmove( first, startAddress, numberOfBytes ); - SetCount( Count() - ( last - first ) / elementSize ); + memmove(first, startAddress, numberOfBytes); + SetCount(Count() - (last - first) / elementSize); next = first; } @@ -148,20 +146,19 @@ char* VectorBase::Erase( char* first, char* last, SizeType elementSize ) return next; } -void VectorBase::CopyMemory( char* destination, const char* source, size_t numberOfBytes ) +void VectorBase::CopyMemory(char* destination, const char* source, size_t numberOfBytes) { - if( ( ( source < destination ) && ( source + numberOfBytes > destination ) ) || - ( ( destination < source ) && ( destination + numberOfBytes > source ) ) ) + if(((source < destination) && (source + numberOfBytes > destination)) || + ((destination < source) && (destination + numberOfBytes > source))) { // If there is overlap, use memmove. - memmove( destination, source, numberOfBytes ); + memmove(destination, source, numberOfBytes); } else { // It's safe to use memcpy if there isn't overlap. - memcpy( destination, source, numberOfBytes ); + memcpy(destination, source, numberOfBytes); } } } // namespace Dali - diff --git a/dali/public-api/common/dali-vector.h b/dali/public-api/common/dali-vector.h index b76a1fa..e4bb8ce 100644 --- a/dali/public-api/common/dali-vector.h +++ b/dali/public-api/common/dali-vector.h @@ -19,8 +19,8 @@ */ // EXTERNAL INCLUDES -#include #include +#include #include // uint32_t // INTERNAL INCLUDES @@ -34,11 +34,11 @@ * For Application use, asserts can be enabled manually. * @SINCE_1_0.0 */ -#if defined( DEBUG_ENABLED ) +#if defined(DEBUG_ENABLED) #define ENABLE_VECTOR_ASSERTS #endif -#if defined( ENABLE_VECTOR_ASSERTS ) +#if defined(ENABLE_VECTOR_ASSERTS) #define DALI_ASSERT_VECTOR(cond) DALI_ASSERT_ALWAYS(cond) #else #define DALI_ASSERT_VECTOR(cond) @@ -65,7 +65,6 @@ public: // Typedefs using SizeType = std::size_t; protected: // Construction - /** * @brief Default constructor. Does not allocate space. * @SINCE_1_0.0 @@ -83,7 +82,6 @@ protected: // Construction ~VectorBase(); public: // API - /** * @brief This method is inlined as it's needed frequently for Vector::End() iterator. * @@ -93,10 +91,10 @@ public: // API SizeType Count() const { SizeType items = 0u; - if( mData ) + if(mData) { - SizeType* metadata = reinterpret_cast< SizeType* >( mData ); - items = *(metadata - 1u); + SizeType* metadata = reinterpret_cast(mData); + items = *(metadata - 1u); } return items; } @@ -137,14 +135,13 @@ public: // API void Release(); protected: // for Derived classes - /** * @brief Helper to set the count. * * @SINCE_1_0.0 * @param[in] count Number of elements in the vector */ - void SetCount( SizeType count ); + void SetCount(SizeType count); /** * @brief Reserves space in the vector. @@ -153,7 +150,7 @@ protected: // for Derived classes * @param[in] count Count of elements to reserve * @param[in] elementSize Size of a single element */ - void Reserve( SizeType count, SizeType elementSize ); + void Reserve(SizeType count, SizeType elementSize); /** * @brief Copy a vector. @@ -162,7 +159,7 @@ protected: // for Derived classes * @param[in] vector Vector to copy from * @param[in] elementSize Size of a single element */ - void Copy( const VectorBase& vector, SizeType elementSize ); + void Copy(const VectorBase& vector, SizeType elementSize); /** * @brief Swaps the contents of two vectors. @@ -170,7 +167,7 @@ protected: // for Derived classes * @SINCE_1_0.0 * @param[in] vector Vector to swap with */ - void Swap( VectorBase& vector ); + void Swap(VectorBase& vector); /** * @brief Erases an element. @@ -181,7 +178,7 @@ protected: // for Derived classes * @param[in] elementSize Size to erase * @pre Last element cannot be erased as there is nothing to move. */ - void Erase( char* address, SizeType elementSize ); + void Erase(char* address, SizeType elementSize); /** * @brief Erases a range of elements. @@ -193,7 +190,7 @@ protected: // for Derived classes * @param[in] elementSize Size of one of the elements to be erased * @return Address pointing to the next element of the last one */ - char* Erase( char* first, char* last, SizeType elementSize ); + char* Erase(char* first, char* last, SizeType elementSize); /** * @brief Copies a number of bytes from \e source to \e destination. @@ -205,22 +202,19 @@ protected: // for Derived classes * @param[in] source Pointer to the source address * @param[in] numberOfBytes The number of bytes to be copied */ - void CopyMemory( char* destination, const char* source, size_t numberOfBytes ); + void CopyMemory(char* destination, const char* source, size_t numberOfBytes); private: - // not copyable as it does not know the size of elements - VectorBase( const VectorBase& ) = delete; ///< Deleted copy constructor. @SINCE_1_0.0 - VectorBase& operator=( const VectorBase& ) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0 + VectorBase(const VectorBase&) = delete; ///< Deleted copy constructor. @SINCE_1_0.0 + VectorBase& operator=(const VectorBase&) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0 // not movable as this is handled by deriving classes - VectorBase( VectorBase&& ) = delete; ///< Deleted move constructor. @SINCE_1_9.25 - VectorBase& operator=( VectorBase&& ) = delete; ///< Deleted copy assignment operator. @SINCE_1_9.25 - -protected: // Data + VectorBase(VectorBase&&) = delete; ///< Deleted move constructor. @SINCE_1_9.25 + VectorBase& operator=(VectorBase&&) = delete; ///< Deleted copy assignment operator. @SINCE_1_9.25 +protected: // Data void* mData; ///< Pointer to the data. - }; /// @cond internal @@ -230,7 +224,7 @@ protected: // Data * Trivial types do not need destructor or copy constructor called. * @SINCE_1_0.0 */ -template< bool IsTrivial > +template class VectorAlgorithms : public VectorBase { protected: // API for deriving classes @@ -241,14 +235,16 @@ protected: // API for deriving classes * @SINCE_1_0.0 */ VectorAlgorithms() - { } + { + } /** * @brief Empty destructor. * @SINCE_1_0.0 */ ~VectorAlgorithms() - { } + { + } /** * @brief Copy vector contents. @@ -257,11 +253,11 @@ protected: // API for deriving classes * @param[in] rhs VectorBase object to copy from * @param[in] elementSize Size of the content */ - void Copy( const VectorBase& rhs, SizeType elementSize ) + void Copy(const VectorBase& rhs, SizeType elementSize) { - if( rhs.Capacity() > 0u ) + if(rhs.Capacity() > 0u) { - VectorBase::Copy( rhs, elementSize ); + VectorBase::Copy(rhs, elementSize); } else { @@ -276,9 +272,9 @@ protected: // API for deriving classes * @param[in] count Count of elements to reserve * @param[in] elementSize Size of a single element */ - void Reserve( SizeType count, SizeType elementSize ) + void Reserve(SizeType count, SizeType elementSize) { - VectorBase::Reserve( count, elementSize ); + VectorBase::Reserve(count, elementSize); } /** @@ -288,10 +284,10 @@ protected: // API for deriving classes * @param[in] count Count to resize to * @param[in] elementSize Size of a single element */ - void Resize( SizeType count, SizeType elementSize ) + void Resize(SizeType count, SizeType elementSize) { // reserve will copy old elements as well - Reserve( count, elementSize ); + Reserve(count, elementSize); } /** @@ -302,9 +298,9 @@ protected: // API for deriving classes */ void Clear() { - if( mData ) + if(mData) { - VectorBase::SetCount( 0u ); + VectorBase::SetCount(0u); } } @@ -324,9 +320,9 @@ protected: // API for deriving classes * @param[in] address Address to erase from * @param[in] elementSize Size to erase */ - void Erase( uint8_t* address, SizeType elementSize ) + void Erase(uint8_t* address, SizeType elementSize) { - VectorBase::Erase( reinterpret_cast< char* >( address ), elementSize ); + VectorBase::Erase(reinterpret_cast(address), elementSize); } /** @@ -338,9 +334,9 @@ protected: // API for deriving classes * @param[in] elementSize Size of one of the elements to be erased * @return Address pointing to the next element of the last one */ - uint8_t* Erase( uint8_t* first, uint8_t* last, SizeType elementSize ) + uint8_t* Erase(uint8_t* first, uint8_t* last, SizeType elementSize) { - return reinterpret_cast< uint8_t* >( VectorBase::Erase( reinterpret_cast< char* >( first ), reinterpret_cast< char *>( last ), elementSize ) ); + return reinterpret_cast(VectorBase::Erase(reinterpret_cast(first), reinterpret_cast(last), elementSize)); } /** @@ -352,33 +348,33 @@ protected: // API for deriving classes * @param[in] to Address to the last element to be inserted * @param[in] elementSize Size of one of the elements to be inserted */ - void Insert( uint8_t* at, uint8_t* from, uint8_t* to, SizeType elementSize ) + void Insert(uint8_t* at, uint8_t* from, uint8_t* to, SizeType elementSize) { - const SizeType size = to - from; - const SizeType count = Count(); + const SizeType size = to - from; + const SizeType count = Count(); const SizeType newCount = count + size / elementSize; - if( newCount > Capacity() ) + if(newCount > Capacity()) { // Calculate the at offset as the pointer is invalid after the Reserve() call. - std::size_t offset = at - reinterpret_cast( mData ); + std::size_t offset = at - reinterpret_cast(mData); // need more space - Reserve( NextPowerOfTwo( static_cast( newCount ) ), elementSize ); // reserve enough space to store at least the next power of two elements of the new required size. + Reserve(NextPowerOfTwo(static_cast(newCount)), elementSize); // reserve enough space to store at least the next power of two elements of the new required size. // Set the new at pointer. - at = reinterpret_cast( mData ) + offset; + at = reinterpret_cast(mData) + offset; } // set new count first as otherwise the debug assert will hit us - SetCount( newCount ); + SetCount(newCount); // Move current items to a new position inside the vector. - CopyMemory( reinterpret_cast< char* >( at + size ), - reinterpret_cast< const char* >( at ), - ( reinterpret_cast( mData ) + count * elementSize ) - at ); + CopyMemory(reinterpret_cast(at + size), + reinterpret_cast(at), + (reinterpret_cast(mData) + count * elementSize) - at); // Copy the given items. - CopyMemory( reinterpret_cast< char* >( at ), reinterpret_cast< const char* >( from ), size ); + CopyMemory(reinterpret_cast(at), reinterpret_cast(from), size); } }; /// @endcond @@ -393,13 +389,15 @@ protected: // API for deriving classes * @SINCE_1_0.0 */ template<> -class VectorAlgorithms< false > : public VectorBase +class VectorAlgorithms : public VectorBase { private: VectorAlgorithms() - { } + { + } ~VectorAlgorithms() - { } + { + } }; /// @endcond @@ -409,11 +407,10 @@ private: * @SINCE_1_0.0 * @param type The type of the data that the vector holds */ -template< class T, bool IsTrivialType = TypeTraits::IS_TRIVIAL_TYPE == true > -class Vector : public VectorAlgorithms< IsTrivialType > +template::IS_TRIVIAL_TYPE == true> +class Vector : public VectorAlgorithms { public: // API - /** * @brief Type definitions. * @SINCE_1_0.0 @@ -437,7 +434,8 @@ public: // API * @SINCE_1_0.0 */ Vector() - { } + { + } /** * @brief Destructor. Releases the allocated space. @@ -454,10 +452,10 @@ public: // API * @SINCE_1_0.0 * @param[in] vector Vector to copy from */ - Vector( const Vector& vector ) + Vector(const Vector& vector) { // reuse copy assignment - operator=( vector ); + operator=(vector); } /** @@ -466,10 +464,10 @@ public: // API * @SINCE_1_9.25 * @param[in] vector Vector to move */ - Vector( Vector&& vector ) + Vector(Vector&& vector) { // reuse move assignment - operator=( std::move( vector ) ); + operator=(std::move(vector)); } /** @@ -479,11 +477,11 @@ public: // API * @param[in] vector Vector to assign from * @return Reference to self for chaining */ - Vector& operator=( const Vector& vector ) + Vector& operator=(const Vector& vector) { - if( this != &vector ) + if(this != &vector) { - VectorAlgorithms::Copy( vector, sizeof( ItemType ) ); + VectorAlgorithms::Copy(vector, sizeof(ItemType)); } return *this; } @@ -494,16 +492,16 @@ public: // API * @SINCE_1_9.25 * @param[in] vector Vector to move */ - Vector& operator=( Vector&& vector ) + Vector& operator=(Vector&& vector) { - if( this != &vector ) + if(this != &vector) { - if( VectorBase::mData ) + if(VectorBase::mData) { Release(); } VectorBase::mData = vector.mData; - vector.mData = nullptr; + vector.mData = nullptr; } return *this; } @@ -515,7 +513,7 @@ public: // API */ Iterator Begin() const { - ItemType* address = reinterpret_cast( VectorBase::mData ); + ItemType* address = reinterpret_cast(VectorBase::mData); return address; } @@ -526,7 +524,7 @@ public: // API */ Iterator End() const { - ItemType* address = reinterpret_cast( VectorBase::mData ); + ItemType* address = reinterpret_cast(VectorBase::mData); address += VectorBase::Count(); return address; } @@ -558,10 +556,10 @@ public: // API * @return Reference to the element for given index * @pre Index must be in the vector's range. */ - ItemType& operator[]( SizeType index ) + ItemType& operator[](SizeType index) { // reuse the const version - return const_cast< ItemType& >( const_cast< const Vector< ItemType >& >( *this )[ index ] ); + return const_cast(const_cast&>(*this)[index]); } /** @@ -571,11 +569,11 @@ public: // API * @return Reference to the element for given index * @pre Index must be in the vector's range. */ - const ItemType& operator[]( SizeType index ) const + const ItemType& operator[](SizeType index) const { - DALI_ASSERT_VECTOR( VectorBase::mData && "Vector is empty" ); - DALI_ASSERT_VECTOR( index < VectorBase::Count() && "Index out of bounds" ); - ItemType* address = reinterpret_cast( VectorBase::mData ); + DALI_ASSERT_VECTOR(VectorBase::mData && "Vector is empty"); + DALI_ASSERT_VECTOR(index < VectorBase::Count() && "Index out of bounds"); + ItemType* address = reinterpret_cast(VectorBase::mData); address += index; return *address; } @@ -590,19 +588,19 @@ public: // API * @SINCE_1_0.0 * @param[in] element Element to be added */ - void PushBack( const ItemType& element ) + void PushBack(const ItemType& element) { - const SizeType count = VectorBase::Count(); + const SizeType count = VectorBase::Count(); const SizeType newCount = count + 1u; const SizeType capacity = VectorBase::Capacity(); - if( newCount > capacity ) + if(newCount > capacity) { // need more space - Reserve( newCount << 1u ); // reserve double the current count + Reserve(newCount << 1u); // reserve double the current count } // set new count first as otherwise the debug assert will hit us - VectorBase::SetCount( newCount ); - operator[]( count ) = element; + VectorBase::SetCount(newCount); + operator[](count) = element; } /** @@ -619,15 +617,15 @@ public: // API * @param[in] element An element to be added * @pre Iterator at must be in the vector's range ( Vector::Begin(), Vector::End() ). */ - void Insert( Iterator at, const ItemType& element ) + void Insert(Iterator at, const ItemType& element) { - DALI_ASSERT_VECTOR( ( at <= End() ) && ( at >= Begin() ) && "Iterator not inside vector" ); - const SizeType size = sizeof( ItemType ); - uint8_t* address = const_cast( reinterpret_cast( &element ) ); - VectorAlgorithms::Insert( reinterpret_cast< uint8_t* >( at ), - address, - address + size, - size ); + DALI_ASSERT_VECTOR((at <= End()) && (at >= Begin()) && "Iterator not inside vector"); + const SizeType size = sizeof(ItemType); + uint8_t* address = const_cast(reinterpret_cast(&element)); + VectorAlgorithms::Insert(reinterpret_cast(at), + address, + address + size, + size); } /** @@ -648,21 +646,21 @@ public: // API * @pre Iterator \e from must not be grater than Iterator \e to. * */ - void Insert( Iterator at, Iterator from, Iterator to ) + void Insert(Iterator at, Iterator from, Iterator to) { - DALI_ASSERT_VECTOR( ( at <= End() ) && ( at >= Begin() ) && "Iterator not inside vector" ); - DALI_ASSERT_VECTOR( ( from <= to ) && "from address can't be greater than to" ); + DALI_ASSERT_VECTOR((at <= End()) && (at >= Begin()) && "Iterator not inside vector"); + DALI_ASSERT_VECTOR((from <= to) && "from address can't be greater than to"); - if( from == to ) + if(from == to) { // nothing to copy. return; } - VectorAlgorithms::Insert( reinterpret_cast< uint8_t* >( at ), - reinterpret_cast< uint8_t* >( from ), - reinterpret_cast< uint8_t* >( to ), - sizeof( ItemType ) ); + VectorAlgorithms::Insert(reinterpret_cast(at), + reinterpret_cast(from), + reinterpret_cast(to), + sizeof(ItemType)); } /** @@ -672,9 +670,9 @@ public: // API * @SINCE_1_0.0 * @param[in] count Count of elements to reserve */ - void Reserve( SizeType count ) + void Reserve(SizeType count) { - VectorAlgorithms::Reserve( count, sizeof( ItemType ) ); + VectorAlgorithms::Reserve(count, sizeof(ItemType)); } /** @@ -683,7 +681,7 @@ public: // API * @SINCE_1_0.0 * @param[in] count Count to resize to */ - void Resize( SizeType count ) + void Resize(SizeType count) { ItemType item = ItemType(); Resize(count, item); @@ -696,10 +694,10 @@ public: // API * @SINCE_1_9.27 * @param[in] count Count to resize to */ - void ResizeUninitialized( SizeType count ) + void ResizeUninitialized(SizeType count) { - Reserve( count ); - VectorBase::SetCount( count ); + Reserve(count); + VectorBase::SetCount(count); } /** @@ -709,22 +707,22 @@ public: // API * @param[in] count Count to resize to * @param[in] item An item to insert to the new indices */ - void Resize( SizeType count, const ItemType& item ) + void Resize(SizeType count, const ItemType& item) { const SizeType oldCount = VectorBase::Count(); - if( count <= oldCount ) + if(count <= oldCount) { // getting smaller so just set count - VectorBase::SetCount( count ); + VectorBase::SetCount(count); } else { // remember how many new items get added SizeType newItems = count - oldCount; - Reserve( count ); - for( ; newItems > 0u; --newItems ) + Reserve(count); + for(; newItems > 0u; --newItems) { - PushBack( item ); + PushBack(item); } } } @@ -740,17 +738,17 @@ public: // API * @pre Iterator \e iterator must be within the vector's range ( Vector::Begin(), Vector::End() - 1 ). * */ - Iterator Erase( Iterator iterator ) + Iterator Erase(Iterator iterator) { - DALI_ASSERT_VECTOR( (iterator < End()) && (iterator >= Begin()) && "Iterator not inside vector" ); - if( iterator < ( End() - 1u ) ) + DALI_ASSERT_VECTOR((iterator < End()) && (iterator >= Begin()) && "Iterator not inside vector"); + if(iterator < (End() - 1u)) { - VectorAlgorithms::Erase( reinterpret_cast< uint8_t* >( iterator ), sizeof( ItemType ) ); + VectorAlgorithms::Erase(reinterpret_cast(iterator), sizeof(ItemType)); } else { // just remove the element - Remove( iterator ); + Remove(iterator); } return iterator; } @@ -770,25 +768,25 @@ public: // API * @pre Iterator \e first must not be grater than Iterator \e last. * */ - Iterator Erase( Iterator first, Iterator last ) + Iterator Erase(Iterator first, Iterator last) { - DALI_ASSERT_VECTOR( ( first <= End() ) && ( first >= Begin() ) && "Iterator not inside vector" ); - DALI_ASSERT_VECTOR( ( last <= End() ) && ( last >= Begin() ) && "Iterator not inside vector" ); - DALI_ASSERT_VECTOR( ( first <= last ) && "first iterator greater than last" ); + DALI_ASSERT_VECTOR((first <= End()) && (first >= Begin()) && "Iterator not inside vector"); + DALI_ASSERT_VECTOR((last <= End()) && (last >= Begin()) && "Iterator not inside vector"); + DALI_ASSERT_VECTOR((first <= last) && "first iterator greater than last"); Iterator nextElement; - if( last == End() ) + if(last == End()) { // Erase up to the end. - VectorBase::SetCount( VectorBase::Count() - ( last - first ) ); + VectorBase::SetCount(VectorBase::Count() - (last - first)); nextElement = End(); } else { - nextElement = reinterpret_cast( VectorAlgorithms::Erase( reinterpret_cast< uint8_t* >( first ), - reinterpret_cast< uint8_t* >( last ), - sizeof( ItemType ) ) ); + nextElement = reinterpret_cast(VectorAlgorithms::Erase(reinterpret_cast(first), + reinterpret_cast(last), + sizeof(ItemType))); } return nextElement; @@ -806,16 +804,16 @@ public: // API * @pre Iterator \e iterator must be in the vector's range ( Vector::Begin(), Vector::End() - 1 ). * */ - void Remove( Iterator iterator ) + void Remove(Iterator iterator) { - DALI_ASSERT_VECTOR( (iterator < End()) && (iterator >= Begin()) && "Iterator not inside vector" ); + DALI_ASSERT_VECTOR((iterator < End()) && (iterator >= Begin()) && "Iterator not inside vector"); Iterator last = End() - 1u; - if( last > iterator ) + if(last > iterator) { - std::swap( *iterator, *last ); + std::swap(*iterator, *last); } - VectorBase::SetCount( VectorBase::Count() - 1u ); + VectorBase::SetCount(VectorBase::Count() - 1u); } /** @@ -824,9 +822,9 @@ public: // API * @SINCE_1_0.0 * @param[in] vector Vector to swap with */ - void Swap( Vector& vector ) + void Swap(Vector& vector) { - VectorBase::Swap( vector ); + VectorBase::Swap(vector); } /** diff --git a/dali/public-api/common/extents.cpp b/dali/public-api/common/extents.cpp index 95bdf19..492b064 100644 --- a/dali/public-api/common/extents.cpp +++ b/dali/public-api/common/extents.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -20,49 +20,48 @@ namespace Dali { - Extents::Extents() : start(0), end(0), top(0), bottom(0) - { - } +{ +} -Extents::Extents( uint16_t start, uint16_t end, uint16_t top, uint16_t bottom ) -: start( start ), - end( end ), - top( top ), - bottom( bottom ) - { - } +Extents::Extents(uint16_t start, uint16_t end, uint16_t top, uint16_t bottom) +: start(start), + end(end), + top(top), + bottom(bottom) +{ +} -Extents& Extents::operator=( const uint16_t* array ) +Extents& Extents::operator=(const uint16_t* array) { - start = array[0]; - end = array[1]; - top = array[2]; + start = array[0]; + end = array[1]; + top = array[2]; bottom = array[3]; return *this; } -bool Extents::operator==( const Extents &rhs ) const +bool Extents::operator==(const Extents& rhs) const { - return ( start == rhs.start )&& - ( end == rhs.end )&& - ( top == rhs.top )&& - ( bottom == rhs.bottom ); + return (start == rhs.start) && + (end == rhs.end) && + (top == rhs.top) && + (bottom == rhs.bottom); } -bool Extents::operator!=( const Extents &rhs ) const +bool Extents::operator!=(const Extents& rhs) const { - return !( *this == rhs ); + return !(*this == rhs); } -std::ostream& operator<<( std::ostream& stream, const Extents& extents ) +std::ostream& operator<<(std::ostream& stream, const Extents& extents) { return stream << "[" << extents.start << ", " << extents.end << ", " << extents.top << ", " << extents.bottom << "]"; } -} // Dali +} // namespace Dali diff --git a/dali/public-api/common/extents.h b/dali/public-api/common/extents.h index 95aad55..507d1a1 100644 --- a/dali/public-api/common/extents.h +++ b/dali/public-api/common/extents.h @@ -2,7 +2,7 @@ #define DALI_EXTENTS_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -49,7 +49,7 @@ struct DALI_CORE_API Extents * @SINCE_1_2.62 * @param[in] copy A reference to the copied Extents */ - Extents( const Extents& copy ) = default; + Extents(const Extents& copy) = default; /** * @brief Constructor. @@ -60,7 +60,7 @@ struct DALI_CORE_API Extents * @param[in] top Top extent * @param[in] bottom Bottom extent */ - Extents( uint16_t start, uint16_t end, uint16_t top, uint16_t bottom ); + Extents(uint16_t start, uint16_t end, uint16_t top, uint16_t bottom); /** * @brief Copy Assignment operator. @@ -68,7 +68,7 @@ struct DALI_CORE_API Extents * @param[in] copy A reference to the copied Extents * @return Itself */ - Extents& operator=( const Extents& copy ) = default; + Extents& operator=(const Extents& copy) = default; /** * @brief Assignment operator. @@ -77,7 +77,7 @@ struct DALI_CORE_API Extents * @param[in] array Array of uint16_t * @return Itself */ - Extents& operator=( const uint16_t* array ); + Extents& operator=(const uint16_t* array); /** * @brief Equality operator. @@ -86,7 +86,7 @@ struct DALI_CORE_API Extents * @param[in] rhs The Extents to test against * @return True if the extents are equal */ - bool operator==( const Extents &rhs ) const; + bool operator==(const Extents& rhs) const; /** * @brief Inequality operator. @@ -95,14 +95,13 @@ struct DALI_CORE_API Extents * @param[in] rhs The Extents to test against * @return True if the extents are not equal */ - bool operator!=( const Extents &rhs ) const; + bool operator!=(const Extents& rhs) const; public: - uint16_t start; ///< The start extent. @SINCE_1_2.62 - uint16_t end; ///< The end extent. @SINCE_1_2.62 - uint16_t top; ///< The top extent. @SINCE_1_2.62 - uint16_t bottom; ///< The bottom extent. @SINCE_1_2.62 - + uint16_t start; ///< The start extent. @SINCE_1_2.62 + uint16_t end; ///< The end extent. @SINCE_1_2.62 + uint16_t top; ///< The top extent. @SINCE_1_2.62 + uint16_t bottom; ///< The bottom extent. @SINCE_1_2.62 }; /** @@ -113,7 +112,7 @@ public: * @param[in] extents The Extents to output * @return The output stream operator */ -DALI_CORE_API std::ostream& operator<<( std::ostream& stream, const Extents& extents ); +DALI_CORE_API std::ostream& operator<<(std::ostream& stream, const Extents& extents); /** * @} diff --git a/dali/public-api/common/intrusive-ptr.h b/dali/public-api/common/intrusive-ptr.h index 87fc5f7..b566257 100644 --- a/dali/public-api/common/intrusive-ptr.h +++ b/dali/public-api/common/intrusive-ptr.h @@ -38,14 +38,15 @@ namespace Dali template class IntrusivePtr { - public: - /** * @brief Standard constructor to unassigned object. * @SINCE_1_0.0 */ - IntrusivePtr() : mPtr( nullptr ) {} + IntrusivePtr() + : mPtr(nullptr) + { + } /** * @brief Constructor to attach existing object. @@ -53,9 +54,10 @@ public: * @SINCE_1_0.0 * @param[in] p Pointer to object */ - IntrusivePtr( T* p ) : mPtr( p ) + IntrusivePtr(T* p) + : mPtr(p) { - if( mPtr ) + if(mPtr) { mPtr->Reference(); } @@ -69,9 +71,10 @@ public: * @tparam U Reference counter object type */ template - IntrusivePtr( IntrusivePtr const& rhs ) : mPtr( rhs.Get() ) + IntrusivePtr(IntrusivePtr const& rhs) + : mPtr(rhs.Get()) { - if( mPtr ) + if(mPtr) { mPtr->Reference(); } @@ -82,9 +85,10 @@ public: * @SINCE_1_0.0 * @param[in] rhs Const reference to an IntrusivePtr */ - IntrusivePtr( IntrusivePtr const& rhs ) : mPtr( rhs.mPtr ) + IntrusivePtr(IntrusivePtr const& rhs) + : mPtr(rhs.mPtr) { - if( mPtr ) + if(mPtr) { mPtr->Reference(); } @@ -96,8 +100,8 @@ public: * @param[in] rhs Reference to an IntrusivePtr */ template - IntrusivePtr( IntrusivePtr&& rhs ) - : mPtr( rhs.Detach() ) + IntrusivePtr(IntrusivePtr&& rhs) + : mPtr(rhs.Detach()) { } @@ -106,8 +110,8 @@ public: * @SINCE_1_9.23 * @param[in] rhs Reference to an IntrusivePtr */ - IntrusivePtr( IntrusivePtr&& rhs ) - : mPtr( rhs.Detach() ) + IntrusivePtr(IntrusivePtr&& rhs) + : mPtr(rhs.Detach()) { } @@ -119,7 +123,7 @@ public: */ ~IntrusivePtr() { - if( mPtr ) + if(mPtr) { mPtr->Unreference(); } @@ -165,9 +169,9 @@ public: * @param rhs Const reference to intrusive pointer * @return Reference to reference counted object */ - IntrusivePtr& operator=( IntrusivePtr const& rhs ) + IntrusivePtr& operator=(IntrusivePtr const& rhs) { - IntrusivePtr( rhs ).Swap( *this ); + IntrusivePtr(rhs).Swap(*this); return *this; } @@ -178,9 +182,9 @@ public: * @param rhs Pointer to object to wrap * @return A Reference to this object */ - IntrusivePtr& operator=( T* rhs ) + IntrusivePtr& operator=(T* rhs) { - IntrusivePtr( rhs ).Swap( *this ); + IntrusivePtr(rhs).Swap(*this); return *this; } @@ -191,11 +195,11 @@ public: * @param rhs Reference to intrusive pointer * @return Reference to moved intrusive pointer */ - IntrusivePtr& operator=( IntrusivePtr&& rhs ) + IntrusivePtr& operator=(IntrusivePtr&& rhs) { - if ( this != &rhs ) + if(this != &rhs) { - if (mPtr) + if(mPtr) { mPtr->Unreference(); } @@ -213,11 +217,11 @@ public: * @return Reference to moved intrusive pointer */ template - IntrusivePtr& operator=( IntrusivePtr&& rhs ) + IntrusivePtr& operator=(IntrusivePtr&& rhs) { - if ( this != reinterpret_cast*>( &rhs ) ) + if(this != reinterpret_cast*>(&rhs)) { - if (mPtr) + if(mPtr) { mPtr->Unreference(); } @@ -233,7 +237,7 @@ public: */ void Reset() { - IntrusivePtr().Swap( *this ); + IntrusivePtr().Swap(*this); } /** @@ -242,9 +246,9 @@ public: * @SINCE_1_0.0 * @param[in] rhs Pointer to object */ - void Reset( T* rhs ) + void Reset(T* rhs) { - IntrusivePtr( rhs ).Swap( *this ); + IntrusivePtr(rhs).Swap(*this); } // IntrusivePtr comparisons - This is a variation of the safe bool idiom @@ -254,7 +258,7 @@ public: * * Objects can be implicitly converted to this for validity checks. */ - using BooleanType = void ( IntrusivePtr::* )() const; + using BooleanType = void (IntrusivePtr::*)() const; /** * @brief Converts an object handle to a BooleanType. @@ -277,30 +281,31 @@ public: T* Detach() { T* ptr = mPtr; - mPtr = nullptr; + mPtr = nullptr; return ptr; } private: - /** * @brief Used by the safe bool idiom. * @SINCE_1_0.0 */ - void ThisIsSaferThanReturningVoidStar() const {} + void ThisIsSaferThanReturningVoidStar() const + { + } /** * @brief Internal swap function. * @SINCE_1_0.0 */ - void Swap( IntrusivePtr& rhs ) + void Swap(IntrusivePtr& rhs) { - T* tmp = mPtr; - mPtr = rhs.mPtr; + T* tmp = mPtr; + mPtr = rhs.mPtr; rhs.mPtr = tmp; } - T* mPtr; ///< pointer to RefObject + T* mPtr; ///< pointer to RefObject }; /** @@ -312,7 +317,7 @@ private: * @return True if the pointers point at the same object */ template -inline bool operator==( IntrusivePtrconst& lhs, IntrusivePtrconst& rhs ) +inline bool operator==(IntrusivePtr const& lhs, IntrusivePtr const& rhs) { return lhs.Get() == rhs.Get(); } @@ -326,7 +331,7 @@ inline bool operator==( IntrusivePtrconst& lhs, IntrusivePtrconst& rhs ) * @return True if the pointers point at different objects */ template -inline bool operator!=( IntrusivePtrconst& lhs, IntrusivePtrconst &rhs) +inline bool operator!=(IntrusivePtr const& lhs, IntrusivePtr const& rhs) { return lhs.Get() != rhs.Get(); } @@ -340,7 +345,7 @@ inline bool operator!=( IntrusivePtrconst& lhs, IntrusivePtrconst &rhs) * @return True if the intrusive pointer points at the specified object */ template -inline bool operator==( IntrusivePtrconst& lhs, U* rhs ) +inline bool operator==(IntrusivePtr const& lhs, U* rhs) { return lhs.Get() == rhs; } @@ -354,7 +359,7 @@ inline bool operator==( IntrusivePtrconst& lhs, U* rhs ) * @return True if the intrusive pointer doesn't point at the specified object */ template -inline bool operator!=( IntrusivePtrconst& lhs, U* rhs ) +inline bool operator!=(IntrusivePtr const& lhs, U* rhs) { return lhs.Get() != rhs; } @@ -368,7 +373,7 @@ inline bool operator!=( IntrusivePtrconst& lhs, U* rhs ) * @return True if the intrusive pointer points at the specified object */ template -inline bool operator==( T* lhs, IntrusivePtrconst& rhs ) +inline bool operator==(T* lhs, IntrusivePtr const& rhs) { return lhs == rhs.Get(); } @@ -382,7 +387,7 @@ inline bool operator==( T* lhs, IntrusivePtrconst& rhs ) * @return True if the intrusive pointer doesn't point at the specified object */ template -inline bool operator!=( T* lhs, IntrusivePtrconst& rhs ) +inline bool operator!=(T* lhs, IntrusivePtr const& rhs) { return lhs != rhs.Get(); } diff --git a/dali/public-api/common/list-wrapper.h b/dali/public-api/common/list-wrapper.h index a63e6c8..6c03918 100644 --- a/dali/public-api/common/list-wrapper.h +++ b/dali/public-api/common/list-wrapper.h @@ -39,7 +39,7 @@ #include #undef _LIBCPP_INLINE_VISIBILITY -#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__)) +#define _LIBCPP_INLINE_VISIBILITY __attribute__((__visibility__("hidden"), __always_inline__)) #undef _LIBCPP_EXTERN_TEMPLATE #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; @@ -49,13 +49,13 @@ #include #undef _GLIBCXX_VISIBILITY_ATTR #undef _GLIBCXX_VISIBILITY -#define _GLIBCXX_VISIBILITY_ATTR(V) __attribute__ ((__visibility__ ("hidden"))) -#define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ ("hidden"))) +#define _GLIBCXX_VISIBILITY_ATTR(V) __attribute__((__visibility__("hidden"))) +#define _GLIBCXX_VISIBILITY(V) __attribute__((__visibility__("hidden"))) #include #undef _GLIBCXX_VISIBILITY_ATTR #undef _GLIBCXX_VISIBILITY -#define _GLIBCXX_VISIBILITY_ATTR(V) __attribute__ ((__visibility__ (#V))) // restore `_GLIBCXX_VISIBILITY_ATTR` -#define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V))) // restore `_GLIBCXX_VISIBILITY` +#define _GLIBCXX_VISIBILITY_ATTR(V) __attribute__((__visibility__(#V))) // restore `_GLIBCXX_VISIBILITY_ATTR` +#define _GLIBCXX_VISIBILITY(V) __attribute__((__visibility__(#V))) // restore `_GLIBCXX_VISIBILITY` #endif // #ifdef __clang__ diff --git a/dali/public-api/common/type-traits.h b/dali/public-api/common/type-traits.h index bafc98c..514b2ab 100644 --- a/dali/public-api/common/type-traits.h +++ b/dali/public-api/common/type-traits.h @@ -2,7 +2,7 @@ #define DALI_TYPE_TRAITS_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -31,7 +31,7 @@ namespace Dali * This allows specializations to not have to repeat all flags. * @SINCE_1_0.0 */ -template +template struct BasicTypes { /** @@ -41,7 +41,10 @@ struct BasicTypes * and cannot be copied by using memcpy etc. * @SINCE_1_0.0 */ - enum { IS_TRIVIAL_TYPE = __has_trivial_destructor(Type) && __has_trivial_copy(Type) }; + enum + { + IS_TRIVIAL_TYPE = __has_trivial_destructor(Type) && __has_trivial_copy(Type) + }; }; /** @@ -61,8 +64,8 @@ struct BasicTypes * * @SINCE_1_0.0 */ -template -struct TypeTraits : public BasicTypes< Type > +template +struct TypeTraits : public BasicTypes { }; diff --git a/dali/public-api/common/vector-wrapper.h b/dali/public-api/common/vector-wrapper.h index accc2db..ca14edc 100644 --- a/dali/public-api/common/vector-wrapper.h +++ b/dali/public-api/common/vector-wrapper.h @@ -2,7 +2,7 @@ #define DALI_VECTOR_WRAPPER_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -39,7 +39,7 @@ #include #undef _LIBCPP_INLINE_VISIBILITY -#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__)) +#define _LIBCPP_INLINE_VISIBILITY __attribute__((__visibility__("hidden"), __always_inline__)) #undef _LIBCPP_EXTERN_TEMPLATE #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; @@ -48,13 +48,13 @@ #include #undef _GLIBCXX_VISIBILITY_ATTR #undef _GLIBCXX_VISIBILITY -#define _GLIBCXX_VISIBILITY_ATTR(V) __attribute__ ((__visibility__ ("hidden"))) -#define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ ("hidden"))) +#define _GLIBCXX_VISIBILITY_ATTR(V) __attribute__((__visibility__("hidden"))) +#define _GLIBCXX_VISIBILITY(V) __attribute__((__visibility__("hidden"))) #include #undef _GLIBCXX_VISIBILITY_ATTR #undef _GLIBCXX_VISIBILITY -#define _GLIBCXX_VISIBILITY_ATTR(V) __attribute__ ((__visibility__ (#V))) // restore `_GLIBCXX_VISIBILITY_ATTR` -#define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V))) // restore `_GLIBCXX_VISIBILITY` +#define _GLIBCXX_VISIBILITY_ATTR(V) __attribute__((__visibility__(#V))) // restore `_GLIBCXX_VISIBILITY_ATTR` +#define _GLIBCXX_VISIBILITY(V) __attribute__((__visibility__(#V))) // restore `_GLIBCXX_VISIBILITY` #endif // #ifdef __clang__ diff --git a/dali/public-api/dali-core-version.cpp b/dali/public-api/dali-core-version.cpp index 0898bec..4cb94f0 100644 --- a/dali/public-api/dali-core-version.cpp +++ b/dali/public-api/dali-core-version.cpp @@ -25,11 +25,10 @@ namespace Dali { - -const uint32_t CORE_MAJOR_VERSION = 1; -const uint32_t CORE_MINOR_VERSION = 9; -const uint32_t CORE_MICRO_VERSION = 28; -const char * const CORE_BUILD_DATE = __DATE__ " " __TIME__; +const uint32_t CORE_MAJOR_VERSION = 1; +const uint32_t CORE_MINOR_VERSION = 9; +const uint32_t CORE_MICRO_VERSION = 28; +const char* const CORE_BUILD_DATE = __DATE__ " " __TIME__; #ifdef DEBUG_ENABLED namespace diff --git a/dali/public-api/dali-core-version.h b/dali/public-api/dali-core-version.h index 098d22a..ed1df80 100644 --- a/dali/public-api/dali-core-version.h +++ b/dali/public-api/dali-core-version.h @@ -2,7 +2,7 @@ #define DALI_CORE_VERSION_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -26,10 +26,10 @@ namespace Dali { -DALI_CORE_API extern const uint32_t CORE_MAJOR_VERSION; ///< The major version number of the Core library. -DALI_CORE_API extern const uint32_t CORE_MINOR_VERSION; ///< The minor version number of the Core library. -DALI_CORE_API extern const uint32_t CORE_MICRO_VERSION; ///< The micro version number of the Core library. -DALI_CORE_API extern const char * const CORE_BUILD_DATE; ///< The date/time the Core library was built. +DALI_CORE_API extern const uint32_t CORE_MAJOR_VERSION; ///< The major version number of the Core library. +DALI_CORE_API extern const uint32_t CORE_MINOR_VERSION; ///< The minor version number of the Core library. +DALI_CORE_API extern const uint32_t CORE_MICRO_VERSION; ///< The micro version number of the Core library. +DALI_CORE_API extern const char* const CORE_BUILD_DATE; ///< The date/time the Core library was built. } // namespace Dali #endif // DALI_CORE_VERSION_H diff --git a/dali/public-api/dali-core.h b/dali/public-api/dali-core.h index 7e97f2d..a70879b 100644 --- a/dali/public-api/dali-core.h +++ b/dali/public-api/dali-core.h @@ -18,8 +18,8 @@ * */ -#include #include +#include #include #include #include @@ -51,7 +51,6 @@ #include #include #include -#include #include #include #include @@ -62,10 +61,11 @@ #include #include #include +#include #include -#include #include +#include #include #include @@ -97,8 +97,8 @@ #include #include #include -#include #include +#include #include #include @@ -109,8 +109,8 @@ #include #include #include -#include #include +#include #include #include diff --git a/dali/public-api/events/device.h b/dali/public-api/events/device.h index 01ea742..934e843 100644 --- a/dali/public-api/events/device.h +++ b/dali/public-api/events/device.h @@ -2,7 +2,7 @@ #define DALI_DEVICE_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -36,28 +36,26 @@ namespace Dali */ namespace Device { - /** * @brief Categorization type about input Device * @SINCE_1_2.60 */ namespace Class { - /** * @brief An enum of Device Class types. * @SINCE_1_2.60 */ enum Type { - NONE, ///< Not a device. @SINCE_1_2.60 - USER, ///< The user/seat (the user themselves). @SINCE_1_2.60 - KEYBOARD, ///< A regular keyboard, numberpad or attached buttons. @SINCE_1_2.60 - MOUSE, ///< A mouse, trackball or touchpad relative motion device. @SINCE_1_2.60 - TOUCH, ///< A touchscreen with fingers or stylus. @SINCE_1_2.60 - PEN, ///< A special pen device. @SINCE_1_2.60 - POINTER, ///< A pointing device based on laser, infrared or similar technology. @SINCE_1_2.60 - GAMEPAD ///< A gamepad controller or joystick. @SINCE_1_2.60 + NONE, ///< Not a device. @SINCE_1_2.60 + USER, ///< The user/seat (the user themselves). @SINCE_1_2.60 + KEYBOARD, ///< A regular keyboard, numberpad or attached buttons. @SINCE_1_2.60 + MOUSE, ///< A mouse, trackball or touchpad relative motion device. @SINCE_1_2.60 + TOUCH, ///< A touchscreen with fingers or stylus. @SINCE_1_2.60 + PEN, ///< A special pen device. @SINCE_1_2.60 + POINTER, ///< A pointing device based on laser, infrared or similar technology. @SINCE_1_2.60 + GAMEPAD ///< A gamepad controller or joystick. @SINCE_1_2.60 }; } // namespace Class @@ -68,26 +66,25 @@ enum Type */ namespace Subclass { - /** * @brief An enum of Device Subclass types. * @SINCE_1_2.60 */ enum Type { - NONE, ///< Not a device. @SINCE_1_2.60 - FINGER, ///< The normal flat of your finger. @SINCE_1_2.60 - FINGERNAIL, ///< A fingernail. @SINCE_1_2.60 - KNUCKLE, ///< A Knuckle. @SINCE_1_2.60 - PALM, ///< The palm of a users hand. @SINCE_1_2.60 - HAND_SIDE, ///< The side of your hand. @SINCE_1_2.60 - HAND_FLAT, ///< The flat of your hand. @SINCE_1_2.60 - PEN_TIP, ///< The tip of a pen. @SINCE_1_2.60 - TRACKPAD, ///< A trackpad style mouse. @SINCE_1_2.60 - TRACKPOINT, ///< A trackpoint style mouse. @SINCE_1_2.60 - TRACKBALL, ///< A trackball style mouse. @SINCE_1_2.60 - REMOCON, ///< A remote controller. @SINCE_1_2.61 - VIRTUAL_KEYBOARD, ///< A virtual keyboard. @SINCE_1_2.61 + NONE, ///< Not a device. @SINCE_1_2.60 + FINGER, ///< The normal flat of your finger. @SINCE_1_2.60 + FINGERNAIL, ///< A fingernail. @SINCE_1_2.60 + KNUCKLE, ///< A Knuckle. @SINCE_1_2.60 + PALM, ///< The palm of a users hand. @SINCE_1_2.60 + HAND_SIDE, ///< The side of your hand. @SINCE_1_2.60 + HAND_FLAT, ///< The flat of your hand. @SINCE_1_2.60 + PEN_TIP, ///< The tip of a pen. @SINCE_1_2.60 + TRACKPAD, ///< A trackpad style mouse. @SINCE_1_2.60 + TRACKPOINT, ///< A trackpoint style mouse. @SINCE_1_2.60 + TRACKBALL, ///< A trackball style mouse. @SINCE_1_2.60 + REMOCON, ///< A remote controller. @SINCE_1_2.61 + VIRTUAL_KEYBOARD, ///< A virtual keyboard. @SINCE_1_2.61 }; } // namespace Subclass @@ -99,4 +96,4 @@ enum Type */ } // namespace Dali -#endif //DALI_KEY_EVENT_DEVEL_H +#endif //DALI_KEY_EVENT_DEVEL_H diff --git a/dali/public-api/events/gesture-detector.cpp b/dali/public-api/events/gesture-detector.cpp index 16f2be0..36a838a 100644 --- a/dali/public-api/events/gesture-detector.cpp +++ b/dali/public-api/events/gesture-detector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -23,7 +23,6 @@ namespace Dali { - GestureDetector::GestureDetector(Internal::GestureDetector* internal) : Handle(internal) { @@ -33,9 +32,9 @@ GestureDetector::GestureDetector() { } -GestureDetector GestureDetector::DownCast( BaseHandle handle ) +GestureDetector GestureDetector::DownCast(BaseHandle handle) { - return GestureDetector( dynamic_cast(handle.GetObjectPtr()) ); + return GestureDetector(dynamic_cast(handle.GetObjectPtr())); } GestureDetector::~GestureDetector() diff --git a/dali/public-api/events/gesture-detector.h b/dali/public-api/events/gesture-detector.h index 9d90bf2..9b786f7 100644 --- a/dali/public-api/events/gesture-detector.h +++ b/dali/public-api/events/gesture-detector.h @@ -2,7 +2,7 @@ #define DALI_GESTURE_DETECTOR_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -50,7 +50,6 @@ class Actor; class DALI_CORE_API GestureDetector : public Handle { public: // Creation & Destruction - /** * @brief Creates an uninitialized GestureDetector. * @@ -70,7 +69,7 @@ public: // Creation & Destruction * @param[in] handle Handle to an object * @return Handle to a GestureDetector object or an uninitialized handle */ - static GestureDetector DownCast( BaseHandle handle ); + static GestureDetector DownCast(BaseHandle handle); /** * @brief Dali::GestureDetector is intended as a base class. @@ -98,7 +97,6 @@ public: // Creation & Destruction GestureDetector& operator=(const GestureDetector& rhs); public: // Actor related - /** * @brief Attaches an actor to the gesture. * @@ -150,7 +148,6 @@ public: // Actor related Actor GetAttachedActor(size_t index) const; protected: - /// @cond internal /** * @brief This constructor is used by New() methods of derived classes (For example, PanGestureDetector::New()). diff --git a/dali/public-api/events/gesture-enumerations.h b/dali/public-api/events/gesture-enumerations.h index 4d30123..5fe303c 100644 --- a/dali/public-api/events/gesture-enumerations.h +++ b/dali/public-api/events/gesture-enumerations.h @@ -23,7 +23,6 @@ namespace Dali { - /** * @brief Enumeration for type of gesture. * @SINCE_1_9.28 diff --git a/dali/public-api/events/gesture.cpp b/dali/public-api/events/gesture.cpp index 11b124c..be6badd 100644 --- a/dali/public-api/events/gesture.cpp +++ b/dali/public-api/events/gesture.cpp @@ -23,7 +23,6 @@ namespace Dali { - Gesture::Gesture() { } @@ -33,13 +32,13 @@ Gesture::Gesture(Internal::Gesture* internal) { } -Gesture::Gesture( const Gesture& rhs ) = default; +Gesture::Gesture(const Gesture& rhs) = default; -Gesture::Gesture( Gesture&& rhs ) = default; +Gesture::Gesture(Gesture&& rhs) = default; -Gesture& Gesture::operator=( const Gesture& rhs ) = default; +Gesture& Gesture::operator=(const Gesture& rhs) = default; -Gesture& Gesture::operator=( Gesture&& rhs ) = default; +Gesture& Gesture::operator=(Gesture&& rhs) = default; Gesture::~Gesture() { diff --git a/dali/public-api/events/gesture.h b/dali/public-api/events/gesture.h index 8f407d2..aed5e0c 100644 --- a/dali/public-api/events/gesture.h +++ b/dali/public-api/events/gesture.h @@ -23,8 +23,8 @@ // INTERNAL INCLUDES #include -#include #include +#include namespace Dali { @@ -56,7 +56,6 @@ class Gesture; class DALI_CORE_API Gesture : public BaseHandle { public: - /** * @brief Creates an uninitialized Gesture handle. * @@ -70,14 +69,14 @@ public: * @SINCE_1_9.28 * @param[in] rhs A reference to the copied handle */ - Gesture( const Gesture& rhs ); + Gesture(const Gesture& rhs); /** * @brief Move constructor. * @SINCE_1_9.28 * @param[in] rhs A reference to the handle to move */ - Gesture( Gesture&& rhs ); + Gesture(Gesture&& rhs); /** * @brief Assignment operator. @@ -85,7 +84,7 @@ public: * @param[in] rhs A reference to the copied handle * @return A reference to this */ - Gesture& operator=( const Gesture& rhs ); + Gesture& operator=(const Gesture& rhs); /** * @brief Move assignment operator. @@ -93,7 +92,7 @@ public: * @param[in] rhs A reference to the handle to move * @return A reference to this */ - Gesture& operator=( Gesture&& rhs ); + Gesture& operator=(Gesture&& rhs); /** * @brief Non virtual destructor. @@ -126,7 +125,6 @@ public: uint32_t GetTime() const; public: // Not intended for application developers - /// @cond internal /** * @brief Internal constructor. diff --git a/dali/public-api/events/hover-event.cpp b/dali/public-api/events/hover-event.cpp index d8a241e..21968dc 100644 --- a/dali/public-api/events/hover-event.cpp +++ b/dali/public-api/events/hover-event.cpp @@ -19,66 +19,65 @@ #include // INTERNAL INCLUDES -#include #include +#include namespace Dali { - HoverEvent::HoverEvent() : BaseHandle() { } -HoverEvent::HoverEvent( const HoverEvent& rhs ) = default; +HoverEvent::HoverEvent(const HoverEvent& rhs) = default; -HoverEvent::HoverEvent( HoverEvent&& rhs ) = default; +HoverEvent::HoverEvent(HoverEvent&& rhs) = default; HoverEvent::~HoverEvent() { } -HoverEvent& HoverEvent::operator=( const HoverEvent& rhs ) = default; +HoverEvent& HoverEvent::operator=(const HoverEvent& rhs) = default; -HoverEvent& HoverEvent::operator=( HoverEvent&& rhs ) = default; +HoverEvent& HoverEvent::operator=(HoverEvent&& rhs) = default; unsigned long HoverEvent::GetTime() const { - return GetImplementation( *this ).GetTime(); + return GetImplementation(*this).GetTime(); } std::size_t HoverEvent::GetPointCount() const { - return GetImplementation( *this ).GetPointCount(); + return GetImplementation(*this).GetPointCount(); } -int32_t HoverEvent::GetDeviceId( std::size_t point ) const +int32_t HoverEvent::GetDeviceId(std::size_t point) const { - return GetImplementation( *this ).GetDeviceId( point ); + return GetImplementation(*this).GetDeviceId(point); } -PointState::Type HoverEvent::GetState( std::size_t point ) const +PointState::Type HoverEvent::GetState(std::size_t point) const { - return GetImplementation( *this ).GetState( point ); + return GetImplementation(*this).GetState(point); } -Actor HoverEvent::GetHitActor( std::size_t point ) const +Actor HoverEvent::GetHitActor(std::size_t point) const { - return GetImplementation( *this ).GetHitActor( point ); + return GetImplementation(*this).GetHitActor(point); } -const Vector2& HoverEvent::GetLocalPosition( std::size_t point ) const +const Vector2& HoverEvent::GetLocalPosition(std::size_t point) const { - return GetImplementation( *this ).GetLocalPosition( point ); + return GetImplementation(*this).GetLocalPosition(point); } -const Vector2& HoverEvent::GetScreenPosition( std::size_t point ) const +const Vector2& HoverEvent::GetScreenPosition(std::size_t point) const { - return GetImplementation( *this ).GetScreenPosition( point ); + return GetImplementation(*this).GetScreenPosition(point); } -HoverEvent::HoverEvent( Internal::HoverEvent* internal ) -: BaseHandle( internal ) +HoverEvent::HoverEvent(Internal::HoverEvent* internal) +: BaseHandle(internal) { } diff --git a/dali/public-api/events/hover-event.h b/dali/public-api/events/hover-event.h index 9e5a8f1..26593b5 100644 --- a/dali/public-api/events/hover-event.h +++ b/dali/public-api/events/hover-event.h @@ -23,12 +23,11 @@ // INTERNAL INCLUDES #include -#include #include +#include namespace Dali { - namespace Internal DALI_INTERNAL { class HoverEvent; @@ -51,9 +50,7 @@ struct Vector2; */ class DALI_CORE_API HoverEvent : public BaseHandle { - public: - // Construction & Destruction /** @@ -70,7 +67,7 @@ public: * @SINCE_1_9.25 * @param[in] rhs The HoverEvent to copy from */ - HoverEvent( const HoverEvent& rhs ); + HoverEvent(const HoverEvent& rhs); /** * @brief Move constructor. @@ -78,7 +75,7 @@ public: * @SINCE_1_9.25 * @param[in] rhs A reference to the moved HoverEvent */ - HoverEvent( HoverEvent&& rhs ); + HoverEvent(HoverEvent&& rhs); /** * @brief Destructor. @@ -95,7 +92,7 @@ public: * @param[in] rhs The HoverEvent to copy from * @return A reference to this */ - HoverEvent& operator=( const HoverEvent& rhs ); + HoverEvent& operator=(const HoverEvent& rhs); /** * @brief Move assignment operator. @@ -104,7 +101,7 @@ public: * @param[in] rhs A reference to the moved HoverEvent * @return A reference to this */ - HoverEvent& operator=( HoverEvent&& rhs ); + HoverEvent& operator=(HoverEvent&& rhs); // Getters @@ -135,7 +132,7 @@ public: * @return The Device ID of this point * @note If point is greater than GetPointCount() then this method will return -1. */ - int32_t GetDeviceId( std::size_t point ) const; + int32_t GetDeviceId(std::size_t point) const; /** * @brief Retrieves the State of the point specified. @@ -146,7 +143,7 @@ public: * @note If point is greater than GetPointCount() then this method will return PointState::FINISHED. * @see State */ - PointState::Type GetState( std::size_t point ) const; + PointState::Type GetState(std::size_t point) const; /** * @brief Retrieves the actor that was underneath the point specified. @@ -156,7 +153,7 @@ public: * @return The actor that was underneath the point specified * @note If point is greater than GetPointCount() then this method will return an empty handle. */ - Actor GetHitActor( std::size_t point ) const; + Actor GetHitActor(std::size_t point) const; /** * @brief Retrieves the co-ordinates relative to the top-left of the hit-actor at the point specified. @@ -170,7 +167,7 @@ public: * then you should use Actor::ScreenToLocal(). * @note If point is greater than GetPointCount() then this method will return Vector2::ZERO. */ - const Vector2& GetLocalPosition( std::size_t point ) const; + const Vector2& GetLocalPosition(std::size_t point) const; /** * @brief Retrieves the co-ordinates relative to the top-left of the screen of the point specified. @@ -180,10 +177,9 @@ public: * @return The co-ordinates relative to the top-left of the screen of the point specified * @note If point is greater than GetPointCount() then this method will return Vector2::ZERO. */ - const Vector2& GetScreenPosition( std::size_t point ) const; + const Vector2& GetScreenPosition(std::size_t point) const; public: // Not intended for application developers - /// @cond internal /** * @brief This constructor is used internally to Create an initialized HoverEvent handle. @@ -191,7 +187,7 @@ public: // Not intended for application developers * @SINCE_1_9.25 * @param[in] hoverEvent A pointer to a newly allocated Dali resource */ - explicit DALI_INTERNAL HoverEvent( Internal::HoverEvent* hoverEvent ); + explicit DALI_INTERNAL HoverEvent(Internal::HoverEvent* hoverEvent); /// @endcond }; diff --git a/dali/public-api/events/key-event.cpp b/dali/public-api/events/key-event.cpp old mode 100755 new mode 100644 index 9b3bba8..7235d4d --- a/dali/public-api/events/key-event.cpp +++ b/dali/public-api/events/key-event.cpp @@ -23,96 +23,95 @@ namespace Dali { - KeyEvent::KeyEvent() : BaseHandle() { } -KeyEvent::KeyEvent( const KeyEvent& rhs ) = default; +KeyEvent::KeyEvent(const KeyEvent& rhs) = default; -KeyEvent::KeyEvent( KeyEvent&& rhs ) = default; +KeyEvent::KeyEvent(KeyEvent&& rhs) = default; KeyEvent::~KeyEvent() { } -KeyEvent& KeyEvent::operator=( const KeyEvent& rhs ) = default; +KeyEvent& KeyEvent::operator=(const KeyEvent& rhs) = default; -KeyEvent& KeyEvent::operator=( KeyEvent&& rhs ) = default; +KeyEvent& KeyEvent::operator=(KeyEvent&& rhs) = default; bool KeyEvent::IsShiftModifier() const { - return GetImplementation( *this ).IsShiftModifier(); + return GetImplementation(*this).IsShiftModifier(); } bool KeyEvent::IsCtrlModifier() const { - return GetImplementation( *this ).IsCtrlModifier(); + return GetImplementation(*this).IsCtrlModifier(); } bool KeyEvent::IsAltModifier() const { - return GetImplementation( *this ).IsAltModifier(); + return GetImplementation(*this).IsAltModifier(); } const std::string& KeyEvent::GetCompose() const { - return GetImplementation( *this ).GetCompose(); + return GetImplementation(*this).GetCompose(); } const std::string& KeyEvent::GetDeviceName() const { - return GetImplementation( *this ).GetDeviceName(); + return GetImplementation(*this).GetDeviceName(); } Device::Class::Type KeyEvent::GetDeviceClass() const { - return GetImplementation( *this ).GetDeviceClass(); + return GetImplementation(*this).GetDeviceClass(); } Device::Subclass::Type KeyEvent::GetDeviceSubclass() const { - return GetImplementation( *this ).GetDeviceSubclass(); + return GetImplementation(*this).GetDeviceSubclass(); } const std::string& KeyEvent::GetKeyName() const { - return GetImplementation( *this ).GetKeyName(); + return GetImplementation(*this).GetKeyName(); } const std::string& KeyEvent::GetKeyString() const { - return GetImplementation( *this ).GetKeyString(); + return GetImplementation(*this).GetKeyString(); } const std::string& KeyEvent::GetLogicalKey() const { - return GetImplementation( *this ).GetLogicalKey(); + return GetImplementation(*this).GetLogicalKey(); } int32_t KeyEvent::GetKeyCode() const { - return GetImplementation( *this ).GetKeyCode(); + return GetImplementation(*this).GetKeyCode(); } int32_t KeyEvent::GetKeyModifier() const { - return GetImplementation( *this ).GetKeyModifier(); + return GetImplementation(*this).GetKeyModifier(); } unsigned long KeyEvent::GetTime() const { - return GetImplementation( *this ).GetTime(); + return GetImplementation(*this).GetTime(); } KeyEvent::State KeyEvent::GetState() const { - return GetImplementation( *this ).GetState(); + return GetImplementation(*this).GetState(); } -KeyEvent::KeyEvent( Internal::KeyEvent* internal ) -: BaseHandle( internal ) +KeyEvent::KeyEvent(Internal::KeyEvent* internal) +: BaseHandle(internal) { } diff --git a/dali/public-api/events/key-event.h b/dali/public-api/events/key-event.h old mode 100755 new mode 100644 index 3b8884c..b1e332c --- a/dali/public-api/events/key-event.h +++ b/dali/public-api/events/key-event.h @@ -19,17 +19,16 @@ */ // EXTERNAL INCLUDES -#include #include // int32_t +#include // INTERNAL INCLUDES #include -#include #include +#include namespace Dali { - namespace Internal DALI_INTERNAL { class KeyEvent; @@ -57,9 +56,7 @@ class KeyEvent; */ class DALI_CORE_API KeyEvent : public BaseHandle { - public: - // Enumerations /** @@ -68,8 +65,8 @@ public: */ enum State { - DOWN, ///< Key down @SINCE_1_9.27 - UP, ///< Key up @SINCE_1_9.27 + DOWN, ///< Key down @SINCE_1_9.27 + UP, ///< Key up @SINCE_1_9.27 }; /** @@ -85,7 +82,7 @@ public: * @SINCE_1_2.36 * @param[in] rhs A reference to the copied handle */ - KeyEvent( const KeyEvent& rhs ); + KeyEvent(const KeyEvent& rhs); /** * @brief Move constructor. @@ -93,7 +90,7 @@ public: * @SINCE_1_9.27 * @param[in] rhs A reference to the moved handle */ - KeyEvent( KeyEvent&& rhs ); + KeyEvent(KeyEvent&& rhs); /** * @brief Copy assignment operator. @@ -101,7 +98,7 @@ public: * @param[in] rhs A reference to the copied handle * @return A reference to this */ - KeyEvent& operator=( const KeyEvent& rhs ); + KeyEvent& operator=(const KeyEvent& rhs); /** * @brief Move assignment operator. @@ -110,7 +107,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this */ - KeyEvent& operator=( KeyEvent&& rhs ); + KeyEvent& operator=(KeyEvent&& rhs); /** * @brief Destructor. @@ -243,7 +240,6 @@ public: State GetState() const; public: // Not intended for application developers - /// @cond internal /** * @brief This constructor is used internally to Create an initialized KeyEvent handle. @@ -251,7 +247,7 @@ public: // Not intended for application developers * @SINCE_1_9.27 * @param[in] keyEvent A pointer to a newly allocated Dali resource */ - explicit DALI_INTERNAL KeyEvent( Internal::KeyEvent* keyEvent ); + explicit DALI_INTERNAL KeyEvent(Internal::KeyEvent* keyEvent); /// @endcond }; diff --git a/dali/public-api/events/long-press-gesture-detector.cpp b/dali/public-api/events/long-press-gesture-detector.cpp index f623f9a..ca7b4e3 100644 --- a/dali/public-api/events/long-press-gesture-detector.cpp +++ b/dali/public-api/events/long-press-gesture-detector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -23,7 +23,6 @@ namespace Dali { - LongPressGestureDetector::LongPressGestureDetector(Internal::LongPressGestureDetector* internal) : GestureDetector(internal) { @@ -54,9 +53,9 @@ LongPressGestureDetector LongPressGestureDetector::New(uint32_t minTouches, uint return LongPressGestureDetector(internal.Get()); } -LongPressGestureDetector LongPressGestureDetector::DownCast( BaseHandle handle ) +LongPressGestureDetector LongPressGestureDetector::DownCast(BaseHandle handle) { - return LongPressGestureDetector( dynamic_cast(handle.GetObjectPtr()) ); + return LongPressGestureDetector(dynamic_cast(handle.GetObjectPtr())); } LongPressGestureDetector::~LongPressGestureDetector() diff --git a/dali/public-api/events/long-press-gesture-detector.h b/dali/public-api/events/long-press-gesture-detector.h index 7ab512c..1520191 100644 --- a/dali/public-api/events/long-press-gesture-detector.h +++ b/dali/public-api/events/long-press-gesture-detector.h @@ -63,11 +63,10 @@ class LongPressGesture; */ class DALI_CORE_API LongPressGestureDetector : public GestureDetector { -public: // Typedefs - using DetectedSignalType = Signal; ///< Gesture detected signal type @SINCE_1_0.0 +public: // Typedefs + using DetectedSignalType = Signal; ///< Gesture detected signal type @SINCE_1_0.0 public: // Creation & Destruction - /** * @brief Creates an uninitialized LongPressGestureDetector; this can be initialized with LongPressGestureDetector::New(). * @@ -117,7 +116,7 @@ public: // Creation & Destruction * @param[in] handle Handle to an object * @return Handle to a LongPressGestureDetector object or an uninitialized handle */ - static LongPressGestureDetector DownCast( BaseHandle handle ); + static LongPressGestureDetector DownCast(BaseHandle handle); /** * @brief Destructor. @@ -145,7 +144,6 @@ public: // Creation & Destruction LongPressGestureDetector& operator=(const LongPressGestureDetector& rhs); public: // Setters - /** * @brief Sets the number of touches required. * @@ -175,7 +173,6 @@ public: // Setters void SetTouchesRequired(uint32_t minTouches, uint32_t maxTouches); public: // Getters - /** * @brief Retrieves the minimum number of touches required. * @@ -195,7 +192,6 @@ public: // Getters uint32_t GetMaximumTouchesRequired() const; public: // Signals - /** * @brief This signal is emitted when the specified long press is detected on the attached actor. * @@ -210,7 +206,6 @@ public: // Signals DetectedSignalType& DetectedSignal(); public: // Not intended for Application developers - /// @cond internal /** * @brief This constructor is used by LongPressGestureDetector::New() methods. @@ -220,7 +215,6 @@ public: // Not intended for Application developers */ explicit DALI_INTERNAL LongPressGestureDetector(Internal::LongPressGestureDetector* internal); /// @endcond - }; /** diff --git a/dali/public-api/events/long-press-gesture.cpp b/dali/public-api/events/long-press-gesture.cpp index 1b99fce..9a08810 100644 --- a/dali/public-api/events/long-press-gesture.cpp +++ b/dali/public-api/events/long-press-gesture.cpp @@ -23,37 +23,36 @@ namespace Dali { - -LongPressGesture::LongPressGesture( Internal::LongPressGesture* internal ) -: Gesture( internal ) +LongPressGesture::LongPressGesture(Internal::LongPressGesture* internal) +: Gesture(internal) { } LongPressGesture::LongPressGesture() = default; -LongPressGesture::LongPressGesture( const LongPressGesture& rhs ) = default; +LongPressGesture::LongPressGesture(const LongPressGesture& rhs) = default; -LongPressGesture::LongPressGesture( LongPressGesture&& rhs ) = default; +LongPressGesture::LongPressGesture(LongPressGesture&& rhs) = default; -LongPressGesture& LongPressGesture::operator=( const LongPressGesture& rhs ) = default; +LongPressGesture& LongPressGesture::operator=(const LongPressGesture& rhs) = default; -LongPressGesture& LongPressGesture::operator=( LongPressGesture&& rhs ) = default; +LongPressGesture& LongPressGesture::operator=(LongPressGesture&& rhs) = default; LongPressGesture::~LongPressGesture() = default; uint32_t LongPressGesture::GetNumberOfTouches() const { - return GetImplementation( *this ).GetNumberOfTouches(); + return GetImplementation(*this).GetNumberOfTouches(); } const Vector2& LongPressGesture::GetScreenPoint() const { - return GetImplementation( *this ).GetScreenPoint(); + return GetImplementation(*this).GetScreenPoint(); } const Vector2& LongPressGesture::GetLocalPoint() const { - return GetImplementation( *this ).GetLocalPoint(); + return GetImplementation(*this).GetLocalPoint(); } } // namespace Dali diff --git a/dali/public-api/events/long-press-gesture.h b/dali/public-api/events/long-press-gesture.h index 82355fd..d28a3cf 100644 --- a/dali/public-api/events/long-press-gesture.h +++ b/dali/public-api/events/long-press-gesture.h @@ -24,7 +24,6 @@ namespace Dali { - namespace Internal DALI_INTERNAL { class LongPressGesture; @@ -49,7 +48,6 @@ class LongPressGesture; class DALI_CORE_API LongPressGesture : public Gesture { public: - /** * @brief Creates an uninitialized LongPressGesture handle. * @@ -63,14 +61,14 @@ public: * @SINCE_1_9.28 * @param[in] rhs A reference to the copied handle */ - LongPressGesture( const LongPressGesture& rhs ); + LongPressGesture(const LongPressGesture& rhs); /** * @brief Move constructor. * @SINCE_1_9.28 * @param[in] rhs A reference to the handle to move */ - LongPressGesture( LongPressGesture&& rhs ); + LongPressGesture(LongPressGesture&& rhs); /** * @brief Assignment operator. @@ -78,7 +76,7 @@ public: * @param[in] rhs A reference to the copied handle * @return A reference to this */ - LongPressGesture& operator=( const LongPressGesture& rhs ); + LongPressGesture& operator=(const LongPressGesture& rhs); /** * @brief Move assignment operator. @@ -86,7 +84,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this */ - LongPressGesture& operator=( LongPressGesture&& rhs ); + LongPressGesture& operator=(LongPressGesture&& rhs); /** * @brief Non virtual destructor. @@ -122,7 +120,6 @@ public: const Vector2& GetLocalPoint() const; public: // Not intended for application developers - /// @cond internal /** * @brief This constructor is used internally to Create an initialized LongPressGesture handle. @@ -130,9 +127,8 @@ public: // Not intended for application developers * @param[in] longPressGesture A pointer to a newly allocated Dali resource * @SINCE_1_9.28 */ - explicit DALI_INTERNAL LongPressGesture( Internal::LongPressGesture* longPressGesture ); + explicit DALI_INTERNAL LongPressGesture(Internal::LongPressGesture* longPressGesture); /// @endcond - }; /** diff --git a/dali/public-api/events/mouse-button.h b/dali/public-api/events/mouse-button.h old mode 100755 new mode 100644 index 12f18a7..b36b241 --- a/dali/public-api/events/mouse-button.h +++ b/dali/public-api/events/mouse-button.h @@ -2,7 +2,7 @@ #define DALI_MOUSE_BUTTON_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -31,19 +31,18 @@ namespace Dali */ namespace MouseButton { - /** * @brief Enumeration for mouse button type. * @SINCE_1_3_31 */ enum Type { - INVALID = -1, /**< No mouse button event or invalid data */ - PRIMARY = 1, /**< Primary(Left) mouse button */ - SECONDARY = 3, /**< Secondary(Right) mouse button */ - TERTIARY = 2, /**< Center(Wheel) mouse button */ + INVALID = -1, /**< No mouse button event or invalid data */ + PRIMARY = 1, /**< Primary(Left) mouse button */ + SECONDARY = 3, /**< Secondary(Right) mouse button */ + TERTIARY = 2, /**< Center(Wheel) mouse button */ }; -} +} // namespace MouseButton /** * @} diff --git a/dali/public-api/events/pan-gesture-detector.cpp b/dali/public-api/events/pan-gesture-detector.cpp index 8accd54..343cf98 100644 --- a/dali/public-api/events/pan-gesture-detector.cpp +++ b/dali/public-api/events/pan-gesture-detector.cpp @@ -23,14 +23,13 @@ namespace Dali { - -const Radian PanGestureDetector::DIRECTION_LEFT( -Math::PI ); -const Radian PanGestureDetector::DIRECTION_RIGHT( 0.0f ); -const Radian PanGestureDetector::DIRECTION_UP( -0.5f * Math::PI ); -const Radian PanGestureDetector::DIRECTION_DOWN( 0.5f * Math::PI ); -const Radian PanGestureDetector::DIRECTION_HORIZONTAL( Math::PI ); -const Radian PanGestureDetector::DIRECTION_VERTICAL( -0.5f * Math::PI ); -const Radian PanGestureDetector::DEFAULT_THRESHOLD( 0.25f * Math::PI ); +const Radian PanGestureDetector::DIRECTION_LEFT(-Math::PI); +const Radian PanGestureDetector::DIRECTION_RIGHT(0.0f); +const Radian PanGestureDetector::DIRECTION_UP(-0.5f * Math::PI); +const Radian PanGestureDetector::DIRECTION_DOWN(0.5f * Math::PI); +const Radian PanGestureDetector::DIRECTION_HORIZONTAL(Math::PI); +const Radian PanGestureDetector::DIRECTION_VERTICAL(-0.5f * Math::PI); +const Radian PanGestureDetector::DEFAULT_THRESHOLD(0.25f * Math::PI); PanGestureDetector::PanGestureDetector(Internal::PanGestureDetector* internal) : GestureDetector(internal) @@ -48,9 +47,9 @@ PanGestureDetector PanGestureDetector::New() return PanGestureDetector(internal.Get()); } -PanGestureDetector PanGestureDetector::DownCast( BaseHandle handle ) +PanGestureDetector PanGestureDetector::DownCast(BaseHandle handle) { - return PanGestureDetector( dynamic_cast(handle.GetObjectPtr()) ); + return PanGestureDetector(dynamic_cast(handle.GetObjectPtr())); } PanGestureDetector::~PanGestureDetector() @@ -88,14 +87,14 @@ uint32_t PanGestureDetector::GetMaximumTouchesRequired() const return GetImplementation(*this).GetMaximumTouchesRequired(); } -void PanGestureDetector::AddAngle( Radian angle, Radian threshold ) +void PanGestureDetector::AddAngle(Radian angle, Radian threshold) { - GetImplementation(*this).AddAngle( angle, threshold ); + GetImplementation(*this).AddAngle(angle, threshold); } -void PanGestureDetector::AddDirection( Radian direction, Radian threshold ) +void PanGestureDetector::AddDirection(Radian direction, Radian threshold) { - GetImplementation(*this).AddDirection( direction, threshold ); + GetImplementation(*this).AddDirection(direction, threshold); } size_t PanGestureDetector::GetAngleCount() const @@ -105,7 +104,7 @@ size_t PanGestureDetector::GetAngleCount() const PanGestureDetector::AngleThresholdPair PanGestureDetector::GetAngle(size_t index) const { - return GetImplementation(*this).GetAngle( static_cast( index ) ); + return GetImplementation(*this).GetAngle(static_cast(index)); } void PanGestureDetector::ClearAngles() @@ -113,14 +112,14 @@ void PanGestureDetector::ClearAngles() GetImplementation(*this).ClearAngles(); } -void PanGestureDetector::RemoveAngle( Radian angle ) +void PanGestureDetector::RemoveAngle(Radian angle) { - GetImplementation(*this).RemoveAngle( angle ); + GetImplementation(*this).RemoveAngle(angle); } -void PanGestureDetector::RemoveDirection( Radian direction ) +void PanGestureDetector::RemoveDirection(Radian direction) { - GetImplementation(*this).RemoveDirection( direction ); + GetImplementation(*this).RemoveDirection(direction); } PanGestureDetector::DetectedSignalType& PanGestureDetector::DetectedSignal() @@ -128,9 +127,9 @@ PanGestureDetector::DetectedSignalType& PanGestureDetector::DetectedSignal() return GetImplementation(*this).DetectedSignal(); } -void PanGestureDetector::SetPanGestureProperties( const Dali::PanGesture& pan ) +void PanGestureDetector::SetPanGestureProperties(const Dali::PanGesture& pan) { - Internal::PanGestureDetector::SetPanGestureProperties( pan ); + Internal::PanGestureDetector::SetPanGestureProperties(pan); } } // namespace Dali diff --git a/dali/public-api/events/pan-gesture-detector.h b/dali/public-api/events/pan-gesture-detector.h index 64f5e3a..c31549d 100644 --- a/dali/public-api/events/pan-gesture-detector.h +++ b/dali/public-api/events/pan-gesture-detector.h @@ -29,7 +29,6 @@ namespace Dali { - struct Radian; namespace Internal DALI_INTERNAL @@ -68,7 +67,6 @@ class PanGestureDetector; class DALI_CORE_API PanGestureDetector : public GestureDetector { public: - /** * @brief Enumeration for the instance of properties belonging to the PanGestureDetector class. * @SINCE_1_0.0 @@ -92,7 +90,7 @@ public: }; // Typedefs - using DetectedSignalType = Signal; ///< Pan gesture detected signal type @SINCE_1_0.0 + using DetectedSignalType = Signal; ///< Pan gesture detected signal type @SINCE_1_0.0 // Directional Pan using AngleThresholdPair = std::pair; ///< Range of angles for a direction @SINCE_1_0.0 @@ -104,10 +102,9 @@ public: static const Radian DIRECTION_HORIZONTAL; ///< For a left and right pan (PI Radians). Useful for AddDirection(). static const Radian DIRECTION_VERTICAL; ///< For an up and down pan (-0.5 * PI Radians). Useful for AddDirection(). - static const Radian DEFAULT_THRESHOLD; ///< The default threshold is PI * 0.25 radians (or 45 degrees). + static const Radian DEFAULT_THRESHOLD; ///< The default threshold is PI * 0.25 radians (or 45 degrees). public: // Creation & Destruction - /** * @brief Creates an uninitialized PanGestureDetector; this can be initialized with PanGestureDetector::New(). * @@ -133,7 +130,7 @@ public: // Creation & Destruction * @param[in] handle Handle to an object * @return Handle to a PanGestureDetector object or an uninitialized handle */ - static PanGestureDetector DownCast( BaseHandle handle ); + static PanGestureDetector DownCast(BaseHandle handle); /** * @brief Destructor. @@ -161,7 +158,6 @@ public: // Creation & Destruction PanGestureDetector& operator=(const PanGestureDetector& rhs); public: // Setters - /** * @brief This is the minimum number of touches required for the pan gesture to be detected. * @@ -183,7 +179,6 @@ public: // Setters void SetMaximumTouchesRequired(uint32_t maximum); public: // Getters - /** * @brief Retrieves the minimum number of touches required for the pan gesture to be detected. * @@ -203,7 +198,6 @@ public: // Getters uint32_t GetMaximumTouchesRequired() const; public: // Directional Panning - /** * @brief The pan gesture is only emitted if the pan occurs in the direction specified by this method with a +/- threshold allowance. * @@ -237,7 +231,7 @@ public: // Directional Panning * @note If the threshold is greater than PI, then PI will be used as the threshold. * */ - void AddAngle( Radian angle, Radian threshold = DEFAULT_THRESHOLD ); + void AddAngle(Radian angle, Radian threshold = DEFAULT_THRESHOLD); /** * @brief A helper method for adding bi-directional angles where the pan should take place. @@ -259,7 +253,7 @@ public: // Directional Panning * * @see AddAngle */ - void AddDirection( Radian direction, Radian threshold = DEFAULT_THRESHOLD ); + void AddDirection(Radian direction, Radian threshold = DEFAULT_THRESHOLD); /** * @brief Returns the count of angles that this pan gesture detector emits a signal. @@ -301,7 +295,7 @@ public: // Directional Panning * @note If an angle outside the range in AddAngle() is given, then the value is wrapped within * the range and that is removed. */ - void RemoveAngle( Radian angle ); + void RemoveAngle(Radian angle); /** * @brief Removes the two angles that make up the direction from the container. @@ -312,10 +306,9 @@ public: // Directional Panning * @note If a direction outside the range in AddAngle() is given, then the value is wrapped within * the range and that is removed. */ - void RemoveDirection( Radian direction ); + void RemoveDirection(Radian direction); public: // Signals - /** * @brief This signal is emitted when the pan gesture is detected on the attached actor. * @@ -330,7 +323,6 @@ public: // Signals DetectedSignalType& DetectedSignal(); public: // Pan Properties Setters - /** * @brief Allows setting of the pan properties that are returned in constraints. * @@ -338,10 +330,9 @@ public: // Pan Properties Setters * @param[in] pan The pan gesture to set * @note If a normal pan is taking place, then any value set is ignored. */ - static void SetPanGestureProperties( const PanGesture& pan ); + static void SetPanGestureProperties(const PanGesture& pan); public: // Not intended for Application developers - /// @cond internal /** * @brief This constructor is used by PanGestureDetector::New() methods. @@ -351,7 +342,6 @@ public: // Not intended for Application developers */ explicit DALI_INTERNAL PanGestureDetector(Internal::PanGestureDetector* internal); /// @endcond - }; /** diff --git a/dali/public-api/events/pan-gesture.cpp b/dali/public-api/events/pan-gesture.cpp index 0550f54..d81c04c 100644 --- a/dali/public-api/events/pan-gesture.cpp +++ b/dali/public-api/events/pan-gesture.cpp @@ -19,82 +19,81 @@ #include // INTERNAL INCLUDES -#include #include +#include namespace Dali { - -PanGesture::PanGesture( Internal::PanGesture* internal ) -: Gesture( internal ) +PanGesture::PanGesture(Internal::PanGesture* internal) +: Gesture(internal) { } PanGesture::PanGesture() = default; -PanGesture::PanGesture( const PanGesture& rhs ) = default; +PanGesture::PanGesture(const PanGesture& rhs) = default; -PanGesture::PanGesture( PanGesture&& rhs ) = default; +PanGesture::PanGesture(PanGesture&& rhs) = default; -PanGesture& PanGesture::operator=( const PanGesture& rhs ) = default; +PanGesture& PanGesture::operator=(const PanGesture& rhs) = default; -PanGesture& PanGesture::operator=( PanGesture&& rhs ) = default; +PanGesture& PanGesture::operator=(PanGesture&& rhs) = default; PanGesture::~PanGesture() = default; const Vector2& PanGesture::GetVelocity() const { - return GetImplementation( *this ).GetVelocity(); + return GetImplementation(*this).GetVelocity(); } const Vector2& PanGesture::GetDisplacement() const { - return GetImplementation( *this ).GetDisplacement(); + return GetImplementation(*this).GetDisplacement(); } const Vector2& PanGesture::GetPosition() const { - return GetImplementation( *this ).GetPosition(); + return GetImplementation(*this).GetPosition(); } const Vector2& PanGesture::GetScreenVelocity() const { - return GetImplementation( *this ).GetScreenVelocity(); + return GetImplementation(*this).GetScreenVelocity(); } const Vector2& PanGesture::GetScreenDisplacement() const { - return GetImplementation( *this ).GetScreenDisplacement(); + return GetImplementation(*this).GetScreenDisplacement(); } const Vector2& PanGesture::GetScreenPosition() const { - return GetImplementation( *this ).GetScreenPosition(); + return GetImplementation(*this).GetScreenPosition(); } uint32_t PanGesture::GetNumberOfTouches() const { - return GetImplementation( *this ).GetNumberOfTouches(); + return GetImplementation(*this).GetNumberOfTouches(); } float PanGesture::GetSpeed() const { - return GetImplementation( *this ).GetSpeed(); + return GetImplementation(*this).GetSpeed(); } float PanGesture::GetDistance() const { - return GetImplementation( *this ).GetDistance(); + return GetImplementation(*this).GetDistance(); } float PanGesture::GetScreenSpeed() const { - return GetImplementation( *this ).GetScreenSpeed(); + return GetImplementation(*this).GetScreenSpeed(); } float PanGesture::GetScreenDistance() const { - return GetImplementation( *this ).GetScreenDistance(); + return GetImplementation(*this).GetScreenDistance(); } } // namespace Dali diff --git a/dali/public-api/events/pan-gesture.h b/dali/public-api/events/pan-gesture.h index 3c79a5f..69b6e64 100644 --- a/dali/public-api/events/pan-gesture.h +++ b/dali/public-api/events/pan-gesture.h @@ -24,7 +24,6 @@ namespace Dali { - namespace Internal DALI_INTERNAL { class PanGesture; @@ -51,10 +50,9 @@ class PanGesture; * A pan gesture will continue to be sent to the actor under than initial pan until it ends. * @SINCE_1_9.28 */ -class DALI_CORE_API PanGesture: public Gesture +class DALI_CORE_API PanGesture : public Gesture { public: - /** * @brief Creates an uninitialized PanGesture handle. * @@ -68,14 +66,14 @@ public: * @SINCE_1_9.28 * @param[in] rhs A reference to the copied handle */ - PanGesture( const PanGesture& rhs ); + PanGesture(const PanGesture& rhs); /** * @brief Move constructor. * @SINCE_1_9.28 * @param[in] rhs A reference to the moved handle */ - PanGesture( PanGesture&& rhs ); + PanGesture(PanGesture&& rhs); /** * @brief Assignment operator. @@ -83,7 +81,7 @@ public: * @param[in] rhs A reference to the copied handle * @return A reference to this */ - PanGesture& operator=( const PanGesture& rhs ); + PanGesture& operator=(const PanGesture& rhs); /** * @brief Move assignment operator. @@ -91,7 +89,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this */ - PanGesture& operator=( PanGesture&& rhs ); + PanGesture& operator=(PanGesture&& rhs); /** * @brief Non virtual destructor. @@ -211,7 +209,6 @@ public: float GetScreenDistance() const; public: // Not intended for application developers - /// @cond internal /** * @brief This constructor is used internally to Create an initialized PanGesture handle. @@ -219,9 +216,8 @@ public: // Not intended for application developers * @param[in] panGesture A pointer to a newly allocated Dali resource * @SINCE_1_9.28 */ - explicit DALI_INTERNAL PanGesture( Internal::PanGesture* panGesture ); + explicit DALI_INTERNAL PanGesture(Internal::PanGesture* panGesture); /// @endcond - }; /** diff --git a/dali/public-api/events/pinch-gesture-detector.cpp b/dali/public-api/events/pinch-gesture-detector.cpp index cdda6d1..933f336 100644 --- a/dali/public-api/events/pinch-gesture-detector.cpp +++ b/dali/public-api/events/pinch-gesture-detector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -39,9 +39,9 @@ PinchGestureDetector PinchGestureDetector::New() return PinchGestureDetector(internal.Get()); } -PinchGestureDetector PinchGestureDetector::DownCast( BaseHandle handle ) +PinchGestureDetector PinchGestureDetector::DownCast(BaseHandle handle) { - return PinchGestureDetector( dynamic_cast(handle.GetObjectPtr()) ); + return PinchGestureDetector(dynamic_cast(handle.GetObjectPtr())); } PinchGestureDetector::~PinchGestureDetector() diff --git a/dali/public-api/events/pinch-gesture-detector.h b/dali/public-api/events/pinch-gesture-detector.h index d6c61a3..3a458bf 100644 --- a/dali/public-api/events/pinch-gesture-detector.h +++ b/dali/public-api/events/pinch-gesture-detector.h @@ -61,15 +61,13 @@ class PinchGesture; class DALI_CORE_API PinchGestureDetector : public GestureDetector { public: // Typedefs - /** * @brief Signal type. * @SINCE_1_0.0 */ - using DetectedSignalType = Signal; + using DetectedSignalType = Signal; public: // Creation & Destruction - /** * @brief Creates an uninitialized PinchGestureDetector; this can be initialized with PinchGestureDetector::New(). * @@ -95,7 +93,7 @@ public: // Creation & Destruction * @param[in] handle Handle to an object * @return Handle to a PinchGestureDetector object or an uninitialized handle */ - static PinchGestureDetector DownCast( BaseHandle handle ); + static PinchGestureDetector DownCast(BaseHandle handle); /** * @brief Destructor. @@ -123,7 +121,6 @@ public: // Creation & Destruction PinchGestureDetector& operator=(const PinchGestureDetector& rhs); public: // Signals - /** * @brief This signal is emitted when the pinch gesture is detected on the attached actor. * @@ -138,7 +135,6 @@ public: // Signals DetectedSignalType& DetectedSignal(); public: // Not intended for Application developers - /// @cond internal /** * @brief This constructor is used by PinchGestureDetector::New() methods. @@ -148,7 +144,6 @@ public: // Not intended for Application developers */ explicit DALI_INTERNAL PinchGestureDetector(Internal::PinchGestureDetector* internal); /// @endcond - }; /** diff --git a/dali/public-api/events/pinch-gesture.cpp b/dali/public-api/events/pinch-gesture.cpp index 4281665..8417785 100644 --- a/dali/public-api/events/pinch-gesture.cpp +++ b/dali/public-api/events/pinch-gesture.cpp @@ -19,47 +19,46 @@ #include // INTERNAL INCLUDES -#include #include +#include namespace Dali { - -PinchGesture::PinchGesture( Internal::PinchGesture* internal ) -: Gesture( internal ) +PinchGesture::PinchGesture(Internal::PinchGesture* internal) +: Gesture(internal) { } PinchGesture::PinchGesture() = default; -PinchGesture::PinchGesture( const PinchGesture& rhs ) = default; +PinchGesture::PinchGesture(const PinchGesture& rhs) = default; -PinchGesture::PinchGesture( PinchGesture&& rhs ) = default; +PinchGesture::PinchGesture(PinchGesture&& rhs) = default; -PinchGesture& PinchGesture::operator=( const PinchGesture& rhs ) = default; +PinchGesture& PinchGesture::operator=(const PinchGesture& rhs) = default; -PinchGesture& PinchGesture::operator=( PinchGesture&& rhs ) = default; +PinchGesture& PinchGesture::operator=(PinchGesture&& rhs) = default; PinchGesture::~PinchGesture() = default; float PinchGesture::GetScale() const { - return GetImplementation( *this ).GetScale(); + return GetImplementation(*this).GetScale(); } float PinchGesture::GetSpeed() const { - return GetImplementation( *this ).GetSpeed(); + return GetImplementation(*this).GetSpeed(); } const Vector2& PinchGesture::GetScreenCenterPoint() const { - return GetImplementation( *this ).GetScreenCenterPoint(); + return GetImplementation(*this).GetScreenCenterPoint(); } const Vector2& PinchGesture::GetLocalCenterPoint() const { - return GetImplementation( *this ).GetLocalCenterPoint(); + return GetImplementation(*this).GetLocalCenterPoint(); } } // namespace Dali diff --git a/dali/public-api/events/pinch-gesture.h b/dali/public-api/events/pinch-gesture.h index aacbffa..4691bfd 100644 --- a/dali/public-api/events/pinch-gesture.h +++ b/dali/public-api/events/pinch-gesture.h @@ -24,7 +24,6 @@ namespace Dali { - namespace Internal DALI_INTERNAL { class PinchGesture; @@ -47,10 +46,9 @@ class PinchGesture; * until the pinch ends. * @SINCE_1_9.28 */ -class DALI_CORE_API PinchGesture: public Gesture +class DALI_CORE_API PinchGesture : public Gesture { public: - /** * @brief Creates an uninitialized PinchGesture handle. * @@ -64,14 +62,14 @@ public: * @SINCE_1_9.28 * @param[in] rhs A reference to the copied handle */ - PinchGesture( const PinchGesture& rhs ); + PinchGesture(const PinchGesture& rhs); /** * @brief Move constructor. * @SINCE_1_9.28 * @param[in] rhs A reference to the moved handle */ - PinchGesture( PinchGesture&& rhs ); + PinchGesture(PinchGesture&& rhs); /** * @brief Assignment operator. @@ -79,7 +77,7 @@ public: * @param[in] rhs A reference to the copied handle * @return A reference to this */ - PinchGesture& operator=( const PinchGesture& rhs ); + PinchGesture& operator=(const PinchGesture& rhs); /** * @brief Assignment operator. @@ -87,7 +85,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this */ - PinchGesture& operator=( PinchGesture&& rhs ); + PinchGesture& operator=(PinchGesture&& rhs); /** * @brief Non virtual destructor. @@ -130,7 +128,6 @@ public: const Vector2& GetLocalCenterPoint() const; public: // Not intended for application developers - /// @cond internal /** * @brief This constructor is used internally to Create an initialized PinchGesture handle. @@ -138,9 +135,8 @@ public: // Not intended for application developers * @param[in] PinchGesture A pointer to a newly allocated Dali resource * @SINCE_1_9.28 */ - explicit DALI_INTERNAL PinchGesture( Internal::PinchGesture* pinchGesture ); + explicit DALI_INTERNAL PinchGesture(Internal::PinchGesture* pinchGesture); /// @endcond - }; /** diff --git a/dali/public-api/events/point-state.h b/dali/public-api/events/point-state.h index b970c5e..7abad8a 100644 --- a/dali/public-api/events/point-state.h +++ b/dali/public-api/events/point-state.h @@ -2,7 +2,7 @@ #define DALI_POINT_STATE_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -31,25 +31,24 @@ namespace Dali */ namespace PointState { - /** * @brief Enumeration for point state type. * @SINCE_1_1.37 */ enum Type { - STARTED, /**< Touch or hover started */ - FINISHED, /**< Touch or hover finished */ - DOWN = STARTED, /**< Screen touched */ - UP = FINISHED, /**< Touch stopped */ - MOTION, /**< Finger dragged or hovered */ - LEAVE, /**< Leave the boundary of an actor */ - STATIONARY, /**< No change from last event. Useful when a multi-point event occurs where + STARTED, /**< Touch or hover started */ + FINISHED, /**< Touch or hover finished */ + DOWN = STARTED, /**< Screen touched */ + UP = FINISHED, /**< Touch stopped */ + MOTION, /**< Finger dragged or hovered */ + LEAVE, /**< Leave the boundary of an actor */ + STATIONARY, /**< No change from last event. Useful when a multi-point event occurs where all points are sent but indicates that this particular point has not changed since the last time */ - INTERRUPTED, /**< A system event has occurred which has interrupted the touch or hover event sequence. */ + INTERRUPTED, /**< A system event has occurred which has interrupted the touch or hover event sequence. */ }; -} +} // namespace PointState /** * @} diff --git a/dali/public-api/events/rotation-gesture-detector.cpp b/dali/public-api/events/rotation-gesture-detector.cpp index f174867..778fac4 100644 --- a/dali/public-api/events/rotation-gesture-detector.cpp +++ b/dali/public-api/events/rotation-gesture-detector.cpp @@ -23,9 +23,8 @@ namespace Dali { - -RotationGestureDetector::RotationGestureDetector( Internal::RotationGestureDetector* internal ) -: GestureDetector( internal ) +RotationGestureDetector::RotationGestureDetector(Internal::RotationGestureDetector* internal) +: GestureDetector(internal) { } @@ -37,32 +36,32 @@ RotationGestureDetector RotationGestureDetector::New() { Internal::RotationGestureDetectorPtr internal = Internal::RotationGestureDetector::New(); - return RotationGestureDetector( internal.Get() ); + return RotationGestureDetector(internal.Get()); } -RotationGestureDetector RotationGestureDetector::DownCast( BaseHandle handle ) +RotationGestureDetector RotationGestureDetector::DownCast(BaseHandle handle) { - return RotationGestureDetector( dynamic_cast( handle.GetObjectPtr() ) ); + return RotationGestureDetector(dynamic_cast(handle.GetObjectPtr())); } RotationGestureDetector::~RotationGestureDetector() { } -RotationGestureDetector::RotationGestureDetector( const RotationGestureDetector& handle ) -: GestureDetector( handle ) +RotationGestureDetector::RotationGestureDetector(const RotationGestureDetector& handle) +: GestureDetector(handle) { } -RotationGestureDetector& RotationGestureDetector::operator=( const RotationGestureDetector& rhs ) +RotationGestureDetector& RotationGestureDetector::operator=(const RotationGestureDetector& rhs) { - BaseHandle::operator=( rhs ); + BaseHandle::operator=(rhs); return *this; } RotationGestureDetector::DetectedSignalType& RotationGestureDetector::DetectedSignal() { - return GetImplementation( *this ).DetectedSignal(); + return GetImplementation(*this).DetectedSignal(); } } // namespace Dali diff --git a/dali/public-api/events/rotation-gesture-detector.h b/dali/public-api/events/rotation-gesture-detector.h index edfe069..185cb19 100644 --- a/dali/public-api/events/rotation-gesture-detector.h +++ b/dali/public-api/events/rotation-gesture-detector.h @@ -24,7 +24,6 @@ namespace Dali { - namespace Internal DALI_INTERNAL { class RotationGestureDetector; @@ -57,14 +56,12 @@ class RotationGesture; class DALI_CORE_API RotationGestureDetector : public GestureDetector { public: // Typedefs - /** * @brief Signal type. */ - using DetectedSignalType = Signal; + using DetectedSignalType = Signal; public: // Creation & Destruction - /** * @brief Creates an uninitialized RotationGestureDetector; this can be initialized with RotationGestureDetector::New(). * @@ -90,7 +87,7 @@ public: // Creation & Destruction * @param[in] handle Handle to an object * @return Handle to a RotationGestureDetector object or an uninitialized handle */ - static RotationGestureDetector DownCast( BaseHandle handle ); + static RotationGestureDetector DownCast(BaseHandle handle); /** * @brief Destructor. @@ -118,7 +115,6 @@ public: // Creation & Destruction RotationGestureDetector& operator=(const RotationGestureDetector& rhs); public: // Signals - /** * @brief This signal is emitted when the rotation gesture is detected on the attached actor. * @@ -133,7 +129,6 @@ public: // Signals DetectedSignalType& DetectedSignal(); public: // Not intended for Application developers - /// @cond internal /** * @brief This constructor is used by RotationGestureDetector::New() methods. @@ -143,7 +138,6 @@ public: // Not intended for Application developers */ explicit DALI_INTERNAL RotationGestureDetector(Internal::RotationGestureDetector* internal); /// @endcond - }; } // namespace Dali diff --git a/dali/public-api/events/rotation-gesture.cpp b/dali/public-api/events/rotation-gesture.cpp index a4a4637..355d910 100644 --- a/dali/public-api/events/rotation-gesture.cpp +++ b/dali/public-api/events/rotation-gesture.cpp @@ -19,42 +19,41 @@ #include // INTERNAL INCLUDES -#include #include +#include namespace Dali { - -RotationGesture::RotationGesture( Internal::RotationGesture* internal ) -: Gesture( internal ) +RotationGesture::RotationGesture(Internal::RotationGesture* internal) +: Gesture(internal) { } RotationGesture::RotationGesture() = default; -RotationGesture::RotationGesture( const RotationGesture& rhs ) = default; +RotationGesture::RotationGesture(const RotationGesture& rhs) = default; -RotationGesture::RotationGesture( RotationGesture&& rhs ) = default; +RotationGesture::RotationGesture(RotationGesture&& rhs) = default; -RotationGesture& RotationGesture::operator=( const RotationGesture& rhs ) = default; +RotationGesture& RotationGesture::operator=(const RotationGesture& rhs) = default; -RotationGesture& RotationGesture::operator=( RotationGesture&& rhs ) = default; +RotationGesture& RotationGesture::operator=(RotationGesture&& rhs) = default; RotationGesture::~RotationGesture() = default; const Radian& RotationGesture::GetRotation() const { - return GetImplementation( *this ).GetRotation(); + return GetImplementation(*this).GetRotation(); } const Vector2& RotationGesture::GetScreenCenterPoint() const { - return GetImplementation( *this ).GetScreenCenterPoint(); + return GetImplementation(*this).GetScreenCenterPoint(); } const Vector2& RotationGesture::GetLocalCenterPoint() const { - return GetImplementation( *this ).GetLocalCenterPoint(); + return GetImplementation(*this).GetLocalCenterPoint(); } } // namespace Dali diff --git a/dali/public-api/events/rotation-gesture.h b/dali/public-api/events/rotation-gesture.h index e3020f6..05cbc3a 100644 --- a/dali/public-api/events/rotation-gesture.h +++ b/dali/public-api/events/rotation-gesture.h @@ -25,7 +25,6 @@ namespace Dali { - namespace Internal DALI_INTERNAL { class RotationGesture; @@ -44,10 +43,9 @@ class RotationGesture; * until the rotation ends. * @SINCE_1_9.28 */ -class DALI_CORE_API RotationGesture: public Gesture +class DALI_CORE_API RotationGesture : public Gesture { public: - /** * @brief Creates an uninitialized RotationGesture handle. * @@ -61,14 +59,14 @@ public: * @SINCE_1_9.28 * @param[in] rhs A reference to the copied handle */ - RotationGesture( const RotationGesture& rhs ); + RotationGesture(const RotationGesture& rhs); /** * @brief Move constructor. * @SINCE_1_9.28 * @param[in] rhs A reference to the moved handle */ - RotationGesture( RotationGesture&& rhs ); + RotationGesture(RotationGesture&& rhs); /** * @brief Assignment operator. @@ -76,7 +74,7 @@ public: * @param[in] rhs A reference to the copied handle * @return A reference to this */ - RotationGesture& operator=( const RotationGesture& rhs ); + RotationGesture& operator=(const RotationGesture& rhs); /** * @brief Move assignment operator. @@ -84,7 +82,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this */ - RotationGesture& operator=( RotationGesture&& rhs ); + RotationGesture& operator=(RotationGesture&& rhs); /** * @brief Non virtual destructor. @@ -114,7 +112,6 @@ public: const Vector2& GetLocalCenterPoint() const; public: // Not intended for application developers - /// @cond internal /** * @brief This constructor is used internally to Create an initialized RotationGesture handle. @@ -122,7 +119,7 @@ public: // Not intended for application developers * @param[in] rotationGesture A pointer to a newly allocated Dali resource * @SINCE_1_9.28 */ - explicit DALI_INTERNAL RotationGesture( Internal::RotationGesture* rotationGesture ); + explicit DALI_INTERNAL RotationGesture(Internal::RotationGesture* rotationGesture); /// @endcond }; diff --git a/dali/public-api/events/tap-gesture-detector.cpp b/dali/public-api/events/tap-gesture-detector.cpp index 7dd90e3..ee42cc1 100644 --- a/dali/public-api/events/tap-gesture-detector.cpp +++ b/dali/public-api/events/tap-gesture-detector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -39,16 +39,16 @@ TapGestureDetector TapGestureDetector::New() return TapGestureDetector(internal.Get()); } -TapGestureDetector TapGestureDetector::New(uint32_t tapsRequired ) +TapGestureDetector TapGestureDetector::New(uint32_t tapsRequired) { - Internal::TapGestureDetectorPtr internal = Internal::TapGestureDetector::New( tapsRequired ); + Internal::TapGestureDetectorPtr internal = Internal::TapGestureDetector::New(tapsRequired); return TapGestureDetector(internal.Get()); } -TapGestureDetector TapGestureDetector::DownCast( BaseHandle handle ) +TapGestureDetector TapGestureDetector::DownCast(BaseHandle handle) { - return TapGestureDetector( dynamic_cast(handle.GetObjectPtr()) ); + return TapGestureDetector(dynamic_cast(handle.GetObjectPtr())); } TapGestureDetector::~TapGestureDetector() diff --git a/dali/public-api/events/tap-gesture-detector.h b/dali/public-api/events/tap-gesture-detector.h index 2fbd806..7432c83 100644 --- a/dali/public-api/events/tap-gesture-detector.h +++ b/dali/public-api/events/tap-gesture-detector.h @@ -70,15 +70,13 @@ class TapGesture; class DALI_CORE_API TapGestureDetector : public GestureDetector { public: // Typedefs - /** * @brief Signal type for detected signal. * @SINCE_1_0.0 */ - using DetectedSignalType = Signal; + using DetectedSignalType = Signal; public: // Creation & Destruction - /** * @brief Creates an uninitialized TapGestureDetector; this can be initialized with TapGestureDetector::New(). * @@ -103,7 +101,7 @@ public: // Creation & Destruction * @param[in] tapsRequired The minimum & maximum number of taps required * @return A handle to a newly allocated Dali resource */ - static TapGestureDetector New( uint32_t tapsRequired ); + static TapGestureDetector New(uint32_t tapsRequired); /** * @brief Downcasts a handle to TapGestureDetector handle. @@ -114,7 +112,7 @@ public: // Creation & Destruction * @param[in] handle Handle to an object * @return Handle to a TapGestureDetector object or an uninitialized handle */ - static TapGestureDetector DownCast( BaseHandle handle ); + static TapGestureDetector DownCast(BaseHandle handle); /** * @brief Destructor. @@ -142,7 +140,6 @@ public: // Creation & Destruction TapGestureDetector& operator=(const TapGestureDetector& rhs); public: // Setters - /** * @brief Sets the minimum number of taps required. * @@ -152,7 +149,7 @@ public: // Setters * @pre The gesture detector has been initialized. * @note The default is '1', the maximum is 2. */ - void SetMinimumTapsRequired( uint32_t minimumTaps ); + void SetMinimumTapsRequired(uint32_t minimumTaps); /** * @brief Sets the maximum number of taps required. @@ -163,10 +160,9 @@ public: // Setters * @pre The gesture detector has been initialized. * @note The default is '1', the maximum is 2. */ - void SetMaximumTapsRequired( uint32_t maximumTaps ); + void SetMaximumTapsRequired(uint32_t maximumTaps); public: // Getters - /** * @brief Retrieves the minimum number of taps required. * @@ -186,7 +182,6 @@ public: // Getters uint32_t GetMaximumTapsRequired() const; public: // Signals - /** * @brief This signal is emitted when the specified tap is detected on the attached actor. * @@ -201,7 +196,6 @@ public: // Signals DetectedSignalType& DetectedSignal(); public: // Not intended for Application developers - /// @cond internal /** * @brief This constructor is used by TapGestureDetector::New() methods. diff --git a/dali/public-api/events/tap-gesture.cpp b/dali/public-api/events/tap-gesture.cpp index 0dbefb6..fd0d62a 100644 --- a/dali/public-api/events/tap-gesture.cpp +++ b/dali/public-api/events/tap-gesture.cpp @@ -19,47 +19,46 @@ #include // INTERNAL INCLUDES -#include #include +#include namespace Dali { - -TapGesture::TapGesture( Internal::TapGesture* internal ) -: Gesture( internal ) +TapGesture::TapGesture(Internal::TapGesture* internal) +: Gesture(internal) { } TapGesture::TapGesture() = default; -TapGesture::TapGesture( const TapGesture& rhs ) = default; +TapGesture::TapGesture(const TapGesture& rhs) = default; -TapGesture::TapGesture( TapGesture&& rhs ) = default; +TapGesture::TapGesture(TapGesture&& rhs) = default; -TapGesture& TapGesture::operator=( const TapGesture& rhs ) = default; +TapGesture& TapGesture::operator=(const TapGesture& rhs) = default; -TapGesture& TapGesture::operator=( TapGesture&& rhs ) = default; +TapGesture& TapGesture::operator=(TapGesture&& rhs) = default; TapGesture::~TapGesture() = default; uint32_t TapGesture::GetNumberOfTaps() const { - return GetImplementation( *this ).GetNumberOfTaps(); + return GetImplementation(*this).GetNumberOfTaps(); } uint32_t TapGesture::GetNumberOfTouches() const { - return GetImplementation( *this ).GetNumberOfTouches(); + return GetImplementation(*this).GetNumberOfTouches(); } const Vector2& TapGesture::GetScreenPoint() const { - return GetImplementation( *this ).GetScreenPoint(); + return GetImplementation(*this).GetScreenPoint(); } const Vector2& TapGesture::GetLocalPoint() const { - return GetImplementation( *this ).GetLocalPoint(); + return GetImplementation(*this).GetLocalPoint(); } } // namespace Dali diff --git a/dali/public-api/events/tap-gesture.h b/dali/public-api/events/tap-gesture.h index 6fa0a08..0607568 100644 --- a/dali/public-api/events/tap-gesture.h +++ b/dali/public-api/events/tap-gesture.h @@ -24,7 +24,6 @@ namespace Dali { - namespace Internal DALI_INTERNAL { class TapGesture; @@ -45,7 +44,6 @@ class TapGesture; class DALI_CORE_API TapGesture : public Gesture { public: - /** * @brief Creates an uninitialized TapGesture handle. * @@ -59,14 +57,14 @@ public: * @SINCE_1_9.28 * @param rhs A reference to the copied handle */ - TapGesture( const TapGesture& rhs ); + TapGesture(const TapGesture& rhs); /** * @brief Move constructor. * @SINCE_1_9.28 * @param rhs The handle to move. */ - TapGesture( TapGesture&& rhs ); + TapGesture(TapGesture&& rhs); /** * @brief Assignment operator. @@ -74,14 +72,14 @@ public: * @param rhs A reference to the copied handle * @return A reference to this */ - TapGesture& operator=( const TapGesture& rhs ); + TapGesture& operator=(const TapGesture& rhs); /** * @brief Move assignment operator. * @SINCE_1_9.28 * @param rhs The handle to move. */ - TapGesture& operator=( TapGesture&& rhs ); + TapGesture& operator=(TapGesture&& rhs); /** * @brief Non virtual destructor. @@ -123,7 +121,6 @@ public: const Vector2& GetLocalPoint() const; public: // Not intended for application developers - /// @cond internal /** * @brief This constructor is used internally to Create an initialized TapGesture handle. @@ -131,7 +128,7 @@ public: // Not intended for application developers * @param[in] tapGesture A pointer to a newly allocated Dali resource * @SINCE_1_9.28 */ - explicit DALI_INTERNAL TapGesture( Internal::TapGesture* tapGesture ); + explicit DALI_INTERNAL TapGesture(Internal::TapGesture* tapGesture); /// @endcond }; diff --git a/dali/public-api/events/touch-event.cpp b/dali/public-api/events/touch-event.cpp old mode 100755 new mode 100644 index d5cc27b..215bafa --- a/dali/public-api/events/touch-event.cpp +++ b/dali/public-api/events/touch-event.cpp @@ -19,98 +19,97 @@ #include // INTERNAL INCLUDES -#include #include +#include #include namespace Dali { - TouchEvent::TouchEvent() = default; -TouchEvent::TouchEvent( const TouchEvent& other ) = default; +TouchEvent::TouchEvent(const TouchEvent& other) = default; -TouchEvent::TouchEvent( TouchEvent&& other ) = default; +TouchEvent::TouchEvent(TouchEvent&& other) = default; TouchEvent::~TouchEvent() = default; -TouchEvent& TouchEvent::operator=( const TouchEvent& other ) = default; +TouchEvent& TouchEvent::operator=(const TouchEvent& other) = default; -TouchEvent& TouchEvent::operator=( TouchEvent&& other ) = default; +TouchEvent& TouchEvent::operator=(TouchEvent&& other) = default; unsigned long TouchEvent::GetTime() const { - return GetImplementation( *this ).GetTime(); + return GetImplementation(*this).GetTime(); } std::size_t TouchEvent::GetPointCount() const { - return GetImplementation( *this ).GetPointCount(); + return GetImplementation(*this).GetPointCount(); } -int32_t TouchEvent::GetDeviceId( std::size_t point ) const +int32_t TouchEvent::GetDeviceId(std::size_t point) const { - return GetImplementation( *this ).GetDeviceId( point ); + return GetImplementation(*this).GetDeviceId(point); } -PointState::Type TouchEvent::GetState( std::size_t point ) const +PointState::Type TouchEvent::GetState(std::size_t point) const { - return GetImplementation( *this ).GetState( point ); + return GetImplementation(*this).GetState(point); } -Actor TouchEvent::GetHitActor( std::size_t point ) const +Actor TouchEvent::GetHitActor(std::size_t point) const { - return GetImplementation( *this ).GetHitActor( point ); + return GetImplementation(*this).GetHitActor(point); } -const Vector2& TouchEvent::GetLocalPosition( std::size_t point ) const +const Vector2& TouchEvent::GetLocalPosition(std::size_t point) const { - return GetImplementation( *this ).GetLocalPosition( point ); + return GetImplementation(*this).GetLocalPosition(point); } -const Vector2& TouchEvent::GetScreenPosition( std::size_t point ) const +const Vector2& TouchEvent::GetScreenPosition(std::size_t point) const { - return GetImplementation( *this ).GetScreenPosition( point ); + return GetImplementation(*this).GetScreenPosition(point); } -float TouchEvent::GetRadius( std::size_t point ) const +float TouchEvent::GetRadius(std::size_t point) const { - return GetImplementation( *this ).GetRadius( point ); + return GetImplementation(*this).GetRadius(point); } -const Vector2& TouchEvent::GetEllipseRadius( std::size_t point ) const +const Vector2& TouchEvent::GetEllipseRadius(std::size_t point) const { - return GetImplementation( *this ).GetEllipseRadius( point ); + return GetImplementation(*this).GetEllipseRadius(point); } -float TouchEvent::GetPressure( std::size_t point ) const +float TouchEvent::GetPressure(std::size_t point) const { - return GetImplementation( *this ).GetPressure( point ); + return GetImplementation(*this).GetPressure(point); } -Degree TouchEvent::GetAngle( std::size_t point ) const +Degree TouchEvent::GetAngle(std::size_t point) const { - return GetImplementation( *this ).GetAngle( point ); + return GetImplementation(*this).GetAngle(point); } -Device::Class::Type TouchEvent::GetDeviceClass( std::size_t point ) const +Device::Class::Type TouchEvent::GetDeviceClass(std::size_t point) const { - return GetImplementation( *this ).GetDeviceClass( point ); + return GetImplementation(*this).GetDeviceClass(point); } -Device::Subclass::Type TouchEvent::GetDeviceSubclass( std::size_t point ) const +Device::Subclass::Type TouchEvent::GetDeviceSubclass(std::size_t point) const { - return GetImplementation( *this ).GetDeviceSubclass( point ); + return GetImplementation(*this).GetDeviceSubclass(point); } -MouseButton::Type TouchEvent::GetMouseButton( std::size_t point ) const +MouseButton::Type TouchEvent::GetMouseButton(std::size_t point) const { - return GetImplementation( *this ).GetMouseButton( point ); + return GetImplementation(*this).GetMouseButton(point); } -TouchEvent::TouchEvent( Internal::TouchEvent* internal ) -: BaseHandle( internal ) +TouchEvent::TouchEvent(Internal::TouchEvent* internal) +: BaseHandle(internal) { } diff --git a/dali/public-api/events/touch-event.h b/dali/public-api/events/touch-event.h index 59ee042..ed99c9c 100644 --- a/dali/public-api/events/touch-event.h +++ b/dali/public-api/events/touch-event.h @@ -24,14 +24,13 @@ // INTERNAL INCLUDES #include #include +#include #include -#include #include -#include +#include namespace Dali { - namespace Internal DALI_INTERNAL { class TouchEvent; @@ -62,7 +61,6 @@ struct Vector2; class DALI_CORE_API TouchEvent : public BaseHandle { public: - // Construction & Destruction /** @@ -79,7 +77,7 @@ public: * @SINCE_1_9.26 * @param[in] other The TouchEvent to copy from */ - TouchEvent( const TouchEvent& other ); + TouchEvent(const TouchEvent& other); /** * @brief Move constructor. @@ -87,7 +85,7 @@ public: * @SINCE_1_9.28 * @param[in] other The TouchEvent to move */ - TouchEvent( TouchEvent&& other ); + TouchEvent(TouchEvent&& other); /** * @brief Destructor. @@ -105,7 +103,7 @@ public: * @param[in] other The TouchEvent to copy from * @return A reference to this */ - TouchEvent& operator=( const TouchEvent& other ); + TouchEvent& operator=(const TouchEvent& other); /** * @brief Move assignment Operator. @@ -114,7 +112,7 @@ public: * @param[in] other The TouchEvent to move * @return A reference to this */ - TouchEvent& operator=( TouchEvent&& other ); + TouchEvent& operator=(TouchEvent&& other); // Getters @@ -145,7 +143,7 @@ public: * @return The Device ID of this point * @note If point is greater than GetPointCount() then this method will return -1. */ - int32_t GetDeviceId( std::size_t point ) const; + int32_t GetDeviceId(std::size_t point) const; /** * @brief Retrieves the State of the point specified. @@ -156,7 +154,7 @@ public: * @note If point is greater than GetPointCount() then this method will return PointState::FINISHED. * @see State */ - PointState::Type GetState( std::size_t point ) const; + PointState::Type GetState(std::size_t point) const; /** * @brief Retrieves the actor that was underneath the point specified. @@ -166,7 +164,7 @@ public: * @return The actor that was underneath the point specified * @note If point is greater than GetPointCount() then this method will return an empty handle. */ - Actor GetHitActor( std::size_t point ) const; + Actor GetHitActor(std::size_t point) const; /** * @brief Retrieves the co-ordinates relative to the top-left of the hit-actor at the point specified. @@ -180,7 +178,7 @@ public: * then you should use Actor::ScreenToLocal(). * @note If point is greater than GetPointCount() then this method will return Vector2::ZERO. */ - const Vector2& GetLocalPosition( std::size_t point ) const; + const Vector2& GetLocalPosition(std::size_t point) const; /** * @brief Retrieves the co-ordinates relative to the top-left of the screen of the point specified. @@ -190,7 +188,7 @@ public: * @return The co-ordinates relative to the top-left of the screen of the point specified * @note If point is greater than GetPointCount() then this method will return Vector2::ZERO. */ - const Vector2& GetScreenPosition( std::size_t point ) const; + const Vector2& GetScreenPosition(std::size_t point) const; /** * @brief Retrieves the radius of the press point. @@ -202,7 +200,7 @@ public: * @return The radius of the press point * @note If point is greater than GetPointCount() then this method will return 0.0f. */ - float GetRadius( std::size_t point ) const; + float GetRadius(std::size_t point) const; /** * @brief Retrieves BOTH the horizontal and the vertical radii of the press point. @@ -212,7 +210,7 @@ public: * @return The horizontal and vertical radii of the press point * @note If point is greater than GetPointCount() then this method will return Vector2::ZERO. */ - const Vector2& GetEllipseRadius( std::size_t point ) const; + const Vector2& GetEllipseRadius(std::size_t point) const; /** * @brief Retrieves the touch pressure. @@ -227,7 +225,7 @@ public: * @return The touch pressure * @note If point is greater than GetPointCount() then this method will return 1.0f. */ - float GetPressure( std::size_t point ) const; + float GetPressure(std::size_t point) const; /** * @brief Retrieves the angle of the press point relative to the Y-Axis. @@ -237,7 +235,7 @@ public: * @return The angle of the press point * @note If point is greater than GetPointCount() then this method will return Degree(). */ - Degree GetAngle( std::size_t point ) const; + Degree GetAngle(std::size_t point) const; /** * @brief Gets the device class type from which the mouse/touch event is originated. @@ -247,7 +245,7 @@ public: * @param[in] point The point required * @return The type of the device class */ - Device::Class::Type GetDeviceClass( std::size_t point ) const; + Device::Class::Type GetDeviceClass(std::size_t point) const; /** * @brief Gets the subclass type of the device from which the mouse/touch event is originated. @@ -257,8 +255,7 @@ public: * @param[in] point The point required * @return The type of the device subclass */ - Device::Subclass::Type GetDeviceSubclass( std::size_t point ) const; - + Device::Subclass::Type GetDeviceSubclass(std::size_t point) const; /** * @brief Gets the value, which indicates a mouse button. (ex: right/left button) @@ -267,11 +264,9 @@ public: * @param[in] point The point required * @return The mouse button value */ - MouseButton::Type GetMouseButton( std::size_t point ) const; - + MouseButton::Type GetMouseButton(std::size_t point) const; public: // Not intended for application developers - /// @cond internal /** * @brief This constructor is used internally to Create an initialized TouchEvent handle. @@ -279,7 +274,7 @@ public: // Not intended for application developers * @SINCE_1_9.26 * @param[in] internal A pointer to a newly allocated Dali resource */ - explicit DALI_INTERNAL TouchEvent( Internal::TouchEvent* internal ); + explicit DALI_INTERNAL TouchEvent(Internal::TouchEvent* internal); /// @endcond }; diff --git a/dali/public-api/events/wheel-event.cpp b/dali/public-api/events/wheel-event.cpp index c6dd583..e179135 100644 --- a/dali/public-api/events/wheel-event.cpp +++ b/dali/public-api/events/wheel-event.cpp @@ -23,71 +23,70 @@ namespace Dali { - WheelEvent::WheelEvent() : BaseHandle() { } -WheelEvent::WheelEvent( const WheelEvent& rhs ) = default; +WheelEvent::WheelEvent(const WheelEvent& rhs) = default; -WheelEvent::WheelEvent( WheelEvent&& rhs ) = default; +WheelEvent::WheelEvent(WheelEvent&& rhs) = default; WheelEvent::~WheelEvent() { } -WheelEvent& WheelEvent::operator=( const WheelEvent& rhs ) = default; +WheelEvent& WheelEvent::operator=(const WheelEvent& rhs) = default; -WheelEvent& WheelEvent::operator=( WheelEvent&& rhs ) = default; +WheelEvent& WheelEvent::operator=(WheelEvent&& rhs) = default; bool WheelEvent::IsShiftModifier() const { - return GetImplementation( *this ).IsShiftModifier(); + return GetImplementation(*this).IsShiftModifier(); } bool WheelEvent::IsCtrlModifier() const { - return GetImplementation( *this ).IsCtrlModifier(); + return GetImplementation(*this).IsCtrlModifier(); } bool WheelEvent::IsAltModifier() const { - return GetImplementation( *this ).IsAltModifier(); + return GetImplementation(*this).IsAltModifier(); } WheelEvent::Type WheelEvent::GetType() const { - return GetImplementation( *this ).GetType(); + return GetImplementation(*this).GetType(); } int32_t WheelEvent::GetDirection() const { - return GetImplementation( *this ).GetDirection(); + return GetImplementation(*this).GetDirection(); } uint32_t WheelEvent::GetModifiers() const { - return GetImplementation( *this ).GetModifiers(); + return GetImplementation(*this).GetModifiers(); } const Vector2& WheelEvent::GetPoint() const { - return GetImplementation( *this ).GetPoint(); + return GetImplementation(*this).GetPoint(); } int32_t WheelEvent::GetDelta() const { - return GetImplementation( *this ).GetDelta(); + return GetImplementation(*this).GetDelta(); } uint32_t WheelEvent::GetTime() const { - return GetImplementation( *this ).GetTime(); + return GetImplementation(*this).GetTime(); } -WheelEvent::WheelEvent( Internal::WheelEvent* internal ) -: BaseHandle( internal ) +WheelEvent::WheelEvent(Internal::WheelEvent* internal) +: BaseHandle(internal) { } diff --git a/dali/public-api/events/wheel-event.h b/dali/public-api/events/wheel-event.h index 4e6a985..0737770 100644 --- a/dali/public-api/events/wheel-event.h +++ b/dali/public-api/events/wheel-event.h @@ -28,7 +28,6 @@ namespace Dali { - namespace Internal DALI_INTERNAL { class WheelEvent; @@ -52,9 +51,7 @@ class WheelEvent; */ class DALI_CORE_API WheelEvent : public BaseHandle { - public: - // Enumerations /** @@ -63,8 +60,8 @@ public: */ enum Type { - MOUSE_WHEEL, ///< Mouse wheel event @SINCE_1_0.0 - CUSTOM_WHEEL ///< Custom wheel event @SINCE_1_0.0 + MOUSE_WHEEL, ///< Mouse wheel event @SINCE_1_0.0 + CUSTOM_WHEEL ///< Custom wheel event @SINCE_1_0.0 }; // Construction & Destruction @@ -83,7 +80,7 @@ public: * @SINCE_1_9.26 * @param[in] rhs The WheelEvent to copy from */ - WheelEvent( const WheelEvent& rhs ); + WheelEvent(const WheelEvent& rhs); /** * @brief Move constructor. @@ -91,7 +88,7 @@ public: * @SINCE_1_9.26 * @param[in] rhs A reference to the moved WheelEvent */ - WheelEvent( WheelEvent&& rhs ); + WheelEvent(WheelEvent&& rhs); /** * @brief Destructor. @@ -106,7 +103,7 @@ public: * @param[in] rhs The WheelEvent to copy from * @return A reference to this */ - WheelEvent& operator=( const WheelEvent& rhs ); + WheelEvent& operator=(const WheelEvent& rhs); /** * @brief Move assignment operator. @@ -115,7 +112,7 @@ public: * @param[in] rhs A reference to the moved WheelEvent * @return A reference to this */ - WheelEvent& operator=( WheelEvent&& rhs ); + WheelEvent& operator=(WheelEvent&& rhs); /** * @brief Checks to see if Shift key modifier has been supplied. @@ -193,7 +190,6 @@ public: uint32_t GetTime() const; public: // Not intended for application developers - /// @cond internal /** * @brief This constructor is used internally to Create an initialized WheelEvent handle. @@ -201,7 +197,7 @@ public: // Not intended for application developers * @SINCE_1_9.26 * @param[in] wheelEvent A pointer to a newly allocated Dali resource */ - explicit DALI_INTERNAL WheelEvent( Internal::WheelEvent* hoverEvent ); + explicit DALI_INTERNAL WheelEvent(Internal::WheelEvent* hoverEvent); /// @endcond }; diff --git a/dali/public-api/images/image-operations.h b/dali/public-api/images/image-operations.h index 07b97df..353dc42 100644 --- a/dali/public-api/images/image-operations.h +++ b/dali/public-api/images/image-operations.h @@ -2,7 +2,7 @@ #define DALI_IMAGE_OPERATIONS_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -49,30 +49,30 @@ using ImageDimensions = Dali::Uint16Pair; */ namespace FittingMode { - /** +/** * @brief Enumeration for FittingMode type. * @SINCE_1_0.0 */ - enum Type - { - SHRINK_TO_FIT, ///< Fit full image inside desired width & height, potentially not - /// filling one of either the desired image width or height with - /// pixels. - /// @SINCE_1_0.0 - SCALE_TO_FILL, ///< Image fills whole desired width & height with image data. The - /// image is centred in the desired dimensions, exactly touching - /// in one dimension, with image regions outside the other desired - /// dimension cropped away. - /// @SINCE_1_0.0 - FIT_WIDTH, ///< Image fills whole width. Height is scaled proportionately to - /// maintain aspect ratio. - /// @SINCE_1_0.0 - FIT_HEIGHT ///< Image fills whole height. Width is scaled proportionately to - /// maintain aspect ratio. - /// @SINCE_1_0.0 - }; - const Type DEFAULT = SHRINK_TO_FIT; -} +enum Type +{ + SHRINK_TO_FIT, ///< Fit full image inside desired width & height, potentially not + /// filling one of either the desired image width or height with + /// pixels. + /// @SINCE_1_0.0 + SCALE_TO_FILL, ///< Image fills whole desired width & height with image data. The + /// image is centred in the desired dimensions, exactly touching + /// in one dimension, with image regions outside the other desired + /// dimension cropped away. + /// @SINCE_1_0.0 + FIT_WIDTH, ///< Image fills whole width. Height is scaled proportionately to + /// maintain aspect ratio. + /// @SINCE_1_0.0 + FIT_HEIGHT ///< Image fills whole height. Width is scaled proportionately to + /// maintain aspect ratio. + /// @SINCE_1_0.0 +}; +const Type DEFAULT = SHRINK_TO_FIT; +} // namespace FittingMode /** * @brief Filtering options, used when resizing images to sample original pixels. @@ -88,40 +88,40 @@ namespace FittingMode */ namespace SamplingMode { - /** +/** * @brief Enumeration for SamplingMode type. * @SINCE_1_0.0 */ - enum Type - { - BOX, ///< Iteratively box filter to generate an image of 1/2, 1/4, - /// 1/8, etc width and height and approximately the desired - /// size. This is the default. - /// @SINCE_1_0.0 - NEAREST, ///< For each output pixel, read one input pixel. - /// @SINCE_1_0.0 - LINEAR, ///< For each output pixel, read a quad of four input pixels - /// and write a weighted average of them. - /// @SINCE_1_0.0 - BOX_THEN_NEAREST, ///< Iteratively box filter to generate an image of 1/2, 1/4, - /// 1/8 etc width and height and approximately the desired - /// size, then for each output pixel, read one pixel from the - /// last level of box filtering. - /// @SINCE_1_0.0 - BOX_THEN_LINEAR, ///< Iteratively box filter to almost the right size, then for - /// each output pixel, read four pixels from the last level of - /// box filtering and write their weighted average. - /// @SINCE_1_0.0 - NO_FILTER, ///< No filtering is performed. If the SCALE_TO_FILL scaling mode - /// is enabled, the borders of the image may be trimmed to - /// match the aspect ratio of the desired dimensions. - /// @SINCE_1_0.0 - DONT_CARE ///< For caching algorithms where a client strongly prefers a - /// cache-hit to reuse a cached image. - /// @SINCE_1_0.0 - }; - const Type DEFAULT = BOX; -} +enum Type +{ + BOX, ///< Iteratively box filter to generate an image of 1/2, 1/4, + /// 1/8, etc width and height and approximately the desired + /// size. This is the default. + /// @SINCE_1_0.0 + NEAREST, ///< For each output pixel, read one input pixel. + /// @SINCE_1_0.0 + LINEAR, ///< For each output pixel, read a quad of four input pixels + /// and write a weighted average of them. + /// @SINCE_1_0.0 + BOX_THEN_NEAREST, ///< Iteratively box filter to generate an image of 1/2, 1/4, + /// 1/8 etc width and height and approximately the desired + /// size, then for each output pixel, read one pixel from the + /// last level of box filtering. + /// @SINCE_1_0.0 + BOX_THEN_LINEAR, ///< Iteratively box filter to almost the right size, then for + /// each output pixel, read four pixels from the last level of + /// box filtering and write their weighted average. + /// @SINCE_1_0.0 + NO_FILTER, ///< No filtering is performed. If the SCALE_TO_FILL scaling mode + /// is enabled, the borders of the image may be trimmed to + /// match the aspect ratio of the desired dimensions. + /// @SINCE_1_0.0 + DONT_CARE ///< For caching algorithms where a client strongly prefers a + /// cache-hit to reuse a cached image. + /// @SINCE_1_0.0 +}; +const Type DEFAULT = BOX; +} // namespace SamplingMode /** * @} diff --git a/dali/public-api/images/native-image-interface.h b/dali/public-api/images/native-image-interface.h index 0cff5e2..249cd91 100644 --- a/dali/public-api/images/native-image-interface.h +++ b/dali/public-api/images/native-image-interface.h @@ -23,8 +23,8 @@ #include // uint32_t // INTERNAL INCLUDES -#include #include +#include namespace Dali { @@ -42,7 +42,6 @@ namespace Dali class NativeImageInterface : public Dali::RefObject { public: - class Extension; ///< Forward declare future extension interface /** @@ -98,7 +97,7 @@ public: */ virtual uint32_t GetHeight() const = 0; - /** + /** * @brief Queries whether blending is required. * @SINCE_1_0.0 * @return True if blending is required @@ -158,7 +157,6 @@ public: } protected: - /** * @brief A reference counted object may only be deleted by calling Unreference(). * @@ -168,7 +166,6 @@ protected: ~NativeImageInterface() override { } - }; /** diff --git a/dali/public-api/images/pixel-data.cpp b/dali/public-api/images/pixel-data.cpp index 2118260..8b401bd 100644 --- a/dali/public-api/images/pixel-data.cpp +++ b/dali/public-api/images/pixel-data.cpp @@ -23,16 +23,15 @@ namespace Dali { - -PixelData PixelData::New( uint8_t* buffer, - uint32_t bufferSize, - uint32_t width, - uint32_t height, - Pixel::Format pixelFormat, - ReleaseFunction releaseFunction ) +PixelData PixelData::New(uint8_t* buffer, + uint32_t bufferSize, + uint32_t width, + uint32_t height, + Pixel::Format pixelFormat, + ReleaseFunction releaseFunction) { - IntrusivePtr internal = Internal::PixelData::New( buffer, bufferSize, width, height, pixelFormat, releaseFunction ); - return PixelData( internal.Get() ); + IntrusivePtr internal = Internal::PixelData::New(buffer, bufferSize, width, height, pixelFormat, releaseFunction); + return PixelData(internal.Get()); } PixelData::PixelData() @@ -43,8 +42,8 @@ PixelData::~PixelData() { } -PixelData::PixelData( Internal::PixelData* internal ) -: BaseHandle( internal ) +PixelData::PixelData(Internal::PixelData* internal) +: BaseHandle(internal) { } @@ -52,9 +51,9 @@ PixelData::PixelData(const PixelData& handle) = default; PixelData& PixelData::operator=(const PixelData& rhs) = default; -PixelData::PixelData( PixelData&& rhs ) = default; +PixelData::PixelData(PixelData&& rhs) = default; -PixelData& PixelData::operator=( PixelData&& rhs ) = default; +PixelData& PixelData::operator=(PixelData&& rhs) = default; uint32_t PixelData::GetWidth() const { diff --git a/dali/public-api/images/pixel-data.h b/dali/public-api/images/pixel-data.h index 82401e8..03fefc6 100644 --- a/dali/public-api/images/pixel-data.h +++ b/dali/public-api/images/pixel-data.h @@ -47,15 +47,14 @@ class PixelData; class DALI_CORE_API PixelData : public BaseHandle { public: - /** * @brief Enumeration for Function to release the pixel buffer. * @SINCE_1_1.43 */ enum ReleaseFunction { - FREE, ///< Use free function to release the pixel buffer @SINCE_1_1.43 - DELETE_ARRAY, ///< Use delete[] operator to release the pixel buffer @SINCE_1_1.43 + FREE, ///< Use free function to release the pixel buffer @SINCE_1_1.43 + DELETE_ARRAY, ///< Use delete[] operator to release the pixel buffer @SINCE_1_1.43 }; /** @@ -70,12 +69,12 @@ public: * @param[in] releaseFunction The function used to release the memory * @return A handle to the PixelData */ - static PixelData New( uint8_t* buffer, - uint32_t bufferSize, - uint32_t width, - uint32_t height, - Pixel::Format pixelFormat, - ReleaseFunction releaseFunction); + static PixelData New(uint8_t* buffer, + uint32_t bufferSize, + uint32_t width, + uint32_t height, + Pixel::Format pixelFormat, + ReleaseFunction releaseFunction); /** * @brief Creates an empty handle. @@ -115,7 +114,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs A reference to the moved handle */ - PixelData( PixelData&& rhs ); + PixelData(PixelData&& rhs); /** * @brief Move assignment operator. @@ -124,7 +123,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this handle */ - PixelData& operator=( PixelData&& rhs ); + PixelData& operator=(PixelData&& rhs); /** * @brief Gets the width of the buffer in pixels. @@ -151,14 +150,13 @@ public: Pixel::Format GetPixelFormat() const; public: - /** * @brief The constructor. * @note Not intended for application developers. * @SINCE_1_1.43 * @param[in] pointer A pointer to a newly allocated PixelData */ - explicit DALI_INTERNAL PixelData( Internal::PixelData* pointer ); + explicit DALI_INTERNAL PixelData(Internal::PixelData* pointer); }; /** diff --git a/dali/public-api/images/pixel.cpp b/dali/public-api/images/pixel.cpp index 428185a..38b962f 100644 --- a/dali/public-api/images/pixel.cpp +++ b/dali/public-api/images/pixel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -19,15 +19,14 @@ #include // INTERNAL INCLUDES -#include #include +#include namespace Dali { - bool Pixel::HasAlpha(Format pixelformat) { - switch (pixelformat) + switch(pixelformat) { case RGBA5551: case RGBA8888: @@ -104,7 +103,7 @@ bool Pixel::HasAlpha(Format pixelformat) uint32_t Pixel::GetBytesPerPixel(Format pixelFormat) { - switch (pixelFormat) + switch(pixelFormat) { case L8: case A8: @@ -200,7 +199,7 @@ uint32_t Pixel::GetBytesPerPixel(Format pixelFormat) void Pixel::GetAlphaOffsetAndMask(Format pixelFormat, int& byteOffset, int& bitMask) { - switch (pixelFormat) + switch(pixelFormat) { case A8: { @@ -216,39 +215,39 @@ void Pixel::GetAlphaOffsetAndMask(Format pixelFormat, int& byteOffset, int& bitM case BGR8888: case BGR565: { - byteOffset=0; - bitMask=0; + byteOffset = 0; + bitMask = 0; break; } case LA88: { - byteOffset=1; - bitMask=0xff; + byteOffset = 1; + bitMask = 0xff; break; } case RGBA4444: case BGRA4444: { - byteOffset=1; - bitMask=0x0f; + byteOffset = 1; + bitMask = 0x0f; break; } case RGBA5551: case BGRA5551: { - byteOffset=1; - bitMask=0x01; + byteOffset = 1; + bitMask = 0x01; break; } case RGBA8888: case BGRA8888: { - byteOffset=3; - bitMask=0xff; + byteOffset = 3; + bitMask = 0xff; break; } @@ -300,8 +299,8 @@ void Pixel::GetAlphaOffsetAndMask(Format pixelFormat, int& byteOffset, int& bitM case INVALID: { DALI_LOG_ERROR("Pixel formats are not compatible with simple masking-out of per-pixel alpha.\n"); - byteOffset=0; - bitMask=0; + byteOffset = 0; + bitMask = 0; break; } } diff --git a/dali/public-api/images/pixel.h b/dali/public-api/images/pixel.h index 7caa503..5b1b9de 100644 --- a/dali/public-api/images/pixel.h +++ b/dali/public-api/images/pixel.h @@ -2,7 +2,7 @@ #define DALI_PIXEL_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -46,76 +46,76 @@ namespace Pixel */ enum Format { - INVALID = 0, ///< Used to represent an unsupported format. @SINCE_1_1.17 + INVALID = 0, ///< Used to represent an unsupported format. @SINCE_1_1.17 // Start at > 0 to distinguish null data: - A8 = 1, ///< color depth 8-bit, alpha @SINCE_1_0.0 - L8, ///< color depth 8-bit, luminance @SINCE_1_0.0 - LA88, ///< color depth 16-bit, luminance with 8 bit alpha @SINCE_1_0.0 - RGB565, ///< color depth 16 bit, 5-6-5 @SINCE_1_0.0 - BGR565, ///< color depth 16 bit, 5-6-5 @SINCE_1_0.0 - RGBA4444, ///< color depth 16 bit with alpha, 4-4-4-4 @SINCE_1_0.0 - BGRA4444, ///< color depth 16 bit with alpha, 4-4-4-4 @SINCE_1_0.0 - RGBA5551, ///< color depth 16 bit with alpha, 5-5-5-1 @SINCE_1_0.0 - BGRA5551, ///< color depth 16 bit with alpha, 5-5-5-1 @SINCE_1_0.0 - RGB888, ///< color depth 24 bit, 8-8-8 @SINCE_1_0.0 - RGB8888, ///< color depth 32 bit, alpha is reserved but not used, 8-8-8-8# @SINCE_1_0.0 - BGR8888, ///< color depth 32 bit, alpha is reserved but not used, 8-8-8-8# @SINCE_1_0.0 - RGBA8888, ///< color depth 32 bit with alpha, 8-8-8-8 @SINCE_1_0.0 - BGRA8888, ///< color depth 32 bit with alpha, 8-8-8-8 @SINCE_1_0.0 + A8 = 1, ///< color depth 8-bit, alpha @SINCE_1_0.0 + L8, ///< color depth 8-bit, luminance @SINCE_1_0.0 + LA88, ///< color depth 16-bit, luminance with 8 bit alpha @SINCE_1_0.0 + RGB565, ///< color depth 16 bit, 5-6-5 @SINCE_1_0.0 + BGR565, ///< color depth 16 bit, 5-6-5 @SINCE_1_0.0 + RGBA4444, ///< color depth 16 bit with alpha, 4-4-4-4 @SINCE_1_0.0 + BGRA4444, ///< color depth 16 bit with alpha, 4-4-4-4 @SINCE_1_0.0 + RGBA5551, ///< color depth 16 bit with alpha, 5-5-5-1 @SINCE_1_0.0 + BGRA5551, ///< color depth 16 bit with alpha, 5-5-5-1 @SINCE_1_0.0 + RGB888, ///< color depth 24 bit, 8-8-8 @SINCE_1_0.0 + RGB8888, ///< color depth 32 bit, alpha is reserved but not used, 8-8-8-8# @SINCE_1_0.0 + BGR8888, ///< color depth 32 bit, alpha is reserved but not used, 8-8-8-8# @SINCE_1_0.0 + RGBA8888, ///< color depth 32 bit with alpha, 8-8-8-8 @SINCE_1_0.0 + BGRA8888, ///< color depth 32 bit with alpha, 8-8-8-8 @SINCE_1_0.0 // GLES 3 Standard compressed formats: - COMPRESSED_R11_EAC, ///< ETC2 / EAC single-channel, unsigned @SINCE_1_0.0 - COMPRESSED_SIGNED_R11_EAC, ///< ETC2 / EAC single-channel, signed @SINCE_1_0.0 - COMPRESSED_RG11_EAC, ///< ETC2 / EAC dual-channel, unsigned @SINCE_1_0.0 - COMPRESSED_SIGNED_RG11_EAC, ///< ETC2 / EAC dual-channel, signed @SINCE_1_0.0 - COMPRESSED_RGB8_ETC2, ///< ETC2 / EAC RGB @SINCE_1_0.0 - COMPRESSED_SRGB8_ETC2, ///< ETC2 / EAC RGB using sRGB colourspace. @SINCE_1_0.0 - COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, ///< ETC2 / EAC RGB with single bit per pixel alpha mask. @SINCE_1_0.0 - COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,///< ETC2 / EAC RGB using sRGB colourspace, with single bit per pixel alpha mask. @SINCE_1_0.0 - COMPRESSED_RGBA8_ETC2_EAC, ///< ETC2 / EAC RGB plus separate alpha channel. @SINCE_1_0.0 - COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, ///< ETC2 / EAC RGB using sRGB colourspace, plus separate alpha channel. @SINCE_1_0.0 + COMPRESSED_R11_EAC, ///< ETC2 / EAC single-channel, unsigned @SINCE_1_0.0 + COMPRESSED_SIGNED_R11_EAC, ///< ETC2 / EAC single-channel, signed @SINCE_1_0.0 + COMPRESSED_RG11_EAC, ///< ETC2 / EAC dual-channel, unsigned @SINCE_1_0.0 + COMPRESSED_SIGNED_RG11_EAC, ///< ETC2 / EAC dual-channel, signed @SINCE_1_0.0 + COMPRESSED_RGB8_ETC2, ///< ETC2 / EAC RGB @SINCE_1_0.0 + COMPRESSED_SRGB8_ETC2, ///< ETC2 / EAC RGB using sRGB colourspace. @SINCE_1_0.0 + COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, ///< ETC2 / EAC RGB with single bit per pixel alpha mask. @SINCE_1_0.0 + COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, ///< ETC2 / EAC RGB using sRGB colourspace, with single bit per pixel alpha mask. @SINCE_1_0.0 + COMPRESSED_RGBA8_ETC2_EAC, ///< ETC2 / EAC RGB plus separate alpha channel. @SINCE_1_0.0 + COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, ///< ETC2 / EAC RGB using sRGB colourspace, plus separate alpha channel. @SINCE_1_0.0 // GLES 2 extension compressed formats: - COMPRESSED_RGB8_ETC1, ///< ETC1 RGB as defined by GLES 2 extension OES_compressed_ETC1_RGB8_texture: http://www.khronos.org/registry/gles/extensions/OES/OES_compressed_ETC1_RGB8_texture.txt @SINCE_1_0.0 - COMPRESSED_RGB_PVRTC_4BPPV1, ///< PowerVR 4bpp RGB format (v1) as defined by extension IMG_texture_compression_pvrtc: http://www.khronos.org/registry/gles/extensions/IMG/IMG_texture_compression_pvrtc.txt @SINCE_1_0.0 + COMPRESSED_RGB8_ETC1, ///< ETC1 RGB as defined by GLES 2 extension OES_compressed_ETC1_RGB8_texture: http://www.khronos.org/registry/gles/extensions/OES/OES_compressed_ETC1_RGB8_texture.txt @SINCE_1_0.0 + COMPRESSED_RGB_PVRTC_4BPPV1, ///< PowerVR 4bpp RGB format (v1) as defined by extension IMG_texture_compression_pvrtc: http://www.khronos.org/registry/gles/extensions/IMG/IMG_texture_compression_pvrtc.txt @SINCE_1_0.0 // GLES 3.1 compressed formats: - COMPRESSED_RGBA_ASTC_4x4_KHR, ///< ASTC Linear color space with a 4x4 block-size. @SINCE_1_1.17 - COMPRESSED_RGBA_ASTC_5x4_KHR, ///< ASTC Linear color space with a 5x4 block-size. @SINCE_1_1.17 - COMPRESSED_RGBA_ASTC_5x5_KHR, ///< ASTC Linear color space with a 5x5 block-size. @SINCE_1_1.17 - COMPRESSED_RGBA_ASTC_6x5_KHR, ///< ASTC Linear color space with a 6x5 block-size. @SINCE_1_1.17 - COMPRESSED_RGBA_ASTC_6x6_KHR, ///< ASTC Linear color space with a 6x6 block-size. @SINCE_1_1.17 - COMPRESSED_RGBA_ASTC_8x5_KHR, ///< ASTC Linear color space with a 8x5 block-size. @SINCE_1_1.17 - COMPRESSED_RGBA_ASTC_8x6_KHR, ///< ASTC Linear color space with a 8x6 block-size. @SINCE_1_1.17 - COMPRESSED_RGBA_ASTC_8x8_KHR, ///< ASTC Linear color space with a 8x8 block-size. @SINCE_1_1.17 - COMPRESSED_RGBA_ASTC_10x5_KHR, ///< ASTC Linear color space with a 10x5 block-size. @SINCE_1_1.17 - COMPRESSED_RGBA_ASTC_10x6_KHR, ///< ASTC Linear color space with a 10x6 block-size. @SINCE_1_1.17 - COMPRESSED_RGBA_ASTC_10x8_KHR, ///< ASTC Linear color space with a 10x8 block-size. @SINCE_1_1.17 - COMPRESSED_RGBA_ASTC_10x10_KHR, ///< ASTC Linear color space with a 10x10 block-size. @SINCE_1_1.17 - COMPRESSED_RGBA_ASTC_12x10_KHR, ///< ASTC Linear color space with a 12x10 block-size. @SINCE_1_1.17 - COMPRESSED_RGBA_ASTC_12x12_KHR, ///< ASTC Linear color space with a 12x12 block-size. @SINCE_1_1.17 - COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 4x4 block-size. @SINCE_1_1.17 - COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 5x4 block-size. @SINCE_1_1.17 - COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 5x5 block-size. @SINCE_1_1.17 - COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 6x5 block-size. @SINCE_1_1.17 - COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 6x6 block-size. @SINCE_1_1.17 - COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 8x5 block-size. @SINCE_1_1.17 - COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 8x6 block-size. @SINCE_1_1.17 - COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 8x8 block-size. @SINCE_1_1.17 - COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 10x5 block-size. @SINCE_1_1.17 - COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 10x6 block-size. @SINCE_1_1.17 - COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 10x8 block-size. @SINCE_1_1.17 - COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 10x10 block-size. @SINCE_1_1.17 - COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 12x10 block-size. @SINCE_1_1.17 - COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 12x12 block-size. @SINCE_1_1.17 + COMPRESSED_RGBA_ASTC_4x4_KHR, ///< ASTC Linear color space with a 4x4 block-size. @SINCE_1_1.17 + COMPRESSED_RGBA_ASTC_5x4_KHR, ///< ASTC Linear color space with a 5x4 block-size. @SINCE_1_1.17 + COMPRESSED_RGBA_ASTC_5x5_KHR, ///< ASTC Linear color space with a 5x5 block-size. @SINCE_1_1.17 + COMPRESSED_RGBA_ASTC_6x5_KHR, ///< ASTC Linear color space with a 6x5 block-size. @SINCE_1_1.17 + COMPRESSED_RGBA_ASTC_6x6_KHR, ///< ASTC Linear color space with a 6x6 block-size. @SINCE_1_1.17 + COMPRESSED_RGBA_ASTC_8x5_KHR, ///< ASTC Linear color space with a 8x5 block-size. @SINCE_1_1.17 + COMPRESSED_RGBA_ASTC_8x6_KHR, ///< ASTC Linear color space with a 8x6 block-size. @SINCE_1_1.17 + COMPRESSED_RGBA_ASTC_8x8_KHR, ///< ASTC Linear color space with a 8x8 block-size. @SINCE_1_1.17 + COMPRESSED_RGBA_ASTC_10x5_KHR, ///< ASTC Linear color space with a 10x5 block-size. @SINCE_1_1.17 + COMPRESSED_RGBA_ASTC_10x6_KHR, ///< ASTC Linear color space with a 10x6 block-size. @SINCE_1_1.17 + COMPRESSED_RGBA_ASTC_10x8_KHR, ///< ASTC Linear color space with a 10x8 block-size. @SINCE_1_1.17 + COMPRESSED_RGBA_ASTC_10x10_KHR, ///< ASTC Linear color space with a 10x10 block-size. @SINCE_1_1.17 + COMPRESSED_RGBA_ASTC_12x10_KHR, ///< ASTC Linear color space with a 12x10 block-size. @SINCE_1_1.17 + COMPRESSED_RGBA_ASTC_12x12_KHR, ///< ASTC Linear color space with a 12x12 block-size. @SINCE_1_1.17 + COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 4x4 block-size. @SINCE_1_1.17 + COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 5x4 block-size. @SINCE_1_1.17 + COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 5x5 block-size. @SINCE_1_1.17 + COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 6x5 block-size. @SINCE_1_1.17 + COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 6x6 block-size. @SINCE_1_1.17 + COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 8x5 block-size. @SINCE_1_1.17 + COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 8x6 block-size. @SINCE_1_1.17 + COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 8x8 block-size. @SINCE_1_1.17 + COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 10x5 block-size. @SINCE_1_1.17 + COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 10x6 block-size. @SINCE_1_1.17 + COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 10x8 block-size. @SINCE_1_1.17 + COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 10x10 block-size. @SINCE_1_1.17 + COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 12x10 block-size. @SINCE_1_1.17 + COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, ///< ASTC Non-linear (gamma-corrected) color space with a 12x12 block-size. @SINCE_1_1.17 // GLES 3.0 floating point formats. RGB16F, ///< Color depth 48-bit, 16-16-16 half floating point. @SINCE_1_2.60 RGB32F, ///< Color depth 96-bit, 32-32-32 floating point. @SINCE_1_2.60 DEPTH_UNSIGNED_INT, ///< Unsigned int depth format 32-bit. @SINCE_1_9.9 - DEPTH_FLOAT, ///< Float depth format 32-bit. @SINCE_1_9.9 + DEPTH_FLOAT, ///< Float depth format 32-bit. @SINCE_1_9.9 DEPTH_STENCIL ///< Depth stencil 32-bit, 24 bit for depth, 8 bit for stencil. @SINCE_1_9.9 ///! Update LAST_VALID_PIXEL_FORMAT below if you add an enum value here. diff --git a/dali/public-api/math/angle-axis.h b/dali/public-api/math/angle-axis.h index fe88395..3582d78 100644 --- a/dali/public-api/math/angle-axis.h +++ b/dali/public-api/math/angle-axis.h @@ -51,7 +51,8 @@ struct AngleAxis AngleAxis() : angle(0.0f), axis(0.0f, 0.0f, 0.0f) - { } + { + } /** * @brief Creates an angle-axis pair. @@ -60,23 +61,21 @@ struct AngleAxis * @param[in] initialAngle The initial angle in radians * @param[in] initialAxis The initial axis */ - AngleAxis( Radian initialAngle, const Vector3& initialAxis ) - : angle( initialAngle ), - axis( initialAxis ) - { } + AngleAxis(Radian initialAngle, const Vector3& initialAxis) + : angle(initialAngle), + axis(initialAxis) + { + } public: - - AngleAxis( const AngleAxis& ) = default; ///< Default copy constructor - AngleAxis( AngleAxis&& ) = default; ///< Default move constructor - AngleAxis& operator=( const AngleAxis& ) = default; ///< Default copy assignment operator - AngleAxis& operator=( AngleAxis&& ) = default; ///< Default move assignment operator + AngleAxis(const AngleAxis&) = default; ///< Default copy constructor + AngleAxis(AngleAxis&&) = default; ///< Default move constructor + AngleAxis& operator=(const AngleAxis&) = default; ///< Default copy assignment operator + AngleAxis& operator=(AngleAxis&&) = default; ///< Default move assignment operator public: - - Radian angle; ///< The angle in radians - Vector3 axis; ///< The axis - + Radian angle; ///< The angle in radians + Vector3 axis; ///< The axis }; // Compiler generated destructor, copy constructor and assignment operators are ok as this class is POD @@ -89,7 +88,7 @@ public: * @param rhs angle axis * @return True if they are equal */ -inline bool operator==( const Dali::AngleAxis& lhs, const Dali::AngleAxis& rhs ) +inline bool operator==(const Dali::AngleAxis& lhs, const Dali::AngleAxis& rhs) { return (lhs.angle == rhs.angle) && (lhs.axis == rhs.axis); } @@ -102,9 +101,9 @@ inline bool operator==( const Dali::AngleAxis& lhs, const Dali::AngleAxis& rhs ) * @param[in] angleAxis The angle axis to print * @return The output stream operator */ -inline std::ostream& operator<< (std::ostream& o, const Dali::AngleAxis& angleAxis) +inline std::ostream& operator<<(std::ostream& o, const Dali::AngleAxis& angleAxis) { - return o << "[ Axis: [" << angleAxis.axis.x << ", " << angleAxis.axis.y << ", " << angleAxis.axis.z << "], Angle: " << Degree( angleAxis.angle ).degree << " degrees ]"; + return o << "[ Axis: [" << angleAxis.axis.x << ", " << angleAxis.axis.y << ", " << angleAxis.axis.z << "], Angle: " << Degree(angleAxis.angle).degree << " degrees ]"; } /** diff --git a/dali/public-api/math/compile-time-math.cpp b/dali/public-api/math/compile-time-math.cpp index 5948d78..834361e 100644 --- a/dali/public-api/math/compile-time-math.cpp +++ b/dali/public-api/math/compile-time-math.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -23,28 +23,27 @@ namespace Dali { - // verification for static asserts, these get removed from final binary by the linker -static_assert( Power<10,0>::value == 1, "" ); -static_assert( Power<10,1>::value == 10, "" ); -static_assert( Power<10,2>::value == 100, "" ); -static_assert( Power<10,3>::value == 1000, "" ); -static_assert( Power<4,4>::value == 256, "" ); - -static_assert( Log<0, 10>::value == 0, "" ); -static_assert( Log<1, 10>::value == 0, "" ); -static_assert( Log<2, 10>::value == 1, "" ); -static_assert( Log<10, 10>::value == 1, "" ); -static_assert( Log<100, 10>::value == 2, "" ); -static_assert( Log<1000, 10>::value == 3, "" ); - -static_assert( Log::value, 10 >::value == 0, "" ); -static_assert( Log::value, 2 >::value == 0, "" ); -static_assert( Log::value, 10 >::value == 2, "" ); -static_assert( Log::value, 2 >::value == 2, "" ); - -static_assert( Power<10, Log<10,10>::value >::value == 10, "" ); -static_assert( Power<10, Log<100,10>::value >::value == 100, "" ); +static_assert(Power<10, 0>::value == 1, ""); +static_assert(Power<10, 1>::value == 10, ""); +static_assert(Power<10, 2>::value == 100, ""); +static_assert(Power<10, 3>::value == 1000, ""); +static_assert(Power<4, 4>::value == 256, ""); + +static_assert(Log<0, 10>::value == 0, ""); +static_assert(Log<1, 10>::value == 0, ""); +static_assert(Log<2, 10>::value == 1, ""); +static_assert(Log<10, 10>::value == 1, ""); +static_assert(Log<100, 10>::value == 2, ""); +static_assert(Log<1000, 10>::value == 3, ""); + +static_assert(Log::value, 10>::value == 0, ""); +static_assert(Log::value, 2>::value == 0, ""); +static_assert(Log::value, 10>::value == 2, ""); +static_assert(Log::value, 2>::value == 2, ""); + +static_assert(Power<10, Log<10, 10>::value>::value == 10, ""); +static_assert(Power<10, Log<100, 10>::value>::value == 100, ""); // TODO unfortunately cannot static assert floats so cannot test EPSILON here... diff --git a/dali/public-api/math/compile-time-math.h b/dali/public-api/math/compile-time-math.h index 7aecd85..6846db1 100644 --- a/dali/public-api/math/compile-time-math.h +++ b/dali/public-api/math/compile-time-math.h @@ -2,7 +2,7 @@ #define DALI_COMPILE_TIME_MATH_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -41,10 +41,13 @@ namespace Dali * @note Values need to be compile time constants. * Usage: Power< 10, 2 >::value; // value=100 */ -template< size_t mantissa, size_t exponent > +template struct Power { - enum { value = mantissa * Power< mantissa, exponent - 1 >::value }; + enum + { + value = mantissa * Power::value + }; }; /** @@ -54,10 +57,13 @@ struct Power * @SINCE_1_0.0 * @tparam mantissa to raise to exponent */ -template< size_t mantissa > -struct Power< mantissa, 1 > +template +struct Power { - enum { value = mantissa }; + enum + { + value = mantissa + }; }; /** @@ -67,10 +73,13 @@ struct Power< mantissa, 1 > * @SINCE_1_0.0 * @tparam mantissa to raise to exponent */ -template< size_t mantissa > -struct Power< mantissa, 0 > +template +struct Power { - enum { value = 1 }; + enum + { + value = 1 + }; }; /** @@ -82,10 +91,13 @@ struct Power< mantissa, 0 > * @note Values need to be compile time constants. * Usage: Log< 100, 10 >::value; value equals 2 */ -template< size_t number, size_t base = 2 > +template struct Log { - enum { value = 1 + Log< number / base, base >::value }; + enum + { + value = 1 + Log::value + }; }; /** @@ -95,10 +107,13 @@ struct Log * @SINCE_1_0.0 * @tparam base logarithm to calculate */ -template< size_t base > -struct Log< 1, base > +template +struct Log<1, base> { - enum { value = 0 }; + enum + { + value = 0 + }; }; /** @@ -108,13 +123,15 @@ struct Log< 1, base > * @SINCE_1_0.0 * @tparam base logarithm to calculate */ -template< size_t base > -struct Log< 0, base > +template +struct Log<0, base> { - enum { value = 0 }; + enum + { + value = 0 + }; }; - /** * @brief Compiles time template to calculate the machine epsilon for a given floating point number. * @@ -123,15 +140,15 @@ struct Log< 0, base > * @note Value needs to be compile time constant. * Usage: Epsilon<1000>::value; value equals 0.000119209 */ -template< size_t N > +template struct Epsilon { // take log10 of the number to get to the nearest power of 10 number and divide that by 10 // template recursion will take care of the rest #ifdef _CPP11 - static constexpr float value = 10.0f * Epsilon< Power< 10, Log< N, 10 >::value >::value / 10 >::value; + static constexpr float value = 10.0f * Epsilon::value>::value / 10>::value; #else - static const float value = 10.0f * Epsilon< Power< 10, Log< N, 10 >::value >::value / 10 >::value; + static const float value = 10.0f * Epsilon::value>::value / 10>::value; #endif }; @@ -142,7 +159,7 @@ struct Epsilon * @SINCE_1_0.0 */ template<> -struct Epsilon< 1 > +struct Epsilon<1> { #ifdef _CPP11 static constexpr float value = FLT_EPSILON; @@ -158,7 +175,7 @@ struct Epsilon< 1 > * @SINCE_1_0.0 */ template<> -struct Epsilon< 0 > +struct Epsilon<0> { #ifdef _CPP11 static constexpr float value = FLT_MIN; diff --git a/dali/public-api/math/degree.cpp b/dali/public-api/math/degree.cpp index e2bfca9..e4dd514 100644 --- a/dali/public-api/math/degree.cpp +++ b/dali/public-api/math/degree.cpp @@ -23,9 +23,8 @@ namespace Dali { - -Degree::Degree( Radian radian ) -: degree( radian * Math::ONE80_OVER_PI ) +Degree::Degree(Radian radian) +: degree(radian * Math::ONE80_OVER_PI) { } diff --git a/dali/public-api/math/degree.h b/dali/public-api/math/degree.h index cefaa98..7e130b4 100644 --- a/dali/public-api/math/degree.h +++ b/dali/public-api/math/degree.h @@ -45,8 +45,9 @@ struct Degree * @SINCE_1_0.0 */ Degree() - : degree( 0.f ) - { } + : degree(0.f) + { + } /** * @brief Creates an angle in degrees. @@ -54,9 +55,10 @@ struct Degree * @SINCE_1_0.0 * @param[in] value The initial value in degrees */ - explicit constexpr Degree( float value ) - : degree( value ) - { } + explicit constexpr Degree(float value) + : degree(value) + { + } /** * @brief Creates an angle in degrees from a Radian. @@ -64,25 +66,21 @@ struct Degree * @SINCE_1_0.0 * @param[in] value The initial value in Radians */ - DALI_CORE_API Degree( Radian value ); + DALI_CORE_API Degree(Radian value); public: - - Degree( const Degree& ) = default; ///< Default copy constructor - Degree( Degree&& ) = default; ///< Default move constructor - Degree& operator=( const Degree& ) = default; ///< Default copy assignment operator - Degree& operator=( Degree&& ) = default; ///< Default move assignment operator + Degree(const Degree&) = default; ///< Default copy constructor + Degree(Degree&&) = default; ///< Default move constructor + Degree& operator=(const Degree&) = default; ///< Default copy assignment operator + Degree& operator=(Degree&&) = default; ///< Default move assignment operator public: - // member data float degree; ///< The value in degrees - }; // compiler generated destructor, copy constructor and assignment operators are ok as this class is POD - /** * @brief Compares equality between two degrees. * @@ -91,9 +89,9 @@ public: * @param[in] rhs Degree to compare to * @return True if the values are identical */ -inline bool operator==( const Degree& lhs, const Degree& rhs ) +inline bool operator==(const Degree& lhs, const Degree& rhs) { - return fabsf( lhs.degree - rhs.degree ) < Math::MACHINE_EPSILON_1000; // expect degree angles to be between 0 and 1000 + return fabsf(lhs.degree - rhs.degree) < Math::MACHINE_EPSILON_1000; // expect degree angles to be between 0 and 1000 } /** @@ -104,9 +102,9 @@ inline bool operator==( const Degree& lhs, const Degree& rhs ) * @param[in] rhs Degree to compare to * @return True if the values are not identical */ -inline bool operator!=( const Degree& lhs, const Degree& rhs ) +inline bool operator!=(const Degree& lhs, const Degree& rhs) { - return !( operator==( lhs, rhs ) ); + return !(operator==(lhs, rhs)); } /** @@ -117,9 +115,9 @@ inline bool operator!=( const Degree& lhs, const Degree& rhs ) * @param max value * @return The resulting radian */ -inline Degree Clamp( Degree angle, float min, float max ) +inline Degree Clamp(Degree angle, float min, float max) { - return Degree( Clamp( angle.degree, min, max ) ); + return Degree(Clamp(angle.degree, min, max)); } /** diff --git a/dali/public-api/math/math-utils.h b/dali/public-api/math/math-utils.h index 55024c7..116ee7d 100644 --- a/dali/public-api/math/math-utils.h +++ b/dali/public-api/math/math-utils.h @@ -2,7 +2,7 @@ #define DALI_MATH_UTILS_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -22,8 +22,8 @@ #include // uint32_t // INTERNAL INCLUDES -#include #include +#include namespace Dali { @@ -41,10 +41,10 @@ namespace Dali * @param[in] i Input number * @return The next power of two or i itself in case it's a power of two */ -inline uint32_t NextPowerOfTwo( uint32_t i ) +inline uint32_t NextPowerOfTwo(uint32_t i) { DALI_ASSERT_ALWAYS(i <= 1u << (sizeof(uint32_t) * 8 - 1) && "Return type cannot represent the next power of two greater than the argument."); - if(i==0u) + if(i == 0u) { return 1u; } @@ -66,7 +66,7 @@ inline uint32_t NextPowerOfTwo( uint32_t i ) * @param[in] i Input number * @return True if i is power of two. */ -inline bool IsPowerOfTwo( uint32_t i ) +inline bool IsPowerOfTwo(uint32_t i) { return (i != 0u) && ((i & (i - 1u)) == 0u); } @@ -80,12 +80,12 @@ inline bool IsPowerOfTwo( uint32_t i ) * @param[in] max The maximum allowed value. * @return T the clamped value */ -template< typename T > -inline const T& Clamp( const T& value, const T& min, const T& max ) +template +inline const T& Clamp(const T& value, const T& min, const T& max) { - const T& constrainedUpper = value < max ? value : max; + const T& constrainedUpper = value < max ? value : max; const T& constrainedUpperAndLower = constrainedUpper > min ? constrainedUpper : min; - return constrainedUpperAndLower; + return constrainedUpperAndLower; } /** @@ -96,15 +96,14 @@ inline const T& Clamp( const T& value, const T& min, const T& max ) * @param[in] min The minimum allowed value. * @param[in] max The maximum allowed value. */ -template< typename T > -inline void ClampInPlace( T& value, const T& min, const T& max ) +template +inline void ClampInPlace(T& value, const T& min, const T& max) { - const T& constrainedUpper = value < max ? value : max; + const T& constrainedUpper = value < max ? value : max; const T& constrainedUpperAndLower = constrainedUpper > min ? constrainedUpper : min; - value = constrainedUpperAndLower; + value = constrainedUpperAndLower; } - /** * @brief Linear interpolation between two values. * @@ -115,8 +114,8 @@ inline void ClampInPlace( T& value, const T& min, const T& max ) * @param[in] high Highest value in range * @return A value between low and high. */ -template< typename T > -inline const T Lerp( const float offset, const T& low, const T& high ) +template +inline const T Lerp(const float offset, const T& low, const T& high) { return low + ((high - low) * Clamp(offset, 0.0f, 1.0f)); } @@ -129,31 +128,31 @@ inline const T Lerp( const float offset, const T& low, const T& high ) * @param[in] b the second value in the range. * @return a suitable epsilon */ -inline float GetRangedEpsilon( float a, float b ) +inline float GetRangedEpsilon(float a, float b) { - const float absA = fabsf( a ); - const float absB = fabsf( b ); - const float absF = absA > absB ? absA : absB; - const int32_t absI = static_cast( absF ); // truncated + const float absA = fabsf(a); + const float absB = fabsf(b); + const float absF = absA > absB ? absA : absB; + const int32_t absI = static_cast(absF); // truncated float epsilon = Math::MACHINE_EPSILON_10000; - if (absF < 0.1f) + if(absF < 0.1f) { return Math::MACHINE_EPSILON_0; } - else if (absI < 2) + else if(absI < 2) { return Math::MACHINE_EPSILON_1; } - else if (absI < 20) + else if(absI < 20) { return Math::MACHINE_EPSILON_10; } - else if (absI < 200) + else if(absI < 200) { return Math::MACHINE_EPSILON_100; } - else if (absI < 2000) + else if(absI < 2000) { return Math::MACHINE_EPSILON_1000; } @@ -171,7 +170,7 @@ inline float GetRangedEpsilon( float a, float b ) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wfloat-equal" #endif -inline bool EqualsZero( float value ) +inline bool EqualsZero(float value) { return value == 0.0f; } @@ -187,9 +186,9 @@ inline bool EqualsZero( float value ) * @param[in] b the second value to compare * @return true if the values are equal within a minimal epsilon for their values */ -inline bool Equals( float a, float b ) +inline bool Equals(float a, float b) { - return ( fabsf( a - b ) <= GetRangedEpsilon( a, b ) ); + return (fabsf(a - b) <= GetRangedEpsilon(a, b)); } /** @@ -201,9 +200,9 @@ inline bool Equals( float a, float b ) * @param[in] epsilon the minimum epsilon value that will be used to consider the values different * @return true if the difference between the values is less than the epsilon */ -inline bool Equals( float a, float b, float epsilon ) +inline bool Equals(float a, float b, float epsilon) { - return ( fabsf( a - b ) <= epsilon ); + return (fabsf(a - b) <= epsilon); } /** @@ -214,12 +213,12 @@ inline bool Equals( float a, float b, float epsilon ) * @param[in] pos decimal place * @return a rounded float */ -inline float Round( float value, int32_t pos ) +inline float Round(float value, int32_t pos) { float temp; - temp = value * powf( 10.f, static_cast( pos ) ); - temp = floorf( temp + 0.5f ); - temp *= powf( 10.f, static_cast( -pos ) ); + temp = value * powf(10.f, static_cast(pos)); + temp = floorf(temp + 0.5f); + temp *= powf(10.f, static_cast(-pos)); return temp; } @@ -271,7 +270,6 @@ inline float WrapInDomain(float x, float start, float end) return start; } - /** * @brief Find the shortest distance (magnitude) and direction (sign) * from (a) to (b) in domain (start) to (end). @@ -303,30 +301,30 @@ inline float WrapInDomain(float x, float start, float end) * (start) to (end). * */ -inline float ShortestDistanceInDomain( float a, float b, float start, float end ) +inline float ShortestDistanceInDomain(float a, float b, float start, float end) { // (a-start + end-b) - float size = end-start; - float vect = b-a; + float size = end - start; + float vect = b - a; if(vect > 0) { // +ve vector, let's try perspective 1 domain to the right, // and see if closer. - float aRight = a+size; - if( aRight-b < vect ) + float aRight = a + size; + if(aRight - b < vect) { - return b-aRight; + return b - aRight; } } else { // -ve vector, let's try perspective 1 domain to the left, // and see if closer. - float aLeft = a-size; - if( aLeft-b > vect ) + float aLeft = a - size; + if(aLeft - b > vect) { - return b-aLeft; + return b - aLeft; } } @@ -340,10 +338,10 @@ inline float ShortestDistanceInDomain( float a, float b, float start, float end * @param[in] value The value we want to extract the sign * @return -1 for negative values, +1 for positive values and 0 if value is 0 */ -template -int32_t Sign( T value ) +template +int32_t Sign(T value) { - return ( T(0) < value ) - ( value < T(0) ); + return (T(0) < value) - (value < T(0)); } /** diff --git a/dali/public-api/math/matrix.cpp b/dali/public-api/math/matrix.cpp index b1a33bd..6efc679 100644 --- a/dali/public-api/math/matrix.cpp +++ b/dali/public-api/math/matrix.cpp @@ -25,28 +25,28 @@ #include // INTERNAL INCLUDES +#include #include +#include +#include #include #include -#include -#include -#include namespace { const float ROTATION_EPSILON = 0.003f; // Deliberately large -const uint32_t NUM_BYTES_IN_ROW_OF_3( 3 * sizeof( float ) ); -const uint32_t NUM_BYTES_IN_ROW( 4 * sizeof( float ) ); -const uint32_t NUM_BYTES_IN_MATRIX( 16 * sizeof( float ) ); -const uint32_t ROW1_OFFSET( 4 ); -const uint32_t ROW2_OFFSET( 8 ); -const uint32_t ROW3_OFFSET( 12 ); +const uint32_t NUM_BYTES_IN_ROW_OF_3(3 * sizeof(float)); +const uint32_t NUM_BYTES_IN_ROW(4 * sizeof(float)); +const uint32_t NUM_BYTES_IN_MATRIX(16 * sizeof(float)); +const uint32_t ROW1_OFFSET(4); +const uint32_t ROW2_OFFSET(8); +const uint32_t ROW3_OFFSET(12); /** * Helper to convert to Quaternion to float16 array */ -void Convert( float*& m, const Dali::Quaternion& rotation ) +void Convert(float*& m, const Dali::Quaternion& rotation) { const float xx = rotation.mVector.x * rotation.mVector.x; const float yy = rotation.mVector.y * rotation.mVector.y; @@ -58,6 +58,7 @@ void Convert( float*& m, const Dali::Quaternion& rotation ) const float wz = rotation.mVector.w * rotation.mVector.z; const float yz = rotation.mVector.y * rotation.mVector.z; + // clang-format off m[0] = 1.0f - 2.0f * (yy + zz); m[1] = 2.0f * (xy + wz); m[2] = 2.0f * (xz - wy); @@ -77,83 +78,86 @@ void Convert( float*& m, const Dali::Quaternion& rotation ) m[13]= 0.0f; m[14]= 0.0f; m[15]= 1.0f; + // clang-format on } -} +} // namespace namespace Dali { - using Internal::PerformanceMonitor; -const float identityArray[] = {1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f}; +// clang-format off +const float identityArray[] = { + 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f}; +// clang-format on const Matrix Matrix::IDENTITY(identityArray); Matrix::Matrix() { - memset( mMatrix, 0, NUM_BYTES_IN_MATRIX ); + memset(mMatrix, 0, NUM_BYTES_IN_MATRIX); } -Matrix::Matrix( bool initialize ) +Matrix::Matrix(bool initialize) { - if( initialize ) + if(initialize) { - memset( mMatrix, 0, NUM_BYTES_IN_MATRIX ); + memset(mMatrix, 0, NUM_BYTES_IN_MATRIX); } } Matrix::Matrix(const float* array) { - memcpy( mMatrix, array, NUM_BYTES_IN_MATRIX ); + memcpy(mMatrix, array, NUM_BYTES_IN_MATRIX); } -Matrix::Matrix( const Quaternion& rotation ) +Matrix::Matrix(const Quaternion& rotation) { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,18); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 18); float* matrixPtr = &mMatrix[0]; - Convert( matrixPtr, rotation ); + Convert(matrixPtr, rotation); } -Matrix::Matrix( const Matrix& matrix ) +Matrix::Matrix(const Matrix& matrix) { - memcpy( mMatrix, matrix.mMatrix, NUM_BYTES_IN_MATRIX ); + memcpy(mMatrix, matrix.mMatrix, NUM_BYTES_IN_MATRIX); } -Matrix& Matrix::operator=( const Matrix& matrix ) +Matrix& Matrix::operator=(const Matrix& matrix) { // no point copying if self assigning - if( this != &matrix ) + if(this != &matrix) { - memcpy( mMatrix, matrix.mMatrix, NUM_BYTES_IN_MATRIX ); + memcpy(mMatrix, matrix.mMatrix, NUM_BYTES_IN_MATRIX); } return *this; } -Matrix::Matrix( Matrix&& matrix ) +Matrix::Matrix(Matrix&& matrix) { - memcpy( mMatrix, matrix.mMatrix, NUM_BYTES_IN_MATRIX ); + memcpy(mMatrix, matrix.mMatrix, NUM_BYTES_IN_MATRIX); } -Matrix& Matrix::operator=( Matrix&& matrix ) +Matrix& Matrix::operator=(Matrix&& matrix) { - if( this != &matrix ) + if(this != &matrix) { - memcpy( mMatrix, matrix.mMatrix, NUM_BYTES_IN_MATRIX ); + memcpy(mMatrix, matrix.mMatrix, NUM_BYTES_IN_MATRIX); } return *this; } void Matrix::InvertTransform(Matrix& result) const { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,12); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 12); float* m1 = result.AsFloat(); - DALI_ASSERT_ALWAYS( EqualsZero( mMatrix[3] ) && EqualsZero( mMatrix[7] ) && EqualsZero( mMatrix[11] ) && Equals( mMatrix[15], 1.0f ) && "Must be a transform matrix" ); + DALI_ASSERT_ALWAYS(EqualsZero(mMatrix[3]) && EqualsZero(mMatrix[7]) && EqualsZero(mMatrix[11]) && Equals(mMatrix[15], 1.0f) && "Must be a transform matrix"); m1[0] = mMatrix[0]; m1[1] = mMatrix[4]; @@ -165,14 +169,14 @@ void Matrix::InvertTransform(Matrix& result) const m1[6] = mMatrix[9]; m1[7] = 0.0f; - m1[8] = mMatrix[2]; - m1[9] = mMatrix[6]; + m1[8] = mMatrix[2]; + m1[9] = mMatrix[6]; m1[10] = mMatrix[10]; m1[11] = 0.0f; - m1[12] = -( ( mMatrix[0] * mMatrix[12] ) + ( mMatrix[1] * mMatrix[13] ) + ( mMatrix[2] * mMatrix[14] ) + ( mMatrix[3] * mMatrix[15] ) ); - m1[13] = -( ( mMatrix[4] * mMatrix[12] ) + ( mMatrix[5] * mMatrix[13] ) + ( mMatrix[6] * mMatrix[14] ) + ( mMatrix[7] * mMatrix[15] ) ); - m1[14] = -( ( mMatrix[8] * mMatrix[12] ) + ( mMatrix[9] * mMatrix[13] ) + ( mMatrix[10] * mMatrix[14] ) + ( mMatrix[11] * mMatrix[15] ) ); + m1[12] = -((mMatrix[0] * mMatrix[12]) + (mMatrix[1] * mMatrix[13]) + (mMatrix[2] * mMatrix[14]) + (mMatrix[3] * mMatrix[15])); + m1[13] = -((mMatrix[4] * mMatrix[12]) + (mMatrix[5] * mMatrix[13]) + (mMatrix[6] * mMatrix[14]) + (mMatrix[7] * mMatrix[15])); + m1[14] = -((mMatrix[8] * mMatrix[12]) + (mMatrix[9] * mMatrix[13]) + (mMatrix[10] * mMatrix[14]) + (mMatrix[11] * mMatrix[15])); m1[15] = 1.0f; } @@ -180,36 +184,36 @@ static bool InvertMatrix(const float* m, float* out) { float inv[16]; - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,192); // 12 x 16 multiples - - inv[0] = m[5]*m[10]*m[15] - m[5]*m[11]*m[14] - m[9]*m[6]*m[15] + m[9]*m[7]*m[14] + m[13]*m[6]*m[11] - m[13]*m[7]*m[10]; - inv[4] = -m[4]*m[10]*m[15] + m[4]*m[11]*m[14] + m[8]*m[6]*m[15] - m[8]*m[7]*m[14] - m[12]*m[6]*m[11] + m[12]*m[7]*m[10]; - inv[8] = m[4]*m[9]*m[15] - m[4]*m[11]*m[13] - m[8]*m[5]*m[15] + m[8]*m[7]*m[13] + m[12]*m[5]*m[11] - m[12]*m[7]*m[9]; - inv[12] = -m[4]*m[9]*m[14] + m[4]*m[10]*m[13] + m[8]*m[5]*m[14] - m[8]*m[6]*m[13] - m[12]*m[5]*m[10] + m[12]*m[6]*m[9]; - inv[1] = -m[1]*m[10]*m[15] + m[1]*m[11]*m[14] + m[9]*m[2]*m[15] - m[9]*m[3]*m[14] - m[13]*m[2]*m[11] + m[13]*m[3]*m[10]; - inv[5] = m[0]*m[10]*m[15] - m[0]*m[11]*m[14] - m[8]*m[2]*m[15] + m[8]*m[3]*m[14] + m[12]*m[2]*m[11] - m[12]*m[3]*m[10]; - inv[9] = -m[0]*m[9]*m[15] + m[0]*m[11]*m[13] + m[8]*m[1]*m[15] - m[8]*m[3]*m[13] - m[12]*m[1]*m[11] + m[12]*m[3]*m[9]; - inv[13] = m[0]*m[9]*m[14] - m[0]*m[10]*m[13] - m[8]*m[1]*m[14] + m[8]*m[2]*m[13] + m[12]*m[1]*m[10] - m[12]*m[2]*m[9]; - inv[2] = m[1]*m[6]*m[15] - m[1]*m[7]*m[14] - m[5]*m[2]*m[15] + m[5]*m[3]*m[14] + m[13]*m[2]*m[7] - m[13]*m[3]*m[6]; - inv[6] = -m[0]*m[6]*m[15] + m[0]*m[7]*m[14] + m[4]*m[2]*m[15] - m[4]*m[3]*m[14] - m[12]*m[2]*m[7] + m[12]*m[3]*m[6]; - inv[10] = m[0]*m[5]*m[15] - m[0]*m[7]*m[13] - m[4]*m[1]*m[15] + m[4]*m[3]*m[13] + m[12]*m[1]*m[7] - m[12]*m[3]*m[5]; - inv[14] = -m[0]*m[5]*m[14] + m[0]*m[6]*m[13] + m[4]*m[1]*m[14] - m[4]*m[2]*m[13] - m[12]*m[1]*m[6] + m[12]*m[2]*m[5]; - inv[3] = -m[1]*m[6]*m[11] + m[1]*m[7]*m[10] + m[5]*m[2]*m[11] - m[5]*m[3]*m[10] - m[9]*m[2]*m[7] + m[9]*m[3]*m[6]; - inv[7] = m[0]*m[6]*m[11] - m[0]*m[7]*m[10] - m[4]*m[2]*m[11] + m[4]*m[3]*m[10] + m[8]*m[2]*m[7] - m[8]*m[3]*m[6]; - inv[11] = -m[0]*m[5]*m[11] + m[0]*m[7]*m[9] + m[4]*m[1]*m[11] - m[4]*m[3]*m[9] - m[8]*m[1]*m[7] + m[8]*m[3]*m[5]; - inv[15] = m[0]*m[5]*m[10] - m[0]*m[6]*m[9] - m[4]*m[1]*m[10] + m[4]*m[2]*m[9] + m[8]*m[1]*m[6] - m[8]*m[2]*m[5]; - - float det = m[0]*inv[0] + m[1]*inv[4] + m[2]*inv[8] + m[3]*inv[12]; + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 192); // 12 x 16 multiples + + inv[0] = m[5] * m[10] * m[15] - m[5] * m[11] * m[14] - m[9] * m[6] * m[15] + m[9] * m[7] * m[14] + m[13] * m[6] * m[11] - m[13] * m[7] * m[10]; + inv[4] = -m[4] * m[10] * m[15] + m[4] * m[11] * m[14] + m[8] * m[6] * m[15] - m[8] * m[7] * m[14] - m[12] * m[6] * m[11] + m[12] * m[7] * m[10]; + inv[8] = m[4] * m[9] * m[15] - m[4] * m[11] * m[13] - m[8] * m[5] * m[15] + m[8] * m[7] * m[13] + m[12] * m[5] * m[11] - m[12] * m[7] * m[9]; + inv[12] = -m[4] * m[9] * m[14] + m[4] * m[10] * m[13] + m[8] * m[5] * m[14] - m[8] * m[6] * m[13] - m[12] * m[5] * m[10] + m[12] * m[6] * m[9]; + inv[1] = -m[1] * m[10] * m[15] + m[1] * m[11] * m[14] + m[9] * m[2] * m[15] - m[9] * m[3] * m[14] - m[13] * m[2] * m[11] + m[13] * m[3] * m[10]; + inv[5] = m[0] * m[10] * m[15] - m[0] * m[11] * m[14] - m[8] * m[2] * m[15] + m[8] * m[3] * m[14] + m[12] * m[2] * m[11] - m[12] * m[3] * m[10]; + inv[9] = -m[0] * m[9] * m[15] + m[0] * m[11] * m[13] + m[8] * m[1] * m[15] - m[8] * m[3] * m[13] - m[12] * m[1] * m[11] + m[12] * m[3] * m[9]; + inv[13] = m[0] * m[9] * m[14] - m[0] * m[10] * m[13] - m[8] * m[1] * m[14] + m[8] * m[2] * m[13] + m[12] * m[1] * m[10] - m[12] * m[2] * m[9]; + inv[2] = m[1] * m[6] * m[15] - m[1] * m[7] * m[14] - m[5] * m[2] * m[15] + m[5] * m[3] * m[14] + m[13] * m[2] * m[7] - m[13] * m[3] * m[6]; + inv[6] = -m[0] * m[6] * m[15] + m[0] * m[7] * m[14] + m[4] * m[2] * m[15] - m[4] * m[3] * m[14] - m[12] * m[2] * m[7] + m[12] * m[3] * m[6]; + inv[10] = m[0] * m[5] * m[15] - m[0] * m[7] * m[13] - m[4] * m[1] * m[15] + m[4] * m[3] * m[13] + m[12] * m[1] * m[7] - m[12] * m[3] * m[5]; + inv[14] = -m[0] * m[5] * m[14] + m[0] * m[6] * m[13] + m[4] * m[1] * m[14] - m[4] * m[2] * m[13] - m[12] * m[1] * m[6] + m[12] * m[2] * m[5]; + inv[3] = -m[1] * m[6] * m[11] + m[1] * m[7] * m[10] + m[5] * m[2] * m[11] - m[5] * m[3] * m[10] - m[9] * m[2] * m[7] + m[9] * m[3] * m[6]; + inv[7] = m[0] * m[6] * m[11] - m[0] * m[7] * m[10] - m[4] * m[2] * m[11] + m[4] * m[3] * m[10] + m[8] * m[2] * m[7] - m[8] * m[3] * m[6]; + inv[11] = -m[0] * m[5] * m[11] + m[0] * m[7] * m[9] + m[4] * m[1] * m[11] - m[4] * m[3] * m[9] - m[8] * m[1] * m[7] + m[8] * m[3] * m[5]; + inv[15] = m[0] * m[5] * m[10] - m[0] * m[6] * m[9] - m[4] * m[1] * m[10] + m[4] * m[2] * m[9] + m[8] * m[1] * m[6] - m[8] * m[2] * m[5]; + + float det = m[0] * inv[0] + m[1] * inv[4] + m[2] * inv[8] + m[3] * inv[12]; // In the case where the determinant is exactly zero, the matrix is non-invertible - if ( EqualsZero( det ) ) + if(EqualsZero(det)) { return false; } det = 1.0f / det; - for( int32_t i = 0; i < 16; i++) + for(int32_t i = 0; i < 16; i++) { out[i] = inv[i] * det; } @@ -230,36 +234,36 @@ void Matrix::Transpose() mMatrix[1] = mMatrix[4]; mMatrix[4] = temp; - temp = mMatrix[2]; + temp = mMatrix[2]; mMatrix[2] = mMatrix[8]; mMatrix[8] = temp; - temp = mMatrix[3]; - mMatrix[3] = mMatrix[12]; + temp = mMatrix[3]; + mMatrix[3] = mMatrix[12]; mMatrix[12] = temp; - temp = mMatrix[6]; + temp = mMatrix[6]; mMatrix[6] = mMatrix[9]; mMatrix[9] = temp; - temp = mMatrix[7]; - mMatrix[7] = mMatrix[13]; + temp = mMatrix[7]; + mMatrix[7] = mMatrix[13]; mMatrix[13] = temp; - temp = mMatrix[11]; + temp = mMatrix[11]; mMatrix[11] = mMatrix[14]; mMatrix[14] = temp; } void Matrix::SetIdentity() { - memcpy( mMatrix, identityArray, NUM_BYTES_IN_MATRIX ); + memcpy(mMatrix, identityArray, NUM_BYTES_IN_MATRIX); } -void Matrix::SetIdentityAndScale( const Vector3& scale ) +void Matrix::SetIdentityAndScale(const Vector3& scale) { // initialize to zeros - memset( mMatrix, 0, NUM_BYTES_IN_MATRIX ); + memset(mMatrix, 0, NUM_BYTES_IN_MATRIX); // just apply scale on the diagonal mMatrix[0] = scale.x; @@ -270,40 +274,41 @@ void Matrix::SetIdentityAndScale( const Vector3& scale ) void Matrix::SetTranslation(const Vector4& translation) { - memcpy( mMatrix + ROW3_OFFSET, &translation, NUM_BYTES_IN_ROW ); + memcpy(mMatrix + ROW3_OFFSET, &translation, NUM_BYTES_IN_ROW); } void Matrix::SetTranslation(const Vector3& other) { - memcpy( mMatrix + ROW3_OFFSET, &other, NUM_BYTES_IN_ROW_OF_3 ); + memcpy(mMatrix + ROW3_OFFSET, &other, NUM_BYTES_IN_ROW_OF_3); mMatrix[15] = 1.0f; } -void Matrix::Multiply( Matrix& result, const Matrix& lhs, const Matrix& rhs ) +void Matrix::Multiply(Matrix& result, const Matrix& lhs, const Matrix& rhs) { MATH_INCREASE_COUNTER(PerformanceMonitor::MATRIX_MULTIPLYS); - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,64); // 64 = 16*4 + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 64); // 64 = 16*4 - float* temp = result.AsFloat(); - const float* rhsPtr = rhs.AsFloat(); + float* temp = result.AsFloat(); + const float* rhsPtr = rhs.AsFloat(); const float* lhsPtr = lhs.AsFloat(); -#ifndef __ARM_NEON__ +#ifndef __ARM_NEON__ - for( int32_t i=0; i < 4; i++ ) + for(int32_t i = 0; i < 4; i++) { // i<<2 gives the first vector / column - int32_t loc = i<<2; - int32_t loc1 = loc + 1; - int32_t loc2 = loc + 2; - int32_t loc3 = loc + 3; - float value0 = lhsPtr[loc]; - float value1 = lhsPtr[loc1]; - float value2 = lhsPtr[loc2]; - float value3 = lhsPtr[loc3]; - temp[loc] = (value0 * rhsPtr[0]) + - (value1 * rhsPtr[4]) + - (value2 * rhsPtr[8]) + - (value3 * rhsPtr[12]); + int32_t loc = i << 2; + int32_t loc1 = loc + 1; + int32_t loc2 = loc + 2; + int32_t loc3 = loc + 3; + float value0 = lhsPtr[loc]; + float value1 = lhsPtr[loc1]; + float value2 = lhsPtr[loc2]; + float value3 = lhsPtr[loc3]; + + temp[loc] = (value0 * rhsPtr[0]) + + (value1 * rhsPtr[4]) + + (value2 * rhsPtr[8]) + + (value3 * rhsPtr[12]); temp[loc1] = (value0 * rhsPtr[1]) + (value1 * rhsPtr[5]) + @@ -312,12 +317,12 @@ void Matrix::Multiply( Matrix& result, const Matrix& lhs, const Matrix& rhs ) temp[loc2] = (value0 * rhsPtr[2]) + (value1 * rhsPtr[6]) + - (value2 * rhsPtr[10])+ + (value2 * rhsPtr[10]) + (value3 * rhsPtr[14]); temp[loc3] = (value0 * rhsPtr[3]) + (value1 * rhsPtr[7]) + - (value2 * rhsPtr[11])+ + (value2 * rhsPtr[11]) + (value3 * rhsPtr[15]); } @@ -330,66 +335,68 @@ void Matrix::Multiply( Matrix& result, const Matrix& lhs, const Matrix& rhs ) // e.g. q0 = d0 and d1 // load and stores interleaved as NEON can load and store while calculating - asm volatile ( "VLDM %1, {q0-q3} \n\t" // load matrix 1 (lhsPtr) q[0..q3] - "VLDM %0, {q8-q11} \n\t" // load matrix 2 (rhsPtr) q[q8-q11] - "VMUL.F32 q12, q8, d0[0] \n\t" // column 0 = rhsPtr[0..3] * lhsPtr[0..3] - "VMUL.F32 q13, q8, d2[0] \n\t" // column 1 = rhsPtr[0..3] * lhsPtr[4..7] - "VMUL.F32 q14, q8, d4[0] \n\t" // column 2 = rhsPtr[0..3] * lhsPtr[8..11] - "VMUL.F32 q15, q8, d6[0] \n\t" // column 3 = rhsPtr[0..3] * lhsPtr[12..15] - - "VMLA.F32 q12, q9, d0[1] \n\t" // column 0 += rhsPtr[4..7] * lhsPtr[0..3] - "VMLA.F32 q13, q9, d2[1] \n\t" // column 1 += rhsPtr[4..7] * lhsPtr[4..7] - "VMLA.F32 q14, q9, d4[1] \n\t" // column 2 += rhsPtr[4..7] * lhsPtr[8..11] - "VMLA.F32 q15, q9, d6[1] \n\t" // column 3 += rhsPtr[4..7] * lhsPtr[12..15] - - "VMLA.F32 q12, q10, d1[0] \n\t" // column 0 += rhsPtr[8..11] * lhsPtr[0..3] - "VMLA.F32 q13, q10, d3[0] \n\t" // column 1 += rhsPtr[8..11] * lhsPtr[4..7] - "VMLA.F32 q14, q10, d5[0] \n\t" // column 2 += rhsPtr[8..11] * lhsPtr[8..11] - "VMLA.F32 q15, q10, d7[0] \n\t" // column 3 += rhsPtr[8..11] * lhsPtr[12..15] - - "VMLA.F32 q12, q11, d1[1] \n\t" // column 0 += rhsPtr[12..15] * lhsPtr[0..3] - "VMLA.F32 q13, q11, d3[1] \n\t" // column 1 += rhsPtr[12..15] * lhsPtr[4..7] - "VMLA.F32 q14, q11, d5[1] \n\t" // column 2 += rhsPtr[12..15] * lhsPtr[8..11] - "VMLA.F32 q15, q11, d7[1] \n\t" // column 3 += rhsPtr[12..15] * lhsPtr[12..15] - "VSTM %2, {q12-q15} \n\t" // store entire output matrix. - : "+r"(rhsPtr), "+r"(lhsPtr), "+r"(temp) - : - : "q0", "q1", "q2", "q3", "q8", "q9", "q10", "q11", "q12", "q13", "q14", "q15", "memory" ); + asm volatile( + "VLDM %1, {q0-q3} \n\t" // load matrix 1 (lhsPtr) q[0..q3] + "VLDM %0, {q8-q11} \n\t" // load matrix 2 (rhsPtr) q[q8-q11] + "VMUL.F32 q12, q8, d0[0] \n\t" // column 0 = rhsPtr[0..3] * lhsPtr[0..3] + "VMUL.F32 q13, q8, d2[0] \n\t" // column 1 = rhsPtr[0..3] * lhsPtr[4..7] + "VMUL.F32 q14, q8, d4[0] \n\t" // column 2 = rhsPtr[0..3] * lhsPtr[8..11] + "VMUL.F32 q15, q8, d6[0] \n\t" // column 3 = rhsPtr[0..3] * lhsPtr[12..15] + + "VMLA.F32 q12, q9, d0[1] \n\t" // column 0 += rhsPtr[4..7] * lhsPtr[0..3] + "VMLA.F32 q13, q9, d2[1] \n\t" // column 1 += rhsPtr[4..7] * lhsPtr[4..7] + "VMLA.F32 q14, q9, d4[1] \n\t" // column 2 += rhsPtr[4..7] * lhsPtr[8..11] + "VMLA.F32 q15, q9, d6[1] \n\t" // column 3 += rhsPtr[4..7] * lhsPtr[12..15] + + "VMLA.F32 q12, q10, d1[0] \n\t" // column 0 += rhsPtr[8..11] * lhsPtr[0..3] + "VMLA.F32 q13, q10, d3[0] \n\t" // column 1 += rhsPtr[8..11] * lhsPtr[4..7] + "VMLA.F32 q14, q10, d5[0] \n\t" // column 2 += rhsPtr[8..11] * lhsPtr[8..11] + "VMLA.F32 q15, q10, d7[0] \n\t" // column 3 += rhsPtr[8..11] * lhsPtr[12..15] + + "VMLA.F32 q12, q11, d1[1] \n\t" // column 0 += rhsPtr[12..15] * lhsPtr[0..3] + "VMLA.F32 q13, q11, d3[1] \n\t" // column 1 += rhsPtr[12..15] * lhsPtr[4..7] + "VMLA.F32 q14, q11, d5[1] \n\t" // column 2 += rhsPtr[12..15] * lhsPtr[8..11] + "VMLA.F32 q15, q11, d7[1] \n\t" // column 3 += rhsPtr[12..15] * lhsPtr[12..15] + "VSTM %2, {q12-q15} \n\t" // store entire output matrix. + : "+r"(rhsPtr), "+r"(lhsPtr), "+r"(temp) + : + : "q0", "q1", "q2", "q3", "q8", "q9", "q10", "q11", "q12", "q13", "q14", "q15", "memory"); #endif } -void Matrix::Multiply( Matrix& result, const Matrix& lhs, const Quaternion& rhs ) +void Matrix::Multiply(Matrix& result, const Matrix& lhs, const Quaternion& rhs) { MATH_INCREASE_COUNTER(PerformanceMonitor::MATRIX_MULTIPLYS); - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,54); // 54 = 36+18 + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 54); // 54 = 36+18 - float matrix[16]; + float matrix[16]; float* rhsPtr = &matrix[0]; - Convert( rhsPtr, rhs ); + Convert(rhsPtr, rhs); // quaternion contains just rotation so it really only needs 3x3 matrix - float* temp = result.AsFloat(); + float* temp = result.AsFloat(); const float* lhsPtr = lhs.AsFloat(); -#ifndef __ARM_NEON__ +#ifndef __ARM_NEON__ - for( int32_t i=0; i < 4; i++ ) + for(int32_t i = 0; i < 4; i++) { // i<<2 gives the first vector / column - int32_t loc = i<<2; - int32_t loc1 = loc + 1; - int32_t loc2 = loc + 2; - int32_t loc3 = loc + 3; - float value0 = lhsPtr[loc]; - float value1 = lhsPtr[loc1]; - float value2 = lhsPtr[loc2]; - float value3 = lhsPtr[loc3]; - temp[loc] = (value0 * rhsPtr[0]) + - (value1 * rhsPtr[4]) + - (value2 * rhsPtr[8]) + - (0.0f); //value3 * rhsPtr[12] is 0.0f + int32_t loc = i << 2; + int32_t loc1 = loc + 1; + int32_t loc2 = loc + 2; + int32_t loc3 = loc + 3; + float value0 = lhsPtr[loc]; + float value1 = lhsPtr[loc1]; + float value2 = lhsPtr[loc2]; + float value3 = lhsPtr[loc3]; + + temp[loc] = (value0 * rhsPtr[0]) + + (value1 * rhsPtr[4]) + + (value2 * rhsPtr[8]) + + (0.0f); //value3 * rhsPtr[12] is 0.0f temp[loc1] = (value0 * rhsPtr[1]) + (value1 * rhsPtr[5]) + @@ -398,12 +405,12 @@ void Matrix::Multiply( Matrix& result, const Matrix& lhs, const Quaternion& rhs temp[loc2] = (value0 * rhsPtr[2]) + (value1 * rhsPtr[6]) + - (value2 * rhsPtr[10])+ + (value2 * rhsPtr[10]) + (0.0f); //value3 * rhsPtr[14] is 0.0f - temp[loc3] = (0.0f) + //value0 * rhsPtr[3] is 0.0f - (0.0f) + //value1 * rhsPtr[7] is 0.0f - (0.0f) + //value2 * rhsPtr[11] is 0.0f + temp[loc3] = (0.0f) + //value0 * rhsPtr[3] is 0.0f + (0.0f) + //value1 * rhsPtr[7] is 0.0f + (0.0f) + //value2 * rhsPtr[11] is 0.0f (value3); // rhsPtr[15] is 1.0f } @@ -415,43 +422,44 @@ void Matrix::Multiply( Matrix& result, const Matrix& lhs, const Quaternion& rhs // q =128 bit quad-word q0 -q15 (enough to handle a column of 4 floats in a matrix) // e.g. q0 = d0 and d1 // load and stores interleaved as NEON can load and store while calculating - asm volatile ( "VLDM %1, {q4-q6} \n\t" // load matrix 1 (lhsPtr) - "VLD1.F32 {q7}, [%2]! \n\t" // load matrix 2 (rhsPtr) [0..3] - "VMUL.F32 q0, q7, d8[0] \n\t" // column 0 = rhsPtr[0..3] * lhsPtr[0..3] - "VMUL.F32 q1, q7, d10[0] \n\t" // column 1 = rhsPtr[0..3] * lhsPtr[4..7] - "VMUL.F32 q2, q7, d12[0] \n\t" // column 2 = rhsPtr[0..3] * lhsPtr[8..11] - "VLD1.F32 {q7}, [%2]! \n\t" // load matrix 2 (rhsPtr) [4..7] - "VMLA.F32 q0, q7, d8[1] \n\t" // column 0+= rhsPtr[4..7] * lhsPtr[0..3] - "VMLA.F32 q1, q7, d10[1] \n\t" // column 1+= rhsPtr[4..7] * lhsPtr[4..7] - "VMLA.F32 q2, q7, d12[1] \n\t" // column 2+= rhsPtr[4..7] * lhsPtr[8..11] - "VLD1.F32 {q7}, [%2]! \n\t" // load matrix 2 (rhsPtr) [8..11] - "VMLA.F32 q0, q7, d9[0] \n\t" // column 0+= rhsPtr[8..11] * lhsPtr[0..3] - "VMLA.F32 q1, q7, d11[0] \n\t" // column 1+= rhsPtr[8..11] * lhsPtr[4..7] - "VMLA.F32 q2, q7, d13[0] \n\t" // column 2+= rhsPtr[8..11] * lhsPtr[8..11] - "VSTM %0, {q0-q2} \n\t" // store entire output matrix. - : - : "r"(temp), "r"(lhsPtr), "r" (rhsPtr) - : "%r0", "%q0", "%q1", "%q2", "%q4", "%q5", "%q6", "%q7", "memory" ); - - temp[ 12 ] = 0.0f; - temp[ 13 ] = 0.0f; - temp[ 14 ] = 0.0f; - temp[ 15 ] = 1.0f; + asm volatile( + "VLDM %1, {q4-q6} \n\t" // load matrix 1 (lhsPtr) + "VLD1.F32 {q7}, [%2]! \n\t" // load matrix 2 (rhsPtr) [0..3] + "VMUL.F32 q0, q7, d8[0] \n\t" // column 0 = rhsPtr[0..3] * lhsPtr[0..3] + "VMUL.F32 q1, q7, d10[0] \n\t" // column 1 = rhsPtr[0..3] * lhsPtr[4..7] + "VMUL.F32 q2, q7, d12[0] \n\t" // column 2 = rhsPtr[0..3] * lhsPtr[8..11] + "VLD1.F32 {q7}, [%2]! \n\t" // load matrix 2 (rhsPtr) [4..7] + "VMLA.F32 q0, q7, d8[1] \n\t" // column 0+= rhsPtr[4..7] * lhsPtr[0..3] + "VMLA.F32 q1, q7, d10[1] \n\t" // column 1+= rhsPtr[4..7] * lhsPtr[4..7] + "VMLA.F32 q2, q7, d12[1] \n\t" // column 2+= rhsPtr[4..7] * lhsPtr[8..11] + "VLD1.F32 {q7}, [%2]! \n\t" // load matrix 2 (rhsPtr) [8..11] + "VMLA.F32 q0, q7, d9[0] \n\t" // column 0+= rhsPtr[8..11] * lhsPtr[0..3] + "VMLA.F32 q1, q7, d11[0] \n\t" // column 1+= rhsPtr[8..11] * lhsPtr[4..7] + "VMLA.F32 q2, q7, d13[0] \n\t" // column 2+= rhsPtr[8..11] * lhsPtr[8..11] + "VSTM %0, {q0-q2} \n\t" // store entire output matrix. + : + : "r"(temp), "r"(lhsPtr), "r"(rhsPtr) + : "%r0", "%q0", "%q1", "%q2", "%q4", "%q5", "%q6", "%q7", "memory"); + + temp[12] = 0.0f; + temp[13] = 0.0f; + temp[14] = 0.0f; + temp[15] = 1.0f; #endif } Vector4 Matrix::operator*(const Vector4& rhs) const { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,16); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 16); Vector4 temp; -#ifndef __ARM_NEON__ +#ifndef __ARM_NEON__ - temp.x = rhs.x * mMatrix[0] + rhs.y * mMatrix[4] + rhs.z * mMatrix[8] + rhs.w * mMatrix[12]; - temp.y = rhs.x * mMatrix[1] + rhs.y * mMatrix[5] + rhs.z * mMatrix[9] + rhs.w * mMatrix[13]; - temp.z = rhs.x * mMatrix[2] + rhs.y * mMatrix[6] + rhs.z * mMatrix[10] + rhs.w * mMatrix[14]; - temp.w = rhs.x * mMatrix[3] + rhs.y * mMatrix[7] + rhs.z * mMatrix[11] + rhs.w * mMatrix[15]; + temp.x = rhs.x * mMatrix[0] + rhs.y * mMatrix[4] + rhs.z * mMatrix[8] + rhs.w * mMatrix[12]; + temp.y = rhs.x * mMatrix[1] + rhs.y * mMatrix[5] + rhs.z * mMatrix[9] + rhs.w * mMatrix[13]; + temp.z = rhs.x * mMatrix[2] + rhs.y * mMatrix[6] + rhs.z * mMatrix[10] + rhs.w * mMatrix[14]; + temp.w = rhs.x * mMatrix[3] + rhs.y * mMatrix[7] + rhs.z * mMatrix[11] + rhs.w * mMatrix[15]; #else @@ -461,20 +469,21 @@ Vector4 Matrix::operator*(const Vector4& rhs) const // q =128 bit quad-word q0 -q15 (enough to handle a column of 4 floats in a matrix) // e.g. q0 = d0 and d1 // load and stores interleaved as NEON can load and store while calculating - asm volatile ( "VLD1.F32 {q0}, [%1] \n\t" //q0 = rhs - "VLD1.F32 {q9}, [%0]! \n\t" - "VMUL.F32 q10, q9, d0[0] \n\t" - "VLD1.F32 {q9}, [%0]! \n\t" - "VMLA.F32 q10, q9, d0[1] \n\t" //q10 = mMatrix[0..3] * rhs + mMatrix[4..7] * rhs - "VLD1.F32 {q9}, [%0]! \n\t" - "VMUL.F32 q11, q9, d1[0] \n\t" - "VLD1.F32 {q9}, [%0]! \n\t" - "VMLA.F32 q11, q9, d1[1] \n\t" //q11 = mMatrix[8..11] * rhs + mMatrix[12..15] * rhs - "VADD.F32 q10, q10, q11 \n\t" - "VST1.F32 {q10},[%2] \n\t" //temp = q10 + q11 - : - : "r"(mMatrix), "r"(&rhs), "r"(&temp) - : "q0", "q9", "q10", "q11", "memory" ); + asm volatile( + "VLD1.F32 {q0}, [%1] \n\t" //q0 = rhs + "VLD1.F32 {q9}, [%0]! \n\t" + "VMUL.F32 q10, q9, d0[0] \n\t" + "VLD1.F32 {q9}, [%0]! \n\t" + "VMLA.F32 q10, q9, d0[1] \n\t" //q10 = mMatrix[0..3] * rhs + mMatrix[4..7] * rhs + "VLD1.F32 {q9}, [%0]! \n\t" + "VMUL.F32 q11, q9, d1[0] \n\t" + "VLD1.F32 {q9}, [%0]! \n\t" + "VMLA.F32 q11, q9, d1[1] \n\t" //q11 = mMatrix[8..11] * rhs + mMatrix[12..15] * rhs + "VADD.F32 q10, q10, q11 \n\t" + "VST1.F32 {q10},[%2] \n\t" //temp = q10 + q11 + : + : "r"(mMatrix), "r"(&rhs), "r"(&temp) + : "q0", "q9", "q10", "q11", "memory"); #endif return temp; } @@ -482,27 +491,27 @@ Vector4 Matrix::operator*(const Vector4& rhs) const bool Matrix::operator==(const Matrix& rhs) const { return ( - ( fabsf( mMatrix[0] - rhs.mMatrix[0] ) <= GetRangedEpsilon( mMatrix[0], rhs.mMatrix[0] ) ) && - ( fabsf( mMatrix[1] - rhs.mMatrix[1] ) <= GetRangedEpsilon( mMatrix[1], rhs.mMatrix[1] ) ) && - ( fabsf( mMatrix[2] - rhs.mMatrix[2] ) <= GetRangedEpsilon( mMatrix[2], rhs.mMatrix[2] ) ) && - ( fabsf( mMatrix[3] - rhs.mMatrix[3] ) <= GetRangedEpsilon( mMatrix[3], rhs.mMatrix[3] ) ) && - ( fabsf( mMatrix[4] - rhs.mMatrix[4] ) <= GetRangedEpsilon( mMatrix[4], rhs.mMatrix[4] ) ) && - ( fabsf( mMatrix[5] - rhs.mMatrix[5] ) <= GetRangedEpsilon( mMatrix[5], rhs.mMatrix[5] ) ) && - ( fabsf( mMatrix[6] - rhs.mMatrix[6] ) <= GetRangedEpsilon( mMatrix[6], rhs.mMatrix[6] ) ) && - ( fabsf( mMatrix[7] - rhs.mMatrix[7] ) <= GetRangedEpsilon( mMatrix[7], rhs.mMatrix[7] ) ) && - ( fabsf( mMatrix[8] - rhs.mMatrix[8] ) <= GetRangedEpsilon( mMatrix[8], rhs.mMatrix[8] ) ) && - ( fabsf( mMatrix[9] - rhs.mMatrix[9] ) <= GetRangedEpsilon( mMatrix[9], rhs.mMatrix[9] ) ) && - ( fabsf( mMatrix[10] - rhs.mMatrix[10] ) <= GetRangedEpsilon( mMatrix[10], rhs.mMatrix[10] ) ) && - ( fabsf( mMatrix[11] - rhs.mMatrix[11] ) <= GetRangedEpsilon( mMatrix[11], rhs.mMatrix[11] ) ) && - ( fabsf( mMatrix[12] - rhs.mMatrix[12] ) <= GetRangedEpsilon( mMatrix[12], rhs.mMatrix[12] ) ) && - ( fabsf( mMatrix[13] - rhs.mMatrix[13] ) <= GetRangedEpsilon( mMatrix[13], rhs.mMatrix[13] ) ) && - ( fabsf( mMatrix[14] - rhs.mMatrix[14] ) <= GetRangedEpsilon( mMatrix[14], rhs.mMatrix[14] ) ) && - ( fabsf( mMatrix[15] - rhs.mMatrix[15] ) <= GetRangedEpsilon( mMatrix[15], rhs.mMatrix[15] ) ) ); + (fabsf(mMatrix[0] - rhs.mMatrix[0]) <= GetRangedEpsilon(mMatrix[0], rhs.mMatrix[0])) && + (fabsf(mMatrix[1] - rhs.mMatrix[1]) <= GetRangedEpsilon(mMatrix[1], rhs.mMatrix[1])) && + (fabsf(mMatrix[2] - rhs.mMatrix[2]) <= GetRangedEpsilon(mMatrix[2], rhs.mMatrix[2])) && + (fabsf(mMatrix[3] - rhs.mMatrix[3]) <= GetRangedEpsilon(mMatrix[3], rhs.mMatrix[3])) && + (fabsf(mMatrix[4] - rhs.mMatrix[4]) <= GetRangedEpsilon(mMatrix[4], rhs.mMatrix[4])) && + (fabsf(mMatrix[5] - rhs.mMatrix[5]) <= GetRangedEpsilon(mMatrix[5], rhs.mMatrix[5])) && + (fabsf(mMatrix[6] - rhs.mMatrix[6]) <= GetRangedEpsilon(mMatrix[6], rhs.mMatrix[6])) && + (fabsf(mMatrix[7] - rhs.mMatrix[7]) <= GetRangedEpsilon(mMatrix[7], rhs.mMatrix[7])) && + (fabsf(mMatrix[8] - rhs.mMatrix[8]) <= GetRangedEpsilon(mMatrix[8], rhs.mMatrix[8])) && + (fabsf(mMatrix[9] - rhs.mMatrix[9]) <= GetRangedEpsilon(mMatrix[9], rhs.mMatrix[9])) && + (fabsf(mMatrix[10] - rhs.mMatrix[10]) <= GetRangedEpsilon(mMatrix[10], rhs.mMatrix[10])) && + (fabsf(mMatrix[11] - rhs.mMatrix[11]) <= GetRangedEpsilon(mMatrix[11], rhs.mMatrix[11])) && + (fabsf(mMatrix[12] - rhs.mMatrix[12]) <= GetRangedEpsilon(mMatrix[12], rhs.mMatrix[12])) && + (fabsf(mMatrix[13] - rhs.mMatrix[13]) <= GetRangedEpsilon(mMatrix[13], rhs.mMatrix[13])) && + (fabsf(mMatrix[14] - rhs.mMatrix[14]) <= GetRangedEpsilon(mMatrix[14], rhs.mMatrix[14])) && + (fabsf(mMatrix[15] - rhs.mMatrix[15]) <= GetRangedEpsilon(mMatrix[15], rhs.mMatrix[15]))); } bool Matrix::operator!=(const Matrix& rhs) const { - if (*this == rhs) + if(*this == rhs) { return false; } @@ -518,12 +527,12 @@ void Matrix::OrthoNormalize() vector0.Normalize(); vector1.Normalize(); - vector2 = vector0.Cross( vector1 ); - vector1 = vector2.Cross( vector0 ); + vector2 = vector0.Cross(vector1); + vector1 = vector2.Cross(vector0); - memcpy( mMatrix, &vector0, NUM_BYTES_IN_ROW ); - memcpy( mMatrix + ROW1_OFFSET, &vector1, NUM_BYTES_IN_ROW ); - memcpy( mMatrix + ROW2_OFFSET, &vector2, NUM_BYTES_IN_ROW ); + memcpy(mMatrix, &vector0, NUM_BYTES_IN_ROW); + memcpy(mMatrix + ROW1_OFFSET, &vector1, NUM_BYTES_IN_ROW); + memcpy(mMatrix + ROW2_OFFSET, &vector2, NUM_BYTES_IN_ROW); } Vector3 Matrix::GetXAxis() const @@ -557,16 +566,16 @@ void Matrix::SetYAxis(const Vector3& axis) void Matrix::SetZAxis(const Vector3& axis) { - mMatrix[8] = axis.x; - mMatrix[9] = axis.y; + mMatrix[8] = axis.x; + mMatrix[9] = axis.y; mMatrix[10] = axis.z; } void Matrix::SetTransformComponents(const Vector3& scale, const Quaternion& rotation, - const Vector3& translation ) + const Vector3& translation) { - if( rotation.IsIdentity() ) + if(rotation.IsIdentity()) { mMatrix[0] = scale.x; mMatrix[1] = 0.0f; @@ -578,15 +587,15 @@ void Matrix::SetTransformComponents(const Vector3& scale, mMatrix[6] = 0.0f; mMatrix[7] = 0.0f; - mMatrix[8] = 0.0f; - mMatrix[9] = 0.0f; - mMatrix[10]= scale.z; - mMatrix[11]= 0.0f; + mMatrix[8] = 0.0f; + mMatrix[9] = 0.0f; + mMatrix[10] = scale.z; + mMatrix[11] = 0.0f; } else { MATH_INCREASE_COUNTER(PerformanceMonitor::MATRIX_MULTIPLYS); - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,27); // 27 = 9+18 + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 27); // 27 = 9+18 const float xx = rotation.mVector.x * rotation.mVector.x; const float yy = rotation.mVector.y * rotation.mVector.y; @@ -599,19 +608,19 @@ void Matrix::SetTransformComponents(const Vector3& scale, const float yz = rotation.mVector.y * rotation.mVector.z; mMatrix[0] = (scale.x * (1.0f - 2.0f * (yy + zz))); - mMatrix[1] = (scale.x * ( 2.0f * (xy + wz))); - mMatrix[2] = (scale.x * ( 2.0f * (xz - wy))); + mMatrix[1] = (scale.x * (2.0f * (xy + wz))); + mMatrix[2] = (scale.x * (2.0f * (xz - wy))); mMatrix[3] = 0.0f; - mMatrix[4] = (scale.y * ( 2.0f * (xy - wz))); + mMatrix[4] = (scale.y * (2.0f * (xy - wz))); mMatrix[5] = (scale.y * (1.0f - 2.0f * (xx + zz))); - mMatrix[6] = (scale.y * ( 2.0f * (yz + wx))); + mMatrix[6] = (scale.y * (2.0f * (yz + wx))); mMatrix[7] = 0.0f; - mMatrix[8] = (scale.z * ( 2.0f * (xz + wy))); - mMatrix[9] = (scale.z * ( 2.0f * (yz - wx))); - mMatrix[10]= (scale.z * (1.0f - 2.0f * (xx + yy))); - mMatrix[11]= 0.0f; + mMatrix[8] = (scale.z * (2.0f * (xz + wy))); + mMatrix[9] = (scale.z * (2.0f * (yz - wx))); + mMatrix[10] = (scale.z * (1.0f - 2.0f * (xx + yy))); + mMatrix[11] = 0.0f; } // apply translation mMatrix[12] = translation.x; @@ -622,17 +631,17 @@ void Matrix::SetTransformComponents(const Vector3& scale, void Matrix::SetInverseTransformComponents(const Vector3& scale, const Quaternion& rotation, - const Vector3& translation ) + const Vector3& translation) { - Vector3 inverseTranslation = -translation; - Vector3 inverseScale( 1.0f/scale.x, 1.0f/scale.y, 1.0f/scale.z); + Vector3 inverseTranslation = -translation; + Vector3 inverseScale(1.0f / scale.x, 1.0f / scale.y, 1.0f / scale.z); Quaternion inverseRotation(rotation); - bool isRotated = ! inverseRotation.IsIdentity(); + bool isRotated = !inverseRotation.IsIdentity(); // Order of application is translation, rotation, scale. // Ensure translation is relative to scale & rotation: - if( isRotated ) + if(isRotated) { inverseRotation.Invert(); inverseTranslation = inverseRotation.Rotate(inverseTranslation); @@ -640,10 +649,10 @@ void Matrix::SetInverseTransformComponents(const Vector3& scale, inverseTranslation *= inverseScale; - if( isRotated ) + if(isRotated) { MATH_INCREASE_COUNTER(PerformanceMonitor::MATRIX_MULTIPLYS); - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,27); // 27 = 9+18 + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 27); // 27 = 9+18 const float xx = inverseRotation.mVector.x * inverseRotation.mVector.x; const float yy = inverseRotation.mVector.y * inverseRotation.mVector.y; @@ -665,10 +674,10 @@ void Matrix::SetInverseTransformComponents(const Vector3& scale, mMatrix[6] = (inverseScale.z * (2.0f * (yz + wx))); mMatrix[7] = 0.0f; - mMatrix[8] = (inverseScale.x * (2.0f * (xz + wy))); - mMatrix[9] = (inverseScale.y * (2.0f * (yz - wx))); - mMatrix[10]= (inverseScale.z * (1.0f - 2.0f * (xx + yy))); - mMatrix[11]= 0.0f; + mMatrix[8] = (inverseScale.x * (2.0f * (xz + wy))); + mMatrix[9] = (inverseScale.y * (2.0f * (yz - wx))); + mMatrix[10] = (inverseScale.z * (1.0f - 2.0f * (xx + yy))); + mMatrix[11] = 0.0f; } else { @@ -682,10 +691,10 @@ void Matrix::SetInverseTransformComponents(const Vector3& scale, mMatrix[6] = 0.0f; mMatrix[7] = 0.0f; - mMatrix[8] = 0.0f; - mMatrix[9] = 0.0f; - mMatrix[10]= inverseScale.z; - mMatrix[11]= 0.0f; + mMatrix[8] = 0.0f; + mMatrix[9] = 0.0f; + mMatrix[10] = inverseScale.z; + mMatrix[11] = 0.0f; } // apply translation @@ -695,25 +704,25 @@ void Matrix::SetInverseTransformComponents(const Vector3& scale, mMatrix[15] = 1.0f; } -void Matrix::SetInverseTransformComponents(const Vector3& xAxis, - const Vector3& yAxis, - const Vector3& zAxis, - const Vector3& translation ) +void Matrix::SetInverseTransformComponents(const Vector3& xAxis, + const Vector3& yAxis, + const Vector3& zAxis, + const Vector3& translation) { // x, y, z axis parameters represent a orthonormal basis with no scaling, i.e. a rotation matrix. // Invert rotation by transposing in place // Order of application is translation, rotation - mMatrix[0] = xAxis.x; - mMatrix[1] = yAxis.x; - mMatrix[2] = zAxis.x; - mMatrix[3] = 0.0f; + mMatrix[0] = xAxis.x; + mMatrix[1] = yAxis.x; + mMatrix[2] = zAxis.x; + mMatrix[3] = 0.0f; - mMatrix[4] = xAxis.y; - mMatrix[5] = yAxis.y; - mMatrix[6] = zAxis.y; - mMatrix[7] = 0.0f; + mMatrix[4] = xAxis.y; + mMatrix[5] = yAxis.y; + mMatrix[6] = zAxis.y; + mMatrix[7] = 0.0f; mMatrix[8] = xAxis.z; mMatrix[9] = yAxis.z; @@ -726,16 +735,15 @@ void Matrix::SetInverseTransformComponents(const Vector3& xAxis, // Ensure translation is relative to scale & rotation: - Vector4 inverseTranslation( -translation.x, -translation.y, -translation.z, 1.0f); - inverseTranslation = *this * inverseTranslation; // Rotate inverse translation + Vector4 inverseTranslation(-translation.x, -translation.y, -translation.z, 1.0f); + inverseTranslation = *this * inverseTranslation; // Rotate inverse translation inverseTranslation.w = 1.0f; SetTranslation(inverseTranslation); } - -void Matrix::GetTransformComponents(Vector3& position, - Quaternion& rotation, - Vector3& scale) const +void Matrix::GetTransformComponents(Vector3& position, + Quaternion& rotation, + Vector3& scale) const { position = GetTranslation3(); @@ -743,16 +751,16 @@ void Matrix::GetTransformComponents(Vector3& position, Vector3 theScale(GetXAxis().Length(), GetYAxis().Length(), GetZAxis().Length()); scale = theScale; - if( ! ( fabs(theScale.x - Vector3::ONE.x) < ROTATION_EPSILON && - fabs(theScale.y - Vector3::ONE.y) < ROTATION_EPSILON && - fabs(theScale.z - Vector3::ONE.z) < ROTATION_EPSILON ) ) + if(!(fabs(theScale.x - Vector3::ONE.x) < ROTATION_EPSILON && + fabs(theScale.y - Vector3::ONE.y) < ROTATION_EPSILON && + fabs(theScale.z - Vector3::ONE.z) < ROTATION_EPSILON)) { MATH_INCREASE_COUNTER(PerformanceMonitor::MATRIX_MULTIPLYS); - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,9); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 9); // Non-identity scale is embedded into rotation matrix. Remove it first: - Matrix m(*this); - Vector3 inverseScale(1.0f/theScale.x, 1.0f/theScale.y, 1.0f/theScale.z); + Matrix m(*this); + Vector3 inverseScale(1.0f / theScale.x, 1.0f / theScale.y, 1.0f / theScale.z); m.mMatrix[0] *= inverseScale.x; m.mMatrix[1] *= inverseScale.x; m.mMatrix[2] *= inverseScale.x; @@ -766,9 +774,9 @@ void Matrix::GetTransformComponents(Vector3& position, Quaternion theRotation(m); // If the imaginary components are close to zero, then use null quaternion instead. - if( fabs(theRotation.mVector.x) < ROTATION_EPSILON && - fabs(theRotation.mVector.y) < ROTATION_EPSILON && - fabs(theRotation.mVector.z) < ROTATION_EPSILON ) + if(fabs(theRotation.mVector.x) < ROTATION_EPSILON && + fabs(theRotation.mVector.y) < ROTATION_EPSILON && + fabs(theRotation.mVector.z) < ROTATION_EPSILON) { theRotation = Quaternion(); } @@ -779,9 +787,9 @@ void Matrix::GetTransformComponents(Vector3& position, Quaternion theRotation(*this); // If the imaginary components are close to zero, then use null quaternion instead. - if( fabs(theRotation.mVector.x) < ROTATION_EPSILON && - fabs(theRotation.mVector.y) < ROTATION_EPSILON && - fabs(theRotation.mVector.z) < ROTATION_EPSILON ) + if(fabs(theRotation.mVector.x) < ROTATION_EPSILON && + fabs(theRotation.mVector.y) < ROTATION_EPSILON && + fabs(theRotation.mVector.z) < ROTATION_EPSILON) { theRotation = Quaternion(); } @@ -789,14 +797,12 @@ void Matrix::GetTransformComponents(Vector3& position, } } - - -std::ostream& operator<< (std::ostream& o, const Matrix& matrix) +std::ostream& operator<<(std::ostream& o, const Matrix& matrix) { - return o << "[ " << matrix.mMatrix[0] << ", " << matrix.mMatrix[1] << ", " << matrix.mMatrix[2] << ", " << matrix.mMatrix[3] << ", " - << matrix.mMatrix[4] << ", " << matrix.mMatrix[5] << ", " << matrix.mMatrix[6] << ", " << matrix.mMatrix[7] << ", " - << matrix.mMatrix[8] << ", " << matrix.mMatrix[9] << ", " << matrix.mMatrix[10] << ", " << matrix.mMatrix[11] << ", " - << matrix.mMatrix[12] << ", " << matrix.mMatrix[13] << ", " << matrix.mMatrix[14] << ", " << matrix.mMatrix[15] << " ]"; + return o << "[ " << matrix.mMatrix[0] << ", " << matrix.mMatrix[1] << ", " << matrix.mMatrix[2] << ", " << matrix.mMatrix[3] << ", " + << matrix.mMatrix[4] << ", " << matrix.mMatrix[5] << ", " << matrix.mMatrix[6] << ", " << matrix.mMatrix[7] << ", " + << matrix.mMatrix[8] << ", " << matrix.mMatrix[9] << ", " << matrix.mMatrix[10] << ", " << matrix.mMatrix[11] << ", " + << matrix.mMatrix[12] << ", " << matrix.mMatrix[13] << ", " << matrix.mMatrix[14] << ", " << matrix.mMatrix[15] << " ]"; } } // namespace Dali diff --git a/dali/public-api/math/matrix.h b/dali/public-api/math/matrix.h old mode 100755 new mode 100644 index 80896f8..15b3181 --- a/dali/public-api/math/matrix.h +++ b/dali/public-api/math/matrix.h @@ -59,8 +59,7 @@ class Quaternion; class DALI_CORE_API Matrix { public: - - friend DALI_CORE_API std::ostream& operator<< (std::ostream& o, const Matrix& matrix); + friend DALI_CORE_API std::ostream& operator<<(std::ostream& o, const Matrix& matrix); /** * @brief Constructor. @@ -76,7 +75,7 @@ public: * @SINCE_1_0.0 * @param[in] initialize True for initialization by zero or otherwise */ - explicit Matrix( bool initialize ); + explicit Matrix(bool initialize); /** * @brief Constructor. @@ -99,7 +98,7 @@ public: * @SINCE_1_0.0 * @param rotation Rotation as quaternion */ - explicit Matrix( const Quaternion& rotation ); + explicit Matrix(const Quaternion& rotation); /** * @brief Copy constructor. @@ -107,7 +106,7 @@ public: * @SINCE_1_0.0 * @param[in] matrix A reference to the copied matrix */ - Matrix( const Matrix& matrix ); + Matrix(const Matrix& matrix); /** * @brief Assignment operator. @@ -116,7 +115,7 @@ public: * @param[in] matrix A reference to the copied matrix * @return A reference to this */ - Matrix& operator=( const Matrix& matrix ); + Matrix& operator=(const Matrix& matrix); /** * @brief Move constructor. @@ -124,7 +123,7 @@ public: * @SINCE_1_9.21 * @param[in] matrix A reference to the moved matrix */ - Matrix( Matrix&& matrix ); + Matrix(Matrix&& matrix); /** * @brief Move assignment operator. @@ -133,7 +132,7 @@ public: * @param[in] matrix A reference to the moved matrix * @return A reference to this */ - Matrix& operator=( Matrix&& matrix ); + Matrix& operator=(Matrix&& matrix); /** * @brief The identity matrix. @@ -152,7 +151,7 @@ public: * @SINCE_1_0.0 * @param[in] scale Scale to set on top of identity matrix */ - void SetIdentityAndScale( const Vector3& scale ); + void SetIdentityAndScale(const Vector3& scale); /** * @brief Inverts a transform Matrix. @@ -239,7 +238,10 @@ public: * @return The translation * @note inlined for performance reasons (generates less code than a function call) */ - const Vector4& GetTranslation() const { return reinterpret_cast(mMatrix[12]); } + const Vector4& GetTranslation() const + { + return reinterpret_cast(mMatrix[12]); + } /** * @brief Gets the x,y and z components of the translation as a Vector3. @@ -249,7 +251,10 @@ public: * @return The translation * @note inlined for performance reasons (generates less code than a function call) */ - const Vector3& GetTranslation3() const { return reinterpret_cast(mMatrix[12]); } + const Vector3& GetTranslation3() const + { + return reinterpret_cast(mMatrix[12]); + } /** * @brief Sets the translation. @@ -292,7 +297,10 @@ public: * @return The matrix contents as an array of 16 floats * @note inlined for performance reasons (generates less code than a function call) */ - const float* AsFloat() const {return mMatrix;} + const float* AsFloat() const + { + return mMatrix; + } /** * @brief Returns the contents of the matrix as an array of 16 floats. @@ -307,7 +315,10 @@ public: * @return The matrix contents as an array of 16 floats * @note inlined for performance reasons (generates less code than a function call) */ - float* AsFloat() {return mMatrix;} + float* AsFloat() + { + return mMatrix; + } /** * @brief Function to multiply two matrices and store the result onto third. @@ -321,7 +332,7 @@ public: * @param[in] lhs Matrix, this can be same matrix as result * @param[in] rhs Matrix, this cannot be same matrix as result */ - static void Multiply( Matrix& result, const Matrix& lhs, const Matrix& rhs ); + static void Multiply(Matrix& result, const Matrix& lhs, const Matrix& rhs); /** * @brief Function to multiply a matrix and quaternion and store the result onto third. @@ -332,7 +343,7 @@ public: * @param[in] lhs Matrix, this can be same matrix as result * @param[in] rhs Quaternion */ - static void Multiply( Matrix& result, const Matrix& lhs, const Quaternion& rhs ); + static void Multiply(Matrix& result, const Matrix& lhs, const Quaternion& rhs); /** * @brief The multiplication operator. @@ -354,7 +365,7 @@ public: * @param[in] rhs The Matrix to compare this to * @return true if the matrices are equal */ - bool operator==(const Matrix & rhs) const; + bool operator==(const Matrix& rhs) const; /** * @brief The inequality operator. @@ -364,7 +375,7 @@ public: * @param[in] rhs The Matrix to compare this to * @return true if the matrices are not equal. */ - bool operator!=(const Matrix & rhs) const; + bool operator!=(const Matrix& rhs) const; /** * @brief Sets this matrix to contain the position, scale and rotation components. @@ -375,9 +386,9 @@ public: * @param[in] rotation Rotation to apply * @param[in] translation Translation to apply */ - void SetTransformComponents(const Vector3& scale, + void SetTransformComponents(const Vector3& scale, const Quaternion& rotation, - const Vector3& translation ); + const Vector3& translation); /** * @brief Sets this matrix to contain the inverse of the position, scale and rotation components. @@ -390,8 +401,7 @@ public: */ void SetInverseTransformComponents(const Vector3& scale, const Quaternion& rotation, - const Vector3& translation ); - + const Vector3& translation); /** * @brief Sets this matrix to contain the inverse of the orthonormal basis and position components. @@ -403,10 +413,10 @@ public: * @param[in] zAxis The Z axis of the basis * @param[in] translation Translation to apply */ - void SetInverseTransformComponents(const Vector3& xAxis, - const Vector3& yAxis, - const Vector3& zAxis, - const Vector3& translation ); + void SetInverseTransformComponents(const Vector3& xAxis, + const Vector3& yAxis, + const Vector3& zAxis, + const Vector3& translation); /** * @brief Gets the position, scale and rotation components from the given transform matrix. @@ -417,12 +427,11 @@ public: * @param[out] scale Scale to set - only valid if the transform matrix has not been skewed or sheared * @pre This matrix must not contain skews or shears. */ - void GetTransformComponents(Vector3& position, + void GetTransformComponents(Vector3& position, Quaternion& rotation, - Vector3& scale) const; + Vector3& scale) const; private: - float mMatrix[16]; ///< The elements of the matrix }; @@ -435,10 +444,17 @@ private: * @param[in] matrix The matrix to print * @return The output stream operator */ -DALI_CORE_API std::ostream& operator<< (std::ostream& o, const Matrix& matrix); +DALI_CORE_API std::ostream& operator<<(std::ostream& o, const Matrix& matrix); // Allow Matrix to be treated as a POD type -template <> struct TypeTraits< Matrix > : public BasicTypes< Matrix > { enum { IS_TRIVIAL_TYPE = true }; }; +template<> +struct TypeTraits : public BasicTypes +{ + enum + { + IS_TRIVIAL_TYPE = true + }; +}; /** * @} diff --git a/dali/public-api/math/matrix3.cpp b/dali/public-api/math/matrix3.cpp index 12adfcb..5fc44e7 100644 --- a/dali/public-api/math/matrix3.cpp +++ b/dali/public-api/math/matrix3.cpp @@ -44,16 +44,13 @@ namespace { -const uint32_t NUM_BYTES_IN_ROW = 3*sizeof(float); -const uint32_t NUM_BYTES_IN_MATRIX = 9*sizeof(float); -} +const uint32_t NUM_BYTES_IN_ROW = 3 * sizeof(float); +const uint32_t NUM_BYTES_IN_MATRIX = 9 * sizeof(float); +} // namespace namespace Dali { - -const Matrix3 Matrix3::IDENTITY(1.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 1.0f); +const Matrix3 Matrix3::IDENTITY(1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f); Matrix3::Matrix3() { @@ -63,15 +60,15 @@ Matrix3::Matrix3() Matrix3::Matrix3(const Matrix3& m) { - memcpy( mElements, m.mElements, NUM_BYTES_IN_MATRIX ); + memcpy(mElements, m.mElements, NUM_BYTES_IN_MATRIX); } Matrix3::Matrix3(const Matrix& matrix) { const float* m4 = matrix.AsFloat(); - memcpy(&mElements[S00], m4, NUM_BYTES_IN_ROW); - memcpy(&mElements[S10], m4+4, NUM_BYTES_IN_ROW); - memcpy(&mElements[S20], m4+8, NUM_BYTES_IN_ROW); + memcpy(&mElements[S00], m4, NUM_BYTES_IN_ROW); + memcpy(&mElements[S10], m4 + 4, NUM_BYTES_IN_ROW); + memcpy(&mElements[S20], m4 + 8, NUM_BYTES_IN_ROW); } Matrix3::Matrix3(float s00, float s01, float s02, float s10, float s11, float s12, float s20, float s21, float s22) @@ -87,45 +84,44 @@ Matrix3::Matrix3(float s00, float s01, float s02, float s10, float s11, float s1 mElements[S22] = s22; } - void Matrix3::SetIdentity() { memset(mElements, 0, NUM_BYTES_IN_MATRIX); - mElements[S00]=1.0f; - mElements[S11]=1.0f; - mElements[S22]=1.0f; + mElements[S00] = 1.0f; + mElements[S11] = 1.0f; + mElements[S22] = 1.0f; } -Matrix3::Matrix3( Matrix3&& matrix ) +Matrix3::Matrix3(Matrix3&& matrix) { - memcpy( mElements, matrix.mElements, NUM_BYTES_IN_MATRIX ); + memcpy(mElements, matrix.mElements, NUM_BYTES_IN_MATRIX); } -Matrix3& Matrix3::operator=( Matrix3&& matrix ) +Matrix3& Matrix3::operator=(Matrix3&& matrix) { - if( this != &matrix ) + if(this != &matrix) { - memcpy( AsFloat(), matrix.AsFloat(), NUM_BYTES_IN_MATRIX ); + memcpy(AsFloat(), matrix.AsFloat(), NUM_BYTES_IN_MATRIX); } return *this; } -Matrix3& Matrix3::operator=( const Matrix3& matrix ) +Matrix3& Matrix3::operator=(const Matrix3& matrix) { // no point copying if self assigning - if( this != &matrix ) + if(this != &matrix) { - memcpy( AsFloat(), matrix.AsFloat(), NUM_BYTES_IN_MATRIX ); + memcpy(AsFloat(), matrix.AsFloat(), NUM_BYTES_IN_MATRIX); } return *this; } -Matrix3& Matrix3::operator=( const Matrix& matrix ) +Matrix3& Matrix3::operator=(const Matrix& matrix) { const float* m4 = matrix.AsFloat(); - memcpy(&mElements[S00], m4, NUM_BYTES_IN_ROW); - memcpy(&mElements[S10], m4+4, NUM_BYTES_IN_ROW); - memcpy(&mElements[S20], m4+8, NUM_BYTES_IN_ROW); + memcpy(&mElements[S00], m4, NUM_BYTES_IN_ROW); + memcpy(&mElements[S10], m4 + 4, NUM_BYTES_IN_ROW); + memcpy(&mElements[S20], m4 + 8, NUM_BYTES_IN_ROW); return *this; } @@ -149,10 +145,10 @@ bool Matrix3::Invert() float det = mElements[S00] * cof[S00] + mElements[S01] * cof[S10] + mElements[S02] * cof[S20]; // In the case where the determinant is exactly zero, the matrix is non-invertible - if( ! EqualsZero( det ) ) + if(!EqualsZero(det)) { det = 1.0f / det; - for( int32_t i = 0; i < 9; i++ ) + for(int32_t i = 0; i < 9; i++) { mElements[i] = cof[i] * det; } @@ -164,9 +160,15 @@ bool Matrix3::Invert() bool Matrix3::Transpose() { float tmp; - tmp = mElements[S01]; mElements[S01] = mElements[S10]; mElements[S10]=tmp; - tmp = mElements[S02]; mElements[S02] = mElements[S20]; mElements[S20]=tmp; - tmp = mElements[S21]; mElements[S21] = mElements[S12]; mElements[S12]=tmp; + tmp = mElements[S01]; + mElements[S01] = mElements[S10]; + mElements[S10] = tmp; + tmp = mElements[S02]; + mElements[S02] = mElements[S20]; + mElements[S20] = tmp; + tmp = mElements[S21]; + mElements[S21] = mElements[S12]; + mElements[S12] = tmp; return true; } @@ -190,16 +192,16 @@ bool Matrix3::ScaledInverseTranspose() float det = mElements[S00] * cof[S00] + mElements[S01] * cof[S10] + mElements[S02] * cof[S20]; // In the case where the determinant is exactly zero, the matrix is non-invertible - if( ! EqualsZero( det ) ) + if(!EqualsZero(det)) { // Use average rather than determinant to remove rounding to zero errors in further multiplication - float sum=0; - for(uint32_t i=0;i<9;i++) + float sum = 0; + for(uint32_t i = 0; i < 9; i++) { - sum+=fabsf(cof[i]); + sum += fabsf(cof[i]); } - float scale = 9.0f/sum; // Inverse of the average values - if (det < 0) + float scale = 9.0f / sum; // Inverse of the average values + if(det < 0) { // Ensure the signs of the inverse are correct scale = -scale; @@ -237,33 +239,32 @@ void Matrix3::Scale(float scale) float Matrix3::Magnitude() const { - float avg=0; - for(uint32_t i=0;i<9;i++) + float avg = 0; + for(uint32_t i = 0; i < 9; i++) { - avg+=fabsf(mElements[i]); + avg += fabsf(mElements[i]); } - return avg/3.0f; + return avg / 3.0f; } - -void Matrix3::Multiply( Matrix3& result, const Matrix3& lhs, const Matrix3& rhs ) +void Matrix3::Multiply(Matrix3& result, const Matrix3& lhs, const Matrix3& rhs) { - float* temp = result.AsFloat(); - const float* rhsPtr = rhs.AsFloat(); + float* temp = result.AsFloat(); + const float* rhsPtr = rhs.AsFloat(); const float* lhsPtr = lhs.AsFloat(); - for( int32_t i=0; i < 3; i++ ) + for(int32_t i = 0; i < 3; i++) { - int32_t loc = i * 3; + int32_t loc = i * 3; int32_t loc1 = loc + 1; int32_t loc2 = loc + 2; float value0 = lhsPtr[loc]; float value1 = lhsPtr[loc1]; float value2 = lhsPtr[loc2]; - temp[loc] = (value0 * rhsPtr[0]) + - (value1 * rhsPtr[3]) + - (value2 * rhsPtr[6]); + temp[loc] = (value0 * rhsPtr[0]) + + (value1 * rhsPtr[3]) + + (value2 * rhsPtr[6]); temp[loc1] = (value0 * rhsPtr[1]) + (value1 * rhsPtr[4]) + @@ -275,18 +276,18 @@ void Matrix3::Multiply( Matrix3& result, const Matrix3& lhs, const Matrix3& rhs } } -bool Matrix3::operator==(const Matrix3 & rhs) const +bool Matrix3::operator==(const Matrix3& rhs) const { return ( - Equals( mElements[0], rhs.mElements[0]) && - Equals( mElements[1], rhs.mElements[1]) && - Equals( mElements[2], rhs.mElements[2]) && - Equals( mElements[3], rhs.mElements[3]) && - Equals( mElements[4], rhs.mElements[4]) && - Equals( mElements[5], rhs.mElements[5]) && - Equals( mElements[6], rhs.mElements[6]) && - Equals( mElements[7], rhs.mElements[7]) && - Equals( mElements[8], rhs.mElements[8])); + Equals(mElements[0], rhs.mElements[0]) && + Equals(mElements[1], rhs.mElements[1]) && + Equals(mElements[2], rhs.mElements[2]) && + Equals(mElements[3], rhs.mElements[3]) && + Equals(mElements[4], rhs.mElements[4]) && + Equals(mElements[5], rhs.mElements[5]) && + Equals(mElements[6], rhs.mElements[6]) && + Equals(mElements[7], rhs.mElements[7]) && + Equals(mElements[8], rhs.mElements[8])); } bool Matrix3::operator!=(const Matrix3& rhs) const @@ -294,11 +295,11 @@ bool Matrix3::operator!=(const Matrix3& rhs) const return !(*this == rhs); } -std::ostream& operator<< (std::ostream& o, const Matrix3& matrix) +std::ostream& operator<<(std::ostream& o, const Matrix3& matrix) { return o << "[ " << matrix.mElements[0] << ", " << matrix.mElements[1] << ", " << matrix.mElements[2] << ", " - << matrix.mElements[3] << ", " << matrix.mElements[4] << ", " << matrix.mElements[5] << ", " - << matrix.mElements[6] << ", " << matrix.mElements[7] << ", " << matrix.mElements[8] << " ]"; + << matrix.mElements[3] << ", " << matrix.mElements[4] << ", " << matrix.mElements[5] << ", " + << matrix.mElements[6] << ", " << matrix.mElements[7] << ", " << matrix.mElements[8] << " ]"; } } // namespace Dali diff --git a/dali/public-api/math/matrix3.h b/dali/public-api/math/matrix3.h old mode 100755 new mode 100644 index 47ab4ed..693857a --- a/dali/public-api/math/matrix3.h +++ b/dali/public-api/math/matrix3.h @@ -19,9 +19,9 @@ */ // INTERNAL INCLUDES -#include -#include #include +#include +#include namespace Dali { @@ -55,8 +55,7 @@ struct Vector2; class DALI_CORE_API Matrix3 { public: - - friend DALI_CORE_API std::ostream& operator<< (std::ostream& o, const Matrix3& matrix); + friend DALI_CORE_API std::ostream& operator<<(std::ostream& o, const Matrix3& matrix); /** * @brief The identity matrix. @@ -107,7 +106,7 @@ public: * @SINCE_1_9.21 * @param[in] matrix A reference to the moved matrix */ - Matrix3( Matrix3&& matrix ); + Matrix3(Matrix3&& matrix); /** * @brief Move assignment operator. @@ -116,7 +115,7 @@ public: * @param[in] matrix A reference to the moved matrix * @return A reference to this */ - Matrix3& operator=( Matrix3&& matrix ); + Matrix3& operator=(Matrix3&& matrix); /** * @brief Assignment Operator. @@ -124,7 +123,7 @@ public: * @param[in] matrix From which to copy values * @return Reference to this object */ - Matrix3& operator=( const Matrix3& matrix ); + Matrix3& operator=(const Matrix3& matrix); /** * @brief Assignment Operator. @@ -132,7 +131,7 @@ public: * @param[in] matrix A reference to the copied matrix * @return A reference to this */ - Matrix3& operator=( const Matrix& matrix ); + Matrix3& operator=(const Matrix& matrix); /** * @brief The equality operator. @@ -143,7 +142,7 @@ public: * @param[in] rhs The Matrix to compare this to * @return True if the matrices are equal */ - bool operator==(const Matrix3 & rhs) const; + bool operator==(const Matrix3& rhs) const; /** * @brief The inequality operator. @@ -154,7 +153,7 @@ public: * @param[in] rhs The Matrix to compare this to * @return true if the matrices are equal */ - bool operator!=(const Matrix3 & rhs) const; + bool operator!=(const Matrix3& rhs) const; /** * @brief Destructor. @@ -182,7 +181,10 @@ public: * @SINCE_1_0.0 * @return The matrix contents as an array of 9 floats */ - const float* AsFloat() const {return &mElements[0];} + const float* AsFloat() const + { + return &mElements[0]; + } /** * @brief Returns the contents of the matrix as an array of 9 floats. @@ -196,7 +198,10 @@ public: * @SINCE_1_0.0 * @return The matrix contents as an array of 9 floats */ - float* AsFloat() {return &mElements[0];} + float* AsFloat() + { + return &mElements[0]; + } /** * @brief Inverts the matrix. @@ -255,10 +260,9 @@ public: * @param[in] lhs Matrix, this can be same matrix as result * @param[in] rhs Matrix, this cannot be same matrix as result */ - static void Multiply( Matrix3& result, const Matrix3& lhs, const Matrix3& rhs ); + static void Multiply(Matrix3& result, const Matrix3& lhs, const Matrix3& rhs); private: - float mElements[9]; ///< The elements of the matrix }; @@ -270,10 +274,17 @@ private: * @param[in] matrix The matrix to print * @return The output stream operator */ -DALI_CORE_API std::ostream& operator<< (std::ostream& o, const Matrix3& matrix); +DALI_CORE_API std::ostream& operator<<(std::ostream& o, const Matrix3& matrix); // Allow Matrix3 to be treated as a POD type -template <> struct TypeTraits< Matrix3 > : public BasicTypes< Matrix3 > { enum { IS_TRIVIAL_TYPE = true }; }; +template<> +struct TypeTraits : public BasicTypes +{ + enum + { + IS_TRIVIAL_TYPE = true + }; +}; /** * @} diff --git a/dali/public-api/math/quaternion.cpp b/dali/public-api/math/quaternion.cpp index 853cb09..eb68c50 100644 --- a/dali/public-api/math/quaternion.cpp +++ b/dali/public-api/math/quaternion.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -22,12 +22,12 @@ #include // INTERNAL INCLUDES +#include #include #include +#include #include #include -#include -#include namespace Dali { @@ -35,73 +35,72 @@ using Internal::PerformanceMonitor; const Quaternion Quaternion::IDENTITY; - /** * Default Constructor */ Quaternion::Quaternion() -: mVector( 0.0f, 0.0f, 0.0f, 1.0f ) +: mVector(0.0f, 0.0f, 0.0f, 1.0f) { } -Quaternion::Quaternion( float cosThetaBy2, float iBySineTheta, float jBySineTheta, float kBySineTheta ) -: mVector( iBySineTheta, jBySineTheta, kBySineTheta, cosThetaBy2 ) +Quaternion::Quaternion(float cosThetaBy2, float iBySineTheta, float jBySineTheta, float kBySineTheta) +: mVector(iBySineTheta, jBySineTheta, kBySineTheta, cosThetaBy2) { } -Quaternion::Quaternion( const Vector4& vector ) -: mVector( vector ) +Quaternion::Quaternion(const Vector4& vector) +: mVector(vector) { } -Quaternion::Quaternion( Radian angle, const Vector3& axis ) +Quaternion::Quaternion(Radian angle, const Vector3& axis) { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,4); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 4); Vector3 tmpAxis = axis; tmpAxis.Normalize(); - const float halfAngle = angle.radian * 0.5f; + const float halfAngle = angle.radian * 0.5f; const float sinThetaByTwo = sinf(halfAngle); const float cosThetaByTwo = cosf(halfAngle); - mVector.x = tmpAxis.x * sinThetaByTwo; - mVector.y = tmpAxis.y * sinThetaByTwo; - mVector.z = tmpAxis.z * sinThetaByTwo; - mVector.w = cosThetaByTwo; + mVector.x = tmpAxis.x * sinThetaByTwo; + mVector.y = tmpAxis.y * sinThetaByTwo; + mVector.z = tmpAxis.z * sinThetaByTwo; + mVector.w = cosThetaByTwo; } -Quaternion::Quaternion( Radian pitch, Radian yaw, Radian roll ) +Quaternion::Quaternion(Radian pitch, Radian yaw, Radian roll) { - SetEuler( pitch, yaw, roll ); + SetEuler(pitch, yaw, roll); } -Quaternion::Quaternion( const Matrix& matrix ) +Quaternion::Quaternion(const Matrix& matrix) { - Vector3 xAxis( matrix.GetXAxis() ); - Vector3 yAxis( matrix.GetYAxis() ); - Vector3 zAxis( matrix.GetZAxis() ); + Vector3 xAxis(matrix.GetXAxis()); + Vector3 yAxis(matrix.GetYAxis()); + Vector3 zAxis(matrix.GetZAxis()); - SetFromAxes( xAxis, yAxis, zAxis ); + SetFromAxes(xAxis, yAxis, zAxis); } -Quaternion::Quaternion( const Vector3& xAxis, const Vector3& yAxis, const Vector3& zAxis ) +Quaternion::Quaternion(const Vector3& xAxis, const Vector3& yAxis, const Vector3& zAxis) { - SetFromAxes( xAxis, yAxis, zAxis ); + SetFromAxes(xAxis, yAxis, zAxis); } -Quaternion::Quaternion( const Vector3& v0, const Vector3& v1 ) +Quaternion::Quaternion(const Vector3& v0, const Vector3& v1) { float dot = v0.Dot(v1); - if( dot > 1.0f - Math::MACHINE_EPSILON_1 ) + if(dot > 1.0f - Math::MACHINE_EPSILON_1) { //Identity quaternion mVector.x = mVector.y = mVector.z = 0.0f; - mVector.w = 1.0f; + mVector.w = 1.0f; } - else if( dot < -1.0f + Math::MACHINE_EPSILON_1) + else if(dot < -1.0f + Math::MACHINE_EPSILON_1) { //180 degree rotation across the Z axis mVector.x = mVector.y = mVector.w = 0.0f; - mVector.z = 1.0f; + mVector.z = 1.0f; } else { @@ -122,30 +121,30 @@ bool Quaternion::IsIdentity() const { // start from w as its unlikely that any real rotation has w == 1 // Uses a relaxed epsilon, as composition of rotation introduces error - return ( ( fabsf( mVector.w - 1.0f ) < Math::MACHINE_EPSILON_10 )&& - ( fabsf( mVector.x ) < Math::MACHINE_EPSILON_10 )&& - ( fabsf( mVector.y ) < Math::MACHINE_EPSILON_10 )&& - ( fabsf( mVector.z ) < Math::MACHINE_EPSILON_10 ) ); + return ((fabsf(mVector.w - 1.0f) < Math::MACHINE_EPSILON_10) && + (fabsf(mVector.x) < Math::MACHINE_EPSILON_10) && + (fabsf(mVector.y) < Math::MACHINE_EPSILON_10) && + (fabsf(mVector.z) < Math::MACHINE_EPSILON_10)); } bool Quaternion::ToAxisAngle(Vector3& axis, Radian& angle) const { - angle = acosf(mVector.w); + angle = acosf(mVector.w); bool converted = false; // pre-compute to save time - const float sine = sinf( angle.radian ); + const float sine = sinf(angle.radian); // If sine(angle) is zero, conversion is not possible - if ( ! EqualsZero( sine ) ) + if(!EqualsZero(sine)) { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,3); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 3); float sinf_theta_inv = 1.0f / sine; - axis.x = mVector.x*sinf_theta_inv; - axis.y = mVector.y*sinf_theta_inv; - axis.z = mVector.z*sinf_theta_inv; + axis.x = mVector.x * sinf_theta_inv; + axis.y = mVector.y * sinf_theta_inv; + axis.z = mVector.z * sinf_theta_inv; angle.radian *= 2.0f; converted = true; } @@ -157,9 +156,9 @@ const Vector4& Quaternion::AsVector() const return mVector; } -void Quaternion::SetEuler( Radian pitch, Radian yaw, Radian roll ) +void Quaternion::SetEuler(Radian pitch, Radian yaw, Radian roll) { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,19); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 19); const float halfX = 0.5f * pitch.radian; const float halfY = 0.5f * yaw.radian; @@ -181,33 +180,33 @@ void Quaternion::SetEuler( Radian pitch, Radian yaw, Radian roll ) Vector4 Quaternion::EulerAngles() const { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,13); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 13); - float sqw = mVector.w*mVector.w; - float sqx = mVector.x*mVector.x; - float sqy = mVector.y*mVector.y; - float sqz = mVector.z*mVector.z; + float sqw = mVector.w * mVector.w; + float sqx = mVector.x * mVector.x; + float sqy = mVector.y * mVector.y; + float sqz = mVector.z * mVector.z; Vector4 euler; - euler.x = atan2f(2.0f * (mVector.y*mVector.z + mVector.x*mVector.w), -sqx - sqy + sqz + sqw); - euler.y = asinf(-2.0f * (mVector.x*mVector.z - mVector.y*mVector.w)); - euler.z = atan2f(2.0f * (mVector.x*mVector.y + mVector.z*mVector.w), sqx - sqy - sqz + sqw); + euler.x = atan2f(2.0f * (mVector.y * mVector.z + mVector.x * mVector.w), -sqx - sqy + sqz + sqw); + euler.y = asinf(-2.0f * (mVector.x * mVector.z - mVector.y * mVector.w)); + euler.z = atan2f(2.0f * (mVector.x * mVector.y + mVector.z * mVector.w), sqx - sqy - sqz + sqw); return euler; } -const Quaternion Quaternion::operator+( const Quaternion& other ) const +const Quaternion Quaternion::operator+(const Quaternion& other) const { return Quaternion(mVector + other.mVector); } -const Quaternion Quaternion::operator-( const Quaternion& other ) const +const Quaternion Quaternion::operator-(const Quaternion& other) const { return Quaternion(mVector - other.mVector); } -const Quaternion Quaternion::operator*( const Quaternion& other ) const +const Quaternion Quaternion::operator*(const Quaternion& other) const { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,12); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 12); return Quaternion(mVector.w * other.mVector.w - mVector.Dot(other.mVector), mVector.y * other.mVector.z - mVector.z * other.mVector.y + mVector.w * other.mVector.x + mVector.x * other.mVector.w, @@ -215,10 +214,10 @@ const Quaternion Quaternion::operator*( const Quaternion& other ) const mVector.x * other.mVector.y - mVector.y * other.mVector.x + mVector.w * other.mVector.z + mVector.z * other.mVector.w); } -Vector3 Quaternion::operator*( const Vector3& other ) const +Vector3 Quaternion::operator*(const Vector3& other) const { Vector3 qvec(mVector.x, mVector.y, mVector.z); - Vector3 uv = qvec.Cross( other ); + Vector3 uv = qvec.Cross(other); Vector3 uuv = qvec.Cross(uv); uv *= (2.0f * mVector.w); uuv *= 2.0f; @@ -226,21 +225,21 @@ Vector3 Quaternion::operator*( const Vector3& other ) const return other + uv + uuv; } -const Quaternion Quaternion::operator/( const Quaternion& q ) const +const Quaternion Quaternion::operator/(const Quaternion& q) const { Quaternion p(q); p.Invert(); return *this * p; } -const Quaternion Quaternion::operator*( float scale ) const +const Quaternion Quaternion::operator*(float scale) const { - return Quaternion(mVector*scale); + return Quaternion(mVector * scale); } -const Quaternion Quaternion::operator/( float scale ) const +const Quaternion Quaternion::operator/(float scale) const { - return Quaternion(mVector/scale); + return Quaternion(mVector / scale); } Quaternion Quaternion::operator-() const @@ -248,76 +247,79 @@ Quaternion Quaternion::operator-() const return Quaternion(-mVector.w, -mVector.x, -mVector.y, -mVector.z); } -const Quaternion& Quaternion::operator+=( const Quaternion& q ) +const Quaternion& Quaternion::operator+=(const Quaternion& q) { - mVector += q.mVector; return *this; + mVector += q.mVector; + return *this; } -const Quaternion& Quaternion::operator-=( const Quaternion& q ) +const Quaternion& Quaternion::operator-=(const Quaternion& q) { - mVector -= q.mVector; return *this; + mVector -= q.mVector; + return *this; } -const Quaternion& Quaternion::operator*=( const Quaternion& q ) +const Quaternion& Quaternion::operator*=(const Quaternion& q) { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,12); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 12); float x = mVector.x, y = mVector.y, z = mVector.z, w = mVector.w; mVector.w = mVector.w * q.mVector.w - mVector.Dot(q.mVector); - mVector.x = y*q.mVector.z - z*q.mVector.y + w*q.mVector.x + x*q.mVector.w; - mVector.y = z*q.mVector.x - x*q.mVector.z + w*q.mVector.y + y*q.mVector.w; - mVector.z = x*q.mVector.y - y*q.mVector.x + w*q.mVector.z + z*q.mVector.w; + mVector.x = y * q.mVector.z - z * q.mVector.y + w * q.mVector.x + x * q.mVector.w; + mVector.y = z * q.mVector.x - x * q.mVector.z + w * q.mVector.y + y * q.mVector.w; + mVector.z = x * q.mVector.y - y * q.mVector.x + w * q.mVector.z + z * q.mVector.w; return *this; } -const Quaternion& Quaternion::operator*=( float scale ) +const Quaternion& Quaternion::operator*=(float scale) { - mVector*=scale; return *this; + mVector *= scale; + return *this; } -const Quaternion& Quaternion::operator/=( float scale ) +const Quaternion& Quaternion::operator/=(float scale) { - mVector/=scale; return *this; + mVector /= scale; + return *this; } -bool Quaternion::operator==( const Quaternion& rhs ) const +bool Quaternion::operator==(const Quaternion& rhs) const { - return ( ( fabsf(mVector.x - rhs.mVector.x) < Math::MACHINE_EPSILON_1 && - fabsf(mVector.y - rhs.mVector.y) < Math::MACHINE_EPSILON_1 && - fabsf(mVector.z - rhs.mVector.z) < Math::MACHINE_EPSILON_1 && - fabsf(mVector.w - rhs.mVector.w) < Math::MACHINE_EPSILON_1 ) || - // Or equal to negation of rhs - ( fabsf(mVector.x + rhs.mVector.x) < Math::MACHINE_EPSILON_1 && - fabsf(mVector.y + rhs.mVector.y) < Math::MACHINE_EPSILON_1 && - fabsf(mVector.z + rhs.mVector.z) < Math::MACHINE_EPSILON_1 && - fabsf(mVector.w + rhs.mVector.w) < Math::MACHINE_EPSILON_1 ) - ); + return ((fabsf(mVector.x - rhs.mVector.x) < Math::MACHINE_EPSILON_1 && + fabsf(mVector.y - rhs.mVector.y) < Math::MACHINE_EPSILON_1 && + fabsf(mVector.z - rhs.mVector.z) < Math::MACHINE_EPSILON_1 && + fabsf(mVector.w - rhs.mVector.w) < Math::MACHINE_EPSILON_1) || + // Or equal to negation of rhs + (fabsf(mVector.x + rhs.mVector.x) < Math::MACHINE_EPSILON_1 && + fabsf(mVector.y + rhs.mVector.y) < Math::MACHINE_EPSILON_1 && + fabsf(mVector.z + rhs.mVector.z) < Math::MACHINE_EPSILON_1 && + fabsf(mVector.w + rhs.mVector.w) < Math::MACHINE_EPSILON_1)); } -bool Quaternion::operator!=( const Quaternion& rhs ) const +bool Quaternion::operator!=(const Quaternion& rhs) const { return !operator==(rhs); } float Quaternion::Length() const { - return static_cast< float >( sqrt(mVector.w * mVector.w + mVector.Dot(mVector) ) ); + return static_cast(sqrt(mVector.w * mVector.w + mVector.Dot(mVector))); } float Quaternion::LengthSquared() const { - return static_cast< float >( mVector.w * mVector.w + mVector.Dot(mVector) ); + return static_cast(mVector.w * mVector.w + mVector.Dot(mVector)); } void Quaternion::Normalize() { - *this/=Length(); + *this /= Length(); } Quaternion Quaternion::Normalized() const { - return *this/Length(); + return *this / Length(); } void Quaternion::Conjugate() @@ -330,50 +332,50 @@ void Quaternion::Conjugate() void Quaternion::Invert() { Conjugate(); - *this/=LengthSquared(); + *this /= LengthSquared(); } Quaternion Quaternion::Log() const { - float a = acosf(mVector.w); - float sina = sinf(a); + float a = acosf(mVector.w); + float sina = sinf(a); Quaternion ret; ret.mVector.w = 0; - if (fabsf(sina) >= Math::MACHINE_EPSILON_1) + if(fabsf(sina) >= Math::MACHINE_EPSILON_1) { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,4); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 4); float angleBySinAngle = a * (1.0f / sina); - ret.mVector.x = mVector.x * angleBySinAngle; - ret.mVector.y = mVector.y * angleBySinAngle; - ret.mVector.z = mVector.z * angleBySinAngle; + ret.mVector.x = mVector.x * angleBySinAngle; + ret.mVector.y = mVector.y * angleBySinAngle; + ret.mVector.z = mVector.z * angleBySinAngle; } else { - ret.mVector.x= ret.mVector.y= ret.mVector.z= 0; + ret.mVector.x = ret.mVector.y = ret.mVector.z = 0; } return ret; } Quaternion Quaternion::Exp() const { - DALI_ASSERT_ALWAYS( EqualsZero( mVector.w ) && "Cannot perform Exponent" ); + DALI_ASSERT_ALWAYS(EqualsZero(mVector.w) && "Cannot perform Exponent"); - float a = mVector.Length(); - float sina = sinf(a); + float a = mVector.Length(); + float sina = sinf(a); Quaternion ret; ret.mVector.w = cosf(a); - if (a >= Math::MACHINE_EPSILON_1) + if(a >= Math::MACHINE_EPSILON_1) { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,4); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 4); float sinAOverA = sina * (1.0f / a); - ret.mVector.x = mVector.x * sinAOverA; - ret.mVector.y = mVector.y * sinAOverA; - ret.mVector.z = mVector.z * sinAOverA; + ret.mVector.x = mVector.x * sinAOverA; + ret.mVector.y = mVector.y * sinAOverA; + ret.mVector.z = mVector.z * sinAOverA; } else { @@ -382,67 +384,67 @@ Quaternion Quaternion::Exp() const return ret; } -float Quaternion::Dot( const Quaternion& q1, const Quaternion& q2 ) +float Quaternion::Dot(const Quaternion& q1, const Quaternion& q2) { return q1.mVector.Dot4(q2.mVector); } -Quaternion Quaternion::Lerp(const Quaternion& q1, const Quaternion& q2, float t ) +Quaternion Quaternion::Lerp(const Quaternion& q1, const Quaternion& q2, float t) { - return (q1*(1.0f-t) + q2*t).Normalized(); + return (q1 * (1.0f - t) + q2 * t).Normalized(); } -Quaternion Quaternion::Slerp( const Quaternion& q1, const Quaternion& q2, float progress ) +Quaternion Quaternion::Slerp(const Quaternion& q1, const Quaternion& q2, float progress) { Quaternion q3; - float cosTheta = Quaternion::Dot(q1, q2); + float cosTheta = Quaternion::Dot(q1, q2); /** * If cos(theta) < 0, q1 and q2 are more than 90 degrees apart, * so invert one to reduce spinning. */ - if (cosTheta < 0.0f) + if(cosTheta < 0.0f) { cosTheta = -cosTheta; - q3 = -q2; + q3 = -q2; } else { q3 = q2; } - if (fabsf(cosTheta) < 0.95f) + if(fabsf(cosTheta) < 0.95f) { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,5); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 5); // Normal SLERP - float sine = sqrtf(1.0f - cosTheta*cosTheta); - float angle = atan2f(sine, cosTheta); + float sine = sqrtf(1.0f - cosTheta * cosTheta); + float angle = atan2f(sine, cosTheta); float invSine = 1.0f / sine; - float coeff0 = sinf((1.0f - progress) * angle) * invSine; - float coeff1 = sinf(progress * angle) * invSine; + float coeff0 = sinf((1.0f - progress) * angle) * invSine; + float coeff1 = sinf(progress * angle) * invSine; - return q1*coeff0 + q3*coeff1; + return q1 * coeff0 + q3 * coeff1; } else { // If the angle is small, use linear interpolation - Quaternion result = q1*(1.0f - progress) + q3*progress; + Quaternion result = q1 * (1.0f - progress) + q3 * progress; return result.Normalized(); } } -Quaternion Quaternion::SlerpNoInvert( const Quaternion& q1, const Quaternion& q2, float t ) +Quaternion Quaternion::SlerpNoInvert(const Quaternion& q1, const Quaternion& q2, float t) { float cosTheta = Quaternion::Dot(q1, q2); - if (cosTheta > -0.95f && cosTheta < 0.95f) + if(cosTheta > -0.95f && cosTheta < 0.95f) { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,2); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 2); float theta = acosf(cosTheta); - return (q1*sinf(theta*(1.0f-t)) + q2*sinf(theta*t))/sinf(theta); + return (q1 * sinf(theta * (1.0f - t)) + q2 * sinf(theta * t)) / sinf(theta); } else { @@ -450,16 +452,16 @@ Quaternion Quaternion::SlerpNoInvert( const Quaternion& q1, const Quaternion& q2 } } -Quaternion Quaternion::Squad( const Quaternion& start, const Quaternion& end, const Quaternion& ctrl1, const Quaternion& ctrl2, float t ) +Quaternion Quaternion::Squad(const Quaternion& start, const Quaternion& end, const Quaternion& ctrl1, const Quaternion& ctrl2, float t) { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,2); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 2); - Quaternion c = SlerpNoInvert( start, end, t ); - Quaternion d = SlerpNoInvert( ctrl1, ctrl2, t ); - return SlerpNoInvert( c, d, 2*t*(1-t) ); + Quaternion c = SlerpNoInvert(start, end, t); + Quaternion d = SlerpNoInvert(ctrl1, ctrl2, t); + return SlerpNoInvert(c, d, 2 * t * (1 - t)); } -float Quaternion::AngleBetween( const Quaternion& q1, const Quaternion& q2 ) +float Quaternion::AngleBetween(const Quaternion& q1, const Quaternion& q2) { Quaternion from(q1); Quaternion to(q2); @@ -469,13 +471,13 @@ float Quaternion::AngleBetween( const Quaternion& q1, const Quaternion& q2 ) //Formula for angle θ between two quaternion is: //θ = cos^−1 (2⟨q1,q2⟩^2 − 1), Where (q1,q2) is inner product of the quaternions. - float X = from.mVector.Dot4(to.mVector); - float theta = acosf( (2 * X * X) - 1); // float arc cosine + float X = from.mVector.Dot4(to.mVector); + float theta = acosf((2 * X * X) - 1); // float arc cosine return theta; } -Vector4 Quaternion::Rotate( const Vector4& vector ) const +Vector4 Quaternion::Rotate(const Vector4& vector) const { Quaternion V(0.0f, vector.x, vector.y, vector.z); Quaternion conjugate(*this); @@ -483,7 +485,7 @@ Vector4 Quaternion::Rotate( const Vector4& vector ) const return (*this * V * conjugate).mVector; } -Vector3 Quaternion::Rotate( const Vector3& vector ) const +Vector3 Quaternion::Rotate(const Vector3& vector) const { Quaternion V(0.0f, vector.x, vector.y, vector.z); Quaternion conjugate(*this); @@ -491,59 +493,59 @@ Vector3 Quaternion::Rotate( const Vector3& vector ) const return Vector3((*this * V * conjugate).mVector); } -void Quaternion::SetFromAxes( const Vector3& xAxis, const Vector3& yAxis, const Vector3& zAxis ) +void Quaternion::SetFromAxes(const Vector3& xAxis, const Vector3& yAxis, const Vector3& zAxis) { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,4); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 4); float t = xAxis.x + yAxis.y + zAxis.z; - if ( t > 0.0f ) // w is largest + if(t > 0.0f) // w is largest { - float root = sqrtf( t + 1.0f ); + float root = sqrtf(t + 1.0f); float one_over_4w = 0.5f / root; - mVector.x = ( yAxis.z - zAxis.y ) * one_over_4w; - mVector.y = ( zAxis.x - xAxis.z ) * one_over_4w; - mVector.z = ( xAxis.y - yAxis.x ) * one_over_4w; - mVector.w = root * 0.5f; + mVector.x = (yAxis.z - zAxis.y) * one_over_4w; + mVector.y = (zAxis.x - xAxis.z) * one_over_4w; + mVector.z = (xAxis.y - yAxis.x) * one_over_4w; + mVector.w = root * 0.5f; } - else if( zAxis.z > xAxis.x && zAxis.z > yAxis.y ) // z is largest + else if(zAxis.z > xAxis.x && zAxis.z > yAxis.y) // z is largest { - float root = sqrtf( zAxis.z - xAxis.x - yAxis.y + 1.0f ); + float root = sqrtf(zAxis.z - xAxis.x - yAxis.y + 1.0f); float one_over_4w = 0.5f / root; - mVector.x = ( xAxis.z + zAxis.x ) * one_over_4w; - mVector.y = ( yAxis.z + zAxis.y ) * one_over_4w; - mVector.z = root * 0.5f; - mVector.w = ( xAxis.y - yAxis.x ) * one_over_4w; + mVector.x = (xAxis.z + zAxis.x) * one_over_4w; + mVector.y = (yAxis.z + zAxis.y) * one_over_4w; + mVector.z = root * 0.5f; + mVector.w = (xAxis.y - yAxis.x) * one_over_4w; } - else if( yAxis.y > xAxis.x ) // y is largest + else if(yAxis.y > xAxis.x) // y is largest { - float root = sqrtf(yAxis.y - zAxis.z - xAxis.x + 1.0f ); + float root = sqrtf(yAxis.y - zAxis.z - xAxis.x + 1.0f); float one_over_4w = 0.5f / root; - mVector.x = ( xAxis.y + yAxis.x ) * one_over_4w; + mVector.x = (xAxis.y + yAxis.x) * one_over_4w; mVector.y = root * 0.5f; - mVector.z = ( zAxis.y + yAxis.z ) * one_over_4w; - mVector.w = ( zAxis.x - xAxis.z ) * one_over_4w; + mVector.z = (zAxis.y + yAxis.z) * one_over_4w; + mVector.w = (zAxis.x - xAxis.z) * one_over_4w; } - else // x is largest + else // x is largest { - float root = sqrtf( xAxis.x - yAxis.y - zAxis.z + 1.0f ); + float root = sqrtf(xAxis.x - yAxis.y - zAxis.z + 1.0f); float one_over_4w = 0.5f / root; - mVector.x = root * 0.5f; - mVector.y = ( yAxis.x + xAxis.y ) * one_over_4w; - mVector.z = ( zAxis.x + xAxis.z ) * one_over_4w; - mVector.w = ( yAxis.z - zAxis.y ) * one_over_4w; + mVector.x = root * 0.5f; + mVector.y = (yAxis.x + xAxis.y) * one_over_4w; + mVector.z = (zAxis.x + xAxis.z) * one_over_4w; + mVector.w = (yAxis.z - zAxis.y) * one_over_4w; } Normalize(); } -std::ostream& operator<<( std::ostream& o, const Quaternion& quaternion ) +std::ostream& operator<<(std::ostream& o, const Quaternion& quaternion) { Vector3 axis; - Radian angleRadians; + Radian angleRadians; - quaternion.ToAxisAngle( axis, angleRadians ); - Degree degrees( angleRadians ); + quaternion.ToAxisAngle(axis, angleRadians); + Degree degrees(angleRadians); return o << "[ Axis: [" << axis.x << ", " << axis.y << ", " << axis.z << "], Angle: " << degrees.degree << " degrees ]"; } diff --git a/dali/public-api/math/quaternion.h b/dali/public-api/math/quaternion.h index b679d3a..cb1f8d5 100644 --- a/dali/public-api/math/quaternion.h +++ b/dali/public-api/math/quaternion.h @@ -45,7 +45,6 @@ class Matrix; class DALI_CORE_API Quaternion { public: - /** * @brief Default Constructor. * @SINCE_1_0.0 @@ -61,7 +60,7 @@ public: * @param[in] jBySineTheta * @param[in] kBySineTheta */ - Quaternion( float cosThetaBy2, float iBySineTheta, float jBySineTheta, float kBySineTheta ); + Quaternion(float cosThetaBy2, float iBySineTheta, float jBySineTheta, float kBySineTheta); /** * @brief Constructs from a quaternion represented by a vector. @@ -69,7 +68,7 @@ public: * @SINCE_1_0.0 * @param[in] vector x,y,z fields represent i,j,k coefficients, w represents cos(theta/2) */ - explicit Quaternion( const Vector4& vector ); + explicit Quaternion(const Vector4& vector); /** * @brief Constructor from an axis and angle. @@ -78,7 +77,7 @@ public: * @param[in] angle The angle around the axis * @param[in] axis The vector of the axis */ - Quaternion( Radian angle, const Vector3& axis ); + Quaternion(Radian angle, const Vector3& axis); /** * @brief Constructs from Euler angles. @@ -88,7 +87,7 @@ public: * @param[in] yaw * @param[in] roll */ - Quaternion( Radian pitch, Radian yaw, Radian roll ); + Quaternion(Radian pitch, Radian yaw, Radian roll); /** * @brief Constructs from a matrix. @@ -106,7 +105,7 @@ public: * @param[in] yAxis The Y axis * @param[in] zAxis The Z axis */ - explicit Quaternion( const Vector3& xAxis, const Vector3& yAxis, const Vector3& zAxis ); + explicit Quaternion(const Vector3& xAxis, const Vector3& yAxis, const Vector3& zAxis); /** * @brief Constructs quaternion which describes minimum rotation to align v0 with v1. @@ -116,7 +115,7 @@ public: * @pre v0 and v1 should be normalized * */ - explicit Quaternion( const Vector3& v0, const Vector3& v1 ); + explicit Quaternion(const Vector3& v0, const Vector3& v1); /** * @brief Destructor, nonvirtual as this is not a base class. @@ -125,7 +124,7 @@ public: */ ~Quaternion(); -// Constants + // Constants static const Quaternion IDENTITY; ///< (0.0f,0.0f,0.0f,1.0f) @@ -145,7 +144,7 @@ public: * @param[out] angle Angle in radians * @return True if converted correctly */ - bool ToAxisAngle( Vector3& axis, Radian& angle ) const; + bool ToAxisAngle(Vector3& axis, Radian& angle) const; /** * @brief Returns the quaternion as a vector. @@ -163,7 +162,7 @@ public: * @param[in] yaw * @param[in] roll */ - void SetEuler( Radian pitch, Radian yaw, Radian roll ); + void SetEuler(Radian pitch, Radian yaw, Radian roll); /** * @brief Returns the Euler angles from a rotation Quaternion. @@ -180,7 +179,7 @@ public: * @param[in] other The quaternion to add * @return A quaternion containing the result of the addition */ - const Quaternion operator+( const Quaternion& other ) const; + const Quaternion operator+(const Quaternion& other) const; /** * @brief Subtraction operator. @@ -189,7 +188,7 @@ public: * @param[in] other The quaternion to subtract * @return A quaternion containing the result of the subtract */ - const Quaternion operator-( const Quaternion& other ) const; + const Quaternion operator-(const Quaternion& other) const; /** * @brief Multiplication operator. @@ -198,7 +197,7 @@ public: * @param[in] other The quaternion to multiply * @return A quaternion containing the result */ - const Quaternion operator*( const Quaternion& other ) const; + const Quaternion operator*(const Quaternion& other) const; /** * @brief Multiplication operator. @@ -207,7 +206,7 @@ public: * @param[in] other The vector to multiply * @return A vector containing the result of the multiplication */ - Vector3 operator*( const Vector3& other ) const; + Vector3 operator*(const Vector3& other) const; /** * @brief Division operator. @@ -216,7 +215,7 @@ public: * @param[in] other A quaternion to divide by * @return A quaternion containing the result */ - const Quaternion operator/( const Quaternion& other ) const; + const Quaternion operator/(const Quaternion& other) const; /** * @brief Scale operator. @@ -225,7 +224,7 @@ public: * @param[in] scale A value to scale by * @return A quaternion containing the result */ - const Quaternion operator*( float scale ) const; + const Quaternion operator*(float scale) const; /** * @brief Scale operator. @@ -234,7 +233,7 @@ public: * @param[in] scale A value to scale by * @return A quaternion containing the result */ - const Quaternion operator/( float scale ) const; + const Quaternion operator/(float scale) const; /** * @brief Unary Negation operator. @@ -251,7 +250,7 @@ public: * @param[in] other The quaternion to add * @return A reference to this */ - const Quaternion& operator+=( const Quaternion& other ); + const Quaternion& operator+=(const Quaternion& other); /** * @brief Subtraction with Assignment operator. @@ -260,7 +259,7 @@ public: * @param[in] other The quaternion to subtract * @return A reference to this */ - const Quaternion& operator-=( const Quaternion& other ); + const Quaternion& operator-=(const Quaternion& other); /** * @brief Multiplication with Assignment operator. @@ -269,7 +268,7 @@ public: * @param[in] other The quaternion to multiply * @return A reference to this */ - const Quaternion& operator*=( const Quaternion& other ); + const Quaternion& operator*=(const Quaternion& other); /** * @brief Scale with Assignment operator. @@ -278,7 +277,7 @@ public: * @param[in] scale the value to scale by * @return A reference to this */ - const Quaternion& operator*=( float scale ); + const Quaternion& operator*=(float scale); /** * @brief Scale with Assignment operator. @@ -287,7 +286,7 @@ public: * @param[in] scale The value to scale by * @return A reference to this */ - const Quaternion& operator/=( float scale ); + const Quaternion& operator/=(float scale); /** * @brief Equality operator. @@ -296,7 +295,7 @@ public: * @param[in] rhs The quaternion to compare with * @return True if the quaternions are equal */ - bool operator==( const Quaternion& rhs ) const; + bool operator==(const Quaternion& rhs) const; /** * @brief Inequality operator. @@ -305,7 +304,7 @@ public: * @param[in] rhs The quaternion to compare with * @return True if the quaternions are not equal */ - bool operator!=( const Quaternion& rhs ) const; + bool operator!=(const Quaternion& rhs) const; /** * @brief Returns the length of the quaternion. @@ -376,7 +375,7 @@ public: * @param[in] q2 The second quaternion * @return The dot product of the two quaternions */ - static float Dot( const Quaternion &q1, const Quaternion &q2 ); + static float Dot(const Quaternion& q1, const Quaternion& q2); /** * @brief Linear Interpolation (using a straight line between the two quaternions). @@ -387,7 +386,7 @@ public: * @param[in] t A progress value between 0 and 1 * @return The interpolated quaternion */ - static Quaternion Lerp( const Quaternion &q1, const Quaternion &q2, float t ); + static Quaternion Lerp(const Quaternion& q1, const Quaternion& q2, float t); /** * @brief Spherical Linear Interpolation (using the shortest arc of a great circle between @@ -399,7 +398,7 @@ public: * @param[in] progress A progress value between 0 and 1 * @return The interpolated quaternion */ - static Quaternion Slerp( const Quaternion &q1, const Quaternion &q2, float progress ); + static Quaternion Slerp(const Quaternion& q1, const Quaternion& q2, float progress); /** * @brief This version of Slerp, used by Squad, does not check for theta > 90. @@ -410,7 +409,7 @@ public: * @param[in] t A progress value between 0 and 1 * @return The interpolated quaternion */ - static Quaternion SlerpNoInvert( const Quaternion &q1, const Quaternion &q2, float t ); + static Quaternion SlerpNoInvert(const Quaternion& q1, const Quaternion& q2, float t); /** * @brief Spherical Cubic Interpolation. @@ -423,7 +422,7 @@ public: * @param[in] t A progress value between 0 and 1 * @return The interpolated quaternion */ - static Quaternion Squad( const Quaternion& start, const Quaternion& end, const Quaternion& ctrl1, const Quaternion& ctrl2, float t ); + static Quaternion Squad(const Quaternion& start, const Quaternion& end, const Quaternion& ctrl1, const Quaternion& ctrl2, float t); /** * @brief Returns the shortest angle between two quaternions in Radians. @@ -433,7 +432,7 @@ public: * @param[in] q2 The second quaternion * @return The angle between the two quaternions */ - static float AngleBetween( const Quaternion& q1, const Quaternion& q2 ); + static float AngleBetween(const Quaternion& q1, const Quaternion& q2); /** * @brief Rotates v by this Quaternion (Quaternion must be unit). @@ -442,7 +441,7 @@ public: * @param[in] vector A vector to rotate * @return The rotated vector */ - Vector4 Rotate( const Vector4& vector ) const; + Vector4 Rotate(const Vector4& vector) const; /** * @brief Rotates v by this Quaternion (Quaternion must be unit). @@ -451,10 +450,9 @@ public: * @param[in] vector A vector to rotate * @return The rotated vector */ - Vector3 Rotate( const Vector3& vector ) const; + Vector3 Rotate(const Vector3& vector) const; private: - /// @cond internal /** * @brief Sets the quaternion from 3 orthonormal axes. @@ -464,19 +462,17 @@ private: * @param[in] yAxis The Y axis * @param[in] zAxis The Z axis */ - DALI_INTERNAL void SetFromAxes( const Vector3& xAxis, const Vector3& yAxis, const Vector3& zAxis ); + DALI_INTERNAL void SetFromAxes(const Vector3& xAxis, const Vector3& yAxis, const Vector3& zAxis); /// @endcond public: - - Quaternion( const Quaternion& ) = default; ///< Default copy constructor - Quaternion( Quaternion&& ) = default; ///< Default move constructor - Quaternion& operator=( const Quaternion& ) = default; ///< Default copy assignment operator - Quaternion& operator=( Quaternion&& ) = default; ///< Default move assignment operator + Quaternion(const Quaternion&) = default; ///< Default copy constructor + Quaternion(Quaternion&&) = default; ///< Default move constructor + Quaternion& operator=(const Quaternion&) = default; ///< Default copy assignment operator + Quaternion& operator=(Quaternion&&) = default; ///< Default move assignment operator public: - - Vector4 mVector; ///< w component is s ( = cos(theta/2.0) ) + Vector4 mVector; ///< w component is s ( = cos(theta/2.0) ) }; /** @@ -487,10 +483,17 @@ public: * @param[in] quaternion The quaternion to print * @return The output stream operator */ -DALI_CORE_API std::ostream& operator<< (std::ostream& o, const Quaternion& quaternion); +DALI_CORE_API std::ostream& operator<<(std::ostream& o, const Quaternion& quaternion); // Allow Quaternion to be treated as a POD type -template <> struct TypeTraits< Quaternion > : public BasicTypes< Quaternion > { enum { IS_TRIVIAL_TYPE = true }; }; +template<> +struct TypeTraits : public BasicTypes +{ + enum + { + IS_TRIVIAL_TYPE = true + }; +}; /** * @} diff --git a/dali/public-api/math/radian.h b/dali/public-api/math/radian.h index 6c16482..02c865a 100644 --- a/dali/public-api/math/radian.h +++ b/dali/public-api/math/radian.h @@ -21,8 +21,8 @@ // INTERNAL INCLUDES #include #include -#include #include +#include namespace Dali { @@ -44,8 +44,9 @@ struct Radian * @SINCE_1_0.0 */ Radian() - : radian( 0.f ) - { } + : radian(0.f) + { + } /** * @brief Creates an angle in radians. @@ -53,9 +54,10 @@ struct Radian * @SINCE_1_0.0 * @param[in] value The initial value in radians */ - explicit constexpr Radian( float value ) - : radian( value ) - { } + explicit constexpr Radian(float value) + : radian(value) + { + } /** * @brief Creates an angle in radians from an angle in degrees. @@ -63,9 +65,10 @@ struct Radian * @SINCE_1_0.0 * @param[in] degree The initial value in degrees */ - Radian( Degree degree ) - : radian( degree.degree * Math::PI_OVER_180 ) - { } + Radian(Degree degree) + : radian(degree.degree * Math::PI_OVER_180) + { + } /** * @brief Assigns an angle from a float value. @@ -74,7 +77,7 @@ struct Radian * @param[in] value Float value in radians * @return A reference to this */ - Radian& operator=( float value ) + Radian& operator=(float value) { radian = value; return *this; @@ -87,7 +90,7 @@ struct Radian * @param[in] degree The value in degrees * @return A reference to this */ - Radian& operator=( Degree degree ) + Radian& operator=(Degree degree) { radian = degree.degree * Math::PI_OVER_180; return *this; @@ -104,17 +107,14 @@ struct Radian } public: - - Radian( const Radian& ) = default; ///< Default copy constructor - Radian( Radian&& ) = default; ///< Default move constructor - Radian& operator=( const Radian& ) = default; ///< Default copy assignment operator - Radian& operator=( Radian&& ) = default; ///< Default move assignment operator + Radian(const Radian&) = default; ///< Default copy constructor + Radian(Radian&&) = default; ///< Default move constructor + Radian& operator=(const Radian&) = default; ///< Default copy assignment operator + Radian& operator=(Radian&&) = default; ///< Default move assignment operator public: - // member data float radian; ///< The value in radians - }; // compiler generated destructor, copy constructor and assignment operators are ok as this class is POD @@ -127,9 +127,9 @@ public: * @param[in] rhs Radian to compare to * @return True if the values are identical */ -inline bool operator==( Radian lhs, Radian rhs ) +inline bool operator==(Radian lhs, Radian rhs) { - return fabsf( lhs.radian - rhs.radian ) < Math::MACHINE_EPSILON_10; // expect Radian angles to be between 0 and 10 (multiplies of Math::PI) + return fabsf(lhs.radian - rhs.radian) < Math::MACHINE_EPSILON_10; // expect Radian angles to be between 0 and 10 (multiplies of Math::PI) } /** @@ -140,9 +140,9 @@ inline bool operator==( Radian lhs, Radian rhs ) * @param[in] rhs Radian to compare to * @return True if the values are not identical */ -inline bool operator!=( Radian lhs, Radian rhs ) +inline bool operator!=(Radian lhs, Radian rhs) { - return !( operator==( lhs, rhs ) ); + return !(operator==(lhs, rhs)); } /** @@ -153,9 +153,9 @@ inline bool operator!=( Radian lhs, Radian rhs ) * @param[in] rhs Degree to compare to * @return True if the values are identical */ -inline bool operator==( Radian lhs, Degree rhs ) +inline bool operator==(Radian lhs, Degree rhs) { - return fabsf( lhs.radian - Radian( rhs ).radian ) < Math::MACHINE_EPSILON_100; // expect Degree angles to be between 0 and 999 + return fabsf(lhs.radian - Radian(rhs).radian) < Math::MACHINE_EPSILON_100; // expect Degree angles to be between 0 and 999 } /** @@ -166,9 +166,9 @@ inline bool operator==( Radian lhs, Degree rhs ) * @param[in] rhs Degree to compare to * @return True if the values are not identical */ -inline bool operator!=( Radian lhs, Degree rhs ) +inline bool operator!=(Radian lhs, Degree rhs) { - return !( operator==( lhs, rhs ) ); + return !(operator==(lhs, rhs)); } /** @@ -179,9 +179,9 @@ inline bool operator!=( Radian lhs, Degree rhs ) * @param[in] rhs Radian to compare to * @return True if the values are identical */ -inline bool operator==( Degree lhs, Radian rhs ) +inline bool operator==(Degree lhs, Radian rhs) { - return fabsf( Radian( lhs ).radian - rhs.radian ) < Math::MACHINE_EPSILON_100; // expect Degree angles to be between 0 and 999 + return fabsf(Radian(lhs).radian - rhs.radian) < Math::MACHINE_EPSILON_100; // expect Degree angles to be between 0 and 999 } /** @@ -192,9 +192,9 @@ inline bool operator==( Degree lhs, Radian rhs ) * @param[in] rhs Radian to compare to * @return True if the values are not identical */ -inline bool operator!=( Degree lhs, Radian rhs ) +inline bool operator!=(Degree lhs, Radian rhs) { - return !( operator==( lhs, rhs ) ); + return !(operator==(lhs, rhs)); } /** @@ -205,7 +205,7 @@ inline bool operator!=( Degree lhs, Radian rhs ) * @param[in] rhs Radian to compare to * @return True if lhs is greater than rhs */ -inline bool operator>( Radian lhs, Radian rhs ) +inline bool operator>(Radian lhs, Radian rhs) { return lhs.radian > rhs.radian; } @@ -218,7 +218,7 @@ inline bool operator>( Radian lhs, Radian rhs ) * @param[in] rhs Degree to compare to * @return True if lhs is greater than rhs */ -inline bool operator>( Radian lhs, Degree rhs ) +inline bool operator>(Radian lhs, Degree rhs) { return lhs.radian > Radian(rhs).radian; } @@ -231,7 +231,7 @@ inline bool operator>( Radian lhs, Degree rhs ) * @param[in] rhs Degree to compare to * @return True if lhs is greater than rhs */ -inline bool operator>( Degree lhs, Radian rhs ) +inline bool operator>(Degree lhs, Radian rhs) { return Radian(lhs).radian > rhs.radian; } @@ -244,7 +244,7 @@ inline bool operator>( Degree lhs, Radian rhs ) * @param[in] rhs Radian to compare to * @return True if lhs is less than rhs */ -inline bool operator<( Radian lhs, Radian rhs ) +inline bool operator<(Radian lhs, Radian rhs) { return lhs.radian < rhs.radian; } @@ -257,7 +257,7 @@ inline bool operator<( Radian lhs, Radian rhs ) * @param[in] rhs Degree to compare to * @return True if lhs is less than rhs */ -inline bool operator<( Radian lhs, Degree rhs ) +inline bool operator<(Radian lhs, Degree rhs) { return lhs.radian < Radian(rhs).radian; } @@ -270,7 +270,7 @@ inline bool operator<( Radian lhs, Degree rhs ) * @param[in] rhs Radian to compare to * @return True if lhs is less than rhs */ -inline bool operator<( Degree lhs, Radian rhs ) +inline bool operator<(Degree lhs, Radian rhs) { return Radian(lhs).radian < rhs.radian; } @@ -283,9 +283,9 @@ inline bool operator<( Degree lhs, Radian rhs ) * @param[in] rhs float to multiply * @return Result of the multiplication */ -inline Radian operator*( Radian lhs, float rhs ) +inline Radian operator*(Radian lhs, float rhs) { - return Radian( lhs.radian * rhs ); + return Radian(lhs.radian * rhs); } /** @@ -294,9 +294,9 @@ inline Radian operator*( Radian lhs, float rhs ) * @param[in] in Radian to negate * @return The negative angle */ -inline Radian operator-( Radian in ) +inline Radian operator-(Radian in) { - return Radian( -in.radian ); + return Radian(-in.radian); } /** @@ -307,24 +307,24 @@ inline Radian operator-( Radian in ) * @param max value * @return The resulting radian */ -inline Radian Clamp( Radian angle, float min, float max ) +inline Radian Clamp(Radian angle, float min, float max) { - return Radian( Clamp( angle.radian, min, max ) ); + return Radian(Clamp(angle.radian, min, max)); } // useful constant angles -inline constexpr Radian ANGLE_360( Math::PI * 2.f ); -inline constexpr Radian ANGLE_315( Math::PI * 1.75f ); -inline constexpr Radian ANGLE_270( Math::PI * 1.5f ); -inline constexpr Radian ANGLE_225( Math::PI * 1.25f ); -inline constexpr Radian ANGLE_180( Math::PI ); -inline constexpr Radian ANGLE_135( Math::PI * 0.75f ); -inline constexpr Radian ANGLE_120( Math::PI * 2.f/3.f ); -inline constexpr Radian ANGLE_90 ( Math::PI_2 ); -inline constexpr Radian ANGLE_60 ( Math::PI / 3.f ); -inline constexpr Radian ANGLE_45 ( Math::PI_4 ); -inline constexpr Radian ANGLE_30 ( Math::PI / 6.f ); -inline constexpr Radian ANGLE_0 ( 0.0f ); +inline constexpr Radian ANGLE_360(Math::PI * 2.f); +inline constexpr Radian ANGLE_315(Math::PI * 1.75f); +inline constexpr Radian ANGLE_270(Math::PI * 1.5f); +inline constexpr Radian ANGLE_225(Math::PI * 1.25f); +inline constexpr Radian ANGLE_180(Math::PI); +inline constexpr Radian ANGLE_135(Math::PI * 0.75f); +inline constexpr Radian ANGLE_120(Math::PI * 2.f / 3.f); +inline constexpr Radian ANGLE_90(Math::PI_2); +inline constexpr Radian ANGLE_60(Math::PI / 3.f); +inline constexpr Radian ANGLE_45(Math::PI_4); +inline constexpr Radian ANGLE_30(Math::PI / 6.f); +inline constexpr Radian ANGLE_0(0.0f); /** * @} diff --git a/dali/public-api/math/random.h b/dali/public-api/math/random.h index c9d5377..b422cc1 100644 --- a/dali/public-api/math/random.h +++ b/dali/public-api/math/random.h @@ -2,7 +2,7 @@ #define DALI_RANDOM_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -34,7 +34,6 @@ namespace Dali */ namespace Random { - /** * @brief Returns a random number between f0 and f1. * @@ -51,16 +50,16 @@ inline float Range(float f0, float f1) // Ensure we initialize only once. As it's inlined, this static variable will exist in the code-block using it, thus, // will be created and then initialized again when another code-block uses this. - static bool initialized( false ); - if( !initialized ) + static bool initialized(false); + if(!initialized) { - uint32_t seed = static_cast( time( nullptr ) ); - srand( seed ); + uint32_t seed = static_cast(time(nullptr)); + srand(seed); initialized = true; } int32_t randValue = rand(); - return static_cast(randValue & 0xfff) * (1.0f/4095.0f) * (max-min) + min; + return static_cast(randValue & 0xfff) * (1.0f / 4095.0f) * (max - min) + min; } /** @@ -77,10 +76,10 @@ inline Vector4 Axis() do { axis.x = Range(-1.0f, 1.0f); - axis.y = Range( 0.0f, 1.0f); - axis.z = Range( 0.0f, 1.0f); + axis.y = Range(0.0f, 1.0f); + axis.z = Range(0.0f, 1.0f); axis.w = 0.0f; - } while (axis == Vector4::ZERO); + } while(axis == Vector4::ZERO); axis.Normalize(); return axis; } diff --git a/dali/public-api/math/rect.cpp b/dali/public-api/math/rect.cpp index 94bd0c6..9c3499a 100644 --- a/dali/public-api/math/rect.cpp +++ b/dali/public-api/math/rect.cpp @@ -23,4 +23,3 @@ namespace Dali // Ensure Rect is maintained as a trivially copyable type static_assert(std::is_trivially_copyable>::value); } // namespace Dali - diff --git a/dali/public-api/math/rect.h b/dali/public-api/math/rect.h index 3de2dd0..fcf5b17 100644 --- a/dali/public-api/math/rect.h +++ b/dali/public-api/math/rect.h @@ -36,10 +36,10 @@ namespace Dali * @brief Template class to create and operate on rectangles. * @SINCE_1_0.0 */ -template< typename T = float > +template struct Rect { -// Methods + // Methods /** * @brief Constructor. @@ -76,7 +76,7 @@ struct Rect * @SINCE_1_9.14 * @param[in] vec4 Vector4 to convert from */ - Rect( const Vector4& vec4 ) + Rect(const Vector4& vec4) : x(vec4.x), y(vec4.y), width(vec4.z), @@ -90,7 +90,7 @@ struct Rect * @SINCE_1_9.27 * @param[in] rhs The original object */ - Rect( const Rect& rhs ) = default; + Rect(const Rect& rhs) = default; /** * @brief Default copy assignment operator. @@ -99,7 +99,7 @@ struct Rect * @param[in] rhs The original object * @return Reference to this */ - Rect& operator=( const Rect& rhs ) = default; + Rect& operator=(const Rect& rhs) = default; /** * @brief Default move constructor. @@ -107,7 +107,7 @@ struct Rect * @SINCE_1_9.27 * @param[in] rhs The original object */ - Rect( Rect&& rhs ) = default; + Rect(Rect&& rhs) = default; /** * @brief Default move assignment operator. @@ -116,7 +116,7 @@ struct Rect * @param[in] rhs The original object * @return Reference to this */ - Rect& operator=( Rect&& rhs ) = default; + Rect& operator=(Rect&& rhs) = default; /** * @brief Assignment operator. @@ -127,9 +127,9 @@ struct Rect */ Rect& operator=(const Vector4& vec4) { - x = vec4.x; - y = vec4.y; - width = vec4.z; + x = vec4.x; + y = vec4.y; + width = vec4.z; height = vec4.w; return *this; @@ -146,9 +146,9 @@ struct Rect */ void Set(T newX, T newY, T newWidth, T newHeight) { - x = newX; - y = newY; - width = newWidth; + x = newX; + y = newY; + width = newWidth; height = newHeight; } @@ -160,8 +160,8 @@ struct Rect */ bool IsEmpty() const { - return width == 0 || - height == 0; + return width == 0 || + height == 0; } /** @@ -239,7 +239,7 @@ struct Rect bool Intersects(const Rect& other) const { return (other.x + other.width) > x && other.x < (x + width) && - (other.y + other.height) > y && other.y < (y + height); + (other.y + other.height) > y && other.y < (y + height); } /** @@ -252,18 +252,18 @@ struct Rect */ bool Intersect(const Rect& rect) { - const int left = std::max(rect.x, x); - const int top = std::max(rect.y, y); - const int right = std::min(rect.x + rect.width, x + width); + const int left = std::max(rect.x, x); + const int top = std::max(rect.y, y); + const int right = std::min(rect.x + rect.width, x + width); const int bottom = std::min(rect.y + rect.height, y + height); - const int width = right - left; + const int width = right - left; const int height = bottom - top; - if (!(width < 0 || height < 0)) + if(!(width < 0 || height < 0)) { - x = left; - y = top; - this->width = width; + x = left; + y = top; + this->width = width; this->height = height; return true; } @@ -280,14 +280,14 @@ struct Rect */ void Merge(const Rect& rect) { - const int left = std::min(rect.x, x); - const int top = std::min(rect.y, y); - const int right = std::max(rect.x + rect.width, x + width); + const int left = std::min(rect.x, x); + const int top = std::min(rect.y, y); + const int right = std::max(rect.x + rect.width, x + width); const int bottom = std::max(rect.y + rect.height, y + height); - x = left; - y = top; - width = right - left; - height = bottom - top; + x = left; + y = top; + width = right - left; + height = bottom - top; } /** @@ -298,14 +298,14 @@ struct Rect */ void Inset(T dx, T dy) { - const int left = x - dx; - const int top = y - dy; - const int right = x + width + dx; + const int left = x - dx; + const int top = y - dy; + const int right = x + width + dx; const int bottom = y + height + dy; - x = left; - y = top; - width = right - left; - height = bottom - top; + x = left; + y = top; + width = right - left; + height = bottom - top; } /** @@ -317,22 +317,21 @@ struct Rect */ bool Contains(const Rect& other) const { - return other.x >= x && (other.x + other.width) <= (x + width) && - other.y >= y && (other.y + other.height) <= (y + height); + return other.x >= x && (other.x + other.width) <= (x + width) && + other.y >= y && (other.y + other.height) <= (y + height); } -public: // Data - +public: // Data union { - T x; ///< X position of the rectangle - T left; ///< The left value + T x; ///< X position of the rectangle + T left; ///< The left value }; union { - T y; ///< Y position of the rectangle - T right; ///< The right value + T y; ///< Y position of the rectangle + T right; ///< The right value }; union @@ -356,13 +355,13 @@ public: // Data * @param[in] rhs Second operand * @return True if boxes are exactly same */ -template< typename T > -inline bool operator==( const Rect& lhs, const Rect& rhs ) +template +inline bool operator==(const Rect& lhs, const Rect& rhs) { - return ( lhs.x == rhs.x )&& - ( lhs.y == rhs.y )&& - ( lhs.width == rhs.width )&& - ( lhs.height == rhs.height ); + return (lhs.x == rhs.x) && + (lhs.y == rhs.y) && + (lhs.width == rhs.width) && + (lhs.height == rhs.height); } /** @@ -373,8 +372,8 @@ inline bool operator==( const Rect& lhs, const Rect& rhs ) * @param[in] rhs The second rectangle * @return True if rectangles are not identical */ -template< typename T > -inline bool operator!=( const Rect& lhs, const Rect& rhs ) +template +inline bool operator!=(const Rect& lhs, const Rect& rhs) { return !(lhs == rhs); } @@ -388,12 +387,12 @@ inline bool operator!=( const Rect& lhs, const Rect& rhs ) * @return True if rectangles are exactly same */ template<> -inline bool operator==( const Rect& lhs, const Rect& rhs ) +inline bool operator==(const Rect& lhs, const Rect& rhs) { - return ( fabsf( lhs.x - rhs.x ) < GetRangedEpsilon(lhs.x, rhs.x) )&& - ( fabsf( lhs.y - rhs.y ) < GetRangedEpsilon(lhs.y, rhs.y) )&& - ( fabsf( lhs.width - rhs.width ) < GetRangedEpsilon(lhs.width, rhs.width) )&& - ( fabsf( lhs.height - rhs.height ) < GetRangedEpsilon(lhs.height, rhs.height) ); + return (fabsf(lhs.x - rhs.x) < GetRangedEpsilon(lhs.x, rhs.x)) && + (fabsf(lhs.y - rhs.y) < GetRangedEpsilon(lhs.y, rhs.y)) && + (fabsf(lhs.width - rhs.width) < GetRangedEpsilon(lhs.width, rhs.width)) && + (fabsf(lhs.height - rhs.height) < GetRangedEpsilon(lhs.height, rhs.height)); } /** @@ -405,8 +404,7 @@ inline bool operator==( const Rect& lhs, const Rect& rhs ) template<> inline bool Rect::IsEmpty() const { - return (fabsf(width) <= GetRangedEpsilon(width, width) - || + return (fabsf(width) <= GetRangedEpsilon(width, width) || fabsf(height) <= GetRangedEpsilon(height, height)); } @@ -418,8 +416,8 @@ inline bool Rect::IsEmpty() const * @param[in] rectangle the rectangle to output * @return The output stream operator */ -template< typename T > -inline std::ostream& operator<< (std::ostream& stream, const Rect& rectangle) +template +inline std::ostream& operator<<(std::ostream& stream, const Rect& rectangle) { return stream << "[" << rectangle.x << ", " << rectangle.y << ", " << rectangle.width << ", " << rectangle.height << "]"; } diff --git a/dali/public-api/math/uint-16-pair.h b/dali/public-api/math/uint-16-pair.h index 861d073..e3d9f49 100644 --- a/dali/public-api/math/uint-16-pair.h +++ b/dali/public-api/math/uint-16-pair.h @@ -49,7 +49,10 @@ public: * @brief Default constructor for the (0, 0) tuple. * @SINCE_1_0.0 */ - Uint16Pair() : mData(0) {} + Uint16Pair() + : mData(0) + { + } /** * @brief Constructor taking separate x and y (width and height) parameters. @@ -57,10 +60,10 @@ public: * @param[in] width The width or X dimension of the tuple. Make sure it is less than 65536 * @param[in] height The height or Y dimension of the tuple. Make sure it is less than 65536 */ - Uint16Pair( uint32_t width, uint32_t height ) + Uint16Pair(uint32_t width, uint32_t height) { - DALI_ASSERT_DEBUG( width < ( 1u << 16 ) && "Width parameter not representable." ); - DALI_ASSERT_DEBUG( height < ( 1u << 16 ) && "Height parameter not representable." ); + DALI_ASSERT_DEBUG(width < (1u << 16) && "Width parameter not representable."); + DALI_ASSERT_DEBUG(height < (1u << 16) && "Height parameter not representable."); /* Do equivalent of the code below with one aligned memory access: * mComponents[0] = width; @@ -75,7 +78,7 @@ public: * @SINCE_1_1.13 * @param[in] width The x dimension to be stored in this 2-tuple */ - void SetWidth( uint16_t width ) + void SetWidth(uint16_t width) { mComponents[0] = width; } @@ -95,7 +98,7 @@ public: * @SINCE_1_1.13 * @param[in] height The y dimension to be stored in this 2-tuple */ - void SetHeight( uint16_t height ) + void SetHeight(uint16_t height) { mComponents[1] = height; } @@ -115,7 +118,7 @@ public: * @SINCE_1_1.14 * @param[in] x The x dimension to be stored in this 2-tuple */ - void SetX( uint16_t x ) + void SetX(uint16_t x) { mComponents[0] = x; } @@ -125,7 +128,7 @@ public: * @SINCE_1_0.0 * @return X */ - uint16_t GetX() const + uint16_t GetX() const { return mComponents[0]; } @@ -135,7 +138,7 @@ public: * @SINCE_1_1.14 * @param[in] y The y dimension to be stored in this 2-tuple */ - void SetY( uint16_t y ) + void SetY(uint16_t y) { mComponents[1] = y; } @@ -156,7 +159,7 @@ public: * @param[in] rhs A reference for comparison * @return True if same */ - bool operator==( const Uint16Pair& rhs ) const + bool operator==(const Uint16Pair& rhs) const { return mData == rhs.mData; } @@ -167,7 +170,7 @@ public: * @param[in] rhs A reference for comparison * @return True if different */ - bool operator!=( const Uint16Pair& rhs ) const + bool operator!=(const Uint16Pair& rhs) const { return mData != rhs.mData; } @@ -179,7 +182,7 @@ public: * @param[in] rhs A reference for comparison * @return True if less */ - bool operator<( const Uint16Pair& rhs ) const + bool operator<(const Uint16Pair& rhs) const { return mData < rhs.mData; } @@ -191,7 +194,7 @@ public: * @param[in] rhs A reference for comparison * @return True if greater */ - bool operator>( const Uint16Pair& rhs ) const + bool operator>(const Uint16Pair& rhs) const { return mData > rhs.mData; } @@ -207,11 +210,11 @@ public: * @return Closest integer value */ template - static Uint16Pair FromFloatVec2( const FLOAT_VECTOR_N_TYPE& from ) + static Uint16Pair FromFloatVec2(const FLOAT_VECTOR_N_TYPE& from) { - DALI_ASSERT_DEBUG( from.x + 0.5f < 65536.0f ); - DALI_ASSERT_DEBUG( from.y + 0.5f < 65536.0f ); - return Uint16Pair( from.x + 0.5f, from.y + 0.5f ); + DALI_ASSERT_DEBUG(from.x + 0.5f < 65536.0f); + DALI_ASSERT_DEBUG(from.y + 0.5f < 65536.0f); + return Uint16Pair(from.x + 0.5f, from.y + 0.5f); } /** @@ -225,19 +228,18 @@ public: * @return Closest integer value */ template - static Uint16Pair FromFloatArray( const FLOAT_ARRAY& from ) + static Uint16Pair FromFloatArray(const FLOAT_ARRAY& from) { - DALI_ASSERT_DEBUG( from[0] + 0.5f < 65536.0f ); - DALI_ASSERT_DEBUG( from[1] + 0.5f < 65536.0f ); - return Uint16Pair( from[0] + 0.5f, from[1] + 0.5f ); + DALI_ASSERT_DEBUG(from[0] + 0.5f < 65536.0f); + DALI_ASSERT_DEBUG(from[1] + 0.5f < 65536.0f); + return Uint16Pair(from[0] + 0.5f, from[1] + 0.5f); } public: - - Uint16Pair( const Uint16Pair& ) = default; ///< Default copy constructor - Uint16Pair( Uint16Pair&& ) = default; ///< Default move constructor - Uint16Pair& operator=( const Uint16Pair& ) = default; ///< Default copy assignment operator - Uint16Pair& operator=( Uint16Pair&& ) = default; ///< Default move assignment operator + Uint16Pair(const Uint16Pair&) = default; ///< Default copy constructor + Uint16Pair(Uint16Pair&&) = default; ///< Default move constructor + Uint16Pair& operator=(const Uint16Pair&) = default; ///< Default copy assignment operator + Uint16Pair& operator=(Uint16Pair&&) = default; ///< Default move assignment operator private: union @@ -250,7 +252,14 @@ private: }; // Allow Uint16Pair to be treated as a POD type -template <> struct TypeTraits< Uint16Pair > : public BasicTypes< Uint16Pair > { enum { IS_TRIVIAL_TYPE = true }; }; +template<> +struct TypeTraits : public BasicTypes +{ + enum + { + IS_TRIVIAL_TYPE = true + }; +}; /** * @} diff --git a/dali/public-api/math/vector2.cpp b/dali/public-api/math/vector2.cpp index 678a90f..6cbd122 100644 --- a/dali/public-api/math/vector2.cpp +++ b/dali/public-api/math/vector2.cpp @@ -23,15 +23,14 @@ #include // INTERNAL INCLUDES +#include #include -#include #include #include -#include +#include namespace Dali { - const Vector2 Vector2::ONE(1.0f, 1.0f); const Vector2 Vector2::XAXIS(1.0f, 0.0f); const Vector2 Vector2::YAXIS(0.0f, 1.0f); @@ -73,14 +72,13 @@ Vector2& Vector2::operator=(const Vector4& rhs) return *this; } - bool Vector2::operator==(const Vector2& rhs) const { - if (fabsf(x - rhs.x) > GetRangedEpsilon(x, rhs.x)) + if(fabsf(x - rhs.x) > GetRangedEpsilon(x, rhs.x)) { return false; } - if (fabsf(y - rhs.y) > GetRangedEpsilon(y, rhs.y)) + if(fabsf(y - rhs.y) > GetRangedEpsilon(y, rhs.y)) { return false; } @@ -95,15 +93,15 @@ float Vector2::Length() const float Vector2::LengthSquared() const { - return (x*x) + (y*y); + return (x * x) + (y * y); } void Vector2::Normalize() { float length = Length(); - if( ! EqualsZero(length) ) + if(!EqualsZero(length)) { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,2); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 2); const float inverseLength = 1.0f / length; x *= inverseLength; @@ -111,21 +109,21 @@ void Vector2::Normalize() } } -void Vector2::Clamp( const Vector2& min, const Vector2& max ) +void Vector2::Clamp(const Vector2& min, const Vector2& max) { - Dali::ClampInPlace( x, min.x, max.x ); - Dali::ClampInPlace( y, min.y, max.y ); + Dali::ClampInPlace(x, min.x, max.x); + Dali::ClampInPlace(y, min.y, max.y); } -std::ostream& operator<< (std::ostream& o, const Vector2& vector) +std::ostream& operator<<(std::ostream& o, const Vector2& vector) { return o << "[" << vector.x << ", " << vector.y << "]"; } -Vector2 Clamp( const Vector2& v, const float& min, const float& max ) +Vector2 Clamp(const Vector2& v, const float& min, const float& max) { - Vector2 result( v ); - result.Clamp( Vector2( min, min ) , Vector2( max, max ) ); + Vector2 result(v); + result.Clamp(Vector2(min, min), Vector2(max, max)); return result; } diff --git a/dali/public-api/math/vector2.h b/dali/public-api/math/vector2.h index 7921719..1fae077 100644 --- a/dali/public-api/math/vector2.h +++ b/dali/public-api/math/vector2.h @@ -28,7 +28,6 @@ namespace Dali { - class Uint16Pair; /** @@ -45,12 +44,11 @@ struct Vector4; */ struct DALI_CORE_API Vector2 { -// (x width) and (y height) must be consecutive in memory. -// No other data must be added before (x width) member. -// No virtual methods must be added to this struct. + // (x width) and (y height) must be consecutive in memory. + // No other data must be added before (x width) member. + // No virtual methods must be added to this struct. public: - /** * @brief Constructor. * @SINCE_1_0.0 @@ -69,7 +67,8 @@ public: * @param[in] y y or height component */ explicit constexpr Vector2(float x, float y) - : x(x), y(y) + : x(x), + y(y) { } @@ -110,16 +109,16 @@ public: */ Vector2(const Uint16Pair& pair); -// Constants + // Constants - static const Vector2 ONE; ///< (1.0f,1.0f) - static const Vector2 XAXIS; ///< Vector representing the X axis - static const Vector2 YAXIS; ///< Vector representing the Y axis - static const Vector2 NEGATIVE_XAXIS; ///< Vector representing the negative X axis - static const Vector2 NEGATIVE_YAXIS; ///< Vector representing the negative Y axis - static const Vector2 ZERO; ///< (0.0f, 0.0f) + static const Vector2 ONE; ///< (1.0f,1.0f) + static const Vector2 XAXIS; ///< Vector representing the X axis + static const Vector2 YAXIS; ///< Vector representing the Y axis + static const Vector2 NEGATIVE_XAXIS; ///< Vector representing the negative X axis + static const Vector2 NEGATIVE_YAXIS; ///< Vector representing the negative Y axis + static const Vector2 ZERO; ///< (0.0f, 0.0f) -// API + // API /** * @brief Assignment operator. @@ -290,7 +289,6 @@ public: return Vector2(x / rhs, y / rhs); } - /** * @brief Division assignment operator. * @@ -369,7 +367,7 @@ public: */ const float& operator[](const uint32_t index) const { - DALI_ASSERT_ALWAYS( index < 2 && "Vector element index out of bounds" ); + DALI_ASSERT_ALWAYS(index < 2 && "Vector element index out of bounds"); return AsFloat()[index]; } @@ -384,7 +382,7 @@ public: */ float& operator[](const uint32_t index) { - DALI_ASSERT_ALWAYS( index < 2 && "Vector element index out of bounds" ); + DALI_ASSERT_ALWAYS(index < 2 && "Vector element index out of bounds"); return AsFloat()[index]; } @@ -421,7 +419,7 @@ public: * @param[in] min The minimum vector * @param[in] max The maximum vector */ - void Clamp( const Vector2& min, const Vector2& max ); + void Clamp(const Vector2& min, const Vector2& max); /** * @brief Returns the contents of the vector as an array of 2 floats. @@ -433,7 +431,10 @@ public: * @return The vector contents as an array of 2 floats * @note inlined for performance reasons (generates less code than a function call) */ - const float* AsFloat() const {return &x;} + const float* AsFloat() const + { + return &x; + } /** * @brief Returns the contents of the vector as an array of 2 floats. @@ -445,17 +446,18 @@ public: * @return The vector contents as an array of 2 floats * @note inlined for performance reasons (generates less code than a function call) */ - float* AsFloat() {return &x;} + float* AsFloat() + { + return &x; + } public: - - Vector2( const Vector2& ) = default; ///< Default copy constructor - Vector2( Vector2&& ) = default; ///< Default move constructor - Vector2& operator=( const Vector2& ) = default; ///< Default copy assignment operator - Vector2& operator=( Vector2&& ) = default; ///< Default move assignment operator + Vector2(const Vector2&) = default; ///< Default copy constructor + Vector2(Vector2&&) = default; ///< Default move constructor + Vector2& operator=(const Vector2&) = default; ///< Default copy assignment operator + Vector2& operator=(Vector2&&) = default; ///< Default move assignment operator public: // Data - // NOTE // (x width) and (y height) must be consecutive in memory. // No other data must be added before (x width) member. @@ -471,7 +473,6 @@ public: // Data float y; ///< y component float height; ///< height }; - }; /** @@ -488,7 +489,7 @@ using Size = Vector2; * @param[in] vector The vector to print * @return The output stream operator */ -DALI_CORE_API std::ostream& operator<< (std::ostream& o, const Vector2& vector); +DALI_CORE_API std::ostream& operator<<(std::ostream& o, const Vector2& vector); /** * @brief Returns a vector with components set to the minimum of the corresponding component in a and b. @@ -499,9 +500,9 @@ DALI_CORE_API std::ostream& operator<< (std::ostream& o, const Vector2& vector); * @param[in] b A vector * @return A vector containing the minimum of each component from a and b */ -inline Vector2 Min( const Vector2& a, const Vector2& b ) +inline Vector2 Min(const Vector2& a, const Vector2& b) { - return Vector2( a.x < b.x ? a.x : b.x , a.y < b.y ? a.y : b.y ); + return Vector2(a.x < b.x ? a.x : b.x, a.y < b.y ? a.y : b.y); } /** @@ -513,9 +514,9 @@ inline Vector2 Min( const Vector2& a, const Vector2& b ) * @param[in] b A vector * @return A vector containing the maximum of each component from a and b */ -inline Vector2 Max( const Vector2& a, const Vector2& b ) +inline Vector2 Max(const Vector2& a, const Vector2& b) { - return Vector2( a.x > b.x ? a.x : b.x , a.y > b.y ? a.y : b.y ); + return Vector2(a.x > b.x ? a.x : b.x, a.y > b.y ? a.y : b.y); } /** @@ -527,10 +528,17 @@ inline Vector2 Max( const Vector2& a, const Vector2& b ) * @param[in] max The maximum value * @return A vector containing the clamped components of v */ -DALI_CORE_API Vector2 Clamp( const Vector2& v, const float& min, const float& max ); +DALI_CORE_API Vector2 Clamp(const Vector2& v, const float& min, const float& max); // Allow Vector2 to be treated as a POD type -template <> struct TypeTraits< Vector2 > : public BasicTypes< Vector2 > { enum { IS_TRIVIAL_TYPE = true }; }; +template<> +struct TypeTraits : public BasicTypes +{ + enum + { + IS_TRIVIAL_TYPE = true + }; +}; /** * @} diff --git a/dali/public-api/math/vector3.cpp b/dali/public-api/math/vector3.cpp index 2b410d0..8e621e8 100644 --- a/dali/public-api/math/vector3.cpp +++ b/dali/public-api/math/vector3.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -16,19 +16,19 @@ */ // CLASS HEADER -#include #include +#include // EXTERNAL INCLUDES #include #include // INTERNAL INCLUDES +#include #include +#include #include #include -#include -#include namespace Dali { @@ -43,14 +43,14 @@ const Vector3 Vector3::NEGATIVE_YAXIS(0.0f, -1.0f, 0.0f); const Vector3 Vector3::NEGATIVE_ZAXIS(0.0f, 0.0f, -1.0f); const Vector3 Vector3::ZERO(0.0f, 0.0f, 0.0f); -Vector3::Vector3( const Vector2& vec2 ) +Vector3::Vector3(const Vector2& vec2) : x(vec2.x), y(vec2.y), z(0.0f) { } -Vector3::Vector3( const Vector4& vec4 ) +Vector3::Vector3(const Vector4& vec4) : x(vec4.x), y(vec4.y), z(vec4.z) @@ -80,13 +80,13 @@ Vector3& Vector3::operator*=(const Quaternion& rhs) // nVidia SDK implementation Vector3 qvec(rhs.mVector.x, rhs.mVector.y, rhs.mVector.z); - Vector3 uv( (qvec.y * z) - (qvec.z * y), - (qvec.z * x) - (qvec.x * z), - (qvec.x * y) - (qvec.y * x) ); + Vector3 uv((qvec.y * z) - (qvec.z * y), + (qvec.z * x) - (qvec.x * z), + (qvec.x * y) - (qvec.y * x)); - Vector3 uuv( (qvec.y * uv.z) - (qvec.z * uv.y), - (qvec.z * uv.x) - (qvec.x * uv.z), - (qvec.x * uv.y) - (qvec.y * uv.x) ); + Vector3 uuv((qvec.y * uv.z) - (qvec.z * uv.y), + (qvec.z * uv.x) - (qvec.x * uv.z), + (qvec.x * uv.y) - (qvec.y * uv.x)); uv *= rhs.mVector.w; @@ -99,15 +99,15 @@ Vector3& Vector3::operator*=(const Quaternion& rhs) bool Vector3::operator==(const Vector3& rhs) const { - if (fabsf(x - rhs.x) > GetRangedEpsilon(x, rhs.x) ) + if(fabsf(x - rhs.x) > GetRangedEpsilon(x, rhs.x)) { return false; } - if (fabsf(y - rhs.y) > GetRangedEpsilon(y, rhs.y) ) + if(fabsf(y - rhs.y) > GetRangedEpsilon(y, rhs.y)) { return false; } - if (fabsf(z - rhs.z) > GetRangedEpsilon(z, rhs.z) ) + if(fabsf(z - rhs.z) > GetRangedEpsilon(z, rhs.z)) { return false; } @@ -115,42 +115,42 @@ bool Vector3::operator==(const Vector3& rhs) const return true; } -float Vector3::Dot(const Vector3 &other) const +float Vector3::Dot(const Vector3& other) const { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,3); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 3); return x * other.x + y * other.y + z * other.z; } -Vector3 Vector3::Cross(const Vector3 &other) const +Vector3 Vector3::Cross(const Vector3& other) const { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,6); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 6); - return Vector3( (y * other.z) - (z * other.y), - (z * other.x) - (x * other.z), - (x * other.y) - (y * other.x)); + return Vector3((y * other.z) - (z * other.y), + (z * other.x) - (x * other.z), + (x * other.y) - (y * other.x)); } float Vector3::Length() const { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,3); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 3); - return sqrtf(x*x + y*y + z*z); + return sqrtf(x * x + y * y + z * z); } float Vector3::LengthSquared() const { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,3); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 3); - return x*x + y*y + z*z; + return x * x + y * y + z * z; } void Vector3::Normalize() { float length = Length(); - if( ! EqualsZero(length) ) + if(!EqualsZero(length)) { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,3); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 3); const float inverseLength = 1.0f / length; x *= inverseLength; @@ -159,22 +159,22 @@ void Vector3::Normalize() } } -void Vector3::Clamp( const Vector3& min, const Vector3& max ) +void Vector3::Clamp(const Vector3& min, const Vector3& max) { - Dali::ClampInPlace( x, min.x, max.x ); - Dali::ClampInPlace( y, min.y, max.y ); - Dali::ClampInPlace( z, min.z, max.z ); + Dali::ClampInPlace(x, min.x, max.x); + Dali::ClampInPlace(y, min.y, max.y); + Dali::ClampInPlace(z, min.z, max.z); } -std::ostream& operator<< (std::ostream& o, const Vector3& vector) +std::ostream& operator<<(std::ostream& o, const Vector3& vector) { return o << "[" << vector.x << ", " << vector.y << ", " << vector.z << "]"; } -Vector3 Clamp( const Vector3& v, const float& min, const float& max ) +Vector3 Clamp(const Vector3& v, const float& min, const float& max) { - Vector3 result( v ); - result.Clamp( Vector3( min, min, min ) , Vector3( max, max, max ) ); + Vector3 result(v); + result.Clamp(Vector3(min, min, min), Vector3(max, max, max)); return result; } diff --git a/dali/public-api/math/vector3.h b/dali/public-api/math/vector3.h index 97775f0..4c1ad7f 100644 --- a/dali/public-api/math/vector3.h +++ b/dali/public-api/math/vector3.h @@ -43,7 +43,7 @@ class Quaternion; */ struct DALI_CORE_API Vector3 { -// Construction + // Construction /** * @brief Constructor. @@ -94,7 +94,7 @@ struct DALI_CORE_API Vector3 * @SINCE_1_0.0 * @param[in] vec2 Vector2 to create this vector from */ - explicit Vector3( const Vector2& vec2 ); + explicit Vector3(const Vector2& vec2); /** * @brief Constructor. @@ -102,20 +102,20 @@ struct DALI_CORE_API Vector3 * @SINCE_1_0.0 * @param[in] vec4 Vector4 to create this vector from */ - explicit Vector3( const Vector4& vec4 ); + explicit Vector3(const Vector4& vec4); -// Constants + // Constants - static const Vector3 ONE; ///< (1.0f,1.0f,1.0f) - static const Vector3 XAXIS; ///< Vector representing the X axis - static const Vector3 YAXIS; ///< Vector representing the Y axis - static const Vector3 ZAXIS; ///< Vector representing the Z axis - static const Vector3 NEGATIVE_XAXIS; ///< Vector representing the negative X axis - static const Vector3 NEGATIVE_YAXIS; ///< Vector representing the negative Y axis - static const Vector3 NEGATIVE_ZAXIS; ///< Vector representing the negative Z axis - static const Vector3 ZERO; ///< (0.0f, 0.0f, 0.0f) + static const Vector3 ONE; ///< (1.0f,1.0f,1.0f) + static const Vector3 XAXIS; ///< Vector representing the X axis + static const Vector3 YAXIS; ///< Vector representing the Y axis + static const Vector3 ZAXIS; ///< Vector representing the Z axis + static const Vector3 NEGATIVE_XAXIS; ///< Vector representing the negative X axis + static const Vector3 NEGATIVE_YAXIS; ///< Vector representing the negative Y axis + static const Vector3 NEGATIVE_ZAXIS; ///< Vector representing the negative Z axis + static const Vector3 ZERO; ///< (0.0f, 0.0f, 0.0f) -// API + // API /** * @brief Assignment operator. @@ -385,7 +385,7 @@ struct DALI_CORE_API Vector3 */ const float& operator[](const uint32_t index) const { - DALI_ASSERT_ALWAYS( index < 3 && "Vector element index out of bounds" ); + DALI_ASSERT_ALWAYS(index < 3 && "Vector element index out of bounds"); return AsFloat()[index]; } @@ -400,7 +400,7 @@ struct DALI_CORE_API Vector3 */ float& operator[](const uint32_t index) { - DALI_ASSERT_ALWAYS( index < 3 && "Vector element index out of bounds" ); + DALI_ASSERT_ALWAYS(index < 3 && "Vector element index out of bounds"); return AsFloat()[index]; } @@ -461,7 +461,7 @@ struct DALI_CORE_API Vector3 * @param[in] min The minimum vector * @param[in] max The maximum vector */ - void Clamp( const Vector3& min, const Vector3& max ); + void Clamp(const Vector3& min, const Vector3& max); /** * @brief Returns the contents of the vector as an array of 3 floats. @@ -474,7 +474,10 @@ struct DALI_CORE_API Vector3 * @return The vector contents as an array of 3 floats * @note inlined for performance reasons (generates less code than a function call) */ - const float* AsFloat() const {return &x;} + const float* AsFloat() const + { + return &x; + } /** * @brief Returns the contents of the vector as an array of 3 floats. @@ -487,7 +490,10 @@ struct DALI_CORE_API Vector3 * @return The vector contents as an array of 3 floats * @note inlined for performance reasons (generates less code than a function call) */ - float* AsFloat() {return &x;} + float* AsFloat() + { + return &x; + } /** * @brief Returns the x & y components (or width & height, or r & g) as a Vector2. @@ -496,7 +502,10 @@ struct DALI_CORE_API Vector3 * @return The partial vector contents as Vector2 (x,y) * @note inlined for performance reasons (generates less code than a function call) */ - const Vector2& GetVectorXY() const {return reinterpret_cast(x);} + const Vector2& GetVectorXY() const + { + return reinterpret_cast(x); + } /** * @brief Returns the x & y components (or width & height, or r & g) as a Vector2. @@ -505,7 +514,10 @@ struct DALI_CORE_API Vector3 * @return The partial vector contents as Vector2 (x,y) * @note inlined for performance reasons (generates less code than a function call) */ - Vector2& GetVectorXY() {return reinterpret_cast(x);} + Vector2& GetVectorXY() + { + return reinterpret_cast(x); + } /** * @brief Returns the y & z components (or height & depth, or g & b) as a Vector2. @@ -514,7 +526,10 @@ struct DALI_CORE_API Vector3 * @return The partial vector contents as Vector2 (y,z) * @note inlined for performance reasons (generates less code than a function call) */ - const Vector2& GetVectorYZ() const {return reinterpret_cast(y);} + const Vector2& GetVectorYZ() const + { + return reinterpret_cast(y); + } /** * @brief Returns the y & z components (or height & depth, or g & b) as a Vector2. @@ -523,9 +538,12 @@ struct DALI_CORE_API Vector3 * @return The partial vector contents as Vector2 (y,z) * @note inlined for performance reasons (generates less code than a function call) */ - Vector2& GetVectorYZ() {return reinterpret_cast(y);} + Vector2& GetVectorYZ() + { + return reinterpret_cast(y); + } -// Data + // Data // NOTE // (x width r), (y height g), (z depth b) must be consecutive in memory. @@ -533,9 +551,9 @@ struct DALI_CORE_API Vector3 // No virtual methods must be added to this struct. union { - float x; ///< x component - float width; ///< width component - float r; ///< red component + float x; ///< x component + float width; ///< width component + float r; ///< red component }; union { @@ -545,17 +563,16 @@ struct DALI_CORE_API Vector3 }; union { - float z; ///< z component - float depth; ///< depth component - float b; ///< blue component + float z; ///< z component + float depth; ///< depth component + float b; ///< blue component }; public: - - Vector3( const Vector3& ) = default; ///< Default copy constructor - Vector3( Vector3&& ) = default; ///< Default move constructor - Vector3& operator=( const Vector3& ) = default; ///< Default copy assignment operator - Vector3& operator=( Vector3&& ) = default; ///< Default move assignment operator + Vector3(const Vector3&) = default; ///< Default copy constructor + Vector3(Vector3&&) = default; ///< Default move constructor + Vector3& operator=(const Vector3&) = default; ///< Default copy assignment operator + Vector3& operator=(Vector3&&) = default; ///< Default move assignment operator }; /** @@ -566,7 +583,7 @@ public: * @param[in] vector The vector to print * @return The output stream operator */ -DALI_CORE_API std::ostream& operator<< (std::ostream& o, const Vector3& vector); +DALI_CORE_API std::ostream& operator<<(std::ostream& o, const Vector3& vector); /** * @brief Returns a vector with components set to the minimum of the corresponding component in a and b. @@ -577,11 +594,11 @@ DALI_CORE_API std::ostream& operator<< (std::ostream& o, const Vector3& vector); * @param[in] b A vector * @return A vector containing the minimum of each component from a and b */ -inline Vector3 Min( const Vector3& a, const Vector3& b ) +inline Vector3 Min(const Vector3& a, const Vector3& b) { - return Vector3( a.x < b.x ? a.x : b.x , - a.y < b.y ? a.y : b.y, - a.z < b.z ? a.z : b.z ); + return Vector3(a.x < b.x ? a.x : b.x, + a.y < b.y ? a.y : b.y, + a.z < b.z ? a.z : b.z); } /** @@ -593,11 +610,11 @@ inline Vector3 Min( const Vector3& a, const Vector3& b ) * @param[in] b A vector * @return A vector containing the maximum of each component from a and b */ -inline Vector3 Max( const Vector3& a, const Vector3& b ) +inline Vector3 Max(const Vector3& a, const Vector3& b) { - return Vector3( a.x > b.x ? a.x : b.x, - a.y > b.y ? a.y : b.y, - a.z > b.z ? a.z : b.z ); + return Vector3(a.x > b.x ? a.x : b.x, + a.y > b.y ? a.y : b.y, + a.z > b.z ? a.z : b.z); } /** @@ -609,10 +626,17 @@ inline Vector3 Max( const Vector3& a, const Vector3& b ) * @param[in] max The maximum value * @return A vector containing the clamped components of v */ -DALI_CORE_API Vector3 Clamp( const Vector3& v, const float& min, const float& max ); +DALI_CORE_API Vector3 Clamp(const Vector3& v, const float& min, const float& max); // Allow Vector3 to be treated as a POD type -template <> struct TypeTraits< Vector3 > : public BasicTypes< Vector3 > { enum { IS_TRIVIAL_TYPE = true }; }; +template<> +struct TypeTraits : public BasicTypes +{ + enum + { + IS_TRIVIAL_TYPE = true + }; +}; /** * @} diff --git a/dali/public-api/math/vector4.cpp b/dali/public-api/math/vector4.cpp index 15815d4..b57170e 100644 --- a/dali/public-api/math/vector4.cpp +++ b/dali/public-api/math/vector4.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -23,15 +23,14 @@ #include // INTERNAL INCLUDES +#include #include +#include #include #include -#include -#include namespace Dali { - using Internal::PerformanceMonitor; const Vector4 Vector4::ONE(1.0f, 1.0f, 1.0f, 1.0f); @@ -40,7 +39,7 @@ const Vector4 Vector4::YAXIS(0.0f, 1.0f, 0.0f, 0.0f); const Vector4 Vector4::ZAXIS(0.0f, 0.0f, 1.0f, 0.0f); const Vector4 Vector4::ZERO(0.0f, 0.0f, 0.0f, 0.0f); -Vector4::Vector4( const Vector2& vec2 ) +Vector4::Vector4(const Vector2& vec2) : x(vec2.x), y(vec2.y), z(0.0f), @@ -48,7 +47,7 @@ Vector4::Vector4( const Vector2& vec2 ) { } -Vector4::Vector4( const Vector3& vec3 ) +Vector4::Vector4(const Vector3& vec3) : x(vec3.x), y(vec3.y), z(vec3.z), @@ -56,7 +55,7 @@ Vector4::Vector4( const Vector3& vec3 ) { } -Vector4& Vector4::operator=(const Vector2& vec2 ) +Vector4& Vector4::operator=(const Vector2& vec2) { x = vec2.x; y = vec2.y; @@ -65,7 +64,7 @@ Vector4& Vector4::operator=(const Vector2& vec2 ) return *this; } -Vector4& Vector4::operator=(const Vector3& vec3 ) +Vector4& Vector4::operator=(const Vector3& vec3) { x = vec3.x; y = vec3.y; @@ -74,22 +73,21 @@ Vector4& Vector4::operator=(const Vector3& vec3 ) return *this; } - bool Vector4::operator==(const Vector4& rhs) const { - if (fabsf(x - rhs.x) > GetRangedEpsilon(x, rhs.x) ) + if(fabsf(x - rhs.x) > GetRangedEpsilon(x, rhs.x)) { return false; } - if (fabsf(y - rhs.y) > GetRangedEpsilon(y, rhs.y) ) + if(fabsf(y - rhs.y) > GetRangedEpsilon(y, rhs.y)) { return false; } - if (fabsf(z - rhs.z) > GetRangedEpsilon(z, rhs.z) ) + if(fabsf(z - rhs.z) > GetRangedEpsilon(z, rhs.z)) { return false; } - if (fabsf(w - rhs.w) > GetRangedEpsilon(w, rhs.w) ) + if(fabsf(w - rhs.w) > GetRangedEpsilon(w, rhs.w)) { return false; } @@ -97,50 +95,50 @@ bool Vector4::operator==(const Vector4& rhs) const return true; } -float Vector4::Dot(const Vector3 &other) const +float Vector4::Dot(const Vector3& other) const { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,3); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 3); return x * other.x + y * other.y + z * other.z; } -float Vector4::Dot(const Vector4 &other) const +float Vector4::Dot(const Vector4& other) const { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,3); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 3); return x * other.x + y * other.y + z * other.z; } -float Vector4::Dot4(const Vector4 &other) const +float Vector4::Dot4(const Vector4& other) const { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,4); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 4); return x * other.x + y * other.y + z * other.z + w * other.w; } -Vector4 Vector4::Cross(const Vector4 &other) const +Vector4 Vector4::Cross(const Vector4& other) const { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,6); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 6); - return Vector4( (y * other.z) - (z * other.y), - (z * other.x) - (x * other.z), - (x * other.y) - (y * other.x), - 0.0f); + return Vector4((y * other.z) - (z * other.y), + (z * other.x) - (x * other.z), + (x * other.y) - (y * other.x), + 0.0f); } // Will always return positive square root float Vector4::Length() const { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,3); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 3); - return sqrtf(x*x + y*y + z*z); + return sqrtf(x * x + y * y + z * z); } float Vector4::LengthSquared() const { - MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY,3); + MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 3); - return x*x + y*y + z*z; + return x * x + y * y + z * z; } void Vector4::Normalize() @@ -148,7 +146,7 @@ void Vector4::Normalize() const float length = Length(); // In the case where the length is exactly zero, the vector cannot be normalized. - if ( ! EqualsZero( length ) ) + if(!EqualsZero(length)) { MATH_INCREASE_BY(PerformanceMonitor::FLOAT_POINT_MULTIPLY, 3); @@ -159,23 +157,23 @@ void Vector4::Normalize() } } -void Vector4::Clamp( const Vector4& min, const Vector4& max ) +void Vector4::Clamp(const Vector4& min, const Vector4& max) { - Dali::ClampInPlace( x, min.x, max.x ); - Dali::ClampInPlace( y, min.y, max.y ); - Dali::ClampInPlace( z, min.z, max.z ); - Dali::ClampInPlace( w, min.w, max.w ); + Dali::ClampInPlace(x, min.x, max.x); + Dali::ClampInPlace(y, min.y, max.y); + Dali::ClampInPlace(z, min.z, max.z); + Dali::ClampInPlace(w, min.w, max.w); } -std::ostream& operator<< (std::ostream& o, const Vector4& vector) +std::ostream& operator<<(std::ostream& o, const Vector4& vector) { return o << "[" << vector.x << ", " << vector.y << ", " << vector.z << ", " << vector.w << "]"; } -Vector4 Clamp( const Vector4& v, const float& min, const float& max ) +Vector4 Clamp(const Vector4& v, const float& min, const float& max) { - Vector4 result( v ); - result.Clamp( Vector4( min, min, min, min ), Vector4( max, max, max, max) ); + Vector4 result(v); + result.Clamp(Vector4(min, min, min, min), Vector4(max, max, max, max)); return result; } diff --git a/dali/public-api/math/vector4.h b/dali/public-api/math/vector4.h index 9af98e3..d9bfb70 100644 --- a/dali/public-api/math/vector4.h +++ b/dali/public-api/math/vector4.h @@ -44,12 +44,12 @@ struct Vector3; */ struct DALI_CORE_API Vector4 { -// NOTE -// xrs, ygt, zbp and waq must be consecutive in memory. -// No other data must be added before xrs member. -// No virtual methods must be added to this struct. + // NOTE + // xrs, ygt, zbp and waq must be consecutive in memory. + // No other data must be added before xrs member. + // No virtual methods must be added to this struct. -// Construction + // Construction /** * @brief Default constructor, initializes the vector to 0. @@ -80,7 +80,6 @@ struct DALI_CORE_API Vector4 { } - /** * @brief Conversion constructor from an array of four floats. * @@ -101,7 +100,7 @@ struct DALI_CORE_API Vector4 * @SINCE_1_0.0 * @param[in] vec2 Vector2 to copy from, z and w are initialized to 0 */ - explicit Vector4( const Vector2& vec2 ); + explicit Vector4(const Vector2& vec2); /** * @brief Conversion constructor from Vector3. @@ -109,16 +108,16 @@ struct DALI_CORE_API Vector4 * @SINCE_1_0.0 * @param[in] vec3 Vector3 to copy from, w is initialized to 0 */ - explicit Vector4( const Vector3& vec3 ); + explicit Vector4(const Vector3& vec3); -// Constants + // Constants static const Vector4 ONE; ///< (1.0f,1.0f,1.0f,1.0f) static const Vector4 XAXIS; ///< (1.0f,0.0f,0.0f,0.0f) static const Vector4 YAXIS; ///< (0.0f,1.0f,0.0f,0.0f) static const Vector4 ZAXIS; ///< (0.0f,0.0f,1.0f,0.0f) static const Vector4 ZERO; ///< (0.0f, 0.0f, 0.0f, 0.0f) -// API + // API /** * @brief Assignment operator. @@ -145,7 +144,7 @@ struct DALI_CORE_API Vector4 * @param[in] vec2 A reference to assign from * @return Itself */ - Vector4& operator=(const Vector2& vec2 ); + Vector4& operator=(const Vector2& vec2); /** * @brief Assignment operator. @@ -155,7 +154,7 @@ struct DALI_CORE_API Vector4 * @param[in] vec3 A reference to assign from * @return Itself */ - Vector4& operator=(const Vector3& vec3 ); + Vector4& operator=(const Vector3& vec3); /** * @brief Addition operator. @@ -164,7 +163,7 @@ struct DALI_CORE_API Vector4 * @param[in] rhs Vector to add * @return A vector containing the result of the addition */ - Vector4 operator+(const Vector4 & rhs) const + Vector4 operator+(const Vector4& rhs) const { Vector4 temp(*this); @@ -199,7 +198,7 @@ struct DALI_CORE_API Vector4 { Vector4 temp(*this); - temp-=rhs; + temp -= rhs; return temp; } @@ -288,7 +287,7 @@ struct DALI_CORE_API Vector4 * @param[in] rhs The vector to divide * @return A vector containing the result of the division */ - Vector4 operator/(const Vector4 & rhs) const + Vector4 operator/(const Vector4& rhs) const { Vector4 temp(*this); @@ -365,7 +364,7 @@ struct DALI_CORE_API Vector4 * @param[in] rhs The vector to test against * @return True if the vectors are equal */ - bool operator==(const Vector4 &rhs) const; + bool operator==(const Vector4& rhs) const; /** * @brief Inequality operator. @@ -376,7 +375,7 @@ struct DALI_CORE_API Vector4 * @param[in] rhs The vector to test against * @return True if the vectors are not equal */ - bool operator!=(const Vector4 &rhs) const + bool operator!=(const Vector4& rhs) const { return !(*this == rhs); } @@ -391,7 +390,7 @@ struct DALI_CORE_API Vector4 */ const float& operator[](const uint32_t index) const { - DALI_ASSERT_ALWAYS( index < 4 && "Vector element index out of bounds" ); + DALI_ASSERT_ALWAYS(index < 4 && "Vector element index out of bounds"); return AsFloat()[index]; } @@ -406,7 +405,7 @@ struct DALI_CORE_API Vector4 */ float& operator[](const uint32_t index) { - DALI_ASSERT_ALWAYS( index < 4 && "Vector element index out of bounds" ); + DALI_ASSERT_ALWAYS(index < 4 && "Vector element index out of bounds"); return AsFloat()[index]; } @@ -489,7 +488,7 @@ struct DALI_CORE_API Vector4 * @param[in] min The minimum vector * @param[in] max The maximum vector */ - void Clamp( const Vector4& min, const Vector4& max ); + void Clamp(const Vector4& min, const Vector4& max); /** * @brief Returns the contents of the vector as an array of 4 floats. @@ -508,7 +507,10 @@ struct DALI_CORE_API Vector4 * @return The vector contents as an array of 4 floats * @note inlined for performance reasons (generates less code than a function call) */ - const float* AsFloat() const {return &x;} + const float* AsFloat() const + { + return &x; + } /** * @brief Returns the contents of the vector as an array of 4 floats. @@ -527,9 +529,12 @@ struct DALI_CORE_API Vector4 * @return The vector contents as an array of 4 floats * @note inlined for performance reasons (generates less code than a function call) */ - float* AsFloat() {return &x;} + float* AsFloat() + { + return &x; + } -// Data + // Data // NOTE // xrs, ygt, zbp and waq must be consecutive in memory. @@ -562,11 +567,10 @@ struct DALI_CORE_API Vector4 }; public: - - Vector4( const Vector4& ) = default; ///< Default copy constructor - Vector4( Vector4&& ) = default; ///< Default move constructor - Vector4& operator=( const Vector4& ) = default; ///< Default copy assignment operator - Vector4& operator=( Vector4&& ) = default; ///< Default move assignment operator + Vector4(const Vector4&) = default; ///< Default copy constructor + Vector4(Vector4&&) = default; ///< Default move constructor + Vector4& operator=(const Vector4&) = default; ///< Default copy assignment operator + Vector4& operator=(Vector4&&) = default; ///< Default move assignment operator }; /** @@ -588,12 +592,12 @@ DALI_CORE_API std::ostream& operator<<(std::ostream& o, const Vector4& vector); * @param[in] b A vector * @return A vector containing the minimum of each component from a and b */ -inline Vector4 Min( const Vector4& a, const Vector4& b ) +inline Vector4 Min(const Vector4& a, const Vector4& b) { - return Vector4( a.x < b.x ? a.x : b.x, - a.y < b.y ? a.y : b.y, - a.z < b.z ? a.z : b.z, - a.w < b.w ? a.w : b.w ); + return Vector4(a.x < b.x ? a.x : b.x, + a.y < b.y ? a.y : b.y, + a.z < b.z ? a.z : b.z, + a.w < b.w ? a.w : b.w); } /** @@ -605,12 +609,12 @@ inline Vector4 Min( const Vector4& a, const Vector4& b ) * @param[in] b A vector * @return A vector containing the maximum of each component from a and b */ -inline Vector4 Max( const Vector4& a, const Vector4& b ) +inline Vector4 Max(const Vector4& a, const Vector4& b) { - return Vector4( a.x > b.x ? a.x : b.x, - a.y > b.y ? a.y : b.y, - a.z > b.z ? a.z : b.z, - a.w > b.w ? a.w : b.w ); + return Vector4(a.x > b.x ? a.x : b.x, + a.y > b.y ? a.y : b.y, + a.z > b.z ? a.z : b.z, + a.w > b.w ? a.w : b.w); } /** @@ -622,10 +626,17 @@ inline Vector4 Max( const Vector4& a, const Vector4& b ) * @param[in] max The maximum value * @return A vector containing the clamped components of v */ -DALI_CORE_API Vector4 Clamp( const Vector4& v, const float& min, const float& max ); +DALI_CORE_API Vector4 Clamp(const Vector4& v, const float& min, const float& max); // Allow Vector4 to be treated as a POD type -template <> struct TypeTraits< Vector4 > : public BasicTypes< Vector4 > { enum { IS_TRIVIAL_TYPE = true }; }; +template<> +struct TypeTraits : public BasicTypes +{ + enum + { + IS_TRIVIAL_TYPE = true + }; +}; /** * @} diff --git a/dali/public-api/object/any.cpp b/dali/public-api/object/any.cpp index 8e8dfde..d03d07d 100644 --- a/dali/public-api/object/any.cpp +++ b/dali/public-api/object/any.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -23,9 +23,8 @@ namespace Dali { - Any::Any() -: mContainer( nullptr ) +: mContainer(nullptr) { } @@ -33,18 +32,18 @@ Any::~Any() { // Call the implementation deletion function, which will invalidate mContainer - if ( nullptr != mContainer ) + if(nullptr != mContainer) { - mContainer->mDeleteFunc( mContainer ); + mContainer->mDeleteFunc(mContainer); mContainer = nullptr; } } -Any& Any::operator=( const Any& any ) +Any& Any::operator=(const Any& any) { - if( &any != this ) + if(&any != this) { - if( nullptr == any.mContainer ) + if(nullptr == any.mContainer) { delete mContainer; mContainer = nullptr; @@ -53,17 +52,17 @@ Any& Any::operator=( const Any& any ) { AnyContainerBase* tmp = mContainer; - if( nullptr != mContainer ) + if(nullptr != mContainer) { // Check if two Any types have the same type. Avoids assignments of values with different types. - if( mContainer->GetType() != any.GetType() ) + if(mContainer->GetType() != any.GetType()) { - AssertAlways( "Any::operator=( const Any& Any ). Trying to assign two values with different types." ); + AssertAlways("Any::operator=( const Any& Any ). Trying to assign two values with different types."); } } // Clone the correct templated object - mContainer = any.mContainer->mCloneFunc( *any.mContainer ); + mContainer = any.mContainer->mCloneFunc(*any.mContainer); // Deletes previous container. delete tmp; @@ -75,14 +74,13 @@ Any& Any::operator=( const Any& any ) const std::type_info& Any::GetType() const { - return mContainer ? mContainer->GetType() : typeid( void ); + return mContainer ? mContainer->GetType() : typeid(void); } -void Any::AssertAlways( const char* assertMessage ) +void Any::AssertAlways(const char* assertMessage) { - DALI_LOG_ERROR_NOFN( assertMessage ); - throw Dali::DaliException( assertMessage, "" ); + DALI_LOG_ERROR_NOFN(assertMessage); + throw Dali::DaliException(assertMessage, ""); } - } //namespace Dali diff --git a/dali/public-api/object/any.h b/dali/public-api/object/any.h index d0ca1e2..997c318 100644 --- a/dali/public-api/object/any.h +++ b/dali/public-api/object/any.h @@ -2,7 +2,7 @@ #define DALI_ANY_TYPE_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -19,8 +19,8 @@ */ // EXTERNAL INCLUDES -#include // operator typeid -#include // NULL +#include // NULL +#include // operator typeid // INTERNAL INCLUDES #include @@ -67,7 +67,7 @@ public: * @SINCE_1_0.0 * @param[in] assertMessage Assert message to report */ - DALI_CORE_API static void AssertAlways( const char* assertMessage ); + DALI_CORE_API static void AssertAlways(const char* assertMessage); /** * @brief Constructs a Any type with the given value. @@ -76,8 +76,8 @@ public: * @param[in] value The given value */ template - Any( const Type& value ) - : mContainer( new AnyContainerImpl( value ) ) + Any(const Type& value) + : mContainer(new AnyContainerImpl(value)) { } @@ -86,12 +86,12 @@ public: * @SINCE_1_0.0 * @param[in] any Any to be copied */ - Any( const Any& any ) + Any(const Any& any) { // If container isn't empty then copy the container? - if ( nullptr != any.mContainer ) + if(nullptr != any.mContainer) { - mContainer = any.mContainer->mCloneFunc( *any.mContainer ); + mContainer = any.mContainer->mCloneFunc(*any.mContainer); } else { @@ -110,26 +110,26 @@ public: * */ template - Any& operator=( const Type& value ) + Any& operator=(const Type& value) { // If the container is empty then assign the new value - if ( nullptr == mContainer ) + if(nullptr == mContainer) { - mContainer = new AnyContainerImpl< Type >( value ); + mContainer = new AnyContainerImpl(value); } else { // Check to see if this type is compatible with current container? - if ( mContainer->GetType() == typeid( Type ) ) + if(mContainer->GetType() == typeid(Type)) { // Same type so just set the new value - static_cast< AnyContainerImpl< Type >* >( mContainer )->SetValue( value ); + static_cast*>(mContainer)->SetValue(value); } else { // Incompatible types, so delete old container and assign a new one with this type and value - mContainer->mDeleteFunc( mContainer ); - mContainer = new AnyContainerImpl< Type >( value ); + mContainer->mDeleteFunc(mContainer); + mContainer = new AnyContainerImpl(value); } } return *this; @@ -144,7 +144,7 @@ public: * @exception DaliException If parameter any is of a different type. * */ - DALI_CORE_API Any& operator=( const Any& any ); + DALI_CORE_API Any& operator=(const Any& any); /** * @brief Gets a value of type Type from container. @@ -153,7 +153,7 @@ public: * @param[in] type destination of type Type to write to */ template - void Get( Type& type ) const + void Get(Type& type) const { type = Get(); } @@ -176,15 +176,15 @@ public: template const Type& Get() const { - if ( nullptr == mContainer ) + if(nullptr == mContainer) { - AssertAlways( "Any::Get(). mContainer is NULL" ); + AssertAlways("Any::Get(). mContainer is NULL"); } - else if( mContainer->GetType() != typeid( Type ) ) // Check if the value has the same value than the Any type. + else if(mContainer->GetType() != typeid(Type)) // Check if the value has the same value than the Any type. { - AssertAlways( "Any::Get(). Trying to retrieve a value of a different type than the template one." ); + AssertAlways("Any::Get(). Trying to retrieve a value of a different type than the template one."); } - return static_cast< AnyContainerImpl< Type >* >( mContainer )->GetValue(); + return static_cast*>(mContainer)->GetValue(); } /** @@ -196,16 +196,16 @@ public: template Type* GetPointer() { - if( nullptr == mContainer ) + if(nullptr == mContainer) { return NULL; } - // Check if the value has the same value than the Any type. - if( mContainer->GetType() != typeid( Type ) ) + // Check if the value has the same value than the Any type. + if(mContainer->GetType() != typeid(Type)) { - AssertAlways( "Any::GetPointer(). Trying to retrieve a pointer to a value of a different type than the template one." ); + AssertAlways("Any::GetPointer(). Trying to retrieve a pointer to a value of a different type than the template one."); } - return static_cast< AnyContainerImpl< Type >* >( mContainer )->GetPointerToValue(); + return static_cast*>(mContainer)->GetPointerToValue(); } /** @@ -217,16 +217,16 @@ public: template const Type* GetPointer() const { - if( nullptr == mContainer ) + if(nullptr == mContainer) { return NULL; } - // Check if the value has the same value than the Any type. - if( mContainer->GetType() != typeid( Type ) ) + // Check if the value has the same value than the Any type. + if(mContainer->GetType() != typeid(Type)) { - AssertAlways( "Any::GetPointer(). Trying to retrieve a pointer to a value of a different type than the template one." ); + AssertAlways("Any::GetPointer(). Trying to retrieve a pointer to a value of a different type than the template one."); } - return static_cast< AnyContainerImpl< Type >* >( mContainer )->GetPointerToValue(); + return static_cast*>(mContainer)->GetPointerToValue(); } /** @@ -237,13 +237,13 @@ public: */ bool Empty() const { - return ( nullptr == mContainer ) ? true : false; + return (nullptr == mContainer) ? true : false; } - struct AnyContainerBase; // Forward declaration for typedef - using CloneFunc = AnyContainerBase* (*)( const AnyContainerBase& ); + struct AnyContainerBase; // Forward declaration for typedef + using CloneFunc = AnyContainerBase* (*)(const AnyContainerBase&); - using DeleteFunc = void ( * )( const AnyContainerBase* ); + using DeleteFunc = void (*)(const AnyContainerBase*); /** * @brief Base container to hold type for match verification and instance cloning function. @@ -260,11 +260,12 @@ public: * @param[in] cloneFunc Cloning function to replicate this container type * @param[in] deleteFunc Deleting function to destroy this container type */ - AnyContainerBase( const std::type_info& type, CloneFunc cloneFunc, DeleteFunc deleteFunc ) - : mType( type ), - mCloneFunc( cloneFunc ), - mDeleteFunc( deleteFunc ) - {} + AnyContainerBase(const std::type_info& type, CloneFunc cloneFunc, DeleteFunc deleteFunc) + : mType(type), + mCloneFunc(cloneFunc), + mDeleteFunc(deleteFunc) + { + } /** * @brief Gets the typeid of this container. @@ -277,12 +278,11 @@ public: return mType; } - const::std::type_info& mType; // typeID - CloneFunc mCloneFunc; // cloning function for this container - DeleteFunc mDeleteFunc; // deleting function for this container + const ::std::type_info& mType; // typeID + CloneFunc mCloneFunc; // cloning function for this container + DeleteFunc mDeleteFunc; // deleting function for this container }; - /** * @brief Templated Clone function from container base. * @@ -292,9 +292,9 @@ public: template struct AnyContainerImplCloner { - static AnyContainerBase* Clone( const AnyContainerBase& base ) + static AnyContainerBase* Clone(const AnyContainerBase& base) { - return new AnyContainerImpl< Type >( static_cast< AnyContainerImpl< Type > >( base ) ); + return new AnyContainerImpl(static_cast >(base)); } }; @@ -307,9 +307,9 @@ public: template struct AnyContainerImplDelete { - static void Delete( const AnyContainerBase* base ) + static void Delete(const AnyContainerBase* base) { - delete ( static_cast< const AnyContainerImpl< Type >* > ( base ) ); + delete(static_cast*>(base)); } }; @@ -322,19 +322,19 @@ public: class AnyContainerImpl : public AnyContainerBase { public: - /** * @brief Constructor to create container holding value of type Type. * * @SINCE_1_0.0 * @param[in] value Value of Type */ - AnyContainerImpl( const Type& value ) - : AnyContainerBase( typeid( Type ), - static_cast< CloneFunc >( &AnyContainerImplCloner< Type >::Clone ), - static_cast< DeleteFunc >( &AnyContainerImplDelete< Type >::Delete ) ), - mValue( value ) - {} + AnyContainerImpl(const Type& value) + : AnyContainerBase(typeid(Type), + static_cast(&AnyContainerImplCloner::Clone), + static_cast(&AnyContainerImplDelete::Delete)), + mValue(value) + { + } /** * @brief Constructor to create new container of type from and existing container (cloning). @@ -342,12 +342,12 @@ public: * @SINCE_1_0.0 * @param[in] base The reference to base container to copy from */ - AnyContainerImpl( const AnyContainerBase& base ) - : AnyContainerBase( typeid( Type ), - static_cast< CloneFunc >( &AnyContainerImplCloner< Type >::Clone ), - static_cast< DeleteFunc >( &AnyContainerImplDelete< Type >::Delete ) ) + AnyContainerImpl(const AnyContainerBase& base) + : AnyContainerBase(typeid(Type), + static_cast(&AnyContainerImplCloner::Clone), + static_cast(&AnyContainerImplDelete::Delete)) { - mValue = static_cast< const AnyContainerImpl& >( base ).GetValue(); + mValue = static_cast(base).GetValue(); } /** @@ -367,7 +367,7 @@ public: * @SINCE_1_0.0 * @param[in] value Value of type Type */ - void SetValue( const Type& value ) + void SetValue(const Type& value) { mValue = value; } @@ -380,7 +380,7 @@ public: */ Type* GetPointerToValue() { - return static_cast< Type* >( &mValue ); + return static_cast(&mValue); } /** @@ -391,15 +391,14 @@ public: */ const Type* GetPointerToValue() const { - return static_cast< const Type* >( &mValue ); + return static_cast(&mValue); } - private: - Type mValue; + private: + Type mValue; }; AnyContainerBase* mContainer; - }; /** @@ -415,7 +414,7 @@ public: * @return Pointer to the Type held */ template -inline Type* AnyCast( Any* any ) +inline Type* AnyCast(Any* any) { return any->GetPointer(); } @@ -429,7 +428,7 @@ inline Type* AnyCast( Any* any ) * @return const Pointer to the Type held */ template -inline const Type* AnyCast( const Any* any ) +inline const Type* AnyCast(const Any* any) { return any->GetPointer(); } @@ -443,7 +442,7 @@ inline const Type* AnyCast( const Any* any ) * @return Type value of type Type */ template -inline Type AnyCast( Any& any ) +inline Type AnyCast(Any& any) { return any.Get(); } @@ -457,7 +456,7 @@ inline Type AnyCast( Any& any ) * @return Type value of type Type */ template -inline Type AnyCast( const Any& any ) +inline Type AnyCast(const Any& any) { return any.Get(); } @@ -471,7 +470,7 @@ inline Type AnyCast( const Any& any ) * @return A reference to the Type value of type Type */ template -inline Type& AnyCastReference( Any& any ) +inline Type& AnyCastReference(Any& any) { return any.Get(); } @@ -485,7 +484,7 @@ inline Type& AnyCastReference( Any& any ) * @return A const reference to the Type value of type Type */ template -inline const Type& AnyCastReference( const Any& any ) +inline const Type& AnyCastReference(const Any& any) { return any.Get(); } diff --git a/dali/public-api/object/base-handle.cpp b/dali/public-api/object/base-handle.cpp index c339c63..c9675ed 100644 --- a/dali/public-api/object/base-handle.cpp +++ b/dali/public-api/object/base-handle.cpp @@ -23,12 +23,11 @@ #include // INTERNAL INCLUDES -#include #include +#include namespace Dali { - BaseHandle::BaseHandle(Dali::BaseObject* handle) : mObjectHandle(handle) { @@ -46,13 +45,13 @@ BaseHandle::BaseHandle(const BaseHandle& handle) = default; BaseHandle& BaseHandle::operator=(const BaseHandle& rhs) = default; -BaseHandle::BaseHandle( BaseHandle&& rhs ) = default; +BaseHandle::BaseHandle(BaseHandle&& rhs) = default; -BaseHandle& BaseHandle::operator=( BaseHandle&& rhs ) = default; +BaseHandle& BaseHandle::operator=(BaseHandle&& rhs) = default; bool BaseHandle::DoAction(const std::string& command, const Property::Map& attributes) { - return GetImplementation(*this).DoAction( command, attributes ); + return GetImplementation(*this).DoAction(command, attributes); } const std::string& BaseHandle::GetTypeName() const @@ -100,9 +99,9 @@ Dali::RefObject* BaseHandle::GetObjectPtr() const return mObjectHandle.Get(); } -bool BaseHandle::DoConnectSignal( ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor ) +bool BaseHandle::DoConnectSignal(ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor) { - return GetImplementation(*this).DoConnectSignal( connectionTracker, signalName, functor ); + return GetImplementation(*this).DoConnectSignal(connectionTracker, signalName, functor); } } // namespace Dali diff --git a/dali/public-api/object/base-handle.h b/dali/public-api/object/base-handle.h index e456a6e..35a7873 100644 --- a/dali/public-api/object/base-handle.h +++ b/dali/public-api/object/base-handle.h @@ -59,7 +59,6 @@ class TypeInfo; class DALI_CORE_API BaseHandle { public: - /** * @brief This constructor is used by Dali New() methods. * @@ -116,7 +115,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs A reference to the moved handle */ - BaseHandle( BaseHandle&& rhs ); + BaseHandle(BaseHandle&& rhs); /** * @brief Move assignment operator. @@ -125,7 +124,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this handle */ - BaseHandle& operator=( BaseHandle&& rhs ); + BaseHandle& operator=(BaseHandle&& rhs); /** * @brief Connects a void() functor to a specified signal. @@ -137,10 +136,10 @@ public: * @return True if the signal was available * @pre The signal must be available in this object. */ - template - bool ConnectSignal( ConnectionTrackerInterface* connectionTracker, const std::string& signalName, const T& functor ) + template + bool ConnectSignal(ConnectionTrackerInterface* connectionTracker, const std::string& signalName, const T& functor) { - return DoConnectSignal( connectionTracker, signalName, FunctorDelegate::New( functor ) ); + return DoConnectSignal(connectionTracker, signalName, FunctorDelegate::New(functor)); } /** @@ -181,7 +180,6 @@ public: bool GetTypeInfo(Dali::TypeInfo& info) const; public: - // BaseHandle accessors /** @@ -219,7 +217,7 @@ public: * @brief Pointer-to-member type. * Objects can be implicitly converted to this for validity checks. */ - using BooleanType = void ( BaseHandle::* )() const; + using BooleanType = void (BaseHandle::*)() const; /** * @brief Converts an handle to a BooleanType. @@ -256,7 +254,6 @@ public: Dali::RefObject* GetObjectPtr() const; private: - /** * @brief Not intended for application developers. * @@ -266,10 +263,9 @@ private: * @param[in] functorDelegate A newly allocated functor delegate (takes ownership) * @return True if the signal was available */ - bool DoConnectSignal( ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functorDelegate ); + bool DoConnectSignal(ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functorDelegate); protected: - /** * @brief Used by the safe bool idiom. * @@ -277,12 +273,12 @@ protected: * in a boolean context without the usual harmful side effects. * @SINCE_1_0.0 */ - void ThisIsSaferThanReturningVoidStar() const {} + void ThisIsSaferThanReturningVoidStar() const + { + } private: - IntrusivePtr mObjectHandle; ///< Object this handle points at. - }; /** @@ -293,10 +289,10 @@ private: * @return Handle pointer to either a valid deriving handle or an uninitialized handle * @pre The BaseHandle has been initialized. */ -template< class T > -inline T DownCast( BaseHandle handle ) +template +inline T DownCast(BaseHandle handle) { - return T::DownCast( handle ); + return T::DownCast(handle); } // See also BaseHandle::BooleanType() conversion @@ -308,7 +304,7 @@ inline T DownCast( BaseHandle handle ) * @param[in] rhs A reference to compare to * @return True if the handle handles point to the same Dali resource, or if both are NULL */ -template +template inline bool operator==(const BaseHandle& lhs, const T& rhs) { // We depart from the safe bool idiom to allow Dali::BaseHandle derived classes to be compared @@ -322,7 +318,7 @@ inline bool operator==(const BaseHandle& lhs, const T& rhs) * @param[in] rhs A reference to compare to * @return True if the handle handles point to the different Dali resources */ -template +template inline bool operator!=(const BaseHandle& lhs, const T& rhs) { // We depart from the safe bool idiom to allow Dali::BaseHandle derived classes to be compared diff --git a/dali/public-api/object/base-object.cpp b/dali/public-api/object/base-object.cpp index d0b07e5..41d00e6 100644 --- a/dali/public-api/object/base-object.cpp +++ b/dali/public-api/object/base-object.cpp @@ -19,19 +19,18 @@ #include // INTERNAL INCLUDES -#include #include +#include #include #include -#include #include -#include +#include +#include namespace Dali { - BaseObject::BaseObject() -: mImpl( new Impl( *this ) ) +: mImpl(new Impl(*this)) { } @@ -42,9 +41,9 @@ BaseObject::~BaseObject() void BaseObject::RegisterObject() { Internal::ThreadLocalStorage* tls = Internal::ThreadLocalStorage::GetInternal(); - if ( tls ) + if(tls) { - tls->GetEventThreadServices().RegisterObject( this ); + tls->GetEventThreadServices().RegisterObject(this); } } @@ -53,9 +52,9 @@ void BaseObject::UnregisterObject() Internal::ThreadLocalStorage* tls = Internal::ThreadLocalStorage::GetInternal(); // Guard to allow handle destruction after Core has been destroyed - if( tls ) + if(tls) { - tls->GetEventThreadServices().UnregisterObject( this ); + tls->GetEventThreadServices().UnregisterObject(this); } } @@ -63,7 +62,7 @@ bool BaseObject::DoAction(const std::string& actionName, const Property::Map& at { Dali::Internal::TypeRegistry* registry = Dali::Internal::TypeRegistry::Get(); - if( registry ) + if(registry) { return registry->DoActionTo(this, actionName, attributes); } @@ -75,17 +74,17 @@ const std::string& BaseObject::GetTypeName() const { Dali::Internal::TypeRegistry* registry = Dali::Internal::TypeRegistry::Get(); - if( registry ) + if(registry) { Internal::TypeRegistry::TypeInfoPointer typeInfo = registry->GetTypeInfo(this); - if( typeInfo ) + if(typeInfo) { return typeInfo->GetName(); } } // Return an empty string if type-name not found. - DALI_LOG_WARNING( "TypeName Not Found\n" ); + DALI_LOG_WARNING("TypeName Not Found\n"); static std::string empty; return empty; } @@ -97,7 +96,7 @@ bool BaseObject::GetTypeInfo(Dali::TypeInfo& typeInfo) const Internal::TypeRegistry::TypeInfoPointer info = registry->GetTypeInfo(this); if(info) { - typeInfo = Dali::TypeInfo( info.Get() ); + typeInfo = Dali::TypeInfo(info.Get()); return true; } else @@ -106,17 +105,16 @@ bool BaseObject::GetTypeInfo(Dali::TypeInfo& typeInfo) const } } -bool BaseObject::DoConnectSignal( ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor ) +bool BaseObject::DoConnectSignal(ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor) { Dali::Internal::TypeRegistry* registry = Dali::Internal::TypeRegistry::Get(); - if( registry ) + if(registry) { - return registry->ConnectSignal( this, connectionTracker, signalName, functor ); + return registry->ConnectSignal(this, connectionTracker, signalName, functor); } return false; } } // namespace Dali - diff --git a/dali/public-api/object/base-object.h b/dali/public-api/object/base-object.h index 91ca518..07be7d8 100644 --- a/dali/public-api/object/base-object.h +++ b/dali/public-api/object/base-object.h @@ -22,9 +22,9 @@ #include // INTERNAL INCLUDES -#include #include #include +#include #include namespace Dali @@ -43,7 +43,6 @@ class BaseHandle; class DALI_CORE_API BaseObject : public Dali::RefObject { public: - /** * @brief Connects a void() functor to a specified signal. * @@ -54,10 +53,10 @@ public: * @return True if the signal was available * @pre The signal must be available in this object. */ - template - bool ConnectSignal( ConnectionTrackerInterface* connectionTracker, const std::string& signalName, const T& functor ) + template + bool ConnectSignal(ConnectionTrackerInterface* connectionTracker, const std::string& signalName, const T& functor) { - return DoConnectSignal( connectionTracker, signalName, FunctorDelegate::New( functor ) ); + return DoConnectSignal(connectionTracker, signalName, FunctorDelegate::New(functor)); } /** @@ -76,7 +75,6 @@ public: bool GetTypeInfo(Dali::TypeInfo& info) const; public: // Not intended for application developers - /** * @brief Not intended for application developers. * @@ -86,10 +84,9 @@ public: // Not intended for application developers * @param[in] functorDelegate A newly allocated functor delegate (takes ownership) * @return True if the signal was available */ - bool DoConnectSignal( ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functorDelegate ); + bool DoConnectSignal(ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functorDelegate); protected: - /** * @brief Default constructor. * @SINCE_1_0.0 @@ -116,17 +113,15 @@ protected: // Not copyable or movable - BaseObject(const BaseObject& rhs) = delete; ///< Deleted copy constructor - BaseObject(BaseObject&& rhs) = delete; ///< Deleted move constructor + BaseObject(const BaseObject& rhs) = delete; ///< Deleted copy constructor + BaseObject(BaseObject&& rhs) = delete; ///< Deleted move constructor BaseObject& operator=(const BaseObject& rhs) = delete; ///< Deleted copy assignment operator - BaseObject& operator=(BaseObject&& rhs) = delete; ///< Deleted move assignment operator + BaseObject& operator=(BaseObject&& rhs) = delete; ///< Deleted move assignment operator public: - class DALI_INTERNAL Impl; private: - std::unique_ptr mImpl; }; @@ -141,7 +136,7 @@ private: */ inline BaseObject& GetImplementation(Dali::BaseHandle& handle) { - DALI_ASSERT_ALWAYS( handle && "BaseObject handle is empty" ); + DALI_ASSERT_ALWAYS(handle && "BaseObject handle is empty"); return handle.GetBaseObject(); } @@ -155,7 +150,7 @@ inline BaseObject& GetImplementation(Dali::BaseHandle& handle) */ inline const BaseObject& GetImplementation(const Dali::BaseHandle& handle) { - DALI_ASSERT_ALWAYS( handle && "BaseObject handle is empty" ); + DALI_ASSERT_ALWAYS(handle && "BaseObject handle is empty"); return handle.GetBaseObject(); } @@ -165,4 +160,4 @@ inline const BaseObject& GetImplementation(const Dali::BaseHandle& handle) */ } // namespace Dali -# endif // __DALI_BASE_OBJECT_H__ +#endif // __DALI_BASE_OBJECT_H__ diff --git a/dali/public-api/object/handle.cpp b/dali/public-api/object/handle.cpp index c28330c..0f938d4 100644 --- a/dali/public-api/object/handle.cpp +++ b/dali/public-api/object/handle.cpp @@ -19,18 +19,16 @@ #include // INTERNAL INCLUDES +#include +#include +#include #include #include #include -#include -#include -#include namespace Dali { - - -Handle::Handle( Dali::Internal::Object* handle ) +Handle::Handle(Dali::Internal::Object* handle) : BaseHandle(handle) { } @@ -41,29 +39,29 @@ Handle::Handle() Handle Handle::New() { - return Handle( Internal::Object::New().Get() ); + return Handle(Internal::Object::New().Get()); } Handle::~Handle() { } -Handle::Handle( const Handle& handle ) = default; +Handle::Handle(const Handle& handle) = default; -Handle& Handle::operator=( const Handle& rhs ) = default; +Handle& Handle::operator=(const Handle& rhs) = default; -Handle::Handle( Handle&& rhs ) = default; +Handle::Handle(Handle&& rhs) = default; -Handle& Handle::operator=( Handle&& rhs ) = default; +Handle& Handle::operator=(Handle&& rhs) = default; -Handle Handle::DownCast( BaseHandle handle ) +Handle Handle::DownCast(BaseHandle handle) { - return Handle( dynamic_cast(handle.GetObjectPtr()) ); + return Handle(dynamic_cast(handle.GetObjectPtr())); } -bool Handle::Supports( Capability capability ) const +bool Handle::Supports(Capability capability) const { - return GetImplementation(*this).Supports( capability ); + return GetImplementation(*this).Supports(capability); } uint32_t Handle::GetPropertyCount() const @@ -71,102 +69,102 @@ uint32_t Handle::GetPropertyCount() const return GetImplementation(*this).GetPropertyCount(); } -std::string Handle::GetPropertyName( Property::Index index ) const +std::string Handle::GetPropertyName(Property::Index index) const { - return GetImplementation(*this).GetPropertyName( index ); + return GetImplementation(*this).GetPropertyName(index); } -Property::Index Handle::GetPropertyIndex( Property::Key key ) const +Property::Index Handle::GetPropertyIndex(Property::Key key) const { - return GetImplementation( *this ).GetPropertyIndex( key ); + return GetImplementation(*this).GetPropertyIndex(key); } -bool Handle::IsPropertyWritable( Property::Index index ) const +bool Handle::IsPropertyWritable(Property::Index index) const { - return GetImplementation(*this).IsPropertyWritable( index ); + return GetImplementation(*this).IsPropertyWritable(index); } -bool Handle::IsPropertyAnimatable( Property::Index index ) const +bool Handle::IsPropertyAnimatable(Property::Index index) const { - return GetImplementation(*this).IsPropertyAnimatable( index ); + return GetImplementation(*this).IsPropertyAnimatable(index); } -bool Handle::IsPropertyAConstraintInput( Property::Index index ) const +bool Handle::IsPropertyAConstraintInput(Property::Index index) const { - return GetImplementation(*this).IsPropertyAConstraintInput( index ); + return GetImplementation(*this).IsPropertyAConstraintInput(index); } -Property::Type Handle::GetPropertyType( Property::Index index ) const +Property::Type Handle::GetPropertyType(Property::Index index) const { - return GetImplementation(*this).GetPropertyType( index ); + return GetImplementation(*this).GetPropertyType(index); } -void Handle::SetProperty( Property::Index index, const Property::Value& propertyValue ) +void Handle::SetProperty(Property::Index index, const Property::Value& propertyValue) { - GetImplementation(*this).SetProperty( index, propertyValue ); + GetImplementation(*this).SetProperty(index, propertyValue); } -Property::Index Handle::RegisterProperty( const std::string& name, const Property::Value& propertyValue ) +Property::Index Handle::RegisterProperty(const std::string& name, const Property::Value& propertyValue) { - return GetImplementation(*this).RegisterProperty( name, propertyValue ); + return GetImplementation(*this).RegisterProperty(name, propertyValue); } -Property::Index Handle::RegisterProperty( Property::Index key, const std::string& name, const Property::Value& propertyValue ) +Property::Index Handle::RegisterProperty(Property::Index key, const std::string& name, const Property::Value& propertyValue) { - return GetImplementation( *this ).RegisterProperty( name, key, propertyValue ); + return GetImplementation(*this).RegisterProperty(name, key, propertyValue); } -Property::Index Handle::RegisterProperty( const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode ) +Property::Index Handle::RegisterProperty(const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode) { - return GetImplementation(*this).RegisterProperty( name, propertyValue, accessMode ); + return GetImplementation(*this).RegisterProperty(name, propertyValue, accessMode); } -Property::Value Handle::GetProperty( Property::Index index ) const +Property::Value Handle::GetProperty(Property::Index index) const { - return GetImplementation(*this).GetProperty( index ); + return GetImplementation(*this).GetProperty(index); } -Property::Value Handle::GetCurrentProperty( Property::Index index ) const +Property::Value Handle::GetCurrentProperty(Property::Index index) const { - return GetImplementation(*this).GetCurrentProperty( index ); + return GetImplementation(*this).GetCurrentProperty(index); } -void Handle::SetProperties( const Property::Map& properties ) +void Handle::SetProperties(const Property::Map& properties) { - GetImplementation( *this ).SetProperties( properties ); + GetImplementation(*this).SetProperties(properties); } -void Handle::GetProperties( Property::Map& properties ) +void Handle::GetProperties(Property::Map& properties) { - GetImplementation( *this ).GetProperties( properties ); + GetImplementation(*this).GetProperties(properties); } -void Handle::GetPropertyIndices( Property::IndexContainer& indices ) const +void Handle::GetPropertyIndices(Property::IndexContainer& indices) const { - GetImplementation(*this).GetPropertyIndices( indices ); + GetImplementation(*this).GetPropertyIndices(indices); } -bool Handle::DoesCustomPropertyExist( Property::Index index ) +bool Handle::DoesCustomPropertyExist(Property::Index index) { - return GetImplementation( *this ).DoesCustomPropertyExist( index ); + return GetImplementation(*this).DoesCustomPropertyExist(index); } -Dali::PropertyNotification Handle::AddPropertyNotification( Property::Index index, - const PropertyCondition& condition ) +Dali::PropertyNotification Handle::AddPropertyNotification(Property::Index index, + const PropertyCondition& condition) { - return GetImplementation(*this).AddPropertyNotification( index, -1, condition ); + return GetImplementation(*this).AddPropertyNotification(index, -1, condition); } -Dali::PropertyNotification Handle::AddPropertyNotification( Property::Index index, - int componentIndex, - const PropertyCondition& condition ) +Dali::PropertyNotification Handle::AddPropertyNotification(Property::Index index, + int componentIndex, + const PropertyCondition& condition) { - return GetImplementation(*this).AddPropertyNotification( index, componentIndex, condition ); + return GetImplementation(*this).AddPropertyNotification(index, componentIndex, condition); } -void Handle::RemovePropertyNotification( Dali::PropertyNotification propertyNotification ) +void Handle::RemovePropertyNotification(Dali::PropertyNotification propertyNotification) { - GetImplementation(*this).RemovePropertyNotification( propertyNotification ); + GetImplementation(*this).RemovePropertyNotification(propertyNotification); } void Handle::RemovePropertyNotifications() @@ -179,18 +177,18 @@ void Handle::RemoveConstraints() GetImplementation(*this).RemoveConstraints(); } -void Handle::RemoveConstraints( uint32_t tag ) +void Handle::RemoveConstraints(uint32_t tag) { - GetImplementation(*this).RemoveConstraints( tag ); + GetImplementation(*this).RemoveConstraints(tag); } -IndirectValue Handle::operator[]( Property::Index index ) +IndirectValue Handle::operator[](Property::Index index) { // Will assert on access if handle is empty return IndirectValue(*this, index); } -IndirectValue Handle::operator[]( const std::string& name ) +IndirectValue Handle::operator[](const std::string& name) { // Will assert immediately when GetPropertyIndex is called if handle is empty return IndirectValue(*this, GetPropertyIndex(name)); @@ -198,20 +196,18 @@ IndirectValue Handle::operator[]( const std::string& name ) Handle::PropertySetSignalType& Handle::PropertySetSignal() { - return GetImplementation( *this ).PropertySetSignal(); + return GetImplementation(*this).PropertySetSignal(); } - namespace WeightObject { - const Property::Index WEIGHT = PROPERTY_CUSTOM_START_INDEX; Handle New() { Handle handle = Handle::New(); - handle.RegisterProperty( "weight", 0.0f ); + handle.RegisterProperty("weight", 0.0f); return handle; } diff --git a/dali/public-api/object/handle.h b/dali/public-api/object/handle.h index b5f0ecb..63270ba 100644 --- a/dali/public-api/object/handle.h +++ b/dali/public-api/object/handle.h @@ -19,21 +19,20 @@ */ // EXTERNAL INCLUDES -#include #include // uint32_t +#include // INTERNAL INCLUDES #include #include #include #include +#include #include #include -#include #include #include - namespace Dali { /** @@ -57,7 +56,6 @@ class Object; class DALI_CORE_API Handle : public BaseHandle { public: - /** * @brief Enumeration for Handle's capabilities that can be queried using Handle::Supports(). * @SINCE_1_0.0 @@ -76,17 +74,16 @@ public: /** * @brief PropertySetSignal function prototype for signal handler. Called when a property is set on this object. */ - using PropertySetSignalType = Signal< void( Handle& handle, Property::Index index, Property::Value value ) >; + using PropertySetSignalType = Signal; public: - /** * @brief This constructor is used by Dali New() methods. * * @SINCE_1_0.0 * @param[in] handle A pointer to a newly allocated Dali resource */ - Handle( Dali::Internal::Object* handle ); + Handle(Dali::Internal::Object* handle); /** * @brief This constructor provides an uninitialized Dali::Handle. @@ -120,11 +117,11 @@ public: * @tparam T The derived class to create * @param[in] properties The properties to set */ - template< typename Type > - static DALI_NO_EXPORT_API Type New( const Property::Map& properties ) + template + static DALI_NO_EXPORT_API Type New(const Property::Map& properties) { Type handle = Type::New(); - handle.SetProperties( properties ); + handle.SetProperties(properties); return handle; } @@ -142,7 +139,7 @@ public: * @SINCE_1_0.0 * @param[in] handle A reference to the copied handle */ - Handle( const Handle& handle ); + Handle(const Handle& handle); /** * @brief This assignment operator is required for (smart) pointer semantics. @@ -151,7 +148,7 @@ public: * @param[in] rhs A reference to the copied handle * @return A reference to this */ - Handle& operator=( const Handle& rhs ); + Handle& operator=(const Handle& rhs); /** * @brief Move constructor. @@ -159,7 +156,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs A reference to the moved handle */ - Handle( Handle&& rhs ); + Handle(Handle&& rhs); /** * @brief Move assignment operator. @@ -168,7 +165,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this handle */ - Handle& operator=( Handle&& rhs ); + Handle& operator=(Handle&& rhs); /** * @brief Downcasts to a handle. @@ -178,7 +175,7 @@ public: * @param[in] handle to An object * @return handle or an uninitialized handle */ - static Handle DownCast( BaseHandle handle ); + static Handle DownCast(BaseHandle handle); /** * @brief Queries whether an handle supports a given capability. @@ -187,7 +184,7 @@ public: * @param[in] capability The queried capability * @return True if the capability is supported */ - bool Supports( Capability capability ) const; + bool Supports(Capability capability) const; // Properties @@ -207,7 +204,7 @@ public: * @param[in] index The index of the property * @return The name of the property */ - std::string GetPropertyName( Property::Index index ) const; + std::string GetPropertyName(Property::Index index) const; /** * @brief Query the index of a property using the given key. @@ -218,7 +215,7 @@ public: * @return the matching property index of the key, or Property::INVALID_INDEX if no * property matches the given key. */ - Property::Index GetPropertyIndex( Property::Key key ) const; + Property::Index GetPropertyIndex(Property::Key key) const; /** * @brief Queries whether a property can be set using SetProperty(). @@ -228,7 +225,7 @@ public: * @return True if the property is writable * @pre Property::INVALID_INDEX < index. */ - bool IsPropertyWritable( Property::Index index ) const; + bool IsPropertyWritable(Property::Index index) const; /** * @brief Queries whether a writable property can be the target of an animation or constraint. @@ -237,7 +234,7 @@ public: * @param[in] index The index of the property * @return True if the property is animatable */ - bool IsPropertyAnimatable( Property::Index index ) const; + bool IsPropertyAnimatable(Property::Index index) const; /** * @brief Queries whether a property can be used as in input to a constraint. @@ -246,7 +243,7 @@ public: * @param[in] index The index of the property * @return True if the property can be used as a constraint input */ - bool IsPropertyAConstraintInput( Property::Index index ) const; + bool IsPropertyAConstraintInput(Property::Index index) const; /** * @brief Queries the type of a property. @@ -255,7 +252,7 @@ public: * @param[in] index The index of the property * @return The type of the property */ - Property::Type GetPropertyType( Property::Index index ) const; + Property::Type GetPropertyType(Property::Index index) const; /** * @brief Sets the value of an existing property. @@ -266,7 +263,7 @@ public: * @param[in] propertyValue The new value of the property * @pre The property types match i.e. propertyValue.GetType() is equal to GetPropertyType(index). */ - void SetProperty( Property::Index index, const Property::Value& propertyValue ); + void SetProperty(Property::Index index, const Property::Value& propertyValue); /** * @brief Registers a new animatable property. @@ -292,7 +289,7 @@ public: * - Property::ROTATION * @note If a property with the desired name already exists, then the value given is just set. */ - Property::Index RegisterProperty( const std::string& name, const Property::Value& propertyValue ); + Property::Index RegisterProperty(const std::string& name, const Property::Value& propertyValue); /** * @brief Register a new animatable property with an integer key. @@ -332,9 +329,9 @@ public: * - Property::ROTATION * @note If a property with the desired name already exists, then the value given is just set. */ - Property::Index RegisterProperty( Property::Index key, - const std::string& name, - const Property::Value& propertyValue ); + Property::Index RegisterProperty(Property::Index key, + const std::string& name, + const Property::Value& propertyValue); /** * @brief Registers a new property. @@ -359,7 +356,7 @@ public: * - Property::ROTATION * @note If a property with the desired name already exists, then the value given is just set. */ - Property::Index RegisterProperty( const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode ); + Property::Index RegisterProperty(const std::string& name, const Property::Value& propertyValue, Property::AccessMode accessMode); /** * @brief Retrieves a property value. @@ -368,7 +365,7 @@ public: * @param[in] index The index of the property * @return The property value */ - Property::Value GetProperty( Property::Index index ) const; + Property::Value GetProperty(Property::Index index) const; /** * @brief Convenience function for obtaining a property of a known type. @@ -378,12 +375,12 @@ public: * @return The property value * @pre The property types match i.e. PropertyTypes::Get() is equal to GetPropertyType(index). */ - template - T GetProperty( Property::Index index ) const + template + T GetProperty(Property::Index index) const { Property::Value value = GetProperty(index); - return T( value.Get() ); + return T(value.Get()); } /** @@ -393,7 +390,7 @@ public: * @param[in] index The index of the property * @return The property value */ - Property::Value GetCurrentProperty( Property::Index index ) const; + Property::Value GetCurrentProperty(Property::Index index) const; /** * @brief Convenience function for obtaining the current value of a property of a known type. @@ -403,12 +400,12 @@ public: * @return The property value * @pre The property types match i.e. PropertyTypes::Get() is equal to GetPropertyType(index). */ - template - T GetCurrentProperty( Property::Index index ) const + template + T GetCurrentProperty(Property::Index index) const { - Property::Value value = GetCurrentProperty( index ); + Property::Value value = GetCurrentProperty(index); - return T( value.Get() ); + return T(value.Get()); } /** @@ -417,7 +414,7 @@ public: * @SINCE_1_9.27 * @param[in] properties The properties to set */ - void SetProperties( const Property::Map& properties ); + void SetProperties(const Property::Map& properties); /** * @brief Retrieves all the properties and the values for this object @@ -427,7 +424,7 @@ public: * * @note The properties map will be cleared by this method first. */ - void GetProperties( Property::Map& properties ); + void GetProperties(Property::Map& properties); /** * @brief Retrieves all the property indices for this object (including custom properties). @@ -436,7 +433,7 @@ public: * @param[out] indices A container of property indices for this object * @note The added container is cleared. */ - void GetPropertyIndices( Property::IndexContainer& indices ) const; + void GetPropertyIndices(Property::IndexContainer& indices) const; /** * @brief Determine if the custom property index exists on this object without throwing a Dali::Exception. @@ -445,7 +442,7 @@ public: * @note This does not check default properties. * @param[in] index The index of the property to test for */ - bool DoesCustomPropertyExist( Property::Index index ); + bool DoesCustomPropertyExist(Property::Index index); /** * @brief Adds a property notification to this object. @@ -455,8 +452,8 @@ public: * @param[in] condition The notification will be triggered when this condition is satisfied * @return A handle to the newly created PropertyNotification */ - PropertyNotification AddPropertyNotification( Property::Index index, - const PropertyCondition& condition ); + PropertyNotification AddPropertyNotification(Property::Index index, + const PropertyCondition& condition); /** * @brief Adds a property notification to this object. @@ -467,9 +464,9 @@ public: * @param[in] condition The notification will be triggered when this condition is satisfied * @return A handle to the newly created PropertyNotification */ - PropertyNotification AddPropertyNotification( Property::Index index, - int componentIndex, - const PropertyCondition& condition ); + PropertyNotification AddPropertyNotification(Property::Index index, + int componentIndex, + const PropertyCondition& condition); /** * @brief Removes a property notification from this object. @@ -477,7 +474,7 @@ public: * @SINCE_1_0.0 * @param[in] propertyNotification The propertyNotification to be removed */ - void RemovePropertyNotification( Dali::PropertyNotification propertyNotification ); + void RemovePropertyNotification(Dali::PropertyNotification propertyNotification); /** * @brief Removes all property notifications from this object. @@ -502,7 +499,7 @@ public: * @param[in] tag The tag of the constraints which will be removed * @pre The Object has been initialized. */ - void RemoveConstraints( uint32_t tag ); + void RemoveConstraints(uint32_t tag); /** * @brief Index operator, using integer lookup. @@ -513,7 +510,7 @@ public: * @param[in] index The index of the property to access. * @return indirect value. Should have shorter scope than the handle */ - IndirectValue operator[]( Property::Index index ); + IndirectValue operator[](Property::Index index); /** * @brief Index operator, using name lookup. @@ -524,7 +521,7 @@ public: * @param[in] name The name of the property to access. * @return indirect value. Should have shorter scope than the handle */ - IndirectValue operator[]( const std::string& name ); + IndirectValue operator[](const std::string& name); public: // Signals /** @@ -542,7 +539,6 @@ public: // Signals */ namespace WeightObject { - DALI_CORE_API extern const Property::Index WEIGHT; ///< name "weight", type FLOAT /** diff --git a/dali/public-api/object/indirect-value.cpp b/dali/public-api/object/indirect-value.cpp index 321feaa..5dee0fe 100644 --- a/dali/public-api/object/indirect-value.cpp +++ b/dali/public-api/object/indirect-value.cpp @@ -14,22 +14,20 @@ * limitations under the License. */ - -#include -#include #include +#include +#include namespace Dali { - -IndirectValue::IndirectValue( Handle& handle, Property::Index index ) +IndirectValue::IndirectValue(Handle& handle, Property::Index index) : mHandle(handle.GetObjectPtr()), mIndex(index), mExtension(nullptr) { } -void IndirectValue::operator= (Property::Value value) +void IndirectValue::operator=(Property::Value value) { Handle(static_cast(mHandle.Get())).SetProperty(mIndex, value); } @@ -39,9 +37,8 @@ Property::Value IndirectValue::GetProperty() return Handle(static_cast(mHandle.Get())).GetProperty(mIndex); } -IndirectValue& IndirectValue::operator=( IndirectValue&& ) = default; - -IndirectValue::IndirectValue( IndirectValue&& ) = default; +IndirectValue& IndirectValue::operator=(IndirectValue&&) = default; +IndirectValue::IndirectValue(IndirectValue&&) = default; } // namespace Dali diff --git a/dali/public-api/object/indirect-value.h b/dali/public-api/object/indirect-value.h index 39db23c..a57baa1 100644 --- a/dali/public-api/object/indirect-value.h +++ b/dali/public-api/object/indirect-value.h @@ -18,8 +18,8 @@ */ #include -#include #include +#include #include namespace Dali @@ -31,7 +31,6 @@ namespace Dali class Handle; - /** * @brief Dali::IndirectValue is an intermediate object that enables a simpler * syntax for addressing properties. @@ -75,7 +74,7 @@ public: * @tparam Type The type of the associated property * @return The associated property cast to the desired type */ - template + template inline operator Type() { Property::Value value = GetProperty(); @@ -92,7 +91,7 @@ private: * Making this private to prevent construction of auto type or IndirectValue type. * @param[in] rhs The object to move */ - DALI_INTERNAL IndirectValue( IndirectValue&& rhs ); + DALI_INTERNAL IndirectValue(IndirectValue&& rhs); /** * @brief Move assignment operator. @@ -101,7 +100,7 @@ private: * Making this private to prevent assignment to auto type or IndirectValue type. * @param[in] rhs The object to move */ - DALI_INTERNAL IndirectValue& operator=( IndirectValue&& rhs ); + DALI_INTERNAL IndirectValue& operator=(IndirectValue&& rhs); /** * @brief Accessor for handle property. @@ -121,12 +120,13 @@ private: * @param[in] handle A reference to the associated handle * @param[in] index The index to the associated property */ - DALI_INTERNAL IndirectValue( Handle& handle, Property::Index index ); + DALI_INTERNAL IndirectValue(Handle& handle, Property::Index index); + private: IntrusivePtr mHandle; ///< A handle to the property owner - Property::Index mIndex; ///< Index of the property in the property owner. + Property::Index mIndex; ///< Index of the property in the property owner. - struct Extension; ///< Reserved for future use + struct Extension; ///< Reserved for future use Extension* mExtension; ///< Reserved for future use /// @endcond diff --git a/dali/public-api/object/object-registry.cpp b/dali/public-api/object/object-registry.cpp index f33f9fd..7830abd 100644 --- a/dali/public-api/object/object-registry.cpp +++ b/dali/public-api/object/object-registry.cpp @@ -23,7 +23,6 @@ namespace Dali { - ObjectRegistry::ObjectRegistry() { } @@ -36,9 +35,9 @@ ObjectRegistry::ObjectRegistry(const ObjectRegistry& copy) = default; ObjectRegistry& ObjectRegistry::operator=(const ObjectRegistry& rhs) = default; -ObjectRegistry::ObjectRegistry( ObjectRegistry&& rhs ) = default; +ObjectRegistry::ObjectRegistry(ObjectRegistry&& rhs) = default; -ObjectRegistry& ObjectRegistry::operator=( ObjectRegistry&& rhs ) = default; +ObjectRegistry& ObjectRegistry::operator=(ObjectRegistry&& rhs) = default; ObjectRegistry::ObjectCreatedSignalType& ObjectRegistry::ObjectCreatedSignal() { diff --git a/dali/public-api/object/object-registry.h b/dali/public-api/object/object-registry.h index 4c08e7e..4c789be 100644 --- a/dali/public-api/object/object-registry.h +++ b/dali/public-api/object/object-registry.h @@ -59,20 +59,19 @@ class ObjectRegistry; class DALI_CORE_API ObjectRegistry : public BaseHandle { public: - // Typedefs /** * @brief Object created signal. * @SINCE_1_0.0 */ - using ObjectCreatedSignalType = Signal; + using ObjectCreatedSignalType = Signal; /** * @brief Object destroyed signal. * @SINCE_1_0.0 */ - using ObjectDestroyedSignalType = Signal; + using ObjectDestroyedSignalType = Signal; /** * @brief Allows the creation of an empty objectRegistry handle. @@ -114,7 +113,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs A reference to the moved handle */ - ObjectRegistry( ObjectRegistry&& rhs ); + ObjectRegistry(ObjectRegistry&& rhs); /** * @brief Move assignment operator. @@ -123,10 +122,9 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this handle */ - ObjectRegistry& operator=( ObjectRegistry&& rhs ); + ObjectRegistry& operator=(ObjectRegistry&& rhs); public: // Signals - /** * @brief This signal is emitted when an object is created. * @@ -165,7 +163,6 @@ public: // Signals ObjectDestroyedSignalType& ObjectDestroyedSignal(); public: // Not intended for application developers - /// @cond internal /** * @brief This constructor is used by Dali Get() method. diff --git a/dali/public-api/object/property-array.cpp b/dali/public-api/object/property-array.cpp index edc79d5..2e86679 100644 --- a/dali/public-api/object/property-array.cpp +++ b/dali/public-api/object/property-array.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -23,7 +23,6 @@ namespace Dali { - namespace { }; // unnamed namespace @@ -36,27 +35,27 @@ struct Property::Array::Impl }; Property::Array::Array() -: mImpl( new Impl ) +: mImpl(new Impl) { } -Property::Array::Array( const std::initializer_list< Property::Value >& values ) +Property::Array::Array(const std::initializer_list& values) : Array() { - for( auto&& value : values ) + for(auto&& value : values) { - PushBack( value ); + PushBack(value); } } -Property::Array::Array( const Property::Array& other ) -: mImpl( new Impl ) +Property::Array::Array(const Property::Array& other) +: mImpl(new Impl) { mImpl->mArray = other.mImpl->mArray; } -Property::Array::Array( Property::Array&& other ) -: mImpl( other.mImpl ) +Property::Array::Array(Property::Array&& other) +: mImpl(other.mImpl) { other.mImpl = nullptr; } @@ -68,84 +67,84 @@ Property::Array::~Array() Property::Array::SizeType Property::Array::Count() const { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); return mImpl->mArray.size(); } -void Property::Array::PushBack( const Value& value ) +void Property::Array::PushBack(const Value& value) { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); - mImpl->mArray.push_back( value ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); + mImpl->mArray.push_back(value); } void Property::Array::Clear() { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); mImpl->mArray.clear(); } -void Property::Array::Reserve( SizeType size ) +void Property::Array::Reserve(SizeType size) { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); mImpl->mArray.reserve(size); } -void Property::Array::Resize( SizeType size ) +void Property::Array::Resize(SizeType size) { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); mImpl->mArray.resize(size); } Property::Array::SizeType Property::Array::Capacity() { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); return mImpl->mArray.capacity(); } -const Property::Value& Property::Array::operator[]( SizeType index ) const +const Property::Value& Property::Array::operator[](SizeType index) const { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); // Note says no bounds checking is performed so we don't need to verify mImpl as Count() will return 0 anyway - return mImpl->mArray[ index ]; + return mImpl->mArray[index]; } -Property::Value& Property::Array::operator[]( SizeType index ) +Property::Value& Property::Array::operator[](SizeType index) { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); // Note says no bounds checking is performed so we don't need to verify mImpl as Count() will return 0 anyway - return mImpl->mArray[ index ]; + return mImpl->mArray[index]; } -Property::Array& Property::Array::operator=( const Property::Array& other ) +Property::Array& Property::Array::operator=(const Property::Array& other) { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); - if( this != &other ) + if(this != &other) { mImpl->mArray = other.mImpl->mArray; } return *this; } -Property::Array& Property::Array::operator=( Property::Array&& other ) +Property::Array& Property::Array::operator=(Property::Array&& other) { - if( this != &other ) + if(this != &other) { delete mImpl; - mImpl = other.mImpl; + mImpl = other.mImpl; other.mImpl = nullptr; } return *this; } -std::ostream& operator<<( std::ostream& stream, const Property::Array& array ) +std::ostream& operator<<(std::ostream& stream, const Property::Array& array) { stream << "Array(" << array.Count() << ") = ["; - for( Property::Array::SizeType i=0; i0 ) + if(i > 0) { stream << ", "; } @@ -156,5 +155,4 @@ std::ostream& operator<<( std::ostream& stream, const Property::Array& array ) return stream; } - } // namespace Dali diff --git a/dali/public-api/object/property-array.h b/dali/public-api/object/property-array.h index 3296851..05e20c8 100644 --- a/dali/public-api/object/property-array.h +++ b/dali/public-api/object/property-array.h @@ -2,7 +2,7 @@ #define DALI_PROPERTY_ARRAY_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -55,7 +55,7 @@ public: * @SINCE_1_4.17 * @param[in] values An initializer_list of values */ - Array( const std::initializer_list< Value >& values ); + Array(const std::initializer_list& values); /** * @brief Copy constructor. @@ -63,7 +63,7 @@ public: * @SINCE_1_0.0 * @param[in] other The Array to copy from */ - Array( const Array& other ); + Array(const Array& other); /** * @brief Move constructor. @@ -73,7 +73,7 @@ public: * @param[in] other The Array to move from * @note After the @a other array is used, it becomes invalid and is no longer usable. */ - Array( Array&& other ); + Array(Array&& other); /** * @brief Non-virtual destructor. @@ -122,14 +122,14 @@ public: * @SINCE_1_0.0 * @param[in] size The size to reserve */ - void Reserve( SizeType size ); + void Reserve(SizeType size); /** * @brief Resizes to size. * @SINCE_1_0.0 * @param[in] size The size to resize */ - void Resize( SizeType size ); + void Resize(SizeType size); /** * @brief Retrieves the capacity of the array. @@ -145,7 +145,7 @@ public: * @SINCE_1_0.0 * @param[in] value The value to add to the end of the array */ - void PushBack( const Value& value ); + void PushBack(const Value& value); /** * @brief Add an element to the array. @@ -154,9 +154,9 @@ public: * @param[in] value The value to add to the end of the array * @return A reference to this object */ - inline Property::Array& Add( const Value& value ) + inline Property::Array& Add(const Value& value) { - PushBack( value ); + PushBack(value); return *this; } @@ -167,9 +167,9 @@ public: * @param[in] index The element index to access. No bounds checking is performed * @return The a reference to the element */ - const Value& GetElementAt( SizeType index ) const + const Value& GetElementAt(SizeType index) const { - return operator[]( index ); + return operator[](index); } /** @@ -179,9 +179,9 @@ public: * @param[in] index The element index to access. No bounds checking is performed * @return The a reference to the element */ - Value& GetElementAt( SizeType index ) + Value& GetElementAt(SizeType index) { - return operator[]( index ); + return operator[](index); } /** @@ -192,7 +192,7 @@ public: * @return The a reference to the element * */ - const Value& operator[]( SizeType index ) const; + const Value& operator[](SizeType index) const; /** * @brief Operator to access an element. @@ -202,7 +202,7 @@ public: * @return The a reference to the element * */ - Value& operator[]( SizeType index ); + Value& operator[](SizeType index); /** * @brief Assignment operator. @@ -212,7 +212,7 @@ public: * * @return The copied array. */ - Array& operator=( const Array& other ); + Array& operator=(const Array& other); /** * @brief Move assignment operator. @@ -224,17 +224,17 @@ public: * * @note After the @a other array is used, it becomes invalid and is no longer usable. */ - Array& operator=( Array&& other ); + Array& operator=(Array&& other); /** * @brief Output to stream. * @SINCE_1_1.28 */ - friend DALI_CORE_API std::ostream& operator<<( std::ostream& stream, const Property::Array& array ); + friend DALI_CORE_API std::ostream& operator<<(std::ostream& stream, const Property::Array& array); private: - struct DALI_INTERNAL Impl; ///< Private data - Impl* mImpl; ///< Pointer to private data + struct DALI_INTERNAL Impl; ///< Private data + Impl* mImpl; ///< Pointer to private data }; /** @@ -245,7 +245,7 @@ private: * @param[in] array The array to insert * @return The output stream operator */ -DALI_CORE_API std::ostream& operator<<( std::ostream& stream, const Property::Array& array ); +DALI_CORE_API std::ostream& operator<<(std::ostream& stream, const Property::Array& array); /** * @} diff --git a/dali/public-api/object/property-conditions.cpp b/dali/public-api/object/property-conditions.cpp index e30c74d..46ee48f 100644 --- a/dali/public-api/object/property-conditions.cpp +++ b/dali/public-api/object/property-conditions.cpp @@ -19,106 +19,103 @@ #include // INTERNAL INCLUDES -#include #include +#include namespace Dali { - PropertyCondition::PropertyCondition() : BaseHandle(new Internal::PropertyCondition()) { - } PropertyCondition::~PropertyCondition() { - } -PropertyCondition::PropertyCondition( const PropertyCondition& handle ) = default; +PropertyCondition::PropertyCondition(const PropertyCondition& handle) = default; -PropertyCondition& PropertyCondition::operator=( const PropertyCondition& rhs ) = default; +PropertyCondition& PropertyCondition::operator=(const PropertyCondition& rhs) = default; -PropertyCondition::PropertyCondition( PropertyCondition&& rhs ) = default; +PropertyCondition::PropertyCondition(PropertyCondition&& rhs) = default; -PropertyCondition& PropertyCondition::operator=( PropertyCondition&& rhs ) = default; +PropertyCondition& PropertyCondition::operator=(PropertyCondition&& rhs) = default; std::size_t PropertyCondition::GetArgumentCount() const { return GetImplementation(*this).arguments.Count(); } -float PropertyCondition::GetArgument( std::size_t index ) const +float PropertyCondition::GetArgument(std::size_t index) const { - return GetImplementation(*this).arguments[ index ]; + return GetImplementation(*this).arguments[index]; } -PropertyCondition LessThanCondition( float arg ) +PropertyCondition LessThanCondition(float arg) { - PropertyCondition condition; - Internal::PropertyCondition& impl = GetImplementation( condition ); - impl.type = Internal::PropertyCondition::LessThan; - impl.arguments.PushBack( arg ); + PropertyCondition condition; + Internal::PropertyCondition& impl = GetImplementation(condition); + impl.type = Internal::PropertyCondition::LessThan; + impl.arguments.PushBack(arg); return condition; } -PropertyCondition GreaterThanCondition( float arg ) +PropertyCondition GreaterThanCondition(float arg) { - PropertyCondition condition; - Internal::PropertyCondition& impl = GetImplementation( condition ); - impl.type = Internal::PropertyCondition::GreaterThan; - impl.arguments.PushBack( arg ); + PropertyCondition condition; + Internal::PropertyCondition& impl = GetImplementation(condition); + impl.type = Internal::PropertyCondition::GreaterThan; + impl.arguments.PushBack(arg); return condition; } -PropertyCondition InsideCondition( float arg0, float arg1 ) +PropertyCondition InsideCondition(float arg0, float arg1) { - PropertyCondition condition; - Internal::PropertyCondition& impl = GetImplementation( condition ); - impl.type = Internal::PropertyCondition::Inside; - impl.arguments.PushBack( arg0 ); - impl.arguments.PushBack( arg1 ); + PropertyCondition condition; + Internal::PropertyCondition& impl = GetImplementation(condition); + impl.type = Internal::PropertyCondition::Inside; + impl.arguments.PushBack(arg0); + impl.arguments.PushBack(arg1); return condition; } -PropertyCondition OutsideCondition( float arg0, float arg1 ) +PropertyCondition OutsideCondition(float arg0, float arg1) { - PropertyCondition condition; - Internal::PropertyCondition& impl = GetImplementation( condition ); - impl.type = Internal::PropertyCondition::Outside; - impl.arguments.PushBack( arg0 ); - impl.arguments.PushBack( arg1 ); + PropertyCondition condition; + Internal::PropertyCondition& impl = GetImplementation(condition); + impl.type = Internal::PropertyCondition::Outside; + impl.arguments.PushBack(arg0); + impl.arguments.PushBack(arg1); return condition; } -PropertyCondition StepCondition( float stepAmount, float referenceValue ) +PropertyCondition StepCondition(float stepAmount, float referenceValue) { - PropertyCondition condition; - Internal::PropertyCondition& impl = GetImplementation( condition ); - impl.type = Internal::PropertyCondition::Step; - impl.arguments.PushBack( referenceValue ); - impl.arguments.PushBack( 1.0f / stepAmount ); - impl.arguments.PushBack( 0.0f ); // current step + PropertyCondition condition; + Internal::PropertyCondition& impl = GetImplementation(condition); + impl.type = Internal::PropertyCondition::Step; + impl.arguments.PushBack(referenceValue); + impl.arguments.PushBack(1.0f / stepAmount); + impl.arguments.PushBack(0.0f); // current step return condition; } -PropertyCondition VariableStepCondition( const Dali::Vector& stepAmount ) +PropertyCondition VariableStepCondition(const Dali::Vector& stepAmount) { - PropertyCondition condition; - Internal::PropertyCondition& impl = GetImplementation( condition ); - impl.type = Internal::PropertyCondition::VariableStep; - impl.arguments.PushBack( 0.0f ); // current step + PropertyCondition condition; + Internal::PropertyCondition& impl = GetImplementation(condition); + impl.type = Internal::PropertyCondition::VariableStep; + impl.arguments.PushBack(0.0f); // current step Dali::Vector::SizeType count = stepAmount.Count(); - impl.arguments.PushBack( float( count ) ); // store number of steps - for( Dali::Vector::SizeType index = 0; index < count; ++index ) + impl.arguments.PushBack(float(count)); // store number of steps + for(Dali::Vector::SizeType index = 0; index < count; ++index) { - impl.arguments.PushBack( stepAmount[index] ); + impl.arguments.PushBack(stepAmount[index]); } return condition; diff --git a/dali/public-api/object/property-conditions.h b/dali/public-api/object/property-conditions.h index 9199370..36a0df3 100644 --- a/dali/public-api/object/property-conditions.h +++ b/dali/public-api/object/property-conditions.h @@ -42,7 +42,6 @@ class PropertyCondition; class DALI_CORE_API PropertyCondition : public BaseHandle { public: - /** * @brief Constructor for condition clause. * @SINCE_1_0.0 @@ -61,7 +60,7 @@ public: * @SINCE_1_0.0 * @param[in] handle A reference to the copied handle */ - PropertyCondition( const PropertyCondition& handle ); + PropertyCondition(const PropertyCondition& handle); /** * @brief This assignment operator is required for (smart) pointer semantics. @@ -70,7 +69,7 @@ public: * @param[in] rhs A reference to the copied handle * @return A reference to this */ - PropertyCondition& operator=( const PropertyCondition& rhs ); + PropertyCondition& operator=(const PropertyCondition& rhs); /** * @brief Move constructor. @@ -78,7 +77,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs A reference to the moved handle */ - PropertyCondition( PropertyCondition&& rhs ); + PropertyCondition(PropertyCondition&& rhs); /** * @brief Move assignment operator. @@ -87,10 +86,9 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this handle */ - PropertyCondition& operator=( PropertyCondition&& rhs ); + PropertyCondition& operator=(PropertyCondition&& rhs); public: - /** * @brief Retrieves the arguments that this condition uses. * @@ -107,8 +105,7 @@ public: * @return The arguments used for this condition * @note The container will only be valid as long PropertyCondition is valid. */ - float GetArgument( std::size_t index ) const; - + float GetArgument(std::size_t index) const; }; /** @@ -124,7 +121,7 @@ public: * @param[in] arg The argument for the condition * @return A property condition function object */ -DALI_CORE_API PropertyCondition LessThanCondition( float arg ); +DALI_CORE_API PropertyCondition LessThanCondition(float arg); /** * @brief GreaterThanCondition compares whether property is greater than arg. @@ -139,7 +136,7 @@ DALI_CORE_API PropertyCondition LessThanCondition( float arg ); * @param[in] arg The argument for the condition * @return A property condition function object */ -DALI_CORE_API PropertyCondition GreaterThanCondition( float arg ); +DALI_CORE_API PropertyCondition GreaterThanCondition(float arg); /** * @brief InsideCondition compares whether property is greater than arg0 and less than arg1. @@ -155,7 +152,7 @@ DALI_CORE_API PropertyCondition GreaterThanCondition( float arg ); * @param[in] arg1 The second argument for the condition * @return A property condition function object */ -DALI_CORE_API PropertyCondition InsideCondition( float arg0, float arg1 ); +DALI_CORE_API PropertyCondition InsideCondition(float arg0, float arg1); /** * @brief OutsideCondition compares whether property is less than arg0 or greater than arg1. @@ -171,7 +168,7 @@ DALI_CORE_API PropertyCondition InsideCondition( float arg0, float arg1 ); * @param[in] arg1 The second argument for the condition * @return A property condition function object */ -DALI_CORE_API PropertyCondition OutsideCondition( float arg0, float arg1 ); +DALI_CORE_API PropertyCondition OutsideCondition(float arg0, float arg1); /** * @brief Detects when a property changes by stepAmount from initialValue, in both positive and negative directions. This will continue checking for multiples of stepAmount. @@ -186,7 +183,7 @@ DALI_CORE_API PropertyCondition OutsideCondition( float arg0, float arg1 ); * @param[in] initialValue The initial value to step from * @return A property condition function object */ -DALI_CORE_API PropertyCondition StepCondition( float stepAmount, float initialValue = 0.0f ); +DALI_CORE_API PropertyCondition StepCondition(float stepAmount, float initialValue = 0.0f); /** * @brief Receives notifications as a property goes above/below the inputted values. Values must be ordered and can be either ascending or descending. @@ -200,7 +197,7 @@ DALI_CORE_API PropertyCondition StepCondition( float stepAmount, float initialVa * @param[in] steps List of values to receive notifications for as a property crosses them * @return A property condition function object */ -DALI_CORE_API PropertyCondition VariableStepCondition( const Dali::Vector& steps ); +DALI_CORE_API PropertyCondition VariableStepCondition(const Dali::Vector& steps); /** * @} diff --git a/dali/public-api/object/property-index-ranges.h b/dali/public-api/object/property-index-ranges.h index f8b8daf..bb43b42 100644 --- a/dali/public-api/object/property-index-ranges.h +++ b/dali/public-api/object/property-index-ranges.h @@ -2,7 +2,7 @@ #define DALI_PROPERTY_INDEX_RANGES_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -35,38 +35,38 @@ namespace Dali * used to compare property indices. * @SINCE_1_0.0 */ +// clang-format off enum PropertyRanges { - DEFAULT_OBJECT_PROPERTY_START_INDEX = 0, ///< For all objects deriving from Handle (including Actors). @SINCE_1_0.0 - - DEFAULT_ACTOR_PROPERTY_START_INDEX = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< Start index for Actor. @SINCE_1_0.0 - DEFAULT_ACTOR_PROPERTY_MAX_COUNT = 10000, ///< Actor range: 0 to 9999 @SINCE_1_0.0 + DEFAULT_OBJECT_PROPERTY_START_INDEX = 0, ///< For all objects deriving from Handle (including Actors). @SINCE_1_0.0 + DEFAULT_ACTOR_PROPERTY_START_INDEX = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< Start index for Actor. @SINCE_1_0.0 + DEFAULT_ACTOR_PROPERTY_MAX_COUNT = 10000, ///< Actor range: 0 to 9999 @SINCE_1_0.0 DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX = DEFAULT_ACTOR_PROPERTY_START_INDEX + DEFAULT_ACTOR_PROPERTY_MAX_COUNT, ///< Property start index for classes deriving directly from Actor. @SINCE_1_0.0 + DEFAULT_PROPERTY_MAX_COUNT_PER_DERIVATION = 10000, ///< Second-level and onwards derived objects should increment their start index by this. @SINCE_1_0.0 - DEFAULT_PROPERTY_MAX_COUNT_PER_DERIVATION = 10000, ///< Second-level and onwards derived objects should increment their start index by this. @SINCE_1_0.0 - - DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX = DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX, ///< Used by PanGestureDetector. @SINCE_1_0.0 + DEFAULT_GESTURE_DETECTOR_PROPERTY_START_INDEX = DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX, ///< Used by PanGestureDetector. @SINCE_1_0.0 - DEFAULT_RENDERER_PROPERTY_START_INDEX = 9000000, ///< Start index for Renderer. @SINCE_1_1.44 - DEFAULT_RENDERER_PROPERTY_MAX_INDEX = DEFAULT_RENDERER_PROPERTY_START_INDEX + 100000, ///< Renderer range: 9000000 to 9100000 @SINCE_1_1.44 + DEFAULT_RENDERER_PROPERTY_START_INDEX = 9000000, ///< Start index for Renderer. @SINCE_1_1.44 + DEFAULT_RENDERER_PROPERTY_MAX_INDEX = DEFAULT_RENDERER_PROPERTY_START_INDEX + 100000, ///< Renderer range: 9000000 to 9100000 @SINCE_1_1.44 - PROPERTY_REGISTRATION_START_INDEX = 10000000, ///< The index when registering a property should start from this number. @SINCE_1_0.0 - DEFAULT_PROPERTY_MAX_COUNT = PROPERTY_REGISTRATION_START_INDEX, ///< Default Property Range: 0 to 9999999 @SINCE_1_0.0 + PROPERTY_REGISTRATION_START_INDEX = 10000000, ///< The index when registering a property should start from this number. @SINCE_1_0.0 + DEFAULT_PROPERTY_MAX_COUNT = PROPERTY_REGISTRATION_START_INDEX, ///< Default Property Range: 0 to 9999999 @SINCE_1_0.0 - PROPERTY_REGISTRATION_MAX_INDEX = 19999999, ///< The maximum index supported when registering a property @SINCE_1_0.0 + PROPERTY_REGISTRATION_MAX_INDEX = 19999999, ///< The maximum index supported when registering a property @SINCE_1_0.0 - ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX = 20000000, ///< The index when registering an animatable property should start from this number. (SceneGraph properties per type) @SINCE_1_0.0 - ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX = 29999999, ///< The maximum index supported when registering an animatable property @SINCE_1_0.0 + ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX = 20000000, ///< The index when registering an animatable property should start from this number. (SceneGraph properties per type) @SINCE_1_0.0 + ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX = 29999999, ///< The maximum index supported when registering an animatable property @SINCE_1_0.0 - CHILD_PROPERTY_REGISTRATION_START_INDEX = 45000000, ///< The index when registering a child property should start from this number. (Event side properties per instance) @SINCE_1_1.35 - CHILD_PROPERTY_REGISTRATION_MAX_INDEX = 49999999, ///< The maximum index supported when registering a child property @SINCE_1_1.35 + CHILD_PROPERTY_REGISTRATION_START_INDEX = 45000000, ///< The index when registering a child property should start from this number. (Event side properties per instance) @SINCE_1_1.35 + CHILD_PROPERTY_REGISTRATION_MAX_INDEX = 49999999, ///< The maximum index supported when registering a child property @SINCE_1_1.35 - PROPERTY_CUSTOM_START_INDEX = 50000000, ///< The index at which custom properties start (SceneGraph and Event side properties per instance) @SINCE_1_0.0 - PROPERTY_CUSTOM_MAX_INDEX = 59999999, ///< The maximum index supported for custom properties @SINCE_1_1.45 + PROPERTY_CUSTOM_START_INDEX = 50000000, ///< The index at which custom properties start (SceneGraph and Event side properties per instance) @SINCE_1_0.0 + PROPERTY_CUSTOM_MAX_INDEX = 59999999, ///< The maximum index supported for custom properties @SINCE_1_1.45 - CORE_PROPERTY_MAX_INDEX = PROPERTY_CUSTOM_MAX_INDEX, ///< The maximum index that Core properties can go up to @SINCE_1_1.45 + CORE_PROPERTY_MAX_INDEX = PROPERTY_CUSTOM_MAX_INDEX, ///< The maximum index that Core properties can go up to @SINCE_1_1.45 }; +// clang-format on /** * @} diff --git a/dali/public-api/object/property-input.cpp b/dali/public-api/object/property-input.cpp index 47937b3..3b6c820 100644 --- a/dali/public-api/object/property-input.cpp +++ b/dali/public-api/object/property-input.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -20,7 +20,6 @@ namespace Dali { - PropertyInput::~PropertyInput() { } diff --git a/dali/public-api/object/property-input.h b/dali/public-api/object/property-input.h index e5d6f6a..507bb9c 100644 --- a/dali/public-api/object/property-input.h +++ b/dali/public-api/object/property-input.h @@ -2,7 +2,7 @@ #define DALI_PROPERTY_INPUT_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -42,7 +42,6 @@ class Quaternion; class DALI_CORE_API PropertyInput { public: - class Extension; ///< Forward declare future extension interface /** diff --git a/dali/public-api/object/property-key.cpp b/dali/public-api/object/property-key.cpp index 1d309d0..c57f331 100644 --- a/dali/public-api/object/property-key.cpp +++ b/dali/public-api/object/property-key.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -18,33 +18,31 @@ // CLASS HEADER #include - namespace Dali { - -Property::Key::Key( const std::string& key ) -: type( Key::STRING ), - indexKey( Property::INVALID_INDEX ), - stringKey( key ) +Property::Key::Key(const std::string& key) +: type(Key::STRING), + indexKey(Property::INVALID_INDEX), + stringKey(key) { } -Property::Key::Key( Property::Index key ) -: type( Key::INDEX ), - indexKey( key ) +Property::Key::Key(Property::Index key) +: type(Key::INDEX), + indexKey(key) { } -Property::Key::Key( const char * key ) -: type( Key::STRING ), - indexKey( Property::INVALID_INDEX ), - stringKey( key ) +Property::Key::Key(const char* key) +: type(Key::STRING), + indexKey(Property::INVALID_INDEX), + stringKey(key) { } -bool Property::Key::operator== (const std::string& rhs) +bool Property::Key::operator==(const std::string& rhs) { - bool result=false; + bool result = false; if(type == Key::STRING) { result = (stringKey == rhs); @@ -52,14 +50,14 @@ bool Property::Key::operator== (const std::string& rhs) return result; } -bool Property::Key::operator== ( const char* rhs ) +bool Property::Key::operator==(const char* rhs) { - return operator==( std::string( rhs ) ); + return operator==(std::string(rhs)); } -bool Property::Key::operator== (Property::Index rhs) +bool Property::Key::operator==(Property::Index rhs) { - bool result=false; + bool result = false; if(type == Key::INDEX) { result = (indexKey == rhs); @@ -67,43 +65,43 @@ bool Property::Key::operator== (Property::Index rhs) return result; } -bool Property::Key::operator== (const Key& rhs) +bool Property::Key::operator==(const Key& rhs) { - bool result=false; - if(type == Key::STRING && rhs.type == Key::STRING ) + bool result = false; + if(type == Key::STRING && rhs.type == Key::STRING) { result = (stringKey == rhs.stringKey); } - else if( type == Key::INDEX && rhs.type == Key::INDEX ) + else if(type == Key::INDEX && rhs.type == Key::INDEX) { result = (indexKey == rhs.indexKey); } return result; } -bool Property::Key::operator!= (const std::string& rhs) +bool Property::Key::operator!=(const std::string& rhs) { return !operator==(rhs); } -bool Property::Key::operator!= ( const char* rhs ) +bool Property::Key::operator!=(const char* rhs) { return !operator==(rhs); } -bool Property::Key::operator!= (Property::Index rhs) +bool Property::Key::operator!=(Property::Index rhs) { return !operator==(rhs); } -bool Property::Key::operator!= (const Key& rhs) +bool Property::Key::operator!=(const Key& rhs) { return !operator==(rhs); } -std::ostream& operator<<( std::ostream& stream, const Property::Key& key ) +std::ostream& operator<<(std::ostream& stream, const Property::Key& key) { - if( key.type == Property::Key::INDEX ) + if(key.type == Property::Key::INDEX) { stream << key.indexKey; } diff --git a/dali/public-api/object/property-key.h b/dali/public-api/object/property-key.h index 1feb441..a7f7569 100644 --- a/dali/public-api/object/property-key.h +++ b/dali/public-api/object/property-key.h @@ -2,7 +2,7 @@ #define DALI_PROPERTY_KEY_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -19,8 +19,8 @@ */ // EXTERNAL INCLUDES -#include #include +#include // INTERNAL INCLUDES #include @@ -47,10 +47,10 @@ struct DALI_CORE_API Property::Key { INDEX, ///< The key is a Property::Index STRING ///< The key is a string - } type; ///< The type of the key + } type; ///< The type of the key - Property::Index indexKey; ///< The index key. - std::string stringKey; ///< The string key. + Property::Index indexKey; ///< The index key. + std::string stringKey; ///< The string key. /** * @brief Constructor @@ -58,7 +58,7 @@ struct DALI_CORE_API Property::Key * * @param[in] key The string key */ - Key( const std::string& key ); + Key(const std::string& key); /** * @brief Constructor @@ -66,7 +66,7 @@ struct DALI_CORE_API Property::Key * * @param[in] key The string key as a const char * */ - Key( const char * key ); + Key(const char* key); /** * @brief Constructor @@ -74,7 +74,7 @@ struct DALI_CORE_API Property::Key * * @param[in] key The index key */ - Key( Property::Index key ); + Key(Property::Index key); /** * @brief The equality operator @@ -83,7 +83,7 @@ struct DALI_CORE_API Property::Key * @param[in] rhs A string key to compare against. * @return true if the key compares, or false if it isn't equal or of the wrong type */ - bool operator== (const std::string& rhs); + bool operator==(const std::string& rhs); /** * @brief Constructor @@ -92,7 +92,7 @@ struct DALI_CORE_API Property::Key * @param[in] key The string key as a const char * * @return true if the key compares, or false if it isn't equal or of the wrong type */ - bool operator== ( const char * key ); + bool operator==(const char* key); /** * @brief The equality operator @@ -101,7 +101,7 @@ struct DALI_CORE_API Property::Key * @param[in] rhs An index key to compare against. * @return true if the key compares, or false if it isn't equal or of the wrong type */ - bool operator== (Property::Index rhs); + bool operator==(Property::Index rhs); /** * @brief The equality operator @@ -110,7 +110,7 @@ struct DALI_CORE_API Property::Key * @param[in] rhs A key to compare against. * @return true if the keys are of the same type and have the same value */ - bool operator== (const Key& rhs); + bool operator==(const Key& rhs); /** * @brief The inequality operator @@ -119,7 +119,7 @@ struct DALI_CORE_API Property::Key * @param[in] rhs A string key to compare against. * @return true if the key is not equal or not a string key */ - bool operator!= (const std::string& rhs); + bool operator!=(const std::string& rhs); /** * @brief The inequality operator @@ -128,7 +128,7 @@ struct DALI_CORE_API Property::Key * @param[in] rhs A const char* key to compare against. * @return true if the key is not equal or not a string key */ - bool operator!= ( const char* rhs ); + bool operator!=(const char* rhs); /** * @brief The inequality operator @@ -137,7 +137,7 @@ struct DALI_CORE_API Property::Key * @param[in] rhs An index key to compare against. * @return true if the key is not equal, or not an index key */ - bool operator!= (Property::Index rhs); + bool operator!=(Property::Index rhs); /** * @brief The inequality operator @@ -146,7 +146,7 @@ struct DALI_CORE_API Property::Key * @param[in] rhs A key to compare against. * @return true if the keys are not of the same type or are not equal */ - bool operator!= (const Key& rhs); + bool operator!=(const Key& rhs); }; /** @@ -157,8 +157,7 @@ struct DALI_CORE_API Property::Key * @param [in] key the key to convert * @return The output stream operator. */ -DALI_CORE_API std::ostream& operator<<( std::ostream& stream, const Property::Key& key ); - +DALI_CORE_API std::ostream& operator<<(std::ostream& stream, const Property::Key& key); /** * @} diff --git a/dali/public-api/object/property-map.cpp b/dali/public-api/object/property-map.cpp index d458109..4e9aaaa 100644 --- a/dali/public-api/object/property-map.cpp +++ b/dali/public-api/object/property-map.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -26,58 +26,57 @@ namespace Dali { - namespace { -typedef std::vector< StringValuePair > StringValueContainer; +typedef std::vector StringValueContainer; using IndexValuePair = std::pair; using IndexValueContainer = std::vector; }; // unnamed namespace - struct Property::Map::Impl { StringValueContainer mStringValueContainer; - IndexValueContainer mIndexValueContainer; + IndexValueContainer mIndexValueContainer; }; Property::Map::Map() -: mImpl( new Impl ) +: mImpl(new Impl) { } -Property::Map::Map( const std::initializer_list< KeyValuePair >& values ) : Map() +Property::Map::Map(const std::initializer_list& values) +: Map() { - for( auto&& value : values ) + for(auto&& value : values) { const auto& key = value.first; - switch( key.type ) + switch(key.type) { case Property::Key::INDEX: { - Property::Map::Insert( key.indexKey, value.second ); + Property::Map::Insert(key.indexKey, value.second); break; } case Property::Key::STRING: { - Property::Map::Insert( key.stringKey, value.second ); + Property::Map::Insert(key.stringKey, value.second); break; } } } } -Property::Map::Map( const Property::Map& other ) -: mImpl( new Impl ) +Property::Map::Map(const Property::Map& other) +: mImpl(new Impl) { mImpl->mStringValueContainer = other.mImpl->mStringValueContainer; - mImpl->mIndexValueContainer = other.mImpl->mIndexValueContainer; + mImpl->mIndexValueContainer = other.mImpl->mIndexValueContainer; } -Property::Map::Map( Property::Map&& other ) -: mImpl( other.mImpl ) +Property::Map::Map(Property::Map&& other) +: mImpl(other.mImpl) { other.mImpl = nullptr; } @@ -89,125 +88,125 @@ Property::Map::~Map() Property::Map::SizeType Property::Map::Count() const { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); return mImpl->mStringValueContainer.size() + mImpl->mIndexValueContainer.size(); } bool Property::Map::Empty() const { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); return mImpl->mStringValueContainer.empty() && mImpl->mIndexValueContainer.empty(); } -void Property::Map::Insert( const char* key, const Value& value ) +void Property::Map::Insert(const char* key, const Value& value) { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); - mImpl->mStringValueContainer.push_back( std::make_pair( key, value ) ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); + mImpl->mStringValueContainer.push_back(std::make_pair(key, value)); } -void Property::Map::Insert( const std::string& key, const Value& value ) +void Property::Map::Insert(const std::string& key, const Value& value) { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); - mImpl->mStringValueContainer.push_back( std::make_pair( key, value ) ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); + mImpl->mStringValueContainer.push_back(std::make_pair(key, value)); } -void Property::Map::Insert( Property::Index key, const Value& value ) +void Property::Map::Insert(Property::Index key, const Value& value) { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); - mImpl->mIndexValueContainer.push_back( std::make_pair( key, value ) ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); + mImpl->mIndexValueContainer.push_back(std::make_pair(key, value)); } -Property::Value& Property::Map::GetValue( SizeType position ) const +Property::Value& Property::Map::GetValue(SizeType position) const { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); SizeType numStringKeys = mImpl->mStringValueContainer.size(); SizeType numIndexKeys = mImpl->mIndexValueContainer.size(); - DALI_ASSERT_ALWAYS( position < ( numStringKeys + numIndexKeys ) && "position out-of-bounds" ); + DALI_ASSERT_ALWAYS(position < (numStringKeys + numIndexKeys) && "position out-of-bounds"); - if( position < numStringKeys ) + if(position < numStringKeys) { - return mImpl->mStringValueContainer[ position ].second; + return mImpl->mStringValueContainer[position].second; } else { - return mImpl->mIndexValueContainer[ position-numStringKeys ].second; + return mImpl->mIndexValueContainer[position - numStringKeys].second; } } -const std::string& Property::Map::GetKey( SizeType position ) const +const std::string& Property::Map::GetKey(SizeType position) const { - DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetKey() is deprecated and will be removed from next release.\n" ); + DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetKey() is deprecated and will be removed from next release.\n"); - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); SizeType numStringKeys = mImpl->mStringValueContainer.size(); - DALI_ASSERT_ALWAYS( position < numStringKeys && "position out-of-bounds" ); + DALI_ASSERT_ALWAYS(position < numStringKeys && "position out-of-bounds"); - return mImpl->mStringValueContainer[ position ].first; + return mImpl->mStringValueContainer[position].first; } -Property::Key Property::Map::GetKeyAt( SizeType position ) const +Property::Key Property::Map::GetKeyAt(SizeType position) const { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); SizeType numStringKeys = mImpl->mStringValueContainer.size(); SizeType numIndexKeys = mImpl->mIndexValueContainer.size(); - DALI_ASSERT_ALWAYS( position < ( numStringKeys + numIndexKeys ) && "position out-of-bounds" ); + DALI_ASSERT_ALWAYS(position < (numStringKeys + numIndexKeys) && "position out-of-bounds"); - if( position < numStringKeys ) + if(position < numStringKeys) { - Key key(mImpl->mStringValueContainer[ position ].first); + Key key(mImpl->mStringValueContainer[position].first); return key; } else { - Key key( mImpl->mIndexValueContainer[ position-numStringKeys ].first ); + Key key(mImpl->mIndexValueContainer[position - numStringKeys].first); return key; } } -StringValuePair& Property::Map::GetPair( SizeType position ) const +StringValuePair& Property::Map::GetPair(SizeType position) const { - DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetPair() is deprecated and will be removed from next release.\n" ); + DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: GetPair() is deprecated and will be removed from next release.\n"); - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); SizeType numStringKeys = mImpl->mStringValueContainer.size(); - DALI_ASSERT_ALWAYS( position < ( numStringKeys ) && "position out-of-bounds" ); + DALI_ASSERT_ALWAYS(position < (numStringKeys) && "position out-of-bounds"); - return mImpl->mStringValueContainer[ position ]; + return mImpl->mStringValueContainer[position]; } -KeyValuePair Property::Map::GetKeyValue( SizeType position ) const +KeyValuePair Property::Map::GetKeyValue(SizeType position) const { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); SizeType numStringKeys = mImpl->mStringValueContainer.size(); SizeType numIndexKeys = mImpl->mIndexValueContainer.size(); - DALI_ASSERT_ALWAYS( position < ( numStringKeys + numIndexKeys ) && "position out-of-bounds" ); + DALI_ASSERT_ALWAYS(position < (numStringKeys + numIndexKeys) && "position out-of-bounds"); - if( position < numStringKeys ) + if(position < numStringKeys) { - Key key(mImpl->mStringValueContainer[ position ].first); - KeyValuePair keyValue(key, mImpl->mStringValueContainer[ position ].second ); + Key key(mImpl->mStringValueContainer[position].first); + KeyValuePair keyValue(key, mImpl->mStringValueContainer[position].second); return keyValue; } else { - Key key( mImpl->mIndexValueContainer[ position-numStringKeys ].first ); - KeyValuePair keyValue(key, mImpl->mIndexValueContainer[ position-numStringKeys ].second ); + Key key(mImpl->mIndexValueContainer[position - numStringKeys].first); + KeyValuePair keyValue(key, mImpl->mIndexValueContainer[position - numStringKeys].second); return keyValue; } } -Property::Value* Property::Map::Find( const char* key ) const +Property::Value* Property::Map::Find(const char* key) const { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); - for( auto&& iter : mImpl->mStringValueContainer ) + for(auto&& iter : mImpl->mStringValueContainer) { - if ( iter.first == key ) + if(iter.first == key) { return &iter.second; } @@ -215,18 +214,18 @@ Property::Value* Property::Map::Find( const char* key ) const return nullptr; // Not found } -Property::Value* Property::Map::Find( const std::string& key ) const +Property::Value* Property::Map::Find(const std::string& key) const { - return Find( key.c_str() ); + return Find(key.c_str()); } -Property::Value* Property::Map::Find( Property::Index key ) const +Property::Value* Property::Map::Find(Property::Index key) const { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); - for( auto&& iter : mImpl->mIndexValueContainer ) + for(auto&& iter : mImpl->mIndexValueContainer) { - if ( iter.first == key ) + if(iter.first == key) { return &iter.second; } @@ -234,23 +233,23 @@ Property::Value* Property::Map::Find( Property::Index key ) const return nullptr; // Not found } -Property::Value* Property::Map::Find( Property::Index indexKey, const std::string& stringKey ) const +Property::Value* Property::Map::Find(Property::Index indexKey, const std::string& stringKey) const { - Property::Value* valuePtr = Find( indexKey ); - if( !valuePtr ) + Property::Value* valuePtr = Find(indexKey); + if(!valuePtr) { - valuePtr = Find( stringKey ); + valuePtr = Find(stringKey); } return valuePtr; } -Property::Value* Property::Map::Find( const std::string& key, Property::Type type ) const +Property::Value* Property::Map::Find(const std::string& key, Property::Type type) const { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); - for( auto&& iter : mImpl->mStringValueContainer ) + for(auto&& iter : mImpl->mStringValueContainer) { - if( (iter.second.GetType() == type) && (iter.first == key) ) + if((iter.second.GetType() == type) && (iter.first == key)) { return &iter.second; } @@ -258,13 +257,13 @@ Property::Value* Property::Map::Find( const std::string& key, Property::Type typ return nullptr; // Not found } -Property::Value* Property::Map::Find( Property::Index key, Property::Type type ) const +Property::Value* Property::Map::Find(Property::Index key, Property::Type type) const { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); - for( auto&& iter : mImpl->mIndexValueContainer ) + for(auto&& iter : mImpl->mIndexValueContainer) { - if( (iter.second.GetType() == type) && (iter.first == key) ) + if((iter.second.GetType() == type) && (iter.first == key)) { return &iter.second; } @@ -274,27 +273,27 @@ Property::Value* Property::Map::Find( Property::Index key, Property::Type type ) void Property::Map::Clear() { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); mImpl->mStringValueContainer.clear(); mImpl->mIndexValueContainer.clear(); } -void Property::Map::Merge( const Property::Map& from ) +void Property::Map::Merge(const Property::Map& from) { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); // Ensure we're not attempting to merge with ourself - if ( this != &from ) + if(this != &from) { - if ( Count() ) + if(Count()) { - for( auto&& iter : from.mImpl->mStringValueContainer ) + for(auto&& iter : from.mImpl->mStringValueContainer) { (*this)[iter.first] = iter.second; } - for( auto&& iter : from.mImpl->mIndexValueContainer ) + for(auto&& iter : from.mImpl->mIndexValueContainer) { (*this)[iter.first] = iter.second; } @@ -307,118 +306,118 @@ void Property::Map::Merge( const Property::Map& from ) } } -const Property::Value& Property::Map::operator[]( const std::string& key ) const +const Property::Value& Property::Map::operator[](const std::string& key) const { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); - for( auto&& iter : mImpl->mStringValueContainer ) + for(auto&& iter : mImpl->mStringValueContainer) { - if ( iter.first == key ) + if(iter.first == key) { return iter.second; } } - DALI_ASSERT_ALWAYS( ! "Invalid Key" ); + DALI_ASSERT_ALWAYS(!"Invalid Key"); } -Property::Value& Property::Map::operator[]( const std::string& key ) +Property::Value& Property::Map::operator[](const std::string& key) { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); - for( auto&& iter : mImpl->mStringValueContainer ) + for(auto&& iter : mImpl->mStringValueContainer) { - if ( iter.first == key ) + if(iter.first == key) { return iter.second; } } // Create and return reference to new value - mImpl->mStringValueContainer.push_back( std::make_pair( key, Property::Value() ) ); + mImpl->mStringValueContainer.push_back(std::make_pair(key, Property::Value())); return (mImpl->mStringValueContainer.end() - 1)->second; } -const Property::Value& Property::Map::operator[]( Property::Index key ) const +const Property::Value& Property::Map::operator[](Property::Index key) const { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); - for( auto&& iter : mImpl->mIndexValueContainer ) + for(auto&& iter : mImpl->mIndexValueContainer) { - if ( iter.first == key ) + if(iter.first == key) { return iter.second; } } - DALI_ASSERT_ALWAYS( ! "Invalid Key" ); + DALI_ASSERT_ALWAYS(!"Invalid Key"); } -Property::Value& Property::Map::operator[]( Property::Index key ) +Property::Value& Property::Map::operator[](Property::Index key) { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); - for( auto&& iter : mImpl->mIndexValueContainer ) + for(auto&& iter : mImpl->mIndexValueContainer) { - if ( iter.first == key ) + if(iter.first == key) { return iter.second; } } // Create and return reference to new value - mImpl->mIndexValueContainer.push_back( std::make_pair( key, Property::Value() ) ); + mImpl->mIndexValueContainer.push_back(std::make_pair(key, Property::Value())); return (mImpl->mIndexValueContainer.end() - 1)->second; } -Property::Map& Property::Map::operator=( const Property::Map& other ) +Property::Map& Property::Map::operator=(const Property::Map& other) { - DALI_ASSERT_DEBUG( mImpl && "Cannot use an object previously used as an r-value" ); + DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value"); - if( this != &other ) + if(this != &other) { mImpl->mStringValueContainer = other.mImpl->mStringValueContainer; - mImpl->mIndexValueContainer = other.mImpl->mIndexValueContainer; + mImpl->mIndexValueContainer = other.mImpl->mIndexValueContainer; } return *this; } -Property::Map& Property::Map::operator=( Property::Map&& other ) +Property::Map& Property::Map::operator=(Property::Map&& other) { - if( this != &other ) + if(this != &other) { delete mImpl; - mImpl = other.mImpl; + mImpl = other.mImpl; other.mImpl = nullptr; } return *this; } -std::ostream& operator<<( std::ostream& stream, const Property::Map& map ) +std::ostream& operator<<(std::ostream& stream, const Property::Map& map) { stream << "Map(" << map.Count() << ") = {"; - if ( map.mImpl ) + if(map.mImpl) { int32_t count = 0; // Output the String-Value pairs - for( auto&& iter : map.mImpl->mStringValueContainer ) + for(auto&& iter : map.mImpl->mStringValueContainer) { - if( count++ > 0 ) + if(count++ > 0) { - stream<<", "; + stream << ", "; } - stream<< iter.first << ":" << iter.second; + stream << iter.first << ":" << iter.second; } // Output the Index-Value pairs - for( auto&& iter : map.mImpl->mIndexValueContainer ) + for(auto&& iter : map.mImpl->mIndexValueContainer) { - if( count++ > 0 ) + if(count++ > 0) { - stream<<", "; + stream << ", "; } - stream<< iter.first << ":" << iter.second; + stream << iter.first << ":" << iter.second; } } diff --git a/dali/public-api/object/property-map.h b/dali/public-api/object/property-map.h index 259aaae..115a7fa 100644 --- a/dali/public-api/object/property-map.h +++ b/dali/public-api/object/property-map.h @@ -2,7 +2,7 @@ #define DALI_PROPERTY_MAP_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -19,15 +19,15 @@ */ // EXTERNAL INCLUDES -#include -#include #include +#include +#include // INTERNAL INCLUDES #include -#include #include #include +#include namespace Dali { @@ -60,7 +60,7 @@ public: * @SINCE_1_4.17 * @param[in] values An initializer_list of pairs of index and value. */ - Map( const std::initializer_list< KeyValuePair >& values ); + Map(const std::initializer_list& values); /** * @brief Copy constructor. @@ -68,7 +68,7 @@ public: * @SINCE_1_0.0 * @param[in] other The Map to copy from */ - Map( const Map& other ); + Map(const Map& other); /** * @brief Move constructor. @@ -77,7 +77,7 @@ public: * @param[in] other The Map to move from * @note After the @a other array is used, it becomes invalid and is no longer usable. */ - Map( Map&& other ); + Map(Map&& other); /** * @brief Non-virtual destructor. @@ -109,7 +109,7 @@ public: * @param[in] key The key to insert * @param[in] value The value to insert */ - void Insert( const char* key, const Value& value ); + void Insert(const char* key, const Value& value); /** * @brief Inserts the key-value pair in the Map, with the key type as string. @@ -119,7 +119,7 @@ public: * @param[in] key The key to insert * @param[in] value The value to insert */ - void Insert( const std::string& key, const Value& value ); + void Insert(const std::string& key, const Value& value); /** * @brief Inserts the key-value pair in the Map, with the key type as index. @@ -129,8 +129,7 @@ public: * @param[in] key The key to insert * @param[in] value The value to insert */ - void Insert( Property::Index key, const Value& value ); - + void Insert(Property::Index key, const Value& value); /** * @brief Inserts the key-value pair in the Map, with the key type as string. @@ -141,7 +140,7 @@ public: * @param value to insert * @return a reference to this object */ - inline Property::Map& Add( const char* key, const Value& value ) + inline Property::Map& Add(const char* key, const Value& value) { Insert(key, value); return *this; @@ -156,13 +155,12 @@ public: * @param value to insert * @return a reference to this object */ - inline Property::Map& Add( const std::string& key, const Value& value ) + inline Property::Map& Add(const std::string& key, const Value& value) { Insert(key, value); return *this; } - /** * @brief Inserts the key-value pair in the Map, with the key type as index. * @@ -172,7 +170,7 @@ public: * @param value to insert * @return a reference to this object */ - inline Property::Map& Add( Property::Index key, const Value& value ) + inline Property::Map& Add(Property::Index key, const Value& value) { Insert(key, value); return *this; @@ -187,7 +185,7 @@ public: * * @note Will assert if position >= Count() */ - Value& GetValue( SizeType position ) const; + Value& GetValue(SizeType position) const; /** * DEPRECATED_1_1.39 Position based retrieval is no longer supported after extending the key type to both Index and String. @@ -200,7 +198,7 @@ public: * * @note Will assert if position >= Count() */ - const std::string& GetKey( SizeType position ) const DALI_DEPRECATED_API; + const std::string& GetKey(SizeType position) const DALI_DEPRECATED_API; /** * @brief Retrieve the key at the specified position. @@ -211,7 +209,7 @@ public: * * @note Will assert if position >= Count() */ - Key GetKeyAt( SizeType position ) const; + Key GetKeyAt(SizeType position) const; /** * DEPRECATED_1_1.39 Position based retrieval is no longer supported after extending the key type to both Index and String. @@ -224,7 +222,7 @@ public: * * @note Will assert if position >= Count() or key at position is an index key. */ - StringValuePair& GetPair( SizeType position ) const DALI_DEPRECATED_API; + StringValuePair& GetPair(SizeType position) const DALI_DEPRECATED_API; /** * @brief Retrieve the key & the value at the specified position. @@ -235,7 +233,7 @@ public: * * @note Will assert if position >= Count() */ - KeyValuePair GetKeyValue( SizeType position ) const; + KeyValuePair GetKeyValue(SizeType position) const; /** * @brief Finds the value for the specified key if it exists. @@ -245,7 +243,7 @@ public: * * @return A const pointer to the value if it exists, NULL otherwise */ - Value* Find( const char* key ) const; + Value* Find(const char* key) const; /** * @brief Finds the value for the specified key if it exists. @@ -255,7 +253,7 @@ public: * * @return A const pointer to the value if it exists, NULL otherwise */ - Value* Find( const std::string& key ) const; + Value* Find(const std::string& key) const; /** * @brief Finds the value for the specified key if it exists. @@ -265,7 +263,7 @@ public: * * @return A const pointer to the value if it exists, NULL otherwise */ - Value* Find( Property::Index key ) const; + Value* Find(Property::Index key) const; /** * @brief Finds the value for the specified keys if either exist. @@ -278,7 +276,7 @@ public: * * @return A const pointer to the value if it exists, NULL otherwise */ - Value* Find( Property::Index indexKey, const std::string& stringKey ) const; + Value* Find(Property::Index indexKey, const std::string& stringKey) const; /** * @brief Finds the value for the specified key if it exists and its type is type. @@ -289,7 +287,7 @@ public: * * @return A const pointer to the value if it exists, NULL otherwise */ - Value* Find( const std::string& key, Property::Type type ) const; + Value* Find(const std::string& key, Property::Type type) const; /** * @brief Finds the value for the specified key if it exists and its type is type. @@ -300,7 +298,7 @@ public: * * @return A const pointer to the value if it exists, NULL otherwise */ - Value* Find( Property::Index key, Property::Type type ) const; + Value* Find(Property::Index key, Property::Type type) const; /** * @brief Clears the map. @@ -316,7 +314,7 @@ public: * @SINCE_1_0.0 * @param[in] from The map to merge from */ - void Merge( const Map& from ); + void Merge(const Map& from); /** * @brief Const operator to access element with the specified string key. @@ -328,7 +326,7 @@ public: * * @note Will assert if invalid-key is given. */ - const Value& operator[]( const std::string& key ) const; + const Value& operator[](const std::string& key) const; /** * @brief Operator to access the element with the specified string key. @@ -340,7 +338,7 @@ public: * * @note If an element with the key does not exist, then it is created. */ - Value& operator[]( const std::string& key ); + Value& operator[](const std::string& key); /** * @brief Const operator to access element with the specified index key. @@ -352,7 +350,7 @@ public: * * @note Will assert if invalid-key is given. */ - const Value& operator[]( Property::Index key ) const; + const Value& operator[](Property::Index key) const; /** * @brief Operator to access the element with the specified index key. @@ -364,7 +362,7 @@ public: * * @note If an element with the key does not exist, then it is created. */ - Value& operator[]( Property::Index key ); + Value& operator[](Property::Index key); /** * @brief Assignment operator. @@ -374,7 +372,7 @@ public: * * @return The copied map */ - Map& operator=( const Map& other ); + Map& operator=(const Map& other); /** * @brief Move assignment operator. @@ -386,17 +384,17 @@ public: * * @note The other array is an r-value so becomes invalid and is no longer usable. */ - Map& operator=( Map&& other ); + Map& operator=(Map&& other); /** * @brief Output to stream. * @SINCE_1_1.28 */ - friend DALI_CORE_API std::ostream& operator<<( std::ostream& stream, const Property::Map& map ); + friend DALI_CORE_API std::ostream& operator<<(std::ostream& stream, const Property::Map& map); private: - struct DALI_INTERNAL Impl; ///< Private data - Impl* mImpl; ///< Pointer to private data + struct DALI_INTERNAL Impl; ///< Private data + Impl* mImpl; ///< Pointer to private data }; /** @@ -407,7 +405,7 @@ private: * @param[in] map The map to insert * @return The output stream operator */ -DALI_CORE_API std::ostream& operator<<( std::ostream& stream, const Property::Map& map ); +DALI_CORE_API std::ostream& operator<<(std::ostream& stream, const Property::Map& map); /** * @} diff --git a/dali/public-api/object/property-notification-declarations.h b/dali/public-api/object/property-notification-declarations.h index 34dfd31..33cfc7c 100644 --- a/dali/public-api/object/property-notification-declarations.h +++ b/dali/public-api/object/property-notification-declarations.h @@ -2,7 +2,7 @@ #define DALI_PROPERTY_NOTIFICATION_DECLARATIONS_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -18,7 +18,6 @@ * */ - // INTERNAL INCLUDES #include @@ -35,7 +34,7 @@ class PropertyNotification; * @brief Signal type for Dali::PropertyNotification::NotifySignal(). * @SINCE_1_0.0 */ -using PropertyNotifySignalType = Signal; +using PropertyNotifySignalType = Signal; /** * @} diff --git a/dali/public-api/object/property-notification.cpp b/dali/public-api/object/property-notification.cpp index 7e2c27d..682b845 100644 --- a/dali/public-api/object/property-notification.cpp +++ b/dali/public-api/object/property-notification.cpp @@ -19,17 +19,16 @@ #include // INTERNAL INCLUDES -#include +#include #include +#include #include #include #include -#include #include namespace Dali { - PropertyNotification::PropertyNotification() { } @@ -39,9 +38,9 @@ PropertyNotification::PropertyNotification(Internal::PropertyNotification* prope { } -PropertyNotification PropertyNotification::DownCast( BaseHandle handle ) +PropertyNotification PropertyNotification::DownCast(BaseHandle handle) { - return PropertyNotification( dynamic_cast(handle.GetObjectPtr()) ); + return PropertyNotification(dynamic_cast(handle.GetObjectPtr())); } PropertyNotification::~PropertyNotification() @@ -52,9 +51,9 @@ PropertyNotification::PropertyNotification(const PropertyNotification& copy) = d PropertyNotification& PropertyNotification::operator=(const PropertyNotification& rhs) = default; -PropertyNotification::PropertyNotification( PropertyNotification&& rhs ) = default; +PropertyNotification::PropertyNotification(PropertyNotification&& rhs) = default; -PropertyNotification& PropertyNotification::operator=( PropertyNotification&& rhs ) = default; +PropertyNotification& PropertyNotification::operator=(PropertyNotification&& rhs) = default; PropertyCondition PropertyNotification::GetCondition() { @@ -76,9 +75,9 @@ Property::Index PropertyNotification::GetTargetProperty() const return GetImplementation(*this).GetTargetProperty(); } -void PropertyNotification::SetNotifyMode( NotifyMode mode ) +void PropertyNotification::SetNotifyMode(NotifyMode mode) { - GetImplementation(*this).SetNotifyMode( mode ); + GetImplementation(*this).SetNotifyMode(mode); } PropertyNotification::NotifyMode PropertyNotification::GetNotifyMode() diff --git a/dali/public-api/object/property-notification.h b/dali/public-api/object/property-notification.h index 8178a14..01f14e0 100644 --- a/dali/public-api/object/property-notification.h +++ b/dali/public-api/object/property-notification.h @@ -20,8 +20,8 @@ // INTERNAL INCLUDES #include -#include #include +#include #include namespace Dali @@ -52,14 +52,13 @@ public: */ enum NotifyMode { - DISABLED, ///< Don't notify, regardless of result of Condition @SINCE_1_9.28 - NOTIFY_ON_TRUE, ///< Notify whenever condition changes from false to true. @SINCE_1_9.28 - NOTIFY_ON_FALSE, ///< Notify whenever condition changes from true to false. @SINCE_1_9.28 - NOTIFY_ON_CHANGED ///< Notify whenever condition changes (false to true, and true to false) @SINCE_1_9.28 + DISABLED, ///< Don't notify, regardless of result of Condition @SINCE_1_9.28 + NOTIFY_ON_TRUE, ///< Notify whenever condition changes from false to true. @SINCE_1_9.28 + NOTIFY_ON_FALSE, ///< Notify whenever condition changes from true to false. @SINCE_1_9.28 + NOTIFY_ON_CHANGED ///< Notify whenever condition changes (false to true, and true to false) @SINCE_1_9.28 }; public: - /** * @brief Creates an uninitialized PropertyNotification; this can be initialized with PropertyNotification::New(). * @@ -79,7 +78,7 @@ public: * @param[in] handle to An object * @return handle to a PropertyNotification object or an uninitialized handle */ - static PropertyNotification DownCast( BaseHandle handle ); + static PropertyNotification DownCast(BaseHandle handle); /** * @brief Destructor. @@ -112,7 +111,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs A reference to the moved handle */ - PropertyNotification( PropertyNotification&& rhs ); + PropertyNotification(PropertyNotification&& rhs); /** * @brief Move assignment operator. @@ -121,7 +120,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this handle */ - PropertyNotification& operator=( PropertyNotification&& rhs ); + PropertyNotification& operator=(PropertyNotification&& rhs); /** * @brief Gets the condition of this notification. @@ -164,7 +163,7 @@ public: * @SINCE_1_0.0 * @param[in] mode Notification mode (Default is PropertyNotification::NOTIFY_ON_TRUE) */ - void SetNotifyMode( NotifyMode mode ); + void SetNotifyMode(NotifyMode mode); /** * @brief Retrieves the current Notification mode. @@ -192,7 +191,6 @@ public: PropertyNotifySignalType& NotifySignal(); public: // Not intended for use by Application developers - /// @cond internal /** * @brief This constructor is used by Dali New() methods. diff --git a/dali/public-api/object/property-types.cpp b/dali/public-api/object/property-types.cpp index f9ac88c..aa7a47e 100644 --- a/dali/public-api/object/property-types.cpp +++ b/dali/public-api/object/property-types.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -20,11 +20,9 @@ namespace Dali { - namespace { -const char* const PROPERTY_TYPE_NAMES[] = -{ +const char* const PROPERTY_TYPE_NAMES[] = { "NONE", "BOOLEAN", "FLOAT", @@ -41,15 +39,14 @@ const char* const PROPERTY_TYPE_NAMES[] = "MAP", "EXTENTS", }; -const uint32_t PROPERTY_TYPE_NAMES_COUNT = static_cast( sizeof( PROPERTY_TYPE_NAMES ) / sizeof( const char* ) ); -} +const uint32_t PROPERTY_TYPE_NAMES_COUNT = static_cast(sizeof(PROPERTY_TYPE_NAMES) / sizeof(const char*)); +} // namespace namespace PropertyTypes { - DALI_CORE_API const char* GetName(Property::Type type) { - if (type < PROPERTY_TYPE_NAMES_COUNT ) + if(type < PROPERTY_TYPE_NAMES_COUNT) { return PROPERTY_TYPE_NAMES[type]; } diff --git a/dali/public-api/object/property-types.h b/dali/public-api/object/property-types.h index 2d8429e..0618395 100644 --- a/dali/public-api/object/property-types.h +++ b/dali/public-api/object/property-types.h @@ -2,7 +2,7 @@ #define DALI_PROPERTY_TYPES_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -23,13 +23,13 @@ #include #include #include +#include +#include #include +#include #include #include #include -#include -#include -#include #include namespace Dali @@ -45,7 +45,6 @@ namespace Dali */ namespace PropertyTypes { - /** * @brief Retrieves the name of a property type. * @@ -62,39 +61,86 @@ DALI_CORE_API const char* GetName(Property::Type type); * @SINCE_1_0.0 * @return The property type */ -template -inline Property::Type Get() { return Property::NONE; } -template <> -inline Property::Type Get() { return Property::BOOLEAN; } -template <> -inline Property::Type Get() { return Property::FLOAT; } -template <> -inline Property::Type Get() { return Property::INTEGER; } -template <> -inline Property::Type Get() { return Property::VECTOR2; } -template <> -inline Property::Type Get() { return Property::VECTOR3; } -template <> -inline Property::Type Get() { return Property::VECTOR4; } -template <> -inline Property::Type Get() { return Property::MATRIX3; } -template <> -inline Property::Type Get() { return Property::MATRIX; } -template <> -inline Property::Type Get() { return Property::ROTATION; } // Rotation has two representations -template <> -inline Property::Type Get() { return Property::ROTATION; } // Rotation has two representations -template <> -inline Property::Type Get() { return Property::STRING; } -template <> -inline Property::Type Get >() { return Property::RECTANGLE; } -template <> -inline Property::Type Get() { return Property::MAP; } -template <> -inline Property::Type Get() { return Property::ARRAY; } -template <> -inline Property::Type Get() { return Property::EXTENTS; } - +template +inline Property::Type Get() +{ + return Property::NONE; +} +template<> +inline Property::Type Get() +{ + return Property::BOOLEAN; +} +template<> +inline Property::Type Get() +{ + return Property::FLOAT; +} +template<> +inline Property::Type Get() +{ + return Property::INTEGER; +} +template<> +inline Property::Type Get() +{ + return Property::VECTOR2; +} +template<> +inline Property::Type Get() +{ + return Property::VECTOR3; +} +template<> +inline Property::Type Get() +{ + return Property::VECTOR4; +} +template<> +inline Property::Type Get() +{ + return Property::MATRIX3; +} +template<> +inline Property::Type Get() +{ + return Property::MATRIX; +} +template<> +inline Property::Type Get() +{ + return Property::ROTATION; +} // Rotation has two representations +template<> +inline Property::Type Get() +{ + return Property::ROTATION; +} // Rotation has two representations +template<> +inline Property::Type Get() +{ + return Property::STRING; +} +template<> +inline Property::Type Get >() +{ + return Property::RECTANGLE; +} +template<> +inline Property::Type Get() +{ + return Property::MAP; +} +template<> +inline Property::Type Get() +{ + return Property::ARRAY; +} +template<> +inline Property::Type Get() +{ + return Property::EXTENTS; +} }; // namespace PropertyTypes diff --git a/dali/public-api/object/property-value.cpp b/dali/public-api/object/property-value.cpp index 7132bfb..6c80133 100644 --- a/dali/public-api/object/property-value.cpp +++ b/dali/public-api/object/property-value.cpp @@ -22,143 +22,148 @@ #include // INTERNAL INCLUDES +#include #include #include +#include +#include +#include #include +#include #include #include #include -#include -#include -#include -#include -#include #include +#include #include -#include namespace Dali { - namespace { /** * Helper to check if the property value can be read as int/bool */ -inline bool IsIntegerType( Property::Type type ) +inline bool IsIntegerType(Property::Type type) { - return ( Property::BOOLEAN == type )||( Property::INTEGER == type ); -} + return (Property::BOOLEAN == type) || (Property::INTEGER == type); } +} // namespace struct Property::Value::Impl { - Impl( bool booleanValue ) - : type( Property::BOOLEAN ), - integerValue( booleanValue ) - { } + Impl(bool booleanValue) + : type(Property::BOOLEAN), + integerValue(booleanValue) + { + } - Impl( float floatValue ) - : type( Property::FLOAT ), - floatValue( floatValue ) - { } + Impl(float floatValue) + : type(Property::FLOAT), + floatValue(floatValue) + { + } - Impl( int32_t integerValue ) - : type( Property::INTEGER ), - integerValue( integerValue ) - { } + Impl(int32_t integerValue) + : type(Property::INTEGER), + integerValue(integerValue) + { + } - Impl( const Vector2& vectorValue ) - : type( Property::VECTOR2 ), - vector2Value( new Vector2( vectorValue ) ) - { } + Impl(const Vector2& vectorValue) + : type(Property::VECTOR2), + vector2Value(new Vector2(vectorValue)) + { + } - Impl( const Vector3& vectorValue ) - : type( Property::VECTOR3 ), - vector3Value( new Vector3( vectorValue ) ) - { } + Impl(const Vector3& vectorValue) + : type(Property::VECTOR3), + vector3Value(new Vector3(vectorValue)) + { + } - Impl( const Vector4& vectorValue ) - : type( Property::VECTOR4 ), - vector4Value( new Vector4( vectorValue ) ) - { } + Impl(const Vector4& vectorValue) + : type(Property::VECTOR4), + vector4Value(new Vector4(vectorValue)) + { + } - Impl( const Matrix3& matrixValue ) - : type( Property::MATRIX3 ), - matrix3Value( new Matrix3( matrixValue ) ) + Impl(const Matrix3& matrixValue) + : type(Property::MATRIX3), + matrix3Value(new Matrix3(matrixValue)) { } - Impl( const Matrix& matrixValue ) - : type( Property::MATRIX ), - matrixValue( new Matrix( matrixValue ) ) + Impl(const Matrix& matrixValue) + : type(Property::MATRIX), + matrixValue(new Matrix(matrixValue)) { } - Impl( const AngleAxis& angleAxisValue ) - : type( Property::ROTATION ), - angleAxisValue( new AngleAxis(angleAxisValue) ) + Impl(const AngleAxis& angleAxisValue) + : type(Property::ROTATION), + angleAxisValue(new AngleAxis(angleAxisValue)) { } - Impl( const Quaternion& quaternionValue ) - : type( Property::ROTATION ), - angleAxisValue( new AngleAxis() ) + Impl(const Quaternion& quaternionValue) + : type(Property::ROTATION), + angleAxisValue(new AngleAxis()) { - quaternionValue.ToAxisAngle( angleAxisValue->axis, angleAxisValue->angle ); + quaternionValue.ToAxisAngle(angleAxisValue->axis, angleAxisValue->angle); } - Impl( const std::string& stringValue ) - : type( Property::STRING ), - stringValue( new std::string( stringValue ) ) + Impl(const std::string& stringValue) + : type(Property::STRING), + stringValue(new std::string(stringValue)) { } - Impl( const Rect& rectValue ) - : type( Property::RECTANGLE ), - rectValue( new Rect( rectValue ) ) + Impl(const Rect& rectValue) + : type(Property::RECTANGLE), + rectValue(new Rect(rectValue)) { } - Impl( const Rect& rectValue ) - : type( Property::VECTOR4 ), - vector4Value( new Vector4( rectValue.x, rectValue.y, rectValue.width, rectValue.height ) ) + Impl(const Rect& rectValue) + : type(Property::VECTOR4), + vector4Value(new Vector4(rectValue.x, rectValue.y, rectValue.width, rectValue.height)) { } - Impl( const Property::Array& arrayValue ) - : type( Property::ARRAY ), - arrayValue( new Property::Array( arrayValue ) ) + Impl(const Property::Array& arrayValue) + : type(Property::ARRAY), + arrayValue(new Property::Array(arrayValue)) { } - Impl( Property::Array&& arrayValue ) - : type( Property::ARRAY ), - arrayValue( new Property::Array( std::move( arrayValue ) ) ) + Impl(Property::Array&& arrayValue) + : type(Property::ARRAY), + arrayValue(new Property::Array(std::move(arrayValue))) { } - Impl( const Property::Map& mapValue ) - : type( Property::MAP ), - mapValue( new Property::Map( mapValue ) ) + Impl(const Property::Map& mapValue) + : type(Property::MAP), + mapValue(new Property::Map(mapValue)) { } - Impl( Property::Map&& mapValue ) - : type( Property::MAP ), - mapValue( new Property::Map( std::move( mapValue ) ) ) + Impl(Property::Map&& mapValue) + : type(Property::MAP), + mapValue(new Property::Map(std::move(mapValue))) { } - Impl( const Extents& extentsValue ) - : type( Property::EXTENTS ), - extentsValue( new Extents( extentsValue ) ) + Impl(const Extents& extentsValue) + : type(Property::EXTENTS), + extentsValue(new Extents(extentsValue)) { } - Impl( const std::initializer_list< KeyValuePair >& values ) - : type( Property::MAP ), - mapValue( new Property::Map( values ) ) + Impl(const std::initializer_list& values) + : type(Property::MAP), + mapValue(new Property::Map(values)) { } @@ -167,16 +172,16 @@ struct Property::Value::Impl */ ~Impl() { - switch( type ) + switch(type) { - case Property::NONE : // FALLTHROUGH - case Property::BOOLEAN : // FALLTHROUGH - case Property::FLOAT : // FALLTHROUGH - case Property::INTEGER : + case Property::NONE: // FALLTHROUGH + case Property::BOOLEAN: // FALLTHROUGH + case Property::FLOAT: // FALLTHROUGH + case Property::INTEGER: { break; // nothing to do } - case Property::VECTOR2 : + case Property::VECTOR2: { delete vector2Value; break; @@ -235,220 +240,217 @@ struct Property::Value::Impl } public: // Data - Type type; union { int32_t integerValue; - float floatValue; + float floatValue; // must use pointers for any class value pre c++ 11 - Vector2* vector2Value; - Vector3* vector3Value; - Vector4* vector4Value; - Matrix3* matrix3Value; - Matrix* matrixValue; - AngleAxis* angleAxisValue; - std::string* stringValue; - Rect* rectValue; + Vector2* vector2Value; + Vector3* vector3Value; + Vector4* vector4Value; + Matrix3* matrix3Value; + Matrix* matrixValue; + AngleAxis* angleAxisValue; + std::string* stringValue; + Rect* rectValue; Property::Array* arrayValue; - Property::Map* mapValue; - Extents* extentsValue; + Property::Map* mapValue; + Extents* extentsValue; }; private: - // non-copyable - Impl( const Impl& ) = delete; - Impl& operator=( const Impl& ) = delete; - + Impl(const Impl&) = delete; + Impl& operator=(const Impl&) = delete; }; Property::Value::Value() -: mImpl( nullptr ) +: mImpl(nullptr) { } -Property::Value::Value( bool booleanValue ) -: mImpl( new Impl( booleanValue ) ) +Property::Value::Value(bool booleanValue) +: mImpl(new Impl(booleanValue)) { } -Property::Value::Value( float floatValue ) -: mImpl( new Impl( floatValue ) ) +Property::Value::Value(float floatValue) +: mImpl(new Impl(floatValue)) { } -Property::Value::Value( int32_t integerValue ) -: mImpl( new Impl( integerValue ) ) +Property::Value::Value(int32_t integerValue) +: mImpl(new Impl(integerValue)) { } -Property::Value::Value( const Vector2& vectorValue ) -: mImpl( new Impl( vectorValue ) ) +Property::Value::Value(const Vector2& vectorValue) +: mImpl(new Impl(vectorValue)) { } -Property::Value::Value( const Vector3& vectorValue ) -: mImpl( new Impl( vectorValue ) ) +Property::Value::Value(const Vector3& vectorValue) +: mImpl(new Impl(vectorValue)) { } -Property::Value::Value( const Vector4& vectorValue ) -: mImpl( new Impl( vectorValue ) ) +Property::Value::Value(const Vector4& vectorValue) +: mImpl(new Impl(vectorValue)) { } -Property::Value::Value( const Matrix3& matrixValue ) -: mImpl( new Impl( matrixValue ) ) +Property::Value::Value(const Matrix3& matrixValue) +: mImpl(new Impl(matrixValue)) { } -Property::Value::Value( const Matrix& matrixValue ) -: mImpl( new Impl( matrixValue ) ) +Property::Value::Value(const Matrix& matrixValue) +: mImpl(new Impl(matrixValue)) { } -Property::Value::Value( const Rect& rectValue ) -: mImpl( new Impl( rectValue ) ) +Property::Value::Value(const Rect& rectValue) +: mImpl(new Impl(rectValue)) { } -Property::Value::Value( const Rect& rectValue ) -: mImpl( new Impl( rectValue ) ) +Property::Value::Value(const Rect& rectValue) +: mImpl(new Impl(rectValue)) { } -Property::Value::Value( const AngleAxis& angleAxisValue ) -: mImpl( new Impl( angleAxisValue ) ) +Property::Value::Value(const AngleAxis& angleAxisValue) +: mImpl(new Impl(angleAxisValue)) { } -Property::Value::Value( const Quaternion& quaternionValue ) -: mImpl( new Impl( quaternionValue ) ) +Property::Value::Value(const Quaternion& quaternionValue) +: mImpl(new Impl(quaternionValue)) { } -Property::Value::Value( const std::string& stringValue ) -: mImpl( new Impl( stringValue ) ) +Property::Value::Value(const std::string& stringValue) +: mImpl(new Impl(stringValue)) { } -Property::Value::Value( const char* stringValue ) -: mImpl( nullptr ) +Property::Value::Value(const char* stringValue) +: mImpl(nullptr) { - if( stringValue ) // string constructor is undefined with nullptr + if(stringValue) // string constructor is undefined with nullptr { - mImpl = new Impl( std::string(stringValue) ); + mImpl = new Impl(std::string(stringValue)); } else { - mImpl = new Impl( std::string() ); + mImpl = new Impl(std::string()); } } -Property::Value::Value( Property::Array& arrayValue ) -: mImpl( new Impl( arrayValue ) ) +Property::Value::Value(Property::Array& arrayValue) +: mImpl(new Impl(arrayValue)) { } -Property::Value::Value( Property::Array&& arrayValue ) -: mImpl( new Impl( std::move( arrayValue ) ) ) +Property::Value::Value(Property::Array&& arrayValue) +: mImpl(new Impl(std::move(arrayValue))) { } -Property::Value::Value( Property::Map& mapValue ) -: mImpl( new Impl( mapValue ) ) +Property::Value::Value(Property::Map& mapValue) +: mImpl(new Impl(mapValue)) { } -Property::Value::Value( Property::Map&& mapValue ) -: mImpl( new Impl( std::move( mapValue ) ) ) +Property::Value::Value(Property::Map&& mapValue) +: mImpl(new Impl(std::move(mapValue))) { } -Property::Value::Value( const Extents& extentsValue ) -: mImpl( new Impl( extentsValue ) ) +Property::Value::Value(const Extents& extentsValue) +: mImpl(new Impl(extentsValue)) { } -Property::Value::Value( const std::initializer_list< KeyValuePair >& values ) -: mImpl( new Impl( values ) ) +Property::Value::Value(const std::initializer_list& values) +: mImpl(new Impl(values)) { } -Property::Value::Value( Type type ) -: mImpl( nullptr ) +Property::Value::Value(Type type) +: mImpl(nullptr) { - switch (type) + switch(type) { case Property::BOOLEAN: { - mImpl = new Impl( false ); + mImpl = new Impl(false); break; } case Property::FLOAT: { - mImpl = new Impl( 0.f ); + mImpl = new Impl(0.f); break; } case Property::INTEGER: { - mImpl = new Impl( 0 ); + mImpl = new Impl(0); break; } case Property::VECTOR2: { - mImpl = new Impl( Vector2::ZERO ); + mImpl = new Impl(Vector2::ZERO); break; } case Property::VECTOR3: { - mImpl = new Impl( Vector3::ZERO ); + mImpl = new Impl(Vector3::ZERO); break; } case Property::VECTOR4: { - mImpl = new Impl( Vector4::ZERO ); + mImpl = new Impl(Vector4::ZERO); break; } case Property::RECTANGLE: { - mImpl = new Impl( Rect(0,0,0,0) ); + mImpl = new Impl(Rect(0, 0, 0, 0)); break; } case Property::ROTATION: { - mImpl = new Impl( AngleAxis() ); + mImpl = new Impl(AngleAxis()); break; } case Property::STRING: { - mImpl = new Impl( std::string() ); + mImpl = new Impl(std::string()); break; } case Property::MATRIX: { - mImpl = new Impl( Matrix() ); + mImpl = new Impl(Matrix()); break; } case Property::MATRIX3: { - mImpl = new Impl( Matrix3() ); + mImpl = new Impl(Matrix3()); break; } case Property::ARRAY: { - mImpl = new Impl( Property::Array() ); + mImpl = new Impl(Property::Array()); break; } case Property::MAP: { - mImpl = new Impl( Property::Map() ); + mImpl = new Impl(Property::Map()); break; } case Property::EXTENTS: { - mImpl = new Impl( Extents() ); + mImpl = new Impl(Extents()); break; } case Property::NONE: @@ -459,37 +461,37 @@ Property::Value::Value( Type type ) } } -Property::Value::Value( const Property::Value& value ) -: mImpl( nullptr ) +Property::Value::Value(const Property::Value& value) +: mImpl(nullptr) { // reuse assignment operator - operator=( value ); + operator=(value); } -Property::Value::Value( Property::Value&& value ) -: mImpl( value.mImpl ) +Property::Value::Value(Property::Value&& value) +: mImpl(value.mImpl) { value.mImpl = nullptr; } -Property::Value& Property::Value::operator=( const Property::Value& value ) +Property::Value& Property::Value::operator=(const Property::Value& value) { - if ( this == &value ) + if(this == &value) { // skip self assignment return *this; } // if we are assigned an empty value, just drop impl - if( !value.mImpl ) + if(!value.mImpl) { delete mImpl; mImpl = nullptr; return *this; } // first check if the type is the same, no need to change impl, just assign - if( mImpl && ( mImpl->type == value.mImpl->type ) ) + if(mImpl && (mImpl->type == value.mImpl->type)) { - switch( mImpl->type ) + switch(mImpl->type) { case Property::BOOLEAN: { @@ -569,77 +571,77 @@ Property::Value& Property::Value::operator=( const Property::Value& value ) else { // different type, release old impl and create new - Impl* newImpl( nullptr ); - switch ( value.mImpl->type ) + Impl* newImpl(nullptr); + switch(value.mImpl->type) { case Property::BOOLEAN: { - newImpl = new Impl( bool( value.mImpl->integerValue ) ); + newImpl = new Impl(bool(value.mImpl->integerValue)); break; } case Property::FLOAT: { - newImpl = new Impl( value.mImpl->floatValue ); + newImpl = new Impl(value.mImpl->floatValue); break; } case Property::INTEGER: { - newImpl = new Impl( value.mImpl->integerValue ); + newImpl = new Impl(value.mImpl->integerValue); break; } case Property::VECTOR2: { - newImpl = new Impl( *value.mImpl->vector2Value ); // type cannot change in mImpl so vector is allocated + newImpl = new Impl(*value.mImpl->vector2Value); // type cannot change in mImpl so vector is allocated break; } case Property::VECTOR3: { - newImpl = new Impl( *value.mImpl->vector3Value ); // type cannot change in mImpl so vector is allocated + newImpl = new Impl(*value.mImpl->vector3Value); // type cannot change in mImpl so vector is allocated break; } case Property::VECTOR4: { - newImpl = new Impl( *value.mImpl->vector4Value ); // type cannot change in mImpl so vector is allocated + newImpl = new Impl(*value.mImpl->vector4Value); // type cannot change in mImpl so vector is allocated break; } case Property::RECTANGLE: { - newImpl = new Impl( *value.mImpl->rectValue ); // type cannot change in mImpl so rect is allocated + newImpl = new Impl(*value.mImpl->rectValue); // type cannot change in mImpl so rect is allocated break; } case Property::ROTATION: { - newImpl = new Impl( *value.mImpl->angleAxisValue ); // type cannot change in mImpl so quaternion is allocated + newImpl = new Impl(*value.mImpl->angleAxisValue); // type cannot change in mImpl so quaternion is allocated break; } case Property::MATRIX3: { - newImpl = new Impl( *value.mImpl->matrix3Value ); // type cannot change in mImpl so matrix is allocated + newImpl = new Impl(*value.mImpl->matrix3Value); // type cannot change in mImpl so matrix is allocated break; } case Property::MATRIX: { - newImpl = new Impl( *value.mImpl->matrixValue ); // type cannot change in mImpl so matrix is allocated + newImpl = new Impl(*value.mImpl->matrixValue); // type cannot change in mImpl so matrix is allocated break; } case Property::STRING: { - newImpl = new Impl( *value.mImpl->stringValue ); // type cannot change in mImpl so string is allocated + newImpl = new Impl(*value.mImpl->stringValue); // type cannot change in mImpl so string is allocated break; } case Property::ARRAY: { - newImpl = new Impl( *value.mImpl->arrayValue ); // type cannot change in mImpl so array is allocated + newImpl = new Impl(*value.mImpl->arrayValue); // type cannot change in mImpl so array is allocated break; } case Property::MAP: { - newImpl = new Impl( *value.mImpl->mapValue ); // type cannot change in mImpl so map is allocated + newImpl = new Impl(*value.mImpl->mapValue); // type cannot change in mImpl so map is allocated break; } case Property::EXTENTS: { - newImpl = new Impl( *value.mImpl->extentsValue ); // type cannot change in mImpl so extents is allocated + newImpl = new Impl(*value.mImpl->extentsValue); // type cannot change in mImpl so extents is allocated break; } case Property::NONE: @@ -653,12 +655,12 @@ Property::Value& Property::Value::operator=( const Property::Value& value ) return *this; } -Property::Value& Property::Value::operator=( Property::Value&& value ) +Property::Value& Property::Value::operator=(Property::Value&& value) { - if( this != &value ) + if(this != &value) { delete mImpl; - mImpl = value.mImpl; + mImpl = value.mImpl; value.mImpl = nullptr; } @@ -672,148 +674,148 @@ Property::Value::~Value() Property::Type Property::Value::GetType() const { - Property::Type type( Property::NONE ); - if( mImpl ) + Property::Type type(Property::NONE); + if(mImpl) { type = mImpl->type; } return type; } -bool Property::Value::Get( bool& booleanValue ) const +bool Property::Value::Get(bool& booleanValue) const { bool converted = false; - if( mImpl && IsIntegerType( mImpl->type ) ) + if(mImpl && IsIntegerType(mImpl->type)) { booleanValue = mImpl->integerValue; - converted = true; + converted = true; } return converted; } -bool Property::Value::Get( float& floatValue ) const +bool Property::Value::Get(float& floatValue) const { bool converted = false; - if( mImpl ) + if(mImpl) { - if( mImpl->type == FLOAT ) + if(mImpl->type == FLOAT) { floatValue = mImpl->floatValue; - converted = true; + converted = true; } - else if( IsIntegerType( mImpl->type ) ) + else if(IsIntegerType(mImpl->type)) { - floatValue = static_cast< float >( mImpl->integerValue ); - converted = true; + floatValue = static_cast(mImpl->integerValue); + converted = true; } } return converted; } -bool Property::Value::Get( int32_t& integerValue ) const +bool Property::Value::Get(int32_t& integerValue) const { bool converted = false; - if( mImpl ) + if(mImpl) { - if( IsIntegerType( mImpl->type ) ) + if(IsIntegerType(mImpl->type)) { integerValue = mImpl->integerValue; - converted = true; + converted = true; } - else if( mImpl->type == FLOAT ) + else if(mImpl->type == FLOAT) { - integerValue = static_cast< int32_t >( mImpl->floatValue ); - converted = true; + integerValue = static_cast(mImpl->floatValue); + converted = true; } } return converted; } -bool Property::Value::Get( Vector2& vectorValue ) const +bool Property::Value::Get(Vector2& vectorValue) const { bool converted = false; - if( mImpl ) + if(mImpl) { // type cannot change in mImpl so vector is allocated - if( mImpl->type == VECTOR2 || mImpl->type == VECTOR3 || mImpl->type == VECTOR4 ) + if(mImpl->type == VECTOR2 || mImpl->type == VECTOR3 || mImpl->type == VECTOR4) { vectorValue = *(mImpl->vector2Value); // if Vector3 or 4 only x and y are assigned - converted = true; + converted = true; } } return converted; } -bool Property::Value::Get( Vector3& vectorValue ) const +bool Property::Value::Get(Vector3& vectorValue) const { bool converted = false; - if( mImpl ) + if(mImpl) { // type cannot change in mImpl so vector is allocated - if ( mImpl->type == VECTOR3 || mImpl->type == VECTOR4 ) + if(mImpl->type == VECTOR3 || mImpl->type == VECTOR4) { vectorValue = *(mImpl->vector3Value); // if Vector4 only x,y,z are assigned - converted = true; + converted = true; } - else if( mImpl->type == VECTOR2 ) + else if(mImpl->type == VECTOR2) { vectorValue = *(mImpl->vector2Value); - converted = true; + converted = true; } } return converted; } -bool Property::Value::Get( Vector4& vectorValue ) const +bool Property::Value::Get(Vector4& vectorValue) const { bool converted = false; - if( mImpl ) + if(mImpl) { - if( mImpl->type == VECTOR4 ) // type cannot change in mImpl so vector is allocated + if(mImpl->type == VECTOR4) // type cannot change in mImpl so vector is allocated { vectorValue = *(mImpl->vector4Value); - converted = true; + converted = true; } - else if( mImpl->type == VECTOR2 ) + else if(mImpl->type == VECTOR2) { vectorValue = *(mImpl->vector2Value); - converted = true; + converted = true; } - else if( mImpl->type == VECTOR3 ) + else if(mImpl->type == VECTOR3) { vectorValue = *(mImpl->vector3Value); - converted = true; + converted = true; } } return converted; } -bool Property::Value::Get( Matrix3& matrixValue ) const +bool Property::Value::Get(Matrix3& matrixValue) const { bool converted = false; - if( mImpl && (mImpl->type == MATRIX3) ) // type cannot change in mImpl so matrix is allocated + if(mImpl && (mImpl->type == MATRIX3)) // type cannot change in mImpl so matrix is allocated { matrixValue = *(mImpl->matrix3Value); - converted = true; + converted = true; } return converted; } -bool Property::Value::Get( Matrix& matrixValue ) const +bool Property::Value::Get(Matrix& matrixValue) const { bool converted = false; - if( mImpl && (mImpl->type == MATRIX) ) // type cannot change in mImpl so matrix is allocated + if(mImpl && (mImpl->type == MATRIX)) // type cannot change in mImpl so matrix is allocated { matrixValue = *(mImpl->matrixValue); - converted = true; + converted = true; } return converted; } -bool Property::Value::Get( Rect& rectValue ) const +bool Property::Value::Get(Rect& rectValue) const { bool converted = false; - if( mImpl && (mImpl->type == RECTANGLE) ) // type cannot change in mImpl so rect is allocated + if(mImpl && (mImpl->type == RECTANGLE)) // type cannot change in mImpl so rect is allocated { rectValue = *(mImpl->rectValue); converted = true; @@ -821,56 +823,56 @@ bool Property::Value::Get( Rect& rectValue ) const return converted; } -bool Property::Value::Get( AngleAxis& angleAxisValue ) const +bool Property::Value::Get(AngleAxis& angleAxisValue) const { bool converted = false; - if( mImpl && (mImpl->type == ROTATION) ) // type cannot change in mImpl so angleAxis is allocated + if(mImpl && (mImpl->type == ROTATION)) // type cannot change in mImpl so angleAxis is allocated { angleAxisValue = *(mImpl->angleAxisValue); - converted = true; + converted = true; } return converted; } -bool Property::Value::Get( Quaternion& quaternionValue ) const +bool Property::Value::Get(Quaternion& quaternionValue) const { bool converted = false; - if( mImpl && (mImpl->type == ROTATION) ) // type cannot change in mImpl so angleAxis is allocated + if(mImpl && (mImpl->type == ROTATION)) // type cannot change in mImpl so angleAxis is allocated { - quaternionValue = Quaternion(mImpl->angleAxisValue->angle, mImpl->angleAxisValue->axis ); - converted = true; + quaternionValue = Quaternion(mImpl->angleAxisValue->angle, mImpl->angleAxisValue->axis); + converted = true; } return converted; } -bool Property::Value::Get( std::string& stringValue ) const +bool Property::Value::Get(std::string& stringValue) const { bool converted = false; - if( mImpl && (mImpl->type == STRING) ) // type cannot change in mImpl so string is allocated + if(mImpl && (mImpl->type == STRING)) // type cannot change in mImpl so string is allocated { - stringValue.assign( *(mImpl->stringValue) ); + stringValue.assign(*(mImpl->stringValue)); converted = true; } return converted; } -bool Property::Value::Get( Property::Array& arrayValue ) const +bool Property::Value::Get(Property::Array& arrayValue) const { bool converted = false; - if( mImpl && (mImpl->type == ARRAY) ) // type cannot change in mImpl so array is allocated + if(mImpl && (mImpl->type == ARRAY)) // type cannot change in mImpl so array is allocated { arrayValue = *(mImpl->arrayValue); - converted = true; + converted = true; } return converted; } -bool Property::Value::Get( Property::Map& mapValue ) const +bool Property::Value::Get(Property::Map& mapValue) const { bool converted = false; - if( mImpl && (mImpl->type == MAP) ) // type cannot change in mImpl so map is allocated + if(mImpl && (mImpl->type == MAP)) // type cannot change in mImpl so map is allocated { - mapValue = *(mImpl->mapValue); + mapValue = *(mImpl->mapValue); converted = true; } return converted; @@ -879,7 +881,7 @@ bool Property::Value::Get( Property::Map& mapValue ) const Property::Array* Property::Value::GetArray() const { Property::Array* array = nullptr; - if( mImpl && (mImpl->type == ARRAY) ) // type cannot change in mImpl so array is allocated + if(mImpl && (mImpl->type == ARRAY)) // type cannot change in mImpl so array is allocated { array = mImpl->arrayValue; } @@ -889,42 +891,42 @@ Property::Array* Property::Value::GetArray() const Property::Map* Property::Value::GetMap() const { Property::Map* map = nullptr; - if( mImpl && (mImpl->type == MAP) ) // type cannot change in mImpl so map is allocated + if(mImpl && (mImpl->type == MAP)) // type cannot change in mImpl so map is allocated { map = mImpl->mapValue; } return map; } -bool Property::Value::Get( Extents& extentsValue ) const +bool Property::Value::Get(Extents& extentsValue) const { bool converted = false; - if( mImpl ) + if(mImpl) { - if( mImpl->type == EXTENTS ) + if(mImpl->type == EXTENTS) { extentsValue = *(mImpl->extentsValue); - converted = true; + converted = true; } - else if( mImpl->type == VECTOR4 ) + else if(mImpl->type == VECTOR4) { - extentsValue.start = static_cast< uint16_t >( mImpl->vector4Value->x ); - extentsValue.end = static_cast< uint16_t >( mImpl->vector4Value->y ); - extentsValue.top = static_cast< uint16_t >( mImpl->vector4Value->z ); - extentsValue.bottom = static_cast< uint16_t >( mImpl->vector4Value->w ); - converted = true; + extentsValue.start = static_cast(mImpl->vector4Value->x); + extentsValue.end = static_cast(mImpl->vector4Value->y); + extentsValue.top = static_cast(mImpl->vector4Value->z); + extentsValue.bottom = static_cast(mImpl->vector4Value->w); + converted = true; } } return converted; } -std::ostream& operator<<( std::ostream& stream, const Property::Value& value ) +std::ostream& operator<<(std::ostream& stream, const Property::Value& value) { - if( value.mImpl ) + if(value.mImpl) { - const Property::Value::Impl& impl( *value.mImpl ); + const Property::Value::Impl& impl(*value.mImpl); - switch( impl.type ) + switch(impl.type) { case Dali::Property::BOOLEAN: { @@ -938,8 +940,8 @@ std::ostream& operator<<( std::ostream& stream, const Property::Value& value ) } case Dali::Property::INTEGER: { - stream << impl.integerValue; - break; + stream << impl.integerValue; + break; } case Dali::Property::VECTOR2: { @@ -1008,5 +1010,4 @@ std::ostream& operator<<( std::ostream& stream, const Property::Value& value ) return stream; } - } // namespace Dali diff --git a/dali/public-api/object/property-value.h b/dali/public-api/object/property-value.h old mode 100755 new mode 100644 index c503808..d04c9e9 --- a/dali/public-api/object/property-value.h +++ b/dali/public-api/object/property-value.h @@ -19,15 +19,14 @@ */ // EXTERNAL INCLUDES +#include #include #include #include -#include // INTERNAL INCLUDES -#include #include - +#include namespace Dali { @@ -54,7 +53,6 @@ using KeyValuePair = std::pair; class DALI_CORE_API Property::Value { public: - /** * @brief Default constructor. * @@ -69,7 +67,7 @@ public: * @SINCE_1_0.0 * @param[in] boolValue A boolean value */ - Value( bool boolValue ); + Value(bool boolValue); /** * @brief Creates an integer property value. @@ -77,7 +75,7 @@ public: * @SINCE_1_0.0 * @param[in] integerValue An integer value */ - Value( int32_t integerValue ); + Value(int32_t integerValue); /** * @brief Creates a float property value. @@ -85,7 +83,7 @@ public: * @SINCE_1_0.0 * @param[in] floatValue A floating-point value */ - Value( float floatValue ); + Value(float floatValue); /** * @brief Creates a Vector2 property value. @@ -93,7 +91,7 @@ public: * @SINCE_1_0.0 * @param[in] vectorValue A vector of 2 floating-point values */ - Value( const Vector2& vectorValue ); + Value(const Vector2& vectorValue); /** * @brief Creates a Vector3 property value. @@ -101,7 +99,7 @@ public: * @SINCE_1_0.0 * @param[in] vectorValue A vector of 3 floating-point values */ - Value( const Vector3& vectorValue ); + Value(const Vector3& vectorValue); /** * @brief Creates a Vector4 property value. @@ -109,7 +107,7 @@ public: * @SINCE_1_0.0 * @param[in] vectorValue A vector of 4 floating-point values */ - Value( const Vector4& vectorValue ); + Value(const Vector4& vectorValue); /** * @brief Creates a Matrix3 property value. @@ -117,7 +115,7 @@ public: * @SINCE_1_0.0 * @param[in] matrixValue A matrix of 3x3 floating-point values */ - Value( const Matrix3& matrixValue ); + Value(const Matrix3& matrixValue); /** * @brief Creates a Matrix property value. @@ -125,7 +123,7 @@ public: * @SINCE_1_0.0 * @param[in] matrixValue A matrix of 4x4 floating-point values */ - Value( const Matrix& matrixValue ); + Value(const Matrix& matrixValue); /** * @brief Creates a Vector4 property value. @@ -133,7 +131,7 @@ public: * @SINCE_1_0.0 * @param[in] vectorValue A vector of 4 integer values */ - Value( const Rect& vectorValue ); + Value(const Rect& vectorValue); /** * @brief Creates a Vector4 property value. @@ -141,7 +139,7 @@ public: * @SINCE_1_9.14 * @param[in] vectorValue A vector of 4 float values */ - Value( const Rect& vectorValue ); + Value(const Rect& vectorValue); /** * @brief Creates an orientation property value. @@ -149,7 +147,7 @@ public: * @SINCE_1_0.0 * @param[in] angleAxis An angle-axis representing the rotation */ - Value( const AngleAxis& angleAxis ); + Value(const AngleAxis& angleAxis); /** * @brief Creates an orientation property value. @@ -157,7 +155,7 @@ public: * @SINCE_1_0.0 * @param[in] quaternion A quaternion representing the rotation */ - Value( const Quaternion& quaternion ); + Value(const Quaternion& quaternion); /** * @brief Creates an string property value. @@ -165,7 +163,7 @@ public: * @SINCE_1_0.0 * @param[in] stringValue A string */ - Value( const std::string& stringValue ); + Value(const std::string& stringValue); /** * @brief Creates a string property value. @@ -173,7 +171,7 @@ public: * @SINCE_1_0.0 * @param[in] stringValue A string */ - Value( const char* stringValue ); + Value(const char* stringValue); /** * @brief Creates an array property value. @@ -181,7 +179,7 @@ public: * @SINCE_1_0.0 * @param[in] arrayValue An array */ - Value( Property::Array& arrayValue ); + Value(Property::Array& arrayValue); /** * @brief Creates an array property value. @@ -189,7 +187,7 @@ public: * @SINCE_1_4.16 * @param[in] arrayValue An r-value array */ - Value( Property::Array&& arrayValue ); + Value(Property::Array&& arrayValue); /** * @brief Creates a map property value. @@ -197,7 +195,7 @@ public: * @SINCE_1_0.0 * @param[in] mapValue A map */ - Value( Property::Map& mapValue ); + Value(Property::Map& mapValue); /** * @brief Creates a map property value. @@ -205,7 +203,7 @@ public: * @SINCE_1_4.16 * @param[in] mapValue An r-value map */ - Value( Property::Map&& mapValue ); + Value(Property::Map&& mapValue); /** * @brief Create a map property value from an initializer_list. @@ -213,7 +211,7 @@ public: * @SINCE_1_4.16 * @param [in] values An initializer_list of pairs of index and value. */ - Value( const std::initializer_list< KeyValuePair >& values ); + Value(const std::initializer_list& values); /** * @brief Creates an extents property value. @@ -221,7 +219,7 @@ public: * @SINCE_1_2.62 * @param[in] extentsValue A collection of 4 uint16_t values */ - Value( const Extents& extentsValue ); + Value(const Extents& extentsValue); /** * @brief Creates an enumeration property value. @@ -229,8 +227,9 @@ public: * @SINCE_1_4.36 * @param[in] enumValue An enumeration value */ - template< typename T, typename std::enable_if< std::is_enum< T >::value >::type* = nullptr > - Value( T enumValue ) : Value( static_cast< int32_t >( enumValue ) ) + template::value>::type* = nullptr> + Value(T enumValue) + : Value(static_cast(enumValue)) { } @@ -240,7 +239,7 @@ public: * @SINCE_1_0.0 * @param[in] type The property value type */ - explicit Value( Type type ); + explicit Value(Type type); /** * @brief Copy constructor. @@ -248,7 +247,7 @@ public: * @SINCE_1_0.0 * @param[in] value The property value to copy */ - Value( const Value& value ); + Value(const Value& value); /** * @brief Move constructor. @@ -257,7 +256,7 @@ public: * @SINCE_1_4.16 * @param[in] value The property value to move from */ - Value( Value&& value ); + Value(Value&& value); /** * @brief Assigns a property value. @@ -266,7 +265,7 @@ public: * @param[in] value The property value to assign from * @return a reference to this */ - Value& operator=( const Value& value ); + Value& operator=(const Value& value); /** * @brief Move assignment operator. @@ -275,7 +274,7 @@ public: * @param[in] value The property value to move from * @return a reference to this */ - Value& operator=( Value&& value ); + Value& operator=(Value&& value); /** * @brief Non-virtual destructor. @@ -301,11 +300,11 @@ public: * @SINCE_1_4.36 * @return A value of type T */ - template< typename T, typename std::enable_if< ! std::is_enum< T >::value >::type* = nullptr > + template::value>::type* = nullptr> T DALI_INTERNAL Get() const { T temp = T(); // value (zero) initialize - Get( temp ); + Get(temp); return temp; } @@ -318,12 +317,12 @@ public: * @SINCE_1_4.36 * @return A value of type T */ - template< typename T, typename std::enable_if< std::is_enum< T >::value >::type* = nullptr > + template::value>::type* = nullptr> T DALI_INTERNAL Get() const { int32_t temp = 0; // value (zero) initialize - Get( temp ); - return static_cast< T >( temp ); + Get(temp); + return static_cast(temp); } /** @@ -334,15 +333,15 @@ public: * @return @c true if the value is successfully retrieved, @c false if the type is different * @pre GetType() is any enumeration */ - template< typename T, typename std::enable_if< std::is_enum< T >::value >::type* = nullptr > - bool DALI_INTERNAL Get( T& enumValue ) const + template::value>::type* = nullptr> + bool DALI_INTERNAL Get(T& enumValue) const { int32_t temp = 0; - if( ! Get( temp ) ) + if(!Get(temp)) { return false; } - enumValue = static_cast< T >( temp ); + enumValue = static_cast(temp); return true; } @@ -354,7 +353,7 @@ public: * @return @c true if the value is successfully retrieved, @c false if the type is not convertible * @pre GetType() is a type convertible to bool. */ - bool Get( bool& boolValue ) const; + bool Get(bool& boolValue) const; /** * @brief Retrieves a floating-point value. @@ -364,7 +363,7 @@ public: * @return @c true if the value is successfully retrieved, @c false if the type is not convertible * @pre GetType() is a type convertible to float. */ - bool Get( float& floatValue ) const; + bool Get(float& floatValue) const; /** * @brief Retrieves an integer value. @@ -374,7 +373,7 @@ public: * @return @c true if the value is successfully retrieved, @c false if the type is not convertible * @pre GetType() is a type convertible to int. */ - bool Get( int32_t& integerValue ) const; + bool Get(int32_t& integerValue) const; /** * @brief Retrieves an integer rectangle. @@ -384,7 +383,7 @@ public: * @return @c true if the value is successfully retrieved, @c false if the type is not convertible * @pre GetType() is a type convertible to Rect. */ - bool Get( Rect& rect ) const; + bool Get(Rect& rect) const; /** * @brief Retrieves a vector value. @@ -394,7 +393,7 @@ public: * @return @c true if the value is successfully retrieved, @c false if the type is not convertible * @pre GetType() is a type convertible to Vector2. */ - bool Get( Vector2& vectorValue ) const; + bool Get(Vector2& vectorValue) const; /** * @brief Retrieves a vector value. @@ -404,7 +403,7 @@ public: * @return @c true if the value is successfully retrieved, @c false if the type is not convertible * @pre GetType() is a type convertible to Vector3. */ - bool Get( Vector3& vectorValue ) const; + bool Get(Vector3& vectorValue) const; /** * @brief Retrieves a vector value. @@ -414,7 +413,7 @@ public: * @return @c true if the value is successfully retrieved, @c false if the type is not convertible * @pre GetType() is a type convertible to Vector4. */ - bool Get( Vector4& vectorValue ) const; + bool Get(Vector4& vectorValue) const; /** * @brief Retrieves a matrix3 value. @@ -424,7 +423,7 @@ public: * @return @c true if the value is successfully retrieved, @c false if the type is not convertible * @pre GetType() is a type convertible to Matrix3. */ - bool Get( Matrix3& matrixValue ) const; + bool Get(Matrix3& matrixValue) const; /** * @brief Retrieves a matrix value. @@ -434,7 +433,7 @@ public: * @return @c true if the value is successfully retrieved, @c false if the type is not convertible * @pre GetType() is a type convertible to Matrix. */ - bool Get( Matrix& matrixValue ) const; + bool Get(Matrix& matrixValue) const; /** * @brief Retrieves an angle-axis value. @@ -444,7 +443,7 @@ public: * @return @c true if the value is successfully retrieved, @c false if the type is not convertible * @pre GetType() is a type convertible to AngleAxis. */ - bool Get( AngleAxis& angleAxisValue ) const; + bool Get(AngleAxis& angleAxisValue) const; /** * @brief Retrieves a quaternion value. @@ -454,7 +453,7 @@ public: * @return @c true if the value is successfully retrieved, @c false if the type is not convertible * @pre GetType() is a type convertible to Quaternion. */ - bool Get( Quaternion& quaternionValue ) const; + bool Get(Quaternion& quaternionValue) const; /** * @brief Retrieves an string property value. @@ -464,7 +463,7 @@ public: * @return @c true if the value is successfully retrieved, @c false if the type is not convertible * @pre GetType() is a type convertible to string. */ - bool Get( std::string& stringValue ) const; + bool Get(std::string& stringValue) const; /** * @brief Retrieves an array property value. @@ -474,7 +473,7 @@ public: * @return @c true if the value is successfully retrieved, @c false if the type is not convertible * @pre GetType() returns Property::ARRAY. */ - bool Get( Property::Array& arrayValue ) const; + bool Get(Property::Array& arrayValue) const; /** * @brief Retrieves an map property value. @@ -484,7 +483,7 @@ public: * @return @c true if the value is successfully retrieved, @c false if the type is not convertible * @pre GetType() returns Property::MAP. */ - bool Get( Property::Map& mapValue ) const; + bool Get(Property::Map& mapValue) const; /** * @brief Retrieves the Array API of the Property::Value without copying the contents of the map. @@ -510,19 +509,17 @@ public: * @return @c true if the value is successfully retrieved, @c false if the type is not convertible * @pre GetType() is a type convertible to Extents. */ - bool Get( Extents& extentsValue ) const; + bool Get(Extents& extentsValue) const; /** * @brief Output to stream. * @SINCE_1_0.0 */ - friend DALI_CORE_API std::ostream& operator<<( std::ostream& ouputStream, const Property::Value& value ); + friend DALI_CORE_API std::ostream& operator<<(std::ostream& ouputStream, const Property::Value& value); private: - struct DALI_INTERNAL Impl; - Impl* mImpl; ///< Pointer to the implementation - + Impl* mImpl; ///< Pointer to the implementation }; /** @@ -533,7 +530,7 @@ private: * @param[in] value The value to insert * @return The output stream operator */ -DALI_CORE_API std::ostream& operator<<( std::ostream& ouputStream, const Property::Value& value ); +DALI_CORE_API std::ostream& operator<<(std::ostream& ouputStream, const Property::Value& value); /** * @} diff --git a/dali/public-api/object/property.cpp b/dali/public-api/object/property.cpp index c80524e..77aa921 100644 --- a/dali/public-api/object/property.cpp +++ b/dali/public-api/object/property.cpp @@ -23,7 +23,6 @@ namespace Dali { - Property::Property(Handle& obj, Property::Index propIndex) : object(obj), propertyIndex(propIndex), @@ -43,7 +42,7 @@ Property::Property(Handle& obj, const std::string& propertyName) propertyIndex(Property::INVALID_INDEX), componentIndex(Property::INVALID_COMPONENT_INDEX) { - propertyIndex = object.GetPropertyIndex( propertyName ); + propertyIndex = object.GetPropertyIndex(propertyName); } Property::Property(Handle& obj, const std::string& propertyName, int32_t compIndex) @@ -51,7 +50,7 @@ Property::Property(Handle& obj, const std::string& propertyName, int32_t compInd propertyIndex(Property::INVALID_INDEX), componentIndex(compIndex) { - propertyIndex = object.GetPropertyIndex( propertyName ); + propertyIndex = object.GetPropertyIndex(propertyName); } Property::~Property() diff --git a/dali/public-api/object/property.h b/dali/public-api/object/property.h index eeda0c7..b9cdf0b 100644 --- a/dali/public-api/object/property.h +++ b/dali/public-api/object/property.h @@ -19,9 +19,9 @@ */ // EXTERNAL INCLUDES +#include // int32_t #include #include -#include // int32_t // INTERNAL INCLUDES #include @@ -48,8 +48,8 @@ struct DALI_CORE_API Property */ using Index = int32_t; - static constexpr int32_t INVALID_INDEX{-1}; ///< -1 is not a valid property index - static constexpr int32_t INVALID_KEY{-1}; ///< -1 is not a valid property key + static constexpr int32_t INVALID_INDEX{-1}; ///< -1 is not a valid property index + static constexpr int32_t INVALID_KEY{-1}; ///< -1 is not a valid property key static constexpr int32_t INVALID_COMPONENT_INDEX{-1}; ///< -1 is not a valid property index using IndexContainer = Dali::Vector; ///< A vector of property indices @SINCE_1_0.0 @@ -80,22 +80,22 @@ struct DALI_CORE_API Property */ enum Type { - NONE, ///< No type @SINCE_1_0.0 - - BOOLEAN, ///< A boolean type @SINCE_1_0.0 - FLOAT, ///< A float type @SINCE_1_0.0 - INTEGER, ///< An integer type @SINCE_1_0.0 - VECTOR2, ///< a vector array of size=2 with float precision @SINCE_1_0.0 - VECTOR3, ///< a vector array of size=3 with float precision @SINCE_1_0.0 - VECTOR4, ///< a vector array of size=4 with float precision @SINCE_1_0.0 - MATRIX3, ///< a 3x3 matrix @SINCE_1_0.0 - MATRIX, ///< a 4x4 matrix @SINCE_1_0.0 - RECTANGLE, ///< an integer array of size=4 @SINCE_1_0.0 - ROTATION, ///< either a quaternion or an axis angle rotation @SINCE_1_0.0 - STRING, ///< A string type @SINCE_1_0.0 - ARRAY, ///< an array of Property::Value @SINCE_1_0.0 - MAP, ///< a string key to Property:value mapping @SINCE_1_0.0 - EXTENTS ///< a collection of 4 x uint16_t @SINCE_1_2.62 + NONE, ///< No type @SINCE_1_0.0 + + BOOLEAN, ///< A boolean type @SINCE_1_0.0 + FLOAT, ///< A float type @SINCE_1_0.0 + INTEGER, ///< An integer type @SINCE_1_0.0 + VECTOR2, ///< a vector array of size=2 with float precision @SINCE_1_0.0 + VECTOR3, ///< a vector array of size=3 with float precision @SINCE_1_0.0 + VECTOR4, ///< a vector array of size=4 with float precision @SINCE_1_0.0 + MATRIX3, ///< a 3x3 matrix @SINCE_1_0.0 + MATRIX, ///< a 4x4 matrix @SINCE_1_0.0 + RECTANGLE, ///< an integer array of size=4 @SINCE_1_0.0 + ROTATION, ///< either a quaternion or an axis angle rotation @SINCE_1_0.0 + STRING, ///< A string type @SINCE_1_0.0 + ARRAY, ///< an array of Property::Value @SINCE_1_0.0 + MAP, ///< a string key to Property:value mapping @SINCE_1_0.0 + EXTENTS ///< a collection of 4 x uint16_t @SINCE_1_2.62 }; /** @@ -104,13 +104,12 @@ struct DALI_CORE_API Property */ enum AccessMode { - READ_ONLY, ///< if the property is read-only @SINCE_1_0.0 - READ_WRITE, ///< If the property is read/writeable @SINCE_1_0.0 - ANIMATABLE, ///< If the property can be animated or constrained @SINCE_1_0.0 - ACCESS_MODE_COUNT ///< The number of access modes @SINCE_1_0.0 + READ_ONLY, ///< if the property is read-only @SINCE_1_0.0 + READ_WRITE, ///< If the property is read/writeable @SINCE_1_0.0 + ANIMATABLE, ///< If the property can be animated or constrained @SINCE_1_0.0 + ACCESS_MODE_COUNT ///< The number of access modes @SINCE_1_0.0 }; - /** * @brief Creates a Property instance. * @@ -118,8 +117,7 @@ struct DALI_CORE_API Property * @param[in] object A valid handle to the target object * @param[in] propertyIndex The index of a property */ - Property( Handle& object, Property::Index propertyIndex ); - + Property(Handle& object, Property::Index propertyIndex); /** * @brief Creates a Property instance. @@ -129,7 +127,7 @@ struct DALI_CORE_API Property * @param[in] propertyIndex The index of a property. * @param[in] componentIndex Index to a sub component of a property, for use with Vector2, Vector3 and Vector4. -1 for main property (default is -1) */ - Property( Handle& object, Property::Index propertyIndex, int32_t componentIndex ); + Property(Handle& object, Property::Index propertyIndex, int32_t componentIndex); /** * @brief Creates a Property instance. @@ -140,7 +138,7 @@ struct DALI_CORE_API Property * @note This performs a property index query and is therefore slower than * constructing a Property directly with the index. */ - Property( Handle& object, const std::string& propertyName ); + Property(Handle& object, const std::string& propertyName); /** * @brief Creates a Property instance. @@ -152,7 +150,7 @@ struct DALI_CORE_API Property * @note This performs a property index query and is therefore slower than * constructing a Property directly with the index. */ - Property( Handle& object, const std::string& propertyName, int32_t componentIndex ); + Property(Handle& object, const std::string& propertyName, int32_t componentIndex); /** * @brief Non-virtual destructor; Property is not intended as a base class. diff --git a/dali/public-api/object/ref-object.cpp b/dali/public-api/object/ref-object.cpp index cdd3546..f27065d 100644 --- a/dali/public-api/object/ref-object.cpp +++ b/dali/public-api/object/ref-object.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -55,6 +55,7 @@ RefObject& RefObject::operator=(const RefObject&) void RefObject::Reference() { + // clang-format off // The inline assembly below was tested on an ARMv8 64 bit platform on // 2015-02-06 and found to run in 11.8 nanoseconds, whereas // __sync_add_and_fetch( address, 1 ) required 18.8 nanoseconds. @@ -105,10 +106,13 @@ void RefObject::Reference() __sync_add_and_fetch( &mCount, 1 ); #endif + // clang-format on } void RefObject::Unreference() { + // clang-format off + // The output register: int32_t newValue; @@ -159,6 +163,7 @@ void RefObject::Unreference() { delete this; } + // clang-format on } uint32_t RefObject::ReferenceCount() @@ -167,5 +172,3 @@ uint32_t RefObject::ReferenceCount() } } // namespace Dali - - diff --git a/dali/public-api/object/ref-object.h b/dali/public-api/object/ref-object.h index 473b08f..56e0018 100644 --- a/dali/public-api/object/ref-object.h +++ b/dali/public-api/object/ref-object.h @@ -2,7 +2,7 @@ #define DALI_REF_OBJECT_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -44,7 +44,6 @@ class Value; class DALI_CORE_API RefObject { public: - /** * @brief Increments the object's reference count. * @SINCE_1_0.0 @@ -68,7 +67,6 @@ public: uint32_t ReferenceCount(); protected: - /** * @brief Default constructor. * @SINCE_1_0.0 @@ -103,7 +101,6 @@ protected: RefObject& operator=(const RefObject& rhs); private: - volatile uint32_t mCount; ///< Reference count }; diff --git a/dali/public-api/object/type-info.cpp b/dali/public-api/object/type-info.cpp index 16d06a2..76e147c 100644 --- a/dali/public-api/object/type-info.cpp +++ b/dali/public-api/object/type-info.cpp @@ -25,7 +25,6 @@ namespace Dali { - TypeInfo::TypeInfo() { } @@ -38,9 +37,9 @@ TypeInfo::TypeInfo(const TypeInfo& copy) = default; TypeInfo& TypeInfo::operator=(const TypeInfo& rhs) = default; -TypeInfo::TypeInfo( TypeInfo&& rhs ) = default; +TypeInfo::TypeInfo(TypeInfo&& rhs) = default; -TypeInfo& TypeInfo::operator=( TypeInfo&& rhs ) = default; +TypeInfo& TypeInfo::operator=(TypeInfo&& rhs) = default; const std::string& TypeInfo::GetName() const { @@ -69,7 +68,7 @@ size_t TypeInfo::GetActionCount() const std::string TypeInfo::GetActionName(size_t index) { - return GetImplementation(*this).GetActionName( static_cast( index ) ); + return GetImplementation(*this).GetActionName(static_cast(index)); } size_t TypeInfo::GetSignalCount() const @@ -79,7 +78,7 @@ size_t TypeInfo::GetSignalCount() const std::string TypeInfo::GetSignalName(size_t index) { - return GetImplementation(*this).GetSignalName( static_cast( index ) ); + return GetImplementation(*this).GetSignalName(static_cast(index)); } size_t TypeInfo::GetPropertyCount() const @@ -87,36 +86,36 @@ size_t TypeInfo::GetPropertyCount() const return GetImplementation(*this).GetPropertyCount(); } -void TypeInfo::GetPropertyIndices( Property::IndexContainer& indices ) const +void TypeInfo::GetPropertyIndices(Property::IndexContainer& indices) const { indices.Clear(); // We do not want to clear the container if called internally, so only clear here - GetImplementation(*this).GetPropertyIndices( indices ); + GetImplementation(*this).GetPropertyIndices(indices); } -const std::string& TypeInfo::GetPropertyName( Property::Index index ) const +const std::string& TypeInfo::GetPropertyName(Property::Index index) const { - return GetImplementation(*this).GetRegisteredPropertyName( index ); + return GetImplementation(*this).GetRegisteredPropertyName(index); } -Property::Index TypeInfo::GetChildPropertyIndex( const std::string& name ) const +Property::Index TypeInfo::GetChildPropertyIndex(const std::string& name) const { - return GetImplementation(*this).GetChildPropertyIndex( name ); + return GetImplementation(*this).GetChildPropertyIndex(name); } -const std::string& TypeInfo::GetChildPropertyName( Property::Index index ) const +const std::string& TypeInfo::GetChildPropertyName(Property::Index index) const { - return GetImplementation(*this).GetChildPropertyName( index ); + return GetImplementation(*this).GetChildPropertyName(index); } -Property::Type TypeInfo::GetChildPropertyType( Property::Index index ) const +Property::Type TypeInfo::GetChildPropertyType(Property::Index index) const { - return GetImplementation(*this).GetChildPropertyType( index ); + return GetImplementation(*this).GetChildPropertyType(index); } -void TypeInfo::GetChildPropertyIndices( Property::IndexContainer& indices ) const +void TypeInfo::GetChildPropertyIndices(Property::IndexContainer& indices) const { indices.Clear(); // We do not want to clear the container if called internally, so only clear here - GetImplementation(*this).GetChildPropertyIndices( indices ); + GetImplementation(*this).GetChildPropertyIndices(indices); } TypeInfo::TypeInfo(Internal::TypeInfo* internal) diff --git a/dali/public-api/object/type-info.h b/dali/public-api/object/type-info.h index cbc9aa1..164ab17 100644 --- a/dali/public-api/object/type-info.h +++ b/dali/public-api/object/type-info.h @@ -22,8 +22,8 @@ #include // uint32_t // INTERNAL INCLUDES -#include #include +#include namespace Dali { @@ -37,7 +37,7 @@ class FunctorDelegate; namespace Internal DALI_INTERNAL { - class TypeInfo; +class TypeInfo; }; /** @@ -50,7 +50,6 @@ namespace Internal DALI_INTERNAL class DALI_CORE_API TypeInfo : public BaseHandle { public: - using CreateFunction = BaseHandle (*)(); ///< Function signature for creating an instance of the associated object type. @SINCE_1_0.0 using ActionFunction = bool (*)(BaseObject*, const std::string&, const Property::Map&); ///< Function signature for creating scriptable actions @SINCE_1_0.0 @@ -77,7 +76,7 @@ public: * @param[in] value The new value of the property for the object specified * @see PropertyRegistration. */ - using SetPropertyFunction = void (*)( BaseObject* object, Property::Index index, const Property::Value& value ); + using SetPropertyFunction = void (*)(BaseObject* object, Property::Index index, const Property::Value& value); /** * @brief Callback to get the value of an event-thread only property. @@ -88,7 +87,7 @@ public: * @return The current value of the property for the object specified * @see PropertyRegistration. */ - using GetPropertyFunction = Property::Value (*)( BaseObject* object, Property::Index index ); + using GetPropertyFunction = Property::Value (*)(BaseObject* object, Property::Index index); /** * @brief Allows the creation of an empty TypeInfo handle. @@ -127,7 +126,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs A reference to the moved handle */ - TypeInfo( TypeInfo&& rhs ); + TypeInfo(TypeInfo&& rhs); /** * @brief Move assignment operator. @@ -136,7 +135,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this handle */ - TypeInfo& operator=( TypeInfo&& rhs ); + TypeInfo& operator=(TypeInfo&& rhs); /** * @brief Retrieves the type name for this type. @@ -221,7 +220,7 @@ public: * @param[out] indices Container of property indices * @note The container will be cleared */ - void GetPropertyIndices( Property::IndexContainer& indices ) const; + void GetPropertyIndices(Property::IndexContainer& indices) const; /** * @brief Retrieves all the child property indices for this type. @@ -230,7 +229,7 @@ public: * @param[out] indices Container of property indices * @note The container will be cleared */ - void GetChildPropertyIndices( Property::IndexContainer& indices ) const; + void GetChildPropertyIndices(Property::IndexContainer& indices) const; /** * @brief Given a property index, retrieve the property name associated with it. @@ -241,8 +240,7 @@ public: * @exception DaliException If index is not valid. * @note this method only works for custom registered properties */ - const std::string& GetPropertyName( Property::Index index ) const; - + const std::string& GetPropertyName(Property::Index index) const; /** * @brief Given a child property name, retrieve the property index associated with it, @@ -251,7 +249,7 @@ public: * @param[in] name The name of the property at the given index, * @return The property index or Property::INVALID_INDEX */ - Property::Index GetChildPropertyIndex( const std::string& name ) const; + Property::Index GetChildPropertyIndex(const std::string& name) const; /** * @brief Given a child property index, retrieve the property name associated with it. @@ -260,7 +258,7 @@ public: * @param[in] index The property index * @return The name of the property at the given index, or empty string if it does not exist */ - const std::string& GetChildPropertyName( Property::Index index ) const; + const std::string& GetChildPropertyName(Property::Index index) const; /** * @brief Given a child property index, retrieve the property name associated with it. @@ -269,12 +267,9 @@ public: * @param[in] index The property index * @return The name of the property at the given index, or empty string if it does not exist */ - Property::Type GetChildPropertyType( Property::Index index ) const; - - + Property::Type GetChildPropertyType(Property::Index index) const; public: // Not intended for application developers - /// @cond internal /** * @brief This constructor is used by Dali Get() method. @@ -284,7 +279,6 @@ public: // Not intended for application developers */ explicit DALI_INTERNAL TypeInfo(Internal::TypeInfo* typeInfo); /// @endcond - }; /** diff --git a/dali/public-api/object/type-registry-helper.h b/dali/public-api/object/type-registry-helper.h index 27b53fb..4bad863 100644 --- a/dali/public-api/object/type-registry-helper.h +++ b/dali/public-api/object/type-registry-helper.h @@ -27,37 +27,36 @@ * These internal macros exist as to perform the compile-time check on the enumeration order, the __COUNTER__ macro is used twice. * Using it twice within the same macro would result in two different values. */ -#define DALI_TOKEN_PASTE_EXPAND( x, y ) x ## y -#define DALI_TOKEN_PASTE( x, y ) DALI_TOKEN_PASTE_EXPAND(x, y) +#define DALI_TOKEN_PASTE_EXPAND(x, y) x##y +#define DALI_TOKEN_PASTE(x, y) DALI_TOKEN_PASTE_EXPAND(x, y) -#define DALI_PROPERTY_REGISTRATION_INTERNAL( count, typeRegistrationObject, objectNamespace, objectType, text, valueType, enumIndex ) \ - Dali::PropertyRegistration DALI_TOKEN_PASTE( property, count ) ( typeRegistrationObject, text, objectNamespace::objectType::Property::enumIndex, Dali::Property::valueType, &objectType::SetProperty, &objectType::GetProperty ); \ - static_assert( ( objectNamespace::objectType::Property::enumIndex - objectNamespace::objectType::PROPERTY_START_INDEX ) == count ); +#define DALI_PROPERTY_REGISTRATION_INTERNAL(count, typeRegistrationObject, objectNamespace, objectType, text, valueType, enumIndex) \ + Dali::PropertyRegistration DALI_TOKEN_PASTE(property, count)(typeRegistrationObject, text, objectNamespace::objectType::Property::enumIndex, Dali::Property::valueType, &objectType::SetProperty, &objectType::GetProperty); \ + static_assert((objectNamespace::objectType::Property::enumIndex - objectNamespace::objectType::PROPERTY_START_INDEX) == count); -#define DALI_PROPERTY_REGISTRATION_INTERNAL_READ_ONLY( count, typeRegistrationObject, objectNamespace, objectType, text, valueType, enumIndex ) \ - Dali::PropertyRegistration DALI_TOKEN_PASTE( property, count ) ( typeRegistrationObject, text, objectNamespace::objectType::Property::enumIndex, Dali::Property::valueType, NULL, &objectType::GetProperty ); \ - static_assert( ( objectNamespace::objectType::Property::enumIndex - objectNamespace::objectType::PROPERTY_START_INDEX ) == count ); +#define DALI_PROPERTY_REGISTRATION_INTERNAL_READ_ONLY(count, typeRegistrationObject, objectNamespace, objectType, text, valueType, enumIndex) \ + Dali::PropertyRegistration DALI_TOKEN_PASTE(property, count)(typeRegistrationObject, text, objectNamespace::objectType::Property::enumIndex, Dali::Property::valueType, NULL, &objectType::GetProperty); \ + static_assert((objectNamespace::objectType::Property::enumIndex - objectNamespace::objectType::PROPERTY_START_INDEX) == count); -#define DALI_ANIMATABLE_PROPERTY_REGISTRATION_INTERNAL( count, typeRegistrationObject, objectNamespace, objectType, text, valueType, enumIndex) \ - Dali::AnimatablePropertyRegistration DALI_TOKEN_PASTE( property, count ) ( typeRegistrationObject, text, objectNamespace::objectType::Property::enumIndex, Dali::Property::valueType ); +#define DALI_ANIMATABLE_PROPERTY_REGISTRATION_INTERNAL(count, typeRegistrationObject, objectNamespace, objectType, text, valueType, enumIndex) \ + Dali::AnimatablePropertyRegistration DALI_TOKEN_PASTE(property, count)(typeRegistrationObject, text, objectNamespace::objectType::Property::enumIndex, Dali::Property::valueType); -#define DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT_INTERNAL( count, typeRegistrationObject, objectNamespace, objectType, text, value, enumIndex) \ - Dali::AnimatablePropertyRegistration DALI_TOKEN_PASTE( property, count ) ( typeRegistrationObject, text, objectNamespace::objectType::Property::enumIndex, value ); +#define DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT_INTERNAL(count, typeRegistrationObject, objectNamespace, objectType, text, value, enumIndex) \ + Dali::AnimatablePropertyRegistration DALI_TOKEN_PASTE(property, count)(typeRegistrationObject, text, objectNamespace::objectType::Property::enumIndex, value); -#define DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION_INTERNAL( count, typeRegistrationObject, objectNamespace, objectType, text, enumIndex, baseEnumIndex, componentIndex) \ - Dali::AnimatablePropertyComponentRegistration DALI_TOKEN_PASTE( property, count ) ( typeRegistrationObject, text, objectNamespace::objectType::Property::enumIndex, objectNamespace::objectType::Property::baseEnumIndex, componentIndex ); +#define DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION_INTERNAL(count, typeRegistrationObject, objectNamespace, objectType, text, enumIndex, baseEnumIndex, componentIndex) \ + Dali::AnimatablePropertyComponentRegistration DALI_TOKEN_PASTE(property, count)(typeRegistrationObject, text, objectNamespace::objectType::Property::enumIndex, objectNamespace::objectType::Property::baseEnumIndex, componentIndex); -#define DALI_CHILD_PROPERTY_REGISTRATION_INTERNAL( count, typeRegistrationObject, objectNamespace, objectType, text, valueType, enumIndex ) \ - Dali::ChildPropertyRegistration DALI_TOKEN_PASTE( property, count ) ( typeRegistrationObject, text, objectNamespace::objectType::ChildProperty::enumIndex, Property::valueType ); +#define DALI_CHILD_PROPERTY_REGISTRATION_INTERNAL(count, typeRegistrationObject, objectNamespace, objectType, text, valueType, enumIndex) \ + Dali::ChildPropertyRegistration DALI_TOKEN_PASTE(property, count)(typeRegistrationObject, text, objectNamespace::objectType::ChildProperty::enumIndex, Property::valueType); -#define DALI_SIGNAL_REGISTRATION_INTERNAL( count, typeRegistrationObject, objectNamespace, objectType, text, textVariable ) \ - const char* const textVariable = text; \ - Dali::SignalConnectorType DALI_TOKEN_PASTE( signalConnector, count ) ( typeRegistrationObject, text, &objectNamespace::Internal::objectType::DoConnectSignal ); - -#define DALI_ACTION_REGISTRATION_INTERNAL( count, typeRegistrationObject, objectNamespace, objectType, text, textVariable ) \ - const char* const textVariable = text; \ - Dali::TypeAction DALI_TOKEN_PASTE( signalConnector, count ) ( typeRegistrationObject, text, &objectNamespace::Internal::objectType::DoAction ); +#define DALI_SIGNAL_REGISTRATION_INTERNAL(count, typeRegistrationObject, objectNamespace, objectType, text, textVariable) \ + const char* const textVariable = text; \ + Dali::SignalConnectorType DALI_TOKEN_PASTE(signalConnector, count)(typeRegistrationObject, text, &objectNamespace::Internal::objectType::DoConnectSignal); +#define DALI_ACTION_REGISTRATION_INTERNAL(count, typeRegistrationObject, objectNamespace, objectType, text, textVariable) \ + const char* const textVariable = text; \ + Dali::TypeAction DALI_TOKEN_PASTE(signalConnector, count)(typeRegistrationObject, text, &objectNamespace::Internal::objectType::DoAction); /** * @brief These macros are used to define properties for implementations of CustomActor. @@ -110,37 +109,36 @@ * Using these macros have certain prerequisites on how the property enumeration is defined. * Please see the Programming Guide (within the generated Doxygen) for full details. */ -#define DALI_TYPE_REGISTRATION_BEGIN( thisType, baseType, createFunction ) \ - Dali::TypeRegistration typeRegistration( typeid( thisType ), typeid( baseType ), createFunction ); - -#define DALI_TYPE_REGISTRATION_BEGIN_CREATE( thisType, baseType, createFunction, createAtStartup ) \ - Dali::TypeRegistration typeRegistration( typeid( thisType ), typeid( baseType ), createFunction, createAtStartup ); +#define DALI_TYPE_REGISTRATION_BEGIN(thisType, baseType, createFunction) \ + Dali::TypeRegistration typeRegistration(typeid(thisType), typeid(baseType), createFunction); -#define DALI_PROPERTY_REGISTRATION( objectNamespace, objectType, text, valueType, enumIndex ) \ - DALI_PROPERTY_REGISTRATION_INTERNAL( __COUNTER__, typeRegistration, objectNamespace, objectType, text, valueType, enumIndex ) +#define DALI_TYPE_REGISTRATION_BEGIN_CREATE(thisType, baseType, createFunction, createAtStartup) \ + Dali::TypeRegistration typeRegistration(typeid(thisType), typeid(baseType), createFunction, createAtStartup); -#define DALI_PROPERTY_REGISTRATION_READ_ONLY( objectNamespace, objectType, text, valueType, enumIndex ) \ - DALI_PROPERTY_REGISTRATION_INTERNAL_READ_ONLY( __COUNTER__, typeRegistration, objectNamespace, objectType, text, valueType, enumIndex ) +#define DALI_PROPERTY_REGISTRATION(objectNamespace, objectType, text, valueType, enumIndex) \ + DALI_PROPERTY_REGISTRATION_INTERNAL(__COUNTER__, typeRegistration, objectNamespace, objectType, text, valueType, enumIndex) -#define DALI_ANIMATABLE_PROPERTY_REGISTRATION( objectNamespace, objectType, text, valueType, enumIndex ) \ - DALI_ANIMATABLE_PROPERTY_REGISTRATION_INTERNAL( __COUNTER__, typeRegistration, objectNamespace, objectType, text, valueType, enumIndex ) +#define DALI_PROPERTY_REGISTRATION_READ_ONLY(objectNamespace, objectType, text, valueType, enumIndex) \ + DALI_PROPERTY_REGISTRATION_INTERNAL_READ_ONLY(__COUNTER__, typeRegistration, objectNamespace, objectType, text, valueType, enumIndex) -#define DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT( objectNamespace, objectType, text, value, enumIndex ) \ - DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT_INTERNAL( __COUNTER__, typeRegistration, objectNamespace, objectType, text, value, enumIndex ) +#define DALI_ANIMATABLE_PROPERTY_REGISTRATION(objectNamespace, objectType, text, valueType, enumIndex) \ + DALI_ANIMATABLE_PROPERTY_REGISTRATION_INTERNAL(__COUNTER__, typeRegistration, objectNamespace, objectType, text, valueType, enumIndex) -#define DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION( objectNamespace, objectType, text, enumIndex, baseEnumIndex, componentIndex ) \ - DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION_INTERNAL( __COUNTER__, typeRegistration, objectNamespace, objectType, text, enumIndex, baseEnumIndex, componentIndex ) +#define DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT(objectNamespace, objectType, text, value, enumIndex) \ + DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT_INTERNAL(__COUNTER__, typeRegistration, objectNamespace, objectType, text, value, enumIndex) -#define DALI_CHILD_PROPERTY_REGISTRATION( objectNamespace, objectType, text, valueType, enumIndex ) \ - DALI_CHILD_PROPERTY_REGISTRATION_INTERNAL( __COUNTER__, typeRegistration, objectNamespace, objectType, text, valueType, enumIndex ) +#define DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION(objectNamespace, objectType, text, enumIndex, baseEnumIndex, componentIndex) \ + DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION_INTERNAL(__COUNTER__, typeRegistration, objectNamespace, objectType, text, enumIndex, baseEnumIndex, componentIndex) -#define DALI_SIGNAL_REGISTRATION( objectNamespace, objectType, text, textVariable ) \ - DALI_SIGNAL_REGISTRATION_INTERNAL( __COUNTER__, typeRegistration, objectNamespace, objectType, text, textVariable ) +#define DALI_CHILD_PROPERTY_REGISTRATION(objectNamespace, objectType, text, valueType, enumIndex) \ + DALI_CHILD_PROPERTY_REGISTRATION_INTERNAL(__COUNTER__, typeRegistration, objectNamespace, objectType, text, valueType, enumIndex) -#define DALI_ACTION_REGISTRATION( objectNamespace, objectType, text, textVariable ) \ - DALI_ACTION_REGISTRATION_INTERNAL( __COUNTER__, typeRegistration, objectNamespace, objectType, text, textVariable ) +#define DALI_SIGNAL_REGISTRATION(objectNamespace, objectType, text, textVariable) \ + DALI_SIGNAL_REGISTRATION_INTERNAL(__COUNTER__, typeRegistration, objectNamespace, objectType, text, textVariable) -#define DALI_TYPE_REGISTRATION_END( ) // This macro exists for consistency and readability. +#define DALI_ACTION_REGISTRATION(objectNamespace, objectType, text, textVariable) \ + DALI_ACTION_REGISTRATION_INTERNAL(__COUNTER__, typeRegistration, objectNamespace, objectType, text, textVariable) +#define DALI_TYPE_REGISTRATION_END() // This macro exists for consistency and readability. #endif // DALI_TYPE_REGISTRY_HELPER_H diff --git a/dali/public-api/object/type-registry.cpp b/dali/public-api/object/type-registry.cpp index a3f4a64..00b6bf9 100644 --- a/dali/public-api/object/type-registry.cpp +++ b/dali/public-api/object/type-registry.cpp @@ -21,13 +21,12 @@ // EXTERNAL INCLUDES // INTERNAL INCLUDES -#include #include #include +#include namespace Dali { - TypeRegistry::TypeRegistry() { } @@ -40,23 +39,23 @@ TypeRegistry::TypeRegistry(const TypeRegistry& copy) = default; TypeRegistry& TypeRegistry::operator=(const TypeRegistry& rhs) = default; -TypeRegistry::TypeRegistry( TypeRegistry&& rhs ) = default; +TypeRegistry::TypeRegistry(TypeRegistry&& rhs) = default; -TypeRegistry& TypeRegistry::operator=( TypeRegistry&& rhs ) = default; +TypeRegistry& TypeRegistry::operator=(TypeRegistry&& rhs) = default; TypeRegistry TypeRegistry::Get() { return TypeRegistry(Internal::TypeRegistry::Get()); } -Dali::TypeInfo TypeRegistry::GetTypeInfo( const std::string &uniqueTypeName ) +Dali::TypeInfo TypeRegistry::GetTypeInfo(const std::string& uniqueTypeName) { - return Dali::TypeInfo( GetImplementation(*this).GetTypeInfo( uniqueTypeName ).Get() ); + return Dali::TypeInfo(GetImplementation(*this).GetTypeInfo(uniqueTypeName).Get()); } -Dali::TypeInfo TypeRegistry::GetTypeInfo( const std::type_info& registerType ) +Dali::TypeInfo TypeRegistry::GetTypeInfo(const std::type_info& registerType) { - return Dali::TypeInfo( GetImplementation(*this).GetTypeInfo( registerType ).Get() ); + return Dali::TypeInfo(GetImplementation(*this).GetTypeInfo(registerType).Get()); } size_t TypeRegistry::GetTypeNameCount() const @@ -66,7 +65,7 @@ size_t TypeRegistry::GetTypeNameCount() const std::string TypeRegistry::GetTypeName(size_t index) const { - return GetImplementation(*this).GetTypeName( static_cast( index ) ); + return GetImplementation(*this).GetTypeName(static_cast(index)); } TypeRegistry::TypeRegistry(Internal::TypeRegistry* internal) @@ -74,98 +73,92 @@ TypeRegistry::TypeRegistry(Internal::TypeRegistry* internal) { } -TypeRegistration::TypeRegistration( const std::type_info& registerType, const std::type_info& baseType, - TypeInfo::CreateFunction f ) - : mReference(Internal::TypeRegistry::Get()) +TypeRegistration::TypeRegistration(const std::type_info& registerType, const std::type_info& baseType, TypeInfo::CreateFunction f) +: mReference(Internal::TypeRegistry::Get()) { - Internal::TypeRegistry *impl = Internal::TypeRegistry::Get(); + Internal::TypeRegistry* impl = Internal::TypeRegistry::Get(); - mName = impl->Register( registerType, baseType, f, false ); + mName = impl->Register(registerType, baseType, f, false); } -TypeRegistration::TypeRegistration( const std::type_info& registerType, const std::type_info& baseType, - TypeInfo::CreateFunction f, bool callCreateOnInit ) - : mReference(Internal::TypeRegistry::Get()) +TypeRegistration::TypeRegistration(const std::type_info& registerType, const std::type_info& baseType, TypeInfo::CreateFunction f, bool callCreateOnInit) +: mReference(Internal::TypeRegistry::Get()) { - Internal::TypeRegistry *impl = Internal::TypeRegistry::Get(); + Internal::TypeRegistry* impl = Internal::TypeRegistry::Get(); - mName = impl->Register( registerType, baseType, f, callCreateOnInit ); + mName = impl->Register(registerType, baseType, f, callCreateOnInit); } -TypeRegistration::TypeRegistration( const std::type_info& registerType, const std::type_info& baseType, - TypeInfo::CreateFunction f, const DefaultPropertyMetadata& defaultProperties ) +TypeRegistration::TypeRegistration(const std::type_info& registerType, const std::type_info& baseType, TypeInfo::CreateFunction f, const DefaultPropertyMetadata& defaultProperties) { - Internal::TypeRegistry *impl = Internal::TypeRegistry::Get(); + Internal::TypeRegistry* impl = Internal::TypeRegistry::Get(); - mName = impl->Register( registerType, baseType, f, false, defaultProperties.propertyTable, defaultProperties.propertyCount ); + mName = impl->Register(registerType, baseType, f, false, defaultProperties.propertyTable, defaultProperties.propertyCount); } -TypeRegistration::TypeRegistration( const std::string& name, const std::type_info& baseType, - TypeInfo::CreateFunction f ) - : mReference(Internal::TypeRegistry::Get()) +TypeRegistration::TypeRegistration(const std::string& name, const std::type_info& baseType, TypeInfo::CreateFunction f) +: mReference(Internal::TypeRegistry::Get()) { - Internal::TypeRegistry *impl = Internal::TypeRegistry::Get(); + Internal::TypeRegistry* impl = Internal::TypeRegistry::Get(); - mName = impl->Register( name, baseType, f, false ); + mName = impl->Register(name, baseType, f, false); } - const std::string TypeRegistration::RegisteredName() const { return mName; } -SignalConnectorType::SignalConnectorType( TypeRegistration& typeRegistration, const std::string& name, TypeInfo::SignalConnectorFunction func ) +SignalConnectorType::SignalConnectorType(TypeRegistration& typeRegistration, const std::string& name, TypeInfo::SignalConnectorFunction func) { - Internal::TypeRegistry::Get()->RegisterSignal( typeRegistration, name, func ); + Internal::TypeRegistry::Get()->RegisterSignal(typeRegistration, name, func); } -TypeAction::TypeAction( TypeRegistration ®istered, const std::string &name, TypeInfo::ActionFunction f) +TypeAction::TypeAction(TypeRegistration& registered, const std::string& name, TypeInfo::ActionFunction f) { - Internal::TypeRegistry::Get()->RegisterAction( registered, name, f ); + Internal::TypeRegistry::Get()->RegisterAction(registered, name, f); } -PropertyRegistration::PropertyRegistration( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type, TypeInfo::SetPropertyFunction setFunc, TypeInfo::GetPropertyFunction getFunc ) +PropertyRegistration::PropertyRegistration(TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type, TypeInfo::SetPropertyFunction setFunc, TypeInfo::GetPropertyFunction getFunc) { - DALI_ASSERT_ALWAYS( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) ); + DALI_ASSERT_ALWAYS((index >= PROPERTY_REGISTRATION_START_INDEX) && (index <= PROPERTY_REGISTRATION_MAX_INDEX)); - Internal::TypeRegistry::Get()->RegisterProperty( registered, name, index, type, setFunc, getFunc ); + Internal::TypeRegistry::Get()->RegisterProperty(registered, name, index, type, setFunc, getFunc); } -AnimatablePropertyRegistration::AnimatablePropertyRegistration( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type ) +AnimatablePropertyRegistration::AnimatablePropertyRegistration(TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type) { - DALI_ASSERT_ALWAYS( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) ); + DALI_ASSERT_ALWAYS((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX)); - Internal::TypeRegistry::Get()->RegisterAnimatableProperty( registered, name, index, type ); + Internal::TypeRegistry::Get()->RegisterAnimatableProperty(registered, name, index, type); } -AnimatablePropertyRegistration::AnimatablePropertyRegistration( TypeRegistration& registered, const std::string& name, Property::Index index, const Property::Value& value ) +AnimatablePropertyRegistration::AnimatablePropertyRegistration(TypeRegistration& registered, const std::string& name, Property::Index index, const Property::Value& value) { - DALI_ASSERT_ALWAYS( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) ); + DALI_ASSERT_ALWAYS((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX)); - Internal::TypeRegistry::Get()->RegisterAnimatableProperty( registered, name, index, value ); + Internal::TypeRegistry::Get()->RegisterAnimatableProperty(registered, name, index, value); } -AnimatablePropertyComponentRegistration::AnimatablePropertyComponentRegistration( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Index baseIndex, uint32_t componentIndex) +AnimatablePropertyComponentRegistration::AnimatablePropertyComponentRegistration(TypeRegistration& registered, const std::string& name, Property::Index index, Property::Index baseIndex, uint32_t componentIndex) { - DALI_ASSERT_ALWAYS( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) ); + DALI_ASSERT_ALWAYS((index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX) && (index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX)); - Internal::TypeRegistry::Get()->RegisterAnimatablePropertyComponent( registered, name, index, baseIndex, componentIndex ); + Internal::TypeRegistry::Get()->RegisterAnimatablePropertyComponent(registered, name, index, baseIndex, componentIndex); } -ChildPropertyRegistration::ChildPropertyRegistration( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type ) +ChildPropertyRegistration::ChildPropertyRegistration(TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type) { - DALI_ASSERT_ALWAYS( ( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX ) ); + DALI_ASSERT_ALWAYS((index >= CHILD_PROPERTY_REGISTRATION_START_INDEX) && (index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX)); - Internal::TypeRegistry::Get()->RegisterChildProperty( registered, name, index, type ); + Internal::TypeRegistry::Get()->RegisterChildProperty(registered, name, index, type); } -ChildPropertyRegistration::ChildPropertyRegistration( const std::string& registered, const std::string& name, Property::Index index, Property::Type type ) +ChildPropertyRegistration::ChildPropertyRegistration(const std::string& registered, const std::string& name, Property::Index index, Property::Type type) { - DALI_ASSERT_ALWAYS( ( index >= CHILD_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX ) ); + DALI_ASSERT_ALWAYS((index >= CHILD_PROPERTY_REGISTRATION_START_INDEX) && (index <= CHILD_PROPERTY_REGISTRATION_MAX_INDEX)); - Internal::TypeRegistry::Get()->RegisterChildProperty( registered, name, index, type ); + Internal::TypeRegistry::Get()->RegisterChildProperty(registered, name, index, type); } - } // namespace Dali diff --git a/dali/public-api/object/type-registry.h b/dali/public-api/object/type-registry.h index 082943c..5e3ceda 100644 --- a/dali/public-api/object/type-registry.h +++ b/dali/public-api/object/type-registry.h @@ -19,8 +19,8 @@ */ // EXTERNAL INCLUDES -#include #include // uint32_t +#include // INTERNAL INCLUDES #include @@ -140,7 +140,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs A reference to the moved handle */ - TypeRegistry( TypeRegistry&& rhs ); + TypeRegistry(TypeRegistry&& rhs); /** * @brief Move assignment operator. @@ -149,7 +149,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this handle */ - TypeRegistry& operator=( TypeRegistry&& rhs ); + TypeRegistry& operator=(TypeRegistry&& rhs); /** * @brief Gets TypeInfo for a registered type. @@ -158,7 +158,7 @@ public: * @param[in] uniqueTypeName A unique type name * @return TypeInfo if the type exists, otherwise an empty handle */ - TypeInfo GetTypeInfo( const std::string &uniqueTypeName ); + TypeInfo GetTypeInfo(const std::string& uniqueTypeName); /** * @brief Gets TypeInfo for a registered type. @@ -167,7 +167,7 @@ public: * @param[in] registerType The registered type info * @return TypeInfo if the type exists, otherwise an empty handle */ - TypeInfo GetTypeInfo( const std::type_info& registerType ); + TypeInfo GetTypeInfo(const std::type_info& registerType); /** * @brief Gets type name count. @@ -187,7 +187,6 @@ public: std::string GetTypeName(size_t index) const; public: // Not intended for application developers - /// @cond internal /** * @brief This constructor is used by Dali Get() method. @@ -195,7 +194,7 @@ public: // Not intended for application developers * @SINCE_1_0.0 * @param[in] typeRegistry A pointer to a Dali resource */ - explicit DALI_INTERNAL TypeRegistry(Internal::TypeRegistry*typeRegistry); + explicit DALI_INTERNAL TypeRegistry(Internal::TypeRegistry* typeRegistry); /// @endcond }; @@ -214,8 +213,7 @@ public: * @param[in] baseType The base type info of registerType * @param[in] f registerType Instance creation function */ - TypeRegistration( const std::type_info& registerType, const std::type_info& baseType, - TypeInfo::CreateFunction f ); + TypeRegistration(const std::type_info& registerType, const std::type_info& baseType, TypeInfo::CreateFunction f); /** * @brief Constructor registers the type creation function. @@ -226,8 +224,7 @@ public: * @param[in] f registerType instance creation function * @param[in] callCreateOnInit If true the creation function is called as part of Dali initialization */ - TypeRegistration( const std::type_info& registerType, const std::type_info& baseType, - TypeInfo::CreateFunction f, bool callCreateOnInit ); + TypeRegistration(const std::type_info& registerType, const std::type_info& baseType, TypeInfo::CreateFunction f, bool callCreateOnInit); /** * @brief Constructor registers the type creation function. @@ -238,8 +235,7 @@ public: * @param[in] f registerType instance creation function * @param[in] defaultProperties the default property meta-data */ - TypeRegistration( const std::type_info& registerType, const std::type_info& baseType, - TypeInfo::CreateFunction f, const DefaultPropertyMetadata& defaultProperties ); + TypeRegistration(const std::type_info& registerType, const std::type_info& baseType, TypeInfo::CreateFunction f, const DefaultPropertyMetadata& defaultProperties); /** * @brief Constructor registers the type creation function for a named class or type. @@ -251,8 +247,7 @@ public: * @param[in] baseType the base type info of registerType * @param[in] f registerType instance creation function */ - TypeRegistration( const std::string& name, const std::type_info& baseType, - TypeInfo::CreateFunction f ); + TypeRegistration(const std::string& name, const std::type_info& baseType, TypeInfo::CreateFunction f); /** * @brief The name the type is registered under (derived from type_info). @@ -264,7 +259,7 @@ public: private: TypeRegistry mReference; ///< Reference to the type registry - std::string mName; ///< Name of the type + std::string mName; ///< Name of the type }; /** @@ -282,7 +277,7 @@ public: * @param[in] name The signal name * @param[in] func The signal connector function */ - SignalConnectorType( TypeRegistration& typeRegistration, const std::string& name, TypeInfo::SignalConnectorFunction func ); + SignalConnectorType(TypeRegistration& typeRegistration, const std::string& name, TypeInfo::SignalConnectorFunction func); }; /** @@ -300,7 +295,7 @@ public: * @param[in] name The action name * @param[in] f The action function */ - TypeAction( TypeRegistration ®istered, const std::string &name, TypeInfo::ActionFunction f); + TypeAction(TypeRegistration& registered, const std::string& name, TypeInfo::ActionFunction f); }; /** @@ -310,7 +305,6 @@ public: class DALI_CORE_API PropertyRegistration { public: - /** * @brief This constructor registers the property with the registered type. * @@ -337,9 +331,12 @@ public: * @note "getFunc" MUST be provided. * */ - PropertyRegistration( TypeRegistration& registered, - const std::string& name, Property::Index index, Property::Type type, - TypeInfo::SetPropertyFunction setFunc, TypeInfo::GetPropertyFunction getFunc ); + PropertyRegistration(TypeRegistration& registered, + const std::string& name, + Property::Index index, + Property::Type type, + TypeInfo::SetPropertyFunction setFunc, + TypeInfo::GetPropertyFunction getFunc); }; /** @@ -349,7 +346,6 @@ public: class DALI_CORE_API AnimatablePropertyRegistration { public: - /** * @brief This constructor registers the animatable property with the registered type. * @@ -364,7 +360,7 @@ public: * @param[in] type The property value type * @pre "registered" must be registered with the TypeRegistry. */ - AnimatablePropertyRegistration( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type ); + AnimatablePropertyRegistration(TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type); /** * @brief This constructor registers the animatable property with the registered default value. @@ -380,7 +376,7 @@ public: * @param[in] value The property default value * @pre "registered" must be registered with the TypeRegistry. */ - AnimatablePropertyRegistration( TypeRegistration& registered, const std::string& name, Property::Index index, const Property::Value& value ); + AnimatablePropertyRegistration(TypeRegistration& registered, const std::string& name, Property::Index index, const Property::Value& value); }; /** @@ -390,7 +386,6 @@ public: class DALI_CORE_API AnimatablePropertyComponentRegistration { public: - /** * @brief This constructor registers a component of an animatable property where * the base animatable property must be a property that supports property component @@ -408,7 +403,7 @@ public: * @param[in] componentIndex The index of the component (e.g. 0 for the x component of a Vector2 property and 1 for the y component of a Vector2 property) * @pre "registered" must be registered with the TypeRegistry. */ - AnimatablePropertyComponentRegistration( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Index baseIndex, uint32_t componentIndex ); + AnimatablePropertyComponentRegistration(TypeRegistration& registered, const std::string& name, Property::Index index, Property::Index baseIndex, uint32_t componentIndex); }; /** @@ -418,7 +413,6 @@ public: class DALI_CORE_API ChildPropertyRegistration { public: - /** * @brief This constructor registers an event-thread only child property (i.e. a property * that the parent supports in its children) with the registered type. @@ -430,7 +424,7 @@ public: * @param[in] type The property value type * @pre "registered" must be registered with the TypeRegistry. */ - ChildPropertyRegistration( TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type ); + ChildPropertyRegistration(TypeRegistration& registered, const std::string& name, Property::Index index, Property::Type type); /** * @brief This constructor registers an event-thread only child property (i.e. a property @@ -443,10 +437,9 @@ public: * @param[in] type The property value type * @pre "registered" must be registered with the TypeRegistry. */ - ChildPropertyRegistration( const std::string& registered, const std::string& name, Property::Index index, Property::Type type ); + ChildPropertyRegistration(const std::string& registered, const std::string& name, Property::Index index, Property::Type type); }; - /** * @} */ diff --git a/dali/public-api/object/weak-handle.cpp b/dali/public-api/object/weak-handle.cpp index bec255d..3a8ff33 100644 --- a/dali/public-api/object/weak-handle.cpp +++ b/dali/public-api/object/weak-handle.cpp @@ -23,25 +23,24 @@ namespace Dali { - struct WeakHandleBase::Impl : public BaseObject::Impl::Observer { // Construction Impl() - : mObject( nullptr ) + : mObject(nullptr) { } // Construction - Impl( BaseHandle& handle ) - : mObject( nullptr ) + Impl(BaseHandle& handle) + : mObject(nullptr) { - if( handle ) + if(handle) { - mObject = static_cast( handle.GetObjectPtr() ); - if( mObject ) + mObject = static_cast(handle.GetObjectPtr()); + if(mObject) { - BaseObject::Impl::Get( *mObject ).AddObserver( *this ); + BaseObject::Impl::Get(*mObject).AddObserver(*this); } } } @@ -54,9 +53,9 @@ struct WeakHandleBase::Impl : public BaseObject::Impl::Observer void Reset() { - if( mObject ) + if(mObject) { - BaseObject::Impl::Get( *mObject ).RemoveObserver( *this ); + BaseObject::Impl::Get(*mObject).RemoveObserver(*this); mObject = nullptr; } } @@ -64,7 +63,7 @@ struct WeakHandleBase::Impl : public BaseObject::Impl::Observer /** * From BaseObject::Impl::Observer */ - void ObjectDestroyed( BaseObject& object ) override + void ObjectDestroyed(BaseObject& object) override { mObject = nullptr; } @@ -74,12 +73,12 @@ struct WeakHandleBase::Impl : public BaseObject::Impl::Observer }; WeakHandleBase::WeakHandleBase() -: mImpl( new Impl() ) +: mImpl(new Impl()) { } -WeakHandleBase::WeakHandleBase( BaseHandle& handle ) -: mImpl( new Impl( handle ) ) +WeakHandleBase::WeakHandleBase(BaseHandle& handle) +: mImpl(new Impl(handle)) { } @@ -90,57 +89,57 @@ WeakHandleBase::~WeakHandleBase() } WeakHandleBase::WeakHandleBase(const WeakHandleBase& handle) -: mImpl( nullptr ) +: mImpl(nullptr) { BaseHandle object = handle.GetBaseHandle(); - mImpl = new Impl(object); + mImpl = new Impl(object); } -WeakHandleBase& WeakHandleBase::operator=( const WeakHandleBase& rhs ) +WeakHandleBase& WeakHandleBase::operator=(const WeakHandleBase& rhs) { - if( this != &rhs ) + if(this != &rhs) { delete mImpl; BaseHandle handle = rhs.GetBaseHandle(); - mImpl = new Impl(handle); + mImpl = new Impl(handle); } return *this; } -WeakHandleBase::WeakHandleBase( WeakHandleBase&& rhs ) -: mImpl( rhs.mImpl ) +WeakHandleBase::WeakHandleBase(WeakHandleBase&& rhs) +: mImpl(rhs.mImpl) { rhs.mImpl = nullptr; } -WeakHandleBase& WeakHandleBase::operator=( WeakHandleBase&& rhs ) +WeakHandleBase& WeakHandleBase::operator=(WeakHandleBase&& rhs) { - if (this != &rhs) + if(this != &rhs) { delete mImpl; - mImpl = rhs.mImpl; + mImpl = rhs.mImpl; rhs.mImpl = nullptr; } return *this; } -bool WeakHandleBase::operator==( const WeakHandleBase& rhs ) const +bool WeakHandleBase::operator==(const WeakHandleBase& rhs) const { return this->mImpl->mObject == rhs.mImpl->mObject; } -bool WeakHandleBase::operator!=( const WeakHandleBase& rhs ) const +bool WeakHandleBase::operator!=(const WeakHandleBase& rhs) const { - return !( *this == rhs ); + return !(*this == rhs); } BaseHandle WeakHandleBase::GetBaseHandle() const { - return mImpl ? BaseHandle( mImpl->mObject ) : BaseHandle(); + return mImpl ? BaseHandle(mImpl->mObject) : BaseHandle(); } void WeakHandleBase::Reset() @@ -148,5 +147,4 @@ void WeakHandleBase::Reset() mImpl->Reset(); } - -} // Dali +} // namespace Dali diff --git a/dali/public-api/object/weak-handle.h b/dali/public-api/object/weak-handle.h index d7fb0d0..91a0795 100644 --- a/dali/public-api/object/weak-handle.h +++ b/dali/public-api/object/weak-handle.h @@ -19,8 +19,8 @@ */ // INTERNAL INCLUDES -#include #include +#include namespace Dali { @@ -39,9 +39,7 @@ namespace Dali */ class DALI_CORE_API WeakHandleBase { - public: - /** * @brief Default constructor which provides an uninitialized Dali::WeakHandleBase. * @SINCE_1_2.60 @@ -54,7 +52,7 @@ public: * @SINCE_1_2.60 * @param [in] handle A reference to the handle of the DALi object */ - WeakHandleBase( BaseHandle& handle ); + WeakHandleBase(BaseHandle& handle); /** * @brief Destructor to free resources. @@ -78,7 +76,7 @@ public: * @param [in] rhs A reference to the copied WeakHandleBase * @return A reference to this WeakHandleBase */ - WeakHandleBase& operator=( const WeakHandleBase& rhs ); + WeakHandleBase& operator=(const WeakHandleBase& rhs); /** * @brief Move constructor. @@ -86,7 +84,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs A reference to the moved handle */ - WeakHandleBase( WeakHandleBase&& rhs ); + WeakHandleBase(WeakHandleBase&& rhs); /** * @brief Move assignment operator. @@ -95,7 +93,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this handle */ - WeakHandleBase& operator=( WeakHandleBase&& rhs ); + WeakHandleBase& operator=(WeakHandleBase&& rhs); /** * @brief Equality operator overload. @@ -129,26 +127,22 @@ public: */ void Reset(); - protected: - /// @cond internal struct Impl; Impl* mImpl; /// @endcond }; - /** * @brief Weak handle for the given type of DALi object. * @SINCE_1_2.60 * @see WeakHandleBase */ -template < class T > +template class WeakHandle : public WeakHandleBase { public: - /** * @copydoc Dali::WeakHandleBase::WeakHandleBase() */ @@ -160,28 +154,30 @@ public: /** * @copydoc Dali::WeakHandleBase::WeakHandleBase( BaseHandle& ) */ - WeakHandle( T& handle ) - : WeakHandleBase( handle ) + WeakHandle(T& handle) + : WeakHandleBase(handle) { } /** * @copydoc Dali::WeakHandleBase::~WeakHandleBase() */ - ~WeakHandle() {} + ~WeakHandle() + { + } /** * @copydoc Dali::WeakHandleBase::WeakHandleBase(const WeakHandleBase&) */ WeakHandle(const WeakHandle& handle) - : WeakHandleBase( handle ) + : WeakHandleBase(handle) { } /** * @copydoc Dali::WeakHandleBase::operator=(const WeakHandleBase& rhs) */ - WeakHandle& operator=( const WeakHandle& rhs ) + WeakHandle& operator=(const WeakHandle& rhs) { WeakHandleBase::operator=(rhs); return *this; @@ -190,12 +186,12 @@ public: /** * @copydoc Dali::WeakHandleBase::WeakHandleBase(WeakHandleBase&& rhs) */ - WeakHandle( WeakHandle&& rhs ) = default; + WeakHandle(WeakHandle&& rhs) = default; /** * @copydoc Dali::WeakHandleBase::operator=(WeakHandleBase&& rhs) */ - WeakHandle& operator=( WeakHandle&& rhs ) = default; + WeakHandle& operator=(WeakHandle&& rhs) = default; /** * @copydoc Dali::WeakHandleBase::operator==() @@ -218,10 +214,10 @@ public: */ T GetHandle() const { - BaseHandle handle( WeakHandleBase::GetBaseHandle() ); - if( handle ) + BaseHandle handle(WeakHandleBase::GetBaseHandle()); + if(handle) { - return DownCast< T >( handle ); + return DownCast(handle); } else { diff --git a/dali/public-api/render-tasks/render-task-list.cpp b/dali/public-api/render-tasks/render-task-list.cpp index fa12c98..60bfeda 100644 --- a/dali/public-api/render-tasks/render-task-list.cpp +++ b/dali/public-api/render-tasks/render-task-list.cpp @@ -23,14 +23,13 @@ namespace Dali { - RenderTaskList::RenderTaskList() { } -RenderTaskList RenderTaskList::DownCast( BaseHandle handle ) +RenderTaskList RenderTaskList::DownCast(BaseHandle handle) { - return RenderTaskList( dynamic_cast( handle.GetObjectPtr() ) ); + return RenderTaskList(dynamic_cast(handle.GetObjectPtr())); } RenderTaskList::~RenderTaskList() @@ -41,20 +40,20 @@ RenderTaskList::RenderTaskList(const RenderTaskList& handle) = default; RenderTaskList& RenderTaskList::operator=(const RenderTaskList& rhs) = default; -RenderTaskList::RenderTaskList( RenderTaskList&& rhs ) = default; +RenderTaskList::RenderTaskList(RenderTaskList&& rhs) = default; -RenderTaskList& RenderTaskList::operator=( RenderTaskList&& rhs ) = default; +RenderTaskList& RenderTaskList::operator=(RenderTaskList&& rhs) = default; RenderTask RenderTaskList::CreateTask() { - return RenderTask( GetImplementation(*this).CreateTask().Get() ); + return RenderTask(GetImplementation(*this).CreateTask().Get()); } -void RenderTaskList::RemoveTask( RenderTask task ) +void RenderTaskList::RemoveTask(RenderTask task) { - if( task ) // don't crash if called with empty task handle + if(task) // don't crash if called with empty task handle { - GetImplementation(*this).RemoveTask( GetImplementation( task ) ); + GetImplementation(*this).RemoveTask(GetImplementation(task)); } } @@ -63,15 +62,14 @@ uint32_t RenderTaskList::GetTaskCount() const return GetImplementation(*this).GetTaskCount(); } -RenderTask RenderTaskList::GetTask( uint32_t index ) const +RenderTask RenderTaskList::GetTask(uint32_t index) const { - return RenderTask( GetImplementation(*this).GetTask( index ).Get() ); + return RenderTask(GetImplementation(*this).GetTask(index).Get()); } -RenderTaskList::RenderTaskList( Internal::RenderTaskList* internal ) -: BaseHandle( internal ) +RenderTaskList::RenderTaskList(Internal::RenderTaskList* internal) +: BaseHandle(internal) { } } // namespace Dali - diff --git a/dali/public-api/render-tasks/render-task-list.h b/dali/public-api/render-tasks/render-task-list.h index b4a5d04..ad33f96 100644 --- a/dali/public-api/render-tasks/render-task-list.h +++ b/dali/public-api/render-tasks/render-task-list.h @@ -47,7 +47,6 @@ class RenderTaskList; class DALI_CORE_API RenderTaskList : public BaseHandle { public: - /** * @brief Creates an empty RenderTaskList handle. * @@ -66,7 +65,7 @@ public: * @param[in] handle A handle to an object * @return A handle to a RenderTaskList or an uninitialized handle */ - static RenderTaskList DownCast( BaseHandle handle ); + static RenderTaskList DownCast(BaseHandle handle); /** * @brief Destructor. @@ -99,7 +98,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs A reference to the moved handle */ - RenderTaskList( RenderTaskList&& rhs ); + RenderTaskList(RenderTaskList&& rhs); /** * @brief Move assignment operator. @@ -108,7 +107,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this handle */ - RenderTaskList& operator=( RenderTaskList&& rhs ); + RenderTaskList& operator=(RenderTaskList&& rhs); /** * @brief Creates a new RenderTask. @@ -124,7 +123,7 @@ public: * @SINCE_1_0.0 * @param[in] task The render-task to remove. */ - void RemoveTask( RenderTask task ); + void RemoveTask(RenderTask task); /** * @brief Queries the number of render-tasks in the list. @@ -143,10 +142,9 @@ public: * @return A handle to the render-task * @pre index should be in range i.e. less than GetTaskCount(). */ - RenderTask GetTask( uint32_t index ) const; + RenderTask GetTask(uint32_t index) const; public: // Not intended for application developers - /// @cond internal /** * @brief This constructor is used by Dali New() methods. @@ -154,7 +152,7 @@ public: // Not intended for application developers * @SINCE_1_0.0 * @param [in] renderTask A pointer to a newly allocated render-task */ - explicit DALI_INTERNAL RenderTaskList( Internal::RenderTaskList* renderTask ); + explicit DALI_INTERNAL RenderTaskList(Internal::RenderTaskList* renderTask); /// @endcond }; diff --git a/dali/public-api/render-tasks/render-task.cpp b/dali/public-api/render-tasks/render-task.cpp index d0726dc..bba07a4 100644 --- a/dali/public-api/render-tasks/render-task.cpp +++ b/dali/public-api/render-tasks/render-task.cpp @@ -19,21 +19,20 @@ #include // INTERNAL INCLUDES -#include -#include #include #include #include +#include +#include namespace Dali { - -static bool DefaultScreenToFrameBufferFunction( Vector2& coordinates ) +static bool DefaultScreenToFrameBufferFunction(Vector2& coordinates) { return false; } -static bool FullScreenFrameBufferFunction( Vector2& coordinates ) +static bool FullScreenFrameBufferFunction(Vector2& coordinates) { // Don't need to modify frameBufferCoords return true; @@ -44,7 +43,7 @@ RenderTask::ConstScreenToFrameBufferFunction RenderTask::FULLSCREEN_FRAMEBUFFER_ const bool RenderTask::DEFAULT_EXCLUSIVE = false; const bool RenderTask::DEFAULT_INPUT_ENABLED = true; -const Vector4 RenderTask::DEFAULT_CLEAR_COLOR = Vector4( 0.0f, 0.0f, 0.0f, 1.0f ); // cannot use Color::Black because it may or may not be initialized yet +const Vector4 RenderTask::DEFAULT_CLEAR_COLOR = Vector4(0.0f, 0.0f, 0.0f, 1.0f); // cannot use Color::Black because it may or may not be initialized yet const bool RenderTask::DEFAULT_CLEAR_ENABLED = false; const bool RenderTask::DEFAULT_CULL_MODE = true; const uint32_t RenderTask::DEFAULT_REFRESH_RATE = REFRESH_ALWAYS; @@ -53,9 +52,9 @@ RenderTask::RenderTask() { } -RenderTask RenderTask::DownCast( BaseHandle handle ) +RenderTask RenderTask::DownCast(BaseHandle handle) { - return RenderTask( dynamic_cast( handle.GetObjectPtr() ) ); + return RenderTask(dynamic_cast(handle.GetObjectPtr())); } RenderTask::~RenderTask() @@ -66,20 +65,20 @@ RenderTask::RenderTask(const RenderTask& handle) = default; RenderTask& RenderTask::operator=(const RenderTask& rhs) = default; -RenderTask::RenderTask( RenderTask&& rhs ) = default; +RenderTask::RenderTask(RenderTask&& rhs) = default; -RenderTask& RenderTask::operator=( RenderTask&& rhs ) = default; +RenderTask& RenderTask::operator=(RenderTask&& rhs) = default; -void RenderTask::SetSourceActor( Actor actor ) +void RenderTask::SetSourceActor(Actor actor) { // NULL handle is allowed - Internal::Actor* actorImpl( nullptr ); - if ( actor ) + Internal::Actor* actorImpl(nullptr); + if(actor) { - actorImpl = &GetImplementation( actor ); + actorImpl = &GetImplementation(actor); } - GetImplementation(*this).SetSourceActor( actorImpl ); + GetImplementation(*this).SetSourceActor(actorImpl); } Actor RenderTask::GetSourceActor() const @@ -87,9 +86,9 @@ Actor RenderTask::GetSourceActor() const return Dali::Actor(GetImplementation(*this).GetSourceActor()); } -void RenderTask::SetExclusive( bool exclusive ) +void RenderTask::SetExclusive(bool exclusive) { - GetImplementation(*this).SetExclusive( exclusive ); + GetImplementation(*this).SetExclusive(exclusive); } bool RenderTask::IsExclusive() const @@ -97,16 +96,16 @@ bool RenderTask::IsExclusive() const return GetImplementation(*this).IsExclusive(); } -void RenderTask::SetCameraActor( CameraActor cameraActor ) +void RenderTask::SetCameraActor(CameraActor cameraActor) { // NULL handle is allowed - Internal::CameraActor* actorImpl( nullptr ); - if ( cameraActor ) + Internal::CameraActor* actorImpl(nullptr); + if(cameraActor) { - actorImpl = &GetImplementation( cameraActor ); + actorImpl = &GetImplementation(cameraActor); } - GetImplementation(*this).SetCameraActor( actorImpl ); + GetImplementation(*this).SetCameraActor(actorImpl); } CameraActor RenderTask::GetCameraActor() const @@ -114,26 +113,26 @@ CameraActor RenderTask::GetCameraActor() const return Dali::CameraActor(GetImplementation(*this).GetCameraActor()); } -void RenderTask::SetFrameBuffer( FrameBuffer frameBuffer ) +void RenderTask::SetFrameBuffer(FrameBuffer frameBuffer) { - Internal::FrameBuffer* frameBufferPtr( nullptr ); - if( frameBuffer ) + Internal::FrameBuffer* frameBufferPtr(nullptr); + if(frameBuffer) { - frameBufferPtr = &GetImplementation( frameBuffer ); + frameBufferPtr = &GetImplementation(frameBuffer); } - GetImplementation(*this).SetFrameBuffer( frameBufferPtr ); + GetImplementation(*this).SetFrameBuffer(frameBufferPtr); } FrameBuffer RenderTask::GetFrameBuffer() const { - Internal::FrameBuffer* frameBufferPtr( GetImplementation(*this).GetFrameBuffer() ); - return FrameBuffer( frameBufferPtr ); + Internal::FrameBuffer* frameBufferPtr(GetImplementation(*this).GetFrameBuffer()); + return FrameBuffer(frameBufferPtr); } -void RenderTask::SetScreenToFrameBufferFunction( ScreenToFrameBufferFunction conversionFunction ) +void RenderTask::SetScreenToFrameBufferFunction(ScreenToFrameBufferFunction conversionFunction) { - GetImplementation(*this).SetScreenToFrameBufferFunction( conversionFunction ); + GetImplementation(*this).SetScreenToFrameBufferFunction(conversionFunction); } RenderTask::ScreenToFrameBufferFunction RenderTask::GetScreenToFrameBufferFunction() const @@ -141,9 +140,9 @@ RenderTask::ScreenToFrameBufferFunction RenderTask::GetScreenToFrameBufferFuncti return GetImplementation(*this).GetScreenToFrameBufferFunction(); } -void RenderTask::SetScreenToFrameBufferMappingActor( Dali::Actor mappingActor ) +void RenderTask::SetScreenToFrameBufferMappingActor(Dali::Actor mappingActor) { - GetImplementation(*this).SetScreenToFrameBufferMappingActor( mappingActor ); + GetImplementation(*this).SetScreenToFrameBufferMappingActor(mappingActor); } Dali::Actor RenderTask::GetScreenToFrameBufferMappingActor() const @@ -151,9 +150,9 @@ Dali::Actor RenderTask::GetScreenToFrameBufferMappingActor() const return GetImplementation(*this).GetScreenToFrameBufferMappingActor(); } -void RenderTask::SetViewportPosition( Vector2 position ) +void RenderTask::SetViewportPosition(Vector2 position) { - GetImplementation(*this).SetViewportPosition( position ); + GetImplementation(*this).SetViewportPosition(position); } Vector2 RenderTask::GetCurrentViewportPosition() const @@ -161,9 +160,9 @@ Vector2 RenderTask::GetCurrentViewportPosition() const return GetImplementation(*this).GetCurrentViewportPosition(); } -void RenderTask::SetViewportSize( Vector2 size ) +void RenderTask::SetViewportSize(Vector2 size) { - GetImplementation(*this).SetViewportSize( size ); + GetImplementation(*this).SetViewportSize(size); } Vector2 RenderTask::GetCurrentViewportSize() const @@ -171,21 +170,21 @@ Vector2 RenderTask::GetCurrentViewportSize() const return GetImplementation(*this).GetCurrentViewportSize(); } -void RenderTask::SetViewport( Viewport viewport ) +void RenderTask::SetViewport(Viewport viewport) { - GetImplementation(*this).SetViewport( viewport ); + GetImplementation(*this).SetViewport(viewport); } Viewport RenderTask::GetViewport() const { Viewport result; - GetImplementation(*this).GetViewport( result ); + GetImplementation(*this).GetViewport(result); return result; } -void RenderTask::SetClearColor( const Vector4& color ) +void RenderTask::SetClearColor(const Vector4& color) { - GetImplementation(*this).SetClearColor( color ); + GetImplementation(*this).SetClearColor(color); } Vector4 RenderTask::GetClearColor() const @@ -193,9 +192,9 @@ Vector4 RenderTask::GetClearColor() const return GetImplementation(*this).GetClearColor(); } -void RenderTask::SetClearEnabled( bool enabled ) +void RenderTask::SetClearEnabled(bool enabled) { - GetImplementation(*this).SetClearEnabled( enabled ); + GetImplementation(*this).SetClearEnabled(enabled); } bool RenderTask::GetClearEnabled() const @@ -203,9 +202,9 @@ bool RenderTask::GetClearEnabled() const return GetImplementation(*this).GetClearEnabled(); } -void RenderTask::SetCullMode( bool mode ) +void RenderTask::SetCullMode(bool mode) { - GetImplementation(*this).SetCullMode( mode ); + GetImplementation(*this).SetCullMode(mode); } bool RenderTask::GetCullMode() const @@ -213,9 +212,9 @@ bool RenderTask::GetCullMode() const return GetImplementation(*this).GetCullMode(); } -void RenderTask::SetRefreshRate( uint32_t refreshRate ) +void RenderTask::SetRefreshRate(uint32_t refreshRate) { - GetImplementation(*this).SetRefreshRate( refreshRate ); + GetImplementation(*this).SetRefreshRate(refreshRate); } uint32_t RenderTask::GetRefreshRate() const @@ -228,9 +227,9 @@ RenderTask::RenderTaskSignalType& RenderTask::FinishedSignal() return GetImplementation(*this).FinishedSignal(); } -void RenderTask::SetInputEnabled( bool enabled ) +void RenderTask::SetInputEnabled(bool enabled) { - GetImplementation(*this).SetInputEnabled( enabled ); + GetImplementation(*this).SetInputEnabled(enabled); } bool RenderTask::GetInputEnabled() const @@ -238,17 +237,17 @@ bool RenderTask::GetInputEnabled() const return GetImplementation(*this).GetInputEnabled(); } -bool RenderTask::WorldToViewport(const Vector3 &position, float& viewportX, float& viewportY) const +bool RenderTask::WorldToViewport(const Vector3& position, float& viewportX, float& viewportY) const { return GetImplementation(*this).WorldToViewport(position, viewportX, viewportY); } -bool RenderTask::ViewportToLocal(Actor actor, float viewportX, float viewportY, float &localX, float &localY) const +bool RenderTask::ViewportToLocal(Actor actor, float viewportX, float viewportY, float& localX, float& localY) const { - if( actor ) + if(actor) { - Internal::Actor* actorImpl( &GetImplementation( actor ) ); - return GetImplementation(*this).ViewportToLocal( actorImpl, viewportX, viewportY, localX, localY ); + Internal::Actor* actorImpl(&GetImplementation(actor)); + return GetImplementation(*this).ViewportToLocal(actorImpl, viewportX, viewportY, localX, localY); } else { @@ -256,8 +255,7 @@ bool RenderTask::ViewportToLocal(Actor actor, float viewportX, float viewportY, } } - -RenderTask::RenderTask( Internal::RenderTask* internal ) +RenderTask::RenderTask(Internal::RenderTask* internal) : Handle(internal) { } diff --git a/dali/public-api/render-tasks/render-task.h b/dali/public-api/render-tasks/render-task.h index fa4d9da..9e95672 100644 --- a/dali/public-api/render-tasks/render-task.h +++ b/dali/public-api/render-tasks/render-task.h @@ -87,7 +87,6 @@ class RenderTask; class DALI_CORE_API RenderTask : public Handle { public: - /** * @brief Enumeration for instances of properties belonging to the RenderTask class. * @SINCE_1_0.0 @@ -131,7 +130,7 @@ public: * @brief Typedef for signals sent by this class. * @SINCE_1_0.0 */ - using RenderTaskSignalType = Signal; + using RenderTaskSignalType = Signal; /** * @brief A pointer to a function for converting screen to frame-buffer coordinates. @@ -139,7 +138,7 @@ public: * @param[in,out] coordinates The screen coordinates to convert where (0,0) is the top-left of the screen * @return True if the conversion was successful, otherwise coordinates should be unmodified */ - using ScreenToFrameBufferFunction = bool ( * )( Vector2& ); + using ScreenToFrameBufferFunction = bool (*)(Vector2&); /** * @brief A pointer to a function for converting screen to frame-buffer coordinates. @@ -147,7 +146,7 @@ public: * @param[in,out] coordinates The screen coordinates to convert where (0,0) is the top-left of the screen * @return True if the conversion was successful, otherwise coordinates should be unmodified */ - using ConstScreenToFrameBufferFunction = bool ( *const )( Vector2& ); + using ConstScreenToFrameBufferFunction = bool (*const)(Vector2&); /** * @brief The default conversion function returns false for any screen coordinates. @@ -198,7 +197,7 @@ public: * @param[in] handle A handle to an object * @return A handle to a RenderTask or an uninitialized handle */ - static RenderTask DownCast( BaseHandle handle ); + static RenderTask DownCast(BaseHandle handle); /** * @brief Destructor. @@ -231,7 +230,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs A reference to the moved handle */ - RenderTask( RenderTask&& rhs ); + RenderTask(RenderTask&& rhs); /** * @brief Move assignment operator. @@ -240,7 +239,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this */ - RenderTask& operator=( RenderTask&& rhs ); + RenderTask& operator=(RenderTask&& rhs); /** * @brief Sets the actors to be rendered. @@ -248,7 +247,7 @@ public: * @param[in] actor This actor and its children will be rendered. * If actor is an empty handle, then nothing will be rendered */ - void SetSourceActor( Actor actor ); + void SetSourceActor(Actor actor); /** * @brief Retrieves the actors to be rendered. @@ -262,7 +261,7 @@ public: * @SINCE_1_0.0 * @param[in] exclusive True if the source actors will only be rendered by this render-task */ - void SetExclusive( bool exclusive ); + void SetExclusive(bool exclusive); /** * @brief Queries whether the RenderTask has exclusive access to the source actors. @@ -281,7 +280,7 @@ public: * @SINCE_1_0.0 * @param[in] enabled True if the render-task should be considered for input handling */ - void SetInputEnabled( bool enabled ); + void SetInputEnabled(bool enabled); /** * @brief Queries whether the render-task should be considered for input handling. @@ -295,7 +294,7 @@ public: * @SINCE_1_0.0 * @param[in] cameraActor The scene is viewed from the perspective of this actor */ - void SetCameraActor( CameraActor cameraActor ); + void SetCameraActor(CameraActor cameraActor); /** * @brief Retrieves the actor from which the scene is viewed. @@ -309,7 +308,7 @@ public: * @SINCE_1_1.38 * @param[in] frameBuffer A valid FrameBuffer handle to enable off-screen rendering, or an uninitialized handle to disable it */ - void SetFrameBuffer( FrameBuffer frameBuffer ); + void SetFrameBuffer(FrameBuffer frameBuffer); /** * @brief Retrieves the frame-buffer used as a render target. @@ -325,7 +324,7 @@ public: * @SINCE_1_0.0 * @param[in] conversionFunction The conversion function */ - void SetScreenToFrameBufferFunction( ScreenToFrameBufferFunction conversionFunction ); + void SetScreenToFrameBufferFunction(ScreenToFrameBufferFunction conversionFunction); /** * @brief Retrieves the function used to convert screen coordinates to frame-buffer coordinates. @@ -343,7 +342,7 @@ public: * @param[in] mappingActor The actor used for conversion * @note The mapping actor needs to be rendered by the default render task to make the mapping work properly. */ - void SetScreenToFrameBufferMappingActor( Actor mappingActor ); + void SetScreenToFrameBufferMappingActor(Actor mappingActor); /** * @brief Retrieves the actor used to convert screen coordinates to frame-buffer coordinates. @@ -361,7 +360,7 @@ public: * @param[in] position The viewports position (x,y) * @note Unlike the glViewport method, the x & y coordinates refer to the top-left of the viewport rectangle. */ - void SetViewportPosition( Vector2 position ); + void SetViewportPosition(Vector2 position); /** * @brief Retrieves the GL viewport position used when rendering. @@ -378,7 +377,7 @@ public: * @SINCE_1_0.0 * @param[in] size The viewports size (width,height) */ - void SetViewportSize( Vector2 size ); + void SetViewportSize(Vector2 size); /** * @brief Retrieves the GL viewport size used when rendering. @@ -396,7 +395,7 @@ public: * @param[in] viewport The new viewport * @note Unlike the glViewport method, the x & y coordinates refer to the top-left of the viewport rectangle. */ - void SetViewport( Viewport viewport ); + void SetViewport(Viewport viewport); /** * @brief Retrieves the GL viewport used when rendering. @@ -410,7 +409,7 @@ public: * @SINCE_1_0.0 * @param[in] color The new clear color */ - void SetClearColor( const Vector4& color ); + void SetClearColor(const Vector4& color); /** * @brief Retrieves the clear color used when SetClearEnabled(true) is used. @@ -433,7 +432,7 @@ public: * be (partially) cleared before rendering the second. * */ - void SetClearEnabled( bool enabled ); + void SetClearEnabled(bool enabled); /** * @brief Queries whether the render-task will clear the results of previous render-tasks. @@ -451,7 +450,7 @@ public: * @note If the shader uses @ref Shader::Hint::MODIFIES_GEOMETRY then culling optimizations are disabled. * @see Shader::Hint */ - void SetCullMode( bool cullMode ); + void SetCullMode(bool cullMode); /** * @brief Gets the cull mode. @@ -479,7 +478,7 @@ public: * @SINCE_1_0.0 * @param[in] refreshRate The new refresh rate */ - void SetRefreshRate( uint32_t refreshRate ); + void SetRefreshRate(uint32_t refreshRate); /** * @brief Queries the refresh-rate of the RenderTask. @@ -497,7 +496,7 @@ public: * @param[out] viewportY The viewport y position * @return true if the position has a screen coordinate */ - bool WorldToViewport(const Vector3 &position, float& viewportX, float& viewportY) const; + bool WorldToViewport(const Vector3& position, float& viewportX, float& viewportY) const; /** * @brief Gets actor local coordinates for given viewport coordinates. @@ -510,10 +509,9 @@ public: * @param[out] localY The local y position * @return true if the screen position has a local coordinate */ - bool ViewportToLocal(Actor actor, float viewportX, float viewportY, float &localX, float &localY) const; + bool ViewportToLocal(Actor actor, float viewportX, float viewportY, float& localX, float& localY) const; public: // Signals - /** * @brief If the refresh rate is REFRESH_ONCE, connect to this signal to be notified when a RenderTask has finished. * @SINCE_1_0.0 @@ -522,14 +520,13 @@ public: // Signals RenderTaskSignalType& FinishedSignal(); public: // Not intended for application developers - /// @cond internal /** * @brief This constructor is used by Dali New() methods. * @SINCE_1_0.0 * @param[in] renderTask A pointer to a newly allocated render-task */ - explicit DALI_INTERNAL RenderTask( Internal::RenderTask* renderTask ); + explicit DALI_INTERNAL RenderTask(Internal::RenderTask* renderTask); /// @endcond }; diff --git a/dali/public-api/rendering/frame-buffer.cpp b/dali/public-api/rendering/frame-buffer.cpp index 31ef8db..8fc7aeb 100644 --- a/dali/public-api/rendering/frame-buffer.cpp +++ b/dali/public-api/rendering/frame-buffer.cpp @@ -22,39 +22,38 @@ #include // INTERNAL INCLUDES -#include // DALI_LOG_WARNING_NOFN +#include // DALI_LOG_WARNING_NOFN #include // Dali::Internal::FrameBuffer -#include // Dali::Internal::Texture +#include // Dali::Internal::Texture namespace Dali { - namespace { /// Bool operator for FrameBuffer::Attachment::Mask. /// in cpp as only used in this file -bool operator&( FrameBuffer::Attachment::Mask lhs, FrameBuffer::Attachment::Mask rhs ) +bool operator&(FrameBuffer::Attachment::Mask lhs, FrameBuffer::Attachment::Mask rhs) { - using UnderlyingType = typename std::underlying_type< FrameBuffer::Attachment::Mask >::type; - return static_cast( static_cast( lhs ) & static_cast( rhs ) ); + using UnderlyingType = typename std::underlying_type::type; + return static_cast(static_cast(lhs) & static_cast(rhs)); } } // unnamed namespace -FrameBuffer FrameBuffer::New( uint32_t width, uint32_t height ) +FrameBuffer FrameBuffer::New(uint32_t width, uint32_t height) { - return New( width, height, FrameBuffer::Attachment::COLOR ); + return New(width, height, FrameBuffer::Attachment::COLOR); } -FrameBuffer FrameBuffer::New( uint32_t width, uint32_t height, Attachment::Mask attachments ) +FrameBuffer FrameBuffer::New(uint32_t width, uint32_t height, Attachment::Mask attachments) { - Internal::FrameBufferPtr frameBuffer = Internal::FrameBuffer::New( width, height, attachments ); - if( attachments & FrameBuffer::Attachment::COLOR ) + Internal::FrameBufferPtr frameBuffer = Internal::FrameBuffer::New(width, height, attachments); + if(attachments & FrameBuffer::Attachment::COLOR) { - Internal::TexturePtr texture = Internal::Texture::New( Dali::TextureType::TEXTURE_2D, Pixel::RGB888, width, height ); - frameBuffer->AttachColorTexture( texture, 0u, 0u ); + Internal::TexturePtr texture = Internal::Texture::New(Dali::TextureType::TEXTURE_2D, Pixel::RGB888, width, height); + frameBuffer->AttachColorTexture(texture, 0u, 0u); } - return FrameBuffer( frameBuffer.Get() ); + return FrameBuffer(frameBuffer.Get()); } FrameBuffer::FrameBuffer() @@ -65,42 +64,42 @@ FrameBuffer::~FrameBuffer() { } -FrameBuffer::FrameBuffer( const FrameBuffer& handle ) = default; +FrameBuffer::FrameBuffer(const FrameBuffer& handle) = default; -FrameBuffer FrameBuffer::DownCast( BaseHandle handle ) +FrameBuffer FrameBuffer::DownCast(BaseHandle handle) { - return FrameBuffer( dynamic_cast(handle.GetObjectPtr())); + return FrameBuffer(dynamic_cast(handle.GetObjectPtr())); } -FrameBuffer& FrameBuffer::operator=( const FrameBuffer& handle ) = default; +FrameBuffer& FrameBuffer::operator=(const FrameBuffer& handle) = default; -FrameBuffer::FrameBuffer( Internal::FrameBuffer* pointer ) -: BaseHandle( pointer ) +FrameBuffer::FrameBuffer(Internal::FrameBuffer* pointer) +: BaseHandle(pointer) { } -FrameBuffer::FrameBuffer( FrameBuffer&& rhs ) = default; +FrameBuffer::FrameBuffer(FrameBuffer&& rhs) = default; -FrameBuffer& FrameBuffer::operator=( FrameBuffer&& rhs ) = default; +FrameBuffer& FrameBuffer::operator=(FrameBuffer&& rhs) = default; -void FrameBuffer::AttachColorTexture( Texture& texture ) +void FrameBuffer::AttachColorTexture(Texture& texture) { - AttachColorTexture( texture, 0u, 0u ); + AttachColorTexture(texture, 0u, 0u); } -void FrameBuffer::AttachColorTexture( Texture& texture, uint32_t mipmapLevel, uint32_t layer ) +void FrameBuffer::AttachColorTexture(Texture& texture, uint32_t mipmapLevel, uint32_t layer) { - if( texture ) + if(texture) { - Internal::TexturePtr texturePtr( &GetImplementation( texture ) ); - GetImplementation(*this).AttachColorTexture( texturePtr, mipmapLevel, layer ); + Internal::TexturePtr texturePtr(&GetImplementation(texture)); + GetImplementation(*this).AttachColorTexture(texturePtr, mipmapLevel, layer); } } Texture FrameBuffer::GetColorTexture() { Internal::Texture* texturePtr = GetImplementation(*this).GetColorTexture(0); - return Dali::Texture( texturePtr ); + return Dali::Texture(texturePtr); } } //namespace Dali diff --git a/dali/public-api/rendering/frame-buffer.h b/dali/public-api/rendering/frame-buffer.h index 6c1ced7..9954182 100644 --- a/dali/public-api/rendering/frame-buffer.h +++ b/dali/public-api/rendering/frame-buffer.h @@ -44,7 +44,6 @@ class FrameBuffer; class DALI_CORE_API FrameBuffer : public BaseHandle { public: - /** * @brief The initial attachments to create the FrameBuffer with. * @note The color attachment can also be created on calling AttachColorTexture(). @@ -60,13 +59,13 @@ public: */ enum Mask { - NONE = 0, ///< No attachments are created initially. @SINCE_1_1.45 - DEPTH = 1 << 0, ///< Depth buffer is created. @SINCE_1_1.45 - STENCIL = 1 << 1, ///< Stencil buffer is created. @SINCE_1_1.45 - DEPTH_STENCIL = DEPTH | STENCIL, ///< Depth and stencil buffer are created. @SINCE_1_1.45 - COLOR = 1 << 2, ///< Color texture is created. @SINCE_1_4.0 - COLOR_DEPTH = COLOR | DEPTH, ///< Color texture and depth buffer are created. @SINCE_1_4.0 - COLOR_STENCIL = COLOR | STENCIL, ///< Color texture and stencil buffer are created. @SINCE_1_4.0 + NONE = 0, ///< No attachments are created initially. @SINCE_1_1.45 + DEPTH = 1 << 0, ///< Depth buffer is created. @SINCE_1_1.45 + STENCIL = 1 << 1, ///< Stencil buffer is created. @SINCE_1_1.45 + DEPTH_STENCIL = DEPTH | STENCIL, ///< Depth and stencil buffer are created. @SINCE_1_1.45 + COLOR = 1 << 2, ///< Color texture is created. @SINCE_1_4.0 + COLOR_DEPTH = COLOR | DEPTH, ///< Color texture and depth buffer are created. @SINCE_1_4.0 + COLOR_STENCIL = COLOR | STENCIL, ///< Color texture and stencil buffer are created. @SINCE_1_4.0 COLOR_DEPTH_STENCIL = COLOR_DEPTH | STENCIL ///< Color, depth and stencil buffer are created. @SINCE_1_4.0 }; }; @@ -82,7 +81,7 @@ public: * @param[in] height The height of the FrameBuffer and the color texture * @return A handle to a newly allocated FrameBuffer */ - static FrameBuffer New( uint32_t width, uint32_t height ); + static FrameBuffer New(uint32_t width, uint32_t height); /** * @brief Creates a new FrameBuffer with specific attachments. @@ -94,7 +93,7 @@ public: * @param[in] attachments Enumeration of the attachments to create * @return A handle to a newly allocated FrameBuffer */ - static FrameBuffer New( uint32_t width, uint32_t height, Attachment::Mask attachments ); + static FrameBuffer New(uint32_t width, uint32_t height, Attachment::Mask attachments); /** * @brief Default constructor, creates an empty handle. @@ -113,7 +112,7 @@ public: * @SINCE_1_1.43 * @param[in] handle Handle to an object */ - FrameBuffer( const FrameBuffer& handle ); + FrameBuffer(const FrameBuffer& handle); /** * @brief Downcasts to a FrameBuffer. @@ -122,7 +121,7 @@ public: * @param[in] handle Handle to an object * @return FrameBuffer handle or an uninitialized handle */ - static FrameBuffer DownCast( BaseHandle handle ); + static FrameBuffer DownCast(BaseHandle handle); /** * @brief Assignment operator, changes this handle to point at the same object. @@ -131,7 +130,7 @@ public: * @param[in] handle Handle to an object * @return Reference to the assigned object */ - FrameBuffer& operator=( const FrameBuffer& handle ); + FrameBuffer& operator=(const FrameBuffer& handle); /** * @brief Move constructor. @@ -139,7 +138,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs A reference to the moved handle */ - FrameBuffer( FrameBuffer&& rhs ); + FrameBuffer(FrameBuffer&& rhs); /** * @brief Move assignment operator. @@ -148,7 +147,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this handle */ - FrameBuffer& operator=( FrameBuffer&& rhs ); + FrameBuffer& operator=(FrameBuffer&& rhs); /** * @brief Attach the base LOD of a 2D texture to the framebuffer for color rendering. @@ -161,7 +160,7 @@ public: * @note The texture has to have same size as that of FrameBuffer * otherwise it won't be attached. */ - void AttachColorTexture( Texture& texture ); + void AttachColorTexture(Texture& texture); /** * @brief Attach a texture to the framebuffer for color rendering. @@ -176,7 +175,7 @@ public: * @note The mipmapped texture has to have same size as that of FrameBuffer * otherwise it won't be attached. */ - void AttachColorTexture( Texture& texture, uint32_t mipmapLevel, uint32_t layer ); + void AttachColorTexture(Texture& texture, uint32_t mipmapLevel, uint32_t layer); /** * @brief Gets the first color texture used as output in the FrameBuffer. @@ -187,14 +186,13 @@ public: Texture GetColorTexture(); public: - /** * @brief The constructor. * @note Not intended for application developers. * @SINCE_1_1.43 * @param[in] pointer A pointer to a newly allocated FrameBuffer */ - explicit DALI_INTERNAL FrameBuffer( Internal::FrameBuffer* pointer ); + explicit DALI_INTERNAL FrameBuffer(Internal::FrameBuffer* pointer); }; /** diff --git a/dali/public-api/rendering/geometry.cpp b/dali/public-api/rendering/geometry.cpp index 58b54be..09e9303 100644 --- a/dali/public-api/rendering/geometry.cpp +++ b/dali/public-api/rendering/geometry.cpp @@ -16,18 +16,17 @@ */ // CLASS HEADER -#include // Dali::Geometry +#include // Dali::Geometry // INTERNAL INCLUDES #include // Dali::Internal::Geometry namespace Dali { - Geometry Geometry::New() { Internal::GeometryPtr geometry = Internal::Geometry::New(); - return Geometry( geometry.Get() ); + return Geometry(geometry.Get()); } Geometry::Geometry() @@ -38,23 +37,23 @@ Geometry::~Geometry() { } -Geometry::Geometry( const Geometry& handle ) = default; +Geometry::Geometry(const Geometry& handle) = default; -Geometry Geometry::DownCast( BaseHandle handle ) +Geometry Geometry::DownCast(BaseHandle handle) { - return Geometry( dynamic_cast(handle.GetObjectPtr())); + return Geometry(dynamic_cast(handle.GetObjectPtr())); } -Geometry& Geometry::operator=( const Geometry& handle ) = default; +Geometry& Geometry::operator=(const Geometry& handle) = default; -Geometry::Geometry( Geometry&& rhs ) = default; +Geometry::Geometry(Geometry&& rhs) = default; -Geometry& Geometry::operator=( Geometry&& rhs ) = default; +Geometry& Geometry::operator=(Geometry&& rhs) = default; -std::size_t Geometry::AddVertexBuffer( VertexBuffer& vertexBuffer ) +std::size_t Geometry::AddVertexBuffer(VertexBuffer& vertexBuffer) { - DALI_ASSERT_ALWAYS( vertexBuffer && "VertexBuffer is not initialized "); - return GetImplementation(*this).AddVertexBuffer( GetImplementation( vertexBuffer ) ); + DALI_ASSERT_ALWAYS(vertexBuffer && "VertexBuffer is not initialized "); + return GetImplementation(*this).AddVertexBuffer(GetImplementation(vertexBuffer)); } std::size_t Geometry::GetNumberOfVertexBuffers() const @@ -62,19 +61,19 @@ std::size_t Geometry::GetNumberOfVertexBuffers() const return GetImplementation(*this).GetNumberOfVertexBuffers(); } -void Geometry::RemoveVertexBuffer( std::size_t index ) +void Geometry::RemoveVertexBuffer(std::size_t index) { - GetImplementation(*this).RemoveVertexBuffer( static_cast( index ) ); + GetImplementation(*this).RemoveVertexBuffer(static_cast(index)); } -void Geometry::SetIndexBuffer( const uint16_t* indices, size_t count ) +void Geometry::SetIndexBuffer(const uint16_t* indices, size_t count) { - GetImplementation(*this).SetIndexBuffer( indices, static_cast( count ) ); + GetImplementation(*this).SetIndexBuffer(indices, static_cast(count)); } -void Geometry::SetType( Type geometryType ) +void Geometry::SetType(Type geometryType) { - GetImplementation(*this).SetType( geometryType ); + GetImplementation(*this).SetType(geometryType); } Geometry::Type Geometry::GetType() const @@ -82,8 +81,8 @@ Geometry::Type Geometry::GetType() const return GetImplementation(*this).GetType(); } -Geometry::Geometry( Internal::Geometry* pointer ) -: BaseHandle( pointer ) +Geometry::Geometry(Internal::Geometry* pointer) +: BaseHandle(pointer) { } diff --git a/dali/public-api/rendering/geometry.h b/dali/public-api/rendering/geometry.h index 56cb874..cfb0f15 100644 --- a/dali/public-api/rendering/geometry.h +++ b/dali/public-api/rendering/geometry.h @@ -23,9 +23,9 @@ #include // uint16_t // INTERNAL INCLUDES -#include // Dali::Handle +#include // Dali::Handle #include // DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX -#include // Dali::VertexBuffer +#include // Dali::VertexBuffer namespace Dali { @@ -47,7 +47,6 @@ class Geometry; class DALI_CORE_API Geometry : public BaseHandle { public: - /** * @brief Enumeration for the description of the type of geometry, used to determine how the coordinates will be used. * @SINCE_1_1.45 @@ -63,7 +62,6 @@ public: TRIANGLE_STRIP ///< A strip of triangles (after the first triangle, following triangles need only 1 point) @SINCE_1_1.45 }; - /** * @brief Creates a new Geometry object. * @@ -92,7 +90,7 @@ public: * @SINCE_1_1.43 * @param[in] handle Handle to an object */ - Geometry( const Geometry& handle ); + Geometry(const Geometry& handle); /** * @brief Downcasts to a geometry. @@ -102,7 +100,7 @@ public: * @param[in] handle Handle to an object * @return Geometry handle or an uninitialized handle */ - static Geometry DownCast( BaseHandle handle ); + static Geometry DownCast(BaseHandle handle); /** * @brief Assignment operator, changes this handle to point at the same object. @@ -111,7 +109,7 @@ public: * @param[in] handle Handle to an object * @return Reference to the assigned object */ - Geometry& operator=( const Geometry& handle ); + Geometry& operator=(const Geometry& handle); /** * @brief Move constructor. @@ -119,7 +117,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs A reference to the moved handle */ - Geometry( Geometry&& rhs ); + Geometry(Geometry&& rhs); /** * @brief Move assignment operator. @@ -128,7 +126,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this handle */ - Geometry& operator=( Geometry&& rhs ); + Geometry& operator=(Geometry&& rhs); /** * @brief Adds a VertexBuffer to be used as source of geometry vertices. @@ -138,7 +136,7 @@ public: * @return Index of the newly added buffer, can be used with RemoveVertexBuffer to remove * this buffer if no longer required */ - std::size_t AddVertexBuffer( VertexBuffer& vertexBuffer ); + std::size_t AddVertexBuffer(VertexBuffer& vertexBuffer); /** * @brief Retrieves the number of vertex buffers that have been added to this geometry. @@ -155,7 +153,7 @@ public: * @SINCE_1_9.27 * @param[in] index Index to the vertex buffer to remove */ - void RemoveVertexBuffer( std::size_t index ); + void RemoveVertexBuffer(std::size_t index); /** * @brief Sets a the index data to be used as a source of indices for the geometry @@ -166,7 +164,7 @@ public: * @param[in] indices Array of indices * @param[in] count Number of indices in the array */ - void SetIndexBuffer( const uint16_t* indices, size_t count ); + void SetIndexBuffer(const uint16_t* indices, size_t count); /** * @brief Sets the type of primitives this geometry contains. @@ -174,7 +172,7 @@ public: * @SINCE_1_1.43 * @param[in] geometryType Type of primitives this geometry contains */ - void SetType( Type geometryType ); + void SetType(Type geometryType); /** * @brief Gets the type of primitives this geometry contains. @@ -186,14 +184,13 @@ public: Type GetType() const; public: - /** * @brief The constructor. * @note Not intended for application developers. * @SINCE_1_1.43 * @param[in] pointer A pointer to a newly allocated Geometry */ - explicit DALI_INTERNAL Geometry( Internal::Geometry* pointer ); + explicit DALI_INTERNAL Geometry(Internal::Geometry* pointer); }; /** diff --git a/dali/public-api/rendering/renderer.cpp b/dali/public-api/rendering/renderer.cpp index 0d89476..be49c1b 100644 --- a/dali/public-api/rendering/renderer.cpp +++ b/dali/public-api/rendering/renderer.cpp @@ -16,20 +16,19 @@ */ // CLASS HEADER -#include // Dali::Renderer +#include // Dali::Renderer // INTERNAL INCLUDES #include // Dali::Internal::Renderer namespace Dali { - -Renderer Renderer::New( Geometry& geometry, Shader& shader ) +Renderer Renderer::New(Geometry& geometry, Shader& shader) { - Internal::RendererPtr renderer = Internal::Renderer::New( ); - renderer->SetGeometry( GetImplementation(geometry) ); - renderer->SetShader( GetImplementation(shader) ); - return Renderer( renderer.Get() ); + Internal::RendererPtr renderer = Internal::Renderer::New(); + renderer->SetGeometry(GetImplementation(geometry)); + renderer->SetShader(GetImplementation(shader)); + return Renderer(renderer.Get()); } Renderer::Renderer() @@ -40,54 +39,54 @@ Renderer::~Renderer() { } -Renderer::Renderer( const Renderer& handle ) = default; +Renderer::Renderer(const Renderer& handle) = default; -Renderer Renderer::DownCast( BaseHandle handle ) +Renderer Renderer::DownCast(BaseHandle handle) { - return Renderer( dynamic_cast(handle.GetObjectPtr())); + return Renderer(dynamic_cast(handle.GetObjectPtr())); } -Renderer& Renderer::operator=( const Renderer& handle ) = default; +Renderer& Renderer::operator=(const Renderer& handle) = default; -Renderer::Renderer( Renderer&& rhs ) = default; +Renderer::Renderer(Renderer&& rhs) = default; -Renderer& Renderer::operator=( Renderer&& rhs ) = default; +Renderer& Renderer::operator=(Renderer&& rhs) = default; -void Renderer::SetGeometry( Geometry& geometry ) +void Renderer::SetGeometry(Geometry& geometry) { - DALI_ASSERT_ALWAYS( geometry && "Geometry handle not initialized" ); - GetImplementation(*this).SetGeometry( GetImplementation(geometry) ); + DALI_ASSERT_ALWAYS(geometry && "Geometry handle not initialized"); + GetImplementation(*this).SetGeometry(GetImplementation(geometry)); } Geometry Renderer::GetGeometry() const { - return Dali::Geometry( GetImplementation(*this).GetGeometry().Get() ); + return Dali::Geometry(GetImplementation(*this).GetGeometry().Get()); } -void Renderer::SetTextures( TextureSet& textureSet ) +void Renderer::SetTextures(TextureSet& textureSet) { - DALI_ASSERT_ALWAYS( textureSet && "TextureSet handle not initialized" ); - GetImplementation(*this).SetTextures( GetImplementation(textureSet) ); + DALI_ASSERT_ALWAYS(textureSet && "TextureSet handle not initialized"); + GetImplementation(*this).SetTextures(GetImplementation(textureSet)); } TextureSet Renderer::GetTextures() const { - return Dali::TextureSet( GetImplementation(*this).GetTextures().Get() ); + return Dali::TextureSet(GetImplementation(*this).GetTextures().Get()); } -void Renderer::SetShader( Shader& shader ) +void Renderer::SetShader(Shader& shader) { - DALI_ASSERT_ALWAYS( shader && "Shader handle not initialized" ); - GetImplementation(*this).SetShader( GetImplementation(shader) ); + DALI_ASSERT_ALWAYS(shader && "Shader handle not initialized"); + GetImplementation(*this).SetShader(GetImplementation(shader)); } Shader Renderer::GetShader() const { - return Dali::Shader( GetImplementation(*this).GetShader().Get() ); + return Dali::Shader(GetImplementation(*this).GetShader().Get()); } -Renderer::Renderer( Internal::Renderer* pointer ) -: Handle( pointer ) +Renderer::Renderer(Internal::Renderer* pointer) +: Handle(pointer) { } diff --git a/dali/public-api/rendering/renderer.h b/dali/public-api/rendering/renderer.h index 8ff7f97..6af1b32 100644 --- a/dali/public-api/rendering/renderer.h +++ b/dali/public-api/rendering/renderer.h @@ -38,24 +38,22 @@ class Renderer; namespace FaceCullingMode { - /** * @brief Enumeration for face culling mode. * @SINCE_1_1.43 */ enum Type { - NONE, ///< None of the faces should be culled @SINCE_1_1.43 - FRONT, ///< Cull front face, front faces should never be shown @SINCE_1_1.43 - BACK, ///< Cull back face, back faces should never be shown @SINCE_1_1.43 - FRONT_AND_BACK, ///< Cull front and back faces; if the geometry is composed of triangles none of the faces will be shown @SINCE_1_1.43 + NONE, ///< None of the faces should be culled @SINCE_1_1.43 + FRONT, ///< Cull front face, front faces should never be shown @SINCE_1_1.43 + BACK, ///< Cull back face, back faces should never be shown @SINCE_1_1.43 + FRONT_AND_BACK, ///< Cull front and back faces; if the geometry is composed of triangles none of the faces will be shown @SINCE_1_1.43 }; } // namespace FaceCullingMode namespace BlendMode { - /** * @brief Enumeration for blend mode. * @SINCE_1_1.43 @@ -71,23 +69,21 @@ enum Type namespace BlendEquation { - /** * @brief Enumeration for blend equation. * @SINCE_1_1.43 */ enum Type { - ADD = 0x8006, ///< The source and destination colors are added to each other. @SINCE_1_1.43 - SUBTRACT = 0x800A, ///< Subtracts the destination from the source. @SINCE_1_1.43 - REVERSE_SUBTRACT = 0x800B ///< Subtracts the source from the destination. @SINCE_1_1.43 + ADD = 0x8006, ///< The source and destination colors are added to each other. @SINCE_1_1.43 + SUBTRACT = 0x800A, ///< Subtracts the destination from the source. @SINCE_1_1.43 + REVERSE_SUBTRACT = 0x800B ///< Subtracts the source from the destination. @SINCE_1_1.43 }; } // namespace BlendEquation namespace BlendFactor { - /** * @brief Enumeration for blend factor. * @SINCE_1_1.43 @@ -115,7 +111,6 @@ enum Type namespace DepthWriteMode { - /** * @brief Enumeration for depth buffer write modes. * @SINCE_1_1.43 @@ -131,7 +126,6 @@ enum Type namespace DepthTestMode { - /** * @brief Enumeration for depth buffer test (read) modes. * @SINCE_1_1.43 @@ -147,7 +141,6 @@ enum Type namespace DepthFunction { - /** * @brief Enumeration for depth functions. * @SINCE_1_1.43 @@ -168,7 +161,6 @@ enum Type namespace RenderMode { - /** * @brief Enumeration for the controls of how this renderer uses its stencil properties and writes to the color buffer. * @SINCE_1_2_5 @@ -186,7 +178,6 @@ enum Type namespace StencilFunction { - /** * @brief Enumeration for the comparison function used on the stencil buffer. * @SINCE_1_1.43 @@ -207,7 +198,6 @@ enum Type namespace StencilOperation { - /** * @brief Enumeration for specifying the action to take when the stencil (or depth) test fails during stencil test. * @SINCE_1_1.43 @@ -226,7 +216,6 @@ enum Type } // namespace StencilOperation - /** * @brief Renderer is a handle to an object used to show content by combining a Geometry, a TextureSet and a shader. * @@ -235,7 +224,6 @@ enum Type class DALI_CORE_API Renderer : public Handle { public: - /** * @brief Enumeration for instances of properties belonging to the Renderer class. * @SINCE_1_1.43 @@ -434,7 +422,7 @@ public: * @param[in] shader Shader to be used by this renderer * @return A handle to the Renderer */ - static Renderer New( Geometry& geometry, Shader& shader ); + static Renderer New(Geometry& geometry, Shader& shader); /** * @brief Default constructor, creates an empty handle @@ -456,7 +444,7 @@ public: * @SINCE_1_1.43 * @param[in] handle Handle to an object */ - Renderer( const Renderer& handle ); + Renderer(const Renderer& handle); /** * @brief Downcasts to a renderer handle. @@ -466,7 +454,7 @@ public: * @param[in] handle Handle to an object * @return Renderer handle or an uninitialized handle */ - static Renderer DownCast( BaseHandle handle ); + static Renderer DownCast(BaseHandle handle); /** * @brief Assignment operator, changes this handle to point at the same object. @@ -475,7 +463,7 @@ public: * @param[in] handle Handle to an object * @return Reference to the assigned object */ - Renderer& operator=( const Renderer& handle ); + Renderer& operator=(const Renderer& handle); /** * @brief Move constructor. @@ -483,7 +471,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs A reference to the moved handle */ - Renderer( Renderer&& rhs ); + Renderer(Renderer&& rhs); /** * @brief Move assignment operator. @@ -492,7 +480,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this handle */ - Renderer& operator=( Renderer&& rhs ); + Renderer& operator=(Renderer&& rhs); /** * @brief Sets the geometry to be used by this renderer. @@ -500,7 +488,7 @@ public: * @SINCE_1_1.43 * @param[in] geometry The geometry to be used by this renderer */ - void SetGeometry( Geometry& geometry ); + void SetGeometry(Geometry& geometry); /** * @brief Gets the geometry used by this renderer. @@ -517,10 +505,10 @@ public: * @param[in] firstElement The First element to draw * @param[in] elementsCount The number of elements to draw */ - inline void SetIndexRange( int firstElement, int elementsCount ) + inline void SetIndexRange(int firstElement, int elementsCount) { - SetProperty( Property::INDEX_RANGE_FIRST, firstElement ); - SetProperty( Property::INDEX_RANGE_COUNT, elementsCount ); + SetProperty(Property::INDEX_RANGE_FIRST, firstElement); + SetProperty(Property::INDEX_RANGE_COUNT, elementsCount); } /** @@ -529,7 +517,7 @@ public: * @SINCE_1_1.43 * @param[in] textureSet The texture set to be used by this renderer */ - void SetTextures( TextureSet& textureSet ); + void SetTextures(TextureSet& textureSet); /** * @brief Gets the texture set used by this renderer. @@ -545,7 +533,7 @@ public: * @SINCE_1_1.43 * @param[in] shader The shader to be used by this renderer */ - void SetShader( Shader& shader ); + void SetShader(Shader& shader); /** * @brief Gets the shader used by this renderer. @@ -556,14 +544,13 @@ public: Shader GetShader() const; public: - /** * @brief The constructor. * @note Not intended for application developers. * @SINCE_1_1.43 * @param[in] pointer A pointer to a newly allocated Renderer */ - explicit DALI_INTERNAL Renderer( Internal::Renderer* pointer ); + explicit DALI_INTERNAL Renderer(Internal::Renderer* pointer); }; /** diff --git a/dali/public-api/rendering/sampler.cpp b/dali/public-api/rendering/sampler.cpp index 1b3722a..8dd4eaa 100644 --- a/dali/public-api/rendering/sampler.cpp +++ b/dali/public-api/rendering/sampler.cpp @@ -16,18 +16,17 @@ */ // CLASS HEADER -#include // Dali::Sampler +#include // Dali::Sampler // INTERNAL INCLUDES #include // Dali::Internal::Sampler namespace Dali { - Sampler Sampler::New() { Internal::SamplerPtr sampler = Internal::Sampler::New(); - return Sampler( sampler.Get() ); + return Sampler(sampler.Get()); } Sampler::Sampler() @@ -38,36 +37,36 @@ Sampler::~Sampler() { } -Sampler::Sampler( const Sampler& handle ) = default; +Sampler::Sampler(const Sampler& handle) = default; -Sampler Sampler::DownCast( BaseHandle handle ) +Sampler Sampler::DownCast(BaseHandle handle) { - return Sampler( dynamic_cast(handle.GetObjectPtr())); + return Sampler(dynamic_cast(handle.GetObjectPtr())); } -Sampler& Sampler::operator=( const Sampler& handle ) = default; +Sampler& Sampler::operator=(const Sampler& handle) = default; -Sampler::Sampler( Sampler&& rhs ) = default; +Sampler::Sampler(Sampler&& rhs) = default; -Sampler& Sampler::operator=( Sampler&& rhs ) = default; +Sampler& Sampler::operator=(Sampler&& rhs) = default; -void Sampler::SetFilterMode( FilterMode::Type minFilter, FilterMode::Type magFilter ) +void Sampler::SetFilterMode(FilterMode::Type minFilter, FilterMode::Type magFilter) { - GetImplementation(*this).SetFilterMode( minFilter, magFilter ); + GetImplementation(*this).SetFilterMode(minFilter, magFilter); } -void Sampler::SetWrapMode( WrapMode::Type uWrap, WrapMode::Type vWrap ) +void Sampler::SetWrapMode(WrapMode::Type uWrap, WrapMode::Type vWrap) { - GetImplementation(*this).SetWrapMode( uWrap, uWrap, vWrap ); + GetImplementation(*this).SetWrapMode(uWrap, uWrap, vWrap); } -void Sampler::SetWrapMode( WrapMode::Type rWrap, WrapMode::Type sWrap, WrapMode::Type tWrap ) +void Sampler::SetWrapMode(WrapMode::Type rWrap, WrapMode::Type sWrap, WrapMode::Type tWrap) { - GetImplementation(*this).SetWrapMode( rWrap, sWrap, tWrap ); + GetImplementation(*this).SetWrapMode(rWrap, sWrap, tWrap); } Sampler::Sampler(Internal::Sampler* pointer) -: BaseHandle( pointer ) +: BaseHandle(pointer) { } diff --git a/dali/public-api/rendering/sampler.h b/dali/public-api/rendering/sampler.h index cc44ff0..aeabcf3 100644 --- a/dali/public-api/rendering/sampler.h +++ b/dali/public-api/rendering/sampler.h @@ -19,8 +19,8 @@ */ // INTERNAL INCLUDES -#include // Dali::Handle #include +#include // Dali::Handle namespace Dali { @@ -42,7 +42,6 @@ class Sampler; class DALI_CORE_API Sampler : public BaseHandle { public: - /** * @brief Creates a new Sampler object. * @@ -71,7 +70,7 @@ public: * @SINCE_1_1.43 * @param[in] handle Handle to an object */ - Sampler( const Sampler& handle ); + Sampler(const Sampler& handle); /** * @brief Downcasts to a sampler handle. @@ -81,7 +80,7 @@ public: * @param[in] handle Handle to an object * @return Handle or an uninitialized handle */ - static Sampler DownCast( BaseHandle handle ); + static Sampler DownCast(BaseHandle handle); /** * @brief Assignment operator, changes this handle to point at the same object. @@ -90,8 +89,7 @@ public: * @param[in] handle Handle to an object * @return Reference to the assigned object */ - Sampler& operator=( const Sampler& handle ); - + Sampler& operator=(const Sampler& handle); /** * @brief Move constructor. @@ -99,7 +97,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs A reference to the moved handle */ - Sampler( Sampler&& rhs ); + Sampler(Sampler&& rhs); /** * @brief Move assignment operator. @@ -108,7 +106,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this handle */ - Sampler& operator=( Sampler&& rhs ); + Sampler& operator=(Sampler&& rhs); /** * @brief Sets the filter modes for this sampler. @@ -118,7 +116,7 @@ public: * @param[in] minFilter The minification filter that will be used * @param[in] magFilter The magnification filter that will be used */ - void SetFilterMode( FilterMode::Type minFilter, FilterMode::Type magFilter ); + void SetFilterMode(FilterMode::Type minFilter, FilterMode::Type magFilter); /** * @brief Sets the wrap modes for this sampler. @@ -127,7 +125,7 @@ public: * @param[in] uWrap Wrap mode for u coordinates * @param[in] vWrap Wrap mode for v coordinates */ - void SetWrapMode( WrapMode::Type uWrap, WrapMode::Type vWrap ); + void SetWrapMode(WrapMode::Type uWrap, WrapMode::Type vWrap); /** * @brief Sets the wrap modes for this sampler. @@ -137,17 +135,16 @@ public: * @param[in] sWrap Wrap mode for the x direction * @param[in] tWrap Wrap mode for the y direction */ - void SetWrapMode( WrapMode::Type rWrap, WrapMode::Type sWrap, WrapMode::Type tWrap ); + void SetWrapMode(WrapMode::Type rWrap, WrapMode::Type sWrap, WrapMode::Type tWrap); public: - /** * @brief The constructor. * @note Not intended for application developers. * @SINCE_1_1.43 * @param[in] pointer A pointer to a newly allocated Sampler */ - explicit DALI_INTERNAL Sampler( Internal::Sampler* pointer ); + explicit DALI_INTERNAL Sampler(Internal::Sampler* pointer); }; /** diff --git a/dali/public-api/rendering/shader.cpp b/dali/public-api/rendering/shader.cpp index a6d3ed4..d452ea3 100644 --- a/dali/public-api/rendering/shader.cpp +++ b/dali/public-api/rendering/shader.cpp @@ -16,20 +16,19 @@ */ // CLASS HEADER -#include // Dali::Shader +#include // Dali::Shader // INTERNAL INCLUDES -#include // Dali::Internal::Shader +#include // Dali::Internal::Shader namespace Dali { - -Shader Shader::New( const std::string& vertexShader, - const std::string& fragmentShader, - Hint::Value hints ) +Shader Shader::New(const std::string& vertexShader, + const std::string& fragmentShader, + Hint::Value hints) { - Internal::ShaderPtr renderer = Internal::Shader::New( vertexShader, fragmentShader, hints ); - return Shader( renderer.Get() ); + Internal::ShaderPtr renderer = Internal::Shader::New(vertexShader, fragmentShader, hints); + return Shader(renderer.Get()); } Shader::Shader() @@ -40,21 +39,21 @@ Shader::~Shader() { } -Shader::Shader( const Shader& handle ) = default; +Shader::Shader(const Shader& handle) = default; -Shader Shader::DownCast( BaseHandle handle ) +Shader Shader::DownCast(BaseHandle handle) { - return Shader( dynamic_cast(handle.GetObjectPtr())); + return Shader(dynamic_cast(handle.GetObjectPtr())); } -Shader& Shader::operator=( const Shader& handle ) = default; +Shader& Shader::operator=(const Shader& handle) = default; -Shader::Shader( Shader&& rhs ) = default; +Shader::Shader(Shader&& rhs) = default; -Shader& Shader::operator=( Shader&& rhs ) = default; +Shader& Shader::operator=(Shader&& rhs) = default; -Shader::Shader( Internal::Shader* pointer ) -: Handle( pointer ) +Shader::Shader(Internal::Shader* pointer) +: Handle(pointer) { } diff --git a/dali/public-api/rendering/shader.h b/dali/public-api/rendering/shader.h index 1009a46..2535639 100644 --- a/dali/public-api/rendering/shader.h +++ b/dali/public-api/rendering/shader.h @@ -75,7 +75,6 @@ class Shader; class DALI_CORE_API Shader : public Handle { public: - /** * @brief Hints for rendering. * @SINCE_1_1.45 @@ -88,9 +87,9 @@ public: */ enum Value { - NONE = 0x00, ///< No hints @SINCE_1_1.45 - OUTPUT_IS_TRANSPARENT = 0x01, ///< Might generate transparent alpha from opaque inputs @SINCE_1_1.45 - MODIFIES_GEOMETRY = 0x02, ///< Might change position of vertices, this option disables any culling optimizations @SINCE_1_1.45 + NONE = 0x00, ///< No hints @SINCE_1_1.45 + OUTPUT_IS_TRANSPARENT = 0x01, ///< Might generate transparent alpha from opaque inputs @SINCE_1_1.45 + MODIFIES_GEOMETRY = 0x02, ///< Might change position of vertices, this option disables any culling optimizations @SINCE_1_1.45 }; }; @@ -125,9 +124,9 @@ public: * @param[in] hints Hints to define the geometry of the rendered object * @return A handle to a shader effect */ - static Shader New( const std::string& vertexShader, - const std::string& fragmentShader, - Hint::Value hints = Hint::NONE ); + static Shader New(const std::string& vertexShader, + const std::string& fragmentShader, + Hint::Value hints = Hint::NONE); /** * @brief Default constructor, creates an empty handle. @@ -150,7 +149,7 @@ public: * @SINCE_1_1.43 * @param[in] handle A handle to a Shader object */ - Shader( const Shader& handle ); + Shader(const Shader& handle); /** * @brief Downcasts to a shader handle. @@ -160,7 +159,7 @@ public: * @param[in] handle Handle to an object * @return Shader handle or an uninitialized handle */ - static Shader DownCast( BaseHandle handle ); + static Shader DownCast(BaseHandle handle); /** * @brief Assignment operator, changes this handle to point at the same object. @@ -169,7 +168,7 @@ public: * @param[in] handle Handle to an object * @return Reference to the assigned object */ - Shader& operator=( const Shader& handle ); + Shader& operator=(const Shader& handle); /** * @brief Move constructor. @@ -177,7 +176,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs A reference to the moved handle */ - Shader( Shader&& rhs ); + Shader(Shader&& rhs); /** * @brief Move assignment operator. @@ -186,17 +185,16 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this */ - Shader& operator=( Shader&& rhs ); + Shader& operator=(Shader&& rhs); public: - /** * @brief This constructor is used by Dali New() methods. * @note Not intended for application developers. * @SINCE_1_1.43 * @param[in] effect A pointer to a newly allocated Dali resource. */ - explicit DALI_INTERNAL Shader( Internal::Shader* effect ); + explicit DALI_INTERNAL Shader(Internal::Shader* effect); }; /** diff --git a/dali/public-api/rendering/texture-set.cpp b/dali/public-api/rendering/texture-set.cpp index 127533a..62e908a 100644 --- a/dali/public-api/rendering/texture-set.cpp +++ b/dali/public-api/rendering/texture-set.cpp @@ -16,20 +16,19 @@ */ // CLASS HEADER -#include // Dali::TextureSet +#include // Dali::TextureSet // INTERNAL INCLUDES -#include // Dali::Internal::TextureSet #include // Dali::Internal::Sampler #include // Dali::Internal::Shader +#include // Dali::Internal::TextureSet namespace Dali { - TextureSet TextureSet::New() { Internal::TextureSetPtr textureSet = Internal::TextureSet::New(); - return TextureSet( textureSet.Get() ); + return TextureSet(textureSet.Get()); } TextureSet::TextureSet() @@ -40,55 +39,55 @@ TextureSet::~TextureSet() { } -TextureSet::TextureSet( const TextureSet& handle ) = default; +TextureSet::TextureSet(const TextureSet& handle) = default; -TextureSet TextureSet::DownCast( BaseHandle handle ) +TextureSet TextureSet::DownCast(BaseHandle handle) { - return TextureSet( dynamic_cast(handle.GetObjectPtr())); + return TextureSet(dynamic_cast(handle.GetObjectPtr())); } -TextureSet& TextureSet::operator=( const TextureSet& handle ) = default; +TextureSet& TextureSet::operator=(const TextureSet& handle) = default; -TextureSet::TextureSet( TextureSet&& rhs ) = default; +TextureSet::TextureSet(TextureSet&& rhs) = default; -TextureSet& TextureSet::operator=( TextureSet&& rhs ) = default; +TextureSet& TextureSet::operator=(TextureSet&& rhs) = default; -void TextureSet::SetTexture( size_t index, Texture texture ) +void TextureSet::SetTexture(size_t index, Texture texture) { - if( texture ) + if(texture) { - Internal::TexturePtr texturePtr( &GetImplementation( texture ) ); - GetImplementation(*this).SetTexture( static_cast( index ), texturePtr ); // only support 4,294,967,295 textures + Internal::TexturePtr texturePtr(&GetImplementation(texture)); + GetImplementation(*this).SetTexture(static_cast(index), texturePtr); // only support 4,294,967,295 textures } else { - GetImplementation(*this).SetTexture( static_cast( index ), nullptr ); // only support 4,294,967,295 textures + GetImplementation(*this).SetTexture(static_cast(index), nullptr); // only support 4,294,967,295 textures } } -Texture TextureSet::GetTexture( size_t index ) const +Texture TextureSet::GetTexture(size_t index) const { - Internal::Texture* texturePtr = GetImplementation(*this).GetTexture( static_cast( index ) ); // only support 4,294,967,295 textures - return Dali::Texture( texturePtr ); + Internal::Texture* texturePtr = GetImplementation(*this).GetTexture(static_cast(index)); // only support 4,294,967,295 textures + return Dali::Texture(texturePtr); } -void TextureSet::SetSampler( size_t index, Sampler sampler ) +void TextureSet::SetSampler(size_t index, Sampler sampler) { - if( sampler ) + if(sampler) { - Internal::SamplerPtr samplerPtr( &GetImplementation( sampler ) ); - GetImplementation(*this).SetSampler( static_cast( index ), samplerPtr ); // only support 4,294,967,295 samplers + Internal::SamplerPtr samplerPtr(&GetImplementation(sampler)); + GetImplementation(*this).SetSampler(static_cast(index), samplerPtr); // only support 4,294,967,295 samplers } else { - GetImplementation(*this).SetSampler( static_cast( index ), nullptr ); // only support 4,294,967,295 samplers + GetImplementation(*this).SetSampler(static_cast(index), nullptr); // only support 4,294,967,295 samplers } } -Sampler TextureSet::GetSampler( size_t index ) const +Sampler TextureSet::GetSampler(size_t index) const { - Internal::Sampler* samplerPtr = GetImplementation(*this).GetSampler( static_cast( index ) ); // only support 4,294,967,295 samplers - return Dali::Sampler( samplerPtr ); + Internal::Sampler* samplerPtr = GetImplementation(*this).GetSampler(static_cast(index)); // only support 4,294,967,295 samplers + return Dali::Sampler(samplerPtr); } size_t TextureSet::GetTextureCount() const @@ -96,8 +95,8 @@ size_t TextureSet::GetTextureCount() const return GetImplementation(*this).GetTextureCount(); } -TextureSet::TextureSet( Internal::TextureSet* pointer ) -: BaseHandle( pointer ) +TextureSet::TextureSet(Internal::TextureSet* pointer) +: BaseHandle(pointer) { } diff --git a/dali/public-api/rendering/texture-set.h b/dali/public-api/rendering/texture-set.h index 90c314c..abdce8c 100644 --- a/dali/public-api/rendering/texture-set.h +++ b/dali/public-api/rendering/texture-set.h @@ -47,7 +47,6 @@ class TextureSet; class DALI_CORE_API TextureSet : public BaseHandle { public: - /** * @brief Creates a new TextureSet object. * @@ -76,7 +75,7 @@ public: * @SINCE_1_1.43 * @param[in] handle Handle to an object */ - TextureSet( const TextureSet& handle ); + TextureSet(const TextureSet& handle); /** * @brief Downcasts to a TextureSet handle. @@ -85,7 +84,7 @@ public: * @param[in] handle Handle to an object * @return TextureSet handle or an uninitialized handle */ - static TextureSet DownCast( BaseHandle handle ); + static TextureSet DownCast(BaseHandle handle); /** * @brief Assignment operator, changes this handle to point at the same object. @@ -94,7 +93,7 @@ public: * @param[in] handle Handle to an object * @return A reference to this */ - TextureSet& operator=( const TextureSet& handle ); + TextureSet& operator=(const TextureSet& handle); /** * @brief Move constructor. @@ -102,7 +101,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs A reference to the moved handle */ - TextureSet( TextureSet&& rhs ); + TextureSet(TextureSet&& rhs); /** * @brief Move assignment operator. @@ -111,7 +110,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this handle */ - TextureSet& operator=( TextureSet&& rhs ); + TextureSet& operator=(TextureSet&& rhs); /** * @brief Sets the texture at position "index". @@ -120,7 +119,7 @@ public: * @param[in] index The position in the texture set of the texture * @param[in] texture The texture */ - void SetTexture( size_t index, Texture texture ); + void SetTexture(size_t index, Texture texture); /** * @brief Gets the image at position "index". @@ -129,7 +128,7 @@ public: * @param[in] index The position in the texture set of the image * @return A handle to the image at the the specified position */ - Texture GetTexture( size_t index ) const; + Texture GetTexture(size_t index) const; /** * @brief Sets the sampler to be used by the image at position "index". @@ -138,7 +137,7 @@ public: * @param[in] index The position in the texture set of the sampler * @param[in] sampler The sampler to use */ - void SetSampler( size_t index, Sampler sampler ); + void SetSampler(size_t index, Sampler sampler); /** * @brief Sets the sampler to be used by the image at position "index". @@ -147,7 +146,7 @@ public: * @param[in] index The position in the texture set of the image * @return A handle to the sampler at the specified position */ - Sampler GetSampler( size_t index ) const; + Sampler GetSampler(size_t index) const; /** * @brief Gets the number of textures present in the TextureSet. @@ -158,14 +157,13 @@ public: size_t GetTextureCount() const; public: - /** * @brief The constructor. * @note Not intended for application developers. * @SINCE_1_1.43 * @param[in] pointer A pointer to a newly allocated TextureSet */ - explicit DALI_INTERNAL TextureSet( Internal::TextureSet* pointer ); + explicit DALI_INTERNAL TextureSet(Internal::TextureSet* pointer); }; /** @@ -173,5 +171,4 @@ public: */ } //namespace Dali - #endif // DALI_TEXTURE_SET_H diff --git a/dali/public-api/rendering/texture.cpp b/dali/public-api/rendering/texture.cpp index ea8e911..c348a95 100644 --- a/dali/public-api/rendering/texture.cpp +++ b/dali/public-api/rendering/texture.cpp @@ -16,26 +16,24 @@ */ // CLASS HEADER -#include // Dali::Texture +#include // Dali::Texture // INTERNAL INCLUDES -#include // Dali::Internal::Texture #include // Dali::Internal::PixelData - +#include // Dali::Internal::Texture namespace Dali { - -Texture Texture::New( TextureType::Type type, Pixel::Format format, uint32_t width, uint32_t height ) +Texture Texture::New(TextureType::Type type, Pixel::Format format, uint32_t width, uint32_t height) { - Internal::TexturePtr texture = Internal::Texture::New(type, format, width, height ); - return Texture( texture.Get() ); + Internal::TexturePtr texture = Internal::Texture::New(type, format, width, height); + return Texture(texture.Get()); } -Texture Texture::New( NativeImageInterface& nativeImageInterface ) +Texture Texture::New(NativeImageInterface& nativeImageInterface) { - Internal::TexturePtr texture = Internal::Texture::New( nativeImageInterface ); - return Texture( texture.Get() ); + Internal::TexturePtr texture = Internal::Texture::New(nativeImageInterface); + return Texture(texture.Get()); } Texture::Texture() @@ -46,32 +44,35 @@ Texture::~Texture() { } -Texture::Texture( const Texture& handle ) = default; +Texture::Texture(const Texture& handle) = default; -Texture Texture::DownCast( BaseHandle handle ) +Texture Texture::DownCast(BaseHandle handle) { - return Texture( dynamic_cast(handle.GetObjectPtr())); + return Texture(dynamic_cast(handle.GetObjectPtr())); } -Texture& Texture::operator=( const Texture& handle ) = default; +Texture& Texture::operator=(const Texture& handle) = default; -Texture::Texture( Texture&& rhs ) = default; +Texture::Texture(Texture&& rhs) = default; -Texture& Texture::operator=( Texture&& rhs ) = default; +Texture& Texture::operator=(Texture&& rhs) = default; -bool Texture::Upload( PixelData pixelData ) +bool Texture::Upload(PixelData pixelData) { - Internal::PixelData& internalPixelData = GetImplementation( pixelData ); - return GetImplementation(*this).Upload( &internalPixelData ); + Internal::PixelData& internalPixelData = GetImplementation(pixelData); + return GetImplementation(*this).Upload(&internalPixelData); } -bool Texture::Upload( PixelData pixelData, - uint32_t layer, uint32_t mipmap, - uint32_t xOffset, uint32_t yOffset, - uint32_t width, uint32_t height ) +bool Texture::Upload(PixelData pixelData, + uint32_t layer, + uint32_t mipmap, + uint32_t xOffset, + uint32_t yOffset, + uint32_t width, + uint32_t height) { - Internal::PixelData& internalPixelData = GetImplementation( pixelData ); - return GetImplementation(*this).Upload( &internalPixelData, layer, mipmap, xOffset, yOffset, width, height ); + Internal::PixelData& internalPixelData = GetImplementation(pixelData); + return GetImplementation(*this).Upload(&internalPixelData, layer, mipmap, xOffset, yOffset, width, height); } void Texture::GenerateMipmaps() @@ -89,8 +90,8 @@ uint32_t Texture::GetHeight() const return GetImplementation(*this).GetHeight(); } -Texture::Texture( Internal::Texture* pointer ) -: BaseHandle( pointer ) +Texture::Texture(Internal::Texture* pointer) +: BaseHandle(pointer) { } diff --git a/dali/public-api/rendering/texture.h b/dali/public-api/rendering/texture.h index 8668772..8295868 100644 --- a/dali/public-api/rendering/texture.h +++ b/dali/public-api/rendering/texture.h @@ -19,10 +19,10 @@ */ // INTERNAL INCLUDES -#include #include -#include #include +#include +#include namespace Dali { @@ -38,37 +38,34 @@ class Texture; namespace TextureType { - /** * @brief Enumeration for texture types. * @SINCE_1_1.43 */ enum Type { - TEXTURE_2D, ///< One 2D image @SINCE_1_1.43 - TEXTURE_CUBE ///< Six 2D images arranged in a cube-shape @SINCE_1_1.43 + TEXTURE_2D, ///< One 2D image @SINCE_1_1.43 + TEXTURE_CUBE ///< Six 2D images arranged in a cube-shape @SINCE_1_1.43 }; } // namespace TextureType namespace CubeMapLayer { - - /** +/** * @brief Faces of a cube map. * These constants should be used as the "layer" parameter when uploading a cube-map with Texture::Upload. * @SINCE_1_1.43 */ - const uint32_t POSITIVE_X = 0u; ///< CubeMap image for +x @SINCE_1_1.43 - const uint32_t NEGATIVE_X = 1u; ///< CubeMap image for -x @SINCE_1_1.43 - const uint32_t POSITIVE_Y = 2u; ///< CubeMap image for +y @SINCE_1_1.43 - const uint32_t NEGATIVE_Y = 3u; ///< CubeMap image for -y @SINCE_1_1.43 - const uint32_t POSITIVE_Z = 4u; ///< CubeMap image for +z @SINCE_1_1.43 - const uint32_t NEGATIVE_Z = 5u; ///< CubeMap image for -z @SINCE_1_1.43 +const uint32_t POSITIVE_X = 0u; ///< CubeMap image for +x @SINCE_1_1.43 +const uint32_t NEGATIVE_X = 1u; ///< CubeMap image for -x @SINCE_1_1.43 +const uint32_t POSITIVE_Y = 2u; ///< CubeMap image for +y @SINCE_1_1.43 +const uint32_t NEGATIVE_Y = 3u; ///< CubeMap image for -y @SINCE_1_1.43 +const uint32_t POSITIVE_Z = 4u; ///< CubeMap image for +z @SINCE_1_1.43 +const uint32_t NEGATIVE_Z = 5u; ///< CubeMap image for -z @SINCE_1_1.43 } // namespace CubeMapLayer - /** * @brief Texture represents a texture object used as input or output by shaders. * @SINCE_1_1.43 @@ -76,7 +73,6 @@ namespace CubeMapLayer class DALI_CORE_API Texture : public BaseHandle { public: - /** * @brief Creates a new Texture object. * @@ -87,7 +83,7 @@ public: * @param[in] height The height of the texture * @return A handle to a newly allocated Texture */ - static Texture New( TextureType::Type type, Pixel::Format format, uint32_t width, uint32_t height ); + static Texture New(TextureType::Type type, Pixel::Format format, uint32_t width, uint32_t height); /** * @brief Creates a new Texture object from a native image. @@ -98,7 +94,7 @@ public: * @note It is not possible to upload data to textures created from a native image using Upload methods * although there might be platform specific APIs to upload data to a native image. */ - static Texture New( NativeImageInterface& nativeImageInterface ); + static Texture New(NativeImageInterface& nativeImageInterface); /** * @brief Default constructor, creates an empty handle. @@ -120,7 +116,7 @@ public: * @SINCE_1_1.43 * @param[in] handle Handle to an object */ - Texture( const Texture& handle ); + Texture(const Texture& handle); /** * @brief Downcasts to a texture. @@ -130,7 +126,7 @@ public: * @param[in] handle Handle to an object * @return Texture handle or an uninitialized handle */ - static Texture DownCast( BaseHandle handle ); + static Texture DownCast(BaseHandle handle); /** * @brief Assignment operator, changes this handle to point at the same object. @@ -139,7 +135,7 @@ public: * @param[in] handle Handle to an object * @return Reference to the assigned object */ - Texture& operator=( const Texture& handle ); + Texture& operator=(const Texture& handle); /** * @brief Move constructor. @@ -147,7 +143,7 @@ public: * @SINCE_1_9.22 * @param[in] rhs A reference to the moved handle */ - Texture( Texture&& rhs ); + Texture(Texture&& rhs); /** * @brief Move assignment operator. @@ -156,7 +152,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this handle */ - Texture& operator=( Texture&& rhs ); + Texture& operator=(Texture&& rhs); /** * @brief Uploads data to the texture from a PixelData object. @@ -165,7 +161,7 @@ public: * @param[in] pixelData The pixelData object * @return True if the PixelData object has compatible pixel format and fits within the texture, false otherwise */ - bool Upload( PixelData pixelData ); + bool Upload(PixelData pixelData); /** * @brief Uploads data to the texture from a PixelData object. @@ -181,10 +177,13 @@ public: * @param[in] height Specifies the height of the rectangular area in the texture that will be updated * @return True if the PixelData object has compatible pixel format and fits in the rectangle specified, false otherwise */ - bool Upload( PixelData pixelData, - uint32_t layer, uint32_t mipmap, - uint32_t xOffset, uint32_t yOffset, - uint32_t width, uint32_t height ); + bool Upload(PixelData pixelData, + uint32_t layer, + uint32_t mipmap, + uint32_t xOffset, + uint32_t yOffset, + uint32_t width, + uint32_t height); /** * @brief Generates mipmaps for the texture. @@ -211,14 +210,13 @@ public: uint32_t GetHeight() const; public: - /** * @brief The constructor. * @note Not intended for application developers. * @SINCE_1_1.43 * @param[in] pointer A pointer to a newly allocated Texture */ - explicit DALI_INTERNAL Texture( Internal::Texture* pointer ); + explicit DALI_INTERNAL Texture(Internal::Texture* pointer); }; /** diff --git a/dali/public-api/rendering/vertex-buffer.cpp b/dali/public-api/rendering/vertex-buffer.cpp index 3b7873d..a267edd 100644 --- a/dali/public-api/rendering/vertex-buffer.cpp +++ b/dali/public-api/rendering/vertex-buffer.cpp @@ -19,17 +19,16 @@ #include // INTERNAL INCLUDES -#include // Dali::Property::Map #include // Dali::Internal::VertexBuffer +#include // Dali::Property::Map namespace Dali { - -VertexBuffer VertexBuffer::New( Dali::Property::Map& bufferFormat ) +VertexBuffer VertexBuffer::New(Dali::Property::Map& bufferFormat) { - Internal::VertexBufferPtr vertexBuffer = Internal::VertexBuffer::New( bufferFormat ); + Internal::VertexBufferPtr vertexBuffer = Internal::VertexBuffer::New(bufferFormat); - return VertexBuffer( vertexBuffer.Get() ); + return VertexBuffer(vertexBuffer.Get()); } VertexBuffer::VertexBuffer() @@ -40,32 +39,31 @@ VertexBuffer::~VertexBuffer() { } -VertexBuffer::VertexBuffer( const VertexBuffer& handle ) = default; +VertexBuffer::VertexBuffer(const VertexBuffer& handle) = default; -VertexBuffer VertexBuffer::DownCast( BaseHandle handle ) +VertexBuffer VertexBuffer::DownCast(BaseHandle handle) { - return VertexBuffer( dynamic_cast(handle.GetObjectPtr())); + return VertexBuffer(dynamic_cast(handle.GetObjectPtr())); } -VertexBuffer& VertexBuffer::operator=( const VertexBuffer& handle ) = default; +VertexBuffer& VertexBuffer::operator=(const VertexBuffer& handle) = default; -VertexBuffer::VertexBuffer( VertexBuffer&& rhs ) = default; +VertexBuffer::VertexBuffer(VertexBuffer&& rhs) = default; -VertexBuffer& VertexBuffer::operator=( VertexBuffer&& rhs ) = default; +VertexBuffer& VertexBuffer::operator=(VertexBuffer&& rhs) = default; -void VertexBuffer::SetData( const void* data, std::size_t size ) +void VertexBuffer::SetData(const void* data, std::size_t size) { - GetImplementation(*this).SetData( data, static_cast( size ) ); // only support 4,294,967,295 bytes + GetImplementation(*this).SetData(data, static_cast(size)); // only support 4,294,967,295 bytes } std::size_t VertexBuffer::GetSize() const { - return GetImplementation(*this).GetSize(); + return GetImplementation(*this).GetSize(); } - -VertexBuffer::VertexBuffer( Internal::VertexBuffer* pointer ) -: BaseHandle( pointer ) +VertexBuffer::VertexBuffer(Internal::VertexBuffer* pointer) +: BaseHandle(pointer) { } diff --git a/dali/public-api/rendering/vertex-buffer.h b/dali/public-api/rendering/vertex-buffer.h index 69f46c5..5c25bec 100644 --- a/dali/public-api/rendering/vertex-buffer.h +++ b/dali/public-api/rendering/vertex-buffer.h @@ -72,7 +72,6 @@ class VertexBuffer; class DALI_CORE_API VertexBuffer : public BaseHandle { public: - /** * @brief Creates a VertexBuffer. * @@ -80,7 +79,7 @@ public: * @param[in] bufferFormat Map of names and types that describes the components of the buffer * @return Handle to a newly allocated VertexBuffer */ - static VertexBuffer New( Dali::Property::Map& bufferFormat ); + static VertexBuffer New(Dali::Property::Map& bufferFormat); /** * @brief Default constructor, creates an empty handle. @@ -102,7 +101,7 @@ public: * @SINCE_1_9.27 * @param[in] handle Handle to an object */ - VertexBuffer( const VertexBuffer& handle ); + VertexBuffer(const VertexBuffer& handle); /** * @brief Downcasts to a property buffer handle. @@ -112,7 +111,7 @@ public: * @param[in] handle Handle to an object * @return Property buffer handle or an uninitialized handle */ - static VertexBuffer DownCast( BaseHandle handle ); + static VertexBuffer DownCast(BaseHandle handle); /** * @brief Assignment operator, changes this handle to point at the same object. @@ -121,7 +120,7 @@ public: * @param[in] handle Handle to an object * @return Reference to the assigned object */ - VertexBuffer& operator=( const VertexBuffer& handle ); + VertexBuffer& operator=(const VertexBuffer& handle); /** * @brief Move constructor. @@ -129,7 +128,7 @@ public: * @SINCE_1_9.27 * @param[in] rhs A reference to the moved handle */ - VertexBuffer( VertexBuffer&& rhs ); + VertexBuffer(VertexBuffer&& rhs); /** * @brief Move assignment operator. @@ -138,7 +137,7 @@ public: * @param[in] rhs A reference to the moved handle * @return A reference to this handle */ - VertexBuffer& operator=( VertexBuffer&& rhs ); + VertexBuffer& operator=(VertexBuffer&& rhs); /** * @brief Updates the whole buffer information. @@ -162,7 +161,7 @@ public: * @param[in] data A pointer to the data that will be copied to the buffer * @param[in] size Number of elements to expand or contract the buffer */ - void SetData( const void* data, std::size_t size ); + void SetData(const void* data, std::size_t size); /** * @brief Gets the number of elements in the buffer. @@ -173,14 +172,13 @@ public: std::size_t GetSize() const; public: - /** * @brief The constructor. * @note Not intended for application developers. * @SINCE_1_9.27 * @param[in] pointer A pointer to a newly allocated VertexBuffer */ - explicit DALI_INTERNAL VertexBuffer( Internal::VertexBuffer* pointer ); + explicit DALI_INTERNAL VertexBuffer(Internal::VertexBuffer* pointer); }; /** diff --git a/dali/public-api/signals/base-signal.cpp b/dali/public-api/signals/base-signal.cpp index a26a0c8..0b3cfd7 100644 --- a/dali/public-api/signals/base-signal.cpp +++ b/dali/public-api/signals/base-signal.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -26,38 +26,36 @@ namespace { - const int32_t INVALID_CALLBACK_INDEX = -1; } // unnamed namespace namespace Dali { - BaseSignal::BaseSignal() -: mEmittingFlag( false ) +: mEmittingFlag(false) { } BaseSignal::~BaseSignal() { // We can't assert in a destructor - if( mEmittingFlag ) + if(mEmittingFlag) { - DALI_LOG_ERROR( "Invalid destruction of Signal during Emit()\n" ); + DALI_LOG_ERROR("Invalid destruction of Signal during Emit()\n"); } // The signal is being destroyed. We have to inform any slots // that are connected, that the signal is dead. - const std::size_t count( mSignalConnections.Count() ); - for( std::size_t i=0; i < count; i++ ) + const std::size_t count(mSignalConnections.Count()); + for(std::size_t i = 0; i < count; i++) { - SignalConnection* connection = mSignalConnections[ i ]; + SignalConnection* connection = mSignalConnections[i]; // Note that values are set to NULL in DeleteConnection - if( connection ) + if(connection) { - connection->Disconnect( this ); + connection->Disconnect(this); delete connection; } } @@ -67,18 +65,18 @@ BaseSignal::~BaseSignal() bool BaseSignal::Empty() const { - return ( 0 == GetConnectionCount() ); + return (0 == GetConnectionCount()); } std::size_t BaseSignal::GetConnectionCount() const { - std::size_t count( 0 ); + std::size_t count(0); - const std::size_t size( mSignalConnections.Count() ); - for( std::size_t i = 0; i < size; ++i ) + const std::size_t size(mSignalConnections.Count()); + for(std::size_t i = 0; i < size; ++i) { // Note that values are set to NULL in DeleteConnection - if ( nullptr != mSignalConnections[i] ) + if(nullptr != mSignalConnections[i]) { ++count; } @@ -90,25 +88,25 @@ std::size_t BaseSignal::GetConnectionCount() const void BaseSignal::Emit() { // Guards against nested Emit() calls - EmitGuard guard( mEmittingFlag ); // Guards against nested Emit() calls - if( guard.ErrorOccurred() ) + EmitGuard guard(mEmittingFlag); // Guards against nested Emit() calls + if(guard.ErrorOccurred()) { return; } // If more connections are added by callbacks, these are ignore until the next Emit() // Note that mSignalConnections.Count() count cannot be reduced while iterating - const std::size_t initialCount( mSignalConnections.Count() ); + const std::size_t initialCount(mSignalConnections.Count()); - for( std::size_t i = 0; i < initialCount; ++i ) + for(std::size_t i = 0; i < initialCount; ++i) { - CallbackBase* callback( GetCallback(i) ); + CallbackBase* callback(GetCallback(i)); // Note that connections will be set to NULL when disconnected // This is preferable to reducing the connection count while iterating - if( callback ) + if(callback) { - CallbackBase::Execute( *callback ); + CallbackBase::Execute(*callback); } } @@ -116,19 +114,19 @@ void BaseSignal::Emit() CleanupConnections(); } -void BaseSignal::OnConnect( CallbackBase* callback ) +void BaseSignal::OnConnect(CallbackBase* callback) { - DALI_ASSERT_ALWAYS( nullptr != callback && "Invalid member function pointer passed to Connect()" ); + DALI_ASSERT_ALWAYS(nullptr != callback && "Invalid member function pointer passed to Connect()"); - int32_t index = FindCallback( callback ); + int32_t index = FindCallback(callback); // Don't double-connect the same callback - if( INVALID_CALLBACK_INDEX == index ) + if(INVALID_CALLBACK_INDEX == index) { // create a new signal connection object, to allow the signal to track the connection. - SignalConnection* connection = new SignalConnection( callback ); + SignalConnection* connection = new SignalConnection(callback); - mSignalConnections.PushBack( connection ); + mSignalConnections.PushBack(connection); } else { @@ -137,38 +135,38 @@ void BaseSignal::OnConnect( CallbackBase* callback ) } } -void BaseSignal::OnDisconnect( CallbackBase* callback ) +void BaseSignal::OnDisconnect(CallbackBase* callback) { - DALI_ASSERT_ALWAYS( nullptr != callback && "Invalid member function pointer passed to Disconnect()" ); + DALI_ASSERT_ALWAYS(nullptr != callback && "Invalid member function pointer passed to Disconnect()"); - int32_t index = FindCallback( callback ); + int32_t index = FindCallback(callback); - if( index > INVALID_CALLBACK_INDEX ) + if(index > INVALID_CALLBACK_INDEX) { - DeleteConnection( index ); + DeleteConnection(index); } // call back is a temporary created to find which slot should be disconnected. delete callback; } -void BaseSignal::OnConnect( ConnectionTrackerInterface* tracker, CallbackBase* callback ) +void BaseSignal::OnConnect(ConnectionTrackerInterface* tracker, CallbackBase* callback) { - DALI_ASSERT_ALWAYS( nullptr != tracker && "Invalid ConnectionTrackerInterface pointer passed to Connect()" ); - DALI_ASSERT_ALWAYS( nullptr != callback && "Invalid member function pointer passed to Connect()" ); + DALI_ASSERT_ALWAYS(nullptr != tracker && "Invalid ConnectionTrackerInterface pointer passed to Connect()"); + DALI_ASSERT_ALWAYS(nullptr != callback && "Invalid member function pointer passed to Connect()"); - int32_t index = FindCallback( callback ); + int32_t index = FindCallback(callback); // Don't double-connect the same callback - if( INVALID_CALLBACK_INDEX == index ) + if(INVALID_CALLBACK_INDEX == index) { // create a new signal connection object, to allow the signal to track the connection. - SignalConnection* connection = new SignalConnection( tracker, callback ); + SignalConnection* connection = new SignalConnection(tracker, callback); - mSignalConnections.PushBack( connection ); + mSignalConnections.PushBack(connection); // Let the connection tracker know that a connection between a signal and a slot has been made. - tracker->SignalConnected( this, callback ); + tracker->SignalConnected(this, callback); } else { @@ -177,23 +175,23 @@ void BaseSignal::OnConnect( ConnectionTrackerInterface* tracker, CallbackBase* c } } -void BaseSignal::OnDisconnect( ConnectionTrackerInterface* tracker, CallbackBase* callback ) +void BaseSignal::OnDisconnect(ConnectionTrackerInterface* tracker, CallbackBase* callback) { - DALI_ASSERT_ALWAYS( nullptr != tracker && "Invalid ConnectionTrackerInterface pointer passed to Disconnect()" ); - DALI_ASSERT_ALWAYS( nullptr != callback && "Invalid member function pointer passed to Disconnect()" ); + DALI_ASSERT_ALWAYS(nullptr != tracker && "Invalid ConnectionTrackerInterface pointer passed to Disconnect()"); + DALI_ASSERT_ALWAYS(nullptr != callback && "Invalid member function pointer passed to Disconnect()"); - int32_t index = FindCallback( callback ); + int32_t index = FindCallback(callback); - if( index > INVALID_CALLBACK_INDEX ) + if(index > INVALID_CALLBACK_INDEX) { // temporary pointer to disconnected callback CallbackBase* disconnectedCallback = mSignalConnections[index]->GetCallback(); // close the signal side connection first. - DeleteConnection( index ); + DeleteConnection(index); // close the slot side connection - tracker->SignalDisconnected( this, disconnectedCallback ); + tracker->SignalDisconnected(this, disconnectedCallback); } // call back is a temporary created to find which slot should be disconnected. @@ -201,37 +199,37 @@ void BaseSignal::OnDisconnect( ConnectionTrackerInterface* tracker, CallbackBase } // for SlotObserver::SlotDisconnected -void BaseSignal::SlotDisconnected( CallbackBase* callback ) +void BaseSignal::SlotDisconnected(CallbackBase* callback) { - const std::size_t count( mSignalConnections.Count() ); - for( std::size_t i=0; i < count; ++i ) + const std::size_t count(mSignalConnections.Count()); + for(std::size_t i = 0; i < count; ++i) { - const CallbackBase* connectionCallback = GetCallback( i ); + const CallbackBase* connectionCallback = GetCallback(i); // Pointer comparison i.e. SignalConnection contains pointer to same callback instance - if( connectionCallback && - connectionCallback == callback ) + if(connectionCallback && + connectionCallback == callback) { - DeleteConnection( i ); + DeleteConnection(i); // Disconnection complete return; } } - DALI_ABORT( "Callback lost in SlotDisconnected()" ); + DALI_ABORT("Callback lost in SlotDisconnected()"); } -CallbackBase* BaseSignal::GetCallback( std::size_t connectionIndex ) const +CallbackBase* BaseSignal::GetCallback(std::size_t connectionIndex) const { - DALI_ASSERT_ALWAYS( connectionIndex < mSignalConnections.Count() && "GetCallback called with invalid index" ); + DALI_ASSERT_ALWAYS(connectionIndex < mSignalConnections.Count() && "GetCallback called with invalid index"); - CallbackBase* callback( nullptr ); + CallbackBase* callback(nullptr); - SignalConnection* connection( mSignalConnections[ connectionIndex ] ); + SignalConnection* connection(mSignalConnections[connectionIndex]); // Note that values are set to NULL in DeleteConnection - if( connection ) + if(connection) { callback = connection->GetCallback(); } @@ -239,22 +237,22 @@ CallbackBase* BaseSignal::GetCallback( std::size_t connectionIndex ) const return callback; } -int32_t BaseSignal::FindCallback( CallbackBase* callback ) +int32_t BaseSignal::FindCallback(CallbackBase* callback) { - int32_t index( INVALID_CALLBACK_INDEX ); + int32_t index(INVALID_CALLBACK_INDEX); // A signal can have multiple slots connected to it. // We need to search for the slot which has the same call back function (if it's static) // Or the same object / member function (for non-static) const std::size_t count = mSignalConnections.Count(); - for( std::size_t i = 0; i < count; ++i ) + for(std::size_t i = 0; i < count; ++i) { - const CallbackBase* connectionCallback = GetCallback( i ); + const CallbackBase* connectionCallback = GetCallback(i); // Note that values are set to NULL in DeleteConnection - if( connectionCallback && ( *connectionCallback == *callback ) ) + if(connectionCallback && (*connectionCallback == *callback)) { - index = static_cast( i ); // only 2,147,483,647 connections supported, no error check + index = static_cast(i); // only 2,147,483,647 connections supported, no error check break; } } @@ -262,26 +260,26 @@ int32_t BaseSignal::FindCallback( CallbackBase* callback ) return index; } -void BaseSignal::DeleteConnection( std::size_t connectionIndex ) +void BaseSignal::DeleteConnection(std::size_t connectionIndex) { - DALI_ASSERT_ALWAYS( connectionIndex < mSignalConnections.Count() && "DeleteConnection called with invalid index" ); + DALI_ASSERT_ALWAYS(connectionIndex < mSignalConnections.Count() && "DeleteConnection called with invalid index"); // delete the object - SignalConnection* connection( mSignalConnections[ connectionIndex ] ); + SignalConnection* connection(mSignalConnections[connectionIndex]); delete connection; - if( mEmittingFlag ) + if(mEmittingFlag) { // IMPORTANT - do not remove from items from mSignalConnections, set to NULL instead. // Signal Emit() methods require that connection count is not reduced while iterating // i.e. DeleteConnection can be called from within callbacks, while iterating through mSignalConnections. - mSignalConnections[ connectionIndex ] = nullptr; + mSignalConnections[connectionIndex] = nullptr; } else { // If application connects and disconnects without the signal never emitting, // the mSignalConnections vector keeps growing and growing as CleanupConnections() is done from Emit. - mSignalConnections.Erase( mSignalConnections.Begin() + connectionIndex ); + mSignalConnections.Erase(mSignalConnections.Begin() + connectionIndex); } } @@ -289,16 +287,16 @@ void BaseSignal::CleanupConnections() { const std::size_t total = mSignalConnections.Count(); // only do something if there are items - if( total > 0 ) + if(total > 0) { std::size_t index = 0; // process the whole vector - for( std::size_t i = 0; i < total; ++i ) + for(std::size_t i = 0; i < total; ++i) { - if( mSignalConnections[ index ] == nullptr ) + if(mSignalConnections[index] == nullptr) { // items will be moved so don't increase index (erase will decrease the count of vector) - mSignalConnections.Erase( mSignalConnections.Begin() + index ); + mSignalConnections.Erase(mSignalConnections.Begin() + index); } else { @@ -311,24 +309,24 @@ void BaseSignal::CleanupConnections() // BaseSignal::EmitGuard -BaseSignal::EmitGuard::EmitGuard( bool& flag ) -: mFlag( nullptr ) +BaseSignal::EmitGuard::EmitGuard(bool& flag) +: mFlag(nullptr) { - if( !flag ) + if(!flag) { mFlag = &flag; - flag = true; + flag = true; } else { // mFlag is NULL when Emit() is called during Emit() - DALI_LOG_ERROR( "Cannot call Emit() from inside Emit()\n" ); + DALI_LOG_ERROR("Cannot call Emit() from inside Emit()\n"); } } BaseSignal::EmitGuard::~EmitGuard() { - if( mFlag ) + if(mFlag) { *mFlag = false; } diff --git a/dali/public-api/signals/base-signal.h b/dali/public-api/signals/base-signal.h old mode 100755 new mode 100644 index 887403b..ddfe915 --- a/dali/public-api/signals/base-signal.h +++ b/dali/public-api/signals/base-signal.h @@ -78,7 +78,6 @@ namespace Dali class DALI_CORE_API BaseSignal : public SlotObserver { public: - /** * @brief Constructor. * @SINCE_1_0.0 @@ -121,7 +120,7 @@ public: * @SINCE_1_0.0 * @param[in,out] flag This flag will be set to true during Emit() calls */ - EmitGuard( bool& flag ); + EmitGuard(bool& flag); /** * @brief Non-virtual destructor. @@ -156,31 +155,31 @@ public: * @return The value returned by the last callback * @pre Cannot be called from inside the same Signal's Emit methods. */ - template< typename Ret > + template Ret EmitReturn() { Ret returnVal = Ret(); // Guards against nested Emit() calls - EmitGuard guard( mEmittingFlag ); - if( guard.ErrorOccurred() ) + EmitGuard guard(mEmittingFlag); + if(guard.ErrorOccurred()) { return returnVal; } // If more connections are added by callbacks, these are ignore until the next Emit() // Note that count cannot be reduced while iterating - const std::size_t initialCount( mSignalConnections.Count() ); + const std::size_t initialCount(mSignalConnections.Count()); - for( std::size_t i = 0; i < initialCount; ++i ) + for(std::size_t i = 0; i < initialCount; ++i) { - CallbackBase* callback( GetCallback(i) ); + CallbackBase* callback(GetCallback(i)); // Note that connections will be set to NULL when disconnected // This is preferable to reducing the connection count while iterating - if( callback ) + if(callback) { - returnVal = CallbackBase::ExecuteReturn( *callback ); + returnVal = CallbackBase::ExecuteReturn(*callback); } } @@ -197,29 +196,29 @@ public: * @param[in] arg0 The first parameter * @pre Cannot be called from inside the same Signal's Emit methods. */ - template< typename Arg0 > - void Emit( Arg0 arg0 ) + template + void Emit(Arg0 arg0) { // Guards against nested Emit() calls - EmitGuard guard( mEmittingFlag ); // Guards against nested Emit() calls - if( guard.ErrorOccurred() ) + EmitGuard guard(mEmittingFlag); // Guards against nested Emit() calls + if(guard.ErrorOccurred()) { return; } // If more connections are added by callbacks, these are ignore until the next Emit() // Note that count cannot be reduced while iterating - const std::size_t initialCount( mSignalConnections.Count() ); + const std::size_t initialCount(mSignalConnections.Count()); - for( std::size_t i = 0; i < initialCount; ++i ) + for(std::size_t i = 0; i < initialCount; ++i) { - CallbackBase* callback( GetCallback(i) ); + CallbackBase* callback(GetCallback(i)); // Note that connections will be set to NULL when disconnected // This is preferable to reducing the connection count while iterating - if( callback ) + if(callback) { - CallbackBase::Execute( *callback, arg0 ); + CallbackBase::Execute(*callback, arg0); } } @@ -235,31 +234,31 @@ public: * @return The value returned by the last callback * @pre Cannot be called from inside the same Signal's Emit methods. */ - template< typename Ret, typename Arg0 > - Ret EmitReturn( Arg0 arg0 ) + template + Ret EmitReturn(Arg0 arg0) { Ret returnVal = Ret(); // Guards against nested Emit() calls - EmitGuard guard( mEmittingFlag ); // Guards against nested Emit() calls - if( guard.ErrorOccurred() ) + EmitGuard guard(mEmittingFlag); // Guards against nested Emit() calls + if(guard.ErrorOccurred()) { return returnVal; } // If more connections are added by callbacks, these are ignore until the next Emit() // Note that count cannot be reduced while iterating - const std::size_t initialCount( mSignalConnections.Count() ); + const std::size_t initialCount(mSignalConnections.Count()); - for( std::size_t i = 0; i < initialCount; ++i ) + for(std::size_t i = 0; i < initialCount; ++i) { - CallbackBase* callback( GetCallback(i) ); + CallbackBase* callback(GetCallback(i)); // Note that connections will be set to NULL when disconnected // This is preferable to reducing the connection count while iterating - if( callback ) + if(callback) { - returnVal = CallbackBase::ExecuteReturn( *callback, arg0 ); + returnVal = CallbackBase::ExecuteReturn(*callback, arg0); } } @@ -277,29 +276,29 @@ public: * @param[in] arg1 The second parameter * @pre Cannot be called from inside the same Signal's Emit methods. */ - template< typename Arg0, typename Arg1 > - void Emit( Arg0 arg0, Arg1 arg1 ) + template + void Emit(Arg0 arg0, Arg1 arg1) { // Guards against nested Emit() calls - EmitGuard guard( mEmittingFlag ); // Guards against nested Emit() calls - if( guard.ErrorOccurred() ) + EmitGuard guard(mEmittingFlag); // Guards against nested Emit() calls + if(guard.ErrorOccurred()) { return; } // If more connections are added by callbacks, these are ignore until the next Emit() // Note that count cannot be reduced while iterating - const std::size_t initialCount( mSignalConnections.Count() ); + const std::size_t initialCount(mSignalConnections.Count()); - for( std::size_t i = 0; i < initialCount; ++i ) + for(std::size_t i = 0; i < initialCount; ++i) { - CallbackBase* callback( GetCallback(i) ); + CallbackBase* callback(GetCallback(i)); // Note that connections will be set to NULL when disconnected // This is preferable to reducing the connection count while iterating - if( callback ) + if(callback) { - CallbackBase::Execute( *callback, arg0, arg1 ); + CallbackBase::Execute(*callback, arg0, arg1); } } @@ -316,31 +315,31 @@ public: * @return The value returned by the last callback * @pre Cannot be called from inside the same Signal's Emit methods. */ - template< typename Ret, typename Arg0, typename Arg1 > - Ret EmitReturn( Arg0 arg0, Arg1 arg1 ) + template + Ret EmitReturn(Arg0 arg0, Arg1 arg1) { Ret returnVal = Ret(); // Guards against nested Emit() calls - EmitGuard guard( mEmittingFlag ); // Guards against nested Emit() calls - if( guard.ErrorOccurred() ) + EmitGuard guard(mEmittingFlag); // Guards against nested Emit() calls + if(guard.ErrorOccurred()) { return returnVal; } // If more connections are added by callbacks, these are ignore until the next Emit() // Note that count cannot be reduced while iterating - const std::size_t initialCount( mSignalConnections.Count() ); + const std::size_t initialCount(mSignalConnections.Count()); - for( std::size_t i = 0; i < initialCount; ++i ) + for(std::size_t i = 0; i < initialCount; ++i) { - CallbackBase* callback( GetCallback(i) ); + CallbackBase* callback(GetCallback(i)); // Note that connections will be set to NULL when disconnected // This is preferable to reducing the connection count while iterating - if( callback ) + if(callback) { - returnVal = CallbackBase::ExecuteReturn( *callback, arg0, arg1 ); + returnVal = CallbackBase::ExecuteReturn(*callback, arg0, arg1); } } @@ -359,29 +358,29 @@ public: * @param[in] arg2 The third parameter * @pre Cannot be called from inside the same Signal's Emit methods. */ - template< typename Arg0, typename Arg1, typename Arg2 > - void Emit( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) + template + void Emit(Arg0 arg0, Arg1 arg1, Arg2 arg2) { // Guards against nested Emit() calls - EmitGuard guard( mEmittingFlag ); // Guards against nested Emit() calls - if( guard.ErrorOccurred() ) + EmitGuard guard(mEmittingFlag); // Guards against nested Emit() calls + if(guard.ErrorOccurred()) { return; } // If more connections are added by callbacks, these are ignore until the next Emit() // Note that count cannot be reduced while iterating - const std::size_t initialCount( mSignalConnections.Count() ); + const std::size_t initialCount(mSignalConnections.Count()); - for( std::size_t i = 0; i < initialCount; ++i ) + for(std::size_t i = 0; i < initialCount; ++i) { - CallbackBase* callback( GetCallback(i) ); + CallbackBase* callback(GetCallback(i)); // Note that connections will be set to NULL when disconnected // This is preferable to reducing the connection count while iterating - if( callback ) + if(callback) { - CallbackBase::Execute( *callback, arg0, arg1, arg2 ); + CallbackBase::Execute(*callback, arg0, arg1, arg2); } } @@ -399,31 +398,31 @@ public: * @return The value returned by the last callback * @pre Cannot be called from inside the same Signal's Emit methods. */ - template< typename Ret, typename Arg0, typename Arg1, typename Arg2 > - Ret EmitReturn( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) + template + Ret EmitReturn(Arg0 arg0, Arg1 arg1, Arg2 arg2) { Ret returnVal = Ret(); // Guards against nested Emit() calls - EmitGuard guard( mEmittingFlag ); // Guards against nested Emit() calls - if( guard.ErrorOccurred() ) + EmitGuard guard(mEmittingFlag); // Guards against nested Emit() calls + if(guard.ErrorOccurred()) { return returnVal; } // If more connections are added by callbacks, these are ignore until the next Emit() // Note that count cannot be reduced while iterating - const std::size_t initialCount( mSignalConnections.Count() ); + const std::size_t initialCount(mSignalConnections.Count()); - for( std::size_t i = 0; i < initialCount; ++i ) + for(std::size_t i = 0; i < initialCount; ++i) { - CallbackBase* callback( GetCallback(i) ); + CallbackBase* callback(GetCallback(i)); // Note that connections will be set to NULL when disconnected // This is preferable to reducing the connection count while iterating - if( callback ) + if(callback) { - returnVal = CallbackBase::ExecuteReturn( *callback, arg0, arg1, arg2 ); + returnVal = CallbackBase::ExecuteReturn(*callback, arg0, arg1, arg2); } } @@ -441,7 +440,7 @@ public: * @SINCE_1_0.0 * @param[in] callback A newly allocated callback object (takes ownership) */ - void OnConnect( CallbackBase* callback ); + void OnConnect(CallbackBase* callback); /** * @brief Called by Signal implementations, when the user calls Signal.Disconnect( ... ). @@ -449,7 +448,7 @@ public: * @SINCE_1_0.0 * @param[in] callback A newly allocated callback object (takes ownership) */ - void OnDisconnect( CallbackBase* callback ); + void OnDisconnect(CallbackBase* callback); /** * @brief Called by Signal implementations, when the user calls Signal.Connect( ... ). @@ -458,7 +457,7 @@ public: * @param[in] tracker The connection tracker * @param[in] callback A newly allocated callback object (takes ownership) */ - void OnConnect( ConnectionTrackerInterface* tracker, CallbackBase* callback ); + void OnConnect(ConnectionTrackerInterface* tracker, CallbackBase* callback); /** * @brief Called by Signal implementations, when the user calls Signal.Disconnect( ... ). @@ -467,17 +466,15 @@ public: * @param[in] tracker The connection tracker * @param[in] callback A newly allocated callback object (takes ownership) */ - void OnDisconnect( ConnectionTrackerInterface* tracker, CallbackBase* callback ); + void OnDisconnect(ConnectionTrackerInterface* tracker, CallbackBase* callback); private: // SlotObserver interface, to be told when a slot disconnects - /** * @copydoc SlotObserver::SlotDisconnected */ - void SlotDisconnected( CallbackBase* callback ) override; + void SlotDisconnected(CallbackBase* callback) override; private: - /** * @brief Returns a callback given an index in to the connection array. * @@ -485,7 +482,7 @@ private: * @param[in] connectionIndex The index of the callback * @return The callback, or NULL if the connection has been deleted */ - CallbackBase* GetCallback( std::size_t connectionIndex ) const; + CallbackBase* GetCallback(std::size_t connectionIndex) const; /** * @brief Helper to find whether a callback is connected. @@ -494,7 +491,7 @@ private: * @param[in] callback The call back object * @return A valid index if the callback is connected */ - int32_t FindCallback( CallbackBase* callback ); + int32_t FindCallback(CallbackBase* callback); /** * @brief Deletes a connection object from the list of connections. @@ -502,7 +499,7 @@ private: * @SINCE_1_0.0 * @param[in] connectionIndex The index of the callback */ - void DeleteConnection( std::size_t connectionIndex ); + void DeleteConnection(std::size_t connectionIndex); /** * @brief Helper to remove NULL items from mSignalConnections, which is only safe at the end of Emit() @@ -511,14 +508,13 @@ private: */ void CleanupConnections(); - BaseSignal( const BaseSignal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0 - BaseSignal( BaseSignal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25 - BaseSignal& operator=( const BaseSignal& ) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0 - BaseSignal& operator=( BaseSignal&& ) = delete; ///< Deleted move assignment operator. @SINCE_1_9.25 + BaseSignal(const BaseSignal&) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0 + BaseSignal(BaseSignal&&) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25 + BaseSignal& operator=(const BaseSignal&) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0 + BaseSignal& operator=(BaseSignal&&) = delete; ///< Deleted move assignment operator. @SINCE_1_9.25 private: - - Dali::Vector< SignalConnection* > mSignalConnections; ///< Array of connections + Dali::Vector mSignalConnections; ///< Array of connections bool mEmittingFlag; ///< Used to guard against nested Emit() calls }; diff --git a/dali/public-api/signals/callback.cpp b/dali/public-api/signals/callback.cpp index bd3787c..fd0576b 100644 --- a/dali/public-api/signals/callback.cpp +++ b/dali/public-api/signals/callback.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -18,15 +18,13 @@ // CLASS HEADER #include - namespace Dali { - // CallbackBase CallbackBase::CallbackBase() -: mImpl( nullptr ), - mFunction( nullptr ) +: mImpl(nullptr), + mFunction(nullptr) { } @@ -35,46 +33,46 @@ CallbackBase::~CallbackBase() Reset(); } -CallbackBase::CallbackBase( Function function ) -: mImpl( nullptr ), - mFunction( function ) +CallbackBase::CallbackBase(Function function) +: mImpl(nullptr), + mFunction(function) { } -CallbackBase::CallbackBase( void* object, MemberFunction function, Dispatcher dispatcher ) -: mMemberFunction( function ) +CallbackBase::CallbackBase(void* object, MemberFunction function, Dispatcher dispatcher) +: mMemberFunction(function) { mImpl = new CallbackBase::Impl; - if( mImpl ) + if(mImpl) { - mImpl->mObjectPointer = object; + mImpl->mObjectPointer = object; mImpl->mMemberFunctionDispatcher = dispatcher; - mImpl->mDestructorDispatcher = nullptr; // object is not owned + mImpl->mDestructorDispatcher = nullptr; // object is not owned } } -CallbackBase::CallbackBase( void* object, MemberFunction function, Dispatcher dispatcher, Destructor destructor ) -: mMemberFunction( function ) +CallbackBase::CallbackBase(void* object, MemberFunction function, Dispatcher dispatcher, Destructor destructor) +: mMemberFunction(function) { mImpl = new CallbackBase::Impl; - if( mImpl ) + if(mImpl) { - mImpl->mObjectPointer = object; + mImpl->mObjectPointer = object; mImpl->mMemberFunctionDispatcher = dispatcher; - mImpl->mDestructorDispatcher = destructor; // object is owned + mImpl->mDestructorDispatcher = destructor; // object is owned } } void CallbackBase::Reset() { - if( mImpl ) + if(mImpl) { // if destructor function is set it means we own this object - if ( mImpl->mObjectPointer && - mImpl->mDestructorDispatcher ) + if(mImpl->mObjectPointer && + mImpl->mDestructorDispatcher) { // call the destructor dispatcher - (*mImpl->mDestructorDispatcher)( mImpl->mObjectPointer ); + (*mImpl->mDestructorDispatcher)(mImpl->mObjectPointer); } delete mImpl; @@ -87,26 +85,26 @@ void CallbackBase::Reset() // CallbackBase::Impl CallbackBase::Impl::Impl() -: mObjectPointer( nullptr ), - mMemberFunctionDispatcher( nullptr ), - mDestructorDispatcher( nullptr ) +: mObjectPointer(nullptr), + mMemberFunctionDispatcher(nullptr), + mDestructorDispatcher(nullptr) { } // Non-member equality operator -bool operator==( const CallbackBase& lhs, const CallbackBase& rhs ) +bool operator==(const CallbackBase& lhs, const CallbackBase& rhs) { - if( lhs.mImpl ) + if(lhs.mImpl) { // check it's the same member function / object - return ( lhs.mFunction == rhs.mFunction ) && ( lhs.mImpl->mObjectPointer == rhs.mImpl->mObjectPointer ); + return (lhs.mFunction == rhs.mFunction) && (lhs.mImpl->mObjectPointer == rhs.mImpl->mObjectPointer); } else { // check if it the same C function or a static member function - return ( lhs.mFunction == rhs.mFunction ); + return (lhs.mFunction == rhs.mFunction); } } -} // namespace DALI +} // namespace Dali diff --git a/dali/public-api/signals/callback.h b/dali/public-api/signals/callback.h index 2e068e0..81d875f 100644 --- a/dali/public-api/signals/callback.h +++ b/dali/public-api/signals/callback.h @@ -2,7 +2,7 @@ #define DALI_CALLBACK_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -41,7 +41,6 @@ class CallbackBase; class DALI_CORE_API CallbackBase { public: - /** * @brief Default constructor. * @SINCE_1_0.0 @@ -66,26 +65,26 @@ public: * @SINCE_1_0.0 * @param[in] callback The callback to call */ - static void Execute( CallbackBase& callback ) + static void Execute(CallbackBase& callback) { // if we point to a function, we can call it directly // otherwise call the dispatcher function that knows the real type of the object // Note that this template dispatcher lives in client code so the library containing // the code has to be loaded, otherwise we crash boom bang - if( callback.mImpl && callback.mImpl->mObjectPointer ) + if(callback.mImpl && callback.mImpl->mObjectPointer) { Dispatcher dispatcher = callback.mImpl->mMemberFunctionDispatcher; - (*dispatcher)( callback ); + (*dispatcher)(callback); } // its also possible to have a member function pointer to a CallbackProvider // that has been deleted, so check if we have impl still - else if( !callback.mImpl && callback.mFunction ) + else if(!callback.mImpl && callback.mFunction) { (*(callback.mFunction))(); } else { - DALI_ASSERT_ALWAYS( 0 && "no function to execute" ); + DALI_ASSERT_ALWAYS(0 && "no function to execute"); } } @@ -96,24 +95,24 @@ public: * @param[in] callback The callback to call * @return The value from the function */ - template< typename R > - static R ExecuteReturn( CallbackBase& callback ) + template + static R ExecuteReturn(CallbackBase& callback) { R returnVal = R(); // if we point to a function, we can call it directly // otherwise call the dispatcher function that knows the real type of the object // Note that this template dispatcher lives in client code so the library containing // the code has to be loaded, otherwise we crash boom bang - if( callback.mImpl && callback.mImpl->mObjectPointer ) + if(callback.mImpl && callback.mImpl->mObjectPointer) { - using Dispatcher = R ( * )( CallbackBase& ); - Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher ); - returnVal = (*dispatcher)( callback ); + using Dispatcher = R (*)(CallbackBase&); + Dispatcher dispatcher = reinterpret_cast(callback.mImpl->mMemberFunctionDispatcher); + returnVal = (*dispatcher)(callback); } - else if( !callback.mImpl && callback.mFunction ) + else if(!callback.mImpl && callback.mFunction) { - using Function1 = R ( * )(); - returnVal = (*(reinterpret_cast< Function1 >( callback.mFunction )))(); + using Function1 = R (*)(); + returnVal = (*(reinterpret_cast(callback.mFunction)))(); } return returnVal; @@ -127,24 +126,24 @@ public: * @param[in] callback The callback to call * @param[in] param1 The first parameter to pass into the function */ - template< typename P1 > - static void Execute( CallbackBase& callback, P1 param1 ) + template + static void Execute(CallbackBase& callback, P1 param1) { // if we point to a function, we can call it directly // otherwise call the dispatcher function that knows the real type of the object // Note that this template dispatcher lives in client code (where the callback was created) // so the library containing the code has to be loaded, otherwise we crash boom bang - if( callback.mImpl && callback.mImpl->mObjectPointer ) + if(callback.mImpl && callback.mImpl->mObjectPointer) { - using Dispatcher = void ( * )( CallbackBase&, P1 ); - Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher ); - (*dispatcher)( callback, param1 ); + using Dispatcher = void (*)(CallbackBase&, P1); + Dispatcher dispatcher = reinterpret_cast(callback.mImpl->mMemberFunctionDispatcher); + (*dispatcher)(callback, param1); } - else if( !callback.mImpl && callback.mFunction ) + else if(!callback.mImpl && callback.mFunction) { // convert function type - using Function1 = void ( * )( P1 ); - (*(reinterpret_cast< Function1 >( callback.mFunction )))( param1 ); + using Function1 = void (*)(P1); + (*(reinterpret_cast(callback.mFunction)))(param1); } } @@ -157,25 +156,25 @@ public: * @param[in] param1 The first parameter to pass into the function * @return The value from the function */ - template< typename R, typename P1 > - static R ExecuteReturn( CallbackBase& callback, P1 param1 ) + template + static R ExecuteReturn(CallbackBase& callback, P1 param1) { - R returnVal = R(); + R returnVal = R(); // if we point to a function, we can call it directly // otherwise call the dispatcher function that knows the real type of the object // Note that this template dispatcher lives in client code (where the callback was created) // so the library containing the code has to be loaded, otherwise we crash boom bang - if( callback.mImpl && callback.mImpl->mObjectPointer ) + if(callback.mImpl && callback.mImpl->mObjectPointer) { - using Dispatcher = R ( * )( CallbackBase&, P1 ); - Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher ); - returnVal = (*dispatcher)( callback, param1 ); + using Dispatcher = R (*)(CallbackBase&, P1); + Dispatcher dispatcher = reinterpret_cast(callback.mImpl->mMemberFunctionDispatcher); + returnVal = (*dispatcher)(callback, param1); } - else if( !callback.mImpl && callback.mFunction ) + else if(!callback.mImpl && callback.mFunction) { // convert function type - using Function1 = R ( * )( P1 ); - returnVal = (*(reinterpret_cast< Function1 >( callback.mFunction )))( param1 ); + using Function1 = R (*)(P1); + returnVal = (*(reinterpret_cast(callback.mFunction)))(param1); } return returnVal; @@ -190,24 +189,24 @@ public: * @param[in] param1 The first parameter to pass into the function * @param[in] param2 The second parameter to pass into the function */ - template< typename P1, typename P2 > - static void Execute( CallbackBase& callback, P1 param1, P2 param2 ) + template + static void Execute(CallbackBase& callback, P1 param1, P2 param2) { // if we point to a function, we can call it directly // otherwise call the dispatcher function that knows the real type of the object // Note that this template dispatcher lives in client code (where the callback was created) // so the library containing the code has to be loaded, otherwise we crash boom bang - if( callback.mImpl && callback.mImpl->mObjectPointer ) + if(callback.mImpl && callback.mImpl->mObjectPointer) { - using Dispatcher = void ( * )( CallbackBase&, P1, P2 ); - Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher ); - (*dispatcher)( callback, param1, param2 ); + using Dispatcher = void (*)(CallbackBase&, P1, P2); + Dispatcher dispatcher = reinterpret_cast(callback.mImpl->mMemberFunctionDispatcher); + (*dispatcher)(callback, param1, param2); } - else if( !callback.mImpl && callback.mFunction ) + else if(!callback.mImpl && callback.mFunction) { // convert function type - using Function2 = void ( * )( P1, P2 ); - (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2 ); + using Function2 = void (*)(P1, P2); + (*(reinterpret_cast(callback.mFunction)))(param1, param2); } } @@ -221,25 +220,25 @@ public: * @param[in] param2 The second parameter to pass into the function * @return The return value from the function */ - template< typename R, typename P1, typename P2 > - static R ExecuteReturn( CallbackBase& callback, P1 param1, P2 param2 ) + template + static R ExecuteReturn(CallbackBase& callback, P1 param1, P2 param2) { - R returnVal= R(); + R returnVal = R(); // if we point to a function, we can call it directly // otherwise call the dispatcher function that knows the real type of the object // Note that this template dispatcher lives in client code (where the callback was created) // so the library containing the code has to be loaded, otherwise we crash boom bang - if( callback.mImpl && callback.mImpl->mObjectPointer ) + if(callback.mImpl && callback.mImpl->mObjectPointer) { - using Dispatcher = R ( * )( CallbackBase&, P1, P2 ); - Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher ); - returnVal = (*dispatcher)( callback, param1, param2 ); + using Dispatcher = R (*)(CallbackBase&, P1, P2); + Dispatcher dispatcher = reinterpret_cast(callback.mImpl->mMemberFunctionDispatcher); + returnVal = (*dispatcher)(callback, param1, param2); } - else if( !callback.mImpl && callback.mFunction ) + else if(!callback.mImpl && callback.mFunction) { // convert function type - using Function2 = R ( * )( P1, P2 ); - returnVal = (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2 ); + using Function2 = R (*)(P1, P2); + returnVal = (*(reinterpret_cast(callback.mFunction)))(param1, param2); } return returnVal; @@ -255,24 +254,24 @@ public: * @param[in] param2 The second parameter to pass into the function * @param[in] param3 The third parameter to pass into the function */ - template< typename P1, typename P2, typename P3 > - static void Execute( CallbackBase& callback, P1 param1, P2 param2, P3 param3 ) + template + static void Execute(CallbackBase& callback, P1 param1, P2 param2, P3 param3) { // if we point to a function, we can call it directly // otherwise call the dispatcher function that knows the real type of the object // Note that this template dispatcher lives in client code (where the callback was created) // so the library containing the code has to be loaded, otherwise we crash boom bang - if( callback.mImpl && callback.mImpl->mObjectPointer ) + if(callback.mImpl && callback.mImpl->mObjectPointer) { - using Dispatcher = void ( * )( CallbackBase&, P1, P2, P3 ); - Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher ); - (*dispatcher)( callback, param1, param2, param3 ); + using Dispatcher = void (*)(CallbackBase&, P1, P2, P3); + Dispatcher dispatcher = reinterpret_cast(callback.mImpl->mMemberFunctionDispatcher); + (*dispatcher)(callback, param1, param2, param3); } - else if( !callback.mImpl && callback.mFunction ) + else if(!callback.mImpl && callback.mFunction) { // convert function type - using Function2 = void ( * )( P1, P2, P3 ); - (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2, param3 ); + using Function2 = void (*)(P1, P2, P3); + (*(reinterpret_cast(callback.mFunction)))(param1, param2, param3); } } @@ -287,62 +286,61 @@ public: * @param[in] param3 The third parameter to pass into the function * @return The return value from the function */ - template< typename R, typename P1, typename P2, typename P3 > - static R ExecuteReturn( CallbackBase& callback, P1 param1, P2 param2, P3 param3 ) + template + static R ExecuteReturn(CallbackBase& callback, P1 param1, P2 param2, P3 param3) { - R returnVal= R(); + R returnVal = R(); // if we point to a function, we can call it directly // otherwise call the dispatcher function that knows the real type of the object // Note that this template dispatcher lives in client code (where the callback was created) // so the library containing the code has to be loaded, otherwise we crash boom bang - if( callback.mImpl && callback.mImpl->mObjectPointer ) + if(callback.mImpl && callback.mImpl->mObjectPointer) { - using Dispatcher = R ( * )( CallbackBase&, P1, P2, P3 ); - Dispatcher dispatcher = reinterpret_cast< Dispatcher >( callback.mImpl->mMemberFunctionDispatcher ); - returnVal = (*dispatcher)( callback, param1, param2, param3 ); + using Dispatcher = R (*)(CallbackBase&, P1, P2, P3); + Dispatcher dispatcher = reinterpret_cast(callback.mImpl->mMemberFunctionDispatcher); + returnVal = (*dispatcher)(callback, param1, param2, param3); } - else if( !callback.mImpl && callback.mFunction ) + else if(!callback.mImpl && callback.mFunction) { // convert function type - using Function2 = R ( * )( P1, P2, P3 ); - returnVal = (*(reinterpret_cast< Function2 >( callback.mFunction )))( param1, param2, param3 ); + using Function2 = R (*)(P1, P2, P3); + returnVal = (*(reinterpret_cast(callback.mFunction)))(param1, param2, param3); } return returnVal; } protected: // Constructors for deriving classes - /** * @brief Function with static linkage. * @SINCE_1_0.0 */ - using Function = void ( * )(); + using Function = void (*)(); /** * @brief Member function. * @SINCE_1_0.0 */ - using MemberFunction = void ( CallbackBase::* )(); + using MemberFunction = void (CallbackBase::*)(); /** * @brief Used to call the correct member function. * @SINCE_1_0.0 */ - using Dispatcher = void ( * )( CallbackBase& ); + using Dispatcher = void (*)(CallbackBase&); /** * @brief Used to destroy mObjectPointer (NULL if not mObjectPointer is not owned). * @SINCE_1_0.0 */ - using Destructor = void ( * )( void* ); + using Destructor = void (*)(void*); /** * @brief Copy constructor operator not declared. * @SINCE_1_0.0 * @param[in] rhs Handle to an object */ - CallbackBase( const CallbackBase& rhs ); + CallbackBase(const CallbackBase& rhs); /** * @brief Assignment operator not declared. @@ -350,7 +348,7 @@ protected: // Constructors for deriving classes * @param[in] rhs Handle to an object * @return A reference to this */ - CallbackBase& operator=( const CallbackBase& rhs ); + CallbackBase& operator=(const CallbackBase& rhs); /** * @brief Constructor for function with static linkage. @@ -358,7 +356,7 @@ protected: // Constructors for deriving classes * @SINCE_1_0.0 * @param[in] function The function to call */ - CallbackBase( Function function ); + CallbackBase(Function function); /** * @brief Constructor for member function. @@ -368,7 +366,7 @@ protected: // Constructors for deriving classes * @param[in] function The member function of the object * @param[in] dispatcher Used to call the actual object */ - CallbackBase( void* object, MemberFunction function, Dispatcher dispatcher ); + CallbackBase(void* object, MemberFunction function, Dispatcher dispatcher); /** * @brief Constructor for member function. @@ -379,28 +377,27 @@ protected: // Constructors for deriving classes * @param dispatcher Used to call the actual object * @param destructor Used to delete the owned object */ - CallbackBase( void* object, MemberFunction function, Dispatcher dispatcher, Destructor destructor ); + CallbackBase(void* object, MemberFunction function, Dispatcher dispatcher, Destructor destructor); public: // Data for deriving classes & Dispatchers - /** * @brief Struct to hold the extra data needed for member functions. * @SINCE_1_0.0 */ struct Impl { - Impl(); ///< Default constructor @SINCE_1_0.0 + Impl(); ///< Default constructor @SINCE_1_0.0 - void* mObjectPointer; ///< Object whose member function will be called. Not owned if mDestructorDispatcher is NULL. + void* mObjectPointer; ///< Object whose member function will be called. Not owned if mDestructorDispatcher is NULL. Dispatcher mMemberFunctionDispatcher; ///< Dispatcher for member functions Destructor mDestructorDispatcher; ///< Destructor for owned objects. NULL if mDestructorDispatcher is not owned. }; - Impl* mImpl; ///< Implementation pointer + Impl* mImpl; ///< Implementation pointer union { - MemberFunction mMemberFunction; ///< Pointer to member function - Function mFunction; ///< Static function + MemberFunction mMemberFunction; ///< Pointer to member function + Function mFunction; ///< Static function }; }; @@ -411,13 +408,13 @@ public: // Data for deriving classes & Dispatchers * @param[in] rhs A reference to compare to * @return True if lhs is same as rhs */ -bool operator==( const CallbackBase& lhs, const CallbackBase& rhs ); +bool operator==(const CallbackBase& lhs, const CallbackBase& rhs); /** * @brief Dispatcher to delete an object. * @SINCE_1_0.0 */ -template< class T > +template struct Destroyer { /** @@ -425,11 +422,11 @@ struct Destroyer * @SINCE_1_0.0 * @param[in] object An object to delete */ - static void Delete( void* object ) + static void Delete(void* object) { // CallbackBase owns the object but we're the only one who knows the real type so need // to delete by "downcasting" from void* to the correct type - delete reinterpret_cast< T* >( object ); + delete reinterpret_cast(object); } }; @@ -437,7 +434,7 @@ struct Destroyer * @brief Dispatcher to call the actual member function. * @SINCE_1_0.0 */ -template< class T > +template struct Dispatcher0 { /** @@ -446,12 +443,12 @@ struct Dispatcher0 * @SINCE_1_0.0 * @param[in] callback The callback information */ - static void Dispatch( CallbackBase& callback ) + static void Dispatch(CallbackBase& callback) { // "downcast" the object and function type back to the correct ones - T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer ); - using MemberFunction = void ( T::* )(); - MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction ); + T* object = reinterpret_cast(callback.mImpl->mObjectPointer); + using MemberFunction = void (T::*)(); + MemberFunction function = reinterpret_cast(callback.mMemberFunction); (object->*function)(); } }; @@ -460,7 +457,7 @@ struct Dispatcher0 * @brief Dispatcher to call the actual member function. * @SINCE_1_0.0 */ -template< class T, typename P1 > +template struct Dispatcher1 { /** @@ -470,13 +467,13 @@ struct Dispatcher1 * @param[in] callback The callback information * @param[in] param1 The first parameter to pass to the real member function */ - static void Dispatch( CallbackBase& callback, P1 param1 ) + static void Dispatch(CallbackBase& callback, P1 param1) { // "downcast" the object and function type back to the correct ones - T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer ); - using MemberFunction = void ( T::* )( P1 ); - MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction ); - (object->*function)( param1 ); + T* object = reinterpret_cast(callback.mImpl->mObjectPointer); + using MemberFunction = void (T::*)(P1); + MemberFunction function = reinterpret_cast(callback.mMemberFunction); + (object->*function)(param1); } }; @@ -484,7 +481,7 @@ struct Dispatcher1 * @brief Dispatcher to call the actual member function. * @SINCE_1_0.0 */ -template< class T, typename P1, typename P2 > +template struct Dispatcher2 { /** @@ -495,13 +492,13 @@ struct Dispatcher2 * @param[in] param1 The first parameter to pass to the real member function * @param[in] param2 The second parameter to pass to the real member function */ - static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 ) + static void Dispatch(CallbackBase& callback, P1 param1, P2 param2) { // "downcast" the object and function type back to the correct ones - T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer ); - using MemberFunction = void ( T::* )( P1, P2 ); - MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction ); - (object->*function)( param1, param2 ); + T* object = reinterpret_cast(callback.mImpl->mObjectPointer); + using MemberFunction = void (T::*)(P1, P2); + MemberFunction function = reinterpret_cast(callback.mMemberFunction); + (object->*function)(param1, param2); } }; @@ -509,7 +506,7 @@ struct Dispatcher2 * @brief Dispatcher to call the actual member function. * @SINCE_1_0.0 */ -template< class T, typename P1, typename P2, typename P3 > +template struct Dispatcher3 { /** @@ -521,13 +518,13 @@ struct Dispatcher3 * @param[in] param2 The second parameter to pass to the real member function * @param[in] param3 The third parameter to pass to the real member function */ - static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 ) + static void Dispatch(CallbackBase& callback, P1 param1, P2 param2, P3 param3) { // "downcast" the object and function type back to the correct ones - T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer ); - using MemberFunction = void ( T::* )( P1, P2, P3 ); - MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction ); - (object->*function)( param1, param2, param3 ); + T* object = reinterpret_cast(callback.mImpl->mObjectPointer); + using MemberFunction = void (T::*)(P1, P2, P3); + MemberFunction function = reinterpret_cast(callback.mMemberFunction); + (object->*function)(param1, param2, param3); } }; @@ -535,7 +532,7 @@ struct Dispatcher3 * @brief Dispatcher to call the actual member function. * @SINCE_1_0.0 */ -template< class T, typename R > +template struct DispatcherReturn0 { /** @@ -545,12 +542,12 @@ struct DispatcherReturn0 * @param[in] callback The callback information * @return The value */ - static R Dispatch( CallbackBase& callback ) + static R Dispatch(CallbackBase& callback) { // "downcast" the object and function type back to the correct ones - T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer ); - using MemberFunction = R ( T::* )(); - MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction ); + T* object = reinterpret_cast(callback.mImpl->mObjectPointer); + using MemberFunction = R (T::*)(); + MemberFunction function = reinterpret_cast(callback.mMemberFunction); return (object->*function)(); } }; @@ -559,7 +556,7 @@ struct DispatcherReturn0 * @brief Dispatcher to call the actual member function. * @SINCE_1_0.0 */ -template< class T, typename R, typename P1 > +template struct DispatcherReturn1 { /** @@ -570,13 +567,13 @@ struct DispatcherReturn1 * @param[in] param1 The first parameter to pass to the real member function * @return The return value from the function */ - static R Dispatch( CallbackBase& callback, P1 param1 ) + static R Dispatch(CallbackBase& callback, P1 param1) { // "downcast" the object and function type back to the correct ones - T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer ); - using MemberFunction = R ( T::* )( P1 ); - MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction ); - return (object->*function)( param1 ); + T* object = reinterpret_cast(callback.mImpl->mObjectPointer); + using MemberFunction = R (T::*)(P1); + MemberFunction function = reinterpret_cast(callback.mMemberFunction); + return (object->*function)(param1); } }; @@ -584,7 +581,7 @@ struct DispatcherReturn1 * @brief Dispatcher to call the actual member function. * @SINCE_1_0.0 */ -template< class T, typename R, typename P1, typename P2 > +template struct DispatcherReturn2 { /** @@ -596,13 +593,13 @@ struct DispatcherReturn2 * @param[in] param2 The second parameter to pass to the real member function * @return The return value from the function */ - static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 ) + static R Dispatch(CallbackBase& callback, P1 param1, P2 param2) { // "downcast" the object and function type back to the correct ones - T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer ); - using MemberFunction = R ( T::* )( P1, P2 ); - MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction ); - return (object->*function)( param1, param2 ); + T* object = reinterpret_cast(callback.mImpl->mObjectPointer); + using MemberFunction = R (T::*)(P1, P2); + MemberFunction function = reinterpret_cast(callback.mMemberFunction); + return (object->*function)(param1, param2); } }; @@ -610,7 +607,7 @@ struct DispatcherReturn2 * @brief Dispatcher to call the actual member function. * @SINCE_1_0.0 */ -template< class T, typename R, typename P1, typename P2, typename P3 > +template struct DispatcherReturn3 { /** @@ -623,13 +620,13 @@ struct DispatcherReturn3 * @param[in] param3 The third parameter to pass to the real member function * @return The return value from the function */ - static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 ) + static R Dispatch(CallbackBase& callback, P1 param1, P2 param2, P3 param3) { // "downcast" the object and function type back to the correct ones - T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer ); - using MemberFunction = R ( T::* )( P1, P2, P3 ); - MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction ); - return (object->*function)( param1, param2, param3 ); + T* object = reinterpret_cast(callback.mImpl->mObjectPointer); + using MemberFunction = R (T::*)(P1, P2, P3); + MemberFunction function = reinterpret_cast(callback.mMemberFunction); + return (object->*function)(param1, param2, param3); } }; @@ -637,7 +634,7 @@ struct DispatcherReturn3 * @brief Dispatcher to call a functor. * @SINCE_1_0.0 */ -template< class T > +template struct FunctorDispatcher0 { /** @@ -646,10 +643,10 @@ struct FunctorDispatcher0 * @SINCE_1_0.0 * @param[in] callback The callback information */ - static void Dispatch( CallbackBase& callback ) + static void Dispatch(CallbackBase& callback) { // "downcast" the object and function type back to the correct ones - T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer ); + T* object = reinterpret_cast(callback.mImpl->mObjectPointer); (*object)(); } }; @@ -658,7 +655,7 @@ struct FunctorDispatcher0 * @brief Dispatcher to call a functor. * @SINCE_1_0.0 */ -template< class T, typename P1 > +template struct FunctorDispatcher1 { /** @@ -668,11 +665,11 @@ struct FunctorDispatcher1 * @param[in] callback The callback information * @param[in] param1 The first parameter to pass to the real member function. */ - static void Dispatch( CallbackBase& callback, P1 param1 ) + static void Dispatch(CallbackBase& callback, P1 param1) { // "downcast" the object and function type back to the correct ones - T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer ); - (*object)( param1 ); + T* object = reinterpret_cast(callback.mImpl->mObjectPointer); + (*object)(param1); } }; @@ -680,7 +677,7 @@ struct FunctorDispatcher1 * @brief Dispatcher to call a functor. * @SINCE_1_0.0 */ -template< class T, typename P1, typename P2 > +template struct FunctorDispatcher2 { /** @@ -691,11 +688,11 @@ struct FunctorDispatcher2 * @param[in] param1 The first parameter to pass to the real member function * @param[in] param2 The second parameter to pass to the real member function */ - static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 ) + static void Dispatch(CallbackBase& callback, P1 param1, P2 param2) { // "downcast" the object and function type back to the correct ones - T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer ); - (*object)( param1, param2 ); + T* object = reinterpret_cast(callback.mImpl->mObjectPointer); + (*object)(param1, param2); } }; @@ -703,7 +700,7 @@ struct FunctorDispatcher2 * @brief Dispatcher to call a functor. * @SINCE_1_0.0 */ -template< class T, typename P1, typename P2, typename P3 > +template struct FunctorDispatcher3 { /** @@ -715,11 +712,11 @@ struct FunctorDispatcher3 * @param[in] param2 The second parameter to pass to the real member function * @param[in] param3 The third parameter to pass to the real member function */ - static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 ) + static void Dispatch(CallbackBase& callback, P1 param1, P2 param2, P3 param3) { // "downcast" the object and function type back to the correct ones - T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer ); - (*object)( param1, param2, param3 ); + T* object = reinterpret_cast(callback.mImpl->mObjectPointer); + (*object)(param1, param2, param3); } }; @@ -727,7 +724,7 @@ struct FunctorDispatcher3 * @brief Dispatcher to call a functor. * @SINCE_1_0.0 */ -template< class T, typename R > +template struct FunctorDispatcherReturn0 { /** @@ -737,10 +734,10 @@ struct FunctorDispatcherReturn0 * @param[in] callback The callback information * @return The value */ - static R Dispatch( CallbackBase& callback ) + static R Dispatch(CallbackBase& callback) { // "downcast" the object and function type back to the correct ones - T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer ); + T* object = reinterpret_cast(callback.mImpl->mObjectPointer); return (*object)(); } }; @@ -749,7 +746,7 @@ struct FunctorDispatcherReturn0 * @brief Dispatcher to call a functor. * @SINCE_1_0.0 */ -template< class T, typename R, typename P1 > +template struct FunctorDispatcherReturn1 { /** @@ -760,11 +757,11 @@ struct FunctorDispatcherReturn1 * @param[in] param1 The first parameter to pass to the real member function * @return The return value from the function */ - static R Dispatch( CallbackBase& callback, P1 param1 ) + static R Dispatch(CallbackBase& callback, P1 param1) { // "downcast" the object and function type back to the correct ones - T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer ); - return (*object)( param1 ); + T* object = reinterpret_cast(callback.mImpl->mObjectPointer); + return (*object)(param1); } }; @@ -772,7 +769,7 @@ struct FunctorDispatcherReturn1 * @brief Dispatcher to call a functor. * @SINCE_1_0.0 */ -template< class T, typename R, typename P1, typename P2 > +template struct FunctorDispatcherReturn2 { /** @@ -784,11 +781,11 @@ struct FunctorDispatcherReturn2 * @param[in] param2 The second parameter to pass to the real member function * @return The return value from the function */ - static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 ) + static R Dispatch(CallbackBase& callback, P1 param1, P2 param2) { // "downcast" the object and function type back to the correct ones - T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer ); - return (*object)( param1, param2 ); + T* object = reinterpret_cast(callback.mImpl->mObjectPointer); + return (*object)(param1, param2); } }; @@ -796,7 +793,7 @@ struct FunctorDispatcherReturn2 * @brief Dispatcher to call a functor. * @SINCE_1_0.0 */ -template< class T, typename R, typename P1, typename P2, typename P3 > +template struct FunctorDispatcherReturn3 { /** @@ -809,11 +806,11 @@ struct FunctorDispatcherReturn3 * @param[in] param3 The third parameter to pass to the real member function * @return The return value from the function */ - static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 ) + static R Dispatch(CallbackBase& callback, P1 param1, P2 param2, P3 param3) { // "downcast" the object and function type back to the correct ones - T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer ); - return (*object)( param1, param2, param3 ); + T* object = reinterpret_cast(callback.mImpl->mObjectPointer); + return (*object)(param1, param2, param3); } }; @@ -823,7 +820,7 @@ struct FunctorDispatcherReturn3 * This variant calls a specific void() member function. * @SINCE_1_0.0 */ -template< class T > +template struct VoidFunctorDispatcher0 { /** @@ -832,12 +829,12 @@ struct VoidFunctorDispatcher0 * @SINCE_1_0.0 * @param[in] callback The callback information */ - static void Dispatch( CallbackBase& callback ) + static void Dispatch(CallbackBase& callback) { // "downcast" the object and function type back to the correct ones - T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer ); - using MemberFunction = void ( T::* )(); - MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction ); + T* object = reinterpret_cast(callback.mImpl->mObjectPointer); + using MemberFunction = void (T::*)(); + MemberFunction function = reinterpret_cast(callback.mMemberFunction); (object->*function)(); } }; @@ -848,7 +845,7 @@ struct VoidFunctorDispatcher0 * This variant calls a void() member, ignoring any signal parameters. * @SINCE_1_0.0 */ -template< class T, typename P1 > +template struct VoidFunctorDispatcher1 { /** @@ -858,12 +855,12 @@ struct VoidFunctorDispatcher1 * @param[in] callback The callback information * @param[in] param1 The first parameter to pass to the real member function */ - static void Dispatch( CallbackBase& callback, P1 param1 ) + static void Dispatch(CallbackBase& callback, P1 param1) { // "downcast" the object and function type back to the correct ones - T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer ); - using MemberFunction = void ( T::* )(); - MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction ); + T* object = reinterpret_cast(callback.mImpl->mObjectPointer); + using MemberFunction = void (T::*)(); + MemberFunction function = reinterpret_cast(callback.mMemberFunction); (object->*function)(/*ignore params*/); } }; @@ -874,7 +871,7 @@ struct VoidFunctorDispatcher1 * This variant calls a void() member, ignoring any signal parameters. * @SINCE_1_0.0 */ -template< class T, typename P1, typename P2 > +template struct VoidFunctorDispatcher2 { /** @@ -885,12 +882,12 @@ struct VoidFunctorDispatcher2 * @param[in] param1 The first parameter to pass to the real member function * @param[in] param2 The second parameter to pass to the real member function */ - static void Dispatch( CallbackBase& callback, P1 param1, P2 param2 ) + static void Dispatch(CallbackBase& callback, P1 param1, P2 param2) { // "downcast" the object and function type back to the correct ones - T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer ); - using MemberFunction = void ( T::* )(); - MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction ); + T* object = reinterpret_cast(callback.mImpl->mObjectPointer); + using MemberFunction = void (T::*)(); + MemberFunction function = reinterpret_cast(callback.mMemberFunction); (object->*function)(/*ignore params*/); } }; @@ -901,7 +898,7 @@ struct VoidFunctorDispatcher2 * This variant calls a void() member, ignoring any signal parameters. * @SINCE_1_0.0 */ -template< class T, typename P1, typename P2, typename P3 > +template struct VoidFunctorDispatcher3 { /** @@ -913,12 +910,12 @@ struct VoidFunctorDispatcher3 * @param[in] param2 The second parameter to pass to the real member function * @param[in] param3 The third parameter to pass to the real member function */ - static void Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 ) + static void Dispatch(CallbackBase& callback, P1 param1, P2 param2, P3 param3) { // "downcast" the object and function type back to the correct ones - T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer ); - using MemberFunction = void ( T::* )(); - MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction ); + T* object = reinterpret_cast(callback.mImpl->mObjectPointer); + using MemberFunction = void (T::*)(); + MemberFunction function = reinterpret_cast(callback.mMemberFunction); (object->*function)(/*ignore params*/); } }; @@ -929,7 +926,7 @@ struct VoidFunctorDispatcher3 * This variant calls a void() member, and returns a default-constructed value. * @SINCE_1_0.0 */ -template< class T, typename R > +template struct VoidFunctorDispatcherReturn0 { /** @@ -939,12 +936,12 @@ struct VoidFunctorDispatcherReturn0 * @param[in] callback The callback information * @return The value */ - static R Dispatch( CallbackBase& callback ) + static R Dispatch(CallbackBase& callback) { // "downcast" the object and function type back to the correct ones - T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer ); - using MemberFunction = void ( T::* )(); - MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction ); + T* object = reinterpret_cast(callback.mImpl->mObjectPointer); + using MemberFunction = void (T::*)(); + MemberFunction function = reinterpret_cast(callback.mMemberFunction); (object->*function)(/*ignore params*/); return R(); } @@ -956,7 +953,7 @@ struct VoidFunctorDispatcherReturn0 * This variant calls a void() member, and returns a default-constructed value. * @SINCE_1_0.0 */ -template< class T, typename R, typename P1 > +template struct VoidFunctorDispatcherReturn1 { /** @@ -967,12 +964,12 @@ struct VoidFunctorDispatcherReturn1 * @param[in] param1 The first parameter to pass to the real member function * @return The return value from the function */ - static R Dispatch( CallbackBase& callback, P1 param1 ) + static R Dispatch(CallbackBase& callback, P1 param1) { // "downcast" the object and function type back to the correct ones - T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer ); - using MemberFunction = void ( T::* )(); - MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction ); + T* object = reinterpret_cast(callback.mImpl->mObjectPointer); + using MemberFunction = void (T::*)(); + MemberFunction function = reinterpret_cast(callback.mMemberFunction); (object->*function)(/*ignore params*/); return R(); } @@ -984,7 +981,7 @@ struct VoidFunctorDispatcherReturn1 * This variant calls a void() member, and returns a default-constructed value. * @SINCE_1_0.0 */ -template< class T, typename R, typename P1, typename P2 > +template struct VoidFunctorDispatcherReturn2 { /** @@ -996,12 +993,12 @@ struct VoidFunctorDispatcherReturn2 * @param[in] param2 The second parameter to pass to the real member function * @return The return value from the function */ - static R Dispatch( CallbackBase& callback, P1 param1, P2 param2 ) + static R Dispatch(CallbackBase& callback, P1 param1, P2 param2) { // "downcast" the object and function type back to the correct ones - T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer ); - using MemberFunction = void ( T::* )(); - MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction ); + T* object = reinterpret_cast(callback.mImpl->mObjectPointer); + using MemberFunction = void (T::*)(); + MemberFunction function = reinterpret_cast(callback.mMemberFunction); (object->*function)(/*ignore params*/); return R(); } @@ -1013,7 +1010,7 @@ struct VoidFunctorDispatcherReturn2 * This variant calls a void() member, and returns a default-constructed value. * @SINCE_1_0.0 */ -template< class T, typename R, typename P1, typename P2, typename P3 > +template struct VoidFunctorDispatcherReturn3 { /** @@ -1026,12 +1023,12 @@ struct VoidFunctorDispatcherReturn3 * @param[in] param3 The third parameter to pass to the real member function * @return The return value from the function */ - static R Dispatch( CallbackBase& callback, P1 param1, P2 param2, P3 param3 ) + static R Dispatch(CallbackBase& callback, P1 param1, P2 param2, P3 param3) { // "downcast" the object and function type back to the correct ones - T* object = reinterpret_cast< T* >( callback.mImpl->mObjectPointer ); - using MemberFunction = void ( T::* )(); - MemberFunction function = reinterpret_cast< MemberFunction >( callback.mMemberFunction ); + T* object = reinterpret_cast(callback.mImpl->mObjectPointer); + using MemberFunction = void (T::*)(); + MemberFunction function = reinterpret_cast(callback.mMemberFunction); (object->*function)(/*ignore params*/); return R(); } @@ -1043,11 +1040,10 @@ struct VoidFunctorDispatcherReturn3 * Version with two parameters and return value. * @SINCE_1_0.0 */ -template< class T > +template class Callback : public CallbackBase { public: - /** * @brief Default constructor. * @@ -1066,46 +1062,61 @@ public: * @param[in] object The object to call * @param[in] memberFunction The member function of the object */ - Callback( T* object, void(T::*memberFunction)(void) ) - : CallbackBase( object, - reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ), - reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher0::Dispatch ) ) { } - template< typename P1 > - Callback( T* object, void(T::*memberFunction)(P1) ) - : CallbackBase( object, - reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ), - reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher1::Dispatch ) ) { } - template< typename P1, typename P2 > - Callback( T* object, void(T::*memberFunction)(P1, P2) ) - : CallbackBase( object, - reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ), - reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher2::Dispatch ) ) { } - template< typename P1, typename P2, typename P3 > - Callback( T* object, void(T::*memberFunction)(P1, P2, P3) ) - : CallbackBase( object, - reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ), - reinterpret_cast< CallbackBase::Dispatcher >( &Dispatcher3::Dispatch ) ) { } - template< typename R > - Callback( T* object, R(T::*memberFunction)(void) ) - : CallbackBase( object, - reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ), - reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn0::Dispatch ) ) { } - template< typename R, typename P1 > - Callback( T* object, R(T::*memberFunction)(P1) ) - : CallbackBase( object, - reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ), - reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn1::Dispatch ) ) { } - template< typename R, typename P1, typename P2 > - Callback( T* object, R(T::*memberFunction)(P1, P2) ) - : CallbackBase( object, - reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ), - reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn2::Dispatch ) ) { } - template< typename R, typename P1, typename P2, typename P3 > - Callback( T* object, R(T::*memberFunction)(P1, P2, P3) ) - : CallbackBase( object, - reinterpret_cast< CallbackBase::MemberFunction >( memberFunction ), - reinterpret_cast< CallbackBase::Dispatcher >( &DispatcherReturn3::Dispatch ) ) { } - + Callback(T* object, void (T::*memberFunction)(void)) + : CallbackBase(object, + reinterpret_cast(memberFunction), + reinterpret_cast(&Dispatcher0::Dispatch)) + { + } + template + Callback(T* object, void (T::*memberFunction)(P1)) + : CallbackBase(object, + reinterpret_cast(memberFunction), + reinterpret_cast(&Dispatcher1::Dispatch)) + { + } + template + Callback(T* object, void (T::*memberFunction)(P1, P2)) + : CallbackBase(object, + reinterpret_cast(memberFunction), + reinterpret_cast(&Dispatcher2::Dispatch)) + { + } + template + Callback(T* object, void (T::*memberFunction)(P1, P2, P3)) + : CallbackBase(object, + reinterpret_cast(memberFunction), + reinterpret_cast(&Dispatcher3::Dispatch)) + { + } + template + Callback(T* object, R (T::*memberFunction)(void)) + : CallbackBase(object, + reinterpret_cast(memberFunction), + reinterpret_cast(&DispatcherReturn0::Dispatch)) + { + } + template + Callback(T* object, R (T::*memberFunction)(P1)) + : CallbackBase(object, + reinterpret_cast(memberFunction), + reinterpret_cast(&DispatcherReturn1::Dispatch)) + { + } + template + Callback(T* object, R (T::*memberFunction)(P1, P2)) + : CallbackBase(object, + reinterpret_cast(memberFunction), + reinterpret_cast(&DispatcherReturn2::Dispatch)) + { + } + template + Callback(T* object, R (T::*memberFunction)(P1, P2, P3)) + : CallbackBase(object, + reinterpret_cast(memberFunction), + reinterpret_cast(&DispatcherReturn3::Dispatch)) + { + } }; /** @@ -1115,7 +1126,6 @@ public: class CallbackFunction : public CallbackBase { public: - /** * @brief Default constructor. * @SINCE_1_0.0 @@ -1131,60 +1141,68 @@ public: * @SINCE_1_0.0 * @param[in] function The function to call */ - CallbackFunction( void(*function)() ) - : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) ) - { } - template< typename R > - CallbackFunction( R(*function)() ) - : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) ) - { } - template< typename P1 > - CallbackFunction( void(*function)(P1) ) - : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) ) - { } - template< typename P1, typename R > - CallbackFunction( R(*function)(P1) ) - : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) ) - { } - template< typename P1, typename P2 > - CallbackFunction( void(*function)(P1,P2) ) - : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) ) - { } - template< typename P1, typename P2, typename R > - CallbackFunction( R(*function)(P1,P2) ) - : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) ) - { } - template< typename P1, typename P2, typename P3 > - CallbackFunction( void(*function)(P1,P2,P3) ) - : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) ) - { } - template< typename P1, typename P2, typename P3, typename R > - CallbackFunction( R(*function)(P1,P2,P3) ) - : CallbackBase( reinterpret_cast< CallbackBase::Function >( function ) ) - { } - + CallbackFunction(void (*function)()) + : CallbackBase(reinterpret_cast(function)) + { + } + template + CallbackFunction(R (*function)()) + : CallbackBase(reinterpret_cast(function)) + { + } + template + CallbackFunction(void (*function)(P1)) + : CallbackBase(reinterpret_cast(function)) + { + } + template + CallbackFunction(R (*function)(P1)) + : CallbackBase(reinterpret_cast(function)) + { + } + template + CallbackFunction(void (*function)(P1, P2)) + : CallbackBase(reinterpret_cast(function)) + { + } + template + CallbackFunction(R (*function)(P1, P2)) + : CallbackBase(reinterpret_cast(function)) + { + } + template + CallbackFunction(void (*function)(P1, P2, P3)) + : CallbackBase(reinterpret_cast(function)) + { + } + template + CallbackFunction(R (*function)(P1, P2, P3)) + : CallbackBase(reinterpret_cast(function)) + { + } }; /** * @brief Specializations for function object callbacks. * @SINCE_1_0.0 */ -template< class T > +template class CallbackFunctor0 : public CallbackBase { public: - /** * @brief Constructor which copies a function object. * * @SINCE_1_0.0 * @param[in] object The object to copy */ - CallbackFunctor0( const T& object ) - : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object - NULL, // uses operator() instead of member function - reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher0::Dispatch ), - reinterpret_cast< CallbackBase::Destructor >( &Destroyer::Delete ) ) { } + CallbackFunctor0(const T& object) + : CallbackBase(reinterpret_cast(new T(object)), // copy the object + NULL, // uses operator() instead of member function + reinterpret_cast(&FunctorDispatcher0::Dispatch), + reinterpret_cast(&Destroyer::Delete)) + { + } }; /** @@ -1194,7 +1212,6 @@ public: class CallbackFunctorDelegate0 : public CallbackBase { public: - /** * @brief Constructor which copies a function object. * @@ -1202,44 +1219,46 @@ public: * @SINCE_1_0.0 * @param[in] object A newly allocated object (ownership is transferred) */ - CallbackFunctorDelegate0( FunctorDelegate* object ) - : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership - reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ), - reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher0::Dispatch ), - reinterpret_cast< CallbackBase::Destructor >( &Destroyer::Delete ) ) { } + CallbackFunctorDelegate0(FunctorDelegate* object) + : CallbackBase(reinterpret_cast(object), // transfer ownership + reinterpret_cast(&FunctorDelegate::Execute), + reinterpret_cast(&VoidFunctorDispatcher0::Dispatch), + reinterpret_cast(&Destroyer::Delete)) + { + } }; /** * @brief Function object callback for matching callbacks to signal signature. * @SINCE_1_0.0 */ -template< class T, typename P1 > +template class CallbackFunctor1 : public CallbackBase { public: - /** * @brief Constructor which copies a function object. * * @SINCE_1_0.0 * @param[in] object The object to copy */ - CallbackFunctor1( const T& object ) - : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object - NULL, // uses operator() instead of member function - reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher1::Dispatch ), - reinterpret_cast< CallbackBase::Destructor >( &Destroyer::Delete ) ) { } + CallbackFunctor1(const T& object) + : CallbackBase(reinterpret_cast(new T(object)), // copy the object + NULL, // uses operator() instead of member function + reinterpret_cast(&FunctorDispatcher1::Dispatch), + reinterpret_cast(&Destroyer::Delete)) + { + } }; /** * @brief Function object callback for connecting void() methods. * @SINCE_1_0.0 */ -template< typename P1 > +template class CallbackFunctorDelegate1 : public CallbackBase { public: - /** * @brief Constructor which copies a function object. * @@ -1247,44 +1266,46 @@ public: * @SINCE_1_0.0 * @param[in] object The object to copy */ - CallbackFunctorDelegate1( FunctorDelegate* object ) - : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership - reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ), - reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher1::Dispatch ), - reinterpret_cast< CallbackBase::Destructor >( &Destroyer::Delete ) ) { } + CallbackFunctorDelegate1(FunctorDelegate* object) + : CallbackBase(reinterpret_cast(object), // transfer ownership + reinterpret_cast(&FunctorDelegate::Execute), + reinterpret_cast(&VoidFunctorDispatcher1::Dispatch), + reinterpret_cast(&Destroyer::Delete)) + { + } }; /** * @brief Function object callback for matching callbacks to signal signature. * @SINCE_1_0.0 */ -template< class T, typename P1, typename P2 > +template class CallbackFunctor2 : public CallbackBase { public: - /** * @brief Constructor which copies a function object. * * @SINCE_1_0.0 * @param[in] object The object to copy */ - CallbackFunctor2( const T& object ) - : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object - NULL, // uses operator() instead of member function - reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher2::Dispatch ), - reinterpret_cast< CallbackBase::Destructor >( &Destroyer::Delete ) ) { } + CallbackFunctor2(const T& object) + : CallbackBase(reinterpret_cast(new T(object)), // copy the object + NULL, // uses operator() instead of member function + reinterpret_cast(&FunctorDispatcher2::Dispatch), + reinterpret_cast(&Destroyer::Delete)) + { + } }; /** * @brief Function object callback for connecting void() methods. * @SINCE_1_0.0 */ -template< typename P1, typename P2 > +template class CallbackFunctorDelegate2 : public CallbackBase { public: - /** * @brief Constructor which copies a function object. * @@ -1292,45 +1313,46 @@ public: * @SINCE_1_0.0 * @param[in] object The object to copy */ - CallbackFunctorDelegate2( FunctorDelegate* object ) - : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership - reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ), - reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher2::Dispatch ), - reinterpret_cast< CallbackBase::Destructor >( &Destroyer::Delete ) ) { } + CallbackFunctorDelegate2(FunctorDelegate* object) + : CallbackBase(reinterpret_cast(object), // transfer ownership + reinterpret_cast(&FunctorDelegate::Execute), + reinterpret_cast(&VoidFunctorDispatcher2::Dispatch), + reinterpret_cast(&Destroyer::Delete)) + { + } }; /** * @brief Function object callback for matching callbacks to signal signature. * @SINCE_1_0.0 */ -template< class T, typename P1, typename P2, typename P3 > +template class CallbackFunctor3 : public CallbackBase { public: - /** * @brief Constructor which copies a function object. * * @SINCE_1_0.0 * @param[in] object The object to copy */ - CallbackFunctor3( const T& object ) - : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object - NULL, // uses operator() instead of member function - reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcher3::Dispatch ), - reinterpret_cast< CallbackBase::Destructor >( &Destroyer::Delete ) ) { } + CallbackFunctor3(const T& object) + : CallbackBase(reinterpret_cast(new T(object)), // copy the object + NULL, // uses operator() instead of member function + reinterpret_cast(&FunctorDispatcher3::Dispatch), + reinterpret_cast(&Destroyer::Delete)) + { + } }; /** * @brief Function object callback for connecting void() methods. * @SINCE_1_0.0 */ -template< typename P1, typename P2, typename P3 > +template class CallbackFunctorDelegate3 : public CallbackBase { public: - - /** * @brief Constructor which copies a function object. * @@ -1338,44 +1360,46 @@ public: * @SINCE_1_0.0 * @param[in] object The object to copy */ - CallbackFunctorDelegate3( FunctorDelegate* object ) - : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership - reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ), - reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcher3::Dispatch ), - reinterpret_cast< CallbackBase::Destructor >( &Destroyer::Delete ) ) { } + CallbackFunctorDelegate3(FunctorDelegate* object) + : CallbackBase(reinterpret_cast(object), // transfer ownership + reinterpret_cast(&FunctorDelegate::Execute), + reinterpret_cast(&VoidFunctorDispatcher3::Dispatch), + reinterpret_cast(&Destroyer::Delete)) + { + } }; /** * @brief Function object callback for matching callbacks to signal signature. * @SINCE_1_0.0 */ -template< class T, typename R > +template class CallbackFunctorReturn0 : public CallbackBase { public: - /** * @brief Constructor which copies a function object. * * @SINCE_1_0.0 * @param[in] object The object to copy */ - CallbackFunctorReturn0( const T& object ) - : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object - NULL, // uses operator() instead of member function - reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn0::Dispatch ), - reinterpret_cast< CallbackBase::Destructor >( &Destroyer::Delete ) ) { } + CallbackFunctorReturn0(const T& object) + : CallbackBase(reinterpret_cast(new T(object)), // copy the object + NULL, // uses operator() instead of member function + reinterpret_cast(&FunctorDispatcherReturn0::Dispatch), + reinterpret_cast(&Destroyer::Delete)) + { + } }; /** * @brief Function object callback for connecting void() methods. * @SINCE_1_0.0 */ -template< typename R > +template class CallbackFunctorDelegateReturn0 : public CallbackBase { public: - /** * @brief Constructor which copies a function object. * @@ -1383,44 +1407,46 @@ public: * @SINCE_1_0.0 * @param[in] object The object to copy */ - CallbackFunctorDelegateReturn0( FunctorDelegate* object ) - : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership - reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ), - reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn0::Dispatch ), - reinterpret_cast< CallbackBase::Destructor >( &Destroyer::Delete ) ) { } + CallbackFunctorDelegateReturn0(FunctorDelegate* object) + : CallbackBase(reinterpret_cast(object), // transfer ownership + reinterpret_cast(&FunctorDelegate::Execute), + reinterpret_cast(&VoidFunctorDispatcherReturn0::Dispatch), + reinterpret_cast(&Destroyer::Delete)) + { + } }; /** * @brief Function object callback for matching callbacks to signal signature. * @SINCE_1_0.0 */ -template< class T, typename P1, typename R > +template class CallbackFunctorReturn1 : public CallbackBase { public: - /** * @brief Constructor which copies a function object. * * @SINCE_1_0.0 * @param[in] object The object to copy */ - CallbackFunctorReturn1( const T& object ) - : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object - NULL, // uses operator() instead of member function - reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn1::Dispatch ), - reinterpret_cast< CallbackBase::Destructor >( &Destroyer::Delete ) ) { } + CallbackFunctorReturn1(const T& object) + : CallbackBase(reinterpret_cast(new T(object)), // copy the object + NULL, // uses operator() instead of member function + reinterpret_cast(&FunctorDispatcherReturn1::Dispatch), + reinterpret_cast(&Destroyer::Delete)) + { + } }; /** * @brief Function object callback for connecting void() methods. * @SINCE_1_0.0 */ -template< typename P1, typename R > +template class CallbackFunctorDelegateReturn1 : public CallbackBase { public: - /** * @brief Constructor which copies a function object. * @@ -1428,44 +1454,46 @@ public: * @SINCE_1_0.0 * @param[in] object The object to copy */ - CallbackFunctorDelegateReturn1( FunctorDelegate* object ) - : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership - reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ), - reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn1::Dispatch ), - reinterpret_cast< CallbackBase::Destructor >( &Destroyer::Delete ) ) { } + CallbackFunctorDelegateReturn1(FunctorDelegate* object) + : CallbackBase(reinterpret_cast(object), // transfer ownership + reinterpret_cast(&FunctorDelegate::Execute), + reinterpret_cast(&VoidFunctorDispatcherReturn1::Dispatch), + reinterpret_cast(&Destroyer::Delete)) + { + } }; /** * @brief Function object callback for matching callbacks to signal signature. * @SINCE_1_0.0 */ -template< class T, typename P1, typename P2, typename R > +template class CallbackFunctorReturn2 : public CallbackBase { public: - /** * @brief Constructor which copies a function object. * * @SINCE_1_0.0 * @param[in] object The object to copy */ - CallbackFunctorReturn2( const T& object ) - : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object - NULL, // uses operator() instead of member function - reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn2::Dispatch ), - reinterpret_cast< CallbackBase::Destructor >( &Destroyer::Delete ) ) { } + CallbackFunctorReturn2(const T& object) + : CallbackBase(reinterpret_cast(new T(object)), // copy the object + NULL, // uses operator() instead of member function + reinterpret_cast(&FunctorDispatcherReturn2::Dispatch), + reinterpret_cast(&Destroyer::Delete)) + { + } }; /** * @brief Function object callback for connecting void() methods. * @SINCE_1_0.0 */ -template< typename P1, typename P2, typename R > +template class CallbackFunctorDelegateReturn2 : public CallbackBase { public: - /** * @brief Constructor which copies a function object. * @@ -1473,44 +1501,46 @@ public: * @SINCE_1_0.0 * @param[in] object The object to copy */ - CallbackFunctorDelegateReturn2( FunctorDelegate* object ) - : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership - reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ), - reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn2::Dispatch ), - reinterpret_cast< CallbackBase::Destructor >( &Destroyer::Delete ) ) { } + CallbackFunctorDelegateReturn2(FunctorDelegate* object) + : CallbackBase(reinterpret_cast(object), // transfer ownership + reinterpret_cast(&FunctorDelegate::Execute), + reinterpret_cast(&VoidFunctorDispatcherReturn2::Dispatch), + reinterpret_cast(&Destroyer::Delete)) + { + } }; /** * @brief Function object callback for matching callbacks to signal signature. * @SINCE_1_0.0 */ -template< class T, typename P1, typename P2, typename P3, typename R > +template class CallbackFunctorReturn3 : public CallbackBase { public: - /** * @brief Constructor which copies a function object. * * @SINCE_1_0.0 * @param[in] object The object to copy */ - CallbackFunctorReturn3( const T& object ) - : CallbackBase( reinterpret_cast< void* >( new T( object ) ), // copy the object - NULL, // uses operator() instead of member function - reinterpret_cast< CallbackBase::Dispatcher >( &FunctorDispatcherReturn3::Dispatch ), - reinterpret_cast< CallbackBase::Destructor >( &Destroyer::Delete ) ) { } + CallbackFunctorReturn3(const T& object) + : CallbackBase(reinterpret_cast(new T(object)), // copy the object + NULL, // uses operator() instead of member function + reinterpret_cast(&FunctorDispatcherReturn3::Dispatch), + reinterpret_cast(&Destroyer::Delete)) + { + } }; /** * @brief Function object callback for connecting void() methods. * @SINCE_1_0.0 */ -template< typename P1, typename P2, typename P3, typename R > +template class CallbackFunctorDelegateReturn3 : public CallbackBase { public: - /** * @brief Constructor which copies a function object. * @@ -1518,11 +1548,13 @@ public: * @SINCE_1_0.0 * @param[in] object The object to copy */ - CallbackFunctorDelegateReturn3( FunctorDelegate* object ) - : CallbackBase( reinterpret_cast< void* >( object ), // transfer ownership - reinterpret_cast< CallbackBase::MemberFunction >( &FunctorDelegate::Execute ), - reinterpret_cast< CallbackBase::Dispatcher >( &VoidFunctorDispatcherReturn3::Dispatch ), - reinterpret_cast< CallbackBase::Destructor >( &Destroyer::Delete ) ) { } + CallbackFunctorDelegateReturn3(FunctorDelegate* object) + : CallbackBase(reinterpret_cast(object), // transfer ownership + reinterpret_cast(&FunctorDelegate::Execute), + reinterpret_cast(&VoidFunctorDispatcherReturn3::Dispatch), + reinterpret_cast(&Destroyer::Delete)) + { + } }; // Callback creation thin templates @@ -1534,9 +1566,9 @@ public: * @param[in] function The function to call * @return A newly allocated Callback object, ownership transferred to caller */ -inline CallbackBase* MakeCallback( void(*function)(void) ) +inline CallbackBase* MakeCallback(void (*function)(void)) { - return new CallbackFunction( function ); + return new CallbackFunction(function); } /** @@ -1546,10 +1578,10 @@ inline CallbackBase* MakeCallback( void(*function)(void) ) * @param[in] function The function to call * @return A newly allocated Callback object, ownership transferred to caller */ -template< typename P1 > -inline CallbackBase* MakeCallback( void(*function)(P1) ) +template +inline CallbackBase* MakeCallback(void (*function)(P1)) { - return new CallbackFunction( function ); + return new CallbackFunction(function); } /** @@ -1559,10 +1591,10 @@ inline CallbackBase* MakeCallback( void(*function)(P1) ) * @param[in] function The function to call * @return A newly allocated Callback object, ownership transferred to caller */ -template< typename R > -inline CallbackBase* MakeCallback( R(*function)(void) ) +template +inline CallbackBase* MakeCallback(R (*function)(void)) { - return new CallbackFunction( function ); + return new CallbackFunction(function); } /** @@ -1572,10 +1604,10 @@ inline CallbackBase* MakeCallback( R(*function)(void) ) * @param[in] function The function to call * @return A newly allocated Callback object, ownership transferred to caller */ -template< typename R, typename P1 > -inline CallbackBase* MakeCallback( R(*function)(P1) ) +template +inline CallbackBase* MakeCallback(R (*function)(P1)) { - return new CallbackFunction( function ); + return new CallbackFunction(function); } /** @@ -1585,10 +1617,10 @@ inline CallbackBase* MakeCallback( R(*function)(P1) ) * @param[in] function The function to call * @return A newly allocated Callback object, ownership transferred to caller */ -template< typename P1, typename P2 > -inline CallbackBase* MakeCallback( void(*function)(P1,P2) ) +template +inline CallbackBase* MakeCallback(void (*function)(P1, P2)) { - return new CallbackFunction( function ); + return new CallbackFunction(function); } /** @@ -1598,10 +1630,10 @@ inline CallbackBase* MakeCallback( void(*function)(P1,P2) ) * @param[in] function The function to call * @return A newly allocated Callback object, ownership transferred to caller */ -template< typename R, typename P1, typename P2 > -inline CallbackBase* MakeCallback( R(*function)(P1,P2) ) +template +inline CallbackBase* MakeCallback(R (*function)(P1, P2)) { - return new CallbackFunction( function ); + return new CallbackFunction(function); } /** @@ -1611,10 +1643,10 @@ inline CallbackBase* MakeCallback( R(*function)(P1,P2) ) * @param[in] function The function to call * @return A newly allocated Callback object, ownership transferred to caller */ -template< typename P1, typename P2, typename P3 > -inline CallbackBase* MakeCallback( void(*function)(P1,P2,P3) ) +template +inline CallbackBase* MakeCallback(void (*function)(P1, P2, P3)) { - return new CallbackFunction( function ); + return new CallbackFunction(function); } /** @@ -1624,10 +1656,10 @@ inline CallbackBase* MakeCallback( void(*function)(P1,P2,P3) ) * @param[in] function The function to call * @return A newly allocated Callback object, ownership transferred to caller */ -template< typename R, typename P1, typename P2, typename P3 > -inline CallbackBase* MakeCallback( R(*function)(P1,P2,P3) ) +template +inline CallbackBase* MakeCallback(R (*function)(P1, P2, P3)) { - return new CallbackFunction( function ); + return new CallbackFunction(function); } /** @@ -1639,10 +1671,10 @@ inline CallbackBase* MakeCallback( R(*function)(P1,P2,P3) ) * @param[in] function The member function to call * @return A newly allocated Callback object, ownership transferred to caller */ -template< class T > -inline CallbackBase* MakeCallback( T* object, void(T::*function)(void) ) +template +inline CallbackBase* MakeCallback(T* object, void (T::*function)(void)) { - return new Callback< T >( object, function ); + return new Callback(object, function); } /** @@ -1654,10 +1686,10 @@ inline CallbackBase* MakeCallback( T* object, void(T::*function)(void) ) * @param[in] function The member function to call * @return A newly allocated Callback object, ownership transferred to caller */ -template< class T, typename P1 > -inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1) ) +template +inline CallbackBase* MakeCallback(T* object, void (T::*function)(P1)) { - return new Callback< T >( object, function ); + return new Callback(object, function); } /** @@ -1669,10 +1701,10 @@ inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1) ) * @param[in] function The member function to call * @return A newly allocated Callback object, ownership transferred to caller */ -template< class T, typename P1, typename P2 > -inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1,P2) ) +template +inline CallbackBase* MakeCallback(T* object, void (T::*function)(P1, P2)) { - return new Callback< T >( object, function ); + return new Callback(object, function); } /** @@ -1684,10 +1716,10 @@ inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1,P2) ) * @param[in] function The member function to call * @return A newly allocated Callback object, ownership transferred to caller */ -template< class T, typename P1, typename P2, typename P3 > -inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1,P2,P3) ) +template +inline CallbackBase* MakeCallback(T* object, void (T::*function)(P1, P2, P3)) { - return new Callback< T >( object, function ); + return new Callback(object, function); } /** @@ -1699,10 +1731,10 @@ inline CallbackBase* MakeCallback( T* object, void(T::*function)(P1,P2,P3) ) * @param[in] function The member function to call * @return A newly allocated Callback object, ownership transferred to caller */ -template< class T, typename R > -inline CallbackBase* MakeCallback( T* object, R(T::*function)() ) +template +inline CallbackBase* MakeCallback(T* object, R (T::*function)()) { - return new Callback< T >( object, function ); + return new Callback(object, function); } /** @@ -1714,10 +1746,10 @@ inline CallbackBase* MakeCallback( T* object, R(T::*function)() ) * @param[in] function The member function to call * @return A newly allocated Callback object, ownership transferred to caller */ -template< class T, typename P1, typename R > -inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1) ) +template +inline CallbackBase* MakeCallback(T* object, R (T::*function)(P1)) { - return new Callback< T >( object, function ); + return new Callback(object, function); } /** @@ -1729,10 +1761,10 @@ inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1) ) * @param[in] function The member function to call * @return A newly allocated Callback object, ownership transferred to caller */ -template< class T, typename P1, typename P2, typename R > -inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1,P2) ) +template +inline CallbackBase* MakeCallback(T* object, R (T::*function)(P1, P2)) { - return new Callback< T >( object, function ); + return new Callback(object, function); } /** @@ -1744,10 +1776,10 @@ inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1,P2) ) * @param[in] function The member function to call * @return A newly allocated Callback object, ownership transferred to caller */ -template< class T, typename P1, typename P2, typename P3, typename R > -inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1,P2,P3) ) +template +inline CallbackBase* MakeCallback(T* object, R (T::*function)(P1, P2, P3)) { - return new Callback< T >( object, function ); + return new Callback(object, function); } /** @@ -1759,10 +1791,10 @@ inline CallbackBase* MakeCallback( T* object, R(T::*function)(P1,P2,P3) ) * @param[in] function The member function to call * @return A newly allocated Callback object, ownership transferred to caller */ -template< class T, class Base > -inline CallbackBase* MakeCallback( T* object, void(Base::*function)(void) ) +template +inline CallbackBase* MakeCallback(T* object, void (Base::*function)(void)) { - return new Callback< T >( object, function ); + return new Callback(object, function); } /** * @brief Creates a callback from a class's parent member function with no parameters. @@ -1773,15 +1805,15 @@ inline CallbackBase* MakeCallback( T* object, void(Base::*function)(void) ) * @param[in] function The member function to call * @return A newly allocated Callback object, ownership transferred to caller */ -template< class T, class Base > -inline CallbackBase* MakeCallback( T& object, void(Base::*function)(void) ) +template +inline CallbackBase* MakeCallback(T& object, void (Base::*function)(void)) { - return new Callback< T >( object, function ); + return new Callback(object, function); } /** * @} */ -} // namespace DALI +} // namespace Dali #endif // DALI_CALLBACK_H diff --git a/dali/public-api/signals/connection-tracker-interface.cpp b/dali/public-api/signals/connection-tracker-interface.cpp index a100088..97da38a 100644 --- a/dali/public-api/signals/connection-tracker-interface.cpp +++ b/dali/public-api/signals/connection-tracker-interface.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -20,7 +20,6 @@ namespace Dali { - ConnectionTrackerInterface::ConnectionTrackerInterface() { } diff --git a/dali/public-api/signals/connection-tracker-interface.h b/dali/public-api/signals/connection-tracker-interface.h index 6e27eb4..21bffca 100644 --- a/dali/public-api/signals/connection-tracker-interface.h +++ b/dali/public-api/signals/connection-tracker-interface.h @@ -54,7 +54,6 @@ namespace Dali class DALI_CORE_API ConnectionTrackerInterface : public SignalObserver { public: - /** * @brief Constructor. * @SINCE_1_0.0 @@ -74,14 +73,13 @@ public: * @param[in] slotObserver The slot observer i.e. a signal. Ownership is not passed * @param[in] callback The call back. Ownership is not passed */ - virtual void SignalConnected( SlotObserver* slotObserver, CallbackBase* callback ) = 0; + virtual void SignalConnected(SlotObserver* slotObserver, CallbackBase* callback) = 0; private: - - ConnectionTrackerInterface( const ConnectionTrackerInterface& ) = delete; ///< Deleted copy constructor. @SINCE_1_0.0 - ConnectionTrackerInterface( ConnectionTrackerInterface&& ) = delete; ///< Deleted move constructor. @SINCE_1_9.25 - ConnectionTrackerInterface& operator=( const ConnectionTrackerInterface& ) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0 - ConnectionTrackerInterface& operator=( ConnectionTrackerInterface&& ) = delete; ///< Deleted move assignment operator. @SINCE_1_9.25 + ConnectionTrackerInterface(const ConnectionTrackerInterface&) = delete; ///< Deleted copy constructor. @SINCE_1_0.0 + ConnectionTrackerInterface(ConnectionTrackerInterface&&) = delete; ///< Deleted move constructor. @SINCE_1_9.25 + ConnectionTrackerInterface& operator=(const ConnectionTrackerInterface&) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0 + ConnectionTrackerInterface& operator=(ConnectionTrackerInterface&&) = delete; ///< Deleted move assignment operator. @SINCE_1_9.25 }; /** diff --git a/dali/public-api/signals/connection-tracker.cpp b/dali/public-api/signals/connection-tracker.cpp index 0be40a1..fbab2a4 100644 --- a/dali/public-api/signals/connection-tracker.cpp +++ b/dali/public-api/signals/connection-tracker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -19,12 +19,11 @@ #include #include -#include #include +#include namespace Dali { - ConnectionTracker::ConnectionTracker() { } @@ -38,12 +37,12 @@ void ConnectionTracker::DisconnectAll() { std::size_t size = mConnections.Size(); - for( std::size_t i = 0; i< size; ++i ) + for(std::size_t i = 0; i < size; ++i) { SlotConnection* connection = mConnections[i]; // Tell the signal that the slot is disconnected - connection->GetSlotObserver()->SlotDisconnected( connection->GetCallback() ); + connection->GetSlotObserver()->SlotDisconnected(connection->GetCallback()); delete connection; } @@ -51,25 +50,25 @@ void ConnectionTracker::DisconnectAll() mConnections.Clear(); } -void ConnectionTracker::SignalConnected( SlotObserver* slotObserver, CallbackBase* callback ) +void ConnectionTracker::SignalConnected(SlotObserver* slotObserver, CallbackBase* callback) { - SlotConnection* connection = new SlotConnection( slotObserver, callback ); - mConnections.PushBack( connection ); + SlotConnection* connection = new SlotConnection(slotObserver, callback); + mConnections.PushBack(connection); } -void ConnectionTracker::SignalDisconnected( SlotObserver* signal, CallbackBase* callback ) +void ConnectionTracker::SignalDisconnected(SlotObserver* signal, CallbackBase* callback) { std::size_t size = mConnections.Size(); - for( std::size_t i = 0; i< size; ++i ) + for(std::size_t i = 0; i < size; ++i) { SlotConnection* connection = mConnections[i]; // Pointer comparison i.e. SignalConnection contains pointer to same callback instance - if( connection->GetCallback() == callback ) + if(connection->GetCallback() == callback) { // Remove from connection list - mConnections.Erase( mConnections.Begin() + i ); + mConnections.Erase(mConnections.Begin() + i); // Delete connection delete connection; @@ -79,7 +78,7 @@ void ConnectionTracker::SignalDisconnected( SlotObserver* signal, CallbackBase* } } - DALI_ABORT( "Callback lost in SignalDisconnected()" ); + DALI_ABORT("Callback lost in SignalDisconnected()"); } std::size_t ConnectionTracker::GetConnectionCount() const diff --git a/dali/public-api/signals/connection-tracker.h b/dali/public-api/signals/connection-tracker.h index 74a17f3..2d1538a 100644 --- a/dali/public-api/signals/connection-tracker.h +++ b/dali/public-api/signals/connection-tracker.h @@ -41,7 +41,6 @@ class SlotConnection; class DALI_CORE_API ConnectionTracker : public ConnectionTrackerInterface { public: - /** * @brief Constructor. * @SINCE_1_0.0 @@ -63,12 +62,12 @@ public: /** * @copydoc ConnectionTrackerInterface::SignalConnected */ - void SignalConnected( SlotObserver* slotObserver, CallbackBase* callback ) override; + void SignalConnected(SlotObserver* slotObserver, CallbackBase* callback) override; /** * @copydoc ConnectionTrackerInterface::SignalDisconnected */ - void SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback ) override; + void SignalDisconnected(SlotObserver* slotObserver, CallbackBase* callback) override; /** * @brief Returns the connection count. @@ -78,15 +77,13 @@ public: std::size_t GetConnectionCount() const; private: - - ConnectionTracker( const ConnectionTracker& ) = delete; ///< Deleted copy constructor. @SINCE_1_0.0 - ConnectionTracker( ConnectionTracker&& ) = delete; ///< Deleted move constructor. @SINCE_1_9.25 - ConnectionTracker& operator=( const ConnectionTracker& ) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0 - ConnectionTracker& operator=( ConnectionTracker&& ) = delete;///< Deleted move assignment operator. @SINCE_1_9.25 + ConnectionTracker(const ConnectionTracker&) = delete; ///< Deleted copy constructor. @SINCE_1_0.0 + ConnectionTracker(ConnectionTracker&&) = delete; ///< Deleted move constructor. @SINCE_1_9.25 + ConnectionTracker& operator=(const ConnectionTracker&) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0 + ConnectionTracker& operator=(ConnectionTracker&&) = delete; ///< Deleted move assignment operator. @SINCE_1_9.25 private: - - Dali::Vector< SlotConnection* > mConnections; ///< Vector of connection pointers + Dali::Vector mConnections; ///< Vector of connection pointers }; /** diff --git a/dali/public-api/signals/dali-signal.h b/dali/public-api/signals/dali-signal.h index 4812ca9..7931c6a 100644 --- a/dali/public-api/signals/dali-signal.h +++ b/dali/public-api/signals/dali-signal.h @@ -54,10 +54,10 @@ // INTERNAL INCLUDES #include +#include #include #include #include -#include namespace Dali { @@ -132,7 +132,7 @@ namespace Dali * @endcode * @SINCE_1_0.0 */ -template< typename _Signature > +template class Signal { }; @@ -141,11 +141,10 @@ class Signal * @brief A template for Signals with no parameters or return value. * @SINCE_1_0.0 */ -template <> -class Signal< void () > +template<> +class Signal { public: - /** * @brief Default constructor. * @SINCE_1_0.0 @@ -190,9 +189,9 @@ public: * @SINCE_1_0.0 * @param[in] func The function to connect */ - void Connect( void (*func)() ) + void Connect(void (*func)()) { - mImpl.OnConnect( MakeCallback( func ) ); + mImpl.OnConnect(MakeCallback(func)); } /** @@ -201,9 +200,9 @@ public: * @SINCE_1_0.0 * @param[in] func The function to disconnect */ - void Disconnect( void (*func)() ) + void Disconnect(void (*func)()) { - mImpl.OnDisconnect( MakeCallback( func ) ); + mImpl.OnDisconnect(MakeCallback(func)); } /** @@ -214,9 +213,9 @@ public: * @param[in] func The member function to connect */ template - void Connect( X* obj, void (X::*func)() ) + void Connect(X* obj, void (X::*func)()) { - mImpl.OnConnect( obj, MakeCallback( obj, func ) ); + mImpl.OnConnect(obj, MakeCallback(obj, func)); } /** @@ -227,9 +226,9 @@ public: * @param[in] func The member function to disconnect */ template - void Disconnect( X* obj, void (X::*func)() ) + void Disconnect(X* obj, void (X::*func)()) { - mImpl.OnDisconnect( obj, MakeCallback( obj, func ) ); + mImpl.OnDisconnect(obj, MakeCallback(obj, func)); } /** @@ -240,9 +239,9 @@ public: * @param[in] func The member function to connect */ template - void Connect( SlotDelegate& delegate, void (X::*func)() ) + void Connect(SlotDelegate& delegate, void (X::*func)()) { - mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) ); + mImpl.OnConnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func)); } /** @@ -253,9 +252,9 @@ public: * @param[in] func The member function to disconnect */ template - void Disconnect( SlotDelegate& delegate, void (X::*func)() ) + void Disconnect(SlotDelegate& delegate, void (X::*func)()) { - mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) ); + mImpl.OnDisconnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func)); } /** @@ -266,9 +265,9 @@ public: * @param[in] func The function object to copy */ template - void Connect( ConnectionTrackerInterface* connectionTracker, const X& func ) + void Connect(ConnectionTrackerInterface* connectionTracker, const X& func) { - mImpl.OnConnect( connectionTracker, new CallbackFunctor0< X >( func ) ); + mImpl.OnConnect(connectionTracker, new CallbackFunctor0(func)); } /** @@ -278,9 +277,9 @@ public: * @param[in] connectionTracker A connection tracker which can be used to disconnect * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken) */ - void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate ) + void Connect(ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate) { - mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate0( delegate ) ); + mImpl.OnConnect(connectionTracker, new CallbackFunctorDelegate0(delegate)); } /** @@ -293,14 +292,12 @@ public: } private: - - Signal( const Signal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0 - Signal( Signal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25 - Signal& operator=( const Signal& ) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0 - Signal& operator=( Signal&& ) = delete; ///< Deleted move assignment operator @SINCE_1_9.25 + Signal(const Signal&) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0 + Signal(Signal&&) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25 + Signal& operator=(const Signal&) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0 + Signal& operator=(Signal&&) = delete; ///< Deleted move assignment operator @SINCE_1_9.25 private: - // Use composition instead of inheritance (virtual methods don't mix well with templates) BaseSignal mImpl; ///< The base signal implementation }; @@ -309,11 +306,10 @@ private: * @brief A template for Signals with no parameters and a return value. * @SINCE_1_0.0 */ -template < typename Ret > -class Signal< Ret() > +template +class Signal { public: - /** * @brief Default constructor. * @SINCE_1_0.0 @@ -357,9 +353,9 @@ public: * @SINCE_1_0.0 * @param[in] func The function to connect */ - void Connect( Ret (*func)() ) + void Connect(Ret (*func)()) { - mImpl.OnConnect( MakeCallback( func ) ); + mImpl.OnConnect(MakeCallback(func)); } /** @@ -368,9 +364,9 @@ public: * @SINCE_1_0.0 * @param[in] func The function to disconnect */ - void Disconnect( Ret (*func)() ) + void Disconnect(Ret (*func)()) { - mImpl.OnDisconnect( MakeCallback( func ) ); + mImpl.OnDisconnect(MakeCallback(func)); } /** @@ -381,9 +377,9 @@ public: * @param[in] func The member function to connect */ template - void Connect( X* obj, Ret (X::*func)() ) + void Connect(X* obj, Ret (X::*func)()) { - mImpl.OnConnect( obj, MakeCallback( obj, func ) ); + mImpl.OnConnect(obj, MakeCallback(obj, func)); } /** @@ -394,9 +390,9 @@ public: * @param[in] func The member function to disconnect */ template - void Disconnect( X* obj, Ret (X::*func)() ) + void Disconnect(X* obj, Ret (X::*func)()) { - mImpl.OnDisconnect( obj, MakeCallback( obj, func ) ); + mImpl.OnDisconnect(obj, MakeCallback(obj, func)); } /** @@ -407,9 +403,9 @@ public: * @param[in] func The member function to connect */ template - void Connect( SlotDelegate& delegate, Ret (X::*func)() ) + void Connect(SlotDelegate& delegate, Ret (X::*func)()) { - mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) ); + mImpl.OnConnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func)); } /** @@ -420,9 +416,9 @@ public: * @param[in] func The member function to disconnect */ template - void Disconnect( SlotDelegate& delegate, Ret (X::*func)() ) + void Disconnect(SlotDelegate& delegate, Ret (X::*func)()) { - mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) ); + mImpl.OnDisconnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func)); } /** @@ -433,9 +429,9 @@ public: * @param[in] func The function object to copy */ template - void Connect( ConnectionTrackerInterface* connectionTracker, const X& func ) + void Connect(ConnectionTrackerInterface* connectionTracker, const X& func) { - mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn0< X, Ret >( func ) ); + mImpl.OnConnect(connectionTracker, new CallbackFunctorReturn0(func)); } /** @@ -445,9 +441,9 @@ public: * @param[in] connectionTracker A connection tracker which can be used to disconnect * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken) */ - void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate ) + void Connect(ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate) { - mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn0< Ret >( delegate ) ); + mImpl.OnConnect(connectionTracker, new CallbackFunctorDelegateReturn0(delegate)); } /** @@ -458,18 +454,16 @@ public: */ Ret Emit() { - return mImpl.EmitReturn< Ret >(); + return mImpl.EmitReturn(); } private: - - Signal( const Signal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0 - Signal( Signal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25 - Signal& operator=( const Signal& ) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0 - Signal& operator=( Signal&& ) = delete; ///< Deleted move assignment operator @SINCE_1_9.25 + Signal(const Signal&) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0 + Signal(Signal&&) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25 + Signal& operator=(const Signal&) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0 + Signal& operator=(Signal&&) = delete; ///< Deleted move assignment operator @SINCE_1_9.25 private: - // Use composition instead of inheritance (virtual methods don't mix well with templates) BaseSignal mImpl; ///< Implementation }; @@ -478,11 +472,10 @@ private: * @brief A template for Signals with 1 parameter. * @SINCE_1_0.0 */ -template < typename Arg0 > -class Signal< void ( Arg0 ) > +template +class Signal { public: - /** * @brief Default constructor. * @SINCE_1_0.0 @@ -526,9 +519,9 @@ public: * @SINCE_1_0.0 * @param[in] func The function to connect */ - void Connect( void (*func)( Arg0 arg0 ) ) + void Connect(void (*func)(Arg0 arg0)) { - mImpl.OnConnect( MakeCallback( func ) ); + mImpl.OnConnect(MakeCallback(func)); } /** @@ -537,9 +530,9 @@ public: * @SINCE_1_0.0 * @param[in] func The function to disconnect */ - void Disconnect( void (*func)( Arg0 arg0 ) ) + void Disconnect(void (*func)(Arg0 arg0)) { - mImpl.OnDisconnect( MakeCallback( func ) ); + mImpl.OnDisconnect(MakeCallback(func)); } /** @@ -550,9 +543,9 @@ public: * @param[in] func The member function to connect */ template - void Connect( X* obj, void (X::*func)( Arg0 arg0 ) ) + void Connect(X* obj, void (X::*func)(Arg0 arg0)) { - mImpl.OnConnect( obj, MakeCallback( obj, func ) ); + mImpl.OnConnect(obj, MakeCallback(obj, func)); } /** @@ -563,9 +556,9 @@ public: * @param[in] func The member function to disconnect */ template - void Disconnect( X* obj, void (X::*func)( Arg0 arg0 ) ) + void Disconnect(X* obj, void (X::*func)(Arg0 arg0)) { - mImpl.OnDisconnect( obj, MakeCallback( obj, func ) ); + mImpl.OnDisconnect(obj, MakeCallback(obj, func)); } /** @@ -576,9 +569,9 @@ public: * @param[in] func The member function to connect */ template - void Connect( SlotDelegate& delegate, void (X::*func)( Arg0 arg0 ) ) + void Connect(SlotDelegate& delegate, void (X::*func)(Arg0 arg0)) { - mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) ); + mImpl.OnConnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func)); } /** @@ -589,9 +582,9 @@ public: * @param[in] func The member function to disconnect */ template - void Disconnect( SlotDelegate& delegate, void (X::*func)( Arg0 arg0 ) ) + void Disconnect(SlotDelegate& delegate, void (X::*func)(Arg0 arg0)) { - mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) ); + mImpl.OnDisconnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func)); } /** @@ -602,9 +595,9 @@ public: * @param[in] func The function object to copy */ template - void Connect( ConnectionTrackerInterface* connectionTracker, const X& func ) + void Connect(ConnectionTrackerInterface* connectionTracker, const X& func) { - mImpl.OnConnect( connectionTracker, new CallbackFunctor1< X, Arg0 >( func ) ); + mImpl.OnConnect(connectionTracker, new CallbackFunctor1(func)); } /** @@ -614,9 +607,9 @@ public: * @param[in] connectionTracker A connection tracker which can be used to disconnect * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken) */ - void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate ) + void Connect(ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate) { - mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate1< Arg0 >( delegate ) ); + mImpl.OnConnect(connectionTracker, new CallbackFunctorDelegate1(delegate)); } /** @@ -625,20 +618,18 @@ public: * @SINCE_1_0.0 * @param[in] arg0 The first value to pass to callbacks */ - void Emit( Arg0 arg0 ) + void Emit(Arg0 arg0) { - mImpl.Emit< Arg0 >( arg0 ); + mImpl.Emit(arg0); } private: - - Signal( const Signal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0 - Signal( Signal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25 - Signal& operator=( const Signal& ) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0 - Signal& operator=( Signal&& ) = delete; ///< Deleted move assignment operator @SINCE_1_9.25 + Signal(const Signal&) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0 + Signal(Signal&&) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25 + Signal& operator=(const Signal&) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0 + Signal& operator=(Signal&&) = delete; ///< Deleted move assignment operator @SINCE_1_9.25 private: - // Use composition instead of inheritance (virtual methods don't mix well with templates) BaseSignal mImpl; ///< Implementation }; @@ -647,11 +638,10 @@ private: * @brief A template for Signals with 1 parameter and a return value. * @SINCE_1_0.0 */ -template < typename Ret, typename Arg0 > -class Signal< Ret( Arg0 ) > +template +class Signal { public: - /** * @brief Default constructor. * @SINCE_1_0.0 @@ -695,9 +685,9 @@ public: * @SINCE_1_0.0 * @param[in] func The function to connect */ - void Connect( Ret (*func)( Arg0 arg0 ) ) + void Connect(Ret (*func)(Arg0 arg0)) { - mImpl.OnConnect( MakeCallback( func ) ); + mImpl.OnConnect(MakeCallback(func)); } /** @@ -706,9 +696,9 @@ public: * @SINCE_1_0.0 * @param[in] func The function to disconnect */ - void Disconnect( Ret (*func)( Arg0 arg0 ) ) + void Disconnect(Ret (*func)(Arg0 arg0)) { - mImpl.OnDisconnect( MakeCallback( func ) ); + mImpl.OnDisconnect(MakeCallback(func)); } /** @@ -719,9 +709,9 @@ public: * @param[in] func The member function to connect */ template - void Connect( X* obj, Ret (X::*func)( Arg0 arg0 ) ) + void Connect(X* obj, Ret (X::*func)(Arg0 arg0)) { - mImpl.OnConnect( obj, MakeCallback( obj, func ) ); + mImpl.OnConnect(obj, MakeCallback(obj, func)); } /** @@ -732,9 +722,9 @@ public: * @param[in] func The member function to disconnect */ template - void Disconnect( X* obj, Ret (X::*func)( Arg0 arg0 ) ) + void Disconnect(X* obj, Ret (X::*func)(Arg0 arg0)) { - mImpl.OnDisconnect( obj, MakeCallback( obj, func ) ); + mImpl.OnDisconnect(obj, MakeCallback(obj, func)); } /** @@ -745,9 +735,9 @@ public: * @param[in] func The member function to connect */ template - void Connect( SlotDelegate& delegate, Ret (X::*func)( Arg0 arg0 ) ) + void Connect(SlotDelegate& delegate, Ret (X::*func)(Arg0 arg0)) { - mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) ); + mImpl.OnConnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func)); } /** @@ -758,9 +748,9 @@ public: * @param[in] func The member function to disconnect */ template - void Disconnect( SlotDelegate& delegate, Ret (X::*func)( Arg0 arg0 ) ) + void Disconnect(SlotDelegate& delegate, Ret (X::*func)(Arg0 arg0)) { - mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) ); + mImpl.OnDisconnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func)); } /** @@ -771,9 +761,9 @@ public: * @param[in] func The function object to copy */ template - void Connect( ConnectionTrackerInterface* connectionTracker, const X& func ) + void Connect(ConnectionTrackerInterface* connectionTracker, const X& func) { - mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn1< X, Arg0, Ret >( func ) ); + mImpl.OnConnect(connectionTracker, new CallbackFunctorReturn1(func)); } /** @@ -783,9 +773,9 @@ public: * @param[in] connectionTracker A connection tracker which can be used to disconnect * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken) */ - void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate ) + void Connect(ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate) { - mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn1< Arg0, Ret >( delegate ) ); + mImpl.OnConnect(connectionTracker, new CallbackFunctorDelegateReturn1(delegate)); } /** @@ -795,20 +785,18 @@ public: * @param[in] arg0 The first value to pass to callbacks * @return The value returned by the last callback, or a default constructed value if no callbacks are connected */ - Ret Emit( Arg0 arg0 ) + Ret Emit(Arg0 arg0) { - return mImpl.EmitReturn< Ret,Arg0 >(arg0); + return mImpl.EmitReturn(arg0); } private: - - Signal( const Signal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0 - Signal( Signal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25 - Signal& operator=( const Signal& ) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0 - Signal& operator=( Signal&& ) = delete; ///< Deleted move assignment operator @SINCE_1_9.25 + Signal(const Signal&) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0 + Signal(Signal&&) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25 + Signal& operator=(const Signal&) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0 + Signal& operator=(Signal&&) = delete; ///< Deleted move assignment operator @SINCE_1_9.25 private: - // Use composition instead of inheritance (virtual methods don't mix well with templates) BaseSignal mImpl; ///< Implementation }; @@ -818,11 +806,10 @@ private: * * @SINCE_1_0.0 */ -template < typename Arg0, typename Arg1 > -class Signal< void ( Arg0, Arg1 ) > +template +class Signal { public: - /** * @brief Default constructor. * @@ -868,9 +855,9 @@ public: * @SINCE_1_0.0 * @param[in] func The function to connect */ - void Connect( void (*func)( Arg0 arg0, Arg1 arg1 ) ) + void Connect(void (*func)(Arg0 arg0, Arg1 arg1)) { - mImpl.OnConnect( MakeCallback( func ) ); + mImpl.OnConnect(MakeCallback(func)); } /** @@ -879,9 +866,9 @@ public: * @SINCE_1_0.0 * @param[in] func The function to disconnect */ - void Disconnect( void (*func)( Arg0 arg0, Arg1 arg1 ) ) + void Disconnect(void (*func)(Arg0 arg0, Arg1 arg1)) { - mImpl.OnDisconnect( MakeCallback( func ) ); + mImpl.OnDisconnect(MakeCallback(func)); } /** @@ -892,9 +879,9 @@ public: * @param[in] func The member function to connect */ template - void Connect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1 ) ) + void Connect(X* obj, void (X::*func)(Arg0 arg0, Arg1 arg1)) { - mImpl.OnConnect( obj, MakeCallback( obj, func ) ); + mImpl.OnConnect(obj, MakeCallback(obj, func)); } /** @@ -905,9 +892,9 @@ public: * @param[in] func The member function to disconnect */ template - void Disconnect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1 ) ) + void Disconnect(X* obj, void (X::*func)(Arg0 arg0, Arg1 arg1)) { - mImpl.OnDisconnect( obj, MakeCallback( obj, func ) ); + mImpl.OnDisconnect(obj, MakeCallback(obj, func)); } /** @@ -918,9 +905,9 @@ public: * @param[in] func The member function to connect */ template - void Connect( SlotDelegate& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1 ) ) + void Connect(SlotDelegate& delegate, void (X::*func)(Arg0 arg0, Arg1 arg1)) { - mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) ); + mImpl.OnConnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func)); } /** @@ -931,9 +918,9 @@ public: * @param[in] func The member function to disconnect */ template - void Disconnect( SlotDelegate& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1 ) ) + void Disconnect(SlotDelegate& delegate, void (X::*func)(Arg0 arg0, Arg1 arg1)) { - mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) ); + mImpl.OnDisconnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func)); } /** @@ -944,9 +931,9 @@ public: * @param[in] func The function object to copy */ template - void Connect( ConnectionTrackerInterface* connectionTracker, const X& func ) + void Connect(ConnectionTrackerInterface* connectionTracker, const X& func) { - mImpl.OnConnect( connectionTracker, new CallbackFunctor2< X, Arg0, Arg1 >( func ) ); + mImpl.OnConnect(connectionTracker, new CallbackFunctor2(func)); } /** @@ -956,9 +943,9 @@ public: * @param[in] connectionTracker A connection tracker which can be used to disconnect * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken) */ - void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate ) + void Connect(ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate) { - mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate2< Arg0, Arg1 >( delegate ) ); + mImpl.OnConnect(connectionTracker, new CallbackFunctorDelegate2(delegate)); } /** @@ -968,20 +955,18 @@ public: * @param[in] arg0 The first value to pass to callbacks * @param[in] arg1 The second value to pass to callbacks */ - void Emit( Arg0 arg0, Arg1 arg1 ) + void Emit(Arg0 arg0, Arg1 arg1) { - mImpl.Emit< Arg0,Arg1 >( arg0, arg1 ); + mImpl.Emit(arg0, arg1); } private: - - Signal( const Signal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0 - Signal( Signal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25 - Signal& operator=( const Signal& ) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0 - Signal& operator=( Signal&& ) = delete; ///< Deleted move assignment operator @SINCE_1_9.25 + Signal(const Signal&) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0 + Signal(Signal&&) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25 + Signal& operator=(const Signal&) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0 + Signal& operator=(Signal&&) = delete; ///< Deleted move assignment operator @SINCE_1_9.25 private: - // Use composition instead of inheritance (virtual methods don't mix well with templates) BaseSignal mImpl; ///< Implementation }; @@ -990,11 +975,10 @@ private: * @brief A template for Signals with 2 parameters and a return value. * @SINCE_1_0.0 */ -template < typename Ret, typename Arg0, typename Arg1 > -class Signal< Ret( Arg0, Arg1 ) > +template +class Signal { public: - /** * @brief Default constructor. * @SINCE_1_0.0 @@ -1037,9 +1021,9 @@ public: * @SINCE_1_0.0 * @param[in] func The function to connect */ - void Connect( Ret (*func)( Arg0 arg0, Arg1 arg1 ) ) + void Connect(Ret (*func)(Arg0 arg0, Arg1 arg1)) { - mImpl.OnConnect( MakeCallback( func ) ); + mImpl.OnConnect(MakeCallback(func)); } /** @@ -1048,9 +1032,9 @@ public: * @SINCE_1_0.0 * @param[in] func The function to disconnect */ - void Disconnect( Ret (*func)( Arg0 arg0, Arg1 arg1 ) ) + void Disconnect(Ret (*func)(Arg0 arg0, Arg1 arg1)) { - mImpl.OnDisconnect( MakeCallback( func ) ); + mImpl.OnDisconnect(MakeCallback(func)); } /** @@ -1061,9 +1045,9 @@ public: * @param[in] func The member function to connect */ template - void Connect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) ) + void Connect(X* obj, Ret (X::*func)(Arg0 arg0, Arg1 arg1)) { - mImpl.OnConnect( obj, MakeCallback( obj, func ) ); + mImpl.OnConnect(obj, MakeCallback(obj, func)); } /** @@ -1074,9 +1058,9 @@ public: * @param[in] func The member function to disconnect */ template - void Disconnect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) ) + void Disconnect(X* obj, Ret (X::*func)(Arg0 arg0, Arg1 arg1)) { - mImpl.OnDisconnect( obj, MakeCallback( obj, func ) ); + mImpl.OnDisconnect(obj, MakeCallback(obj, func)); } /** @@ -1087,9 +1071,9 @@ public: * @param[in] func The member function to connect */ template - void Connect( SlotDelegate& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) ) + void Connect(SlotDelegate& delegate, Ret (X::*func)(Arg0 arg0, Arg1 arg1)) { - mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) ); + mImpl.OnConnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func)); } /** @@ -1100,9 +1084,9 @@ public: * @param[in] func The member function to disconnect */ template - void Disconnect( SlotDelegate& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1 ) ) + void Disconnect(SlotDelegate& delegate, Ret (X::*func)(Arg0 arg0, Arg1 arg1)) { - mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) ); + mImpl.OnDisconnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func)); } /** @@ -1113,9 +1097,9 @@ public: * @param[in] func The function object to copy */ template - void Connect( ConnectionTrackerInterface* connectionTracker, const X& func ) + void Connect(ConnectionTrackerInterface* connectionTracker, const X& func) { - mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn2< X, Arg0, Arg1, Ret >( func ) ); + mImpl.OnConnect(connectionTracker, new CallbackFunctorReturn2(func)); } /** @@ -1125,9 +1109,9 @@ public: * @param[in] connectionTracker A connection tracker which can be used to disconnect * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken) */ - void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate ) + void Connect(ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate) { - mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn2< Arg0, Arg1, Ret >( delegate ) ); + mImpl.OnConnect(connectionTracker, new CallbackFunctorDelegateReturn2(delegate)); } /** @@ -1138,20 +1122,18 @@ public: * @param[in] arg1 The second value to pass to callbacks * @return The value returned by the last callback, or a default constructed value if no callbacks are connected */ - Ret Emit( Arg0 arg0, Arg1 arg1 ) + Ret Emit(Arg0 arg0, Arg1 arg1) { - return mImpl.EmitReturn< Ret,Arg0,Arg1 >( arg0, arg1 ); + return mImpl.EmitReturn(arg0, arg1); } private: - - Signal( const Signal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0 - Signal( Signal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25 - Signal& operator=( const Signal& ) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0 - Signal& operator=( Signal&& ) = delete; ///< Deleted move assignment operator @SINCE_1_9.25 + Signal(const Signal&) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0 + Signal(Signal&&) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25 + Signal& operator=(const Signal&) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0 + Signal& operator=(Signal&&) = delete; ///< Deleted move assignment operator @SINCE_1_9.25 private: - // Use composition instead of inheritance (virtual methods don't mix well with templates) BaseSignal mImpl; ///< Implementation }; @@ -1160,11 +1142,10 @@ private: * @brief A template for Signals with 3 parameters. * @SINCE_1_0.0 */ -template < typename Arg0, typename Arg1, typename Arg2 > -class Signal< void ( Arg0, Arg1, Arg2 ) > +template +class Signal { public: - /** * @brief Default constructor. * @SINCE_1_0.0 @@ -1208,9 +1189,9 @@ public: * @SINCE_1_0.0 * @param[in] func The function to connect */ - void Connect( void (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) ) + void Connect(void (*func)(Arg0 arg0, Arg1 arg1, Arg2 arg2)) { - mImpl.OnConnect( MakeCallback( func ) ); + mImpl.OnConnect(MakeCallback(func)); } /** @@ -1219,9 +1200,9 @@ public: * @SINCE_1_0.0 * @param[in] func The function to disconnect */ - void Disconnect( void (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) ) + void Disconnect(void (*func)(Arg0 arg0, Arg1 arg1, Arg2 arg2)) { - mImpl.OnDisconnect( MakeCallback( func ) ); + mImpl.OnDisconnect(MakeCallback(func)); } /** @@ -1232,9 +1213,9 @@ public: * @param[in] func The member function to connect */ template - void Connect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) ) + void Connect(X* obj, void (X::*func)(Arg0 arg0, Arg1 arg1, Arg2 arg2)) { - mImpl.OnConnect( obj, MakeCallback( obj, func ) ); + mImpl.OnConnect(obj, MakeCallback(obj, func)); } /** @@ -1245,9 +1226,9 @@ public: * @param[in] func The member function to disconnect */ template - void Disconnect( X* obj, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) ) + void Disconnect(X* obj, void (X::*func)(Arg0 arg0, Arg1 arg1, Arg2 arg2)) { - mImpl.OnDisconnect( obj, MakeCallback( obj, func ) ); + mImpl.OnDisconnect(obj, MakeCallback(obj, func)); } /** @@ -1258,9 +1239,9 @@ public: * @param[in] func The member function to connect */ template - void Connect( SlotDelegate& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) ) + void Connect(SlotDelegate& delegate, void (X::*func)(Arg0 arg0, Arg1 arg1, Arg2 arg2)) { - mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) ); + mImpl.OnConnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func)); } /** @@ -1271,9 +1252,9 @@ public: * @param[in] func The member function to disconnect */ template - void Disconnect( SlotDelegate& delegate, void (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) ) + void Disconnect(SlotDelegate& delegate, void (X::*func)(Arg0 arg0, Arg1 arg1, Arg2 arg2)) { - mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) ); + mImpl.OnDisconnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func)); } /** @@ -1284,9 +1265,9 @@ public: * @param[in] func The function object to copy */ template - void Connect( ConnectionTrackerInterface* connectionTracker, const X& func ) + void Connect(ConnectionTrackerInterface* connectionTracker, const X& func) { - mImpl.OnConnect( connectionTracker, new CallbackFunctor3< X, Arg0, Arg1, Arg2 >( func ) ); + mImpl.OnConnect(connectionTracker, new CallbackFunctor3(func)); } /** @@ -1296,9 +1277,9 @@ public: * @param[in] connectionTracker A connection tracker which can be used to disconnect * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken) */ - void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate ) + void Connect(ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate) { - mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegate3< Arg0, Arg1, Arg2 >( delegate ) ); + mImpl.OnConnect(connectionTracker, new CallbackFunctorDelegate3(delegate)); } /** @@ -1309,20 +1290,18 @@ public: * @param[in] arg1 The second value to pass to callbacks * @param[in] arg2 The third value to pass to callbacks */ - void Emit( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) + void Emit(Arg0 arg0, Arg1 arg1, Arg2 arg2) { - mImpl.Emit< Arg0,Arg1,Arg2 >( arg0, arg1, arg2 ); + mImpl.Emit(arg0, arg1, arg2); } private: - - Signal( const Signal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0 - Signal( Signal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25 - Signal& operator=( const Signal& ) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0 - Signal& operator=( Signal&& ) = delete; ///< Deleted move assignment operator @SINCE_1_9.25 + Signal(const Signal&) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0 + Signal(Signal&&) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25 + Signal& operator=(const Signal&) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0 + Signal& operator=(Signal&&) = delete; ///< Deleted move assignment operator @SINCE_1_9.25 private: - // Use composition instead of inheritance (virtual methods don't mix well with templates) BaseSignal mImpl; ///< Implementation }; @@ -1331,11 +1310,10 @@ private: * @brief A template for Signals with 2 parameters and a return value. * @SINCE_1_0.0 */ -template < typename Ret, typename Arg0, typename Arg1, typename Arg2 > -class Signal< Ret( Arg0, Arg1, Arg2 ) > +template +class Signal { public: - /** * @brief Default constructor. * @SINCE_1_0.0 @@ -1380,9 +1358,9 @@ public: * @SINCE_1_0.0 * @param[in] func The function to connect */ - void Connect( Ret (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) ) + void Connect(Ret (*func)(Arg0 arg0, Arg1 arg1, Arg2 arg2)) { - mImpl.OnConnect( MakeCallback( func ) ); + mImpl.OnConnect(MakeCallback(func)); } /** @@ -1391,9 +1369,9 @@ public: * @SINCE_1_0.0 * @param[in] func The function to disconnect */ - void Disconnect( Ret (*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) ) + void Disconnect(Ret (*func)(Arg0 arg0, Arg1 arg1, Arg2 arg2)) { - mImpl.OnDisconnect( MakeCallback( func ) ); + mImpl.OnDisconnect(MakeCallback(func)); } /** @@ -1404,9 +1382,9 @@ public: * @param[in] func The member function to connect */ template - void Connect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) ) + void Connect(X* obj, Ret (X::*func)(Arg0 arg0, Arg1 arg1, Arg2 arg2)) { - mImpl.OnConnect( obj, MakeCallback( obj, func ) ); + mImpl.OnConnect(obj, MakeCallback(obj, func)); } /** @@ -1417,9 +1395,9 @@ public: * @param[in] func The member function to disconnect */ template - void Disconnect( X* obj, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) ) + void Disconnect(X* obj, Ret (X::*func)(Arg0 arg0, Arg1 arg1, Arg2 arg2)) { - mImpl.OnDisconnect( obj, MakeCallback( obj, func ) ); + mImpl.OnDisconnect(obj, MakeCallback(obj, func)); } /** @@ -1430,9 +1408,9 @@ public: * @param[in] func The member function to connect */ template - void Connect( SlotDelegate& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) ) + void Connect(SlotDelegate& delegate, Ret (X::*func)(Arg0 arg0, Arg1 arg1, Arg2 arg2)) { - mImpl.OnConnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) ); + mImpl.OnConnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func)); } /** @@ -1443,9 +1421,9 @@ public: * @param[in] func The member function to disconnect */ template - void Disconnect( SlotDelegate& delegate, Ret (X::*func)( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) ) + void Disconnect(SlotDelegate& delegate, Ret (X::*func)(Arg0 arg0, Arg1 arg1, Arg2 arg2)) { - mImpl.OnDisconnect( delegate.GetConnectionTracker(), MakeCallback( delegate.GetSlot(), func ) ); + mImpl.OnDisconnect(delegate.GetConnectionTracker(), MakeCallback(delegate.GetSlot(), func)); } /** @@ -1456,9 +1434,9 @@ public: * @param[in] func The function object to copy */ template - void Connect( ConnectionTrackerInterface* connectionTracker, const X& func ) + void Connect(ConnectionTrackerInterface* connectionTracker, const X& func) { - mImpl.OnConnect( connectionTracker, new CallbackFunctorReturn3< X, Arg0, Arg1, Arg2, Ret >( func ) ); + mImpl.OnConnect(connectionTracker, new CallbackFunctorReturn3(func)); } /** @@ -1468,9 +1446,9 @@ public: * @param[in] connectionTracker A connection tracker which can be used to disconnect * @param[in] delegate A newly allocated FunctorDelegate (ownership is taken) */ - void Connect( ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate ) + void Connect(ConnectionTrackerInterface* connectionTracker, FunctorDelegate* delegate) { - mImpl.OnConnect( connectionTracker, new CallbackFunctorDelegateReturn3< Arg0, Arg1, Arg2, Ret >( delegate ) ); + mImpl.OnConnect(connectionTracker, new CallbackFunctorDelegateReturn3(delegate)); } /** @@ -1482,20 +1460,18 @@ public: * @param[in] arg2 The third value to pass to callbacks * @return The value returned by the last callback, or a default constructed value if no callbacks are connected */ - Ret Emit( Arg0 arg0, Arg1 arg1, Arg2 arg2 ) + Ret Emit(Arg0 arg0, Arg1 arg1, Arg2 arg2) { - return mImpl.EmitReturn< Ret,Arg0,Arg1,Arg2 >( arg0, arg1, arg2 ); + return mImpl.EmitReturn(arg0, arg1, arg2); } private: - - Signal( const Signal& ) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0 - Signal( Signal&& ) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25 - Signal& operator=( const Signal& ) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0 - Signal& operator=( Signal&& ) = delete; ///< Deleted move assignment operator @SINCE_1_9.25 + Signal(const Signal&) = delete; ///< Deleted copy constructor, signals don't support copying. @SINCE_1_0.0 + Signal(Signal&&) = delete; ///< Deleted move constructor, signals don't support moving. @SINCE_1_9.25 + Signal& operator=(const Signal&) = delete; ///< Deleted copy assignment operator @SINCE_1_0.0 + Signal& operator=(Signal&&) = delete; ///< Deleted move assignment operator @SINCE_1_9.25 private: - // Use composition instead of inheritance (virtual methods don't mix well with templates) BaseSignal mImpl; ///< Implementation }; diff --git a/dali/public-api/signals/functor-delegate.cpp b/dali/public-api/signals/functor-delegate.cpp index 8fafecd..fa7772f 100644 --- a/dali/public-api/signals/functor-delegate.cpp +++ b/dali/public-api/signals/functor-delegate.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -31,30 +31,30 @@ namespace * functions and regular functions. * If this assert fails, please implement the template specialisation for C functions. */ -static_assert( sizeof(void*) == sizeof( &FunctorDispatcher::Dispatch ), "Need to implement template specialisation for C functions" ); -} +static_assert(sizeof(void*) == sizeof(&FunctorDispatcher::Dispatch), "Need to implement template specialisation for C functions"); +} // namespace FunctorDelegate::~FunctorDelegate() { - if( mFunctorPointer ) + if(mFunctorPointer) { - (*mDestructorDispatcher)( mFunctorPointer ); + (*mDestructorDispatcher)(mFunctorPointer); } } void FunctorDelegate::Execute() { - if( mFunctorPointer ) + if(mFunctorPointer) { Dispatcher dispatcher = mMemberFunctionDispatcher; - (*dispatcher)( mFunctorPointer ); + (*dispatcher)(mFunctorPointer); } } -FunctorDelegate::FunctorDelegate( void* objectPtr, Dispatcher dispatcher, Destructor destructor ) -: mFunctorPointer( objectPtr ), - mMemberFunctionDispatcher( dispatcher ), - mDestructorDispatcher( destructor ) +FunctorDelegate::FunctorDelegate(void* objectPtr, Dispatcher dispatcher, Destructor destructor) +: mFunctorPointer(objectPtr), + mMemberFunctionDispatcher(dispatcher), + mDestructorDispatcher(destructor) { } diff --git a/dali/public-api/signals/functor-delegate.h b/dali/public-api/signals/functor-delegate.h index 7832173..f1cf04a 100644 --- a/dali/public-api/signals/functor-delegate.h +++ b/dali/public-api/signals/functor-delegate.h @@ -2,7 +2,7 @@ #define DALI_FUNCTOR_DELEGATE_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -32,7 +32,7 @@ namespace Dali * @brief Dispatcher to call a functor. * @SINCE_1_0.0 */ -template< typename T > +template struct FunctorDispatcher { /** @@ -41,10 +41,10 @@ struct FunctorDispatcher * @SINCE_1_0.0 * @param[in] functorPtr The functor to call */ - static void Dispatch( void* functorPtr ) + static void Dispatch(void* functorPtr) { // "downcast" the functor type back to the correct one - T* functor = reinterpret_cast< T* >( functorPtr ); + T* functor = reinterpret_cast(functorPtr); (*functor)(); } }; @@ -53,7 +53,7 @@ struct FunctorDispatcher * @brief Dispatcher to delete a functor object. * @SINCE_1_0.0 */ -template< typename T > +template struct FunctorDestroyer { /** @@ -61,11 +61,11 @@ struct FunctorDestroyer * @SINCE_1_0.0 * @param[in] functorPtr A functor object to delete */ - static void Delete( void* functorPtr ) + static void Delete(void* functorPtr) { // FunctorDelegate owns the object but we're the only one who knows the real type so need // to delete by "downcasting" from void* to the correct type - delete reinterpret_cast< T* >( functorPtr ); + delete reinterpret_cast(functorPtr); } }; @@ -76,7 +76,6 @@ struct FunctorDestroyer class DALI_CORE_API FunctorDelegate { public: - /** * @brief Constructor which copies a function object. * @@ -84,12 +83,12 @@ public: * @param[in] functor The functor object to copy, either a class with operator() or a C function * @return A pointer to the new function object */ - template< typename T > - static FunctorDelegate* New( const T& functor ) + template + static FunctorDelegate* New(const T& functor) { - return new FunctorDelegate( reinterpret_cast< void* >( new T( functor ) ), // heap allocate the functor - reinterpret_cast< FunctorDelegate::Dispatcher >( &FunctorDispatcher::Dispatch ), - reinterpret_cast< FunctorDelegate::Destructor >( &FunctorDestroyer::Delete ) ); + return new FunctorDelegate(reinterpret_cast(new T(functor)), // heap allocate the functor + reinterpret_cast(&FunctorDispatcher::Dispatch), + reinterpret_cast(&FunctorDestroyer::Delete)); } /** @@ -105,30 +104,29 @@ public: void Execute(); private: - /** * @brief Used to call the correct function. * @SINCE_1_0.0 */ - using Dispatcher = void ( * )( void* ); + using Dispatcher = void (*)(void*); /** * @brief Used to destroy mObjectPointer. * @SINCE_1_0.0 */ - using Destructor = void ( * )( void* ); + using Destructor = void (*)(void*); /** * @brief Not defined. * @SINCE_1_0.0 */ - FunctorDelegate( const FunctorDelegate& rhs ); + FunctorDelegate(const FunctorDelegate& rhs); /** * @brief Not defined. * @SINCE_1_0.0 */ - const FunctorDelegate& operator=( const FunctorDelegate& rhs ); + const FunctorDelegate& operator=(const FunctorDelegate& rhs); /** * @brief Private constructor. @@ -138,11 +136,12 @@ private: * @param dispatcher Used to call the actual function * @param destructor Used to delete the owned functor object */ - FunctorDelegate( void* functorPtr, Dispatcher dispatcher, Destructor destructor ); + FunctorDelegate(void* functorPtr, Dispatcher dispatcher, Destructor destructor); -public: // Data for deriving classes & Dispatchers +public: + // Data for deriving classes & Dispatchers - void* mFunctorPointer; ///< Functor that will be called + void* mFunctorPointer; ///< Functor that will be called Dispatcher mMemberFunctionDispatcher; ///< Dispatcher for member functions Destructor mDestructorDispatcher; ///< Destructor for owned objects }; @@ -150,6 +149,6 @@ public: // Data for deriving classes & Dispatchers /** * @} */ -} // namespace DALI +} // namespace Dali #endif // DALI_FUNCTOR_DELEGATE_H diff --git a/dali/public-api/signals/signal-slot-connections.cpp b/dali/public-api/signals/signal-slot-connections.cpp index aaef473..b03e133 100644 --- a/dali/public-api/signals/signal-slot-connections.cpp +++ b/dali/public-api/signals/signal-slot-connections.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -26,10 +26,9 @@ namespace Dali { - -SlotConnection::SlotConnection( SlotObserver* slotObserver, CallbackBase* callback ) -: mSlotObserver( slotObserver ), - mCallback( callback ) +SlotConnection::SlotConnection(SlotObserver* slotObserver, CallbackBase* callback) +: mSlotObserver(slotObserver), + mCallback(callback) { } @@ -47,15 +46,15 @@ SlotObserver* SlotConnection::GetSlotObserver() return mSlotObserver; } -SignalConnection::SignalConnection( CallbackBase* callback ) -: mSignalObserver( nullptr ), - mCallback( callback ) +SignalConnection::SignalConnection(CallbackBase* callback) +: mSignalObserver(nullptr), + mCallback(callback) { } -SignalConnection::SignalConnection( SignalObserver* signalObserver, CallbackBase* callback ) -: mSignalObserver( signalObserver ), - mCallback( callback ) +SignalConnection::SignalConnection(SignalObserver* signalObserver, CallbackBase* callback) +: mSignalObserver(signalObserver), + mCallback(callback) { } @@ -65,12 +64,12 @@ SignalConnection::~SignalConnection() delete mCallback; } -void SignalConnection::Disconnect( SlotObserver* slotObserver ) +void SignalConnection::Disconnect(SlotObserver* slotObserver) { - if( mSignalObserver ) + if(mSignalObserver) { // tell the slot the signal wants to disconnect - mSignalObserver->SignalDisconnected( slotObserver, mCallback ); + mSignalObserver->SignalDisconnected(slotObserver, mCallback); mSignalObserver = nullptr; } diff --git a/dali/public-api/signals/signal-slot-connections.h b/dali/public-api/signals/signal-slot-connections.h index d21e088..2a76199 100644 --- a/dali/public-api/signals/signal-slot-connections.h +++ b/dali/public-api/signals/signal-slot-connections.h @@ -46,7 +46,6 @@ class CallbackBase; class DALI_CORE_API SlotConnection { public: - /** * @brief Constructor. * @@ -79,14 +78,12 @@ public: SlotObserver* GetSlotObserver(); private: - - SlotConnection( const SlotConnection& ) = delete; ///< Deleted copy constructor. @SINCE_1_0.0 - SlotConnection( SlotConnection&& ) = delete; ///< Deleted move constructor. @SINCE_1_9.25 - SlotConnection& operator=( const SlotConnection& ) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0 - SlotConnection& operator=( SlotConnection&& ) = delete; ///< Deleted move assignment operator. @SINCE_1_9.25 + SlotConnection(const SlotConnection&) = delete; ///< Deleted copy constructor. @SINCE_1_0.0 + SlotConnection(SlotConnection&&) = delete; ///< Deleted move constructor. @SINCE_1_9.25 + SlotConnection& operator=(const SlotConnection&) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0 + SlotConnection& operator=(SlotConnection&&) = delete; ///< Deleted move assignment operator. @SINCE_1_9.25 private: - SlotObserver* mSlotObserver; ///< a pointer to the slot observer (not owned) CallbackBase* mCallback; ///< The callback. This is not owned, the corresponding SignalConnection has ownership. }; @@ -108,14 +105,13 @@ private: class DALI_CORE_API SignalConnection { public: - /** * @brief Constructor. * * @SINCE_1_0.0 * @param[in] callback The callback which should be a C function */ - SignalConnection( CallbackBase* callback ); + SignalConnection(CallbackBase* callback); /** * @brief Constructor. @@ -124,7 +120,7 @@ public: * @param[in] signalObserver The signal observer * @param[in] callback Ownership of this callback object is taken */ - SignalConnection( SignalObserver* signalObserver, CallbackBase* callback ); + SignalConnection(SignalObserver* signalObserver, CallbackBase* callback); /** * @brief Non-virtual destructor, not intended as a base class. @@ -138,7 +134,7 @@ public: * @SINCE_1_0.0 * @param[in] slotObserver The signal disconnecting from the slot */ - void Disconnect( SlotObserver* slotObserver ); + void Disconnect(SlotObserver* slotObserver); /** * @brief Retrieves the callback. @@ -149,16 +145,14 @@ public: CallbackBase* GetCallback(); private: - - SignalConnection( const SignalConnection& ) = delete; ///< Deleted copy constructor. @SINCE_1_0.0 - SignalConnection( SignalConnection&& ) = delete; ///< Deleted move constructor. @SINCE_1_9.25 - SignalConnection& operator=( const SignalConnection& ) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0 - SignalConnection& operator=( SignalConnection&& ) = delete; ///< Deleted move assignment operator. @SINCE_1_9.25 + SignalConnection(const SignalConnection&) = delete; ///< Deleted copy constructor. @SINCE_1_0.0 + SignalConnection(SignalConnection&&) = delete; ///< Deleted move constructor. @SINCE_1_9.25 + SignalConnection& operator=(const SignalConnection&) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0 + SignalConnection& operator=(SignalConnection&&) = delete; ///< Deleted move assignment operator. @SINCE_1_9.25 private: - SignalObserver* mSignalObserver; ///< a pointer to the signal observer (not owned) - CallbackBase* mCallback; ///< The callback, has ownership. + CallbackBase* mCallback; ///< The callback, has ownership. }; /** diff --git a/dali/public-api/signals/signal-slot-observers.cpp b/dali/public-api/signals/signal-slot-observers.cpp index 148b56d..b8c293a 100644 --- a/dali/public-api/signals/signal-slot-observers.cpp +++ b/dali/public-api/signals/signal-slot-observers.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -20,7 +20,6 @@ namespace Dali { - SignalObserver::SignalObserver() { } diff --git a/dali/public-api/signals/signal-slot-observers.h b/dali/public-api/signals/signal-slot-observers.h index 0d0fbe4..bd6016c 100644 --- a/dali/public-api/signals/signal-slot-observers.h +++ b/dali/public-api/signals/signal-slot-observers.h @@ -2,7 +2,7 @@ #define DALI_SIGNAL_SLOT_OBSERVERS_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -40,7 +40,6 @@ class CallbackBase; class DALI_CORE_API SignalObserver { public: - /** * @brief Constructor. * @SINCE_1_0.0 @@ -60,7 +59,7 @@ public: * @param[in] slotObserver The signal that has disconnected * @param[in] callback The callback attached to the signal disconnected */ - virtual void SignalDisconnected( SlotObserver* slotObserver, CallbackBase* callback ) = 0; + virtual void SignalDisconnected(SlotObserver* slotObserver, CallbackBase* callback) = 0; }; /** @@ -72,7 +71,6 @@ public: class DALI_CORE_API SlotObserver { public: - /** * @brief Constructor. * @SINCE_1_0.0 @@ -91,7 +89,7 @@ public: * @SINCE_1_0.0 * @param[in] callback The callback attached to the signal disconnected */ - virtual void SlotDisconnected( CallbackBase* callback ) = 0; + virtual void SlotDisconnected(CallbackBase* callback) = 0; }; /** diff --git a/dali/public-api/signals/slot-delegate.h b/dali/public-api/signals/slot-delegate.h index 251a2d8..acbd1ff 100644 --- a/dali/public-api/signals/slot-delegate.h +++ b/dali/public-api/signals/slot-delegate.h @@ -72,19 +72,18 @@ namespace Dali * @endcode * @SINCE_1_0.0 */ -template +template class SlotDelegate { public: - /** * @brief Constructor. * * @SINCE_1_0.0 * @param[in] slot The object with a callback */ - SlotDelegate( Slot* slot ) - : mSlot( slot ) + SlotDelegate(Slot* slot) + : mSlot(slot) { } @@ -138,14 +137,12 @@ public: } private: - - SlotDelegate( const SlotDelegate& ) = delete; ///< Deleted copy constructor. @SINCE_1_0.0 - SlotDelegate( SlotDelegate&& ) = delete; ///< Deleted move constructor. @SINCE_1_9.25 - SlotDelegate& operator=( const SlotDelegate& ) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0 - SlotDelegate& operator=( SlotDelegate&& ) = delete; ///< Deleted move assignment operator. @SINCE_1_9.25 + SlotDelegate(const SlotDelegate&) = delete; ///< Deleted copy constructor. @SINCE_1_0.0 + SlotDelegate(SlotDelegate&&) = delete; ///< Deleted move constructor. @SINCE_1_9.25 + SlotDelegate& operator=(const SlotDelegate&) = delete; ///< Deleted copy assignment operator. @SINCE_1_0.0 + SlotDelegate& operator=(SlotDelegate&&) = delete; ///< Deleted move assignment operator. @SINCE_1_9.25 private: - Slot* mSlot; ///< The slot object // Use composition instead of inheritance (virtual methods don't mix well with templates) diff --git a/dali/public-api/size-negotiation/relayout-container.h b/dali/public-api/size-negotiation/relayout-container.h index 7cc2ae5..19a076e 100644 --- a/dali/public-api/size-negotiation/relayout-container.h +++ b/dali/public-api/size-negotiation/relayout-container.h @@ -2,7 +2,7 @@ #define DALI_RELAYOUT_CONTAINER_H /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -39,19 +39,22 @@ using RelayoutContainerPtr = RelayoutContainer*; class RelayoutContainer { public: - /** * @brief Default constructor. * * @SINCE_1_0.0 */ - RelayoutContainer() {} + RelayoutContainer() + { + } /** * @brief Virtual destructor. * @SINCE_1_0.0 */ - virtual ~RelayoutContainer() {} + virtual ~RelayoutContainer() + { + } /** * @brief Adds relayout information to the container if it doesn't already exist. @@ -60,8 +63,7 @@ public: * @param actor The actor to relayout * @param size The size to relayout */ - virtual void Add( const Actor& actor, const Vector2& size ) = 0; - + virtual void Add(const Actor& actor, const Vector2& size) = 0; }; /** -- 2.7.4