2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/public-api/shader-effects/material.h> // Dali::Material
22 #include <dali/internal/event/effects/material-impl.h> // Dali::Internal::Material
23 #include <dali/internal/event/effects/sampler-impl.h> // Dali::Internal::Sampler
24 #include <dali/internal/event/effects/shader-impl.h> // Dali::Internal::Shader
29 Material Material::New( Shader shader )
32 Internal::MaterialPtr material = Internal::Material::New();
33 material->SetShader( GetImplementation(shader) );
35 return Material( material.Get() );
46 Material::Material( const Material& handle )
51 Material Material::DownCast( BaseHandle handle )
53 return Material( dynamic_cast<Dali::Internal::Material*>(handle.GetObjectPtr()));
56 Material& Material::operator=( const Material& handle )
58 BaseHandle::operator=( handle );
62 void Material::SetShader( Shader& shader )
64 DALI_ASSERT_ALWAYS( shader && "Shader handle is uninitialized" );
65 GetImplementation(*this).SetShader( GetImplementation( shader ) );
68 void Material::AddSampler( Sampler& sampler )
70 DALI_ASSERT_ALWAYS( sampler && "Sampler handle is uninitialized" );
71 GetImplementation(*this).AddSampler( GetImplementation( sampler ) );
74 std::size_t Material::GetNumberOfSamplers() const
76 return GetImplementation(*this).GetNumberOfSamplers();
79 void Material::RemoveSampler( std::size_t index )
81 GetImplementation(*this).RemoveSampler( index );
84 void Material::SetFaceCullingMode( FaceCullingMode cullingMode )
86 GetImplementation(*this).SetFaceCullingMode( cullingMode );
89 void Material::SetBlendMode( BlendingMode::Type mode )
91 GetImplementation(*this).SetBlendMode( mode );
94 BlendingMode::Type Material::GetBlendMode() const
96 return GetImplementation(*this).GetBlendMode();
99 void Material::SetBlendFunc( BlendingFactor::Type srcFactorRgba,
100 BlendingFactor::Type destFactorRgba )
102 GetImplementation(*this).SetBlendFunc( srcFactorRgba, destFactorRgba );
105 void Material::SetBlendFunc( BlendingFactor::Type srcFactorRgb,
106 BlendingFactor::Type destFactorRgb,
107 BlendingFactor::Type srcFactorAlpha,
108 BlendingFactor::Type destFactorAlpha )
110 GetImplementation(*this).SetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
113 void Material::GetBlendFunc( BlendingFactor::Type& srcFactorRgb,
114 BlendingFactor::Type& destFactorRgb,
115 BlendingFactor::Type& srcFactorAlpha,
116 BlendingFactor::Type& destFactorAlpha ) const
118 GetImplementation(*this).GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
121 void Material::SetBlendEquation( BlendingEquation::Type equationRgba )
123 GetImplementation(*this).SetBlendEquation( equationRgba );
126 void Material::SetBlendEquation( BlendingEquation::Type equationRgb,
127 BlendingEquation::Type equationAlpha )
129 GetImplementation(*this).SetBlendEquation( equationRgb, equationAlpha );
132 void Material::GetBlendEquation( BlendingEquation::Type& equationRgb,
133 BlendingEquation::Type& equationAlpha ) const
135 GetImplementation(*this).GetBlendEquation( equationRgb, equationAlpha );
138 void Material::SetBlendColor( const Vector4& color )
140 GetImplementation(*this).SetBlendColor( color );
143 const Vector4& Material::GetBlendColor() const
145 return GetImplementation(*this).GetBlendColor();
148 Material::Material( Internal::Material* pointer )