Exemplo n.º 1
0
bool Socket::Bind( uint16_t port )
{
  if( ! SocketIsOpen() || mBound )
  {
     DALI_LOG_ERROR("Socket is invalid, or already bound");
     return false;
  }
  struct sockaddr_in serverAddress;

  memset( &serverAddress, 0, sizeof(serverAddress) );
  serverAddress.sin_family = AF_INET;                             // internet
  serverAddress.sin_port = htons( port );  //  host-to-net short (16-bit) translation
  serverAddress.sin_addr.s_addr = htonl( INADDR_ANY ); //  binds the socket to all available interfaces

  int ret = bind( mSocketFileDescriptor,
                  (struct sockaddr* ) &serverAddress,
                  sizeof(serverAddress));

  if( ret == -1 )
  {
    char buf[512];
    DALI_LOG_ERROR( "bind failed for port %d %s \n", port, strerror_r( errno, buf, 512 ) );
    return false;
  }

  mBound = true;

  return true;
}
Dali::ImfManager ImfManager::Get()
{
  Dali::ImfManager manager;

  Dali::SingletonService service( SingletonService::Get() );
  if (! service )
  {
    return manager;
  }

  // Check whether the singleton is already created
  Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::ImfManager ) );
  if( handle )
  {
    // If so, downcast the handle
    manager = Dali::ImfManager( dynamic_cast< ImfManager* >( handle.GetObjectPtr() ) );
  }
  else if ( Adaptor::IsAvailable() )
  {
    // Create instance and register singleton only if the adaptor is available
    manager = Dali::ImfManager( new ImfManager() );
    service.Register( typeid( manager ), manager );
  }
  else
  {
    DALI_LOG_ERROR("Failed to get native window handle");
  }
  return manager;
}
Actor NewActor( const Property::Map& map )
{
  BaseHandle handle;

  // First find type and create Actor
  Property::Value* typeValue = map.Find( "type" );
  if ( typeValue )
  {
    TypeInfo type = TypeRegistry::Get().GetTypeInfo( typeValue->Get< std::string >() );
    if ( type )
    {
      handle = type.CreateInstance();
    }
  }

  if ( !handle )
  {
    DALI_LOG_ERROR( "Actor type not provided\n" );
    return Actor();
  }

  Actor actor( Actor::DownCast( handle ) );

  if ( actor )
  {
    // Now set the properties, or create children
    for ( unsigned int i = 0, mapCount = map.Count(); i < mapCount; ++i )
    {
      const StringValuePair& pair( map.GetPair( i ) );
      const std::string& key( pair.first );
      if ( key == "type" )
      {
        continue;
      }

      const Property::Value& value( pair.second );

      if ( key == "actors" )
      {
        // Create children
        Property::Array actorArray = value.Get< Property::Array >();
        for ( Property::Array::SizeType i = 0; i < actorArray.Size(); ++i)
        {
          actor.Add( NewActor( actorArray[i].Get< Property::Map >() ) );
        }
      }
      else
      {
        Property::Index index( actor.GetPropertyIndex( key ) );

        if ( index != Property::INVALID_INDEX )
        {
          actor.SetProperty( index, value );
        }
      }
    }
  }

  return actor;
}
Exemplo n.º 4
0
void BitmapTexture::UpdateArea( const RectArea& updateArea )
{
  DALI_LOG_INFO(Debug::Filter::gGLResource, Debug::General, "BitmapTexture::UpdateArea()\n");

  if( mBitmap != 0 )
  {
    const unsigned char* pixels = mBitmap->GetBuffer();
    if ( NULL == pixels )
    {
      DALI_LOG_ERROR("bitmap has no data\n");
      GlCleanup(); ///!ToDo: Why do we suicide in the case of bad input?
    }
    else
    {
      if ( mId ) // If the texture is already bound
      {
        if( updateArea.IsEmpty() )
        {
          RectArea area;
          area.x = 0;
          area.y = 0;
          area.width = mImageWidth;
          area.height = mImageHeight;
          AreaUpdated( area, pixels );
        }
        else
        {
          AreaUpdated( updateArea, pixels );
        }
      }
    }
  }
}
AnimationPtr ModelActorFactory::BuildAnimation(
    Model& model,
    Actor& rootActor,
    size_t index,
    AlphaFunction alpha,
    float durationSeconds)
{
    AnimationPtr animation;
    Internal::ModelDataPtr modelData(model.GetModelData());

    if (modelData)
    {
        if (index >= modelData->NumberOfAnimationMaps())
        {
            DALI_LOG_ERROR("Invalid animation index\n");
        }
        else
        {
            const ModelAnimationMap* animationData(modelData->GetAnimationMap(index));
            if( animationData != NULL )
            {
                animation = CreateAnimation(rootActor, animationData, alpha, durationSeconds);
            }
        }
    }
    return animation;
}
  static void PollCabllack(uv_poll_t* handle, int status, int events)
  {
    if( handle->data )
    {
       FileDescriptorMonitor::Impl* impl= static_cast<FileDescriptorMonitor::Impl* >(handle->data);

       if( status < 0)
       {
         DALI_LOG_ERROR("LibUV FD_ERROR occurred on %d", impl->mFileDescriptor);
         CallbackBase::Execute( *impl->mCallback, FileDescriptorMonitor::FD_ERROR );
         return;
       }
       // filter the events that have occured based on what we are monitoring

       int eventType = FileDescriptorMonitor::FD_NO_EVENT;

       if (( impl->mEventsToMonitor & UV_READABLE ) && ( events & UV_READABLE ))
       {
         eventType = FileDescriptorMonitor::FD_READABLE;
       }
       if (( impl->mEventsToMonitor & UV_WRITABLE ) && ( events & UV_WRITABLE ))
       {
         eventType |= FileDescriptorMonitor::FD_WRITABLE;
       }

       // if there is an event, execute the callback
       if( eventType != FileDescriptorMonitor::FD_NO_EVENT )
       {
         CallbackBase::Execute( *impl->mCallback, static_cast< FileDescriptorMonitor::EventType >(eventType) );
       }
    }
  }
Exemplo n.º 7
0
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;
}
Exemplo n.º 8
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
    }
}
Exemplo n.º 9
0
GLbitfield FrameBufferStateCache::GetClearMask( GLbitfield mask, bool forceClear, bool scissorTestEnabled )
{
  if( scissorTestEnabled )
  {
    // don't do anything if scissor test is enabled, in the future we could
    // potentially keep track of frame buffer size vs scissor test size to see if the entire
    // buffer is cleared or not.
    return mask;
  }
  FrameBufferState* state = GetFrameBufferState( mCurrentFrameBufferId );
  if( !state )
  {
    DALI_LOG_ERROR("FrameBuffer not found %d \n", mCurrentFrameBufferId);
    return mask;
  }

  // if we are forcing the clear operation, then just update the internal cached values
  if( forceClear )
  {
    SetClearState( state, mask );
    return mask;
  }

  // use the cached values
  if( mask & GL_COLOR_BUFFER_BIT)
  {
    // check if color buffer is currently clean
    if( state->mState & COLOR_BUFFER_CLEAN )
    {
      // remove clear color buffer flag from bitmask, no need to clear twice
      mask&= ~GL_COLOR_BUFFER_BIT;
    }
  }
  if( mask & GL_DEPTH_BUFFER_BIT)
  {
    // check if depth buffer is currently clean
    if( state->mState & DEPTH_BUFFER_CLEAN )
    {
      // remove clear depth buffer flag from bitmask, no need to clear twice
      mask&= ~GL_DEPTH_BUFFER_BIT;
    }
  }
  if( mask & GL_STENCIL_BUFFER_BIT)
  {
    // check if stencil buffer is currently clean
    if( state->mState & STENCIL_BUFFER_CLEAN )
    {
      // remove clear stencil buffer flag from bitmask, no need to clear twice

      mask&= ~GL_STENCIL_BUFFER_BIT;
    }
  }

  // set the clear state based, what's about to be cleared
  SetClearState( state, mask );

  return mask;
}
Exemplo n.º 10
0
bool Socket::ReuseAddress( bool reUse  )
{
  if( ! SocketIsOpen() | mBound )
  {
    DALI_LOG_ERROR("Socket is invalid or already bound \n");
    return false;
  }

  int reUseInteger = reUse; // convert it to an int

  int ret = setsockopt( mSocketFileDescriptor, SOL_SOCKET, SO_REUSEADDR, &reUseInteger, sizeof(reUseInteger));
  if( ret == -1 )
  {
    char buf[512];
    DALI_LOG_ERROR( "SO_REUSEADDR option failed %s \n", strerror_r( errno, buf, 512 ) );
    return false;
  }
  return true;
}
Exemplo n.º 11
0
bool Socket::Listen( int blacklog)
{
  if( ! mBound || mListening )
  {
    DALI_LOG_ERROR("socket is not bound, or already opened for listening");
    return false;
  }
  int ret =  listen( mSocketFileDescriptor, blacklog);

  if( ret == -1 )
  {
    DALI_LOG_ERROR("Listen failed");
    return false;
  }

  mListening = true;

  return true;
}
Exemplo n.º 12
0
AssimpScene::AssimpScene(AssimpProxy* importer,
                         std::string  fileName,
                         unsigned int postProcessFlags)
  : mModelImporter(importer)
{
  mScene = importer->ImportFile(fileName, postProcessFlags);
  if(!mScene)
  {
    DALI_LOG_ERROR("%s", importer->GetErrorString());
  }
}
bool DisplayConnection::InitializeEgl(EglInterface& egl)
{
  EglImplementation& eglImpl = static_cast<EglImplementation&>(egl);

  if (!eglImpl.InitializeGles(reinterpret_cast<EGLNativeDisplayType>(mDisplay)))
  {
    DALI_LOG_ERROR("Failed to initialize GLES.");
    return false;
  }

  return true;
}
Exemplo n.º 14
0
bool Socket::CloseSocket()
{

  if( ! SocketIsOpen() )
  {
    DALI_LOG_ERROR("Socket already closed or is invalid \n");
    return false;
  }

  int ret = close( mSocketFileDescriptor );
  mSocketFileDescriptor = -1;
  mListening = false;
  mBound = false;

  if( ret == -1 )
  {
    DALI_LOG_ERROR("Socket close failed");
    return false;
  }
  return true;
}
Exemplo n.º 15
0
bool Socket::SetBufferSize( SocketInterface::BufferType type, unsigned int size )
{
  if( ! SocketIsOpen() || mBound )
  {
    DALI_LOG_ERROR("Socket is invalid or already bound \n");
    return false;
  }
  int option = SO_RCVBUF;
  if( type == SocketInterface::SEND_BUFFER )
  {
    option = SO_SNDBUF;
  }

  int ret = setsockopt( mSocketFileDescriptor, SOL_SOCKET,option,&size,sizeof(size));
  if( ret == -1 )
  {
    DALI_LOG_ERROR("SO_RCVBUF / SO_SNDBUF  option failed \n");
    return false;
  }
  return true;
}
bool EnumStringToInteger( const char * const value, const StringEnum* const enumTable, unsigned int tableCount, int& integerEnum )
{
  int ret = 0;

  bool found = false;
  bool done = false;

  if( value && enumTable && tableCount )
  {
    const char* pValue = value;

    while(!done)
    {
      size_t size = 0;

      const StringEnum* table = enumTable;

      for ( unsigned int i = 0; i < tableCount; ++i )
      {
        if( Internal::CompareTokens( pValue, table->string, size ) )
        {
          found = true;
          ret |= table->value;
          break;
        }
        table++;
      }

      done = true;

      if(found)
      {
        // allow comma separated or'd value
        if( *(pValue+size) == ',' )
        {
          pValue += size + 1;
          done = false;
        }
      }

    }

    integerEnum = ret;
  }

  if ( !found )
  {
    DALI_LOG_ERROR( "Unknown enumeration string %s\n", value );
  }
  return found;
}
Exemplo n.º 17
0
void Socket::ExitSelect()
{
  if( mQuitPipeCreated )
  {
    // write a single character to the pipe (can be anything)
    char c = ' ';
    int ret = write( mQuitPipe[1], &c, 1);
    if( ret < 1 )
    {
      DALI_LOG_ERROR("ExitSelect failed!\n");
    }
    return;
  }
}
Exemplo n.º 18
0
BaseSignal::EmitGuard::EmitGuard( bool& flag )
: mFlag( NULL )
{
  if( !flag )
  {
    mFlag = &flag;
    flag = true;
  }
  else
  {
    // mFlag is NULL when Emit() is called during Emit()
    DALI_LOG_ERROR( "Cannot call Emit() from inside Emit()" );
  }
}
Exemplo n.º 19
0
bool Socket::Read( void* buffer, unsigned int bufferSizeInBytes, unsigned int& bytesRead )
{
  bytesRead = 0;

  if( !SocketIsOpen() )
  {
    DALI_LOG_ERROR("Socket is invalid \n");
    return false;
  }

  bytesRead = read( mSocketFileDescriptor, buffer, bufferSizeInBytes );

  return true;
}
Exemplo n.º 20
0
bool Socket::Write( const void* buffer, unsigned int bufferSizeInBytes )
{
  if( !SocketIsOpen() )
  {
    DALI_LOG_ERROR("Socket is invalid \n");
    return false;
  }

  // check we don't try to write more than 10MB ( this can be increased if required)
  if( bufferSizeInBytes > MAX_SOCKET_DATA_WRITE_SIZE )
  {
    DALI_LOG_ERROR("Writing %d bytes exceeds MAX_SOCKET_DATA_WRITE_SIZE of %d bytes \n", bufferSizeInBytes, MAX_SOCKET_DATA_WRITE_SIZE);
    return false;
  }

  int bytesWritten = 0;

  // write isn't guaranteed to write the entire buffer in one go

  while(  bytesWritten != static_cast< int>(bufferSizeInBytes))
  {
    const char* byteBuffer = static_cast<const char *>( buffer );
    byteBuffer+=bytesWritten;

    int ret = write( mSocketFileDescriptor, byteBuffer, bufferSizeInBytes - bytesWritten );
    if( ret < 1)
    {
      DALI_LOG_ERROR("Socket writer error \n");
      return false;
    }
    else
    {
      bytesWritten += ret;
    }
  }
  return true;
}
Exemplo n.º 21
0
SocketInterface* Socket::Accept() const
{
  if( !mListening )
  {
    DALI_LOG_ERROR("socket is not being listened to");
    return NULL;
  }

  struct sockaddr clientAddress;

  socklen_t addressLength(sizeof(sockaddr_in));

  int clientFileDescriptor = accept( mSocketFileDescriptor, &clientAddress, &addressLength);
  if( clientFileDescriptor == -1 )
  {
     DALI_LOG_ERROR("Accept failed");
     return NULL;
  }

  // create a new socket, only TCP supports connections
  Socket* client = new Socket( TCP, clientFileDescriptor );

  return client;
}
Exemplo n.º 22
0
void FrameBufferStateCache::DeleteFrameBuffer( GLuint frameBufferId )
{
  FrameBufferStateVector::Iterator iter = mFrameBufferStates.Begin();
  FrameBufferStateVector::Iterator endIter = mFrameBufferStates.End();

  for( ; iter != endIter ; ++iter )
  {
   if( (*iter).mId == frameBufferId )
   {
     mFrameBufferStates.Erase( iter);
     return;
   }
 }
 DALI_LOG_ERROR("FrameBuffer not found %d \n", frameBufferId);
}
Exemplo n.º 23
0
bool Socket::CreateQuitPipe()
{
  if( !mQuitPipeCreated )
  {
    // create a pipe file descriptor to be able to break from the Select statement
    //
    int ret = pipe( mQuitPipe );
    if( ret != 0)
    {
      DALI_LOG_ERROR("Pipe creation failed");
      return false;
    }
    mQuitPipeCreated = true;
  }
  return true;
}
unsigned int FindEnumIndex( const char* value, const StringEnum* table, unsigned int tableCount )
{
  unsigned int index = 0;
  bool found = false;
  for ( unsigned int i = 0; i < tableCount; ++i, ++index )
  {
    size_t sizeIgnored = 0;
    if( Internal::CompareTokens( value, table->string, sizeIgnored ) )
    {
      found = true;
      break;
    }
    ++table;
  }
  if ( !found )
  {
    DALI_LOG_ERROR( "Unknown enumeration string %s\n", value );
  }
  return index;
}
Exemplo n.º 25
0
void FrameBufferStateCache::FrameBuffersCreated( GLsizei count, const GLuint* const frameBuffers )
{
  for( GLsizei i = 0; i < count; ++i )
  {
    // check the frame buffer doesn't exist already
    GLuint id = frameBuffers[i];

    FrameBufferState* state =  GetFrameBufferState( id );
    if( state )
    {
      DALI_LOG_ERROR("FrameBuffer already exists%d \n", id );
      // reset its state
      state->mState = GetInitialFrameBufferState();
      continue;
    }

    FrameBufferState newFrameBuffer( frameBuffers[i], GetInitialFrameBufferState() );
    mFrameBufferStates.PushBack( newFrameBuffer );
  }
}
Exemplo n.º 26
0
int Material::AddTexture( Image image, const std::string& uniformName, Sampler sampler)
{
  int index( -1 );
  if( image )
  {
    Internal::ImagePtr imagePtr(&GetImplementation( image ));
    Internal::SamplerPtr samplerPtr(0);
    if( sampler )
    {
      samplerPtr = &GetImplementation( sampler );
    }

    index = GetImplementation(*this).AddTexture( imagePtr, uniformName, samplerPtr );
  }
  else
  {
    DALI_LOG_ERROR("Error adding invalid texture %s to material", uniformName.c_str() );
  }
  return index;
}
Exemplo n.º 27
0
SocketInterface::SelectReturn Socket::Select()
{
  bool ok = CreateQuitPipe();
  if( !ok )
  {
    return ERROR;
  }

  fd_set  readFileDescriptors, exceptFileDescriptors;
  FD_ZERO(&readFileDescriptors);
  FD_ZERO(&exceptFileDescriptors);

  FD_SET(mSocketFileDescriptor,&readFileDescriptors );
  FD_SET(mQuitPipe[0],&readFileDescriptors );

  FD_SET(mSocketFileDescriptor,&exceptFileDescriptors);

  unsigned int maxFd = mQuitPipe[0] > mSocketFileDescriptor ? mQuitPipe[0]: mSocketFileDescriptor;

  for( ;; )
  {
    // this will block waiting for file descriptors
    int ret = select( maxFd+1, &readFileDescriptors, NULL, &exceptFileDescriptors, NULL );
    if( ret == -1 )
    {
      DALI_LOG_ERROR("select failed");
      return ERROR;
    }
    else if ( FD_ISSET( mQuitPipe[0] , &readFileDescriptors ))
    {
      // ExitSelect() called
      return QUIT;
    }
    else if ( FD_ISSET( mSocketFileDescriptor, &readFileDescriptors ))
    {
      // socket data received
      return DATA_AVAILABLE;
    }
  }
  return QUIT;
}
bool NativeFrameBufferTexture::CreateGlTexture()
{
  DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);

  if( mNativeImage->GlExtensionCreate() )
  {
    mContext.GenTextures(1, &mId);
    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

    mContext.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    mContext.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    mContext.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    mContext.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

    // platform specific implementation decides on what GL extension to use
    mNativeImage->TargetTexture();

    if (!mFrameBufferName)
    {
      // generate frame and render buffer names
      mContext.GenFramebuffers(1, &mFrameBufferName);
      mContext.GenRenderbuffers(1, &mRenderBufferName);

      // Bind render buffer and create 16 depth buffer
      mContext.BindRenderbuffer(GL_RENDERBUFFER, mRenderBufferName);
      mContext.RenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, mWidth, mHeight);
    }
  }
  else
  {
    DALI_LOG_ERROR( "Error creating native image!" );
  }

  return mId != 0;
}
Exemplo n.º 29
0
BaseSignal::~BaseSignal()
{
  // We can't assert in a destructor
  if( mEmittingFlag )
  {
    DALI_LOG_ERROR( "Invalid destruction of Signal during Emit()\n" );
  }

  // The signal is being destroyed. We have to inform any slots
  // that are connected, that the signal is dead.
  for( std::size_t i=0; i < mSignalConnections.size(); i++ )
  {
    SignalConnection* connection = mSignalConnections[ i ];

    // Note that values are set to NULL in DeleteConnection
    if( connection )
    {
      connection->Disconnect( this );
      delete connection;
    }
  }

  mSignalConnections.clear();
}
Exemplo n.º 30
0
void BitmapTexture::Update( Integration::Bitmap* bitmap )
{
  DALI_LOG_INFO( Debug::Filter::gGLResource, Debug::General, "BitmapTexture::Update(bitmap:%p )\n", bitmap );
  DALI_ASSERT_DEBUG( bitmap != 0 );
  if( !bitmap )
  {
    DALI_LOG_ERROR( "Passed a null bitmap to update this bitmap texture." );
    return;
  }

  // Only Packed-pixel bitmaps are ever associated with BitmapTextures, so we should never be passed any other kind:
  const Integration::Bitmap::PackedPixelsProfile * const bitmapPackedPixels = bitmap->GetPackedPixelsProfile();
  DALI_ASSERT_DEBUG(bitmapPackedPixels);
  if( !bitmapPackedPixels )
  {
    ///! This should never happen.
    DALI_LOG_ERROR("Passed an incompatible bitmap type to update this bitmap texture.");
    return;
  }
  mBitmap = bitmap;

  const unsigned char* pixels = mBitmap->GetBuffer();

  DALI_ASSERT_DEBUG( pixels != NULL );

  if ( NULL == pixels )
  {
    DALI_LOG_ERROR("bitmap has no data\n");
    GlCleanup(); // Note, We suicide here in the case of bad input.
  }
  else
  {
    if( mImageWidth == mBitmap->GetImageWidth() &&
        mImageHeight == mBitmap->GetImageHeight() &&
        mWidth  == bitmapPackedPixels->GetBufferWidth() &&
        mHeight == bitmapPackedPixels->GetBufferHeight() &&
        mPixelFormat == mBitmap->GetPixelFormat() ) // and size hasn't changed
    {
      if ( mId ) // If the texture is already bound
      {
        RectArea area(0, 0, mImageWidth, mImageHeight);  // just update whole texture
        AreaUpdated( area, pixels );
        mBitmap->DiscardBuffer();
      }
    }
    else
    {                                           // Otherwise, reload the pixel data
      mImageWidth  = mBitmap->GetImageWidth();
      mImageHeight = mBitmap->GetImageHeight();
      mWidth       = bitmapPackedPixels->GetBufferWidth();
      mHeight      = bitmapPackedPixels->GetBufferHeight();
      mPixelFormat = mBitmap->GetPixelFormat();

      if ( mId ) // If the texture is already bound
      {
        AssignBitmap( false, pixels );
        mBitmap->DiscardBuffer();
      }
    }
  }
}