X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fsuper-blur-view%2Fsuper-blur-view-impl.cpp;h=6ed846fe92925b93d19f4a2e302a778c21adc014;hp=78f354b1f7082f0a31feac6dc32978d38d452df7;hb=dea624eb348a4926d8761c8a1364f03f9f71acf5;hpb=aa273253ab5bb8febb5e4afa7cd511cd945f40d7 diff --git a/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp b/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp index 78f354b..6ed846f 100644 --- a/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.cpp +++ b/dali-toolkit/internal/controls/super-blur-view/super-blur-view-impl.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. @@ -21,7 +21,7 @@ // EXTERNAL INCLUDES #include #include -#include +#include #include #include #include @@ -32,6 +32,7 @@ // INTERNAL_INCLUDES #include #include +#include #include #include @@ -95,104 +96,6 @@ struct ActorOpacityConstraint Vector2 mRange; }; -#define DALI_COMPOSE_SHADER(STR) #STR - -const char * const BASIC_VERTEX_SOURCE = DALI_COMPOSE_SHADER( - precision mediump float;\n - attribute mediump vec2 aPosition;\n - attribute mediump vec2 aTexture;\n - varying mediump vec2 vTexCoord;\n - uniform mediump mat4 uMvpMatrix;\n - uniform mediump vec3 uSize;\n - \n - void main()\n - {\n - mediump vec4 vertexPosition = vec4(aPosition * uSize.xy, 0.0, 1.0);\n - vTexCoord = aTexture;\n - gl_Position = uMvpMatrix * vertexPosition;\n - }\n -); - -const char * const BASIC_FRAGMENT_SOURCE = DALI_COMPOSE_SHADER( - precision mediump float;\n - varying mediump vec2 vTexCoord;\n - uniform sampler2D sTexture;\n - uniform vec4 uColor;\n - \n - void main()\n - {\n - gl_FragColor = texture2D(sTexture, vTexCoord);\n - gl_FragColor *= uColor; - }\n -); - -Renderer CreateRenderer( const char* vertexSrc, const char* fragmentSrc ) -{ - Shader shader = Shader::New( vertexSrc, fragmentSrc ); - - Geometry texturedQuadGeometry = Geometry::New(); - - struct VertexPosition { Vector2 position; }; - struct VertexTexture { Vector2 texture; }; - - VertexPosition positionArray[] = - { - { Vector2( -0.5f, -0.5f ) }, - { Vector2( 0.5f, -0.5f ) }, - { Vector2( -0.5f, 0.5f ) }, - { Vector2( 0.5f, 0.5f ) } - }; - uint32_t numberOfVertices = sizeof(positionArray)/sizeof(VertexPosition); - - VertexTexture uvArray[] = - { - { Vector2( 0.0f, 0.0f ) }, - { Vector2( 1.0f, 0.0f ) }, - { Vector2( 0.0f, 1.0f ) }, - { Vector2( 1.0f, 1.0f ) } - }; - - Property::Map positionVertexFormat; - positionVertexFormat["aPosition"] = Property::VECTOR2; - PropertyBuffer positionVertices = PropertyBuffer::New( positionVertexFormat ); - positionVertices.SetData( positionArray, numberOfVertices ); - texturedQuadGeometry.AddVertexBuffer( positionVertices ); - - Property::Map textureVertexFormat; - textureVertexFormat["aTexture"] = Property::VECTOR2; - PropertyBuffer textureVertices = PropertyBuffer::New( textureVertexFormat ); - textureVertices.SetData( uvArray, numberOfVertices ); - texturedQuadGeometry.AddVertexBuffer( textureVertices ); - - const uint16_t indices[] = { 0, 3, 1, 0, 2, 3 }; - texturedQuadGeometry.SetIndexBuffer ( &indices[0], sizeof( indices )/ sizeof( indices[0] ) ); - - Renderer renderer = Renderer::New( texturedQuadGeometry, shader ); - - TextureSet textureSet = TextureSet::New(); - renderer.SetTextures( textureSet ); - - return renderer; -} - -void SetRendererTexture( Renderer& renderer, Texture& texture ) -{ - if( renderer ) - { - TextureSet textureSet = renderer.GetTextures(); - textureSet.SetTexture( 0u, texture ); - } -} - -void SetRendererTexture( Renderer& renderer, FrameBuffer& frameBuffer ) -{ - if( frameBuffer ) - { - Texture texture = frameBuffer.GetColorTexture(); - SetRendererTexture( renderer, texture ); - } -} - } // namespace namespace Dali @@ -329,8 +232,8 @@ void SuperBlurView::BlurTexture( unsigned int idx, Texture texture ) GAUSSIAN_BLUR_BELL_CURVE_WIDTH + GAUSSIAN_BLUR_BELL_CURVE_WIDTH_INCREMENTATION*static_cast(idx), GAUSSIAN_BLUR_RENDER_TARGET_PIXEL_FORMAT, GAUSSIAN_BLUR_DOWNSAMPLE_WIDTH_SCALE, GAUSSIAN_BLUR_DOWNSAMPLE_HEIGHT_SCALE, true ); - mGaussianBlurView[idx].SetParentOrigin(ParentOrigin::CENTER); - mGaussianBlurView[idx].SetSize(mTargetSize); + mGaussianBlurView[idx].SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER ); + mGaussianBlurView[idx].SetProperty( Actor::Property::SIZE, mTargetSize ); Stage::GetCurrent().Add( mGaussianBlurView[idx] ); mGaussianBlurView[idx].SetUserImageAndOutputRenderTarget( texture, mBlurredImage[idx] ); @@ -391,15 +294,15 @@ void SuperBlurView::OnSizeSet( const Vector3& targetSize ) Control::OnSizeSet( targetSize ); } -void SuperBlurView::OnStageConnection( int depth ) +void SuperBlurView::OnSceneConnection( int depth ) { if( mTargetSize == Vector2::ZERO ) { return; } - // Exception to the rule, chaining up first ensures visuals have SetOnStage called to create their renderers - Control::OnStageConnection( depth ); + // Exception to the rule, chaining up first ensures visuals have SetOnScene called to create their renderers + Control::OnSceneConnection( depth ); Actor self = Self(); @@ -431,7 +334,7 @@ void SuperBlurView::OnStageConnection( int depth ) } } -void SuperBlurView::OnStageDisconnection() +void SuperBlurView::OnSceneDisconnection() { for(unsigned int i=0; i