[dali_1.1.39] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / devel-api / rendering / texture-set.cpp
1 /*
2  * Copyright (c) 2016 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/rendering/texture-set.h>  // Dali::TextureSet
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/event/rendering/texture-set-impl.h> // Dali::Internal::TextureSet
23 #include <dali/internal/event/rendering/sampler-impl.h> // Dali::Internal::Sampler
24 #include <dali/internal/event/rendering/shader-impl.h> // Dali::Internal::Shader
25
26 namespace Dali
27 {
28
29 TextureSet TextureSet::New()
30 {
31   Internal::TextureSetPtr textureSet = Internal::TextureSet::New();
32   return TextureSet( textureSet.Get() );
33 }
34
35 TextureSet::TextureSet()
36 {
37 }
38
39 TextureSet::~TextureSet()
40 {
41 }
42
43 TextureSet::TextureSet( const TextureSet& handle )
44 : BaseHandle( handle )
45 {
46 }
47
48 TextureSet TextureSet::DownCast( BaseHandle handle )
49 {
50   return TextureSet( dynamic_cast<Dali::Internal::TextureSet*>(handle.GetObjectPtr()));
51 }
52
53 TextureSet& TextureSet::operator=( const TextureSet& handle )
54 {
55   BaseHandle::operator=( handle );
56   return *this;
57 }
58
59 void TextureSet::SetImage( size_t index, Image image )
60 {
61   if( image )
62   {
63     Internal::ImagePtr imagePtr( &GetImplementation( image ) );
64     GetImplementation(*this).SetImage( index, imagePtr );
65   }
66   else
67   {
68     GetImplementation(*this).SetImage( index, NULL );
69   }
70 }
71
72 void TextureSet::SetTexture( size_t index, Texture texture )
73 {
74   if( texture )
75   {
76     Internal::NewTexturePtr texturePtr( &GetImplementation( texture ) );
77     GetImplementation(*this).SetTexture( index, texturePtr );
78   }
79   else
80   {
81     GetImplementation(*this).SetTexture( index, NULL );
82   }
83 }
84
85 Image TextureSet::GetImage( size_t index ) const
86 {
87   Internal::Image* imagePtr = GetImplementation(*this).GetImage( index );
88   return Dali::Image( imagePtr );
89 }
90
91 Texture TextureSet::GetTexture( size_t index ) const
92 {
93   Internal::NewTexture* texturePtr = GetImplementation(*this).GetTexture( index );
94   return Dali::Texture( texturePtr );
95 }
96
97 void TextureSet::SetSampler( size_t index, Sampler sampler )
98 {
99   if( sampler )
100   {
101     Internal::SamplerPtr samplerPtr( &GetImplementation( sampler ) );
102     GetImplementation(*this).SetSampler( index, samplerPtr );
103   }
104   else
105   {
106     GetImplementation(*this).SetSampler( index, NULL );
107   }
108 }
109
110 Sampler TextureSet::GetSampler( size_t index ) const
111 {
112   Internal::Sampler* samplerPtr = GetImplementation(*this).GetSampler( index );
113   return Dali::Sampler( samplerPtr );
114 }
115
116 size_t TextureSet::GetTextureCount() const
117 {
118   return GetImplementation(*this).GetTextureCount();
119 }
120
121 TextureSet::TextureSet( Internal::TextureSet* pointer )
122 : BaseHandle( pointer )
123 {
124 }
125
126 } //namespace Dali