1 #ifndef DALI_NATIVE_BITMAP_BUFFER_H
2 #define DALI_NATIVE_BITMAP_BUFFER_H
5 * Copyright (c) 2021 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/integration-api/gl-abstraction.h>
23 #include <dali/integration-api/lockless-buffer.h>
24 #include <dali/public-api/common/dali-vector.h>
25 #include <dali/public-api/images/native-image-interface.h>
26 #include <dali/public-api/images/pixel.h>
29 #include <dali/internal/adaptor/common/adaptor-impl.h>
30 #include <dali/internal/graphics/common/graphics-interface.h>
38 class NativeBitmapBuffer;
39 typedef IntrusivePtr<NativeBitmapBuffer> NativeBitmapBufferPtr;
42 * A Bitmap-based implementation of the NativeImage interface.
44 class NativeBitmapBuffer : public NativeImageInterface
49 * @param adaptor Adaptor used
50 * @param width width of image
51 * @param height height of image
52 * @param pixelFormat pixel format for image
54 NativeBitmapBuffer(Adaptor* adaptor, unsigned int width, unsigned int height, Pixel::Format pixelFormat);
59 virtual ~NativeBitmapBuffer();
62 * Write to buffer. Does not block.
63 * @param[in] src data source
64 * @param[in] size size of data in bytes
65 * @return true if successful, false if currently reading from buffer in render thread
67 void Write(const unsigned char* src, size_t size);
71 * @copydoc Dali::NativeImageInterface::CreateResource()
73 bool CreateResource() override;
76 * @copydoc Dali::NativeImageInterface::DestroyResource()
78 void DestroyResource() override;
81 * @copydoc Dali::NativeImageInterface::TargetTexture()
83 unsigned int TargetTexture() override;
86 * @copydoc Dali::NativeImageInterface::PrepareTexture()
88 void PrepareTexture() override;
91 * @copydoc Dali::NativeImageInterface::GetWidth()
93 unsigned int GetWidth() const override;
96 * @copydoc Dali::NativeImageInterface::GetHeight()
98 unsigned int GetHeight() const override;
101 * @copydoc Dali::NativeImageInterface::RequiresBlending()
103 bool RequiresBlending() const override;
106 * @copydoc Dali::NativeImageInterface::RequiresBlending()
108 int GetTextureTarget() const override;
111 * @copydoc Dali::NativeImageInterface::GetCustomFragmentPrefix()
113 const char* GetCustomFragmentPrefix() const override;
116 * @copydoc Dali::NativeImageInterface::GetCustomSamplerTypename()
118 const char* GetCustomSamplerTypename() const override;
121 * @copydoc Dali::NativeImageInterface::GetNativeImageHandle()
123 Any GetNativeImageHandle() const override;
126 * @copydoc Dali::NativeImageInterface::SourceChanged()
128 bool SourceChanged() const override;
131 NativeBitmapBuffer(const NativeBitmapBuffer&); ///< not defined
132 NativeBitmapBuffer& operator=(const NativeBitmapBuffer&); ///< not defined
133 NativeBitmapBuffer(); ///< not defined
136 Integration::GlAbstraction* mGlAbstraction; ///< GlAbstraction used
138 Integration::LocklessBuffer* mBuffer; ///< bitmap data double buffered
139 unsigned int mWidth; ///< Image width
140 unsigned int mHeight; ///< Image height
141 Pixel::Format mPixelFormat; ///< Image pixelformat
142 const unsigned char* mLastReadBuffer; ///< last buffer that was read
145 } // namespace Adaptor
147 } // namespace Internal
151 #endif // DALI_NATIVE_BITMAP_BUFFER_H