X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftransition-effects%2Fcube-transition-effect-impl.h;h=5eda6b2ba8369580fa1898b60e17b0546adcdfd1;hp=57fd2052ba3681b4d1f746b8808f9e606164a5f6;hb=964dd7f6a94f280063595dbb48fb8f1232836789;hpb=ee3bdc95f623f41feb37be10f21bef1d9da1e805 diff --git a/dali-toolkit/internal/transition-effects/cube-transition-effect-impl.h b/dali-toolkit/internal/transition-effects/cube-transition-effect-impl.h index 57fd205..5eda6b2 100644 --- a/dali-toolkit/internal/transition-effects/cube-transition-effect-impl.h +++ b/dali-toolkit/internal/transition-effects/cube-transition-effect-impl.h @@ -1,8 +1,8 @@ -#ifndef __DALI_TOOLKIT_INTERNAL_CUBE_TRANSITION_EFFECT_H__ -#define __DALI_TOOLKIT_INTERNAL_CUBE_TRANSITION_EFFECT_H__ +#ifndef DALI_TOOLKIT_INTERNAL_CUBE_TRANSITION_EFFECT_H +#define DALI_TOOLKIT_INTERNAL_CUBE_TRANSITION_EFFECT_H /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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,15 +20,11 @@ // EXTERNAL INCLUDES #include -#include -#include -#include -#include -#include -#include +#include // INTERNAL INCLUDES -#include +#include +#include namespace Dali { @@ -42,93 +38,9 @@ namespace Internal { /** - * Create a image with size of viewAreaSize - * with the effect image as its center part and (0,0,0,1) at other parts - */ -class FullAreaImageCreator : public ShaderEffect -{ - -public: - - /** - * Create an uninitialized FullAreaImageCreator - * this can be initialized with FullAreaImageCreator::New() - */ - FullAreaImageCreator(){} - - /** - * @brief Destructor - * - * This is non-virtual since derived Handle types must not contain data or virtual methods. - */ - ~FullAreaImageCreator(){} - - /** - * Create an initialized FullAreaImageCreator. - * @return A handle to a newly allocated Dali resource. - */ - static FullAreaImageCreator New() - { - std::string vertexShader( - "uniform mediump vec4 uRegion; \n" - "void main() \n" - "{\n" - " gl_Position = uProjection * uModelView * vec4(aPosition, 1.0);\n" - " vTexCoord.s = (aTexCoord.s - uRegion.s) / uRegion.p;" - " vTexCoord.t = ( 1.0 - aTexCoord.t - uRegion.t) / uRegion.q;" - "}\n" - ); - - std::string fragmentShader( - "uniform mediump vec4 uRegion; \n" - "void main() \n" - "{\n" - " if( vTexCoord.s > 0.0 && vTexCoord.s < 1.0 && vTexCoord.t > 0.0 && vTexCoord.t < 1.0) \n" - " { \n" - " gl_FragColor = texture2D( sEffect, vTexCoord ) * uColor ; \n" - " } \n" - " else \n" - " { \n" - " gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); \n" - " } \n" - "}\n" - ); - - ShaderEffect shaderEffectCustom = ShaderEffect::New(vertexShader, fragmentShader); - FullAreaImageCreator handle( shaderEffectCustom ); - - return handle; - } - - /** - * Set up the position and size of the effect texture - * @param[in] viewArea the size of full-area image to create - * @param[in] size the size of effect texture - */ - void SetRegionSize( const Vector2& viewArea, const Vector2& size ) - { - Vector2 sizeRatio( std::min(1.f, size.x / viewArea.x), std::min(1.f, size.y / viewArea.y) ); - Vector4 region( (1.f-sizeRatio.x)*0.5f, - (1.f-sizeRatio.y)*0.5f, - sizeRatio.x, - sizeRatio.y ); - SetUniform( "uRegion", region ); - } - -private: - - FullAreaImageCreator( ShaderEffect handle ) - : ShaderEffect( handle ) - {} - -}; - - - -/** * CubeTransitionEffect implementation class */ -class CubeTransitionEffect : public Dali::BaseObject, public ConnectionTracker +class CubeTransitionEffect : public Control { public: @@ -159,24 +71,19 @@ public: float GetCubeDisplacement() const; /** - * @copydoc Toolkit::CubeTransitionEffect::GetRoot + * @copydoc Toolkit::CubeTransitionEffect::IsTransitioning */ - Actor GetRoot(); + bool IsTransitioning(); /** - * @copydoc Toolkit::CubeTransitionEffect::IsTransiting + * @copydoc Toolkit::CubeTransitionEffect::SetCurrentTexture */ - bool IsTransiting(); + void SetCurrentTexture( Texture texture ); /** - * @copydoc Toolkit::CubeTransitionEffect::SetFirstImage + * @copydoc Toolkit::CubeTransitionEffect::SetTargetTexture */ - void SetCurrentImage(ImageActor imageActor); - - /** - * @copydoc Toolkit::CubeTransitionEffect::SetTargetImage - */ - void SetTargetImage(ImageActor imageActor); + void SetTargetTexture( Texture texture ); /** * @copydoc Toolkit::CubeTransitionEffect::StartTransition(bool) @@ -222,15 +129,25 @@ public: //Signal static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ); protected: + /** + * @copydoc CustomActorImpl::OnStageConnection() + */ + virtual void OnStageConnection( int depth ); + + /** + * @copydoc CustomActorImpl::OnStageDisconnection() + */ + virtual void OnStageDisconnection(); + +protected: /** * Construct a new CubeTransitionEffect object * Called in the constructor of subclasses * @param[in] numRows How many rows of cubes * @param[in] numColumns How many columns of cubes - * @param[in] viewAreaSize The size of view area for this transition effect */ - CubeTransitionEffect( unsigned int numRows, unsigned int numColumns, Size viewAreaSize ); + CubeTransitionEffect( unsigned int numRows, unsigned int numColumns ); /** * Initialization steps: creating a layer, two groups of tiles, @@ -238,40 +155,18 @@ protected: */ void Initialize(); -private: - /** - * Create an image actor to serve as a face of the cube - * @param[in] image The image to display. - * @param[in] color The color to set to the actor - * @return The tile actor created - */ - ImageActor CreateTile( Image image, const Vector4& color ); - - /** - * Set Image content to tiles - * As only when the image ready, can we get correct image attributes - * so inside this function, the process needs to be passed to callBack of image resource loading succeed. - * @param[in] imageActor The imageActor whose image content will be set to the tiles - */ - void SetImage(ImageActor imageActor); - - /** - * Callback function of image resource loading succeed - * Set image and pixelArea to tiles - * @param[in] image The image content of the imageActor for transition - */ - void OnImageLoaded(ResourceImage image); +protected: + void SetTargetLeft( unsigned int idx ); + void SetTargetRight( unsigned int idx ); + void SetTargetTop( unsigned int idx ); + void SetTargetBottom( unsigned int idx ); - /** - * Set sub-image to each tile. - * @param[in] image The image content of the imageActor for transition - */ - void PrepareTiles( Image image ); +private: /** * Callback function of transition animation finished - * Hide transition layer, show current imageActor, and set isAnimating flag to false + * Hide transition layer, show current image, and set isAnimating flag to false * @param[in] source The cube transition animation */ void OnTransitionFinished(Animation& source); @@ -297,40 +192,41 @@ private: */ virtual void OnStopTransition() {} + virtual void OnRelayout( const Vector2& size, RelayoutContainer& container ); + + void ResetToInitialState(); + protected: + typedef std::vector< Actor > ActorArray; + enum FACE { TOP, BOTTOM, LEFT, RIGHT }; - unsigned int mNumRows; - unsigned int mNumColumns; - Size mViewAreaSize; - ActorContainer mBoxes; - std::vector< ImageActor > mTiles[2]; - int mRotateIndex; - Size mTileSize; - Actor mRoot; + ActorArray mBoxes; + Vector< FACE > mBoxType; + ActorArray mCurrentTiles; + ActorArray mTargetTiles; - ImageActor mCurrentImage; - unsigned int mContainerIndex; //have the value 0 or 1, refer to mTiles[0] or mTiles[1] + Actor mBoxRoot; - bool mChangeTurningDirection; - bool mIsToNextImage; //if true, cubes rotate counter-clockwise; else clockwise - bool mIsImageLoading; + unsigned int mRows; + unsigned int mColumns; + + Renderer mCurrentRenderer; + Renderer mTargetRenderer; + + Texture mCurrentTexture; + Texture mTargetTexture; - float mAnimationDuration; Animation mAnimation; + + Vector2 mTileSize; + bool mIsAnimating; bool mIsPaused; + float mAnimationDuration; float mCubeDisplacement; - bool mFirstTransition; - - RenderTask mOffScreenTask; - FrameBufferImage mOffScreenBuffer[2]; - ImageActor mEmptyImage; - FullAreaImageCreator mFullImageCreator; - unsigned int mBufferIndex; - static const Vector4 FULL_BRIGHTNESS; static const Vector4 HALF_BRIGHTNESS; @@ -348,7 +244,7 @@ inline Internal::CubeTransitionEffect& GetImpl(Dali::Toolkit::CubeTransitionEffe { DALI_ASSERT_ALWAYS(obj); - Dali::BaseObject& handle = obj.GetBaseObject(); + Dali::RefObject& handle = obj.GetImplementation(); return static_cast(handle); } @@ -357,7 +253,7 @@ inline const Internal::CubeTransitionEffect& GetImpl(const Dali::Toolkit::CubeTr { DALI_ASSERT_ALWAYS(obj); - const Dali::BaseObject& handle = obj.GetBaseObject(); + const Dali::RefObject& handle = obj.GetImplementation(); return static_cast(handle); } @@ -366,4 +262,4 @@ inline const Internal::CubeTransitionEffect& GetImpl(const Dali::Toolkit::CubeTr } // namespace Dali -#endif /* __DALI_TOOLKIT_INTERNAL_CUBE_TRANSITION_EFFECT_H__ */ +#endif // DALI_TOOLKIT_INTERNAL_CUBE_TRANSITION_EFFECT_H