Ensure BaseHandle class move noexcept (core public-api)
[platform/core/uifw/dali-core.git] / dali / public-api / rendering / texture.cpp
1 /*
2  * Copyright (c) 2022 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/public-api/rendering/texture.h> // Dali::Texture
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/event/images/pixel-data-impl.h> // Dali::Internal::PixelData
23 #include <dali/internal/event/rendering/texture-impl.h> // Dali::Internal::Texture
24
25 namespace Dali
26 {
27 Texture Texture::New(TextureType::Type type, Pixel::Format format, uint32_t width, uint32_t height)
28 {
29   Internal::TexturePtr texture = Internal::Texture::New(type, format, width, height);
30   return Texture(texture.Get());
31 }
32
33 Texture Texture::New(NativeImageInterface& nativeImageInterface)
34 {
35   Internal::TexturePtr texture = Internal::Texture::New(nativeImageInterface);
36   return Texture(texture.Get());
37 }
38
39 Texture::Texture() = default;
40
41 Texture::~Texture() = default;
42
43 Texture::Texture(const Texture& handle) = default;
44
45 Texture Texture::DownCast(BaseHandle handle)
46 {
47   return Texture(dynamic_cast<Dali::Internal::Texture*>(handle.GetObjectPtr()));
48 }
49
50 Texture& Texture::operator=(const Texture& handle) = default;
51
52 Texture::Texture(Texture&& rhs) noexcept = default;
53
54 Texture& Texture::operator=(Texture&& rhs) noexcept = default;
55
56 bool Texture::Upload(PixelData pixelData)
57 {
58   Internal::PixelData& internalPixelData = GetImplementation(pixelData);
59   return GetImplementation(*this).Upload(&internalPixelData);
60 }
61
62 bool Texture::Upload(PixelData pixelData,
63                      uint32_t  layer,
64                      uint32_t  mipmap,
65                      uint32_t  xOffset,
66                      uint32_t  yOffset,
67                      uint32_t  width,
68                      uint32_t  height)
69 {
70   Internal::PixelData& internalPixelData = GetImplementation(pixelData);
71   return GetImplementation(*this).Upload(&internalPixelData, layer, mipmap, xOffset, yOffset, width, height);
72 }
73
74 void Texture::GenerateMipmaps()
75 {
76   return GetImplementation(*this).GenerateMipmaps();
77 }
78
79 uint32_t Texture::GetWidth() const
80 {
81   return GetImplementation(*this).GetWidth();
82 }
83
84 uint32_t Texture::GetHeight() const
85 {
86   return GetImplementation(*this).GetHeight();
87 }
88
89 Pixel::Format Texture::GetPixelFormat() const
90 {
91   return GetImplementation(*this).GetPixelFormat();
92 }
93
94 Texture::Texture(Internal::Texture* pointer)
95 : BaseHandle(pointer)
96 {
97 }
98
99 } //namespace Dali