[Problem] Bubble emitter's background render task is deleted on completion.
Context loss removes frame buffer image, and there is no mechanism to regenerate it.
[Cause] New requirement
[Solution] Add listener to Stage::ContextRegainedSignal() to re-run the
render task and regenerate the background image.
Change-Id: I08b54b286b04d22b923785b0634497f13380045f
Signed-off-by: David Steele <david.steele@partner.samsung.com>
TestApplication::TestApplication( size_t surfaceWidth,
size_t surfaceHeight,
float horizontalDpi,
TestApplication::TestApplication( size_t surfaceWidth,
size_t surfaceHeight,
float horizontalDpi,
+ float verticalDpi,
+ ResourcePolicy::DataRetention policy)
: mCore( NULL ),
mSurfaceWidth( surfaceWidth ),
mSurfaceHeight( surfaceHeight ),
mFrame( 0u ),
mDpi( horizontalDpi, verticalDpi ),
: mCore( NULL ),
mSurfaceWidth( surfaceWidth ),
mSurfaceHeight( surfaceHeight ),
mFrame( 0u ),
mDpi( horizontalDpi, verticalDpi ),
+ mLastVSyncTime(0u),
+ mDataRetentionPolicy( policy )
size_t surfaceWidth,
size_t surfaceHeight,
float horizontalDpi,
size_t surfaceWidth,
size_t surfaceHeight,
float horizontalDpi,
+ float verticalDpi,
+ ResourcePolicy::DataRetention policy)
: mCore( NULL ),
mSurfaceWidth( surfaceWidth ),
mSurfaceHeight( surfaceHeight ),
mFrame( 0u ),
: mCore( NULL ),
mSurfaceWidth( surfaceWidth ),
mSurfaceHeight( surfaceHeight ),
mFrame( 0u ),
- mDpi( horizontalDpi, verticalDpi )
+ mDpi( horizontalDpi, verticalDpi ),
+ mDataRetentionPolicy( policy )
mPlatformAbstraction,
mGlAbstraction,
mGlSyncAbstraction,
mPlatformAbstraction,
mGlAbstraction,
mGlSyncAbstraction,
+ mGestureManager,
+ mDataRetentionPolicy);
mCore->ContextCreated();
mCore->SurfaceResized( mSurfaceWidth, mSurfaceHeight );
mCore->ContextCreated();
mCore->SurfaceResized( mSurfaceWidth, mSurfaceHeight );
void TestApplication::ResetContext()
{
void TestApplication::ResetContext()
{
- mCore->ContextToBeDestroyed();
+ mCore->ContextDestroyed();
mCore->ContextCreated();
}
mCore->ContextCreated();
}
TestApplication( size_t surfaceWidth = DEFAULT_SURFACE_WIDTH,
size_t surfaceHeight = DEFAULT_SURFACE_HEIGHT,
float horizontalDpi = DEFAULT_HORIZONTAL_DPI,
TestApplication( size_t surfaceWidth = DEFAULT_SURFACE_WIDTH,
size_t surfaceHeight = DEFAULT_SURFACE_HEIGHT,
float horizontalDpi = DEFAULT_HORIZONTAL_DPI,
- float verticalDpi = DEFAULT_VERTICAL_DPI );
+ float verticalDpi = DEFAULT_VERTICAL_DPI,
+ ResourcePolicy::DataRetention resourcePolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA );
+
+
TestApplication( bool initialize,
size_t surfaceWidth = DEFAULT_SURFACE_WIDTH,
size_t surfaceHeight = DEFAULT_SURFACE_HEIGHT,
float horizontalDpi = DEFAULT_HORIZONTAL_DPI,
TestApplication( bool initialize,
size_t surfaceWidth = DEFAULT_SURFACE_WIDTH,
size_t surfaceHeight = DEFAULT_SURFACE_HEIGHT,
float horizontalDpi = DEFAULT_HORIZONTAL_DPI,
- float verticalDpi = DEFAULT_VERTICAL_DPI );
+ float verticalDpi = DEFAULT_VERTICAL_DPI,
+ ResourcePolicy::DataRetention resourcePolicy = ResourcePolicy::DALI_DISCARDS_ALL_DATA );
void Initialize();
virtual ~TestApplication();
void Initialize();
virtual ~TestApplication();
Vector2 mDpi;
unsigned int mLastVSyncTime;
Vector2 mDpi;
unsigned int mLastVSyncTime;
+ ResourcePolicy::DataRetention mDataRetentionPolicy;
- bitmapData = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true);
+ bitmapData = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD);
bitmapData->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, 64, 64);
PixelBuffer* pixelBuffer = bitmapData->GetBuffer();
memset( pixelBuffer, it->character, 64*64 );
bitmapData->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, 64, 64);
PixelBuffer* pixelBuffer = bitmapData->GetBuffer();
memset( pixelBuffer, it->character, 64*64 );
characters.insert( it->character );
Integration::GlyphMetrics character = {it->character, Integration::GlyphMetrics::HIGH_QUALITY, 10.0f, 10.0f, 9.0f, 1.0f, 10.0f, it->xPosition, it->yPosition };
characters.insert( it->character );
Integration::GlyphMetrics character = {it->character, Integration::GlyphMetrics::HIGH_QUALITY, 10.0f, 10.0f, 9.0f, 1.0f, 10.0f, it->xPosition, it->yPosition };
- bitmapData = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true);
+ bitmapData = Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD);
bitmapData->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, 64, 64);
PixelBuffer* pixelBuffer = bitmapData->GetBuffer();
memset( pixelBuffer, it->character, 64*64 );
bitmapData->GetPackedPixelsProfile()->ReserveBuffer(Pixel::A8, 64, 64);
PixelBuffer* pixelBuffer = bitmapData->GetBuffer();
memset( pixelBuffer, it->character, 64*64 );
Integration::BitmapPtr TestPlatformAbstraction::GetGlyphImage( const std::string& fontFamily, const std::string& fontStyle, float fontSize, uint32_t character ) const
{
Integration::BitmapPtr TestPlatformAbstraction::GetGlyphImage( const std::string& fontFamily, const std::string& fontStyle, float fontSize, uint32_t character ) const
{
- Integration::BitmapPtr image = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, true );
+ Integration::BitmapPtr image = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD );
image->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 1, 1 );
mTrace.PushCall("GetGlyphImage", "");
image->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, 1, 1 );
mTrace.PushCall("GetGlyphImage", "");
mMovementArea( movementArea ),
mShapeImage( shapeImage ),
mTotalNumOfBubble( maximumNumberOfBubble ),
mMovementArea( movementArea ),
mShapeImage( shapeImage ),
mTotalNumOfBubble( maximumNumberOfBubble ),
+ mRenderTaskRunning(false),
mBubbleSizeRange( bubbleSizeRange ),
mCurrentUniform( 0 ),
mDensity( 5 )
mBubbleSizeRange( bubbleSizeRange ),
mCurrentUniform( 0 ),
mDensity( 5 )
// Create a cameraActor for the off screen render task.
mCameraActor = CameraActor::New(mMovementArea);
mCameraActor.SetParentOrigin(ParentOrigin::CENTER);
// Create a cameraActor for the off screen render task.
mCameraActor = CameraActor::New(mMovementArea);
mCameraActor.SetParentOrigin(ParentOrigin::CENTER);
- Stage::GetCurrent().Add(mCameraActor);
+
+ Stage stage = Stage::GetCurrent();
+
+ stage.Add(mCameraActor);
+ stage.ContextRegainedSignal().Connect(this, &BubbleEmitter::OnContextRegained);
}
Actor BubbleEmitter::GetRootActor()
}
Actor BubbleEmitter::GetRootActor()
void BubbleEmitter::SetBackground( Image bgImage, const Vector3& hsvDelta )
{
void BubbleEmitter::SetBackground( Image bgImage, const Vector3& hsvDelta )
{
+ mBackgroundImage = bgImage;
+ mHSVDelta = hsvDelta;
+
ImageActor sourceActor = ImageActor::New( bgImage );
sourceActor.SetSize( mMovementArea );
sourceActor.SetParentOrigin(ParentOrigin::CENTER);
ImageActor sourceActor = ImageActor::New( bgImage );
sourceActor.SetSize( mMovementArea );
sourceActor.SetParentOrigin(ParentOrigin::CENTER);
task.GetCameraActor().SetInvertYAxis(true);
task.SetTargetFrameBuffer( mEffectImage );
task.FinishedSignal().Connect(this, &BubbleEmitter::OnRenderFinished);
task.GetCameraActor().SetInvertYAxis(true);
task.SetTargetFrameBuffer( mEffectImage );
task.FinishedSignal().Connect(this, &BubbleEmitter::OnRenderFinished);
+ mRenderTaskRunning = true;
}
void BubbleEmitter::SetShapeImage( Image shapeImage )
}
void BubbleEmitter::SetShapeImage( Image shapeImage )
// clear the resources created for the off screen rendering
void BubbleEmitter::OnRenderFinished(RenderTask& source)
{
// clear the resources created for the off screen rendering
void BubbleEmitter::OnRenderFinished(RenderTask& source)
{
+ mRenderTaskRunning = false;
Actor sourceActor = source.GetSourceActor();
if( sourceActor )
{
Actor sourceActor = source.GetSourceActor();
if( sourceActor )
{
renderable.RemoveShaderEffect();
}
}
renderable.RemoveShaderEffect();
}
}
- Stage::GetCurrent().Remove(sourceActor);
- Stage::GetCurrent().GetRenderTaskList().RemoveTask(source);
+
+ Stage stage = Stage::GetCurrent();
+ stage.Remove(sourceActor);
+ stage.GetRenderTaskList().RemoveTask(source);
+}
+
+void BubbleEmitter::OnContextRegained()
+{
+ // Context was lost, so the framebuffer has been destroyed. Re-create render task
+ // and trigger re-draw if not already running
+ if( ! mRenderTaskRunning )
+ {
+ SetBackground( mBackgroundImage, mHSVDelta );
+ }
}
void BubbleEmitter::SetBlendMode( bool enable )
}
void BubbleEmitter::SetBlendMode( bool enable )
void OnRenderFinished(RenderTask& source);
/**
void OnRenderFinished(RenderTask& source);
/**
+ * Callback function from Stage to tell us if the context has been regained.
+ */
+ void OnContextRegained();
+
+ /**
* Generate the material object which is attached to the meshActor to describe its color, texture, texture mapping mode etc.
*/
void GenMaterial();
* Generate the material object which is attached to the meshActor to describe its color, texture, texture mapping mode etc.
*/
void GenMaterial();
unsigned int mNumBubblePerShader; ///< How many bubbles for each BubbleEffect shader.
unsigned int mNumShader; ///< How many BubbleEffect shaders are used.
unsigned int mTotalNumOfBubble; ///< mNumBubblePerShader*mNumShader.
unsigned int mNumBubblePerShader; ///< How many bubbles for each BubbleEffect shader.
unsigned int mNumShader; ///< How many BubbleEffect shaders are used.
unsigned int mTotalNumOfBubble; ///< mNumBubblePerShader*mNumShader.
+ bool mRenderTaskRunning; ///< If the background render task is currently running
+
Vector2 mBubbleSizeRange; ///< The bubble size range.
std::vector<Mesh> mMesh; ///< The mesh vector, each mesh is used to create a meshActor which applies a BubbleEffect.
Vector2 mBubbleSizeRange; ///< The bubble size range.
std::vector<Mesh> mMesh; ///< The mesh vector, each mesh is used to create a meshActor which applies a BubbleEffect.
unsigned int mCurrentUniform; ///< Keep track of the uniform index for the newly emitted bubble
unsigned int mCurrentUniform; ///< Keep track of the uniform index for the newly emitted bubble
+ Vector3 mHSVDelta; ///< The HSV difference used to adjust the background image color.
+ Image mBackgroundImage; ///< The original background image
FrameBufferImage mEffectImage; ///< The image stores the adjusted color of the background image.The bubbles pick color from this image.
CameraActor mCameraActor; ///< The render task views the scene from the perspective of this actor.
FrameBufferImage mEffectImage; ///< The image stores the adjusted color of the background image.The bubbles pick color from this image.
CameraActor mCameraActor; ///< The render task views the scene from the perspective of this actor.