Example #1
0
// Given a parameter s (NOT x), return the Y value. Checks that the
// segment index is valid. For bezier splines, the last segment is
// only used to specify the end point, so is not valid.
const float  Spline::GetY(unsigned int segmentIndex, float s) const
{
  DALI_ASSERT_ALWAYS( segmentIndex+1 < mKnots.size() && segmentIndex < mKnots.size() && "segmentIndex out of bounds");
  DALI_ASSERT_ALWAYS( mOutTangents.size() == mKnots.size() && "Spline not fully initialized" );
  DALI_ASSERT_ALWAYS( mInTangents.size()  == mKnots.size() && "Spline not fully initialized" );

  float    yValue=0.0f;

  if(s < 0.0f || s > 1.0f)
  {
    yValue = 0.0f;
  }
  else if(s < Math::MACHINE_EPSILON_1)
  {
    yValue = mKnots[segmentIndex].y;
  }
  else if( (1.0 - s) < Math::MACHINE_EPSILON_1)
  {
    yValue = mKnots[segmentIndex+1].y;
  }
  else
  {
    Vector4  sVect(s*s*s, s*s, s, 1);
    Vector4  cVect;

    cVect.x  = mKnots[segmentIndex].y;
    cVect.y  = mOutTangents[segmentIndex].y;
    cVect.z  = mInTangents[segmentIndex+1].y;
    cVect.w  = mKnots[segmentIndex+1].y;
    yValue   = sVect.Dot4(mBasis * cVect);
  }
  return yValue;
}
void ScrollViewEffect::Detach(Toolkit::ScrollView& scrollView)
{
  DALI_ASSERT_ALWAYS( (mScrollViewImpl) && "Already detached from ScrollView" );
  DALI_ASSERT_ALWAYS( (&GetImpl(scrollView) == mScrollViewImpl) && "Effect attached to a different ScrollView");

  OnDetach(scrollView);

  mScrollViewImpl = NULL;
}
Example #3
0
void AnimationPlaylist::AnimationDestroyed( Animation& animation )
{
  std::set< Animation* >::iterator iter = find( mAnimations.begin(), mAnimations.end(), &animation );
  DALI_ASSERT_ALWAYS( iter != mAnimations.end() && "Animation not found" );

  mAnimations.erase( iter );
}
bool FrameBufferTexture::Prepare()
{
  // bind texture
  Bind(GL_TEXTURE_2D, GL_TEXTURE0);

  if( 0 != mId )
  {
    // bind frame buffer
    mContext.BindFramebuffer(GL_FRAMEBUFFER, mFrameBufferName);
    // bind render buffer
    mContext.BindRenderbuffer(GL_RENDERBUFFER, mRenderBufferName);
    // attach texture to the color attachment point
    mContext.FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mId, 0);
    // attach render buffer to the depth buffer attachment point
    mContext.FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mRenderBufferName);

    int status = mContext.CheckFramebufferStatus(GL_FRAMEBUFFER);
    if ( GL_FRAMEBUFFER_COMPLETE != status )
    {
      DALI_LOG_ERROR( "status (0x%x), glError (0x%x)\n", status, mContext.GetError() );
      DALI_ASSERT_ALWAYS( false && "Frame buffer is not complete!" );
    }

    return true;
  }

  // Texture could not be bound
  return false;
}
Example #5
0
Adaptor::Adaptor(Dali::Adaptor& adaptor, RenderSurface* surface, const DeviceLayout& baseLayout)
: mAdaptor(adaptor),
  mState(READY),
  mCore(NULL),
  mUpdateRenderController(NULL),
  mVSyncMonitor(NULL),
  mGLES( NULL ),
  mEglFactory( NULL ),
  mSurface( surface ),
  mPlatformAbstraction( NULL ),
  mEventHandler( NULL ),
  mCallbackManager( NULL ),
  mNotificationOnIdleInstalled( false ),
  mNotificationTrigger(NULL),
  mGestureManager(NULL),
  mHDpi( 0 ),
  mVDpi( 0 ),
  mDaliFeedbackPlugin(NULL),
  mFeedbackController(NULL),
  mObservers(),
  mDragAndDropDetector(),
  mDeferredRotationObserver(NULL),
  mBaseLayout(baseLayout),
  mEnvironmentOptions(),
  mPerformanceInterface(NULL)
{
  DALI_ASSERT_ALWAYS( gThreadLocalAdaptor.get() == NULL && "Cannot create more than one Adaptor per thread" );
  gThreadLocalAdaptor.reset(this);
}
Example #6
0
void AnimationPlaylist::AnimationDestroyed( Animation& animation )
{
  Dali::Vector< Animation* >::Iterator iter = std::find( mAnimations.Begin(), mAnimations.End(), &animation );
  DALI_ASSERT_ALWAYS( iter != mAnimations.End() && "Animation not found" );

  mAnimations.Remove( iter );
}
Example #7
0
void RenderThread::InitializeEgl()
{
  mEGL = mEglFactory->Create();

  DALI_ASSERT_ALWAYS( mSurface && "NULL surface" );

  // initialize egl & OpenGL
  mDisplayConnection->InitializeEgl( *mEGL );
  mSurface->InitializeEgl( *mEGL );

  // create the OpenGL context
  mEGL->CreateContext();

  // create the OpenGL surface
  mSurface->CreateEglSurface(*mEGL);

  // Make it current
  mEGL->MakeContextCurrent();

  // set the initial sync mode

  // tell core it has a context
  mCore.ContextCreated();

}
const SceneGraph::PropertyBase* PanGestureDetector::GetSceneObjectAnimatableProperty( Property::Index index ) const
{
  DALI_ASSERT_ALWAYS( IsPropertyAnimatable(index) && "Property is not animatable" );

  // None of our properties are animatable
  return NULL;
}
Example #9
0
Property::Value& Property::Value::GetValue(const std::string& key) const
{
  DALI_ASSERT_DEBUG(Property::MAP == GetType() && "Property type invalid");

  Property::Map *container = AnyCast<Property::Map>(&(mImpl->mValue));

  DALI_ASSERT_DEBUG(container);

  if(container)
  {
    for(Property::Map::iterator iter = container->begin(); iter != container->end(); ++iter)
    {
      if(iter->first == key)
      {
        return iter->second;
      }
    }
  }

  DALI_LOG_WARNING("Cannot find property map key %s", key.c_str());
  DALI_ASSERT_ALWAYS(!"Cannot find property map key");

  // should never return this
  static Property::Value null;
  return null;
}
Example #10
0
int main( int argc, char* argv[] )
{
  // pull out the JSON file and JavaScript file from the command line arguments
  std::string javaScriptFileName;
  std::string jSONFileName;

  for( int i = 1 ; i < argc ; ++i )
  {
    std::string arg( argv[i] );

    size_t idx = std::string::npos;

    idx = arg.find( ".json" );
    if( idx != std::string::npos )
    {
      jSONFileName = arg;
    }
    else
    {
      idx = arg.find( ".js" );
      if( idx != std::string::npos )
      {
        javaScriptFileName = arg;
      }
    }
  }

  if( !jSONFileName.empty() )
  {
    bool exists = CheckIfFileExists( jSONFileName );
    if( !exists )
    {
      DALI_ASSERT_ALWAYS( 0 && "JSON file not found ")
    }
  }
const SceneGraph::PropertyBase* AnimatableMesh::GetSceneObjectAnimatableProperty( Property::Index index ) const
{
  DALI_ASSERT_ALWAYS( IsPropertyAnimatable(index) && "Property is not animatable" );

  const SceneGraph::PropertyBase* property( NULL );

  // This method should only return a property which is part of the scene-graph
  if( mSceneObject != NULL )
  {
    int vertexProperty = index % VERTEX_PROPERTY_COUNT;
    int vertexIndex    = index / VERTEX_PROPERTY_COUNT;

    switch ( vertexProperty )
    {
      case Dali::AnimatableVertex::POSITION:
        property = &mSceneObject->mVertices[vertexIndex].position;
        break;
      case Dali::AnimatableVertex::COLOR:
        property = &mSceneObject->mVertices[vertexIndex].color;
        break;
      case Dali::AnimatableVertex::TEXTURE_COORDS:
        property = &mSceneObject->mVertices[vertexIndex].textureCoords;
        break;
    }
  }

  return property;
}
Example #12
0
bool TypeRegistry::Register( const std::string& uniqueTypeName, const std::type_info& baseTypeInfo,
                             Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit )
{
  bool ret = false;

  std::string baseTypeName    = DemangleClassName(baseTypeInfo.name());

  RegistryMap::iterator iter = mRegistryLut.find(uniqueTypeName);

  if( iter == mRegistryLut.end() )
  {
    mRegistryLut[uniqueTypeName] = Dali::TypeInfo(new Internal::TypeInfo(uniqueTypeName, baseTypeName, createInstance));
    ret = true;
    DALI_LOG_INFO( gLogFilter, Debug::Concise, "Type Registration %s(%s)\n", uniqueTypeName.c_str(), baseTypeName.c_str());
  }
  else
  {
    DALI_LOG_WARNING("Duplicate name for TypeRegistry for '%s'\n", + uniqueTypeName.c_str());
    DALI_ASSERT_ALWAYS(!"Duplicate type name for Type Registation");
  }

  if( callCreateOnInit )
  {
    mInitFunctions.push_back(createInstance);
  }

  return ret;
}
Example #13
0
void ShadowView::Activate()
{
  DALI_ASSERT_ALWAYS( Self().OnStage() && "ShadowView should be on stage before calling Activate()\n" );

  // make sure resources are allocated and start the render tasks processing
  CreateRenderTasks();
}
void AnimatableMesh::SetDefaultProperty( Property::Index index, const Property::Value& property )
{
  DALI_ASSERT_ALWAYS( ( index >= 0 ) && ( index < mPropertyCount ) );

  int vertexProperty = index % VERTEX_PROPERTY_COUNT;
  int vertexIndex    = index / VERTEX_PROPERTY_COUNT;
  switch ( vertexProperty )
  {
    case Dali::AnimatableVertex::POSITION:
    {
      SetPosition( vertexIndex, property.Get<Vector3>() );
      break;
    }
    case Dali::AnimatableVertex::COLOR:
    {
      SetColor( vertexIndex, property.Get<Vector4>() );
      break;
    }
    case Dali::AnimatableVertex::TEXTURE_COORDS:
    {
      SetTextureCoords( vertexIndex, property.Get<Vector2>() );
      break;
    }
  }
}
Example #15
0
// Given a parameter s, return the point on the given spline segment.
// Checks that the segment index is valid (e.g. for 10 points, there
// are only 9 segments)
const Vector3 Spline::GetPoint(unsigned int segmentIndex, float s) const
{
  DALI_ASSERT_ALWAYS( segmentIndex+1 < mKnots.size() && segmentIndex < mKnots.size() && "segmentIndex out of bounds" );
  DALI_ASSERT_ALWAYS( mOutTangents.size() == mKnots.size() && "Spline not fully initialized" );
  DALI_ASSERT_ALWAYS( mInTangents.size()  == mKnots.size() && "Spline not fully initialized" );

  Vector3  bPoint;

  if(s < 0.0f || s > 1.0f)
  {
    bPoint.x = 0.0f;
    bPoint.y = 0.0f;
    bPoint.z = 0.0f;
  }
  else if(s < Math::MACHINE_EPSILON_1)
  {
    bPoint = mKnots[segmentIndex];
  }
  else if( (1.0 - s) < Math::MACHINE_EPSILON_1)
  {
    bPoint = mKnots[segmentIndex+1];
  }
  else
  {
    Vector4  sVect(s*s*s, s*s, s, 1);
    Vector4  cVect;

    cVect.x  = mKnots[segmentIndex].x;
    cVect.y  = mOutTangents[segmentIndex].x;
    cVect.z  = mInTangents[segmentIndex+1].x;
    cVect.w  = mKnots[segmentIndex+1].x;
    bPoint.x = sVect.Dot4(mBasis * cVect);

    cVect.x  = mKnots[segmentIndex].y;
    cVect.y  = mOutTangents[segmentIndex].y;
    cVect.z  = mInTangents[segmentIndex+1].y;
    cVect.w  = mKnots[segmentIndex+1].y;
    bPoint.y = sVect.Dot4(mBasis * cVect);

    cVect.x  = mKnots[segmentIndex].z;
    cVect.y  = mOutTangents[segmentIndex].z;
    cVect.z  = mInTangents[segmentIndex+1].z;
    cVect.w  = mKnots[segmentIndex+1].z;
    bPoint.z = sVect.Dot4(mBasis * cVect);
  }
  return bPoint;
}
Example #16
0
void RenderThread::Start()
{
  DALI_LOG_INFO( gRenderLogFilter, Debug::Verbose, "RenderThread::Start()\n");

  // initialise GL and kick off render thread
  DALI_ASSERT_ALWAYS( !mEGL && "Egl already initialized" );

  // create the render thread, initially we are rendering
  mThread = new pthread_t();
  int error = pthread_create( mThread, NULL, InternalThreadEntryFunc, this );
  DALI_ASSERT_ALWAYS( !error && "Return code from pthread_create() in RenderThread" );

  if( mSurface )
  {
    mSurface->StartRender();
  }
}
Example #17
0
void CheckGlError( Integration::GlAbstraction& glAbstraction, const char* operation )
{
    for( GLint error = glAbstraction.GetError(); error; error = glAbstraction.GetError() )
    {
        DALI_LOG_ERROR( "glError (0x%x) %s - after %s\n",  error, ErrorToString(error), operation );
        DALI_ASSERT_ALWAYS( !error && "GL ERROR"); // if errors are being checked we should assert
    }
}
std::string GaussianBlurView::GetSampleWeightsPropertyName( unsigned int index ) const
{
    DALI_ASSERT_ALWAYS( index < mNumSamples );

    std::ostringstream oss;
    oss << "uSampleWeights[" << index << "]";
    return oss.str();
}
Example #19
0
void ShadowView::Deactivate()
{
  DALI_ASSERT_ALWAYS( Self().OnStage() && "ShadowView should be on stage before calling Deactivate()\n" )

  // stop render tasks processing
  // Note: render target resources are automatically freed since we set the Image::Unused flag
  RemoveRenderTasks();
}
Example #20
0
void Application::CreateAdaptor()
{
  DALI_ASSERT_ALWAYS( mWindow && "Window required to create adaptor" );

  mAdaptor = Dali::Internal::Adaptor::Adaptor::New( mWindow, mContextLossConfiguration, &mEnvironmentOptions );

  mAdaptor->ResizedSignal().Connect( mSlotDelegate, &Application::OnResize );
}
Example #21
0
void ScrollViewEffect::Attach(Toolkit::ScrollView& scrollView)
{
  DALI_ASSERT_ALWAYS( (!mScrollViewImpl) && "Already attached to a ScrollView" );

  mScrollViewImpl = &GetImpl(scrollView);

  OnAttach(scrollView);
}
const Internal::Adaptor::SingletonService& GetImplementation(const Dali::SingletonService& player)
{
  DALI_ASSERT_ALWAYS( player && "SingletonService handle is empty" );

  const BaseObject& handle = player.GetBaseObject();

  return static_cast<const Internal::Adaptor::SingletonService&>(handle);
}
Example #23
0
void Thread::Start()
{
  DALI_ASSERT_DEBUG( !mImpl->isCreated );

  int error = pthread_create( &(mImpl->thread), NULL, InternalThreadEntryFunc, this );
  DALI_ASSERT_ALWAYS( !error && "Failed to create a new thread" );
  mImpl->isCreated = true;
}
  inline static const Internal::Adaptor::ClipboardEventNotifier& GetImplementation(const Dali::ClipboardEventNotifier& detector)
  {
    DALI_ASSERT_ALWAYS( detector && "ClipboardEventNotifier handle is empty" );

    const BaseObject& handle = detector.GetBaseObject();

    return static_cast<const Internal::Adaptor::ClipboardEventNotifier&>(handle);
  }
AnimatableMeshPtr AnimatableMesh::New(
  unsigned int numVertices,
  const Dali::AnimatableMesh::Faces& faceIndices,
  Dali::Material material,
  bool useVertexColor )
{
  DALI_ASSERT_ALWAYS( numVertices > 0 && "Mesh has no vertices" );
  DALI_ASSERT_ALWAYS( ( numVertices * 3 ) < DEFAULT_PROPERTY_MAX_COUNT && "Mesh exceeds maximum supported vertices" );
  DALI_ASSERT_ALWAYS( faceIndices.size() > 0 && "Mesh has no faces" );
  for( Dali::AnimatableMesh::FacesConstIter faceIter=faceIndices.begin();
       faceIter != faceIndices.end();
       ++faceIter )
  {
    unsigned int faceIndex = *faceIter;
    DALI_ASSERT_ALWAYS( faceIndex < numVertices && "Face index out of range" );
  }

  ThreadLocalStorage& tls = ThreadLocalStorage::Get();
  SceneGraph::UpdateManager& updateManager = tls.GetUpdateManager();
  ResourceManager& resourceManager = tls.GetResourceManager();

  Dali::MeshData meshData;

  // We need a valid mesh data object to create the scene graph mesh
  Dali::MeshData::VertexContainer vertices( numVertices );
  BoneContainer bones;
  meshData.SetData(vertices, faceIndices, bones, material);
  bool useColor = false;
  if(useVertexColor)
  {
    useColor=true;
  }
  meshData.SetHasColor(useColor);
  meshData.SetHasNormals(false);
  meshData.SetHasTextureCoords(true);

  MeshIPtr mesh( Mesh::New( meshData, false /* not discardable, data is updated in the update thread */, true /* Scaling is required */ ) );

  // Create the scene object
  SceneGraph::AnimatableMesh* sceneObject = new SceneGraph::AnimatableMesh( resourceManager, mesh->GetResourceId(), meshData.GetVertices() );

  // Create the event object
  AnimatableMeshPtr animatableMeshPtr( new AnimatableMesh( updateManager, sceneObject, mesh, meshData.GetVertexCount() ) );

  return animatableMeshPtr;
}
TETButton::PressedSignalV2& TETButton::PressedSignal()
{
    TETButton button( *this );
    DALI_ASSERT_ALWAYS( button );

    Dali::RefObject& handle = button.GetImplementation();

    return static_cast<Toolkit::Internal::TETButton&>( handle ).PressedSignal();
}
void GaussianBlurView::SetUserImageAndOutputRenderTarget(Image inputImage, FrameBufferImage outputRenderTarget)
{
    // can only do this if the GaussianBlurView object was created with this parameter set
    DALI_ASSERT_ALWAYS(mBlurUserImage);

    mUserInputImage = inputImage;
    mImageActorHorizBlur.SetImage( mUserInputImage );

    mUserOutputRenderTarget = outputRenderTarget;
}
Example #28
0
RenderThread::~RenderThread()
{
  if (mDisplayConnection)
  {
    delete mDisplayConnection;
    mDisplayConnection = NULL;
  }

  DALI_ASSERT_ALWAYS( mThread == NULL && "RenderThread is still alive");
  mEglFactory->Destroy();
}
Example #29
0
Dali::Adaptor* Adaptor::New( RenderSurface *surface, const DeviceLayout& baseLayout )
{
  DALI_ASSERT_ALWAYS( surface->GetType() != Dali::RenderSurface::NO_SURFACE && "No surface for adaptor" );

  Dali::Adaptor* adaptor = new Dali::Adaptor;
  Adaptor* impl = new Adaptor( *adaptor, surface, baseLayout );
  adaptor->mImpl = impl;

  impl->Initialize();

  return adaptor;
}
Example #30
0
void BitmapTexture::UploadBitmapArray( const BitmapUploadArray& bitmapArray )
{
  if( mId == 0 )
  {
    CreateGlTexture();
  }

  mContext.ActiveTexture(GL_TEXTURE7);  // bind in unused unit so rebind works the first time
  mContext.Bind2dTexture(mId);
  mContext.PixelStorei(GL_UNPACK_ALIGNMENT, 1); // We always use tightly packed data

  GLenum pixelFormat   = GL_RGBA;
  GLenum pixelDataType = GL_UNSIGNED_BYTE;

  Integration::ConvertToGlFormat(mPixelFormat, pixelDataType, pixelFormat);

  // go through each bitmap uploading it

  for( BitmapUploadArray::const_iterator iter =  bitmapArray.begin(), endIter = bitmapArray.end(); iter != endIter ; ++iter)
  {
    const BitmapUpload& bitmapItem((*iter));

    DALI_ASSERT_ALWAYS(bitmapItem.mPixelData);

    const unsigned char* pixels = bitmapItem.mPixelData;

    DALI_ASSERT_DEBUG( (pixels!=NULL) && "bitmap has no data \n");

    unsigned int bitmapWidth(bitmapItem.mWidth);
    unsigned int bitmapHeight(bitmapItem.mHeight);

    DALI_LOG_INFO(Debug::Filter::gImage, Debug::General, "upload bitmap to texture :%d y:%d w:%d h:%d\n",
                            bitmapItem.mXpos,
                            bitmapItem.mYpos,
                            bitmapWidth,
                            bitmapHeight);

     mContext.TexSubImage2D(GL_TEXTURE_2D,
                            0,                   /* mip map level */
                            bitmapItem.mXpos,    /* X pos */
                            bitmapItem.mYpos,    /* Y pos */
                            bitmapWidth,         /* width */
                            bitmapHeight,        /* height */
                            pixelFormat,         /* our bitmap format (should match internal format) */
                            pixelDataType,       /* pixel data type */
                            pixels);             /* texture data */

     if( BitmapUpload::DISCARD_PIXEL_DATA == bitmapItem.mDiscard)
     {
       delete [] bitmapItem.mPixelData;
     }
  }
}