From: Ferran Sole Date: Thu, 9 Jun 2016 10:25:28 +0000 (+0100) Subject: New Texture API clean-up X-Git-Tag: dali_1.1.38~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F60%2F73760%2F4;p=platform%2Fcore%2Fuifw%2Fdali-core.git New Texture API clean-up - New API to upload data to textures and to set output texture of a framebuffer - Added test cases for Texture and FrameBuffer objects Change-Id: I99aa20da83ab2a6c76655b331d1520cdc90c7916 --- diff --git a/automated-tests/src/dali-devel/CMakeLists.txt b/automated-tests/src/dali-devel/CMakeLists.txt index a0091c8..59fca0d 100644 --- a/automated-tests/src/dali-devel/CMakeLists.txt +++ b/automated-tests/src/dali-devel/CMakeLists.txt @@ -12,9 +12,11 @@ SET(TC_SOURCES 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 diff --git a/automated-tests/src/dali-devel/utc-Dali-Atlas.cpp b/automated-tests/src/dali-devel/utc-Dali-Atlas.cpp index 78e49c2..34d4457 100644 --- a/automated-tests/src/dali-devel/utc-Dali-Atlas.cpp +++ b/automated-tests/src/dali-devel/utc-Dali-Atlas.cpp @@ -146,7 +146,9 @@ int UtcDaliAtlasClear(void) 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; } @@ -182,9 +184,21 @@ int UtcDaliAtlasUpload01P(void) 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; } @@ -219,9 +233,21 @@ int UtcDaliAtlasUpload02P(void) 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; } diff --git a/automated-tests/src/dali-devel/utc-Dali-FrameBuffer.cpp b/automated-tests/src/dali-devel/utc-Dali-FrameBuffer.cpp new file mode 100644 index 0000000..9943923 --- /dev/null +++ b/automated-tests/src/dali-devel/utc-Dali-FrameBuffer.cpp @@ -0,0 +1,275 @@ +/* + * 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 +#include +#include + +using namespace Dali; + +#include + +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; +} + diff --git a/automated-tests/src/dali-devel/utc-Dali-Texture.cpp b/automated-tests/src/dali-devel/utc-Dali-Texture.cpp new file mode 100644 index 0000000..7dcea18 --- /dev/null +++ b/automated-tests/src/dali-devel/utc-Dali-Texture.cpp @@ -0,0 +1,443 @@ +/* + * 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 +#include + +using namespace Dali; + +#include + +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 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 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 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 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 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 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 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 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 data; + data.Resize( width * height * 4 ); + texture.Upload( data, 0u, 0u, 0u, 0u, width, height ); + + Vector 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 data; + data.Resize( width * height * 4 ); + texture.Upload( data, CubeMap::NEGATIVE_X, 0u, 0u, 0u, width, height ); + + Vector 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; +} + diff --git a/automated-tests/src/dali-devel/utc-Dali-TextureSet.cpp b/automated-tests/src/dali-devel/utc-Dali-TextureSet.cpp index 1c7be48..2c5d75d 100644 --- a/automated-tests/src/dali-devel/utc-Dali-TextureSet.cpp +++ b/automated-tests/src/dali-devel/utc-Dali-TextureSet.cpp @@ -22,15 +22,6 @@ using namespace Dali; #include -namespace -{ -void TestConstraintNoBlue( Vector4& current, const PropertyInputContainer& inputs ) -{ - current.b = 0.0f; -} -} - - void texture_set_test_startup(void) { test_return_value = TET_UNDEF; @@ -201,6 +192,96 @@ int UtcDaliTextureSetSetImage02(void) 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( "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( "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; @@ -236,7 +317,7 @@ int UtcDaliTextureSetSetSampler(void) 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); @@ -290,6 +371,35 @@ int UtcDaliTextureSetGetImage(void) 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; diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.h b/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.h index a40d776..f910d51 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.h +++ b/automated-tests/src/dali/dali-test-suite-utils/test-gl-abstraction.h @@ -491,6 +491,9 @@ public: inline void GenerateMipmap(GLenum target) { + std::stringstream out; + out<& buffer, const TextureUploadParams& params ) +void Texture::Upload( Vector& buffer ) { - return GetImplementation(*this).Upload( buffer, params ); + return GetImplementation(*this).Upload( buffer ); } -void Texture::Upload( PixelData pixelData, const TextureUploadParams& params ) +void Texture::Upload( Vector& 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"); diff --git a/dali/devel-api/rendering/texture.h b/dali/devel-api/rendering/texture.h index 8ea159d..876dbce 100644 --- a/dali/devel-api/rendering/texture.h +++ b/dali/devel-api/rendering/texture.h @@ -56,18 +56,6 @@ namespace CubeMap 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 @@ -124,19 +112,35 @@ public: /** * @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& 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& buffer, const TextureUploadParams& params ); + void Upload( Vector& 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 diff --git a/dali/internal/event/rendering/texture-impl.cpp b/dali/internal/event/rendering/texture-impl.cpp index 445a2bc..5d3f4c5 100644 --- a/dali/internal/event/rendering/texture-impl.cpp +++ b/dali/internal/event/rendering/texture-impl.cpp @@ -64,9 +64,44 @@ NewTexture::~NewTexture() } } -void NewTexture::Upload( Vector& buffer, const TextureUploadParams& params ) +bool NewTexture::CheckUploadParametres( const Vector& 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( mWidth/(1< static_cast( mHeight/(1<& 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& buffer ) +{ + UploadParams params = {0u,0u,0u,0u,mWidth,mHeight}; + if( CheckUploadParametres( buffer, params ) ) + { + UploadTextureMessage(mEventThreadServices.GetUpdateManager(), *mRenderObject, buffer, params ); + } } void NewTexture::GenerateMipmaps() diff --git a/dali/internal/event/rendering/texture-impl.h b/dali/internal/event/rendering/texture-impl.h index 76a3301..5e56c53 100644 --- a/dali/internal/event/rendering/texture-impl.h +++ b/dali/internal/event/rendering/texture-impl.h @@ -43,6 +43,19 @@ class NewTexture : public BaseObject 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. * * @param[in] type The type of the texture @@ -63,7 +76,15 @@ public: /** * @copydoc Dali::Texture::Upload() */ - void Upload( Vector& buffer, const TextureUploadParams& params ); + void Upload( Vector& buffer ); + + /** + * @copydoc Dali::Texture::Upload() + */ + void Upload( Vector& buffer, + unsigned int layer, unsigned int mipmap, + unsigned int xOffset, unsigned int yOffset, + unsigned int width, unsigned int height ); /** * @copydoc Dali::Texture::GenerateMipmaps() @@ -106,6 +127,13 @@ private: // unimplemented methods 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& buffer, const UploadParams& parameters) const; + Internal::EventThreadServices& mEventThreadServices; ///GetRenderObject(); + } - SceneGraph::SetTextureMessage( mEventThreadServices, *mSceneObject, index, texture->GetRenderObject() ); - + SceneGraph::SetTextureMessage( mEventThreadServices, *mSceneObject, index, renderTexture ); } Image* TextureSet::GetImage( size_t index ) const diff --git a/dali/internal/render/common/render-manager.cpp b/dali/internal/render/common/render-manager.cpp index d613ad7..d3190bf 100644 --- a/dali/internal/render/common/render-manager.cpp +++ b/dali/internal/render/common/render-manager.cpp @@ -325,7 +325,7 @@ void RenderManager::RemoveTexture( Render::NewTexture* texture ) TextureOwnerContainer& textures = mImpl->textureContainer; - // Find the sampler + // Find the texture for ( TextureOwnerIter iter = textures.Begin(); iter != textures.End(); ++iter ) { if ( *iter == texture ) @@ -337,7 +337,7 @@ void RenderManager::RemoveTexture( Render::NewTexture* texture ) } } -void RenderManager::UploadTexture( Render::NewTexture* texture, Vector& buffer, const TextureUploadParams& params ) +void RenderManager::UploadTexture( Render::NewTexture* texture, Vector& buffer, const NewTexture::UploadParams& params ) { texture->Upload( mImpl->context, buffer, params ); } diff --git a/dali/internal/render/common/render-manager.h b/dali/internal/render/common/render-manager.h index 50b8916..70c8116 100644 --- a/dali/internal/render/common/render-manager.h +++ b/dali/internal/render/common/render-manager.h @@ -25,6 +25,7 @@ #include #include #include +#include namespace Dali { @@ -282,7 +283,7 @@ public: * @param[in] buffer Vector with the data to be uploaded * @param[in] params The parameters for the upload */ - void UploadTexture( Render::NewTexture* texture, Vector& buffer, const TextureUploadParams& params ); + void UploadTexture( Render::NewTexture* texture, Vector& buffer, const NewTexture::UploadParams& params ); /** * Generates mipmaps for a given texture @@ -312,13 +313,6 @@ public: 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 * object, usually an offscreen render task. diff --git a/dali/internal/render/renderers/render-texture.cpp b/dali/internal/render/renderers/render-texture.cpp index fc2234a..1fd3d78 100644 --- a/dali/internal/render/renderers/render-texture.cpp +++ b/dali/internal/render/renderers/render-texture.cpp @@ -574,14 +574,14 @@ void NewTexture::Initialize(Context& context) } } -void NewTexture::Upload( Context& context, Vector& buffer, const Dali::TextureUploadParams& params ) +void NewTexture::Upload( Context& context, Vector& 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<& buffer, const 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 ) @@ -599,17 +599,21 @@ void NewTexture::Upload( Context& context, Vector& buffer, const context.BindCubeMapTexture( mId ); context.PixelStorei( GL_UNPACK_ALIGNMENT, 1 ); - if( params.x0 == 0 && params.y0 == 0 && - params.width == (unsigned int)(mWidth / (1<(mWidth / (1<(mHeight / (1< #include +#include #include #include @@ -135,9 +136,9 @@ public: * 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& buffer, const Dali::TextureUploadParams& params ); + void Upload( Context& context, Vector& buffer, const Internal::NewTexture::UploadParams& params ); /** * Bind the texture to the given texture unit and applies the given sampler @@ -149,6 +150,7 @@ public: /** * Auto generates mipmaps for the texture + * @param[in] context The GL context */ void GenerateMipmaps( Context& context ); @@ -158,21 +160,37 @@ public: */ 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; diff --git a/dali/internal/update/manager/update-manager.cpp b/dali/internal/update/manager/update-manager.cpp index d682022..df573cf 100644 --- a/dali/internal/update/manager/update-manager.cpp +++ b/dali/internal/update/manager/update-manager.cpp @@ -1312,7 +1312,7 @@ void UpdateManager::RemoveTexture( Render::NewTexture* texture) new (slot) DerivedType( &mImpl->renderManager, &RenderManager::RemoveTexture, texture ); } -void UpdateManager::UploadTexture( Render::NewTexture* texture, Vector& buffer, const TextureUploadParams& params ) +void UpdateManager::UploadTexture( Render::NewTexture* texture, Vector& buffer, const NewTexture::UploadParams& params ) { typedef UploadTextureDataMessage< RenderManager > DerivedType; diff --git a/dali/internal/update/manager/update-manager.h b/dali/internal/update/manager/update-manager.h index a0ce591..1c8f2a9 100644 --- a/dali/internal/update/manager/update-manager.h +++ b/dali/internal/update/manager/update-manager.h @@ -37,6 +37,7 @@ #include #include #include +#include namespace Dali { @@ -493,7 +494,7 @@ public: * @param[in] buffer Vector with the data to be uploaded * @param[in] params The parameters for the upload */ - void UploadTexture( Render::NewTexture* texture, Vector& buffer, const TextureUploadParams& params ); + void UploadTexture( Render::NewTexture* texture, Vector& buffer, const NewTexture::UploadParams& params ); /** * Generates mipmaps for a texture owned by the RenderManager @@ -524,13 +525,6 @@ public: */ 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: /** @@ -1236,7 +1230,7 @@ public: /** * Constructor which does a Vector::Swap() */ - UploadTextureDataMessage( T* manager, Render::NewTexture* texture, Dali::Vector& data, const Dali::TextureUploadParams& params ) + UploadTextureDataMessage( T* manager, Render::NewTexture* texture, Dali::Vector& data, const NewTexture::UploadParams& params ) : MessageBase(), mManager( manager ), mRenderTexture( texture ), @@ -1266,10 +1260,10 @@ private: T* mManager; Render::NewTexture* mRenderTexture; Dali::Vector mData; - Dali::TextureUploadParams mParams; + NewTexture::UploadParams mParams; }; -inline void UploadTextureMessage( UpdateManager& manager, Render::NewTexture& texture, Dali::Vector& data, const Dali::TextureUploadParams& params ) +inline void UploadTextureMessage( UpdateManager& manager, Render::NewTexture& texture, Dali::Vector& data, const NewTexture::UploadParams& params ) { typedef UploadTextureDataMessage< UpdateManager > LocalType;