1 #ifndef __DALI_INTERNAL_COMPRESSED_BITMAP_TEXTURE_H__
2 #define __DALI_INTERNAL_COMPRESSED_BITMAP_TEXTURE_H__
5 * Copyright (c) 2014 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.
26 #include <dali/public-api/images/bitmap-image.h>
27 #include <dali/internal/common/message.h>
28 #include <dali/internal/render/gl-resources/texture.h>
29 #include <dali/internal/render/gl-resources/texture-cache.h>
30 #include <dali/internal/common/bitmap-upload.h>
31 #include <dali/integration-api/bitmap.h>
32 #include <dali/internal/event/images/bitmap-compressed.h>
33 #include <dali/integration-api/debug.h>
41 class CompressedBitmapTexture;
42 typedef IntrusivePtr<CompressedBitmapTexture> CompressedBitmapTexturePointer;
45 * Compressed Texture class.
46 * If you want to load a file to a CompressedBitmapTexture use
47 * TextureManager::GetTexture()
48 * Compressed textures differ from ordinary ones in that their in-memory
49 * representation cannot be inspected at a pixel level by simple pointer
50 * arithmetic and in that they cannot be partially updated.
52 class CompressedBitmapTexture : public Texture
57 * Creates a new texture object from a Bitmap
58 * @param[in] bitmap The Bitmap
59 * @param[in] context The GL context
60 * @param[in] discardPolicy The discard policy
62 CompressedBitmapTexture( Internal::BitmapCompressed* const bitmap, Context& context, ResourcePolicy::Discardable discardPolicy );
67 virtual ~CompressedBitmapTexture();
71 * @copydoc Texture::Init
76 * @copydoc Texture::GetWidth
78 virtual unsigned int GetWidth() const;
81 * @copydoc Texture::GetHeight
83 virtual unsigned int GetHeight() const;
86 * @copydoc Texture::HasAlphaChannel
88 virtual bool HasAlphaChannel() const;
91 * @copydoc Texture::IsFullyOpaque
92 * Always returns false as we can't know what is going on inside the encoded pixel data. ///!Todo: Revise this decision: Paul, didn't you want the opposite assumption?
94 virtual bool IsFullyOpaque() const;
97 * Bitmap has been reloaded - update the texture appropriately.
98 * @param[in] bitmap The new bitmap
100 virtual void Update( Integration::Bitmap* bitmap );
103 * @return Return true if the texture should be updated on GL texture creation.
105 virtual bool UpdateOnCreate();
109 * @copydoc Texture::CreateGlTexture
111 virtual bool CreateGlTexture();
116 * Assigns the bitmap data to an OpenGL texture
117 * Creates a new texture object and copies
118 * the image data held in the pixels parameter
119 * @param[in] generateTexture True if we should generate a GL texture id
120 * @param[in] pixels The pixel data
122 void AssignBitmap( bool generateTexture, const unsigned char* pixels, const size_t bufferSize );
125 Internal::BitmapCompressedPtr mBitmap; ///< The Bitmap the Texture was created from (may be NULL)
126 ResourcePolicy::Discardable mDiscardPolicy;
128 // Changes scope, should be at end of class
129 DALI_LOG_OBJECT_STRING_DECLARATION;
131 } //namespace Internal
134 #endif //__DALI_INTERNAL_COMPRESSED_BITMAP_TEXTURE_H__