[dali_1.1.39] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / devel-api / rendering / texture.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.h>  // Dali::Texture
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/event/rendering/texture-impl.h> // Dali::Internal::Texture
23
24
25 namespace Dali
26 {
27
28 Texture Texture::New( TextureType::Type type, Pixel::Format format, unsigned int width, unsigned int height )
29 {
30   Internal::NewTexturePtr texture = Internal::NewTexture::New(type, format, width, height );
31   return Texture( texture.Get() );
32 }
33
34 Texture Texture::New( NativeImageInterface& nativeImageInterface )
35 {
36   Internal::NewTexturePtr texture = Internal::NewTexture::New( nativeImageInterface );
37   return Texture( texture.Get() );
38 }
39
40 Texture::Texture()
41 {
42 }
43
44 Texture::~Texture()
45 {
46 }
47
48 Texture::Texture( const Texture& handle )
49 : BaseHandle( handle )
50 {
51 }
52
53 Texture Texture::DownCast( BaseHandle handle )
54 {
55   return Texture( dynamic_cast<Dali::Internal::NewTexture*>(handle.GetObjectPtr()));
56 }
57
58 Texture& Texture::operator=( const Texture& handle )
59 {
60   BaseHandle::operator=( handle );
61   return *this;
62 }
63
64 void Texture::Upload( Vector<unsigned char>& buffer )
65 {
66   return GetImplementation(*this).Upload( buffer );
67 }
68
69 void Texture::Upload( Vector<unsigned char>& buffer,
70                unsigned int layer, unsigned int mipmap,
71                unsigned int xOffset, unsigned int yOffset,
72                unsigned int width, unsigned int height )
73 {
74   return GetImplementation(*this).Upload( buffer, layer, mipmap, xOffset, yOffset, width, height );
75 }
76
77 void Texture::Upload( PixelData pixelData )
78 {
79   //TODO: Implement this method once PixelData uses handle/body pattern
80   DALI_ASSERT_ALWAYS( false && "Not implemented yet");
81 }
82
83 void Texture::GenerateMipmaps()
84 {
85   return GetImplementation(*this).GenerateMipmaps();
86 }
87
88 unsigned int Texture::GetWidth() const
89 {
90   return GetImplementation(*this).GetWidth();
91 }
92
93 unsigned int Texture::GetHeight() const
94 {
95   return GetImplementation(*this).GetHeight();
96 }
97
98 Texture::Texture( Internal::NewTexture* pointer )
99 : BaseHandle( pointer )
100 {
101 }
102
103 } //namespace Dali