[dali_2.3.20] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / image-loader / image.cpp
1 /*
2  * Copyright (c) 2020 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 // CLASS HEADER
18 #include "image.h"
19
20 // INTERNAL INCLUDES
21 #include <dali-toolkit/devel-api/image-loader/texture-manager.h>
22
23 // EXTERNAL INCLUDES
24 #include <dali/devel-api/rendering/frame-buffer-devel.h>
25
26 namespace Dali
27 {
28 namespace Toolkit
29 {
30 namespace Image
31 {
32 std::string GenerateUrl(Dali::FrameBuffer frameBuffer, Pixel::Format pixelFormat, uint32_t width, uint32_t height)
33 {
34   Texture texture = Texture::New(Dali::TextureType::TEXTURE_2D, pixelFormat, width, height);
35   frameBuffer.AttachColorTexture(texture, 0u, 0u);
36   return Dali::Toolkit::TextureManager::AddTexture(texture);
37 }
38
39 std::string GenerateUrl(const Dali::FrameBuffer frameBuffer, uint8_t index)
40 {
41   Texture texture = Dali::DevelFrameBuffer::GetColorTexture(frameBuffer, index);
42   return Dali::Toolkit::TextureManager::AddTexture(texture);
43 }
44
45 std::string GenerateUrl(const Dali::PixelData pixelData)
46 {
47   Texture texture = Texture::New(TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), pixelData.GetWidth(), pixelData.GetHeight());
48   texture.Upload(pixelData);
49   return Dali::Toolkit::TextureManager::AddTexture(texture);
50 }
51
52 std::string GenerateUrl(const Dali::NativeImageSourcePtr nativeImageSource)
53 {
54   Texture texture = Dali::Texture::New(*nativeImageSource);
55   return Dali::Toolkit::TextureManager::AddTexture(texture);
56 }
57
58 } // namespace Image
59
60 } // namespace Toolkit
61
62 } // namespace Dali