From: joogab.yun Date: Tue, 11 Feb 2025 04:33:10 +0000 (+0900) Subject: [Tizen] Add AutoRotation, LetterBox X-Git-Tag: accepted/tizen/7.0/unified/20250212.163958^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bfb8671f550f3796c6b1ae22afb64bccaea18fce;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git [Tizen] Add AutoRotation, LetterBox Change-Id: I6972611ce1b22e2544c56813a3ab8857ba0eeafd --- diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.cpp index 9909164b66..0d3eb0f5ed 100755 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.cpp @@ -129,6 +129,27 @@ public: } + void SetAutoRotationEnabled(bool enable) + { + + } + + bool IsAutoRotationEnabled() const + { + return false; + } + + void SetLetterBoxEnabled(bool enable) + { + + } + + bool IsLetterBoxEnabled() const + { + return false; + } + + public: std::string mUrl; @@ -365,5 +386,26 @@ void VideoPlayer::LowerToBottom() Internal::Adaptor::GetImplementation( *this ).LowerToBottom(); } +void VideoPlayer::SetAutoRotationEnabled(bool enable) +{ + Internal::Adaptor::GetImplementation( *this ).SetAutoRotationEnabled(enable); +} + +bool VideoPlayer::IsAutoRotationEnabled() const +{ + return Internal::Adaptor::GetImplementation( *this ).IsAutoRotationEnabled(); +} + +void VideoPlayer::SetLetterBoxEnabled(bool enable) +{ + Internal::Adaptor::GetImplementation( *this ).SetLetterBoxEnabled(enable); +} + +bool VideoPlayer::IsLetterBoxEnabled() const +{ + return Internal::Adaptor::GetImplementation( *this ).IsLetterBoxEnabled(); +} + + } // namespace Dali; diff --git a/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp index 4dbea796f4..8704a65e19 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp @@ -900,3 +900,22 @@ int UtcDaliVideoViewSynchronizationForWindowRotation(void) END_TEST; } + +// For coverage +int UtcDaliVideoViewDisplayModeForCoverage(void) +{ + ToolkitTestApplication application; + + VideoView videoView = VideoView::New(); + DALI_TEST_CHECK(videoView); + + Toolkit::DevelVideoView::SetAutoRotationEnabled(videoView, true); + // A false return is correct because there is no plugin. + DALI_TEST_EQUALS(false, Toolkit::DevelVideoView::IsAutoRotationEnabled(videoView), TEST_LOCATION); + + Toolkit::DevelVideoView::SetLetterBoxEnabled(videoView, true); + // A false return is correct because there is no plugin. + DALI_TEST_EQUALS(false, Toolkit::DevelVideoView::IsLetterBoxEnabled(videoView), TEST_LOCATION); + + END_TEST; +} diff --git a/dali-toolkit/devel-api/controls/video-view/video-view-devel.cpp b/dali-toolkit/devel-api/controls/video-view/video-view-devel.cpp index f58501349e..f5191978e1 100644 --- a/dali-toolkit/devel-api/controls/video-view/video-view-devel.cpp +++ b/dali-toolkit/devel-api/controls/video-view/video-view-devel.cpp @@ -41,6 +41,26 @@ void PlayAnimation(VideoView videoView, Animation animation) Dali::Toolkit::GetImpl(videoView).PlayAnimation(animation); } +void SetAutoRotationEnabled(VideoView videoView, bool enable) +{ + Dali::Toolkit::GetImpl(videoView).SetAutoRotationEnabled(enable); +} + +bool IsAutoRotationEnabled(VideoView videoView) +{ +return Dali::Toolkit::GetImpl(videoView).IsAutoRotationEnabled(); +} + +void SetLetterBoxEnabled(VideoView videoView, bool enable) +{ + Dali::Toolkit::GetImpl(videoView).SetLetterBoxEnabled(enable); +} + +bool IsLetterBoxEnabled(VideoView videoView) +{ + return Dali::Toolkit::GetImpl(videoView).IsLetterBoxEnabled(); +} + } // namespace DevelVideoView } // namespace Toolkit diff --git a/dali-toolkit/devel-api/controls/video-view/video-view-devel.h b/dali-toolkit/devel-api/controls/video-view/video-view-devel.h index 73d7826f23..c3543c80fa 100644 --- a/dali-toolkit/devel-api/controls/video-view/video-view-devel.h +++ b/dali-toolkit/devel-api/controls/video-view/video-view-devel.h @@ -60,6 +60,38 @@ DALI_TOOLKIT_API VideoView New(VideoSyncMode syncMode); */ DALI_TOOLKIT_API void PlayAnimation(VideoView videoView, Animation animation); +/** + * @brief Sets auto rotation feature. If enabled, video will rotate automatically according to the video orientation. + * + * @param[in] videoView The current VideoView + * @param[in] enable true if auto rotation should be enabled, false otherwise. Default value is false. + */ +DALI_TOOLKIT_API void SetAutoRotationEnabled(VideoView videoView, bool enable); + +/** + * @brief Checks whether auto rotation feature is enabled. + * + * @param[in] videoView The current VideoView + * @return true if auto rotation is enabled, false otherwise. Default value is false. + */ +DALI_TOOLKIT_API bool IsAutoRotationEnabled(VideoView videoView); + +/** + * @brief Sets letter box feature. If enabled, the video will play in the video player's aspect ratio. + * + * @param[in] videoView The current VideoView + * @param[in] enable true if letter box should be enabled, false otherwise. Default value is false. + */ +DALI_TOOLKIT_API void SetLetterBoxEnabled(VideoView videoView, bool enable); + +/** + * @brief Checks whether letter box feature is enabled. + * + * @param[in] videoView The current VideoView + * @return true if letter box is enabled, false otherwise. Default value is false. + */ +DALI_TOOLKIT_API bool IsLetterBoxEnabled(VideoView videoView); + } // namespace DevelVideoView } // namespace Toolkit diff --git a/dali-toolkit/internal/controls/camera-view/camera-view-impl.cpp b/dali-toolkit/internal/controls/camera-view/camera-view-impl.cpp index 772c1a0382..3116f52214 100644 --- a/dali-toolkit/internal/controls/camera-view/camera-view-impl.cpp +++ b/dali-toolkit/internal/controls/camera-view/camera-view-impl.cpp @@ -188,7 +188,12 @@ Dali::Shader CameraView::CreateShader(Dali::NativeImageSourcePtr nativeImageSour nativeImageSourcePtr->ApplyNativeFragmentShader(fragmentShader); - return Dali::Shader::New(vertexShader, fragmentShader); + Dali::Shader shader = Dali::Shader::New(vertexShader, fragmentShader); + // Initialize shader properties + shader.RegisterProperty("uRotationMatrix", Property::Value(Vector4(1.0f, 0.0f, 0.0f, 1.0f))); + shader.RegisterProperty("uSizeRatio", Property::Value(Vector2(0.0f, 0.0f))); + + return shader; } } // namespace Internal diff --git a/dali-toolkit/internal/controls/video-view/video-view-impl.cpp b/dali-toolkit/internal/controls/video-view/video-view-impl.cpp index 154caac0c3..0ef2ea10ed 100644 --- a/dali-toolkit/internal/controls/video-view/video-view-impl.cpp +++ b/dali-toolkit/internal/controls/video-view/video-view-impl.cpp @@ -711,6 +711,7 @@ void VideoView::SetNativeImageTarget() textureSet.SetTexture(0u, mNativeTexture); } Self().AddRenderer(mTextureRenderer); + mTextureRenderer.SetProperty(DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::CONTINUOUSLY); // Note VideoPlayer::SetRenderingTarget resets all the options. (e.g. url, mute, looping) mVideoPlayer.SetRenderingTarget(nativeImageSourcePtr); @@ -887,7 +888,11 @@ Dali::Shader VideoView::CreateShader() DevelTexture::ApplyNativeFragmentShader(mNativeTexture, fragmentShader); } - return Dali::Shader::New(vertexShader, fragmentShader); + Dali::Shader shader = Dali::Shader::New(vertexShader, fragmentShader); + // Initialize shader properties + shader.RegisterProperty("uRotationMatrix", Property::Value(Vector4(1.0f, 0.0f, 0.0f, 1.0f))); + shader.RegisterProperty("uSizeRatio", Property::Value(Vector2(0.0f, 0.0f))); + return shader; } bool VideoView::GetStringFromProperty(const Dali::Property::Value& value, std::string& output) @@ -954,6 +959,27 @@ VideoPlayer VideoView::GetVideoPlayer() return mVideoPlayer; } +void VideoView::SetAutoRotationEnabled(bool enable) +{ + mVideoPlayer.SetAutoRotationEnabled(enable); +} + +bool VideoView::IsAutoRotationEnabled() const +{ + return mVideoPlayer.IsAutoRotationEnabled(); +} + +void VideoView::SetLetterBoxEnabled(bool enable) +{ + mVideoPlayer.SetLetterBoxEnabled(enable); +} + +bool VideoView::IsLetterBoxEnabled() const +{ + return mVideoPlayer.IsLetterBoxEnabled(); +} + + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/controls/video-view/video-view-impl.h b/dali-toolkit/internal/controls/video-view/video-view-impl.h index c8b2a83ff2..707a6cbd90 100644 --- a/dali-toolkit/internal/controls/video-view/video-view-impl.h +++ b/dali-toolkit/internal/controls/video-view/video-view-impl.h @@ -278,6 +278,30 @@ public: */ VideoPlayer GetVideoPlayer(); + /** + * @brief Sets auto rotation feature. If enabled, video will rotate automatically according to the video orientation. + * @param[in] enable Whether to enable auto rotation feature. Default is false. + */ + void SetAutoRotationEnabled(bool enable); + + /** + * @brief Checks whether auto rotation feature is enabled. + * @return True if auto rotation feature is enabled. Default is false. + */ + bool IsAutoRotationEnabled() const; + + /** + * @brief Sets letter box feature. If enabled, the video will play in the video player's aspect ratio. + * @param[in] enable Whether to enable letter box feature. Default is false. + */ + void SetLetterBoxEnabled(bool enable); + + /** + * @brief Checks whether letter box feature is enabled. + * @return True if letter box feature is enabled. Default is false. + */ + bool IsLetterBoxEnabled() const; + private: // From Control /** * @copydoc Toolkit::Control::OnInitialize() diff --git a/dali-toolkit/internal/graphics/shaders/video-view-texture.vert b/dali-toolkit/internal/graphics/shaders/video-view-texture.vert index 79cbb23937..59b908c450 100644 --- a/dali-toolkit/internal/graphics/shaders/video-view-texture.vert +++ b/dali-toolkit/internal/graphics/shaders/video-view-texture.vert @@ -2,10 +2,25 @@ attribute mediump vec2 aPosition; varying mediump vec2 vTexCoord; uniform highp mat4 uMvpMatrix; uniform highp vec3 uSize; +uniform highp vec2 uSizeRatio; +uniform highp mat2 uRotationMatrix; varying mediump vec2 sTexCoordRect; +highp vec2 getSize(highp vec2 size) +{ + if (size.x < 0.5 || size.y < 0.5) + { + return uSize.xy; + } + else + { + highp float ratio = min(uSize.x / size.x, uSize.y / size.y); + return vec2(size.xy * ratio); + } +} + void main() { - gl_Position = uMvpMatrix * vec4(aPosition * uSize.xy, 0.0, 1.0); - vTexCoord = aPosition + vec2(0.5); + gl_Position = uMvpMatrix * vec4(aPosition * getSize(uSizeRatio), 0.0, 1.0); + vTexCoord = aPosition * uRotationMatrix + vec2(0.5); }