END_TEST;
}
+int UtcDaliFrameBufferNewWithColor01(void)
+{
+ TestApplication application;
+ uint32_t width = 64;
+ uint32_t height = 64;
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height );
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+ // check that texture is not empty handle
+ DALI_TEST_CHECK( frameBuffer.GetColorTexture() );
+ END_TEST;
+}
+
+int UtcDaliFrameBufferNewWithColor02(void)
+{
+ TestApplication application;
+ uint32_t width = 64;
+ uint32_t height = 64;
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::Attachment::COLOR );
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+ // check that texture is not empty handle
+ DALI_TEST_CHECK( frameBuffer.GetColorTexture() );
+ END_TEST;
+}
+
+int UtcDaliFrameBufferNewWithColor03(void)
+{
+ TestApplication application;
+ uint32_t width = 64;
+ uint32_t height = 64;
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::Attachment::COLOR_DEPTH );
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+ // check that texture is not empty handle
+ DALI_TEST_CHECK( frameBuffer.GetColorTexture() );
+ END_TEST;
+}
+
+int UtcDaliFrameBufferNewWithColor04(void)
+{
+ TestApplication application;
+ uint32_t width = 64;
+ uint32_t height = 64;
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::Attachment::COLOR_STENCIL );
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+ // check that texture is not empty handle
+ DALI_TEST_CHECK( frameBuffer.GetColorTexture() );
+ END_TEST;
+}
+
+int UtcDaliFrameBufferNewWithColor05(void)
+{
+ TestApplication application;
+ uint32_t width = 64;
+ uint32_t height = 64;
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::Attachment::COLOR_DEPTH_STENCIL );
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+ // check that texture is not empty handle
+ DALI_TEST_CHECK( frameBuffer.GetColorTexture() );
+ END_TEST;
+}
+
int UtcDaliFrameBufferCopyConstructor(void)
{
TestApplication application;
namespace
{
-const int RenderBufferFormatToFrameBufferAttachments[] = { Dali::FrameBuffer::Attachment::NONE,
- Dali::FrameBuffer::Attachment::DEPTH,
- Dali::FrameBuffer::Attachment::STENCIL,
- Dali::FrameBuffer::Attachment::DEPTH_STENCIL
- };
-
+const Dali::FrameBuffer::Attachment::Mask RenderBufferFormatToFrameBufferAttachments[] =
+ { Dali::FrameBuffer::Attachment::NONE,
+ Dali::FrameBuffer::Attachment::DEPTH,
+ Dali::FrameBuffer::Attachment::STENCIL,
+ Dali::FrameBuffer::Attachment::DEPTH_STENCIL };
} // unnamed namespace
FrameBufferImagePtr FrameBufferImage::New( unsigned int width,
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
namespace Internal
{
-FrameBufferPtr FrameBuffer::New( unsigned int width, unsigned int height, unsigned int attachments )
+FrameBufferPtr FrameBuffer::New( uint32_t width, uint32_t height, Mask attachments )
{
FrameBufferPtr frameBuffer( new FrameBuffer( width, height, attachments ) );
frameBuffer->Initialize();
return mRenderObject;
}
-FrameBuffer::FrameBuffer( unsigned int width, unsigned int height, unsigned int attachments )
+FrameBuffer::FrameBuffer( uint32_t width, uint32_t height, Mask attachments )
: mEventThreadServices( *Stage::GetCurrent() ),
mRenderObject( NULL ),
mColor( NULL ),
AddFrameBuffer( mEventThreadServices.GetUpdateManager(), *mRenderObject );
}
-void FrameBuffer::AttachColorTexture( TexturePtr texture, unsigned int mipmapLevel, unsigned int layer )
+void FrameBuffer::AttachColorTexture( TexturePtr texture, uint32_t mipmapLevel, uint32_t layer )
{
if( ( texture->GetWidth() / ( 1u << mipmapLevel ) == mWidth ) &&
( texture->GetHeight() / ( 1u << mipmapLevel ) == mHeight ) )
#define DALI_INTERNAL_FRAME_BUFFER_H
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
public:
+ using Mask = Dali::FrameBuffer::Attachment::Mask;
+
/**
* @brief Create a new FrameBuffer
*
* @param[in] attachments The attachments comprising the format of the FrameBuffer (bit-mask)
* @return A smart-pointer to the newly allocated Texture.
*/
- static FrameBufferPtr New( unsigned int width, unsigned int height, unsigned int attachments );
+ static FrameBufferPtr New( uint32_t width, uint32_t height, Mask attachments );
/**
* @brief Get the FrameBuffer render object
/**
* @copydoc Dali::FrameBuffer::AttachColorTexture()
*/
- void AttachColorTexture( TexturePtr texture, unsigned int mipmapLevel, unsigned int layer );
+ void AttachColorTexture( TexturePtr texture, uint32_t mipmapLevel, uint32_t layer );
/**
* @copydoc Dali::FrameBuffer::GetColorTexture()
* @param[in] height The height of the FrameBuffer
* @param[in] attachments The attachments comprising the format of the FrameBuffer (bit-mask)
*/
- FrameBuffer( unsigned int width, unsigned int height, unsigned int attachments );
+ FrameBuffer( uint32_t width, uint32_t height, Mask attachments );
/**
* Second stage initialization of the Texture
virtual ~FrameBuffer();
private: // unimplemented methods
- FrameBuffer( const FrameBuffer& );
- FrameBuffer& operator=( const FrameBuffer& );
+
+ FrameBuffer() = delete;
+ FrameBuffer( const FrameBuffer& ) = delete;
+ FrameBuffer& operator=( const FrameBuffer& ) = delete;
private: // data
Internal::Render::FrameBuffer* mRenderObject; ///< The Render::Texture associated to this texture
TexturePtr mColor;
- unsigned int mWidth;
- unsigned int mHeight;
- unsigned int mAttachments; ///< Bit-mask of type FrameBuffer::Attachment::Mask
+ uint32_t mWidth;
+ uint32_t mHeight;
+ Mask mAttachments; ///< Bit-mask of type FrameBuffer::Attachment::Mask
};
namespace Render
{
-FrameBuffer::FrameBuffer( uint32_t width, uint32_t height, uint32_t attachments )
+FrameBuffer::FrameBuffer( uint32_t width, uint32_t height, Mask attachments )
:mId( 0u ),
mDepthBuffer( attachments & Dali::FrameBuffer::Attachment::DEPTH ),
mStencilBuffer( attachments & Dali::FrameBuffer::Attachment::STENCIL ),
{
public:
+ using Mask = Dali::FrameBuffer::Attachment::Mask;
+
/**
* Constructor
* @param[in] width The width of the FrameBuffer
* @param[in] height The height of the FrameBuffer
* @param[in] attachments The attachments comprising the format of the FrameBuffer (bit-mask)
*/
- FrameBuffer( uint32_t width, uint32_t height, uint32_t attachments );
+ FrameBuffer( uint32_t width, uint32_t height, Mask attachments );
/**
* Destructor
#include <dali/public-api/rendering/frame-buffer.h>
// INTERNAL INCLUDES
+#include <dali/integration-api/debug.h> // DALI_LOG_WARNING_NOFN
#include <dali/internal/event/rendering/frame-buffer-impl.h> // Dali::Internal::FrameBuffer
-
+#include <dali/internal/event/rendering/texture-impl.h> // Dali::Internal::Texture
namespace Dali
{
-FrameBuffer FrameBuffer::New( uint32_t width, uint32_t height, uint32_t attachments )
+FrameBuffer FrameBuffer::New( uint32_t width, uint32_t height )
+{
+ return New( width, height, FrameBuffer::Attachment::COLOR );
+}
+
+FrameBuffer FrameBuffer::New( uint32_t width, uint32_t height, Attachment::Mask attachments )
{
Internal::FrameBufferPtr frameBuffer = Internal::FrameBuffer::New( width, height, attachments );
+ if( attachments & FrameBuffer::Attachment::COLOR )
+ {
+ Internal::TexturePtr texture = Internal::Texture::New( Dali::TextureType::TEXTURE_2D, Pixel::RGB888, width, height );
+ frameBuffer->AttachColorTexture( texture, 0u, 0u );
+ }
+ return FrameBuffer( frameBuffer.Get() );
+}
+
+FrameBuffer FrameBuffer::New( uint32_t width, uint32_t height, uint32_t attachments )
+{
+ DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: FrameBuffer::New(uint32_t,uint32_t,uint32_t) is deprecated and will be removed from next release. use New(uint32_t, uint32_t,Attachment::Mask) instead.\n" );
+ // have to static cast, which according to standard since C++11 is undefined behaviour, hence this variant is deprecated
+ Internal::FrameBufferPtr frameBuffer = Internal::FrameBuffer::New( width, height, static_cast<Attachment::Mask>( attachments ) );
return FrameBuffer( frameBuffer.Get() );
}
/**
* @brief The initial attachments to create the FrameBuffer with.
- * @note The color attachment is created on calling AttachColorTexture(). If a color attachment is not required, omit this call.
+ * @note The color attachment can also be created on calling AttachColorTexture().
* @note With "NONE", no attachments are created initially. However color attachments can still be added as described above.
*
* @SINCE_1_1.45
struct Attachment
{
/**
- * @brief Enumeration for the bit-mask value.
+ * @brief Enumeration for the attachments and/or textures to be created by default
* @SINCE_1_1.45
*/
enum Mask
{
- NONE = 0, ///< No attachments are created initially @SINCE_1_1.45
-
- DEPTH = 1 << 0, ///< Depth buffer bit-mask value @SINCE_1_1.45
- STENCIL = 1 << 1, ///< Stencil buffer bit-mask value @SINCE_1_1.45
-
- // Preset bit-mask combinations:
- DEPTH_STENCIL = DEPTH | STENCIL ///< The Framebuffer will be created with depth and stencil buffer @SINCE_1_1.45
+ NONE = 0, ///< No attachments are created initially @SINCE_1_1.45
+ DEPTH = 1 << 0, ///< Depth buffer is created @SINCE_1_1.45
+ STENCIL = 1 << 1, ///< Stencil buffer is created @SINCE_1_1.45
+ DEPTH_STENCIL = DEPTH | STENCIL, ///< Depth and stencil buffer will be created @SINCE_1_1.45
+ COLOR = 1 << 2, ///< Color texture will be created @SINCE_1_3.54
+ COLOR_DEPTH = COLOR | DEPTH, ///< Color texture and depth buffer will be created @SINCE_1_3.54
+ COLOR_STENCIL = COLOR | STENCIL, ///< Color texture and stencil buffer will be created @SINCE_1_3.54
+ COLOR_DEPTH_STENCIL = COLOR_DEPTH | STENCIL ///< Color, depth and stencil buffer will be created @SINCE_1_3.54
};
};
/**
+ * @brief Creates a new FrameBuffer with only COLOR texture attached on it
+ *
+ * @SINCE_1_3.54
+ *
+ * @note Call GetColorTexture() to get the COLOR texture
+ *
+ * @param[in] width The width of the FrameBuffer and the color texture
+ * @param[in] height The height of the FrameBuffer and the color texture
+ * @return A handle to a newly allocated FrameBuffer
+ */
+ static FrameBuffer New( uint32_t width, uint32_t height );
+
+ /**
+ * @brief Creates a new FrameBuffer with the specified attachments
+ *
+ * @SINCE_1_3.54
+ *
+ * @param[in] width The width of the FrameBuffer and the attachments
+ * @param[in] height The height of the FrameBuffer and the attachments
+ * @param[in] attachments Enumeration of the attachments to create
+ * @return A handle to a newly allocated FrameBuffer
+ */
+ static FrameBuffer New( uint32_t width, uint32_t height, Attachment::Mask attachments );
+
+ /**
+ * @DEPRECATED_1_3.54 use New( uint32_t width, uint32_t height ) or New( uint32_t width, uint32_t height, Attachment::Mask attachments ) instead
* @brief Creates a new FrameBuffer object.
*
* @SINCE_1_1.43
+ *
* @param[in] width The width of the FrameBuffer
* @param[in] height The height of the FrameBuffer
* @param[in] attachments The attachments comprising the format of the FrameBuffer (the type is int to allow multiple bitmasks to be ORd)