2 * Copyright (c) 2023 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/rendering/texture.h> // Dali::Texture
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
27 Texture Texture::New(TextureType::Type type, Pixel::Format format, uint32_t width, uint32_t height)
29 Internal::TexturePtr texture = Internal::Texture::New(type, format, width, height);
30 return Texture(texture.Get());
33 Texture Texture::New(TextureType::Type type)
35 Internal::TexturePtr texture = Internal::Texture::New(type, Pixel::INVALID, 0u, 0u);
36 return Texture(texture.Get());
39 Texture Texture::New(NativeImageInterface& nativeImageInterface)
41 Internal::TexturePtr texture = Internal::Texture::New(nativeImageInterface);
42 return Texture(texture.Get());
45 Texture::Texture() = default;
47 Texture::~Texture() = default;
49 Texture::Texture(const Texture& handle) = default;
51 Texture Texture::DownCast(BaseHandle handle)
53 return Texture(dynamic_cast<Dali::Internal::Texture*>(handle.GetObjectPtr()));
56 Texture& Texture::operator=(const Texture& handle) = default;
58 Texture::Texture(Texture&& rhs) noexcept = default;
60 Texture& Texture::operator=(Texture&& rhs) noexcept = default;
62 bool Texture::Upload(PixelData pixelData)
64 Internal::PixelData& internalPixelData = GetImplementation(pixelData);
65 return GetImplementation(*this).Upload(&internalPixelData);
68 bool Texture::Upload(PixelData pixelData,
76 Internal::PixelData& internalPixelData = GetImplementation(pixelData);
77 return GetImplementation(*this).Upload(&internalPixelData, layer, mipmap, xOffset, yOffset, width, height);
80 void Texture::GenerateMipmaps()
82 return GetImplementation(*this).GenerateMipmaps();
85 uint32_t Texture::GetWidth() const
87 return GetImplementation(*this).GetWidth();
90 uint32_t Texture::GetHeight() const
92 return GetImplementation(*this).GetHeight();
95 Pixel::Format Texture::GetPixelFormat() const
97 return GetImplementation(*this).GetPixelFormat();
100 Texture::Texture(Internal::Texture* pointer)
101 : BaseHandle(pointer)