-
-/**
- * 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 )
- {}
-
-};
-
-
-