- FrameBufferImage, NativeImage, EncodedBufferImage and BufferImage use Dali::Texture internally
- Removed Dali::Atlas class as it is not used
Change-Id: Ife1bf687ca314d87cf5974651857dc7242a1ce37
utc-Dali-AngleAxis.cpp
utc-Dali-Animation.cpp
utc-Dali-Any.cpp
- utc-Dali-Atlas.cpp
utc-Dali-BaseHandle.cpp
utc-Dali-BufferImage.cpp
utc-Dali-CameraActor.cpp
inline void SetGlExtensionCreateResult(bool result){ createResult = result;}
inline virtual bool GlExtensionCreate() { ++mExtensionCreateCalls; return createResult;};
inline virtual void GlExtensionDestroy() { ++mExtensionDestroyCalls; };
- inline virtual GLenum TargetTexture() { ++mTargetTextureCalls; return 1;};
+ inline virtual GLenum TargetTexture() { ++mTargetTextureCalls; return 0;};
inline virtual void PrepareTexture() {};
inline virtual unsigned int GetWidth() const {return mWidth;};
inline virtual unsigned int GetHeight() const {return mHeight;};
Integration::BitmapPtr TestPlatformAbstraction::DecodeBuffer( const Integration::ResourceType& resourceType, uint8_t * buffer, size_t size )
{
mTrace.PushCall("DecodeBuffer", "");
- return Integration::BitmapPtr();
+ return mDecodedBitmap;
}
void TestPlatformAbstraction::CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId)
mResourceRequests.Clear();
mIsLoadingResult=false;
mSynchronouslyLoadedResource.Reset();
+ mDecodedBitmap.Reset();
}
bool TestPlatformAbstraction::WasCalled(TestFuncEnum func)
mLoadedResourcesQueue.clear();
mFailedLoadQueue.clear();
mSynchronouslyLoadedResource.Reset();
+ mDecodedBitmap.Reset();
}
void TestPlatformAbstraction::SetResourceLoaded(Integration::ResourceId loadedId,
mSynchronouslyLoadedResource = resource;
}
+void TestPlatformAbstraction::SetDecodedBitmap( Integration::BitmapPtr bitmap )
+{
+ mDecodedBitmap = bitmap;
+}
+
} // namespace Dali
*/
void SetSynchronouslyLoadedResource( Integration::ResourcePointer resource );
+ /**
+ * @brief Sets the bitmap returned by DecodeBuffer()
+ * @param[in] bitmap The decoded bitmap
+ */
+ void SetDecodedBitmap( Integration::BitmapPtr bitmap );
+
private:
struct LoadedResource
bool mSaveFileResult;
Integration::ResourcePointer mSynchronouslyLoadedResource;
+ Integration::BitmapPtr mDecodedBitmap;
};
} // Dali
Actor b = CreateRenderableActor( imageB );
Actor c = CreateRenderableActor( imageC );
+ app.SendNotification();
+ app.Render(1);
+
+ //Textures are bound when first created. Clear bound textures vector
+ app.GetGlAbstraction().ClearBoundTextures();
+
// Render a,b,c as regular non-overlays. so order will be:
// a (8)
// b (9)
+++ /dev/null
-/*
- * Copyright (c) 2016 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 <iostream>
-#include <algorithm>
-#include <stdlib.h>
-#include <dali/public-api/dali-core.h>
-#include <dali/integration-api/bitmap.h>
-#include <dali/devel-api/images/atlas.h>
-#include <dali-test-suite-utils.h>
-#include <test-native-image.h>
-
-using namespace Dali;
-
-namespace
-{
-static const char* gTestImageFilename = "icon_wrt.png";
-
-PixelData CreatePixelData(unsigned int width, unsigned int height, Pixel::Format pixelFormat)
-{
- unsigned int bufferSize = width*height*Pixel::GetBytesPerPixel( pixelFormat );
- unsigned char* buffer = new unsigned char [ bufferSize ];
-
- return PixelData::New( buffer, bufferSize, width, height, pixelFormat, PixelData::DELETE_ARRAY );
-}
-
-}
-
-void utc_dali_atlas_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_dali_atlas_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-int UtcDaliAtlasNew(void)
-{
- TestApplication application;
-
- // invoke default handle constructor
- Atlas atlas;
-
- DALI_TEST_CHECK( !atlas );
-
- // initialise handle
- atlas = Atlas::New( 16, 16 );
-
- DALI_TEST_CHECK( atlas );
- END_TEST;
-}
-
-int UtcDaliAtlasCopyConstructor(void)
-{
- TestApplication application;
-
- Atlas atlas = Atlas::New( 16, 16);
- Atlas atlasCopy(atlas);
-
-
- DALI_TEST_EQUALS( (bool)atlasCopy, true, TEST_LOCATION );
- END_TEST;
-}
-
-int UtcDaliAtlasAssignmentOperator(void)
-{
- TestApplication application;
-
- Atlas atlas = Atlas::New( 16, 16);
-
- Atlas atlas2;
- DALI_TEST_EQUALS( (bool)atlas2, false, TEST_LOCATION );
-
- atlas2 = atlas;
- DALI_TEST_EQUALS( (bool)atlas2, true, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliAtlasDownCast(void)
-{
- TestApplication application;
-
- Atlas atlas = Atlas::New( 16, 16);
-
- BaseHandle handle(atlas);
- Atlas atlasDowncast = Atlas::DownCast(handle);
- DALI_TEST_EQUALS( (bool)atlasDowncast, true, TEST_LOCATION );
-
- Handle handle2 = Handle::New(); // Create a custom object
- Atlas atlas2 = Atlas::DownCast(handle2);
- DALI_TEST_EQUALS( (bool)atlas2, false, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliAtlasClear(void)
-{
- TestApplication application;
-
- Atlas atlas = Atlas::New( 16, 32, Pixel::RGBA8888 );
- DALI_TEST_CHECK( atlas );
-
- atlas.Clear(Color::TRANSPARENT);
-
- TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
- callStack.Reset();
- callStack.Enable(true);
- application.SendNotification();
- application.Render(16);
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- callStack.Enable(false);
-
- std::stringstream out;
- out << GL_TEXTURE_2D <<", "<< 0u << ", " << 0u << ", " << 0u << ", " << 16u <<", "<< 32u;
- DALI_TEST_CHECK( callStack.FindMethodAndParams("TexSubImage2D", out.str().c_str() ) );
-
- END_TEST;
-}
-
-
-// Upload resource image, buffer image & pixel data with same pixel format
-int UtcDaliAtlasUpload01P(void)
-{
- TestApplication application;
-
- Atlas atlas = Atlas::New( 16, 40, Pixel::RGBA8888 );
- DALI_TEST_CHECK( atlas );
-
- // Using same pixel format
- PixelBuffer* buffer = new PixelBuffer[16 * 16 * 4];
- BufferImage image = BufferImage::New( buffer, 16, 16, Pixel::RGBA8888 );
- DALI_TEST_CHECK( atlas.Upload( image, 0, 0 ) );
-
- PrepareResourceImage( application, 16, 16, Pixel::RGBA8888 );
- DALI_TEST_CHECK( atlas.Upload( gTestImageFilename, 0, 16 ) );
-
- PixelData pixelData = CreatePixelData( 6,8,Pixel::RGBA8888 );
- DALI_TEST_CHECK( atlas.Upload( pixelData, 2, 32 ) );
-
- TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
- callStack.Reset();
- callStack.Enable(true);
- application.SendNotification();
- application.Render(16);
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- callStack.Enable(false);
-
- {
- 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;
-}
-
-// Upload resource image, buffer image & pixel data with different pixel format
-int UtcDaliAtlasUpload02P(void)
-{
- TestApplication application;
-
- Atlas atlas = Atlas::New( 20, 20, Pixel::RGBA8888 );
- DALI_TEST_CHECK( atlas );
-
- // Using different pixel format
- PixelBuffer* buffer = new PixelBuffer[16 * 16 * 3];
- BufferImage image = BufferImage::New( buffer, 16, 16, Pixel::RGB888 );
- DALI_TEST_CHECK( atlas.Upload( image, 0, 0 ) );
-
- PrepareResourceImage( application, 12, 12, Pixel::A8 );
- DALI_TEST_CHECK( atlas.Upload( gTestImageFilename, 6, 6 ) );
-
- PixelData pixelData = CreatePixelData( 8,8,Pixel::LA88 );
- DALI_TEST_CHECK( atlas.Upload( pixelData, 10, 10 ) );
-
- TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
- callStack.Reset();
- callStack.Enable(true);
- application.SendNotification();
- application.Render(16);
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- callStack.Enable(false);
-
- {
- 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;
-}
-
-// Upload resource image, buffer image & pixel data which cannot fit into the atlas with given offset
-int UtcDaliAtlasUploadN(void)
-{
- TestApplication application;
-
- Atlas atlas = Atlas::New( 16, 16, Pixel::RGBA8888 );
- DALI_TEST_CHECK( atlas );
-
- // Using image cannot fit into atlas at the given offsets
- PixelBuffer* buffer = new PixelBuffer[24 * 24 * 4];
- BufferImage image = BufferImage::New( buffer, 24, 24, Pixel::RGBA8888 );
- DALI_TEST_CHECK( !atlas.Upload( image, 0, 0 ) );
-
- PrepareResourceImage( application, 16, 16, Pixel::RGBA8888 );
- DALI_TEST_CHECK( !atlas.Upload( gTestImageFilename, 10, 10 ) );
-
- PixelData pixelData = CreatePixelData( 6,6,Pixel::RGBA8888 );
- DALI_TEST_CHECK( !atlas.Upload( pixelData, 11, 11 ) );
-
- TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
- callStack.Reset();
- callStack.Enable(true);
- application.SendNotification();
- application.Render(16);
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- callStack.Enable(false);
-
- // none of these three upload() call sends texture to GPU
- DALI_TEST_CHECK( ! callStack.FindMethodAndParams("TexSubImage2D", "0, 0, 24, 24") );
- DALI_TEST_CHECK( ! callStack.FindMethodAndParams("TexSubImage2D", "10, 10, 16, 16") );
- DALI_TEST_CHECK( ! callStack.FindMethodAndParams("TexSubImage2D", "11, 11, 6, 6") );
-
- END_TEST;
-}
-
-
-
-
TestApplication application;
tet_infoline("Testing Dali::BufferImage::DownCast()");
- BufferImage bitmap = BufferImage::New(1, 1, Dali::Pixel::BGRA8888);
- Actor actor = CreateRenderableActor( bitmap );
- application.SendNotification();
- application.Render(16);
- application.Render(16);
- application.SendNotification();
-
- Image image = GetTexture( actor );
+ Image image = BufferImage::New(1, 1, Dali::Pixel::BGRA8888);
BufferImage bufferImage = BufferImage::DownCast( image );
DALI_TEST_CHECK(bufferImage);
END_TEST;
}
-namespace
-{
-
-static bool SignalReceived;
-static void ImageUploaded(Image image)
-{
- tet_infoline("Received image uploaded signal");
- SignalReceived = true;
-}
-}
-
int UtcDaliBufferImageUpdate01(void)
{
TestApplication application;
Stage::GetCurrent().Add(actor);
actor.SetVisible(true);
- SignalReceived = false;
- image.UploadedSignal().Connect( ImageUploaded );
-
std::vector<GLuint> ids;
ids.push_back(200);
ids.push_back(201);
const TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
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;
+ out << GL_TEXTURE_2D <<", "<< 0u << ", " << 16u <<", "<< 16u;
+ DALI_TEST_EQUALS( callStack.TestMethodAndParams(0, "TexImage2D", out.str().c_str() ), true, TEST_LOCATION);
END_TEST;
}
Stage::GetCurrent().Add(actor);
actor.SetVisible(true);
- SignalReceived = false;
- image.UploadedSignal().Connect( ImageUploaded );
-
application.SendNotification();
application.Render(0);
application.Render(16);
DALI_TEST_EQUALS( callStack.TestMethodAndParams(2, "TexSubImage2D", out.str().c_str()), true, TEST_LOCATION);
}
- DALI_TEST_CHECK( SignalReceived == true );
- SignalReceived = false;
- END_TEST;
-}
-
-int UtcDaliBufferImageUploadedSignal01(void)
-{
- TestApplication application;
-
- tet_infoline("UtcDaliBufferImageUploadedSignal - Test that Uploaded signal is sent when image is staged");
-
- PixelBuffer* buffer = new PixelBuffer[16 * 16];
- BufferImage image = BufferImage::New(buffer, 16, 16, Pixel::A8);
- SignalReceived = false;
- image.UploadedSignal().Connect( ImageUploaded );
-
- application.SendNotification();
- application.Render(16);
- application.Render(16);
- application.SendNotification();
-
- Actor actor = CreateRenderableActor( image );
- Stage::GetCurrent().Add(actor);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
-
- DALI_TEST_CHECK( SignalReceived == true );
END_TEST;
}
-int UtcDaliBufferImageUploadedSignal02(void)
-{
- TestApplication application;
-
- tet_infoline("UtcDaliBufferImageUploadedSignal - Test that Uploaded signal is sent after Update");
-
- PixelBuffer* buffer = new PixelBuffer[16 * 16];
- BufferImage image = BufferImage::New(buffer, 16, 16, Pixel::A8);
- SignalReceived = false;
- //ScopedConnection connection =
- image.UploadedSignal().Connect( ImageUploaded );
-
- application.SendNotification();
- application.Render(16);
- application.Render(16);
- application.SendNotification();
-
- Actor actor = CreateRenderableActor( image );
- Stage::GetCurrent().Add(actor);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- DALI_TEST_CHECK( SignalReceived == true );
- SignalReceived = false;
-
- image.Update(RectArea()); // notify Core that the whole image has been updated
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- application.Render(16);
- application.SendNotification();
- DALI_TEST_CHECK( SignalReceived == true );
- END_TEST;
-}
static const unsigned int sEncodedBufferImageDataPNGLength = sizeof( sEncodedBufferImageDataPNG );
+void PrepareDecodeBuffer( TestApplication& application, unsigned int width, unsigned int height, Pixel::Format pixelFormat )
+{
+ TestPlatformAbstraction& platform = application.GetPlatform();
+ Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_RETAIN );
+ bitmap->GetPackedPixelsProfile()->ReserveBuffer( pixelFormat, width, height, width, height );
+ Integration::BitmapPtr bitmapPtr(bitmap);
+ platform.SetDecodedBitmap( bitmapPtr );
+}
+
} // anonymous namespace
DALI_TEST_CHECK( !image );
// Trigger image decode to initialise the handle
+ PrepareDecodeBuffer( application, 720u, 1280u, Pixel::RGBA8888 );
image = EncodedBufferImage::New( sEncodedBufferImageDataPNG, sEncodedBufferImageDataPNGLength, ImageDimensions(), FittingMode::DEFAULT, SamplingMode::DEFAULT );
DALI_TEST_CHECK( image );
END_TEST;
}
-int UtcDaliNativeImageCreateGlTextureN(void)
-{
- TestApplication application;
- tet_infoline( "Testing Dali::NativeImage::GenerateGlTexture()" );
-
- NativeImage image;
- try
- {
- image.CreateGlTexture();
- tet_printf( "Assertion test failed - no Exception\n" );
- tet_result( TET_FAIL );
- }
- catch( Dali::DaliException& e )
- {
- DALI_TEST_PRINT_ASSERT( e );
- DALI_TEST_ASSERT( e, "image &&", TEST_LOCATION );
- }
- END_TEST;
-}
-
-int UtcDaliNativeImageCreateGlTextureP(void)
-{
- TestApplication application;
- tet_infoline( "Testing Dali::NativeImage::GenerateGlTexture()" );
-
- TestNativeImagePointer imageInterface = TestNativeImage::New( 16, 16 );
- NativeImage image = NativeImage::New( *(imageInterface.Get()) );
- DALI_TEST_CHECK( image );
-
- image.CreateGlTexture();
-
- application.SendNotification();
- application.Render(16);
-
- DALI_TEST_EQUALS( imageInterface->mExtensionCreateCalls, 1, TEST_LOCATION );
- DALI_TEST_EQUALS( imageInterface->mTargetTextureCalls, 1, TEST_LOCATION );
-
- END_TEST;
-}
-
-int UtcDaliNativeImageContextLoss(void)
-{
- TestApplication application;
- tet_infoline( "Testing Dali::NativeImage behaviour through a context lost/regained cycle." );
-
- // Build an image that is expected to have a GL texture created for it and
- // recreated in a GL context recovery:
- TestNativeImagePointer eagerImageInterface = TestNativeImage::New( 16, 16 );
- NativeImage eagerImage = NativeImage::New( *(eagerImageInterface.Get()) );
- DALI_TEST_CHECK( eagerImage );
-
- // Build a regular lazy-allocated image for comparison:
- TestNativeImagePointer lazyImageInterface = TestNativeImage::New( 16, 16 );
- NativeImage lazyImage = NativeImage::New( *(lazyImageInterface.Get()) );
- DALI_TEST_CHECK( lazyImage );
-
- eagerImage.CreateGlTexture();
-
- application.SendNotification();
- application.Render(16);
-
- // Cycle through a context loss and regain, asserting that the texture is
- // not reallocated if it already existed before the cycle and is never allocated
- // throughout the cycle if of the regular lazy kind:
-
- // Call render thread context destroyed / created functions:
- application.ResetContext();
-
- // Call event thread function:
- application.GetCore().RecoverFromContextLoss();
-
- // Run update/render loop
- application.SendNotification();
- application.Render(16);
-
- DALI_TEST_EQUALS( eagerImageInterface->mExtensionCreateCalls, 1, TEST_LOCATION );
- DALI_TEST_EQUALS( eagerImageInterface->mTargetTextureCalls, 1, TEST_LOCATION );
-
- DALI_TEST_EQUALS( lazyImageInterface->mExtensionCreateCalls, 0, TEST_LOCATION );
- DALI_TEST_EQUALS( lazyImageInterface->mTargetTextureCalls, 0, TEST_LOCATION );
-
- END_TEST;
-}
-
int UtcDaliNativeImageExtensionP(void)
{
TestApplication application;
application.Render();
// Test that nothing was rendered
- DALI_TEST_EQUALS( nativeImageInterface->mExtensionCreateCalls, 1, TEST_LOCATION );
+ //GlExtensionCreate() called twice, once at initialization and once when trying to bind the texture
+ DALI_TEST_EQUALS( nativeImageInterface->mExtensionCreateCalls, 2, TEST_LOCATION );
DALI_TEST_EQUALS( nativeImageInterface->mTargetTextureCalls, 0, TEST_LOCATION );
DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), false, TEST_LOCATION );
DALI_TEST_EQUALS( drawTrace.FindMethod("DrawElements") || drawTrace.FindMethod("DrawArrays"), false, TEST_LOCATION );
application.Render();
// This time around, the bind and draw should occur following the call to nativeImage->GlExtensionCreate.
- DALI_TEST_EQUALS( nativeImageInterface->mExtensionCreateCalls, 2, TEST_LOCATION );
+ DALI_TEST_EQUALS( nativeImageInterface->mExtensionCreateCalls, 3, TEST_LOCATION );
DALI_TEST_EQUALS( nativeImageInterface->mTargetTextureCalls, 1, TEST_LOCATION );
DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
DALI_TEST_EQUALS( drawTrace.FindMethod("DrawElements") || drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION );
tet_infoline("Testing RenderTask::SetSourceActor() Positive - check that setting a non-renderable actor stops existing source actor being rendered ");
Stage stage = Stage::GetCurrent();
-
- const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
-
RenderTaskList taskList = stage.GetRenderTaskList();
-
RenderTask task = taskList.GetTask( 0u );
Actor actor = task.GetSourceActor();
DALI_TEST_CHECK( actor );
- std::vector<GLuint> ids;
- ids.push_back( 7 );
- application.GetGlAbstraction().SetNextTextureIds( ids );
-
BufferImage img = BufferImage::New( 1,1 );
Actor newActor = CreateRenderableActor( img );
newActor.SetSize(1,1);
DALI_TEST_CHECK( task.GetSourceActor() != actor );
DALI_TEST_CHECK( task.GetSourceActor() == nonRenderableActor );
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& drawTrace = gl.GetDrawTrace();
+ drawTrace.Enable(true);
+
// Update & Render nothing!
application.GetGlAbstraction().ClearBoundTextures();
application.SendNotification();
application.Render();
// Check that nothing was rendered
- DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION );
END_TEST;
}
Stage stage = Stage::GetCurrent();
- const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
-
RenderTaskList taskList = stage.GetRenderTaskList();
RenderTask task = taskList.GetTask( 0u );
Actor actor = task.GetSourceActor();
DALI_TEST_CHECK( actor );
- std::vector<GLuint> ids;
- ids.push_back( 7 );
- application.GetGlAbstraction().SetNextTextureIds( ids );
BufferImage img = BufferImage::New( 1,1 );
Actor newActor = CreateRenderableActor( img );
Actor nonRenderableActor = Actor::New();
stage.Add( nonRenderableActor );
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& drawTrace = gl.GetDrawTrace();
+ drawTrace.Enable(true);
+
// Stop the newActor from being rendered by changing the source actor
DALI_TEST_CHECK( nonRenderableActor );
task.SetSourceActor( nonRenderableActor );
application.Render();
// Check that nothing was rendered
- DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION );
+ drawTrace.Reset();
// Set newActor as the new source Actor
task.SetSourceActor( newActor );
application.Render();
// Check that the newActor was rendered
- DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
- if ( boundTextures.size() )
- {
- DALI_TEST_EQUALS( boundTextures[0], 7u, TEST_LOCATION );
- }
+ DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
END_TEST;
}
tet_infoline("Testing RenderTask::SetSourceActor (on/off stage testing)");
Stage stage = Stage::GetCurrent();
-
- const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
-
RenderTaskList taskList = stage.GetRenderTaskList();
-
RenderTask task = taskList.GetTask( 0u );
Actor actor = task.GetSourceActor();
DALI_TEST_CHECK( actor );
- std::vector<GLuint> ids;
- GLuint expectedTextureId( 3 );
- ids.push_back( expectedTextureId );
- application.GetGlAbstraction().SetNextTextureIds( ids );
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& drawTrace = gl.GetDrawTrace();
+ drawTrace.Enable(true);
BufferImage img = BufferImage::New( 1,1 );
Actor newActor = CreateRenderableActor( img );
// Don't add newActor to stage yet //'
// Update & Render with the actor initially off-stage
- application.GetGlAbstraction().ClearBoundTextures();
application.SendNotification();
application.Render();
// Check that nothing was rendered
- DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION );
// Now add to stage
stage.Add( newActor );
application.Render();
// Check that the newActor was rendered
- DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
- if ( boundTextures.size() )
- {
- DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION );
- }
+ DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
+ drawTrace.Reset();
// Now remove from stage
stage.Remove( newActor );
// Update & Render with the actor off-stage
- application.GetGlAbstraction().ClearBoundTextures();
application.SendNotification();
application.Render();
+ DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION );
+
END_TEST;
}
tet_infoline("Testing RenderTask::SetSourceActor (empty handle case)");
Stage stage = Stage::GetCurrent();
-
- const std::vector<GLuint>& boundTextures = application.GetGlAbstraction().GetBoundTextures( GL_TEXTURE0 );
-
RenderTaskList taskList = stage.GetRenderTaskList();
-
RenderTask task = taskList.GetTask( 0u );
Actor actor = task.GetSourceActor();
DALI_TEST_CHECK( actor );
- std::vector<GLuint> ids;
- GLuint expectedTextureId( 5 );
- ids.push_back( expectedTextureId );
- application.GetGlAbstraction().SetNextTextureIds( ids );
-
BufferImage img = BufferImage::New( 1,1 );
Actor newActor = CreateRenderableActor( img );
newActor.SetSize(1,1);
task.SetSourceActor( Actor() );
DALI_TEST_CHECK( ! task.GetSourceActor() );
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& drawTrace = gl.GetDrawTrace();
+ drawTrace.Enable(true);
+
// Update & Render nothing!
- application.GetGlAbstraction().ClearBoundTextures();
application.SendNotification();
application.Render();
// Check that nothing was rendered
- DALI_TEST_EQUALS( boundTextures.size(), 0u, TEST_LOCATION );
+ DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 0, TEST_LOCATION );
// Set with non-empty handle
task.SetSourceActor( newActor );
application.Render();
// Check that the newActor was rendered
- DALI_TEST_EQUALS( boundTextures.size(), 1u, TEST_LOCATION );
- if ( boundTextures.size() )
- {
- DALI_TEST_EQUALS( boundTextures[0], expectedTextureId, TEST_LOCATION );
- }
+ DALI_TEST_EQUALS( drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION );
END_TEST;
}
application.SendNotification();
+ //Both render tasks are executed.
DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, false, true, __LINE__ ) );
DALI_TEST_CHECK( firstFinished == false );
DALI_TEST_CHECK( secondFinished == false );
- DALI_TEST_CHECK( UpdateRender(application, drawTrace, true, firstFinished, true, true, __LINE__ ) );
+ //Nothing else to render and both render task should have finished now
+ DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, firstFinished, true, false, __LINE__ ) );
DALI_TEST_CHECK( firstFinished == true );
- DALI_TEST_CHECK( secondFinished == false );
-
- DALI_TEST_CHECK( UpdateRender(application, drawTrace, false, secondFinished, true, false, __LINE__ ) );
DALI_TEST_CHECK( secondFinished == true );
END_TEST;
// Verify gl state
- // There are three calls to TexParameteri when the texture is first created
- // Texture mag filter is not called as the first time set it uses the system default
- DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 3, TEST_LOCATION);
+ // There are 4 calls to TexParameteri when the texture is first created
+ DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 4, TEST_LOCATION);
std::stringstream out;
out << GL_TEXTURE_2D << ", " << GL_TEXTURE_MIN_FILTER << ", " << GL_LINEAR;
- DALI_TEST_EQUALS( texParameterTrace.TestMethodAndParams(2, "TexParameteri", out.str()), true, TEST_LOCATION);
+ DALI_TEST_EQUALS( texParameterTrace.TestMethodAndParams(0, "TexParameteri", out.str()), true, TEST_LOCATION);
/**************************************************************/
- // Default/Default
+ // Linear/Linear
texParameterTrace.Reset();
texParameterTrace.Enable( true );
- sampler.SetFilterMode( FilterMode::DEFAULT, FilterMode::DEFAULT );
+ sampler.SetFilterMode( FilterMode::LINEAR, FilterMode::LINEAR );
// Flush the queue and render once
application.SendNotification();
// Verify gl state
- // Should not make any calls when settings are the same
+ // Should not make any calls when settings are the same (DEFAULT = LINEAR )
DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 0, TEST_LOCATION);
/**************************************************************/
// Verify gl state
- // There are three calls to TexParameteri when the texture is first created
- // Texture mag filter is not called as the first time set it uses the system default
- DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 3, TEST_LOCATION);
+ // There are 4 calls to TexParameteri when the texture is first created
+ DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 4, TEST_LOCATION);
std::stringstream out;
out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_CLAMP_TO_EDGE;
- DALI_TEST_EQUALS( texParameterTrace.TestMethodAndParams(0, "TexParameteri", out.str()), true, TEST_LOCATION);
+ DALI_TEST_EQUALS( texParameterTrace.TestMethodAndParams(2, "TexParameteri", out.str()), true, TEST_LOCATION);
out.str("");
out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_CLAMP_TO_EDGE;
- DALI_TEST_EQUALS( texParameterTrace.TestMethodAndParams(1, "TexParameteri", out.str()), true, TEST_LOCATION);
+ DALI_TEST_EQUALS( texParameterTrace.TestMethodAndParams(3, "TexParameteri", out.str()), true, TEST_LOCATION);
texParameterTrace.Reset();
texParameterTrace.Enable( true );
- sampler.SetWrapMode( WrapMode::CLAMP_TO_EDGE, WrapMode::CLAMP_TO_EDGE );
+ sampler.SetWrapMode( WrapMode::DEFAULT, WrapMode::DEFAULT );
// Flush the queue and render once
application.SendNotification();
application.SendNotification();
application.Render();
+ // Verify that no TexParameteri calls occurred since wrap mode hasn't changed.
+ DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 0u, TEST_LOCATION );
+
+
+ sampler.SetWrapMode( WrapMode::REPEAT, WrapMode::REPEAT, WrapMode::REPEAT );
+ texParameterTrace.Reset();
+ application.SendNotification();
+ application.Render();
+
texParameterTrace.Enable( false );
// Verify that 3 TexParameteri calls occurred.
DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 3u, TEST_LOCATION );
-
END_TEST;
}
// Verify gl state
// 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);
+ DALI_TEST_EQUALS( texParameterTrace.CountMethod( "TexParameteri" ), 4, TEST_LOCATION);
texParameterTrace.Reset();
texParameterTrace.Enable( true );
$(devel_api_src_dir)/animation/path-constrainer.cpp \
$(devel_api_src_dir)/common/hash.cpp \
$(devel_api_src_dir)/events/hit-test-algorithm.cpp \
- $(devel_api_src_dir)/images/atlas.cpp \
$(devel_api_src_dir)/images/distance-field.cpp \
$(devel_api_src_dir)/images/texture-set-image.cpp \
$(devel_api_src_dir)/images/nine-patch-image.cpp \
$(devel_api_src_dir)/events/hit-test-algorithm.h
devel_api_core_images_header_files = \
- $(devel_api_src_dir)/images/atlas.h \
$(devel_api_src_dir)/images/distance-field.h \
$(devel_api_src_dir)/images/native-image-interface-extension.h \
$(devel_api_src_dir)/images/texture-set-image.h \
+++ /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.
- *
- */
-
-// CLASS HEADER
-#include <dali/devel-api/images/atlas.h>
-
-// INTERNAL INCLUDES
-#include <dali/internal/event/images/atlas-impl.h>
-#include <dali/internal/event/images/buffer-image-impl.h>
-#include <dali/internal/event/images/pixel-data-impl.h>
-
-namespace Dali
-{
-
-Atlas Atlas::New( SizeType width,
- SizeType height,
- Pixel::Format pixelFormat,
- bool recoverContext )
-{
- DALI_ASSERT_ALWAYS( 0u != width && "Invalid Atlas width requested" );
- DALI_ASSERT_ALWAYS( 0u != height && "Invalid Atlas height requested" );
-
- return Atlas( Internal::Atlas::New( width, height, pixelFormat, recoverContext ) );
-}
-
-Atlas::Atlas()
-{
-}
-
-void Atlas::Clear( const Vector4& color )
-{
- GetImplementation( *this ).Clear( color );
-}
-
-bool Atlas::Upload( BufferImage bufferImage,
- SizeType xOffset,
- SizeType yOffset )
-{
- return GetImplementation(*this).Upload( GetImplementation(bufferImage), xOffset, yOffset );
-}
-
-bool Atlas::Upload( const std::string& url,
- SizeType xOffset,
- SizeType yOffset )
-{
- return GetImplementation(*this).Upload( url, xOffset, yOffset );
-}
-
-bool Atlas::Upload( PixelData pixelData,
- SizeType xOffset,
- SizeType yOffset )
-{
- Internal::PixelData& internalPixelData = GetImplementation( pixelData );
- return GetImplementation(*this).Upload( &internalPixelData, xOffset, yOffset );
-}
-
-Atlas Atlas::DownCast( BaseHandle handle )
-{
- return Atlas( dynamic_cast<Dali::Internal::Atlas*>(handle.GetObjectPtr()) );
-}
-
-Atlas::~Atlas()
-{
-}
-
-Atlas::Atlas( const Atlas& handle )
-: Image( handle )
-{
-}
-
-Atlas& Atlas::operator=( const Atlas& rhs )
-{
- BaseHandle::operator=(rhs);
- return *this;
-}
-
-Atlas::Atlas( Internal::Atlas* internal )
-: Image( internal )
-{
-}
-
-} // namespace Dali
+++ /dev/null
-#ifndef DALI_ATLAS_H
-#define DALI_ATLAS_H
-
-/*
- * Copyright (c) 2016 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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <stdint.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/images/buffer-image.h>
-#include <dali/public-api/images/image.h>
-#include <dali/public-api/images/pixel-data.h>
-
-namespace Dali
-{
-
-namespace Internal DALI_INTERNAL
-{
-class Atlas;
-}
-
-/**
- * @brief An Atlas is a large image containing multiple smaller images.
- *
- * Buffer image and resource image( by providing the url ) are supported for uploading.
- * Images must be uploaded at a specified position, to populate the Atlas.
- * The client is responsible for generating the appropriate geometry (UV coordinates) needed to draw images within the Atlas.
- *
- * @note For gles 2.0, matched pixel format is demanded to ensure the correct atlasing.
- * The only exception supported is uploading image of RGB888 to atlas of RGBA8888 format which is converted manually before pushing to GPU.
- *
- * For context recovery after loss:
- * By default, the atlas will re-upload the resource images automatically,
- * while the buffer images are left to the client to upload again by connecting to the Stage::ContextRegainedSignal().
- * If resource and buffer images are mixed and they overlap inside the atlas, the recovered contents may be incorrect.
- * In these case, switch off the context recovery by calling SetContextRecovery( false ),
- * and upload both buffer images and resource image to the atlas in order to restore the atlas.
- */
-class DALI_IMPORT_API Atlas : public Image
-{
-public:
-
- typedef uint32_t SizeType;
-
-public:
-
- /**
- * @brief Create a new Atlas.
- *
- * @pre width & height are greater than zero.
- * The maximum size of the atlas is limited by GL_MAX_TEXTURE_SIZE.
- * @param [in] width The atlas width in pixels.
- * @param [in] height The atlas height in pixels.
- * @param [in] pixelFormat The pixel format (rgba 32 bit by default).
- * @param [in] recoverContext Whether re-uploading the resource images automatically when regaining the context( true by default )
- * @return A handle to a new Atlas.
- */
- static Atlas New( SizeType width,
- SizeType height,
- Pixel::Format pixelFormat = Pixel::RGBA8888,
- bool recoverContext = true );
-
- /**
- * @brief Create an empty handle.
- *
- * Calling member functions of an empty handle is not allowed.
- */
- Atlas();
-
- /**
- * @brief Clear the Atlas with the given color
- *
- * @note The Atlas does not clear itself automatically during construction.
- * Application should call this clear function to avoid getting garbage pixels in the atlas.
- * By calling Clear, all the current uploaded image information will be lost.
- * @param [in] color The color used to clear the Atlas.
- */
- void Clear( const Vector4& color );
-
- /**
- * @brief Upload a buffer image to the atlas.
- *
- * @pre The pixel format of this buffer image must match the Atlas format.
- * @param [in] bufferImage The buffer image to upload.
- * @param [in] xOffset Specifies an offset in the x direction within the atlas.
- * @param [in] yOffset Specifies an offset in the y direction within the atlas.
- * @return True if the image has compatible pixel format and fits within the atlas at the specified offset.
- */
- bool Upload( BufferImage bufferImage,
- SizeType xOffset,
- SizeType yOffset );
-
- /**
- * @brief Upload a resource image to atlas
- *
- * @param [in] url The URL of the resource image file to use
- * @param [in] xOffset Specifies an offset in the x direction within the atlas.
- * @param [in] yOffset Specifies an offset in the y direction within the atlas.
- * @return True if the image has compatible pixel format and fits within the atlas at the specified offset.
- */
- bool Upload( const std::string& url,
- SizeType xOffset,
- SizeType yOffset );
-
- /**
- * @brief Upload a pixel buffer to atlas
- *
- * @param [in] pixelData The pixel data.
- * @param [in] xOffset Specifies an offset in the x direction within the atlas.
- * @param [in] yOffset Specifies an offset in the y direction within the atlas.
- */
- bool Upload( PixelData pixelData,
- SizeType xOffset,
- SizeType yOffset );
- /**
- * @brief Downcast an Object handle to Atlas.
- *
- * If handle points to a Atlas the downcast produces valid
- * handle. If not the returned handle is left uninitialized.
- *
- * @param[in] handle to An object
- * @return handle to a Atlas or an empty handle
- */
- static Atlas DownCast( BaseHandle handle );
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~Atlas();
-
- /**
- * @brief This copy constructor is required for (smart) pointer semantics.
- *
- * @param [in] handle A reference to the copied handle
- */
- Atlas( const Atlas& handle );
-
- /**
- * @brief This assignment operator is required for (smart) pointer semantics.
- *
- * @param [in] rhs A reference to the copied handle
- * @return A reference to this
- */
- Atlas& operator=( const Atlas& rhs);
-
-public: // Not intended for application developers
-
- explicit DALI_INTERNAL Atlas( Internal::Atlas* );
-};
-
-} // namespace Dali
-
-#endif // DALI_ATLAS_H
for( RenderTaskList::RenderTaskContainer::reverse_iterator iter = tasks.rbegin(); endIter != iter; ++iter )
{
RenderTask& renderTask = GetImplementation( *iter );
- Dali::FrameBufferImage frameBufferImage = renderTask.GetTargetFrameBuffer();
-
- // Note that if frameBufferImage is NULL we are using the default (on screen) render target
- if( frameBufferImage )
+ bool isOffscreenRenderTask = ( iter->GetTargetFrameBuffer() || iter->GetFrameBuffer() );
+ if( (onScreen && isOffscreenRenderTask) || (!onScreen && !isOffscreenRenderTask) )
{
- ResourceId id = GetImplementation( frameBufferImage ).GetResourceId();
-
- // Change comparison depending on if on-screen or off-screen.
- if( onScreen ? ( 0 != id ) : ( 0 == id ) )
- {
- // Skip to next task
- continue;
- }
+ // Skip to next task
+ continue;
}
if( HitTestRenderTask( exclusives, stage, layers, renderTask, screenCoordinates, results, hitCheck ) )
+++ /dev/null
-/*
- * Copyright (c) 2016 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.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/event/images/atlas-impl.h>
-
-// EXTERNAL INCLUDES
-#include <cstring> // for memset()
-
-// INTERNAL INCLUDES
-#include <dali/public-api/object/type-registry.h>
-#include <dali/internal/event/common/thread-local-storage.h>
-#include <dali/internal/event/images/bitmap-packed-pixel.h>
-#include <dali/internal/event/resources/resource-client.h>
-#include <dali/integration-api/bitmap.h>
-#include <dali/integration-api/platform-abstraction.h>
-
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace
-{
-TypeRegistration mType( typeid( Dali::Atlas ), typeid( Dali::Image ), NULL );
-}
-
-Atlas* Atlas::New( SizeType width,
- SizeType height,
- Pixel::Format pixelFormat,
- bool recoverContext)
-{
- return new Atlas( width, height, pixelFormat, recoverContext );
-}
-
-void Atlas::Clear(const Vector4& color)
-{
- ClearCache();
- ClearBackground( color );
-}
-
-bool Atlas::Upload( BufferImage& bufferImage,
- SizeType xOffset,
- SizeType yOffset )
-{
- bool uploadSuccess( false );
-
- if( IsInside( xOffset + bufferImage.GetWidth(), yOffset + bufferImage.GetHeight() ) )
- {
- AllocateAtlas();
- ResourceId destId = GetResourceId();
-
- if( destId )
- {
- bufferImage.UploadBitmap( destId, xOffset, yOffset );
- uploadSuccess = true;
- }
- }
-
- return uploadSuccess;
-}
-
-bool Atlas::Upload( const std::string& url,
- SizeType xOffset,
- SizeType yOffset)
-{
- bool uploadSuccess( false );
-
- Integration::BitmapPtr bitmap = LoadBitmap( url );
-
- if( bitmap && IsInside( xOffset + bitmap->GetImageWidth(), yOffset + bitmap->GetImageHeight()) )
- {
- AllocateAtlas();
- ResourceId destId = GetResourceId();
- if( destId )
- {
- mResourceClient.UploadBitmap( destId, bitmap, xOffset, yOffset );
- uploadSuccess = true;
-
- if( mRecoverContext )
- {
- mTiles.PushBack( new Tile(xOffset, yOffset, url) );
- }
- }
- }
- return uploadSuccess;
-}
-
-bool Atlas::Upload( PixelDataPtr pixelData,
- SizeType xOffset,
- SizeType yOffset )
-{
- bool uploadSuccess( false );
- if( IsInside( xOffset + pixelData->GetWidth(), yOffset + pixelData->GetHeight() ) )
- {
- AllocateAtlas();
- ResourceId destId = GetResourceId();
-
- if( destId )
- {
- mResourceClient.UploadBitmap( destId, pixelData, xOffset, yOffset );
- uploadSuccess = true;
- }
- }
-
- return uploadSuccess;
-}
-
-void Atlas::RecoverFromContextLoss()
-{
- ResourceId destId = GetResourceId();
- if( destId )
- {
- if( mClear )
- {
- ClearBackground( mClearColor );
- }
-
- if( mRecoverContext )
- {
- // Restore the atlas by re-uploading the url resources
- Vector< Tile* >::ConstIterator end = mTiles.End();
- for( Vector<Tile*>::Iterator iter = mTiles.Begin(); iter != end; iter++ )
- {
- Integration::BitmapPtr bitmap = LoadBitmap( (*iter)->url );
- mResourceClient.UploadBitmap( destId, bitmap, (*iter)->xOffset, (*iter)->yOffset );
- }
- }
- }
-}
-
-Atlas::~Atlas()
-{
- ReleaseAtlas();
-}
-
-Atlas::Atlas( SizeType width,
- SizeType height,
- Pixel::Format pixelFormat,
- bool recoverContext )
-: mResourceClient( ThreadLocalStorage::Get().GetResourceClient() ),
- mClearColor( Vector4::ZERO ),
- mPixelFormat( pixelFormat ),
- mClear( false ),
- mRecoverContext( recoverContext )
-{
- mWidth = width;
- mHeight = height;
-}
-
-void Atlas::Connect()
-{
- ++mConnectionCount;
-
- if( mConnectionCount == 1 )
- {
- AllocateAtlas();
- }
-}
-
-void Atlas::Disconnect()
-{
- if( mConnectionCount )
- {
- --mConnectionCount;
-
- // Only release the atlas upon destruction
- }
-}
-
-bool Atlas::IsInside( SizeType x, SizeType y )
-{
- bool fit(false);
-
- if( x <= mWidth && y <= mHeight )
- {
- fit = true;
- }
- else
- {
- DALI_LOG_ERROR( "image does not fit within the atlas \n" );
- }
-
- return fit;
-}
-
-void Atlas::AllocateAtlas()
-{
- if( !mTicket )
- {
- mTicket = mResourceClient.AllocateTexture( mWidth, mHeight, mPixelFormat );
- mTicket->AddObserver( *this );
- }
-}
-
-void Atlas::ReleaseAtlas()
-{
- mTicket.Reset();
- ClearCache();
-}
-
-void Atlas::ClearBackground(const Vector4& color )
-{
- AllocateAtlas();
- ResourceId destId = GetResourceId();
- if( destId )
- {
- const unsigned int numPixels = mWidth * mHeight;
- unsigned int bytesPerPixel = Pixel::GetBytesPerPixel(mPixelFormat);
- BufferImagePtr imageData = BufferImage::New( mWidth, mHeight, mPixelFormat );
- PixelBuffer* pixbuf = imageData->GetBuffer();
-
- if( pixbuf )
- {
- // converting color value from float 0.f~1.f to byte 0~255
- unsigned char r = static_cast<unsigned char>( 255.f * Clamp( color.r, 0.f, 1.f ) );
- unsigned char g = static_cast<unsigned char>( 255.f * Clamp( color.g, 0.f, 1.f ) );
- unsigned char b = static_cast<unsigned char>( 255.f * Clamp( color.b, 0.f, 1.f ) );
- unsigned char a = static_cast<unsigned char>( 255.f * Clamp( color.a, 0.f, 1.f ) );
- if( mPixelFormat == Pixel::RGBA8888 )
- {
- // For little-endian byte order, the RGBA channels needs to be reversed for bit shifting.
- uint32_t clearColor = ( (uint32_t) a<<24 | (uint32_t)b << 16 | (uint32_t)g << 8 | (uint32_t)r );
- uint32_t* buf = (uint32_t *) pixbuf;
- for( unsigned int i = 0; i < numPixels; ++i )
- {
- buf[i] = clearColor;
- }
- }
- else if( mPixelFormat == Pixel::RGB888 )
- {
- for( unsigned int i = 0; i < numPixels; ++i )
- {
- pixbuf[i*bytesPerPixel] = r;
- pixbuf[i*bytesPerPixel+1] = g;
- pixbuf[i*bytesPerPixel+2] = b;
- }
- }
- else if( mPixelFormat == Pixel::A8 )
- {
- memset( pixbuf, a, numPixels );
- }
- }
-
- mClearColor = color;
- mClear = true;
-
- imageData->UploadBitmap( destId, 0, 0 );
- }
-}
-
-void Atlas::ClearCache()
-{
- Vector< Tile* >::ConstIterator end = mTiles.End();
- for( Vector<Tile*>::Iterator iter = mTiles.Begin(); iter != end; iter++ )
- {
- delete *iter;
- }
- mTiles.Clear();
-}
-
-Integration::BitmapPtr Atlas::LoadBitmap( const std::string& url )
-{
- Integration::BitmapResourceType resourceType;
- Integration::PlatformAbstraction& platformAbstraction = Internal::ThreadLocalStorage::Get().GetPlatformAbstraction();
-
- Integration::ResourcePointer resource = platformAbstraction.LoadResourceSynchronously(resourceType, url);
- Integration::BitmapPtr bitmap = static_cast<Integration::Bitmap*>( resource.Get());
-
- return bitmap;
-}
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_ATLAS_H__
-#define __DALI_INTERNAL_ATLAS_H__
-
-/*
- * 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.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-vector.h>
-#include <dali/devel-api/images/atlas.h>
-#include <dali/internal/event/images/context-recovery-interface.h>
-#include <dali/internal/event/images/image-impl.h>
-#include <dali/internal/event/images/buffer-image-impl.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-class ResourceClient;
-
-typedef Dali::Atlas::SizeType SizeType;
-
-/**
- * Internal class for Dali::Atlas
- */
-class Atlas : public Image, public ContextRecoveryInterface
-{
-public:
-
- /**
- * @brief Create a new Atlas.
- *
- * @pre width & height are greater than zero.
- * The maximum size of the atlas is limited by GL_MAX_TEXTURE_SIZE.
- * @param [in] width The atlas width in pixels.
- * @param [in] height The atlas height in pixels.
- * @param [in] pixelFormat The pixel format.
- * @param [in] recoverContext Whether re-uploading the resource images automatically when regaining the context
- * @return A pointer to a new Atlas.
- */
- static Atlas* New( SizeType width,
- SizeType height,
- Pixel::Format pixelFormat,
- bool recoverContext);
-
- /**
- * @copydoc Dali::Atlas::Clear
- */
- void Clear( const Vector4& color );
-
- /**
- * @copydoc Dali::Atlas::Upload( const BufferImage&, uint32_t, uint32_t )
- */
- bool Upload( BufferImage& bufferImage,
- SizeType xOffset,
- SizeType yOffset );
-
- /**
- * @copydoc Dali::Atlas::Upload( const std::string&, uint32_t, uint32_t )
- */
- bool Upload( const std::string& url,
- SizeType xOffset,
- SizeType yOffset );
-
- /**
- * @copydoc Dali::Atlas::Upload( Dali::PixelData, uint32_t, uint32_t )
- */
- bool Upload( PixelDataPtr pixelData,
- SizeType xOffset,
- SizeType yOffset );
-
- /**
- * @copydoc ContextRecoveryInterface::RecoverFromContextLoss
- */
- virtual void RecoverFromContextLoss();
-
-protected:
-
- /**
- * @brief Protected constructor.
- *
- * @pre width & height are greater than zero.
- * The maximum size of the atlas is limited by GL_MAX_TEXTURE_SIZE.
- * @param [in] width The atlas width in pixels.
- * @param [in] height The atlas height in pixels.
- * @param [in] pixelFormat The pixel format.
- * @param [in] recoverContext Whether re-uploading the resource images automatically when regaining the context
- */
- Atlas( SizeType width,
- SizeType height,
- Pixel::Format pixelFormat,
- bool recoverContext);
-
- /**
- * A reference counted object may only be deleted by calling Unreference()
- */
- virtual ~Atlas();
-
- /**
- * @copydoc Dali::Internal::Image::Connect
- */
- virtual void Connect();
-
- /**
- * @copydoc Dali::Internal::Image::Disconnect
- */
- virtual void Disconnect();
-
-private:
-
- /**
- * Helper for Upload methods
- * @return True if the size of the bitmap fits within the atlas at the specified offset
- */
- bool IsInside( SizeType x, SizeType y );
-
- /**
- * Helper to create the Atlas resource
- */
- void AllocateAtlas();
-
- /**
- * Helper to release the Atlas resource
- */
- void ReleaseAtlas();
-
- /**
- * Upload a bitmap with the given color to clear the background.
- */
- void ClearBackground( const Vector4& color );
-
- /**
- * Clear all the current tiles and resources of the atlas
- */
- void ClearCache();
-
- /**
- * Load the bitmap data from the url
- */
- Integration::BitmapPtr LoadBitmap( const std::string& url );
-
-private:
-
- /**
- * Record of the url resource in the Atlas.
- */
- struct Tile
- {
- Tile( SizeType xOffset, SizeType yOffset, const std::string& url )
- : xOffset( xOffset ), yOffset( yOffset ), url(url)
- {}
-
- ~Tile(){};
-
- SizeType xOffset; ///< Offset in the x direction within the atlas
- SizeType yOffset; ///< Offset in the y direction within the atlas
- std::string url; ///< The URL of the resource image file to use
-
- private:
- Tile(const Tile& rhs); ///< not defined
- Tile& operator=(const Tile& rhs); ///< not defined
- };
-
-private:
-
- ResourceClient& mResourceClient;
- Vector4 mClearColor; ///< The background clear color
- Vector<Tile*> mTiles; ///< The url resources, which would recover automatically when regaining context
- Pixel::Format mPixelFormat; ///< The pixel format (rgba 32 bit by default)
- bool mClear:1; ///< Clear the backgound or not
- bool mRecoverContext:1; ///< Re-upload the url resources or not when regaining context
-};
-
-} // namespace Internal
-
-/**
- * Helper methods for public API.
- */
-inline Internal::Atlas& GetImplementation(Dali::Atlas& image)
-{
- DALI_ASSERT_ALWAYS( image && "Atlas handle is empty" );
-
- BaseObject& handle = image.GetBaseObject();
-
- return static_cast<Internal::Atlas&>(handle);
-}
-
-inline const Internal::Atlas& GetImplementation(const Dali::Atlas& image)
-{
- DALI_ASSERT_ALWAYS( image && "Atlas handle is empty" );
-
- const BaseObject& handle = image.GetBaseObject();
-
- return static_cast<const Internal::Atlas&>(handle);
-}
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_ATLAS_H__
// INTERNAL INCLUDES
#include <dali/public-api/object/type-registry.h>
+#include <dali/public-api/images/pixel-data.h>
#include <dali/internal/event/common/thread-local-storage.h>
-#include <dali/internal/event/resources/resource-client.h>
#include <dali/internal/update/manager/update-manager.h>
using namespace Dali::Integration;
{
BufferImagePtr internal = new BufferImage( width, height, pixelformat );
internal->Initialize();
+ internal->Update( RectArea() );
return internal;
}
{
BufferImagePtr internal = new BufferImage( pixBuf, width, height, pixelformat, stride );
internal->Initialize();
+ internal->Update( RectArea() );
return internal;
}
BufferImage::~BufferImage()
{
- if( mTicket )
- {
- mTicket->RemoveObserver(*this);
- mTicket.Reset();
- }
-
delete[] mInternalBuffer;
}
return ( mExternalBuffer ? true : false );
}
-void BufferImage::Update( RectArea& updateArea )
+void BufferImage::Update( const RectArea& updateArea )
{
- if ( !mTicket )
+ if ( !mTexture )
{
- CreateHostBitmap();
+ mTexture = NewTexture::New( Dali::TextureType::TEXTURE_2D, mPixelFormat, mWidth, mHeight );
}
DALI_ASSERT_DEBUG( updateArea.x + updateArea.width <= mWidth && updateArea.y + updateArea.height <= mHeight );
- UploadArea( mTicket->GetId(), updateArea );
-}
-
-void BufferImage::CreateHostBitmap()
-{
- Integration::Bitmap* bitmap = Bitmap::New( Bitmap::BITMAP_2D_PACKED_PIXELS, mResourcePolicy );
- Bitmap::PackedPixelsProfile* const packedBitmap = bitmap->GetPackedPixelsProfile();
- DALI_ASSERT_DEBUG(packedBitmap);
-
- packedBitmap->ReserveBuffer( mPixelFormat, mWidth, mHeight );
- DALI_ASSERT_DEBUG(bitmap->GetBuffer() != 0);
- DALI_ASSERT_DEBUG(bitmap->GetBufferSize() >= mHeight * mWidth * mBytesPerPixel );
-
- mTicket = mResourceClient->AddBitmapImage( bitmap );
- mTicket->AddObserver(*this);
+ UploadArea( updateArea );
}
-void BufferImage::UploadArea( ResourceId destId, const RectArea& area )
+void BufferImage::UploadArea( const RectArea& area )
{
- Integration::Bitmap* bitmap = Bitmap::New( Bitmap::BITMAP_2D_PACKED_PIXELS, mResourcePolicy );
- Bitmap::PackedPixelsProfile* const packedBitmap = bitmap->GetPackedPixelsProfile();
- DALI_ASSERT_DEBUG(packedBitmap);
DALI_ASSERT_DEBUG( area.width <= mWidth && area.height <= mHeight );
mBufferWidth = area.width ? area.width : mWidth;
- packedBitmap->ReserveBuffer( mPixelFormat, mBufferWidth, area.height ? area.height : mHeight );
- DALI_ASSERT_DEBUG(bitmap->GetBuffer() != 0);
- DALI_ASSERT_DEBUG(bitmap->GetBufferSize() >= mBufferWidth * ( area.height ? area.height : mHeight ) * mBytesPerPixel );
+ uint32_t bufferHeight = area.height ? area.height : mHeight;
+ size_t bufferSize = mBytesPerPixel * mBufferWidth * bufferHeight;
+ unsigned char* buffer = reinterpret_cast< Dali::Integration::PixelBuffer* >( malloc( bufferSize ) );
+ DALI_ASSERT_DEBUG(buffer != 0);
// Are we uploading from an external or internal buffer ?
if ( mExternalBuffer )
// Check if we're doing the entire area without stride mismatch between source and dest ?
if( ( mByteStride == mWidth * mBytesPerPixel ) && area.IsEmpty() )
{
- memcpy( bitmap->GetBuffer(), mExternalBuffer, mBufferSize );
+ memcpy( buffer, mExternalBuffer, mBufferSize );
}
else
{
- UpdateBufferArea( mExternalBuffer, bitmap->GetBuffer(), area );
+ UpdateBufferArea( mExternalBuffer, buffer, area );
}
}
else
// Check if we're doing the entire internal buffer ?
if( area.IsEmpty() )
{
- memcpy( bitmap->GetBuffer(), mInternalBuffer, bitmap->GetBufferSize() );
+ memcpy( buffer, mInternalBuffer, bufferSize );
}
else
{
- UpdateBufferArea( mInternalBuffer, bitmap->GetBuffer(), area );
+ UpdateBufferArea( mInternalBuffer, buffer, area );
}
}
- mResourceClient->UploadBitmap( destId, bitmap, area.x, area.y );
-
-}
-
-void BufferImage::UploadBitmap( ResourceId destId, std::size_t xOffset, std::size_t yOffset )
-{
- RectArea area( xOffset, yOffset, 0, 0 );
- if ( !mTicket )
- {
- CreateHostBitmap();
- }
-
- UploadArea( destId, area );
+ PixelDataPtr pixelData = PixelData::New( buffer, bufferSize, mBufferWidth, bufferHeight, mPixelFormat, Dali::PixelData::FREE );
+ mTexture->Upload( pixelData, 0u, 0u, area.x, area.y, mBufferWidth, bufferHeight );
}
void BufferImage::UpdateBufferArea( PixelBuffer* src, PixelBuffer* dest, const RectArea& area )
}
}
-void BufferImage::Connect()
-{
- if ( !mConnectionCount++ && !mTicket )
- {
- RectArea area;
- Update( area );
- }
-}
-
-void BufferImage::Disconnect()
-{
- --mConnectionCount;
-}
-
} // namespace Internal
} // namespace Dali
* Notify Dali that the contents of the buffer have changed.
* @param [in] updateArea area that has changed in buffer. An empty rect means the whole buffer has changed.
*/
- void Update (RectArea& updateArea);
+ void Update( const RectArea& updateArea);
/**
* @copydoc Dali::BufferImage::IsDataExternal
return mPixelFormat;
}
- /**
- * @brief Upload pixel data to another resource at an offset
- *
- * @param destId ResourceId of the destination
- * @param xOffset x offset in the destination
- * @param yOffset y offset in the destination
- */
- void UploadBitmap( ResourceId destId, std::size_t xOffset, std::size_t yOffset );
-
-protected: // From Image
- /**
- * @copydoc Dali::Internal::Image::Connect
- */
- virtual void Connect();
-
- /**
- * @copydoc Dali::Internal::Image::Disconnect
- */
- virtual void Disconnect();
-
private:
void SetupBuffer( unsigned int width,
Pixel::Format pixelformat,
unsigned int byteStride );
- void CreateHostBitmap();
-
- void UploadArea( ResourceId destId, const RectArea& area );
+ void UploadArea( const RectArea& area );
void UpdateBufferArea( PixelBuffer* src, PixelBuffer* dest, const RectArea& area );
// INTERNAL INCLUDES
#include <dali/public-api/object/type-registry.h>
#include <dali/internal/event/common/thread-local-storage.h>
-#include <dali/internal/event/resources/resource-client.h>
#include <dali/integration-api/platform-abstraction.h>
namespace Dali
if( bitmap )
{
- ResourceClient &resourceClient = ThreadLocalStorage::Get().GetResourceClient();
- image->mTicket = resourceClient.AddBitmapImage( bitmap.Get() );
- image->mTicket->AddObserver( *image );
+ unsigned width = bitmap->GetImageWidth();
+ unsigned height = bitmap->GetImageHeight();
+
+ //Create texture
+ Pixel::Format format = bitmap->GetPixelFormat();
+ image->mTexture = NewTexture::New( Dali::TextureType::TEXTURE_2D, format, width, height );
+
+ //Upload data to the texture
+ size_t bufferSize = bitmap->GetBufferSize();
+ PixelDataPtr pixelData = PixelData::New( bitmap->GetBufferOwnership(), bufferSize, width, height, format,
+ static_cast< Dali::PixelData::ReleaseFunction >( bitmap->GetReleaseFunction() ) );
+ image->mTexture->Upload( pixelData );
+
+ image->mWidth = size.GetWidth();
+ if( image->mWidth == 0 )
+ {
+ image->mWidth = width;
+ }
+
+ image->mHeight = size.GetHeight();
+ if( image->mHeight == 0 )
+ {
+ image->mHeight = height;
+ }
+ }
+ else
+ {
+ image->mTexture = NewTexture::New( Dali::TextureType::TEXTURE_2D, Pixel::RGBA8888, 0u, 0u );
+ image->mWidth = image->mHeight = 0u;
}
return image;
// INTERNAL INCLUDES
#include <dali/public-api/object/type-registry.h>
#include <dali/internal/event/common/thread-local-storage.h>
-#include <dali/internal/event/resources/resource-client.h>
namespace Dali
{
namespace
{
TypeRegistration mType( typeid( Dali::FrameBufferImage ), typeid( Dali::Image ), NULL );
+
+const int RenderBufferFormatToFrameBufferAttachments[] = { Dali::FrameBuffer::Attachment::NONE,
+ Dali::FrameBuffer::Attachment::DEPTH,
+ Dali::FrameBuffer::Attachment::STENCIL,
+ Dali::FrameBuffer::Attachment::DEPTH_STENCIL
+ };
+
} // unnamed namespace
FrameBufferImagePtr FrameBufferImage::New( unsigned int width,
Pixel::Format pixelFormat,
RenderBuffer::Format bufferformat )
{
- FrameBufferImagePtr image = new FrameBufferImage( width, height, pixelFormat, bufferformat );
+ FrameBufferImagePtr image = new FrameBufferImage( width, height );
image->Initialize();
+
+ image->mTexture = NewTexture::New( Dali::TextureType::TEXTURE_2D, pixelFormat, width, height );
+ image->mFrameBufferObject = FrameBuffer::New( width, height, RenderBufferFormatToFrameBufferAttachments[bufferformat] );
+ image->mFrameBufferObject->AttachColorTexture( image->mTexture, 0u, 0u );
+
return image;
}
{
FrameBufferImagePtr image = new FrameBufferImage( nativeImage );
image->Initialize();
+
+ image->mTexture = NewTexture::New( nativeImage );
+ image->mFrameBufferObject = FrameBuffer::New( image->mTexture->GetWidth(), image->mTexture->GetHeight(), Dali::FrameBuffer::Attachment::NONE );
+ image->mFrameBufferObject->AttachColorTexture( image->mTexture, 0u, 0u );
+
return image;
}
-
-FrameBufferImage::FrameBufferImage( unsigned int width,
- unsigned int height,
- Pixel::Format pixelFormat,
- RenderBuffer::Format bufferformat )
+FrameBufferImage::FrameBufferImage( unsigned int width, unsigned int height)
: Image(),
mNativeImage(0),
- mPixelFormat( pixelFormat ),
- mBufferFormat( bufferformat ),
mIsNativeFbo( false )
{
mWidth = width;
FrameBufferImage::FrameBufferImage( NativeImageInterface& nativeImage )
: Image(),
mNativeImage( &nativeImage ),
- mPixelFormat( Pixel::FIRST_VALID_PIXEL_FORMAT ),
- mBufferFormat( RenderBuffer::COLOR ),
mIsNativeFbo( true )
{
mWidth = nativeImage.GetWidth();
mHeight = nativeImage.GetHeight();
}
-void FrameBufferImage::Connect()
-{
- ++mConnectionCount;
-
- if (mConnectionCount == 1)
- {
- // ticket was thrown away when related actors went offstage
- if (!mTicket)
- {
- ResourceClient& resourceClient = ThreadLocalStorage::Get().GetResourceClient();
- if (mNativeImage)
- {
- mTicket = resourceClient.AddFrameBufferImage(*mNativeImage);
- mTicket->AddObserver(*this);
- }
- else
- {
- mTicket = resourceClient.AddFrameBufferImage(mWidth, mHeight, mPixelFormat, mBufferFormat);
- mTicket->AddObserver(*this);
- }
- }
- }
-}
-
-void FrameBufferImage::Disconnect()
-{
- if(!mTicket)
- {
- return;
- }
-
- DALI_ASSERT_DEBUG(mConnectionCount > 0);
- --mConnectionCount;
- if (mConnectionCount == 0)
- {
- // release image memory when it's not visible anymore (decrease ref. count of texture)
- mTicket->RemoveObserver(*this);
- mTicket.Reset();
- }
-}
bool FrameBufferImage::IsNativeFbo() const
{
// INTERNAL INCLUDES
#include <dali/internal/event/images/image-impl.h>
#include <dali/public-api/images/frame-buffer-image.h>
+#include <dali/internal/event/rendering/frame-buffer-impl.h>
namespace Dali
{
/**
* @copydoc Dali::FrameBufferImage::FrameBufferImage
*/
- FrameBufferImage( unsigned int width, unsigned int height, Pixel::Format pixelFormat, RenderBuffer::Format bufferformat );
+ FrameBufferImage( unsigned int width, unsigned int height );
/**
* @copydoc Dali::FrameBufferImage::FrameBufferImage
*/
bool IsNativeFbo() const;
-public: // From Image
/**
- * @copydoc Dali::Internal::Image::Connect()
+ * @return Internal FrameBuffer used by this FrameBufferImage
*/
- virtual void Connect();
-
- /**
- * @copydoc Dali::Internal::Image::Disconnect()
- */
- virtual void Disconnect();
+ FrameBuffer* GetFrameBuffer() const
+ {
+ return mFrameBufferObject.Get();
+ }
protected:
/**
private:
// cached values for the size / pixel format we were created with. Needed to recreate us when we Connect() to stage and mTicket was reset from a previous call to Disconnect().
+ FrameBufferPtr mFrameBufferObject;
NativeImageInterfacePtr mNativeImage;
- Pixel::Format mPixelFormat;
- RenderBuffer::Format mBufferFormat;
bool mIsNativeFbo;
}; // class FrameBufferImage
#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/integration-api/debug.h>
-#include <dali/internal/event/resources/resource-ticket.h>
-#include <dali/internal/event/common/thread-local-storage.h>
-#include <dali/internal/event/resources/resource-client.h>
#include <dali/internal/event/common/stage-impl.h>
#include <dali/devel-api/images/native-image-interface-extension.h>
NativeImagePtr image = new NativeImage( resourceData );
image->Initialize();
- ResourceClient &resourceClient = ThreadLocalStorage::Get().GetResourceClient();
-
image->mWidth = resourceData.GetWidth();
image->mHeight = resourceData.GetHeight();
- const ResourceTicketPtr& ticket = resourceClient.AddNativeImage( resourceData );
- DALI_ASSERT_DEBUG( dynamic_cast<ImageTicket*>( ticket.Get() ) && "Resource ticket not ImageTicket subclass for image resource.\n" );
- image->mTicket = static_cast<ImageTicket*>(ticket.Get());
- image->mTicket->AddObserver( *image );
-
+ image->mTexture = NewTexture::New( resourceData );
return image;
}
{
}
-void NativeImage::CreateGlTexture()
-{
- ResourceClient& resourceClient = ThreadLocalStorage::Get().GetResourceClient();
- resourceClient.CreateGlTexture( GetResourceId() );
-}
-
const char* NativeImage::GetCustomFragmentPreFix()
{
if( mCustomFragmentPreFix.empty() )
*/
static NativeImagePtr New( NativeImageInterface& nativeImageInterface );
- /**
- * @copydoc Dali::NativeImage::CreateGlTexture
- */
- void CreateGlTexture();
-
protected:
/**
return static_cast< CameraActor* >( mCameraConnector.mActor );
}
-void RenderTask::SetTargetFrameBuffer( Dali::FrameBufferImage image )
+void RenderTask::SetTargetFrameBuffer( FrameBufferImagePtr image )
{
- if ( mFrameBufferImage != image )
+ mFrameBufferImage = image;
+ FrameBuffer* frameBufferPtr( NULL );
+ if( image )
{
- // if we have a scene object we need to track connection status and set frame buffer id as well as updating target frame buffer
- if ( mSceneObject )
- {
- if(mFrameBufferImage)
- {
- GetImplementation(mFrameBufferImage).Disconnect();
- }
-
- // update target frame buffer
- mFrameBufferImage = image;
-
- unsigned int resourceId = 0;
- bool isNativeFBO = false;
- if( mFrameBufferImage )
- {
- Dali::Internal::FrameBufferImage& impl = GetImplementation( mFrameBufferImage );
- impl.Connect();
- resourceId = impl.GetResourceId();
- isNativeFBO = impl.IsNativeFbo();
- }
-
- // mSceneObject is being used in a separate thread; queue a message to set the value
- SetFrameBufferIdMessage( GetEventThreadServices(), *mSceneObject, resourceId, isNativeFBO );
- }
- else
- {
- // update target frame buffer
- mFrameBufferImage = image;
- }
+ frameBufferPtr = image->GetFrameBuffer();
}
+
+ SetFrameBuffer( frameBufferPtr );
}
-void RenderTask::SetFrameBuffer( Dali::FrameBuffer frameBuffer )
+void RenderTask::SetFrameBuffer( FrameBufferPtr frameBuffer )
{
+ mFrameBuffer = frameBuffer;
+ Render::FrameBuffer* renderFrameBufferPtr( NULL );
if( frameBuffer )
{
- mFrameBuffer = Internal::FrameBufferPtr( &GetImplementation( frameBuffer ) );
- SetFrameBufferMessage( GetEventThreadServices(), *mSceneObject, mFrameBuffer->GetRenderObject() );
- }
- else
- {
- mFrameBuffer.Reset();
- SetFrameBufferMessage( GetEventThreadServices(), *mSceneObject, NULL );
+ renderFrameBufferPtr = mFrameBuffer->GetRenderObject();
}
+
+ SetFrameBufferMessage( GetEventThreadServices(), *mSceneObject, renderFrameBufferPtr );
}
FrameBuffer* RenderTask::GetFrameBuffer() const
return mFrameBuffer.Get();
}
-Dali::FrameBufferImage RenderTask::GetTargetFrameBuffer() const
+FrameBufferImage* RenderTask::GetTargetFrameBuffer() const
{
- return mFrameBufferImage;
+ return mFrameBufferImage.Get();
}
void RenderTask::SetScreenToFrameBufferFunction( ScreenToFrameBufferFunction conversionFunction )
if ( mFrameBufferImage )
{
viewPort.x = viewPort.y = 0;
- viewPort.width = mFrameBufferImage.GetWidth();
- viewPort.height = mFrameBufferImage.GetHeight();
+ viewPort.width = mFrameBufferImage->GetWidth();
+ viewPort.height = mFrameBufferImage->GetHeight();
}
else
{
// Keep the raw-pointer until DiscardSceneObject is called
mSceneObject = SceneGraph::RenderTask::New();
- // if we have a frame buffer we need to track connection status then send a message to set the frame buffer id in case it has changed since last time we were on stage
- unsigned int resourceId = 0;
- bool isNativeFBO = false;
- if( mFrameBufferImage )
- {
- Dali::Internal::FrameBufferImage& impl = GetImplementation( mFrameBufferImage );
- impl.Connect();
- resourceId = impl.GetResourceId();
- isNativeFBO = impl.IsNativeFbo();
- }
-
- // mSceneObject is being used in a separate thread; queue a message to set the value
- SetFrameBufferIdMessage( GetEventThreadServices(), *mSceneObject, resourceId, isNativeFBO );
-
// Send messages to set other properties that may have changed since last time we were on stage
SetExclusiveMessage( GetEventThreadServices(), *mSceneObject, mExclusive );
SetClearColorMessage( GetEventThreadServices(), *mSceneObject, mClearColor );
SetClearEnabledMessage( GetEventThreadServices(), *mSceneObject, mClearEnabled );
SetCullModeMessage( GetEventThreadServices(), *mSceneObject, mCullMode );
SetRefreshRateMessage( GetEventThreadServices(), *mSceneObject, mRefreshRate );
+ SetSyncRequiredMessage( GetEventThreadServices(), *mSceneObject, mRequiresSync );
+ SetFrameBuffer( mFrameBuffer );
// Caller takes ownership
return mSceneObject;
{
// mSceneObject is not owned; throw away the raw-pointer
mSceneObject = NULL;
-
- // if we have a frame buffer we need to track connection status
- if(mFrameBufferImage)
- {
- GetImplementation(mFrameBufferImage).Disconnect();
- }
}
/********************************************************************************
// INTERNAL INCLUDES
#include <dali/public-api/object/base-object.h>
#include <dali/public-api/render-tasks/render-task.h>
-#include <dali/public-api/images/frame-buffer-image.h>
+#include <dali/internal/event/images/frame-buffer-image-impl.h>
#include <dali/internal/event/common/object-impl.h>
#include <dali/internal/event/rendering/frame-buffer-impl.h>
/**
* @copydoc Dali::RenderTask::SetTargetFrameBuffer()
*/
- void SetTargetFrameBuffer( Dali::FrameBufferImage frameBuffer );
+ void SetTargetFrameBuffer( FrameBufferImagePtr frameBuffer );
/**
* @copydoc Dali::RenderTask::GetTargetFrameBuffer
*/
- Dali::FrameBufferImage GetTargetFrameBuffer() const;
+ FrameBufferImage* GetTargetFrameBuffer() const;
/**
* @copydoc Dali::RenderTask::SetFrameBuffer()
*/
- void SetFrameBuffer( Dali::FrameBuffer frameBuffer );
+ void SetFrameBuffer( FrameBufferPtr frameBuffer );
/**
* @copydoc Dali::RenderTask::GetFrameBuffer
unsigned int mRefreshOnceCounter;
- Dali::FrameBufferImage mFrameBufferImage; ///< Optional off-screen render target.
+ FrameBufferImagePtr mFrameBufferImage; ///< Optional off-screen render target.
FrameBufferPtr mFrameBuffer;
*/
unsigned int GetHeight() const;
-
private: // implementation
/**
$(internal_src_dir)/event/events/tap-gesture-processor.cpp \
$(internal_src_dir)/event/events/touch-data-impl.cpp \
$(internal_src_dir)/event/events/touch-event-processor.cpp \
- $(internal_src_dir)/event/images/atlas-impl.cpp \
$(internal_src_dir)/event/images/bitmap-packed-pixel.cpp \
$(internal_src_dir)/event/images/bitmap-compressed.cpp \
$(internal_src_dir)/event/images/image-impl.cpp \
mImpl->context.InvalidateFramebuffer(GL_FRAMEBUFFER, 2, attachments);
}
- if( instruction.mRenderTracker && offscreen != NULL )
+ if( instruction.mRenderTracker && ( offscreen != NULL || instruction.mFrameBuffer != NULL ) )
{
// This will create a sync object every frame this render tracker
// is alive (though it should be now be created only for
#include <dali/public-api/actors/sampling.h>
#include <dali/public-api/rendering/sampler.h>
-#include <dali/internal/render/renderers/render-sampler.h>
namespace Dali
{
bool NewTexture::Bind( Context& context, unsigned int textureUnit, Render::Sampler* sampler )
{
+ if( mNativeImage && mId == 0 )
+ {
+ Initialize( context );
+ }
+
if( mId != 0 )
{
context.ActiveTexture( static_cast<TextureUnit>(textureUnit) );
if( mSampler.mBitfield != oldSampler.mBitfield )
{
- if( mSampler.mMinificationFilter != oldSampler.mMinificationFilter )
+ GLint mode = FilterModeToGL( mSampler.mMinificationFilter, DALI_MINIFY_DEFAULT, GL_MINIFY_DEFAULT );
+ if( mode != FilterModeToGL( oldSampler.mMinificationFilter, DALI_MINIFY_DEFAULT, GL_MINIFY_DEFAULT ) )
{
- GLint glFilterMode = FilterModeToGL( mSampler.mMinificationFilter, DALI_MINIFY_DEFAULT, GL_MINIFY_DEFAULT );
- context.TexParameteri( mTarget, GL_TEXTURE_MIN_FILTER, glFilterMode );
+ context.TexParameteri( mTarget, GL_TEXTURE_MIN_FILTER, mode );
}
- if( mSampler.mMagnificationFilter != oldSampler.mMagnificationFilter )
+ mode = FilterModeToGL( mSampler.mMagnificationFilter, DALI_MAGNIFY_DEFAULT, GL_MAGNIFY_DEFAULT );
+ if( mode != FilterModeToGL( oldSampler.mMagnificationFilter, DALI_MAGNIFY_DEFAULT, GL_MAGNIFY_DEFAULT ) )
{
- GLint glFilterMode = FilterModeToGL( mSampler.mMagnificationFilter, DALI_MAGNIFY_DEFAULT, GL_MAGNIFY_DEFAULT );
- context.TexParameteri( mTarget, GL_TEXTURE_MAG_FILTER, glFilterMode );
+ context.TexParameteri( mTarget, GL_TEXTURE_MAG_FILTER, mode );
}
- if( mSampler.mSWrapMode != oldSampler.mSWrapMode )
+ mode = WrapModeToGL( mSampler.mSWrapMode, GL_WRAP_DEFAULT );
+ if( mode != WrapModeToGL( oldSampler.mSWrapMode, GL_WRAP_DEFAULT ) )
{
- GLint glWrapMode = WrapModeToGL( mSampler.mSWrapMode, GL_WRAP_DEFAULT );
- context.TexParameteri( mTarget, GL_TEXTURE_WRAP_S, glWrapMode );
+ context.TexParameteri( mTarget, GL_TEXTURE_WRAP_S, mode );
}
- if( mSampler.mTWrapMode != oldSampler.mTWrapMode )
+ mode = WrapModeToGL( mSampler.mTWrapMode, GL_WRAP_DEFAULT );
+ if( mode != WrapModeToGL( oldSampler.mTWrapMode, GL_WRAP_DEFAULT ) )
{
- GLint glWrapMode = WrapModeToGL( mSampler.mTWrapMode, GL_WRAP_DEFAULT );
- context.TexParameteri( mTarget, GL_TEXTURE_WRAP_T, glWrapMode );
+ context.TexParameteri( mTarget, GL_TEXTURE_WRAP_T, mode );
}
- if( mType == TextureType::TEXTURE_CUBE && mSampler.mRWrapMode != oldSampler.mRWrapMode )
+ if( mType == TextureType::TEXTURE_CUBE )
{
- GLint glWrapMode = WrapModeToGL( mSampler.mRWrapMode, GL_WRAP_DEFAULT );
- context.TexParameteri( mTarget, GL_TEXTURE_WRAP_R, glWrapMode );
+ mode = WrapModeToGL( mSampler.mRWrapMode, GL_WRAP_DEFAULT );
+ if( mode != WrapModeToGL( oldSampler.mRWrapMode, GL_WRAP_DEFAULT ) )
+ {
+ context.TexParameteri( mTarget, GL_TEXTURE_WRAP_R, mode );
+ }
}
}
}
void RenderTask::SetFrameBuffer( Render::FrameBuffer* frameBuffer )
{
- mTargetIsNativeFramebuffer = false;
mFrameBuffer = frameBuffer;
}
mNotifyTrigger = true;
}
}
+ else if( mFrameBuffer )
+ {
+ if( !mRenderSyncTracker || (mRenderSyncTracker && mRenderSyncTracker->IsSynced() ))
+ {
+ mWaitingToRender = false;
+ mNotifyTrigger = true;
+ }
+ }
else
{
mNotifyTrigger = true;
viewportSet ? &viewport : NULL,
mClearEnabled ? &GetClearColor( updateBufferIndex ) : NULL );
- if( mTargetIsNativeFramebuffer && mRequiresSync &&
+ if( mRequiresSync &&
mRefreshRate == Dali::RenderTask::REFRESH_ONCE &&
mResourcesFinished )
{
void NativeImage::CreateGlTexture()
{
- GetImplementation(*this).CreateGlTexture();
+ //Nothing to do here. The texture is created immediately.
}
NativeImage NativeImage::New( NativeImageInterface& resourceData )
#include <dali/public-api/rendering/frame-buffer.h>
#include <dali/internal/event/actors/actor-impl.h>
#include <dali/internal/event/actors/camera-actor-impl.h>
+#include <dali/internal/event/images/frame-buffer-image-impl.h>
#include <dali/internal/event/render-tasks/render-task-impl.h>
namespace Dali
return Dali::CameraActor(GetImplementation(*this).GetCameraActor());
}
-void RenderTask::SetTargetFrameBuffer( FrameBufferImage frameBuffer )
+void RenderTask::SetTargetFrameBuffer( Dali::FrameBufferImage frameBuffer )
{
- GetImplementation(*this).SetTargetFrameBuffer( frameBuffer );
+ Internal::FrameBufferImage* frameBufferPtr( NULL );
+ if( frameBuffer )
+ {
+ frameBufferPtr = &GetImplementation( frameBuffer );
+ }
+
+ GetImplementation(*this).SetTargetFrameBuffer( frameBufferPtr );
}
FrameBufferImage RenderTask::GetTargetFrameBuffer() const
{
- return GetImplementation(*this).GetTargetFrameBuffer();
+ Internal::FrameBufferImage* frameBufferPtr = GetImplementation(*this).GetTargetFrameBuffer();
+ return Dali::FrameBufferImage( frameBufferPtr );
}
void RenderTask::SetFrameBuffer( FrameBuffer frameBuffer )
{
- GetImplementation(*this).SetFrameBuffer( frameBuffer );
+ Internal::FrameBuffer* frameBufferPtr( NULL );
+ if( frameBuffer )
+ {
+ frameBufferPtr = &GetImplementation( frameBuffer );
+ }
+
+ GetImplementation(*this).SetFrameBuffer( frameBufferPtr );
}
FrameBuffer RenderTask::GetFrameBuffer() const