1 #ifndef DALI_INTERNAL_NEW_TEXTURE_H
2 #define DALI_INTERNAL_NEW_TEXTURE_H
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/common/dali-common.h> // DALI_ASSERT_ALWAYS
23 #include <dali/public-api/common/intrusive-ptr.h> // Dali::IntrusivePtr
24 #include <dali/public-api/object/base-object.h>
25 #include <dali/public-api/images/pixel.h>
26 #include <dali/devel-api/rendering/texture.h> // Dali::Internal::Render::Texture
27 #include <dali/internal/event/common/event-thread-services.h>
39 typedef IntrusivePtr<NewTexture> NewTexturePtr;
41 class NewTexture : public BaseObject
46 * @brief Create a new Texture.
48 * @param[in] type The type of the texture
49 * @param[in] format The format of the pixel data
50 * @param[in] width The width of the texture
51 * @param[in] height The height of the texture
52 * @return A smart-pointer to the newly allocated Texture.
54 static NewTexturePtr New(TextureType::Type type, Pixel::Format format, unsigned int width, unsigned int height);
57 * @brief Get the texture render object
59 * @return the texture render object
61 Render::NewTexture* GetRenderObject() const;
64 * @copydoc Dali::Texture::Upload()
66 void Upload( Vector<unsigned char>& buffer, const TextureUploadParams& params );
69 * @copydoc Dali::Texture::GenerateMipmaps()
71 void GenerateMipmaps();
74 * @copydoc Dali::Texture::GetWidth()
76 unsigned int GetWidth() const;
79 * @copydoc Dali::Texture::GetHeight()
81 unsigned int GetHeight() const;
84 private: // implementation
89 NewTexture(TextureType::Type type, Pixel::Format format, unsigned int width, unsigned int height );
92 * Second stage initialization of the Texture
99 * A reference counted object may only be deleted by calling Unreference()
101 virtual ~NewTexture();
103 private: // unimplemented methods
104 NewTexture( const NewTexture& );
105 NewTexture& operator=( const NewTexture& );
109 Internal::EventThreadServices& mEventThreadServices; ///<Used to send messages to the render thread via update thread
110 Internal::Render::NewTexture* mRenderObject; ///<The Render::Texture associated to this texture
112 Dali::TextureType::Type mType; ///< Texture type (cached)
113 Pixel::Format mFormat; ///< Pixel format
114 unsigned int mWidth; ///< Width of the texture
115 unsigned int mHeight; ///< Height of the texture
118 } // namespace Internal
120 // Helpers for public-api forwarding methods
121 inline Internal::NewTexture& GetImplementation(Dali::Texture& handle)
123 DALI_ASSERT_ALWAYS(handle && "Texture handle is empty");
125 BaseObject& object = handle.GetBaseObject();
127 return static_cast<Internal::NewTexture&>(object);
130 inline const Internal::NewTexture& GetImplementation(const Dali::Texture& handle)
132 DALI_ASSERT_ALWAYS(handle && "Texture handle is empty");
134 const BaseObject& object = handle.GetBaseObject();
136 return static_cast<const Internal::NewTexture&>(object);
141 #endif // DALI_INTERNAL_TEXTURE_H