[3.0] Remove/move experimental features
[platform/core/uifw/dali-core.git] / dali / devel-api / shader-effects / shader-effect.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/devel-api/shader-effects/shader-effect.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/event/effects/shader-effect-impl.h>
23 #include <dali/internal/event/animation/constraint-impl.h>
24 #include <dali/public-api/animation/constraint.h>
25 #include <dali/public-api/math/vector2.h>
26
27 namespace Dali
28 {
29 const float ShaderEffect::DEFAULT_GRID_DENSITY = 40;
30
31 ShaderEffect::ShaderEffect()
32 {
33 }
34
35 ShaderEffect::ShaderEffect(Internal::ShaderEffect* internal)
36 : Handle(internal)
37 {
38 }
39
40 ShaderEffect::~ShaderEffect()
41 {
42 }
43
44 ShaderEffect::ShaderEffect(const ShaderEffect& handle)
45 : Handle(handle)
46 {
47 }
48
49 ShaderEffect& ShaderEffect::operator=(const ShaderEffect& rhs)
50 {
51   BaseHandle::operator=(rhs);
52   return *this;
53 }
54
55 ShaderEffect ShaderEffect::New( const std::string& vertexShader, const std::string& fragmentShader, GeometryHints hints)
56 {
57   Internal::ShaderEffectPtr internal = Internal::ShaderEffect::New( hints );
58
59   internal->SetPrograms( vertexShader, fragmentShader );
60
61   return ShaderEffect( internal.Get() );
62 }
63
64 ShaderEffect ShaderEffect::NewWithPrefix( const std::string& vertexShaderPrefix,
65                                           const std::string& vertexShader,
66                                           const std::string& fragmentShaderPrefix,
67                                           const std::string& fragmentShader,
68                                           GeometryHints hints)
69 {
70   Internal::ShaderEffectPtr internal = Internal::ShaderEffect::New( hints );
71
72   internal->SetPrograms( vertexShaderPrefix, fragmentShaderPrefix, vertexShader, fragmentShader );
73
74   return ShaderEffect( internal.Get() );
75 }
76
77 ShaderEffect ShaderEffect::DownCast( BaseHandle handle )
78 {
79   return ShaderEffect( dynamic_cast<Dali::Internal::ShaderEffect*>(handle.GetObjectPtr()) );
80 }
81
82 void ShaderEffect::SetEffectImage( Image image )
83 {
84   GetImplementation(*this).SetEffectImage( image );
85 }
86
87 void ShaderEffect::SetUniform( const std::string& name, float value, UniformCoordinateType uniformCoordinateType )
88 {
89   GetImplementation(*this).SetUniform( name, value, uniformCoordinateType );
90 }
91
92 void ShaderEffect::SetUniform( const std::string& name, Vector2 value, UniformCoordinateType uniformCoordinateType )
93 {
94   GetImplementation(*this).SetUniform( name, value, uniformCoordinateType );
95 }
96
97 void ShaderEffect::SetUniform( const std::string& name, Vector3 value, UniformCoordinateType uniformCoordinateType )
98 {
99   GetImplementation(*this).SetUniform( name, value, uniformCoordinateType );
100 }
101
102 void ShaderEffect::SetUniform( const std::string& name, Vector4 value, UniformCoordinateType uniformCoordinateType )
103 {
104   GetImplementation(*this).SetUniform( name, value, uniformCoordinateType );
105 }
106
107 void ShaderEffect::SetUniform( const std::string& name, const Matrix& value, UniformCoordinateType uniformCoordinateType )
108 {
109   GetImplementation(*this).SetUniform( name, value, uniformCoordinateType );
110 }
111
112 void ShaderEffect::SetUniform( const std::string& name, const Matrix3& value, UniformCoordinateType uniformCoordinateType )
113 {
114   GetImplementation(*this).SetUniform( name, value, uniformCoordinateType );
115 }
116
117 } // namespace Dali