Removed some redundant texture features 63/33763/1
authorPaul Wisbey <p.wisbey@samsung.com>
Wed, 14 Jan 2015 13:16:59 +0000 (13:16 +0000)
committerPaul Wisbey <p.wisbey@samsung.com>
Wed, 14 Jan 2015 13:16:59 +0000 (13:16 +0000)
Change-Id: I50b2cd31939feca5511dac2ab369047f35e920de

dali/internal/common/bitmap-upload.h [deleted file]
dali/internal/event/resources/resource-client.cpp
dali/internal/event/resources/resource-client.h
dali/internal/render/common/texture-cache-dispatcher.h
dali/internal/render/gl-resources/bitmap-texture.cpp
dali/internal/render/gl-resources/bitmap-texture.h
dali/internal/render/gl-resources/compressed-bitmap-texture.h
dali/internal/render/gl-resources/texture-cache.cpp
dali/internal/render/gl-resources/texture-cache.h
dali/internal/update/resources/resource-manager.cpp
dali/internal/update/resources/resource-manager.h

diff --git a/dali/internal/common/bitmap-upload.h b/dali/internal/common/bitmap-upload.h
deleted file mode 100644 (file)
index 700785f..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-#ifndef __DALI_INTERNAL_BITMAP_UPLOAD_H__
-#define __DALI_INTERNAL_BITMAP_UPLOAD_H__
-
-/*
- * Copyright (c) 2014 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/vector-wrapper.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-/**
- * Holds a bitmap and a x,y pixel position of where the bitmap
- * should be uploaded to in a texture.
- *
- */
-struct BitmapUpload
-{
-
-  enum DiscardMode
-  {
-    DISCARD_PIXEL_DATA,       ///< Delete the pixel data after upload
-    DONT_DISCARD_PIXEL_DATA  ///< Don't delete the pixel data after upload
-  };
-
-  typedef unsigned char      PixelData;  ///< pixel data type
-
-  /**
-   * Constructor
-   * @param data pixel data
-   * @param xPos x position of where to place the bitmap in a texture
-   * @param yPos y position of where to place the bitmap in a texture
-   * @param width bitmap width in pixels
-   * @param height bitmap height in pixels
-   * @param discardMode whether to delete the pixel data after the upload or not
-   */
-  BitmapUpload(PixelData*   data,
-               unsigned int xPos,
-               unsigned int yPos,
-               unsigned int width,
-               unsigned int height,
-               DiscardMode discardMode = DISCARD_PIXEL_DATA)
-  :mPixelData(data),
-   mXpos(xPos),
-   mYpos(yPos),
-   mWidth(width),
-   mHeight(height),
-   mDiscard(discardMode)
-  {
-  }
-
-
-  PixelData*   mPixelData;         ///< bitmap data to upload
-  unsigned int mXpos;              ///< x position to place the bitmap in the texture
-  unsigned int mYpos;              ///< y position to place the bitmap in the texture
-  unsigned int mWidth;             ///< width of the bitmap to upload
-  unsigned int mHeight;            ///< height of the bitmap to upload
-  DiscardMode  mDiscard;           ///< whether the pixel data should be discarded after the upload
-};
-
-typedef std::vector<BitmapUpload> BitmapUploadArray; ///< typedef for a array of uploads
-
-
-/**
- * Structure is used for clearing areas of the bitmap
- */
-typedef std::vector<Vector2> BitmapClearArray;
-
-}  //namespace Internal
-
-} //namespace Dali
-
-#endif
index bf68566..c55010e 100644 (file)
@@ -403,12 +403,6 @@ ResourceTicketPtr ResourceClient::AllocateTexture( unsigned int width,
   return newTicket;
 }
 
-void ResourceClient::UpdateTexture(  ResourceId id,
-                                     BitmapUploadArray uploadArray )
-{
-  RequestUpdateTextureMessage(  mUpdateManager.GetEventToUpdate(), mResourceManager, id, uploadArray );
-}
-
 ResourceTicketPtr ResourceClient::AllocateMesh( OwnerPointer<MeshData>& meshData )
 {
   ResourceTicketPtr newTicket;
index 4f98e99..2adba24 100644 (file)
@@ -27,7 +27,6 @@
 #include <dali/internal/event/resources/resource-client-declarations.h>
 #include <dali/internal/event/resources/image-ticket.h>
 #include <dali/internal/event/resources/resource-ticket-lifetime-observer.h>
-#include <dali/internal/common/bitmap-upload.h>
 #include <dali/internal/common/message.h>
 #include <dali/internal/update/modeling/internal-mesh-data.h>
 
@@ -224,14 +223,6 @@ public:
                                      Pixel::Format pixelformat );
 
   /**
-   * Update a texture with an array of bitmaps.
-   * @param[in] id texture resource id
-   * @param[in] uploadArray the upload array
-   */
-  void UpdateTexture( ResourceId id,
-                      BitmapUploadArray uploadArray );
-
-  /**
    * Requests allocation of a mesh resource
    * @param[in] meshData representing the mesh; ownership is taken.
    */
index 26d337a..12351f3 100644 (file)
@@ -27,7 +27,6 @@
 #include <dali/public-api/images/pixel.h>
 #include <dali/internal/common/message.h>
 #include <dali/internal/update/common/scene-graph-buffers.h>
-#include <dali/internal/common/bitmap-upload.h>
 #include <dali/integration-api/resource-declarations.h>
 #include <dali/integration-api/bitmap.h>
 
@@ -135,23 +134,6 @@ public:
    */
   virtual void DispatchUpdateTextureArea( ResourceId id, const RectArea& area ) = 0;
 
- /**
-   * Dispatch a message to insert an array of bitmaps into the texture.
-   * Used for uploading multiple images into an atlas.
-   * @param[in] id Resource id of the texture
-   * @param[in] uploadArray array of BitmapUpload structures
-   */
-  virtual void DispatchUploadBitmapArrayToTexture( ResourceId id, const BitmapUploadArray& uploadArray ) = 0;
-
-  /**
-   * Dispatch a message to clear multiple areas of a texture to a specific color
-   * @param[in] id Resource id of the texture to clear
-   * @param[in] area Rectangles to clear
-   * @param[in] blockSize Size of block to clear
-   * @param[in] color Clear color (as a pixel value)
-   */
-  virtual void DispatchClearAreas( ResourceId id, const BitmapClearArray& area, std::size_t blockSize, uint32_t color ) = 0;
-
   /**
    * Dispatch a message to discard a texture
    * May be called from Update thread
index e6967ce..02759e1 100644 (file)
@@ -76,62 +76,6 @@ BitmapTexture::~BitmapTexture()
   // on the render thread. (And avoiding a potentially problematic virtual call in the destructor)
 }
 
-void BitmapTexture::UploadBitmapArray( const BitmapUploadArray& bitmapArray )
-{
-  DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
-
-  if( mId == 0 )
-  {
-    CreateGlTexture();
-  }
-
-  mContext.ActiveTexture( TEXTURE_UNIT_UPLOAD );
-  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;
-    }
-  }
-}
-
 bool BitmapTexture::HasAlphaChannel() const
 {
   return Pixel::HasAlpha(mPixelFormat);
@@ -318,53 +262,6 @@ void BitmapTexture::UpdateArea( const RectArea& updateArea )
   }
 }
 
-void BitmapTexture::ClearAreas( const BitmapClearArray& areaArray, std::size_t blockSize, uint32_t color )
-{
-  if(mId > 0)
-  {
-    DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
-    DALI_LOG_INFO(Debug::Filter::gGLResource, Debug::Verbose, "BitmapTexture::AreaUpdated()\n");
-
-    GLenum pixelFormat   = GL_RGBA;
-    GLenum pixelDataType = GL_UNSIGNED_BYTE;
-    Integration::ConvertToGlFormat(mPixelFormat, pixelDataType, pixelFormat);
-
-    mContext.ActiveTexture( TEXTURE_UNIT_UPLOAD );
-    mContext.Bind2dTexture(mId);
-
-    size_t numPixels = blockSize*blockSize;
-    size_t bytesPerPixel = Pixel::GetBytesPerPixel(mPixelFormat);
-    char* clearPixels = (char*)malloc(numPixels * bytesPerPixel);
-
-    for(size_t i=0; i<numPixels; i++)
-    {
-      memcpy(&clearPixels[i*bytesPerPixel], &color, bytesPerPixel);
-    }
-
-    for( BitmapClearArray::const_iterator iter =  areaArray.begin(), endIter = areaArray.end(); iter != endIter ; ++iter)
-    {
-      const Vector2& clearPos((*iter));
-
-      mContext.PixelStorei( GL_UNPACK_ALIGNMENT, 1 ); // We always use tightly packed data
-      DALI_LOG_INFO( Debug::Filter::gImage, Debug::General, "Update x:%0.2f y:%0.2f w:%d h:%d\n",
-                     clearPos.x, clearPos.y, blockSize, blockSize );
-
-      mContext.TexSubImage2D(GL_TEXTURE_2D,
-                             0,
-                             clearPos.x,
-                             clearPos.y,
-                             blockSize,
-                             blockSize,
-                             pixelFormat,         /* our bitmap format (should match internal format) */
-                             pixelDataType,       /* pixel data type */
-                             clearPixels);        /* texture data */
-
-      INCREASE_BY( PerformanceMonitor::TEXTURE_DATA_UPLOADED, numPixels * bytesPerPixel );
-    }
-    free(clearPixels);
-  }
-}
-
 bool BitmapTexture::UpdateOnCreate()
 {
   return true;
index 46073c8..3fc0a8e 100644 (file)
@@ -24,7 +24,6 @@
 // INTERNAL INCLUDES
 #include <dali/internal/common/message.h>
 #include <dali/internal/render/gl-resources/texture.h>
-#include <dali/internal/common/bitmap-upload.h>
 #include <dali/integration-api/bitmap.h>
 #include <dali/integration-api/debug.h>
 #include <dali/internal/render/gl-resources/texture-cache.h>
@@ -74,22 +73,6 @@ public:
    */
   virtual ~BitmapTexture();
 
-public: // Message interface
-
-  /**
-   * Upload an array of bitmaps
-   * @param bitmapArray array of bitmap items
-   */
-  void UploadBitmapArray( const BitmapUploadArray& bitmapArray);
-
-  /**
-   * Clear an array of areas from bitmap to the given color
-   * @param[in] areaArray Array of rects to clear
-   * @param[in] blockSize Size of block to clear
-   * @param[in] color Clear color
-   */
-  void ClearAreas( const BitmapClearArray& areaArray, std::size_t blockSize, uint32_t color );
-
 public:
   /**
    * @copydoc Texture::Init
@@ -174,14 +157,6 @@ private:
   DALI_LOG_OBJECT_STRING_DECLARATION;
 };
 
-//
-// Upload bitmap array message
-//
-inline MessageBase* UploadBitmapArrayMessage( BitmapTexture& texture, const BitmapUploadArray& bitmapArray )
-{
-  return new MessageValue1< BitmapTexture, BitmapUploadArray >( &texture, &BitmapTexture::UploadBitmapArray, bitmapArray );
-}
-
 }  //namespace Internal
 
 } //namespace Dali
index 583c1ff..e5a0ba7 100644 (file)
@@ -27,7 +27,6 @@
 #include <dali/internal/common/message.h>
 #include <dali/internal/render/gl-resources/texture.h>
 #include <dali/internal/render/gl-resources/texture-cache.h>
-#include <dali/internal/common/bitmap-upload.h>
 #include <dali/integration-api/bitmap.h>
 #include <dali/internal/event/images/bitmap-compressed.h>
 #include <dali/integration-api/debug.h>
index db4f027..47836e6 100644 (file)
@@ -155,43 +155,6 @@ void TextureCache::UpdateTextureArea( ResourceId id, const Dali::RectArea& area
   }
 }
 
-void TextureCache::AddBitmapUploadArray( ResourceId id, const BitmapUploadArray& uploadArray )
-{
-  DALI_LOG_INFO(Debug::Filter::gGLResource, Debug::General, "TextureCache::AddBitmapUploadArray(id=%i )\n", id);
-
-  TextureIter textureIter = mTextures.find(id);
-
-  DALI_ASSERT_DEBUG( textureIter != mTextures.end() );
-  if( textureIter != mTextures.end() )
-  {
-    TexturePointer texturePtr = textureIter->second;
-    if( texturePtr )
-    {
-      BitmapTexture* texture = static_cast< BitmapTexture* >( texturePtr.Get() );
-      texture->UploadBitmapArray( uploadArray );
-    }
-  }
-}
-
-void TextureCache::ClearAreas( ResourceId id,
-                               const BitmapClearArray& areaArray,
-                               std::size_t blockSize,
-                               uint32_t color )
-{
-  DALI_LOG_INFO(Debug::Filter::gGLResource, Debug::General, "TextureCache::ClearAreas(id: %d)\n", id);
-  TextureIter textureIter = mTextures.find(id);
-  DALI_ASSERT_DEBUG( textureIter != mTextures.end() );
-  if( textureIter != mTextures.end() )
-  {
-    TexturePointer texturePtr = textureIter->second;
-    if( texturePtr )
-    {
-      BitmapTexture* texture = static_cast< BitmapTexture* >( texturePtr.Get() );
-      texture->ClearAreas( areaArray, blockSize, color );
-    }
-  }
-}
-
 void TextureCache::DiscardTexture( ResourceId id )
 {
   bool deleted = false;
@@ -507,36 +470,6 @@ void TextureCache::DispatchUpdateTextureArea( ResourceId id, const Dali::RectAre
   }
 }
 
-void TextureCache::DispatchUploadBitmapArrayToTexture( ResourceId id, const BitmapUploadArray& uploadArray )
-{
-  // NULL, means being shutdown, so ignore msgs
-  if( mSceneGraphBuffers != NULL )
-  {
-    typedef MessageValue2< TextureCache, ResourceId, BitmapUploadArray > DerivedType;
-
-    // Reserve some memory inside the render queue
-    unsigned int* slot = mRenderQueue.ReserveMessageSlot( mSceneGraphBuffers->GetUpdateBufferIndex(), sizeof( DerivedType ) );
-
-    // Construct message in the render queue memory; note that delete should not be called on the return value
-    new (slot) DerivedType( this, &TextureCache::AddBitmapUploadArray, id, uploadArray );
-  }
-}
-
-void TextureCache::DispatchClearAreas( ResourceId id, const BitmapClearArray& areaArray, std::size_t blockSize, uint32_t color )
-{
-  // NULL, means being shutdown, so ignore msgs
-  if( mSceneGraphBuffers != NULL )
-  {
-    typedef MessageValue4< TextureCache, ResourceId, BitmapClearArray, std::size_t, uint32_t > DerivedType;
-
-    // Reserve some memory inside the render queue
-    unsigned int* slot = mRenderQueue.ReserveMessageSlot( mSceneGraphBuffers->GetUpdateBufferIndex(), sizeof( DerivedType ) );
-
-    // Construct message in the render queue memory; note that delete should not be called on the return value
-    new (slot) DerivedType( this, &TextureCache::ClearAreas, id, areaArray, blockSize, color );
-  }
-}
-
 void TextureCache::DispatchDiscardTexture( ResourceId id )
 {
   // NULL, means being shutdown, so ignore msgs
index 656d103..07ed002 100644 (file)
@@ -136,13 +136,6 @@ public:
    */
   void UpdateTexture( ResourceId id, Integration::BitmapPtr bitmap );
 
- /**
-   * Add an array of bitmaps to an existing texture used as an Atlas
-   * @param[in] id Resource id of the texture
-   * @param[in] uploadArray array of upload bitmap structures
-   */
-  void AddBitmapUploadArray( ResourceId id, const BitmapUploadArray& uploadArray );
-
   /**
    * Update the area of the texture from the associated bitmap
    * @param[in] id Resource Id of the bitmap
@@ -151,18 +144,6 @@ public:
   void UpdateTextureArea( ResourceId id, const RectArea& area );
 
   /**
-   * Clear multiple areas of the texture
-   * @param[in] id Resource id of the texture
-   * @param[in] area Areas of the texture to clear
-   * @param[in] blockSize Size of block to clear
-   * @param[in] color Color to clear
-   */
-  void ClearAreas( ResourceId id,
-                   const BitmapClearArray& area,
-                   std::size_t blockSize,
-                   uint32_t color );
-
-  /**
    * Discard texture associated with resource ID
    * @param[in] id Resource Id of the texture
    */
@@ -272,16 +253,6 @@ protected: // Implements TextureCacheDispatcher
   virtual void DispatchUpdateTextureArea( ResourceId id, const RectArea& area );
 
   /**
-   * @copydoc TextureCacheDispatcher::DispatchUploadBitmapArrayToTexture()
-   */
-  virtual void DispatchUploadBitmapArrayToTexture( ResourceId id, const BitmapUploadArray& uploadArray );
-
-  /**
-   * @copydoc TextureCacheDispatcher::DispatchClearAreas()
-   */
-  virtual void DispatchClearAreas( ResourceId id, const BitmapClearArray& area, std::size_t blockSize, uint32_t color );
-
-  /**
    * @copydoc TextureCacheDispatcher::DispatchDiscardTexture()
    */
   virtual void DispatchDiscardTexture( ResourceId id );
index c5255cc..459509e 100644 (file)
@@ -357,11 +357,6 @@ void ResourceManager::HandleAllocateTextureRequest( ResourceId id, unsigned int
   mImpl->mTextureCacheDispatcher.DispatchCreateTexture( id, width, height, pixelFormat, true /* true = clear the texture */ );
 }
 
-void ResourceManager::HandleUpdateTextureRequest( ResourceId id,  const BitmapUploadArray& uploadArray )
-{
-  mImpl->mTextureCacheDispatcher.DispatchUploadBitmapArrayToTexture( id, uploadArray );
-}
-
 void ResourceManager::HandleAllocateMeshRequest( ResourceId id, MeshData* meshData )
 {
   DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceManager: HandleAllocateMeshRequest(id:%u)\n", id);
index 854f7fb..b80cec6 100644 (file)
@@ -35,7 +35,6 @@
 #include <dali/internal/common/event-to-update.h>
 #include <dali/internal/common/message.h>
 #include <dali/internal/event/common/thread-local-storage.h>
-#include <dali/internal/common/bitmap-upload.h>
 #include <dali/internal/event/modeling/model-data-impl.h>
 #include <dali/internal/event/resources/resource-client-declarations.h>
 #include <dali/internal/event/effects/shader-factory.h>
@@ -239,13 +238,6 @@ public: // Used by ResourceClient
   void HandleAllocateTextureRequest( ResourceId id, unsigned int width, unsigned int height, Pixel::Format pixelFormat );
 
   /**
-   * Upload an array of bitmaps to a texture.
-   * @param[in] id The resource id
-   * @param[in] uploadArray  bitmap upload array.
-   */
-  void HandleUpdateTextureRequest( ResourceId id,  const BitmapUploadArray& uploadArray );
-
-  /**
    * Requests allocation of a mesh resource
    * @param[in] id The resource id
    * @param[in] meshData The mesh data
@@ -520,20 +512,6 @@ inline void RequestAllocateTextureMessage(EventToUpdate& eventToUpdate,
   new (slot) LocalType( &manager, &ResourceManager::HandleAllocateTextureRequest, id, width, height, pixelFormat );
 }
 
-inline void RequestUpdateTextureMessage(EventToUpdate& eventToUpdate,
-                                               ResourceManager& manager,
-                                               ResourceId id,
-                                               BitmapUploadArray uploadArray )
-{
-  typedef MessageValue2< ResourceManager, ResourceId, BitmapUploadArray > LocalType;
-
-  // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
-
-  // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &manager, &ResourceManager::HandleUpdateTextureRequest, id, uploadArray );
-}
-
 inline void RequestAllocateMeshMessage( EventToUpdate& eventToUpdate,
                                         ResourceManager& manager,
                                         ResourceId id,