Exemplo n.º 1
0
int UtcDaliImageActorUseImageAlpha04(void)
{
  TestApplication application;

  tet_infoline("Testing Dali::RenderableActor::SetUseImageAlpha()");

  FrameBufferImage image = FrameBufferImage::New( 100, 50, Pixel::RGBA8888 );
  RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
  RenderTask task = taskList.GetTask( 0u );
  task.SetTargetFrameBuffer( image ); // To ensure frame buffer is connected
  application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
  application.SendNotification();
  application.Render(0);

  ImageActor actor = ImageActor::New( image );
  application.SendNotification();
  application.Render(0);

  actor.SetBlendMode( BlendingMode::ON );
  actor.SetColor(Vector4(1.0, 1.0, 1.0, 1.0));
  actor.SetSize(100, 50);
  application.GetGlAbstraction().EnableCullFaceCallTrace(true); // For Enable(GL_BLEND)
  Stage::GetCurrent().Add(actor);

  application.SendNotification();
  application.Render();

  const TraceCallStack& callTrace = application.GetGlAbstraction().GetCullFaceTrace();
  DALI_TEST_EQUALS( BlendDisabled( callTrace ), false, TEST_LOCATION );
  DALI_TEST_EQUALS( BlendEnabled( callTrace), true, TEST_LOCATION );
  END_TEST;
}
int UtcDaliHitTestAlgorithmOrtho02(void)
{
  TestApplication application;
  tet_infoline("Testing Dali::HitTestAlgorithm with offset Ortho camera()");

  Stage stage = Stage::GetCurrent();
  RenderTaskList renderTaskList = stage.GetRenderTaskList();
  RenderTask defaultRenderTask = renderTaskList.GetTask(0u);
  Dali::CameraActor cameraActor = defaultRenderTask.GetCameraActor();

  Vector2 stageSize ( stage.GetSize() );
  cameraActor.SetOrthographicProjection(-stageSize.x * 0.3f,  stageSize.x * 0.7f,
                                         stageSize.y * 0.3f, -stageSize.y * 0.7f,
                                         800.0f, 4895.0f);
  cameraActor.SetPosition(0.0f, 0.0f, 1600.0f);

  Vector2 actorSize( stageSize * 0.5f );
  // Create two actors with half the size of the stage and set them to be partially overlapping
  Actor blue = Actor::New();
  blue.SetName( "Blue" );
  blue.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  blue.SetParentOrigin( Vector3(0.2f, 0.2f, 0.5f) );
  blue.SetSize( actorSize );
  blue.SetZ(30.0f);

  Actor green = Actor::New( );
  green.SetName( "Green" );
  green.SetAnchorPoint( AnchorPoint::TOP_LEFT );
  green.SetParentOrigin( Vector3(0.4f, 0.4f, 0.5f) );
  green.SetSize( actorSize );

  // Add the actors to the view
  stage.Add( blue );
  stage.Add( green );

  // Render and notify
  application.SendNotification();
  application.Render(0);
  application.Render(10);

  HitTestAlgorithm::Results results;
  HitTest(stage, Vector2( 240.0f, 400.0f ), results, &DefaultIsActorTouchableFunction);
  DALI_TEST_CHECK( results.actor == green );
  DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.6f, TEST_LOCATION );

  HitTest(stage, Vector2::ZERO, results, &DefaultIsActorTouchableFunction);
  DALI_TEST_CHECK( results.actor == blue );
  DALI_TEST_EQUALS( results.actorCoordinates, Vector2::ZERO, TEST_LOCATION );

  HitTest(stage, stageSize, results, &DefaultIsActorTouchableFunction);
  DALI_TEST_CHECK( ! results.actor );
  DALI_TEST_EQUALS( results.actorCoordinates, Vector2::ZERO, TEST_LOCATION );

  // Just inside green
  HitTest(stage, stageSize*0.69f, results, &DefaultIsActorTouchableFunction);
  DALI_TEST_CHECK( results.actor == green );
  DALI_TEST_EQUALS( results.actorCoordinates, actorSize * 0.98f, TEST_LOCATION );
  END_TEST;
}
int UtcDaliHoverMultipleRenderTasksWithChildLayer(void)
{
  TestApplication application;
  Stage stage ( Stage::GetCurrent() );
  Vector2 stageSize ( stage.GetSize() );

  Actor actor = Actor::New();
  actor.SetSize(100.0f, 100.0f);
  actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
  stage.Add(actor);

  Layer layer = Layer::New();
  layer.SetSize(100.0f, 100.0f);
  layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
  actor.Add(layer);

  // Create render task
  Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f );
  RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() );
  renderTask.SetViewport( viewport );
  renderTask.SetInputEnabled( true );
  renderTask.SetSourceActor( actor );

  // Render and notify
  application.SendNotification();
  application.Render();

  // Connect to layer's hovered signal
  SignalData data;
  HoverEventFunctor functor( data );
  actor.HoveredSignal().Connect( &application, functor );
  layer.HoveredSignal().Connect( &application, functor );

  // Emit a started signal
  application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) );
  DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
  data.Reset();

  // Ensure renderTask actor can be hit too.
  application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
  DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
  data.Reset();

  // Disable input on renderTask, should not be hittable
  renderTask.SetInputEnabled( false );
  application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
  DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
  data.Reset();
  END_TEST;
}
int UtcDaliHoverOffscreenRenderTasks(void)
{
  TestApplication application;
  Stage stage ( Stage::GetCurrent() );
  Vector2 stageSize ( stage.GetSize() );

  // FrameBufferImage for offscreen RenderTask
  FrameBufferImage frameBufferImage( FrameBufferImage::New( stageSize.width, stageSize.height, Pixel::RGBA8888 ) );

  // Create a renderable actor to display the FrameBufferImage
  Actor renderableActor = CreateRenderableActor( frameBufferImage );
  renderableActor.SetParentOrigin(ParentOrigin::CENTER);
  renderableActor.SetSize( stageSize.x, stageSize.y );
  renderableActor.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME
  stage.Add( renderableActor );

  Actor actor = Actor::New();
  actor.SetSize(100.0f, 100.0f);
  actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
  stage.Add( actor );
  application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); // Ensure framebuffer connects

  stage.GetRenderTaskList().GetTask( 0u ).SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );

  // Create a RenderTask
  RenderTask renderTask = stage.GetRenderTaskList().CreateTask();
  renderTask.SetSourceActor( actor );
  renderTask.SetTargetFrameBuffer( frameBufferImage );
  renderTask.SetInputEnabled( true );

  // Create another RenderTask
  RenderTask renderTask2( stage.GetRenderTaskList().CreateTask() );
  renderTask2.SetInputEnabled( true );

  // Render and notify
  application.SendNotification();
  application.Render();

  // Connect to actor's hovered signal
  SignalData data;
  HoverEventFunctor functor( data );
  actor.HoveredSignal().Connect( &application, functor );

  // Emit a started signal
  application.ProcessEvent( GenerateSingleHover( TouchPoint::Started, Vector2( 10.0f, 10.0f ) ) );
  DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
  data.Reset();
  END_TEST;
}
Exemplo n.º 5
0
    bool updateTaskAndCache(uint64_t scene_id, const RenderTask& in_task, RenderTask& cached_task) {
        std::lock_guard<std::mutex> lock(scene_cache_mutex);

        if(in_task.has_scene()) {
            // Update cache.
            scene_cache[scene_id] = in_task.scene();
            return true;
        }
        // Try getting from cache.
        const auto maybe_scene = scene_cache.find(scene_id);
        if(maybe_scene != scene_cache.end()) {
            cached_task.mutable_scene()->CopyFrom(maybe_scene->second);
            return true;
        }
        // Failed to get cache, and scene is not spcified.
        return false;
    }
Exemplo n.º 6
0
Dali::RenderTask RenderTaskList::CreateTask()
{
  RenderTask* taskImpl = RenderTask::New( mIsSystemLevel );

  Dali::RenderTask newTask( taskImpl );
  mTasks.push_back( newTask );

  if ( mSceneObject )
  {
    SceneGraph::RenderTask* sceneObject = taskImpl->CreateSceneObject();
    DALI_ASSERT_DEBUG( NULL != sceneObject );

    // Pass ownership to SceneGraph::RenderTaskList
    AddTaskMessage( mEventToUpdate, *mSceneObject, *sceneObject );
  }

  // Set the default source & camera actors
  taskImpl->SetSourceActor( &mDefaults.GetDefaultRootActor() );
  taskImpl->SetCameraActor( &mDefaults.GetDefaultCameraActor() );

  return newTask;
}
Exemplo n.º 7
0
// clear the resources created for the off screen rendering
void BubbleEmitter::OnRenderFinished(RenderTask& source)
{
  mRenderTaskRunning = false;
  Actor sourceActor = source.GetSourceActor();
  if( sourceActor )
  {
    ImageActor renderable = ImageActor::DownCast( sourceActor );
    if( renderable )
    {
      renderable.RemoveShaderEffect();
    }
  }

  Stage stage = Stage::GetCurrent();
  stage.Remove(sourceActor);
  stage.GetRenderTaskList().RemoveTask(source);
}
Exemplo n.º 8
0
void BubbleEmitter::SetBackground( Image bgImage, const Vector3& hsvDelta )
{
  mBackgroundImage = bgImage;
  mHSVDelta = hsvDelta;

  ImageActor sourceActor = ImageActor::New( bgImage );
  sourceActor.SetSize( mMovementArea );
  sourceActor.SetParentOrigin(ParentOrigin::CENTER);
  Stage::GetCurrent().Add( sourceActor );

  ShaderEffect colorAdjuster = CreateColorAdjuster( hsvDelta, true /*ignore alpha to make bubble color always*/ );
  sourceActor.SetShaderEffect( colorAdjuster );

  RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
  RenderTask task = taskList.CreateTask();
  task.SetRefreshRate( RenderTask::REFRESH_ONCE );
  task.SetSourceActor( sourceActor );
  task.SetExclusive(true);
  task.SetCameraActor(mCameraActor);
  task.GetCameraActor().SetInvertYAxis(true);
  task.SetTargetFrameBuffer( mEffectImage );
  task.FinishedSignal().Connect(this, &BubbleEmitter::OnRenderFinished);
  mRenderTaskRunning = true;
}
Exemplo n.º 9
0
void Magnifier::Initialize()
{
  Actor self = Self();
  mPropertySourcePosition = self.RegisterProperty( Toolkit::Magnifier::SOURCE_POSITION_PROPERTY_NAME, Vector3::ZERO );
  Vector2 stageSize(Stage::GetCurrent().GetSize());

  Layer dummyLayer = Layer::New();
  Stage().GetCurrent().Add(dummyLayer);
  dummyLayer.SetParentOrigin(ParentOrigin::CENTER);

  // NOTE:
  // sourceActor is a dummy delegate actor that takes the source property position,
  // and generates a WORLD_POSITION, which is 1 frame behind the source property.
  // This way the constraints for determining the camera position (source) and those
  // for determining viewport position use the same 1 frame old values.
  // A simple i) CameraPos = f(B), ii) B = f(A) set of constraints wont suffice as
  // although CameraPos will use B, which is A's previous value. The constraint will
  // not realise that B is still dirty as far as constraint (i) is concerned.
  // Perhaps this is a bug in the way the constraint system factors into what is dirty
  // and what is not.
  mSourceActor = Actor::New();
  dummyLayer.Add(mSourceActor);
  mSourceActor.SetParentOrigin(ParentOrigin::CENTER);
  Constraint constraint = Constraint::New<Vector3>( Actor::POSITION,
                                                    Source( self, mPropertySourcePosition ),
                                                    EqualToConstraint() );
  mSourceActor.ApplyConstraint(constraint);

  // create the render task this will render content on top of everything
  // based on camera source position.
  InitializeRenderTask();

  // set up some constraints to:
  // i) reposition (dest) frame actor based on magnifier actor's world position (this is 1 frame delayed)
  // ii) reposition and resize (dest) the render task's viewport based on magnifier actor's world position (1 frame delayed) & size.
  // iii) reposition (source) camera actor based on magnifier source actor's world position (this is 1 frame delayed)

  // Apply constraint to camera's position
  // Position our camera at the same distance from its target as the default camera is.
  // The camera position doesn't affect how we render, just what we render (due to near and far clip planes)
  // NOTE: We can't interrogate the default camera's position as it is not known initially (takes 1 frame
  // for value to update).
  // But we can determine the initial position using the same formula:
  // distance = stage.height * 0.5 / tan(FOV * 0.5)

  RenderTaskList taskList = Stage::GetCurrent().GetRenderTaskList();
  RenderTask renderTask = taskList.GetTask(0u);
  float fov = renderTask.GetCameraActor().GetFieldOfView();
  mDefaultCameraDistance = (stageSize.height * 0.5f) / tanf(fov * 0.5f);

  // Use a 1 frame delayed source position to determine the camera actor's position.
  // This is necessary as the viewport is determined by the Magnifier's Actor's World position (which is computed
  // at the end of the update cycle i.e. after constraints have been applied.)
  //Property::Index propertySourcePositionDelayed = mCameraActor.RegisterProperty("delayed-source-position", Vector3::ZERO);

  constraint = Constraint::New<Vector3>( Actor::POSITION,
                                                    Source( mSourceActor, Actor::WORLD_POSITION ),
                                                    CameraActorPositionConstraint(stageSize, mDefaultCameraDistance) );
  mCameraActor.ApplyConstraint(constraint);

  // Apply constraint to render-task viewport position
  constraint = Constraint::New<Vector2>( RenderTask::VIEWPORT_POSITION,
                                         Source( self, Actor::WORLD_POSITION ),//mPropertySourcePosition ),
                                         Source( self, Actor::SIZE ),
                                         Source( self, Actor::WORLD_SCALE),
                                         RenderTaskViewportPositionConstraint(stageSize) );
  mTask.ApplyConstraint(constraint);

  // Apply constraint to render-task viewport position
  constraint = Constraint::New<Vector2>( RenderTask::VIEWPORT_SIZE,
                                         Source( self, Actor::SIZE ),
                                         Source( self, Actor::WORLD_SCALE),
                                         RenderTaskViewportSizeConstraint() );
  mTask.ApplyConstraint(constraint);
}