1 #ifndef __DALI_NATIVE_BITMAP_BUFFER_H__
2 #define __DALI_NATIVE_BITMAP_BUFFER_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.
22 #include <dali/public-api/images/native-image-interface.h>
23 #include <dali/public-api/images/pixel.h>
24 #include <dali/integration-api/gl-abstraction.h>
25 #include <dali/integration-api/lockless-buffer.h>
26 #include <dali/public-api/common/dali-vector.h>
29 #include <dali/internal/adaptor/common/adaptor-impl.h>
30 #include <dali/internal/graphics/common/graphics-interface.h>
41 class NativeBitmapBuffer;
42 typedef IntrusivePtr<NativeBitmapBuffer> NativeBitmapBufferPtr;
45 * A Bitmap-based implementation of the NativeImage interface.
47 class NativeBitmapBuffer : public NativeImageInterface
53 * @param adaptor Adaptor used
54 * @param width width of image
55 * @param height height of image
56 * @param pixelFormat pixel format for image
58 NativeBitmapBuffer( Adaptor* adaptor, unsigned int width, unsigned int height, Pixel::Format pixelFormat );
63 virtual ~NativeBitmapBuffer();
66 * Write to buffer. Does not block.
67 * @param[in] src data source
68 * @param[in] size size of data in bytes
69 * @return true if successful, false if currently reading from buffer in render thread
71 void Write( const unsigned char* src, size_t size );
75 * @copydoc Dali::NativeImageInterface::GlExtensionCreate()
77 virtual bool GlExtensionCreate();
80 * @copydoc Dali::NativeImageInterface::GlExtensionDestroy()
82 virtual void GlExtensionDestroy();
85 * @copydoc Dali::NativeImageInterface::TargetTexture()
87 virtual unsigned int TargetTexture();
90 * @copydoc Dali::NativeImageInterface::PrepareTexture()
92 virtual void PrepareTexture();
95 * @copydoc Dali::NativeImageInterface::GetWidth()
97 virtual unsigned int GetWidth() const;
100 * @copydoc Dali::NativeImageInterface::GetHeight()
102 virtual unsigned int GetHeight() const;
105 * @copydoc Dali::NativeImageInterface::RequiresBlending()
107 virtual bool RequiresBlending() const;
110 NativeBitmapBuffer( const NativeBitmapBuffer& ); ///< not defined
111 NativeBitmapBuffer& operator =( const NativeBitmapBuffer& ); ///< not defined
112 NativeBitmapBuffer(); ///< not defined
115 Integration::GlAbstraction* mGlAbstraction; ///< GlAbstraction used
117 Integration::LocklessBuffer* mBuffer; ///< bitmap data double buffered
118 unsigned int mWidth; ///< Image width
119 unsigned int mHeight; ///< Image height
120 Pixel::Format mPixelFormat; ///< Image pixelformat
121 const unsigned char* mLastReadBuffer; ///< last buffer that was read
124 } // namespace Adaptor
126 } // namespace Internal
130 #endif // __DALI_NATIVE_BITMAP_BUFFER_H__