utc-Dali-Context.cpp
utc-Dali-Constrainer.cpp
utc-Dali-DistanceField.cpp
+ utc-Dali-FrameBuffer.cpp
utc-Dali-Geometry.cpp
utc-Dali-Hash.cpp
utc-Dali-HitTestAlgorithm.cpp
+ utc-Dali-Texture.cpp
utc-Dali-TextureSet.cpp
utc-Dali-Mutex.cpp
utc-Dali-PixelData.cpp
application.SendNotification();
callStack.Enable(false);
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", "0, 0, 16, 32") );
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << 0u << ", " << 0u << ", " << 16u <<", "<< 32u;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str() ) );
END_TEST;
}
application.SendNotification();
callStack.Enable(false);
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", "0, 0, 16, 16") );
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", "0, 16, 16, 16") );
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", "2, 32, 6, 8") );
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << 0u << ", " << 0u << ", " << 16u <<", "<< 16u;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str() ) );
+ }
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << 0u << ", " << 16u << ", " << 16u <<", "<< 16u;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str() ) );
+ }
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << 2u << ", " << 32u << ", " << 6u <<", "<< 8u;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str() ) );
+ }
END_TEST;
}
application.SendNotification();
callStack.Enable(false);
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", "0, 0, 16, 16") );
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", "6, 6, 12, 12") );
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", "10, 10, 8, 8") );
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << 0u << ", " << 0u << ", " << 16u <<", "<< 16u;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str() ) );
+ }
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << 6u << ", " << 6u << ", " << 12u <<", "<< 12u;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str() ) );
+ }
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << 10u << ", " << 10u << ", " << 8u <<", "<< 8u;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str() ) );
+ }
END_TEST;
}
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/public-api/dali-core.h>
+#include <dali-test-suite-utils.h>
+#include <dali/devel-api/rendering/frame-buffer.h>
+
+using namespace Dali;
+
+#include <mesh-builder.h>
+
+void framebuffer_set_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void framebuffer_set_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+int UtcDaliFrameBufferNew01(void)
+{
+ TestApplication application;
+
+ unsigned int width(64);
+ unsigned int height(64);
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR );
+
+ DALI_TEST_CHECK( frameBuffer );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliFrameBufferNew02(void)
+{
+ TestApplication application;
+
+ unsigned int width(64);
+ unsigned int height(64);
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR_DEPTH );
+
+ DALI_TEST_CHECK( frameBuffer );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliFrameBufferNew03(void)
+{
+ TestApplication application;
+
+ unsigned int width(64);
+ unsigned int height(64);
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR_STENCIL );
+
+ DALI_TEST_CHECK( frameBuffer );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliFrameBufferNew04(void)
+{
+ TestApplication application;
+
+ unsigned int width(64);
+ unsigned int height(64);
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR_DEPTH_STENCIL );
+
+ DALI_TEST_CHECK( frameBuffer );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+ DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliFrameBufferNew05(void)
+{
+ TestApplication application;
+ FrameBuffer frameBuffer;
+ DALI_TEST_CHECK( !frameBuffer );
+ END_TEST;
+}
+
+int UtcDaliFrameBufferCopyConstructor(void)
+{
+ TestApplication application;
+
+ unsigned int width(64);
+ unsigned int height(64);
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR );
+
+ FrameBuffer frameBufferCopy( frameBuffer );
+
+ DALI_TEST_CHECK( frameBufferCopy );
+
+ END_TEST;
+}
+
+int UtcDaliFrameBufferAssignmentOperator(void)
+{
+ TestApplication application;
+
+ unsigned int width(64);
+ unsigned int height(64);
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR );
+
+ FrameBuffer frameBuffer2;
+ DALI_TEST_CHECK( !frameBuffer2 );
+
+ frameBuffer2 = frameBuffer;
+ DALI_TEST_CHECK( frameBuffer2 );
+
+ END_TEST;
+}
+
+int UtcDaliFrameBufferDownCast01(void)
+{
+ TestApplication application;
+ unsigned int width(64);
+ unsigned int height(64);
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR );
+
+ BaseHandle handle(frameBuffer);
+ FrameBuffer frameBuffer2 = FrameBuffer::DownCast(handle);
+ DALI_TEST_CHECK( frameBuffer2 );
+
+ END_TEST;
+}
+
+int UtcDaliFrameBufferDownCast02(void)
+{
+ TestApplication application;
+
+ Handle handle = Handle::New(); // Create a custom object
+ FrameBuffer frameBuffer = FrameBuffer::DownCast(handle);
+ DALI_TEST_CHECK( !frameBuffer );
+ END_TEST;
+}
+
+int UtcDaliFrameBufferAttachColorTexture01(void)
+{
+ TestApplication application;
+
+ unsigned int width(64);
+ unsigned int height(64);
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR_DEPTH_STENCIL );
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
+ frameBuffer.AttachColorTexture( texture );
+
+ 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);
+
+ END_TEST;
+}
+
+int UtcDaliFrameBufferAttachColorTexture02(void)
+{
+ TestApplication application;
+
+ unsigned int width(64);
+ unsigned int height(64);
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR );
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
+ texture.GenerateMipmaps();
+
+ //Attach mipmap 1
+ frameBuffer.AttachColorTexture( texture, 0u, 1u );
+
+ 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);
+
+ END_TEST;
+}
+
+int UtcDaliFrameBufferAttachColorTexture03(void)
+{
+ TestApplication application;
+
+ unsigned int width(64);
+ unsigned int height(64);
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR );
+ Texture texture = Texture::New( TextureType::TEXTURE_CUBE, Pixel::RGBA8888, width, height );
+ texture.GenerateMipmaps();
+
+ //Attach NEGATIVE_Y face of the cubemap
+ frameBuffer.AttachColorTexture( texture, 0u, CubeMap::NEGATIVE_Y );
+
+ 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);
+
+ END_TEST;
+}
+
+int UtcDaliFrameBufferGetColorTexture01(void)
+{
+ TestApplication application;
+
+ unsigned int width(64);
+ unsigned int height(64);
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR );
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
+ frameBuffer.AttachColorTexture( texture );
+
+ DALI_TEST_EQUALS(frameBuffer.GetColorTexture(), texture, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliFrameBufferGetColorTexture02(void)
+{
+ TestApplication application;
+
+ unsigned int width(64);
+ unsigned int height(64);
+ FrameBuffer frameBuffer = FrameBuffer::New( width, height, FrameBuffer::COLOR );
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
+ frameBuffer.AttachColorTexture( texture, 0u, 1u );
+
+ DALI_TEST_EQUALS(frameBuffer.GetColorTexture(), texture, TEST_LOCATION);
+
+ END_TEST;
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <dali/public-api/dali-core.h>
+#include <dali-test-suite-utils.h>
+
+using namespace Dali;
+
+#include <mesh-builder.h>
+
+void texture_set_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void texture_set_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+int UtcDaliTextureNew01(void)
+{
+ TestApplication application;
+
+ unsigned int width(64);
+ unsigned int height(64);
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
+
+ DALI_TEST_CHECK( texture );
+ END_TEST;
+}
+
+int UtcDaliTextureNew02(void)
+{
+ TestApplication application;
+ Texture texture;
+ DALI_TEST_CHECK( !texture );
+ END_TEST;
+}
+
+int UtcDaliTextureCopyConstructor(void)
+{
+ TestApplication application;
+
+ unsigned int width(64);
+ unsigned int height(64);
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
+
+ Texture textureCopy(texture);
+
+ DALI_TEST_CHECK( textureCopy );
+
+ END_TEST;
+}
+
+int UtcDaliTextureAssignmentOperator(void)
+{
+ TestApplication application;
+ unsigned int width(64);
+ unsigned int height(64);
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
+
+ Texture texture2;
+ DALI_TEST_CHECK( !texture2 );
+
+ texture2 = texture;
+ DALI_TEST_CHECK( texture2 );
+
+ END_TEST;
+}
+
+int UtcDaliTextureDownCast01(void)
+{
+ TestApplication application;
+ unsigned int width(64);
+ unsigned int height(64);
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
+
+ BaseHandle handle(texture);
+ Texture texture2 = Texture::DownCast(handle);
+ DALI_TEST_CHECK( texture2 );
+
+ END_TEST;
+}
+
+int UtcDaliTextureDownCast02(void)
+{
+ TestApplication application;
+
+ Handle handle = Handle::New(); // Create a custom object
+ Texture texture = Texture::DownCast(handle);
+ DALI_TEST_CHECK( !texture );
+ END_TEST;
+}
+
+int UtcDaliTextureUpload01(void)
+{
+ TestApplication application;
+
+ //Create the texture
+ unsigned int width(64);
+ unsigned int height(64);
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
+
+ application.GetGlAbstraction().EnableTextureCallTrace(true);
+
+ application.SendNotification();
+ application.Render();
+
+ TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
+
+ //TexImage2D should be called with a null pointer to reserve storage for the texture in the gpu
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << width <<", "<< height;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexImage2D", out.str().c_str() ) );
+ }
+
+ //Upload data to the texture
+ callStack.Reset();
+ Vector<unsigned char> data;
+ data.Resize( width * height * 4 );
+ texture.Upload( data );
+ application.SendNotification();
+ application.Render();
+
+ //TexImage2D should be called to upload the data
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << width <<", "<< height;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexImage2D", out.str().c_str() ) );
+ }
+
+ //Upload part of the texture
+ callStack.Reset();
+ Vector<unsigned char> subImage;
+ subImage.Resize( width * height * 2 );
+ texture.Upload( subImage, 0u, 0u, width/2, height/2, width/2, height/2 );
+ application.SendNotification();
+ application.Render();
+
+ //TexSubImage2D should be called to upload the data
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << width/2 << ", " << height/2 << ", " << width/2 << ", " << height/2;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str() ) );
+ }
+
+
+ END_TEST;
+}
+
+int UtcDaliTextureUpload02(void)
+{
+ TestApplication application;
+
+ //Create the texture
+ unsigned int width(64);
+ unsigned int height(64);
+ Texture texture = Texture::New( TextureType::TEXTURE_CUBE, Pixel::RGBA8888, width, height );
+
+ application.GetGlAbstraction().EnableTextureCallTrace(true);
+
+ application.SendNotification();
+ application.Render();
+
+ TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
+
+ //TexImage2D should be called six times with a null pointer to reserve storage for the six textures of the cube map
+ for( unsigned int i(0); i<6; ++i )
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_CUBE_MAP_POSITIVE_X + i <<", "<< 0u << ", " << width <<", "<< height;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexImage2D", out.str().c_str() ) );
+ }
+
+ //Upload data to the POSITIVE_X face of the texture
+ {
+ callStack.Reset();
+ Vector<unsigned char> data;
+ data.Resize( width * height * 4 );
+ texture.Upload( data, CubeMap::POSITIVE_X, 0u, 0u, 0u, width, height );
+ application.SendNotification();
+ application.Render();
+
+ //TexImage2D should be called to upload the data to the POSITIVE_X face
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_CUBE_MAP_POSITIVE_X <<", "<< 0u << ", " << width <<", "<< height;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexImage2D", out.str().c_str() ) );
+ }
+ }
+
+ //Upload data to the NEGATIVE_X face of the texture
+ {
+ callStack.Reset();
+ Vector<unsigned char> data;
+ data.Resize( width * height * 4 );
+ texture.Upload( data, CubeMap::NEGATIVE_X, 0u, 0u, 0u, width, height );
+ application.SendNotification();
+ application.Render();
+
+ //TexImage2D should be called to upload the data to the NEGATIVE_X face
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_CUBE_MAP_NEGATIVE_X <<", "<< 0u << ", " << width <<", "<< height;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexImage2D", out.str().c_str() ) );
+ }
+ }
+
+ //Upload data to the POSITIVE_Y face of the texture
+ {
+ callStack.Reset();
+ Vector<unsigned char> data;
+ data.Resize( width * height * 4 );
+ texture.Upload( data, CubeMap::POSITIVE_Y, 0u, 0u, 0u, width, height );
+ application.SendNotification();
+ application.Render();
+
+ //TexImage2D should be called to upload the data to the POSITIVE_Y face
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_CUBE_MAP_POSITIVE_Y <<", "<< 0u << ", " << width <<", "<< height;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexImage2D", out.str().c_str() ) );
+ }
+ }
+
+ //Upload data to the NEGATIVE_Y face of the texture
+ {
+ callStack.Reset();
+ Vector<unsigned char> data;
+ data.Resize( width * height * 4 );
+ texture.Upload( data, CubeMap::NEGATIVE_Y, 0u, 0u, 0u, width, height );
+ application.SendNotification();
+ application.Render();
+
+ //TexImage2D should be called to upload the data to the NEGATIVE_Y face
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_CUBE_MAP_NEGATIVE_Y <<", "<< 0u << ", " << width <<", "<< height;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexImage2D", out.str().c_str() ) );
+ }
+ }
+
+ //Upload data to the POSITIVE_Z face of the texture
+ {
+ callStack.Reset();
+ Vector<unsigned char> data;
+ data.Resize( width * height * 4 );
+ texture.Upload( data, CubeMap::POSITIVE_Z, 0u, 0u, 0u, width, height );
+ application.SendNotification();
+ application.Render();
+
+ //TexImage2D should be called to upload the data to the POSITIVE_Z face
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_CUBE_MAP_POSITIVE_Z <<", "<< 0u << ", " << width <<", "<< height;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexImage2D", out.str().c_str() ) );
+ }
+ }
+
+ //Upload data to the NEGATIVE_Z face of the texture
+ {
+ callStack.Reset();
+ Vector<unsigned char> data;
+ data.Resize( width * height * 4 );
+ texture.Upload( data, CubeMap::NEGATIVE_Z, 0u, 0u, 0u, width, height );
+ application.SendNotification();
+ application.Render();
+
+ //TexImage2D should be called to upload the data to the NEGATIVE_Z face
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_CUBE_MAP_NEGATIVE_Z <<", "<< 0u << ", " << width <<", "<< height;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexImage2D", out.str().c_str() ) );
+ }
+ }
+
+ END_TEST;
+}
+
+int UtcDaliTextureUpload03(void)
+{
+ TestApplication application;
+
+ //Create the texture
+ unsigned int width(64);
+ unsigned int height(64);
+ unsigned int widthMipmap1(32);
+ unsigned int heightMipmap1(32);
+
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
+
+ application.GetGlAbstraction().EnableTextureCallTrace(true);
+
+ application.SendNotification();
+ application.Render();
+
+ TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
+
+ //TexImage2D should be called with a null pointer to reserve storage for the texture in the gpu
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << width <<", "<< height;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexImage2D", out.str().c_str() ) );
+ }
+
+ //Upload data to the texture mipmap 0 and mipmap 1
+ callStack.Reset();
+ Vector<unsigned char> data;
+ data.Resize( width * height * 4 );
+ texture.Upload( data, 0u, 0u, 0u, 0u, width, height );
+
+ Vector<unsigned char> dataMipmap1;
+ dataMipmap1.Resize( widthMipmap1 * heightMipmap1 * 4 );
+ texture.Upload( dataMipmap1, 0u, 1u, 0u, 0u, widthMipmap1, heightMipmap1 );
+ application.SendNotification();
+ application.Render();
+
+ //TexImage2D should be called to upload the data to mipmaps 0 and 1
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << width <<", "<< height;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexImage2D", out.str().c_str() ) );
+ }
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 1u << ", " << widthMipmap1 <<", "<< heightMipmap1;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexImage2D", out.str().c_str() ) );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliTextureUpload04(void)
+{
+ TestApplication application;
+
+ //Create the texture
+ unsigned int width(64);
+ unsigned int height(64);
+ unsigned int widthMipmap1(32);
+ unsigned int heightMipmap1(32);
+
+ Texture texture = Texture::New( TextureType::TEXTURE_CUBE, Pixel::RGBA8888, width, height );
+
+ application.GetGlAbstraction().EnableTextureCallTrace(true);
+ TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
+
+ //Upload data to the NEGATIVE_X face mipmap 0 and mipmap 1
+ Vector<unsigned char> data;
+ data.Resize( width * height * 4 );
+ texture.Upload( data, CubeMap::NEGATIVE_X, 0u, 0u, 0u, width, height );
+
+ Vector<unsigned char> dataMipmap1;
+ dataMipmap1.Resize( widthMipmap1 * widthMipmap1 * 4 );
+ texture.Upload( dataMipmap1, CubeMap::NEGATIVE_X, 1u, 0u, 0u, widthMipmap1, heightMipmap1 );
+ application.SendNotification();
+ application.Render();
+
+ //TexImage2D should be called to upload the data to mipmaps 0 and 1
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_CUBE_MAP_NEGATIVE_X <<", "<< 0u << ", " << width <<", "<< height;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexImage2D", out.str().c_str() ) );
+ }
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_CUBE_MAP_NEGATIVE_X <<", "<< 1u << ", " << widthMipmap1 <<", "<< heightMipmap1;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("TexImage2D", out.str().c_str() ) );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliTextureGenerateMipmaps(void)
+{
+ TestApplication application;
+ unsigned int width(64);
+ unsigned int height(64);
+
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
+ texture.GenerateMipmaps();
+
+ Texture textureCubemap = Texture::New( TextureType::TEXTURE_CUBE, Pixel::RGBA8888, width, height );
+ textureCubemap.GenerateMipmaps();
+
+ application.GetGlAbstraction().EnableTextureCallTrace(true);
+ TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
+ application.SendNotification();
+ application.Render();
+
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("GenerateMipmap", out.str().c_str() ) );
+ }
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_CUBE_MAP;
+ DALI_TEST_CHECK( callStack.FindMethodAndParams("GenerateMipmap", out.str().c_str() ) );
+ }
+
+ END_TEST;
+}
+
+int UtcDaliTextureGetWidth(void)
+{
+ TestApplication application;
+ unsigned int width(64);
+ unsigned int height(64);
+
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
+ DALI_TEST_EQUALS( texture.GetWidth(), width, TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliTextureGetHeight(void)
+{
+ TestApplication application;
+ unsigned int width(64);
+ unsigned int height(64);
+
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
+ DALI_TEST_EQUALS( texture.GetHeight(), height, TEST_LOCATION );
+
+ END_TEST;
+}
+
#include <mesh-builder.h>
-namespace
-{
-void TestConstraintNoBlue( Vector4& current, const PropertyInputContainer& inputs )
-{
- current.b = 0.0f;
-}
-}
-
-
void texture_set_test_startup(void)
{
test_return_value = TET_UNDEF;
END_TEST;
}
+int UtcDaliTextureSetTexture01(void)
+{
+ TestApplication application;
+
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64 );
+
+ Shader shader = CreateShader();
+ TextureSet textureSet = CreateTextureSet();
+ textureSet.SetTexture( 0u, texture );
+
+ Geometry geometry = Geometry::QUAD();
+ Renderer renderer = Renderer::New( geometry, shader );
+ renderer.SetTextures( textureSet );
+
+ Actor actor = Actor::New();
+ actor.AddRenderer(renderer);
+ actor.SetParentOrigin( ParentOrigin::CENTER );
+ actor.SetSize(400, 400);
+
+ Stage::GetCurrent().Add( actor );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
+ texParameterTrace.Reset();
+ texParameterTrace.Enable( true );
+ application.SendNotification();
+ application.Render();
+
+ int textureUnit=-1;
+ DALI_TEST_CHECK( gl.GetUniformValue<int>( "sTexture", textureUnit ) );
+ DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
+
+ texParameterTrace.Enable( false );
+
+ // Verify gl state
+ // There are four calls to TexParameteri when the texture is first created
+ // as the texture is using default sampling parametrers there shouldn't be any more calls to TexParameteri
+ DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 4, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliTextureSetTexture02(void)
+{
+ TestApplication application;
+
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64 );
+
+ Shader shader = CreateShader();
+ TextureSet textureSet = CreateTextureSet();
+
+ Sampler sampler = Sampler::New();
+ sampler.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST );
+ textureSet.SetTexture( 0u, texture );
+ textureSet.SetSampler( 0u, sampler );
+
+ Geometry geometry = Geometry::QUAD();
+ Renderer renderer = Renderer::New( geometry, shader );
+ renderer.SetTextures( textureSet );
+
+ Actor actor = Actor::New();
+ actor.AddRenderer(renderer);
+ actor.SetParentOrigin( ParentOrigin::CENTER );
+ actor.SetSize(400, 400);
+
+ Stage::GetCurrent().Add( actor );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+
+ TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
+ texParameterTrace.Reset();
+ texParameterTrace.Enable( true );
+ application.SendNotification();
+ application.Render();
+
+ int textureUnit=-1;
+ DALI_TEST_CHECK( gl.GetUniformValue<int>( "sTexture", textureUnit ) );
+ DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
+
+ texParameterTrace.Enable( false );
+
+ // Verify gl state
+ // There are four calls to TexParameteri when the texture is first created
+ // Texture minification and magnification filters are now different than default so
+ //there should have been two extra TexParameteri calls to set the new filter mode
+ DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 6, TEST_LOCATION);
+
+ END_TEST;
+}
int UtcDaliTextureSetSetSampler(void)
{
TestApplication application;
texParameterTrace.Enable( false );
// Verify gl state
- // There are three calls to TexParameteri when the texture is first created
+ // There are 4 calls to TexParameteri when the texture is first created
// as the texture is using default sampling parametrers there shouldn't be any more calls to TexParameteri
DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 3, TEST_LOCATION);
END_TEST;
}
+int UtcDaliTextureSetGetTexture(void)
+{
+ TestApplication application;
+
+ TextureSet textureSet = CreateTextureSet();
+ DALI_TEST_EQUALS( textureSet.GetTexture(0), Texture(), TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetTexture(1), Texture(), TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetTexture(2), Texture(), TEST_LOCATION );
+
+ Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, 64, 64 );
+ textureSet.SetTexture( 0u, texture );
+
+ DALI_TEST_EQUALS( textureSet.GetTexture(0), texture, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetTexture(1), Texture(), TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetTexture(2), Texture(), TEST_LOCATION );
+
+ textureSet.SetTexture( 2u, texture );
+ DALI_TEST_EQUALS( textureSet.GetTexture(0), texture, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetTexture(1), Texture(), TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetTexture(2), texture, TEST_LOCATION );
+
+ textureSet.SetTexture( 2u, Texture() );
+ DALI_TEST_EQUALS( textureSet.GetTexture(0), texture, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetTexture(1), Texture(), TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetTexture(2), Texture(), TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliTextureSetGetSampler(void)
{
TestApplication application;
inline void GenerateMipmap(GLenum target)
{
+ std::stringstream out;
+ out<<target;
+ mTextureTrace.PushCall("GenerateMipmap", out.str());
}
inline void GenFramebuffers(GLsizei n, GLuint* framebuffers)
inline void TexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels)
{
std::stringstream out;
- out << width << ", " << height;
+ out << target<<", "<<level<<", "<<width << ", " << height;
mTextureTrace.PushCall("TexImage2D", out.str());
}
inline void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels)
{
std::stringstream out;
- out << xoffset << ", " << yoffset << ", " << width << ", " << height;
+ out << target << ", "<<level <<", " << xoffset << ", " << yoffset << ", " << width << ", " << height;
mTextureTrace.PushCall("TexSubImage2D", out.str());
}
application.SendNotification();
const TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
- DALI_TEST_EQUALS( callStack.TestMethodAndParams(0, "TexSubImage2D", "0, 0, 16, 16"), true, TEST_LOCATION);
+
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << 0u << ", " << 0u << ", " << 16u <<", "<< 16u;
+ DALI_TEST_EQUALS( callStack.TestMethodAndParams(0, "TexSubImage2D", out.str().c_str() ), true, TEST_LOCATION);
DALI_TEST_CHECK( SignalReceived == true );
SignalReceived = false;
application.SendNotification();
const TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
- DALI_TEST_EQUALS( callStack.TestMethodAndParams(0, "TexSubImage2D", "9, 9, 5, 5"), true, TEST_LOCATION);
- DALI_TEST_EQUALS( callStack.TestMethodAndParams(1, "TexSubImage2D", "2, 2, 4, 4"), true, TEST_LOCATION);
- DALI_TEST_EQUALS( callStack.TestMethodAndParams(2, "TexSubImage2D", "3, 3, 1, 6"), true, TEST_LOCATION);
+
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << 9u << ", " << 9u << ", " << 5u <<", "<< 5u;
+ DALI_TEST_EQUALS( callStack.TestMethodAndParams(0, "TexSubImage2D", out.str().c_str()), true, TEST_LOCATION);
+ }
+
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << 2u << ", " << 2u << ", " << 4u <<", "<< 4u;
+ DALI_TEST_EQUALS( callStack.TestMethodAndParams(1, "TexSubImage2D", out.str().c_str()), true, TEST_LOCATION);
+ }
+
+ {
+ std::stringstream out;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << 3u << ", " << 3u << ", " << 1u <<", "<< 6u;
+ DALI_TEST_EQUALS( callStack.TestMethodAndParams(2, "TexSubImage2D", out.str().c_str()), true, TEST_LOCATION);
+ }
DALI_TEST_CHECK( SignalReceived == true );
SignalReceived = false;
{
}
+void FrameBuffer::AttachColorTexture( Texture& texture )
+{
+ AttachColorTexture( texture, 0u, 0u );
+}
+
void FrameBuffer::AttachColorTexture( Texture& texture, unsigned int mipmapLevel, unsigned int layer )
{
if( texture )
FrameBuffer& operator=( const FrameBuffer& handle );
/**
- * @brief Attach a texture for color rendering
+ * @brief Attach the base LOD of a 2D texture to the framebuffer for color rendering
+ * @param[in] texture The texture that will be used as output when rendering
+ * @note The texture has to have the same size than the FrameBuffer
+ * otherwise it won't be attached
+ */
+ void AttachColorTexture( Texture& texture );
+
+ /**
+ * @brief Attach a texture to the framebuffer for color rendering
* @param[in] texture The texture that will be used as output when rendering
* @param[in] mipmapLevel The mipmap of the texture to be attached
* @param[in] layer Indicates which layer of a cube map or array texture to attach. Unused for 2D textures
* @note The specified texture mipmap has to have the same size than the FrameBuffer
* otherwise it won't be attached
*/
- void AttachColorTexture( Texture& texture, unsigned int mipmapLevel = 0u, unsigned int layer = 0u );
+ void AttachColorTexture( Texture& texture, unsigned int mipmapLevel, unsigned int layer );
/**
* @brief Get the color texture used as output in the FrameBuffer
enum ShaderHints
{
HINT_NONE = 0x00, ///< no hints
- HINT_OUTPUT_IS_TRANSPARENT = 0x02, ///< Might generate transparent alpha from opaque inputs
- HINT_MODIFIES_GEOMETRY = 0x08, ///< Might change position of vertices,
+ HINT_OUTPUT_IS_TRANSPARENT = 0x01, ///< Might generate transparent alpha from opaque inputs
+ HINT_MODIFIES_GEOMETRY = 0x02, ///< Might change position of vertices,
///< this option disables any culling optimizations
};
return *this;
}
-void Texture::Upload( Vector<unsigned char>& buffer, const TextureUploadParams& params )
+void Texture::Upload( Vector<unsigned char>& buffer )
{
- return GetImplementation(*this).Upload( buffer, params );
+ return GetImplementation(*this).Upload( buffer );
}
-void Texture::Upload( PixelData pixelData, const TextureUploadParams& params )
+void Texture::Upload( Vector<unsigned char>& buffer,
+ unsigned int layer, unsigned int mipmap,
+ unsigned int xOffset, unsigned int yOffset,
+ unsigned int width, unsigned int height )
+{
+ return GetImplementation(*this).Upload( buffer, layer, mipmap, xOffset, yOffset, width, height );
+}
+
+void Texture::Upload( PixelData pixelData )
{
//TODO: Implement this method once PixelData uses handle/body pattern
DALI_ASSERT_ALWAYS( false && "Not implemented yet");
const unsigned int NEGATIVE_Z = 5u;
}
-/**
- * @brief Structure used to pass parameters to the Upload method
- */
-struct TextureUploadParams
-{
- unsigned int layer; ///< Specifies the layer of a cube map or array texture
- unsigned int mipmap; ///< Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image.
- unsigned int x0; ///< Specifies a texel offset in the x direction within the texture array.
- unsigned int y0; ///< Specifies a texel offset in the y direction within the texture array.
- unsigned int width; ///< Specifies the width of the texture subimage
- unsigned int height; ///< Specifies the height of the texture subimage.
-};
/**
* @brief Texture represents a texture object used as input or output by shaders
/**
* @brief Upload data to the texture
* @param[in] buffer A vector with the data to be uploaded
- * @param[in] params A struct with the parameters for the upload. See TextureUploadParams
* @note buffer data will be moved after this call. If the application needs to keep the data,
- * it will have to pass a copy of the original buffer into this function, otherwise, the data
+ * it will have to pass a copy of the original buffer into this function, otherwise the data
+ * will be lost
+ */
+ void Upload( Vector<unsigned char>& buffer );
+
+ /**
+ * @brief Upload data to the texture
+ * @param[in] buffer A vector with the data to be uploaded
+ * @param[in] layer Specifies the layer of a cube map or array texture. (Unused for 2D textures)
+ * @param[in] mipmap Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image
+ * @param[in] xOffset Specifies a texel offset in the x direction within the texture array
+ * @param[in] yOffset Specifies a texel offset in the y direction within the texture array
+ * @param[in] width Specifies the width of the texture subimage
+ * @param[in] height Specifies the height of the texture subimage
+ * @note buffer data will be moved after this call. If the application needs to keep the data,
+ * it will have to pass a copy of the original buffer into this function, otherwise the data
* will be lost
*/
- void Upload( Vector<unsigned char>& buffer, const TextureUploadParams& params );
+ void Upload( Vector<unsigned char>& buffer,
+ unsigned int layer, unsigned int mipmap,
+ unsigned int xOffset, unsigned int yOffset,
+ unsigned int width, unsigned int height );
/**
* @brief Upload data to the texture from a PixelData object
* @param[in] pixelData The pixelData object
- * @param[in] params A struct with the parameters for the upload. See TextureUploadParams
*/
- void Upload( PixelData pixelData, const TextureUploadParams& params );
+ void Upload( PixelData pixelData );
/**
* @brief Generate mipmaps for the texture
}
}
-void NewTexture::Upload( Vector<unsigned char>& buffer, const TextureUploadParams& params )
+bool NewTexture::CheckUploadParametres( const Vector<unsigned char>& buffer, const UploadParams& parameters ) const
{
- UploadTextureMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject, buffer, params );
+ if( buffer.Size() < GetBytesPerPixel( mFormat ) * parameters.width * parameters.height )
+ {
+ DALI_LOG_ERROR( "Error: Buffer of an incorrect size when trying to update texture");
+ return false;
+ }
+ else if( ( parameters.xOffset + parameters.width > static_cast<unsigned int>( mWidth/(1<<parameters.mipmap ))) ||
+ ( parameters.yOffset + parameters.height > static_cast<unsigned int>( mHeight/(1<<parameters.mipmap ))))
+ {
+ DALI_LOG_ERROR( "Error: Out of bounds texture update");
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+}
+
+void NewTexture::Upload( Vector<unsigned char>& buffer,
+ unsigned int layer, unsigned int mipmap,
+ unsigned int xOffset, unsigned int yOffset,
+ unsigned int width, unsigned int height )
+{
+ UploadParams params = { layer, mipmap, xOffset, yOffset, width, height };
+ if( CheckUploadParametres( buffer, params ) )
+ {
+ UploadTextureMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject, buffer, params );
+ }
+}
+
+void NewTexture::Upload( Vector<unsigned char>& buffer )
+{
+ UploadParams params = {0u,0u,0u,0u,mWidth,mHeight};
+ if( CheckUploadParametres( buffer, params ) )
+ {
+ UploadTextureMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject, buffer, params );
+ }
}
void NewTexture::GenerateMipmaps()
{
public:
+ /**
+ * @brief Structure used to pass parameters to the Upload method
+ */
+ struct UploadParams
+ {
+ unsigned int layer; ///< Specifies the layer of a cube map or array texture
+ unsigned int mipmap; ///< Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image.
+ unsigned int xOffset; ///< Specifies a texel offset in the x direction within the texture array.
+ unsigned int yOffset; ///< Specifies a texel offset in the y direction within the texture array.
+ unsigned int width; ///< Specifies the width of the texture subimage
+ unsigned int height; ///< Specifies the height of the texture subimage.
+ };
+
/**
* @brief Create a new Texture.
*
/**
* @copydoc Dali::Texture::Upload()
*/
- void Upload( Vector<unsigned char>& buffer, const TextureUploadParams& params );
+ void Upload( Vector<unsigned char>& buffer );
+
+ /**
+ * @copydoc Dali::Texture::Upload()
+ */
+ void Upload( Vector<unsigned char>& buffer,
+ unsigned int layer, unsigned int mipmap,
+ unsigned int xOffset, unsigned int yOffset,
+ unsigned int width, unsigned int height );
/**
* @copydoc Dali::Texture::GenerateMipmaps()
private: // data
+ /**
+ * @brief Helper method to check that upload parameters are correct
+ * @param[in] buffer A vector with the data to be uploaded
+ * @param[in] parameters The uploading parameters
+ */
+ bool CheckUploadParametres( const Vector<unsigned char>& buffer, const UploadParams& parameters) const;
+
Internal::EventThreadServices& mEventThreadServices; ///<Used to send messages to the render thread via update thread
Internal::Render::NewTexture* mRenderObject; ///<The Render::Texture associated to this texture
mNewTextures[index]= texture;
+ Render::NewTexture* renderTexture(0);
+ if( texture )
+ {
+ renderTexture = texture->GetRenderObject();
+ }
- SceneGraph::SetTextureMessage( mEventThreadServices, *mSceneObject, index, texture->GetRenderObject() );
-
+ SceneGraph::SetTextureMessage( mEventThreadServices, *mSceneObject, index, renderTexture );
}
Image* TextureSet::GetImage( size_t index ) const
TextureOwnerContainer& textures = mImpl->textureContainer;
- // Find the sampler
+ // Find the texture
for ( TextureOwnerIter iter = textures.Begin(); iter != textures.End(); ++iter )
{
if ( *iter == texture )
}
}
-void RenderManager::UploadTexture( Render::NewTexture* texture, Vector<unsigned char>& buffer, const TextureUploadParams& params )
+void RenderManager::UploadTexture( Render::NewTexture* texture, Vector<unsigned char>& buffer, const NewTexture::UploadParams& params )
{
texture->Upload( mImpl->context, buffer, params );
}
#include <dali/internal/render/common/texture-uploaded-dispatcher.h>
#include <dali/internal/render/gl-resources/gpu-buffer.h>
#include <dali/internal/render/renderers/render-property-buffer.h>
+#include <dali/internal/event/rendering/texture-impl.h>
namespace Dali
{
* @param[in] buffer Vector with the data to be uploaded
* @param[in] params The parameters for the upload
*/
- void UploadTexture( Render::NewTexture* texture, Vector<unsigned char>& buffer, const TextureUploadParams& params );
+ void UploadTexture( Render::NewTexture* texture, Vector<unsigned char>& buffer, const NewTexture::UploadParams& params );
/**
* Generates mipmaps for a given texture
*/
void AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::NewTexture* texture, unsigned int mipmapLevel, unsigned int layer );
- /**
- * Attach a texture as depth-stencil to an existing FrameBuffer
- * @param[in] frameBuffer The FrameBuffer
- * @param[in] texture The texture that will be used as depth-stencil buffer when rendering
- */
- void AttachDepthStencilTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::NewTexture* texture );
-
/**
* Adds a render tracker to the RenderManager. RenderManager takes ownership of the
* tracker. The lifetime of the tracker is related to the lifetime of the tracked
}
}
-void NewTexture::Upload( Context& context, Vector<unsigned char>& buffer, const Dali::TextureUploadParams& params )
+void NewTexture::Upload( Context& context, Vector<unsigned char>& buffer, const Internal::NewTexture::UploadParams& params )
{
if( mType == TextureType::TEXTURE_2D )
{
context.Bind2dTexture( mId );
context.PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
- if( params.x0 == 0 && params.y0 == 0 &&
+ if( params.xOffset == 0 && params.yOffset == 0 &&
params.width == (unsigned int)(mWidth / (1<<params.mipmap)) &&
params.height == (unsigned int)(mHeight / (1<<params.mipmap)) )
{
else
{
//Specifying part of the image for the mipmap
- context.TexSubImage2D( GL_TEXTURE_2D, params.mipmap, params.x0, params.y0, params.width, params.height, mInternalFormat, mPixelDataType, &buffer[0] );
+ context.TexSubImage2D( GL_TEXTURE_2D, params.mipmap, params.xOffset, params.yOffset, params.width, params.height, mInternalFormat, mPixelDataType, &buffer[0] );
}
}
else if( mType == TextureType::TEXTURE_CUBE )
context.BindCubeMapTexture( mId );
context.PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
- if( params.x0 == 0 && params.y0 == 0 &&
- params.width == (unsigned int)(mWidth / (1<<params.mipmap)) &&
- params.height == (unsigned int)(mHeight / (1<<params.mipmap)) )
+ if( params.xOffset == 0 && params.yOffset == 0 &&
+ params.width == static_cast<unsigned int>(mWidth / (1<<params.mipmap)) &&
+ params.height == static_cast<unsigned int>(mHeight / (1<<params.mipmap)) )
{
//Specifying the whole image for the mipmap. We cannot assume that storage for that mipmap has been created so we need to use TexImage2D
- context.TexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + params.layer, params.mipmap, mInternalFormat, params.width, params.height, 0, mInternalFormat, mPixelDataType, &buffer[0] );
+ context.TexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + params.layer, params.mipmap, mInternalFormat,
+ params.width, params.height, 0,
+ mInternalFormat, mPixelDataType, &buffer[0] );
}
else
{
//Specifying part of the image for the mipmap
- context.TexSubImage2D( GL_TEXTURE_CUBE_MAP_POSITIVE_X + params.layer, params.mipmap, params.x0, params.y0, params.width, params.height, mInternalFormat, mPixelDataType, &buffer[0] );
+ context.TexSubImage2D( GL_TEXTURE_CUBE_MAP_POSITIVE_X + params.layer, params.mipmap,
+ params.xOffset, params.yOffset, params.width, params.height,
+ mInternalFormat, mPixelDataType, &buffer[0] );
}
}
}
// INTERNAL INCLUDES
#include <dali/devel-api/rendering/sampler.h>
#include <dali/devel-api/rendering/texture.h>
+#include <dali/internal/event/rendering/texture-impl.h>
#include <dali/integration-api/resource-declarations.h>
#include <dali/internal/render/gl-resources/context.h>
* Uploads data to the texture.
* @param[in] context The GL context
* @param[in] buffer A vector with the data to be uploaded
- * @param[in] params Upload parameters. See TextureUploadParams
+ * @param[in] params Upload parameters. See UploadParams
*/
- void Upload( Context& context, Vector<unsigned char>& buffer, const Dali::TextureUploadParams& params );
+ void Upload( Context& context, Vector<unsigned char>& buffer, const Internal::NewTexture::UploadParams& params );
/**
* Bind the texture to the given texture unit and applies the given sampler
/**
* Auto generates mipmaps for the texture
+ * @param[in] context The GL context
*/
void GenerateMipmaps( Context& context );
*/
bool HasAlphaChannel();
+ /**
+ * Get the id of the texture
+ * @return Id of the texture
+ */
GLuint GetId()
{
return mId;
}
+ /**
+ * Get the width of the texture
+ * @return Width of the texture
+ */
unsigned int GetWidth() const
{
return mWidth;
}
+ /**
+ * Get the height of the texture
+ * @return Height of the texture
+ */
unsigned int GetHeight() const
{
return mHeight;
}
+ /**
+ * Get the type of the texture
+ * @return Type of the texture
+ */
Type GetType() const
{
return mType;
new (slot) DerivedType( &mImpl->renderManager, &RenderManager::RemoveTexture, texture );
}
-void UpdateManager::UploadTexture( Render::NewTexture* texture, Vector<unsigned char>& buffer, const TextureUploadParams& params )
+void UpdateManager::UploadTexture( Render::NewTexture* texture, Vector<unsigned char>& buffer, const NewTexture::UploadParams& params )
{
typedef UploadTextureDataMessage< RenderManager > DerivedType;
#include <dali/internal/update/rendering/scene-graph-renderer.h>
#include <dali/internal/render/shaders/scene-graph-shader.h>
#include <dali/internal/render/renderers/render-property-buffer.h>
+#include <dali/internal/event/rendering/texture-impl.h>
namespace Dali
{
* @param[in] buffer Vector with the data to be uploaded
* @param[in] params The parameters for the upload
*/
- void UploadTexture( Render::NewTexture* texture, Vector<unsigned char>& buffer, const TextureUploadParams& params );
+ void UploadTexture( Render::NewTexture* texture, Vector<unsigned char>& buffer, const NewTexture::UploadParams& params );
/**
* Generates mipmaps for a texture owned by the RenderManager
*/
void AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::NewTexture* texture, unsigned int mipmapLevel, unsigned int face );
- /**
- * Attach a texture as depth-stencil to an existing FrameBuffer
- * @param[in] frameBuffer The FrameBuffer
- * @param[in] texture The texture that will be used as depth-stencil buffer when rendering
- */
- void AttachDepthStencilTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::NewTexture* texture );
-
public:
/**
/**
* Constructor which does a Vector::Swap()
*/
- UploadTextureDataMessage( T* manager, Render::NewTexture* texture, Dali::Vector<unsigned char>& data, const Dali::TextureUploadParams& params )
+ UploadTextureDataMessage( T* manager, Render::NewTexture* texture, Dali::Vector<unsigned char>& data, const NewTexture::UploadParams& params )
: MessageBase(),
mManager( manager ),
mRenderTexture( texture ),
T* mManager;
Render::NewTexture* mRenderTexture;
Dali::Vector<unsigned char> mData;
- Dali::TextureUploadParams mParams;
+ NewTexture::UploadParams mParams;
};
-inline void UploadTextureMessage( UpdateManager& manager, Render::NewTexture& texture, Dali::Vector<unsigned char>& data, const Dali::TextureUploadParams& params )
+inline void UploadTextureMessage( UpdateManager& manager, Render::NewTexture& texture, Dali::Vector<unsigned char>& data, const NewTexture::UploadParams& params )
{
typedef UploadTextureDataMessage< UpdateManager > LocalType;