TestPlatformAbstraction::TestPlatformAbstraction()
: mTrace(),
mIsLoadingResult( false ),
- mGetDefaultFontSizeResult( 0 ),
- mLoadedResourcesQueue(),
- mFailedLoadQueue(),
- mResourceRequests(),
mSize(),
mClosestSize(),
mLoadFileResult(),
TestPlatformAbstraction::~TestPlatformAbstraction()
{
- DiscardRequest();
-}
-
-void TestPlatformAbstraction::Suspend()
-{
- mTrace.PushCall("Suspend", "");
-}
-
-void TestPlatformAbstraction::Resume()
-{
- mTrace.PushCall("Resume", "");
}
ImageDimensions TestPlatformAbstraction::GetClosestImageSize( const std::string& filename,
return closestSize;
}
-void TestPlatformAbstraction::LoadResource(const Integration::ResourceRequest& request)
-{
- std::ostringstream out;
- out << "Type:" << request.GetType()->id << ", Path: " << request.GetPath() << std::endl ;
-
- mTrace.PushCall("LoadResource", out.str());
-
- mResourceRequests.PushBack( new Integration::ResourceRequest(request) );
-}
-
Integration::ResourcePointer TestPlatformAbstraction::LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath )
{
mTrace.PushCall("LoadResourceSynchronously", "");
return mDecodedBitmap;
}
-void TestPlatformAbstraction::CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId)
-{
- mTrace.PushCall("CancelLoad", "");
-}
-
-void TestPlatformAbstraction::GetResources(Integration::ResourceCache& cache)
-{
- mTrace.PushCall("GetResources", "");
-
- while( !mLoadedResourcesQueue.empty() )
- {
- LoadedResource loaded( *mLoadedResourcesQueue.begin() );
- mLoadedResourcesQueue.erase( mLoadedResourcesQueue.begin() );
- cache.LoadResponse( loaded.id, loaded.type, loaded.resource, Integration::RESOURCE_COMPLETELY_LOADED );
- }
-
- // iterate through the resources which failed to load
- while( !mFailedLoadQueue.empty() )
- {
- FailedLoad failed( *mFailedLoadQueue.begin() );
- mFailedLoadQueue.erase( mFailedLoadQueue.begin() );
- cache.LoadFailed( failed.id, failed.failure );
- }
-}
-
-bool TestPlatformAbstraction::IsLoading()
-{
- mTrace.PushCall("IsLoading", "");
- return mIsLoadingResult;
-}
-
-int TestPlatformAbstraction::GetDefaultFontSize() const
-{
- mTrace.PushCall("GetDefaultFontSize", "");
- return mGetDefaultFontSizeResult;
-}
-
-void TestPlatformAbstraction::SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical)
-{
- mTrace.PushCall("SetDpi", "");
-}
-
-bool TestPlatformAbstraction::LoadFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const
-{
- mTrace.PushCall("LoadFile", "");
- if( mLoadFileResult.loadResult )
- {
- buffer = mLoadFileResult.buffer;
- }
-
- return mLoadFileResult.loadResult;
-}
-
bool TestPlatformAbstraction::LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const
{
mTrace.PushCall("LoadShaderBinaryFile", "");
return mLoadFileResult.loadResult;
}
-bool TestPlatformAbstraction::SaveFile(const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const
-{
- mTrace.PushCall("SaveFile", "");
- return false;
-}
-
-void TestPlatformAbstraction::JoinLoaderThreads()
-{
- mTrace.PushCall("JoinLoaderThreads", "");
-}
/** Call this every test */
void TestPlatformAbstraction::Initialize()
{
mTrace.Reset();
mTrace.Enable(true);
- mLoadedResourcesQueue.clear();
- mFailedLoadQueue.clear();
- mResourceRequests.Clear();
mIsLoadingResult=false;
mSynchronouslyLoadedResource.Reset();
mDecodedBitmap.Reset();
{
switch(func)
{
- case SuspendFunc: return mTrace.FindMethod("Suspend");
- case ResumeFunc: return mTrace.FindMethod("Resume");
- case LoadResourceFunc: return mTrace.FindMethod("LoadResource");
case LoadResourceSynchronouslyFunc: return mTrace.FindMethod("LoadResourceSynchronously");
- case LoadFileFunc: return mTrace.FindMethod("LoadFile");
case LoadShaderBinaryFileFunc: return mTrace.FindMethod("LoadShaderBinaryFile");
case SaveShaderBinaryFileFunc: return mTrace.FindMethod("SaveShaderBinaryFile");
- case SaveFileFunc: return mTrace.FindMethod("SaveFile");
- case CancelLoadFunc: return mTrace.FindMethod("CancelLoad");
- case GetResourcesFunc: return mTrace.FindMethod("GetResources");
- case IsLoadingFunc: return mTrace.FindMethod("IsLoading");
- case SetDpiFunc: return mTrace.FindMethod("SetDpi");
- case JoinLoaderThreadsFunc: return mTrace.FindMethod("JoinLoaderThreads");
}
return false;
}
void TestPlatformAbstraction::ClearReadyResources()
{
- mLoadedResourcesQueue.clear();
- mFailedLoadQueue.clear();
mSynchronouslyLoadedResource.Reset();
mDecodedBitmap.Reset();
}
-void TestPlatformAbstraction::SetResourceLoaded(Integration::ResourceId loadedId,
- Integration::ResourceTypeId loadedType,
- Integration::ResourcePointer loadedResource)
-{
- LoadedResource loadedInfo;
- loadedInfo.id = loadedId;
- loadedInfo.type = loadedType;
- loadedInfo.resource = loadedResource;
- mLoadedResourcesQueue.push_back( loadedInfo );
-}
-
-void TestPlatformAbstraction::SetResourceLoadFailed(Integration::ResourceId id,
- Integration::ResourceFailure failure)
-{
- FailedLoad failedInfo;
- failedInfo.id = id;
- failedInfo.failure = failure;
- mFailedLoadQueue.push_back( failedInfo );
-}
-
-Integration::ResourceRequest* TestPlatformAbstraction::GetRequest()
-{
- Integration::ResourceRequest* request = NULL;
-
- // Return last request
- if( ! mResourceRequests.Empty() )
- {
- request = *( mResourceRequests.End() - 1 );
- }
-
- return request;
-}
-
-const TestPlatformAbstraction::ResourceRequestContainer& TestPlatformAbstraction::GetAllRequests() const
-{
- return mResourceRequests;
-}
-
-void TestPlatformAbstraction::SetAllResourceRequestsAsLoaded()
-{
- for( ResourceRequestContainer::Iterator iter = mResourceRequests.Begin(), endIter = mResourceRequests.End();
- iter != endIter; ++iter )
- {
- Integration::ResourceRequest* request = *iter;
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
- Integration::ResourcePointer resource(bitmap);
- bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
- SetResourceLoaded( request->GetId(), request->GetType()->id, resource );
- delete request;
- }
- mResourceRequests.Clear();
-}
-
-void TestPlatformAbstraction::SetAllResourceRequestsAsFailed( Integration::ResourceFailure failure )
-{
- for( ResourceRequestContainer::Iterator iter = mResourceRequests.Begin(), endIter = mResourceRequests.End();
- iter != endIter; ++iter )
- {
- Integration::ResourceRequest* request = *iter;
- SetResourceLoadFailed( (*iter)->GetId(), failure);
- delete request;
- }
- mResourceRequests.Clear();
-}
-
-void TestPlatformAbstraction::DiscardRequest()
-{
- for( ResourceRequestContainer::Iterator iter = mResourceRequests.Begin(), endIter = mResourceRequests.End();
- iter != endIter; ++iter )
- {
- Integration::ResourceRequest* request = *iter;
- delete request;
- }
- mResourceRequests.Clear();
-}
-
void TestPlatformAbstraction::SetClosestImageSize(const Vector2& size)
{
mClosestSize = size;
public:
- typedef Vector< Integration::ResourceRequest* > ResourceRequestContainer;
-
/**
* Constructor
*/
virtual ~TestPlatformAbstraction();
/**
- * @copydoc PlatformAbstraction::Suspend()
- */
- virtual void Suspend();
-
- /**
- * @copydoc PlatformAbstraction::Resume()
- */
- virtual void Resume();
-
- /**
* @copydoc PlatformAbstraction::GetClosestImageSize()
*/
virtual ImageDimensions GetClosestImageSize( const std::string& filename,
bool orientationCorrection );
/**
- * @copydoc PlatformAbstraction::LoadResource()
- */
- virtual void LoadResource(const Integration::ResourceRequest& request);
-
- /**
* @copydoc PlatformAbstraction::LoadResourceSynchronously()
*/
virtual Integration::ResourcePointer LoadResourceSynchronously( const Integration::ResourceType& resourceType, const std::string& resourcePath );
virtual Integration::BitmapPtr DecodeBuffer( const Dali::Integration::ResourceType& resourceType, uint8_t * buffer, size_t size );
/**
- * @copydoc PlatformAbstraction::CancelLoad()
- */
- virtual void CancelLoad(Integration::ResourceId id, Integration::ResourceTypeId typeId);
-
- /**
- * @copydoc PlatformAbstraction::GetResources()
- */
- virtual void GetResources(Integration::ResourceCache& cache);
-
- /**
- * @copydoc PlatformAbstraction::IsLoading()
- */
- virtual bool IsLoading();
-
- /**
- * @copydoc PlatformAbstraction::GetDefaultFontSize()
- */
- virtual int GetDefaultFontSize() const;
-
- /**
- * @copydoc PlatformAbstraction::SetDpi()
- */
- virtual void SetDpi (unsigned int dpiHorizontal, unsigned int dpiVertical);
-
- /**
- * @copydoc PlatformAbstraction::LoadFile()
- */
- virtual bool LoadFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const;
-
- /**
* @copydoc PlatformAbstraction::LoadShaderBinaryFile()
*/
virtual bool LoadShaderBinaryFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const;
/**
- * @copydoc PlatformAbstraction::SaveFile()
+ * @copydoc PlatformAbstraction::SaveShaderBinaryFile()
*/
- virtual bool SaveFile(const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const;
-
- /**
- * @copydoc PlatformAbstraction::SaveShaderBinaryFile()
- */
virtual bool SaveShaderBinaryFile( const std::string& filename, const unsigned char * buffer, unsigned int numBytes ) const { return true; }
- virtual void JoinLoaderThreads();
public: // TEST FUNCTIONS
// Enumeration of Platform Abstraction methods
typedef enum
{
- SuspendFunc,
- ResumeFunc,
- LoadResourceFunc,
LoadResourceSynchronouslyFunc,
- SaveFileFunc,
- LoadFileFunc,
LoadShaderBinaryFileFunc,
- SaveShaderBinaryFileFunc,
- CancelLoadFunc,
- GetResourcesFunc,
- IsLoadingFunc,
- SetDpiFunc,
- JoinLoaderThreadsFunc,
+ SaveShaderBinaryFileFunc
} TestFuncEnum;
/** Call this every test */
void SetIsLoadingResult(bool result);
/**
- * @brief Sets the value returned by GetDefaultFontSize
- * @param[in] result The value to return
- */
- void SetGetDefaultFontSizeResult(float result);
-
- /**
* @brief Clears all resource queues
*/
void ClearReadyResources();
/**
- * @brief Sets a particular resource request as loaded.
- * @param[in] loadedId The ResourceID of the resource that has been loaded.
- * @param[in] loadedType The type of resource that has been loaded.
- * @param[in] loadedResource A pointer to the resource that has been loaded.
- */
- void SetResourceLoaded(Integration::ResourceId loadedId,
- Integration::ResourceTypeId loadedType,
- Integration::ResourcePointer loadedResource);
-
- /**
- * @brief Sets a particular resource request as load failure.
- * @param[in] id The ID of the failed resource request.
- * @param[in] failure The type of failure.
- */
- void SetResourceLoadFailed(Integration::ResourceId id,
- Integration::ResourceFailure failure);
-
- /**
- * @brief Retrieves the latest resource request
- * @return A pointer to the latest resource request.
- */
- Integration::ResourceRequest* GetRequest();
-
- /**
- * @brief Retrieves a reference to a container of all the resource requests.
- * @return A reference to a container of all the resource requests.
- */
- const ResourceRequestContainer& GetAllRequests() const;
-
- /**
- * @brief Sets all resource requests as loaded.
- */
- void SetAllResourceRequestsAsLoaded();
-
- /**
- * @brief Sets all resource requests as loaded.
- * @param[in] failure The failure type
- */
- void SetAllResourceRequestsAsFailed( Integration::ResourceFailure failure );
-
- /**
- * @brief Discards all current resource requests.
- */
- void DiscardRequest();
-
- /**
* @brief Sets the value returned by GetClosestImageSize.
* @param[in] size The size that should be returned.
*/
private:
- struct LoadedResource
- {
- Integration::ResourceId id;
- Integration::ResourceTypeId type;
- Integration::ResourcePointer resource;
- };
-
- struct FailedLoad
- {
- Integration::ResourceId id;
- Integration::ResourceFailure failure;
- };
-
struct LoadFileResult
{
inline LoadFileResult()
Dali::Vector< unsigned char> buffer;
};
- typedef std::vector< LoadedResource > LoadedResourceContainer;
- typedef std::vector< FailedLoad > FailedLoadContainer;
-
mutable TraceCallStack mTrace;
bool mIsLoadingResult;
- int mGetDefaultFontSizeResult;
- LoadedResourceContainer mLoadedResourcesQueue;
- FailedLoadContainer mFailedLoadQueue;
- ResourceRequestContainer mResourceRequests;
Vector2 mSize;
Vector2 mClosestSize;
namespace
{
-void LoadBitmapResource(TestPlatformAbstraction& platform)
-{
- Integration::ResourceRequest* request = platform.GetRequest();
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
- Integration::ResourcePointer resource(bitmap);
- bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
-
- if(request)
- {
- platform.SetResourceLoaded(request->GetId(), request->GetType()->id, resource);
- }
-}
}
std::vector<GLuint> ids;
ids.push_back( 23 );
application.GetGlAbstraction().SetNextTextureIds( ids );
- TestPlatformAbstraction& platform = application.GetPlatform();
- LoadBitmapResource( platform );
application.Render(16);
application.SendNotification();
} // Drop image handle
application.SendNotification();
application.Render(16);
- Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
- if(request)
- {
- application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, Integration::ResourcePointer(Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD)));
- }
-
- application.Render(16);
- application.SendNotification();
-
DALI_TEST_CHECK( SignalLoadFlag == true );
END_TEST;
}
void TextureSetImage( TextureSet textureSet, size_t index, Image image )
{
- Internal::NewTexture* texture = NULL;
+ Internal::Texture* texture = NULL;
if( image )
{
texture = GetImplementation( image ).GetTexture();
NOT_REQUESTED = 0, ///< Zero means that no further updates are required
STAGE_KEEP_RENDERING = 1<<1, ///< - Stage::KeepRendering() is being used
ANIMATIONS_RUNNING = 1<<2, ///< - Animations are ongoing
- LOADING_RESOURCES = 1<<3, ///< - Resources are being loaded
- MONITORING_PERFORMANCE = 1<<4, ///< - The --enable-performance-monitor option is being used
- RENDER_TASK_SYNC = 1<<5 ///< - A render task is waiting for render sync
+ MONITORING_PERFORMANCE = 1<<3, ///< - The --enable-performance-monitor option is being used
+ RENDER_TASK_SYNC = 1<<4 ///< - A render task is waiting for render sync
};
}
$(platform_abstraction_src_dir)/bitmap.h \
$(platform_abstraction_src_dir)/resource-policies.h \
$(platform_abstraction_src_dir)/resource-types.h \
- $(platform_abstraction_src_dir)/resource-request.h \
- $(platform_abstraction_src_dir)/resource-cache.h \
$(platform_abstraction_src_dir)/resource-declarations.h \
$(platform_abstraction_src_dir)/gl-abstraction.h \
$(platform_abstraction_src_dir)/gl-defines.h \
// INTERNAL INCLUDES
-#include <dali/integration-api/resource-cache.h>
#include <dali/integration-api/bitmap.h>
+#include <dali/integration-api/resource-types.h>
#include <dali/public-api/images/image-operations.h>
#include <dali/public-api/common/dali-vector.h>
namespace Integration
{
+typedef IntrusivePtr<Dali::RefObject> ResourcePointer;
+
/**
* PlatformAbstraction is an abstract interface, used by Dali to access platform specific services.
* A concrete implementation must be created for each platform, and provided when creating the
*/
virtual ~PlatformAbstraction() {}
- // DALi Lifecycle
-
- /**
- * Tell the platform abstraction that Dali is ready to pause, such as when the
- * application enters a background state.
- * Allows background threads to pause their work until Resume() is called.
- * This is a good time to release recreatable data such as memory caches
- * to cooperate with other apps and reduce the chance of this one being
- * force-killed in a low memory situation.
- */
- virtual void Suspend() = 0;
-
- /**
- * Tell the platform abstraction that Dali is resuming from a pause, such as
- * when it has transitioned from a background state to a foreground one.
- * It is time to wake up sleeping background threads and recreate memory
- * caches and other temporary data.
- */
- virtual void Resume() = 0;
-
// Resource Loading
/**
bool orientationCorrection = true) = 0;
/**
- * Request a resource from the native filesystem. This is an asynchronous request.
- * After this method returns, FillResourceCache() will be called to retrieve the result(s) of the
- * resource loading operation. Loading resources in separate worker thread is recommended.
- * Multi-threading note: this method will be called from the main thread only i.e. not
- * from within the Core::Render() method.
- * @param[in] request A unique resource request. This is not guaranteed to survive after LoadResource
- * returns; the loading process should take a copy.
- */
- virtual void LoadResource(const ResourceRequest& request) = 0;
-
- /**
* Request a resource from the native filesystem. This is a synchronous request, i.e.
* it will block the main loop whilst executing. It should therefore be used sparingly.
*
virtual BitmapPtr DecodeBuffer( const ResourceType& resourceType, uint8_t * buffer, size_t bufferSize ) = 0;
/**
- * Cancel an ongoing LoadResource() request.
- * Multi-threading note: this method will be called from the main thread only i.e. not
- * from within the Core::Render() method.
- * @param[in] id The ID of the resource to cancel.
- * @param[in] typeId The ID type of the resource to cancel.
- */
- virtual void CancelLoad(ResourceId id, ResourceTypeId typeId) = 0;
-
- /**
- * Retrieve newly loaded resources.
- * If no resources have finished loading, then this method returns immediately.
- * Multi-threading note: this method will be called from the update thread, from within
- * the UpdateManager::Update() method.
- * @param[in] cache The resource cache to fill.
- */
- virtual void GetResources(ResourceCache& cache) = 0;
-
- /**
- * Waits for the asynchronous loader threads (if any) to finish.
- * This will be only be called before Core destruction; no resource loading requests will be
- * made following this method.
- */
- virtual void JoinLoaderThreads() = 0;
-
- // Font Queries
-
- /**
- * Called by Dali to retrieve the default font size for the platform.
- * This is an accessibility size, which is mapped to a UI Control specific point-size in stylesheets.
- * For example if zero the smallest size, this could potentially map to TextLabel point-size 8.
- * Multi-threading note: this method will be called from the main thread only i.e. not
- * from within the Core::Render() method.
- * @return The default font size.
- */
- virtual int GetDefaultFontSize() const = 0;
-
- /**
- * Load a file into a buffer
- * @param[in] filename The filename to load
- * @param[out] buffer A buffer to receive the file.
- * @result true if the file is loaded.
- */
- virtual bool LoadFile( const std::string& filename, Dali::Vector< unsigned char >& buffer ) const = 0;
-
- /**
* Load a shader binary file into a buffer
* @param[in] filename The shader binary filename to load
* @param[out] buffer A buffer to receive the file.
#include <dali/internal/event/images/image-impl.h>
-#include <dali/internal/event/resources/resource-ticket.h>
-#include <dali/internal/event/resources/image-ticket.h>
-
#include <dali/internal/update/nodes/node.h>
#include <dali/internal/update/nodes/scene-graph-layer.h>
#include <dali/internal/update/rendering/scene-graph-renderer.h>
-#include <dali/internal/update/resources/texture-metadata.h>
-#include <dali/internal/render/gl-resources/bitmap-texture.h>
#include <dali/internal/render/renderers/render-geometry.h>
#include <dali/internal/render/renderers/render-property-buffer.h>
#include <dali/internal/render/renderers/render-renderer.h>
sizeof( Internal::SceneGraph::Layer ) );
const int IMAGE_MEMORY_SIZE(
sizeof( Internal::Image ) +
- sizeof( Integration::Bitmap ) +
- sizeof( Internal::TextureMetadata ) +
- sizeof( Internal::BitmapTexture ) +
- sizeof( Internal::ImageTicket ) );
+ sizeof( Integration::Bitmap ) );
const int RENDERER_MEMORY_SIZE(
sizeof( Internal::Renderer ) +
sizeof( Internal::SceneGraph::Renderer ) +
+++ /dev/null
-#ifndef __DALI_INTEGRATION_RESOURCE_CACHE_H__
-#define __DALI_INTEGRATION_RESOURCE_CACHE_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/intrusive-ptr.h>
-#include <dali/integration-api/resource-request.h>
-
-namespace Dali
-{
-
-namespace Integration
-{
-/**
- * Used to determine why a resource IO operation has failed.
- */
-enum ResourceFailure
-{
- FailureUnknown,
- FailureFileNotFound,
- FailureInvalidPath
-};
-
-/**
- * Used to return loaded resources for rendering etc.
- */
-typedef IntrusivePtr<Dali::RefObject> ResourcePointer;
-
-/**
- * Abstract interface to receive notifications of resource IO operations.
- * This is used when pulling loaded resources from the PlatformAbstraction.
- */
-class ResourceCache
-{
-protected:
-
- /**
- * Virtual protected destructor, no deletion through this interface
- */
- virtual ~ResourceCache() {}
-
-public:
-
- /**
- * Provide the results of a resource loading operation to the cache.
- * @param[in] id The unique ID of the load request.
- * This should match an ID previously passed into PlatformAbstraction::LoadResource().
- * LoadResponse() may be called multiple times with the same ID, when results are available
- * at different stages e.g. a thumbnail image may be provided, before the full image is loaded.
- * @param[in] type The type of the resource.
- * @param[in] resource A pointer to a resource (Bitmap etc).
- * @param[in] status The current loading status. RESOURCE_LOADING and RESOURCE_PARTIALLY_LOADED indicate there are more responses to come, RESOURCE_COMPLETELY_LOADED indicates this is the last response for this id.
- */
- virtual void LoadResponse(ResourceId id, ResourceTypeId type, ResourcePointer resource, LoadStatus status) = 0;
-
- /**
- * Report that a resource loading operation has failed.
- * @param[in] id The unique ID of the load request.
- * This should match an ID previously passed into PlatformAbstraction::LoadResource().
- * @param[in] failure An error code, used to determine why the load failed.
- */
- virtual void LoadFailed(ResourceId id, ResourceFailure failure) = 0;
-};
-
-
-} // namespace Integration
-
-} // namespace Dali
-
-#endif // __DALI_INTEGRATION_RESOURCE_CACHE_H__
+++ /dev/null
-#ifndef __DALI_INTEGRATION_RESOURCE_REQUEST_H__
-#define __DALI_INTEGRATION_RESOURCE_REQUEST_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/integration-api/resource-types.h>
-#include <dali/public-api/object/ref-object.h>
-
-namespace Dali
-{
-
-class RefObject;
-
-namespace Integration
-{
-
-// Resource Requests
-
-/**
- * Used to return loaded resources for rendering etc.
- */
-typedef IntrusivePtr<Dali::RefObject> ResourcePointer;
-
-/**
- * Used to prioritize between loading operations.
- */
-enum LoadResourcePriority
-{
- LoadPriorityLowest,
- LoadPriorityLow,
- LoadPriorityNormal,
- LoadPriorityHigh,
- LoadPriorityHighest,
-};
-
-/**
- * Used to request a resource from the native filesystem.
- */
-class ResourceRequest
-{
-public:
-
- /**
- * Used to request a resource be accessed from the native filesystem.
- * @param[in] newId A unique ID for this request.
- * @param[in] resourceType The type of resource requested. The implementation of
- * PlatformAbstraction::LoadResource() is responsible for
- * converting the native file(s) to this type
- * e.g. decoding a jpeg to a bitmap.
- * @param[in] resourcePath The path of the resource; typically a filename.
- * @param[in] loadPriority The priority of the request.
- */
- ResourceRequest(ResourceId newId,
- const ResourceType& resourceType,
- const std::string& resourcePath,
- LoadResourcePriority loadPriority = LoadPriorityNormal)
- : id(newId),
- type(NULL),
- path(resourcePath),
- priority(loadPriority)
- {
- type = resourceType.Clone();
- }
-
- /**
- * Used to request or save a resource from/to the native filesystem.
- * @param[in] newId A unique ID for this request.
- * @param[in] resourceType The type of resource.
- * @param[in] resourcePath The location of the resource / where the resource should be saved.
- * @param[in] resourcePtr The resource to decode / save.
- * @param[in] savePriority The priority of the request.
- */
- ResourceRequest(ResourceId newId,
- const ResourceType& resourceType,
- const std::string& resourcePath,
- ResourcePointer resourcePtr,
- LoadResourcePriority savePriority = LoadPriorityNormal)
- : id(newId),
- type(NULL),
- path(resourcePath),
- resource(resourcePtr),
- priority(savePriority)
- {
- type = resourceType.Clone();
- }
-
- /**
- * Copy constructor.
- * @param[in] request The resource request to copy.
- */
- ResourceRequest(const ResourceRequest& request)
- : id(request.id),
- type(NULL),
- path(request.path),
- resource(request.resource),
- priority(request.priority)
- {
- type = request.type->Clone();
- }
-
- /**
- * Assignment operator.
- * @param[in] rhs The resource request to copy.
- */
- ResourceRequest& operator=(const ResourceRequest& rhs)
- {
- if( this != &rhs )
- {
- id = rhs.id;
- type = rhs.type->Clone();
- path = rhs.path;
- resource = rhs.resource;
- priority = rhs.priority;
- }
-
- return *this;
- }
-
- /**
- * Non-virtual destructor; not intended as a base class
- */
- ~ResourceRequest()
- {
- delete type;
- }
-
- /**
- * Retrieve the resource ID
- * @return The ID
- */
- ResourceId GetId() const
- {
- return id;
- }
-
- /**
- * Retrieve the resource type
- * @return The type
- */
- ResourceType* GetType() const
- {
- return type;
- }
-
- /**
- * Retrieve the resource path
- * @return The path
- */
- const std::string& GetPath() const
- {
- return path;
- }
-
- /**
- * Retrieve the resource (for save and decode requests)
- * @return The resource
- */
- ResourcePointer GetResource() const
- {
- return resource;
- }
-
- /**
- * Retrieve the load priority
- * @return The priority
- */
- LoadResourcePriority GetPriority() const
- {
- return priority;
- }
-
-private:
-
- ResourceId id;
- ResourceType* type;
- std::string path;
- /** When saving resources or decoding them, the resource data will be passed
- * through in a reference counted object here. When Loading, it will be null. */
- ResourcePointer resource;
- LoadResourcePriority priority;
-};
-
-} // namespace Integration
-
-} // namespace Dali
-
-#endif // __DALI_INTEGRATION_RESOURCE_REQUEST_H__
*/
enum ResourceTypeId
{
- ResourceBitmap,
- ResourceNativeImage,
- ResourceTargetImage
+ ResourceBitmap
};
/**
BitmapResourceType& operator=(const BitmapResourceType& rhs);
};
-/**
- * NativeImageResourceType describes a native image resource, which can be injected
- * through ResourceManager::AddNativeImage() or requested through ResourceLoader::LoadResource().
- * If the adaptor does not support NativeImages, it can fall back to Bitmap type.
- */
-struct NativeImageResourceType : public ResourceType
-{
- /**
- * Constructor.
- */
- NativeImageResourceType()
- : ResourceType(ResourceNativeImage) {}
-
- /**
- * Constructor.
- * @param[in] dimensions Width and Height to allocate for image.
- */
- NativeImageResourceType( ImageDimensions dimensions )
- : ResourceType(ResourceNativeImage),
- imageDimensions(dimensions) {}
-
- /**
- * Destructor.
- */
- virtual ~NativeImageResourceType() {}
-
- /**
- * @copydoc ResourceType::Clone
- */
- virtual ResourceType* Clone() const
- {
- return new NativeImageResourceType(imageDimensions);
- }
-
- /**
- * Attributes are copied from the request (if supplied).
- */
- ImageDimensions imageDimensions;
-
-private:
-
- // Undefined copy constructor.
- NativeImageResourceType(const NativeImageResourceType& typePath);
-
- // Undefined assignment operator.
- NativeImageResourceType& operator=(const NativeImageResourceType& rhs);
-};
-
-/**
- * RenderTargetResourceType describes a bitmap resource, which can injected
- * through ResourceManager::AddTargetImage()
- */
-struct RenderTargetResourceType : public ResourceType
-{
- /**
- * Constructor.
- */
- RenderTargetResourceType()
- : ResourceType(ResourceTargetImage) {}
-
- /**
- * Constructor.
- * @param[in] dims Width and Height to allocate for image.
- */
- RenderTargetResourceType( ImageDimensions dims )
- : ResourceType(ResourceTargetImage),
- imageDimensions(dims) {}
-
- /**
- * Destructor.
- */
- virtual ~RenderTargetResourceType() {}
-
- /**
- * @copydoc ResourceType::Clone
- */
- virtual ResourceType* Clone() const
- {
- return new RenderTargetResourceType(imageDimensions);
- }
-
- /**
- * Image size is copied from the request.
- */
- ImageDimensions imageDimensions;
-
-private:
-
- // Undefined copy constructor.
- RenderTargetResourceType(const RenderTargetResourceType& typePath);
-
- // Undefined assignment operator.
- RenderTargetResourceType& operator=(const RenderTargetResourceType& rhs);
-};
-
} // namespace Integration
} // namespace Dali
#include <dali/internal/event/size-negotiation/relayout-controller-impl.h>
#include <dali/internal/update/common/discard-queue.h>
-#include <dali/internal/update/common/texture-cache-dispatcher.h>
#include <dali/internal/update/manager/update-manager.h>
#include <dali/internal/update/manager/render-task-processor.h>
-#include <dali/internal/update/resources/resource-manager.h>
#include <dali/internal/render/common/performance-monitor.h>
#include <dali/internal/render/common/render-manager.h>
-#include <dali/internal/render/gl-resources/texture-cache.h>
#include <dali/internal/render/gl-resources/context.h>
using Dali::Internal::SceneGraph::UpdateManager;
using Dali::Internal::SceneGraph::RenderManager;
using Dali::Internal::SceneGraph::DiscardQueue;
using Dali::Internal::SceneGraph::RenderQueue;
-using Dali::Internal::SceneGraph::TextureCache;
-using Dali::Internal::SceneGraph::TextureCacheDispatcher;
namespace
{
mUpdateManager(NULL),
mRenderManager(NULL),
mDiscardQueue(NULL),
- mTextureUploadedQueue(),
mNotificationManager(NULL),
mShaderFactory(NULL),
mIsActive(true),
mPropertyNotificationManager = PropertyNotificationManager::New();
- mTextureUploadedQueue = new LockedResourceQueue;
-
mRenderTaskProcessor = new SceneGraph::RenderTaskProcessor();
- mRenderManager = RenderManager::New( glAbstraction, glSyncAbstraction, *mTextureUploadedQueue );
+ mRenderManager = RenderManager::New( glAbstraction, glSyncAbstraction );
RenderQueue& renderQueue = mRenderManager->GetRenderQueue();
- TextureCache& textureCache = mRenderManager->GetTextureCache();
-
- ResourcePolicy::Discardable discardPolicy = ResourcePolicy::OWNED_DISCARD;
- if( dataRetentionPolicy == ResourcePolicy::DALI_RETAINS_ALL_DATA )
- {
- discardPolicy = ResourcePolicy::OWNED_RETAIN;
- }
- textureCache.SetDiscardBitmapsPolicy(discardPolicy);
-
- mTextureCacheDispatcher = new SceneGraph::TextureCacheDispatcher( renderQueue, textureCache );
mDiscardQueue = new DiscardQueue( renderQueue );
- mResourceManager = new ResourceManager( mPlatform,
- *mNotificationManager,
- *mTextureCacheDispatcher,
- *mTextureUploadedQueue,
- *mDiscardQueue,
- renderQueue );
-
mUpdateManager = new UpdateManager( *mNotificationManager,
*mAnimationPlaylist,
*mPropertyNotificationManager,
- *mResourceManager,
*mDiscardQueue,
renderController,
*mRenderManager,
renderQueue,
- *mTextureCacheDispatcher,
*mRenderTaskProcessor );
mRenderManager->SetShaderSaver( *mUpdateManager );
Core::~Core()
{
- /**
- * TODO this should be done by Adaptor, Core does not know about threading
- * First stop the resource loading thread(s)
- */
- mPlatform.JoinLoaderThreads();
-
/*
* The order of destructing these singletons is important!!!
*/
delete mGestureEventProcessor;
delete mNotificationManager;
delete mShaderFactory;
- delete mResourceManager;
delete mDiscardQueue;
- delete mTextureCacheDispatcher;
delete mUpdateManager;
delete mRenderManager;
delete mRenderTaskProcessor;
- delete mTextureUploadedQueue;
}
Integration::ContextNotifierInterface* Core::GetContextNotifier()
// No need to keep update running if there are notifications to process.
// Any message to update will wake it up anyways
-
- if ( mResourceManager->ResourcesToProcess() )
- {
- // If we are still processing resources, then we have to continue the update
- status.keepUpdating |= Integration::KeepUpdating::LOADING_RESOURCES;
- }
}
void Core::Render( RenderStatus& status )
void Core::Suspend()
{
- mPlatform.Suspend();
-
mIsActive = false;
}
void Core::Resume()
{
- mPlatform.Resume();
-
mIsActive = true;
// trigger processing of events queued up while paused
return *(mNotificationManager);
}
-ResourceManager& Core::GetResourceManager()
-{
- return *(mResourceManager);
-}
-
ShaderFactory& Core::GetShaderFactory()
{
return *(mShaderFactory);
#include <dali/internal/common/owner-pointer.h>
#include <dali/internal/event/animation/animation-playlist-declarations.h>
#include <dali/internal/event/common/stage-def.h>
-#include <dali/internal/update/resources/resource-manager-declarations.h>
#include <dali/public-api/common/view-mode.h>
#include <dali/integration-api/resource-policies.h>
class PropertyNotificationManager;
class EventProcessor;
class GestureEventProcessor;
-class ResourceManager;
class ShaderFactory;
class TouchResampler;
class RelayoutController;
class UpdateManager;
class RenderManager;
class DiscardQueue;
-class TextureCacheDispatcher;
class RenderTaskProcessor;
}
NotificationManager& GetNotificationManager();
/**
- * Returns the Resource Manager.
- * @return A reference to the Resource Manager.
- */
- ResourceManager& GetResourceManager();
-
- /**
* Returns the Shader factory
* @return A reference to the Shader binary factory.
*/
SceneGraph::UpdateManager* mUpdateManager; ///< Update manager
SceneGraph::RenderManager* mRenderManager; ///< Render manager
SceneGraph::DiscardQueue* mDiscardQueue; ///< Used to cleanup nodes & resources when no longer in use.
- SceneGraph::TextureCacheDispatcher* mTextureCacheDispatcher; ///< Used to send messages to TextureCache
- LockedResourceQueue* mTextureUploadedQueue; ///< Stores resource ids which require post processing after render
NotificationManager* mNotificationManager; ///< Notification manager
AnimationPlaylistOwner mAnimationPlaylist; ///< For 'Fire and forget' animation support
OwnerPointer<PropertyNotificationManager> mPropertyNotificationManager; ///< For safe signal emmision of property changed notifications
ShaderFactory* mShaderFactory; ///< Shader resource factory
- ResourceManager* mResourceManager; ///< Asynchronous Resource Loading
IntrusivePtr< RelayoutController > mRelayoutController; ///< Size negotiation relayout controller
SceneGraph::RenderTaskProcessor* mRenderTaskProcessor; ///< Handles the processing of render tasks
bool mIsActive : 1; ///< Whether Core is active or suspended
return mCore->GetNotificationManager();
}
-ResourceManager& ThreadLocalStorage::GetResourceManager()
-{
- return mCore->GetResourceManager();
-}
-
ShaderFactory& ThreadLocalStorage::GetShaderFactory()
{
return mCore->GetShaderFactory();
class Core;
class NotificationManager;
-class ResourceManager;
class ShaderFactory;
class GestureEventProcessor;
class RelayoutController;
NotificationManager& GetNotificationManager();
/**
- * Returns the Resource Manager
- * @return reference to the Resource Manager
- */
- ResourceManager& GetResourceManager();
-
- /**
* Returns the Shader Factory
* @return reference to the Shader Factory
*/
{
if ( !mTexture )
{
- mTexture = NewTexture::New( Dali::TextureType::TEXTURE_2D, mPixelFormat, mWidth, mHeight );
+ mTexture = Texture::New( Dali::TextureType::TEXTURE_2D, mPixelFormat, mWidth, mHeight );
}
DALI_ASSERT_DEBUG( updateArea.x + updateArea.width <= mWidth && updateArea.y + updateArea.height <= mHeight );
UploadArea( updateArea );
class BufferImage;
typedef IntrusivePtr<BufferImage> BufferImagePtr;
-class ResourceManager;
-
/**
* BufferImage represents an image resource that can be added to actors etc.
* Its pixel buffer data is provided by the application developer.
// INTERNAL INCLUDES
#include <dali/public-api/object/type-registry.h>
+#include <dali/devel-api/common/ref-counted-dali-vector.h>
#include <dali/internal/event/common/thread-local-storage.h>
#include <dali/integration-api/platform-abstraction.h>
namespace
{
+
TypeRegistration mType( typeid( Dali::EncodedBufferImage ), typeid( Dali::Image ), NULL );
+
+/** Raw bytes of a resource laid out exactly as it would be in a file, but in memory. */
+typedef Dali::RefCountedVector<uint8_t> RequestBuffer;
+/** Counting smart pointer for managing a buffer of raw bytes. */
+typedef IntrusivePtr<RequestBuffer> RequestBufferPtr;
+
} // unnamed namespace
EncodedBufferImagePtr EncodedBufferImage::New( const uint8_t * const encodedImage,
//Create texture
Pixel::Format format = bitmap->GetPixelFormat();
- image->mTexture = NewTexture::New( Dali::TextureType::TEXTURE_2D, format, width, height );
+ image->mTexture = Texture::New( Dali::TextureType::TEXTURE_2D, format, width, height );
//Upload data to the texture
size_t bufferSize = bitmap->GetBufferSize();
}
else
{
- image->mTexture = NewTexture::New( Dali::TextureType::TEXTURE_2D, Pixel::RGBA8888, 0u, 0u );
+ image->mTexture = Texture::New( Dali::TextureType::TEXTURE_2D, Pixel::RGBA8888, 0u, 0u );
image->mWidth = image->mHeight = 0u;
}
class EncodedBufferImage;
typedef IntrusivePtr<EncodedBufferImage> EncodedBufferImagePtr;
-class ResourceManager;
-
namespace SceneGraph
{
class UpdateManager;
FrameBufferImagePtr image = new FrameBufferImage( width, height );
image->Initialize();
- image->mTexture = NewTexture::New( Dali::TextureType::TEXTURE_2D, pixelFormat, width, height );
+ image->mTexture = Texture::New( Dali::TextureType::TEXTURE_2D, pixelFormat, width, height );
image->mFrameBufferObject = FrameBuffer::New( width, height, RenderBufferFormatToFrameBufferAttachments[bufferformat] );
image->mFrameBufferObject->AttachColorTexture( image->mTexture, 0u, 0u );
FrameBufferImagePtr image = new FrameBufferImage( nativeImage );
image->Initialize();
- image->mTexture = NewTexture::New( nativeImage );
+ image->mTexture = Texture::New( nativeImage );
image->mFrameBufferObject = FrameBuffer::New( image->mTexture->GetWidth(), image->mTexture->GetHeight(), Dali::FrameBuffer::Attachment::NONE );
image->mFrameBufferObject->AttachColorTexture( image->mTexture, 0u, 0u );
#include <dali/public-api/object/type-registry.h>
#include <dali/integration-api/debug.h>
-#include <dali/internal/event/resources/resource-ticket.h>
#include <dali/internal/event/common/thread-local-storage.h>
#include <dali/internal/event/common/stage-impl.h>
bool Image::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
{
bool connected( true );
- DALI_ASSERT_DEBUG( dynamic_cast<Image*>( object ) && "Resource ticket not ImageTicket subclass for image resource.\n" );
+ DALI_ASSERT_DEBUG( dynamic_cast<Image*>( object ) && "Failed to downcast from BaseObject to Image.\n" );
Image* image = static_cast<Image*>(object);
if( 0 == strcmp( signalName.c_str(), SIGNAL_IMAGE_UPLOADED ) )
return connected;
}
-ResourceId Image::GetResourceId() const
-{
- ResourceId ret = mTicket ? mTicket->GetId() : 0;
-
- return ret;
-}
-
-void Image::ResourceLoadingFailed(const ResourceTicket& ticket)
-{
- // do nothing
-}
-
-void Image::ResourceLoadingSucceeded(const ResourceTicket& ticket)
-{
- // do nothing
-}
-
-void Image::ResourceUploaded(const ResourceTicket& ticket)
-{
- mUploaded.Emit( Dali::Image( this ) );
-}
-
unsigned int Image::GetWidth() const
{
return mWidth;
Image::~Image()
{
- if( mTicket )
- {
- mTicket->RemoveObserver( *this );
- mTicket.Reset();
- }
-
if( Stage::IsInstalled() )
{
UnregisterObject();
#include <dali/public-api/images/image.h>
#include <dali/public-api/object/base-object.h>
#include <dali/internal/event/rendering/texture-impl.h>
-#include <dali/internal/event/resources/resource-client-declarations.h>
-#include <dali/internal/event/resources/resource-ticket-observer.h>
namespace Dali
{
* When the Image object is created, resource loading will be attempted.
* Provided this is successful, the resource will exist until the Image is destroyed.
*/
-class Image : public BaseObject, public ResourceTicketObserver
+class Image : public BaseObject
{
public:
static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
/**
- * returns the Id used for lookups
- * @note if LoadPolicy::OnDemand is used and Image is off Stage, this will return 0.
- * @return the unique ID of the image data resource. This is actually also the same as Dali Texture id.
- */
- ResourceId GetResourceId() const;
-
- /**
* Get the width of the image.
* Only to be used after the image has finished loading.
* (Ticket's LoadingSucceeded callback was called)
/**
* Returns a pointer to the internal texture used by the image
*/
- NewTexture* GetTexture() const
+ Texture* GetTexture() const
{
return mTexture.Get();
}
-public: // From ResourceTicketObserver
-
- /**
- * @copydoc Dali::Internal::ResourceTicketObserver::ResourceLoadingFailed()
- */
- virtual void ResourceLoadingFailed(const ResourceTicket& ticket);
-
- /**
- * @copydoc Dali::Internal::ResourceTicketObserver::ResourceLoadingSucceeded()
- */
- virtual void ResourceLoadingSucceeded(const ResourceTicket& ticket);
-
- /**
- * @copydoc Dali::Internal::ResourceTicketObserver::ResourceUploaded()
- */
- virtual void ResourceUploaded(const ResourceTicket& ticket);
-
public:
/**
protected:
- ResourceTicketPtr mTicket; ///< smart pointer to the ticket object that gets completed when load finishes
- NewTexturePtr mTexture; ///< smart pointer to the texture used by the image
+ TexturePtr mTexture; ///< smart pointer to the texture used by the image
unsigned int mWidth; ///< natural width of the image
unsigned int mHeight; ///< natural height of the image
image->mWidth = resourceData.GetWidth();
image->mHeight = resourceData.GetHeight();
- image->mTexture = NewTexture::New( resourceData );
+ image->mTexture = Texture::New( resourceData );
return image;
}
#include <dali/internal/update/manager/update-manager.h>
#include <dali/integration-api/platform-abstraction.h>
#include <dali/integration-api/resource-types.h>
-#include <dali/integration-api/resource-cache.h>
namespace
mWidth = mBitmap->GetImageWidth();
mHeight = mBitmap->GetImageHeight();
- mTexture = NewTexture::New( Dali::TextureType::TEXTURE_2D, mBitmap->GetPixelFormat(), mWidth, mHeight );
+ mTexture = Texture::New( Dali::TextureType::TEXTURE_2D, mBitmap->GetPixelFormat(), mWidth, mHeight );
size_t bufferSize = mBitmap->GetBufferSize();
unsigned char* buffer = new unsigned char[bufferSize];
class NinePatchImage;
typedef IntrusivePtr<NinePatchImage> NinePatchImagePtr;
-class ResourceManager;
-
namespace SceneGraph
{
class UpdateManager;
bool ResourceImage::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
{
bool connected( true );
- DALI_ASSERT_DEBUG( dynamic_cast<ResourceImage*>( object ) && "Resource ticket not ImageTicket subclass for image resource.\n" );
+ DALI_ASSERT_DEBUG( dynamic_cast<ResourceImage*>( object ) && "Failed to downcast from BaseObject to ResourceImage.\n" );
ResourceImage* image = static_cast<ResourceImage*>(object);
if( 0 == strcmp( signalName.c_str(), SIGNAL_IMAGE_LOADING_FINISHED ) )
//Create texture
Pixel::Format format = bitmap->GetPixelFormat();
- mTexture = NewTexture::New( Dali::TextureType::TEXTURE_2D, format, width, height );
+ mTexture = Texture::New( Dali::TextureType::TEXTURE_2D, format, width, height );
//Upload data to the texture
size_t bufferSize = bitmap->GetBufferSize();
}
else
{
- mTexture = NewTexture::New( Dali::TextureType::TEXTURE_2D, Pixel::RGBA8888, 0u, 0u );
+ mTexture = Texture::New( Dali::TextureType::TEXTURE_2D, Pixel::RGBA8888, 0u, 0u );
mWidth = mHeight = 0u;
mLoadingState = Dali::ResourceLoadingFailed;
}
AddFrameBuffer( mEventThreadServices.GetUpdateManager(), *mRenderObject );
}
-void FrameBuffer::AttachColorTexture( NewTexturePtr texture, unsigned int mipmapLevel, unsigned int layer )
+void FrameBuffer::AttachColorTexture( TexturePtr texture, unsigned int mipmapLevel, unsigned int layer )
{
if( (unsigned int)( texture->GetWidth() / ( 1 << mipmapLevel ) ) == mWidth &&
(unsigned int)( texture->GetHeight() / ( 1 << mipmapLevel ) ) == mHeight )
}
}
-NewTexture* FrameBuffer::GetColorTexture()
+Texture* FrameBuffer::GetColorTexture()
{
return mColor.Get();
}
/**
* @copydoc Dali::FrameBuffer::AttachColorTexture()
*/
- void AttachColorTexture( NewTexturePtr texture, unsigned int mipmapLevel, unsigned int layer );
+ void AttachColorTexture( TexturePtr texture, unsigned int mipmapLevel, unsigned int layer );
/**
* @copydoc Dali::FrameBuffer::GetColorTexture()
*/
- NewTexture* GetColorTexture();
+ Texture* GetColorTexture();
private: // implementation
Internal::EventThreadServices& mEventThreadServices; ///< Used to send messages to the render thread via update thread
Internal::Render::FrameBuffer* mRenderObject; ///< The Render::Texture associated to this texture
- NewTexturePtr mColor;
+ TexturePtr mColor;
unsigned int mWidth;
unsigned int mHeight;
unsigned int mAttachments; ///< Bit-mask of type FrameBuffer::Attachment::Mask
#include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
#include <dali/internal/event/common/thread-local-storage.h>
#include <dali/internal/event/effects/shader-factory.h>
-#include <dali/internal/event/resources/resource-ticket.h>
#include <dali/internal/update/manager/update-manager.h>
namespace Dali
#include <dali/public-api/rendering/shader.h> // Dali::Shader
#include <dali/internal/event/common/object-connector.h> // Dali::Internal::ObjectConnector
#include <dali/internal/event/common/object-impl.h> // Dali::Internal::Object
-#include <dali/internal/event/resources/resource-ticket.h> // Dali::Internal::ResourceTicketPtr
#include <dali/internal/common/shader-data.h> // ShaderPtr
namespace Dali
namespace Internal
{
-NewTexturePtr NewTexture::New(TextureType::Type type, Pixel::Format format, unsigned int width, unsigned int height )
+TexturePtr Texture::New(TextureType::Type type, Pixel::Format format, unsigned int width, unsigned int height )
{
- NewTexturePtr texture( new NewTexture( type, format, width, height ) );
+ TexturePtr texture( new Texture( type, format, width, height ) );
texture->Initialize();
return texture;
}
-NewTexturePtr NewTexture::New( NativeImageInterface& nativeImageInterface )
+TexturePtr Texture::New( NativeImageInterface& nativeImageInterface )
{
- NewTexturePtr texture( new NewTexture( &nativeImageInterface ) );
+ TexturePtr texture( new Texture( &nativeImageInterface ) );
texture->Initialize();
return texture;
}
-Render::NewTexture* NewTexture::GetRenderObject() const
+Render::Texture* Texture::GetRenderObject() const
{
return mRenderObject;
}
-NewTexture::NewTexture(TextureType::Type type, Pixel::Format format, unsigned int width, unsigned int height )
+Texture::Texture(TextureType::Type type, Pixel::Format format, unsigned int width, unsigned int height )
: mEventThreadServices( *Stage::GetCurrent() ),
mRenderObject( NULL ),
mNativeImage(),
{
}
-NewTexture::NewTexture( NativeImageInterfacePtr nativeImageInterface )
+Texture::Texture( NativeImageInterfacePtr nativeImageInterface )
: mEventThreadServices( *Stage::GetCurrent() ),
mRenderObject( NULL ),
mNativeImage( nativeImageInterface ),
{
}
-void NewTexture::Initialize()
+void Texture::Initialize()
{
if( EventThreadServices::IsCoreRunning() )
{
if( mNativeImage )
{
- mRenderObject = new Render::NewTexture( mNativeImage );
+ mRenderObject = new Render::Texture( mNativeImage );
}
else
{
- mRenderObject = new Render::NewTexture( mType, mFormat, mWidth, mHeight );
+ mRenderObject = new Render::Texture( mType, mFormat, mWidth, mHeight );
}
AddTexture( mEventThreadServices.GetUpdateManager(), *mRenderObject );
}
}
-NewTexture::~NewTexture()
+Texture::~Texture()
{
if( EventThreadServices::IsCoreRunning() && mRenderObject )
{
}
}
-bool NewTexture::Upload( PixelDataPtr pixelData )
+bool Texture::Upload( PixelDataPtr pixelData )
{
return Upload( pixelData, 0u, 0u, 0u, 0u, pixelData->GetWidth(), pixelData->GetHeight() );
}
-bool NewTexture::Upload( PixelDataPtr pixelData,
+bool Texture::Upload( PixelDataPtr pixelData,
unsigned int layer, unsigned int mipmap,
unsigned int xOffset, unsigned int yOffset,
unsigned int width, unsigned int height )
return result;
}
-void NewTexture::GenerateMipmaps()
+void Texture::GenerateMipmaps()
{
if( EventThreadServices::IsCoreRunning() && mRenderObject )
{
}
}
-unsigned int NewTexture::GetWidth() const
+unsigned int Texture::GetWidth() const
{
return mWidth;
}
-unsigned int NewTexture::GetHeight() const
+unsigned int Texture::GetHeight() const
{
return mHeight;
}
{
namespace Render
{
-class NewTexture;
+class Texture;
}
-class NewTexture;
-typedef IntrusivePtr<NewTexture> NewTexturePtr;
+class Texture;
+typedef IntrusivePtr<Texture> TexturePtr;
-class NewTexture : public BaseObject
+class Texture : public BaseObject
{
public:
* @param[in] height The height of the texture
* @return A smart-pointer to the newly allocated Texture.
*/
- static NewTexturePtr New(TextureType::Type type, Pixel::Format format, unsigned int width, unsigned int height);
+ static TexturePtr New(TextureType::Type type, Pixel::Format format, unsigned int width, unsigned int height);
/**
* @brief Creates a new Texture from a native image
* @param[in] nativeImageInterface The native image
* @return A smart-pointer to the newly allocated Texture.
*/
- static NewTexturePtr New( NativeImageInterface& nativeImageInterface );
+ static TexturePtr New( NativeImageInterface& nativeImageInterface );
/**
* @brief Get the texture render object
*
* @return the texture render object
*/
- Render::NewTexture* GetRenderObject() const;
+ Render::Texture* GetRenderObject() const;
/**
* @copydoc Dali::Texture::Upload()
* @param[in] width The width of the texture
* @param[in] height The height of the texture
*/
- NewTexture(TextureType::Type type, Pixel::Format format, unsigned int width, unsigned int height );
+ Texture(TextureType::Type type, Pixel::Format format, unsigned int width, unsigned int height );
/**
* Constructor from native image
* @param[in] nativeImageInterface The native image
*/
- NewTexture( NativeImageInterfacePtr nativeImageInterface );
+ Texture( NativeImageInterfacePtr nativeImageInterface );
/**
* Second stage initialization of the Texture
/**
* A reference counted object may only be deleted by calling Unreference()
*/
- virtual ~NewTexture();
+ virtual ~Texture();
private: // unimplemented methods
- NewTexture( const NewTexture& );
- NewTexture& operator=( const NewTexture& );
+ Texture( const Texture& );
+ Texture& operator=( const Texture& );
private: // data
Internal::EventThreadServices& mEventThreadServices; ///<Used to send messages to the render thread via update thread
- Internal::Render::NewTexture* mRenderObject; ///<The Render::Texture associated to this texture
+ Internal::Render::Texture* mRenderObject; ///<The Render::Texture associated to this texture
NativeImageInterfacePtr mNativeImage; ///< Pointer to native image
Dali::TextureType::Type mType; ///< Texture type (cached)
} // namespace Internal
// Helpers for public-api forwarding methods
-inline Internal::NewTexture& GetImplementation(Dali::Texture& handle)
+inline Internal::Texture& GetImplementation(Dali::Texture& handle)
{
DALI_ASSERT_ALWAYS(handle && "Texture handle is empty");
BaseObject& object = handle.GetBaseObject();
- return static_cast<Internal::NewTexture&>(object);
+ return static_cast<Internal::Texture&>(object);
}
-inline const Internal::NewTexture& GetImplementation(const Dali::Texture& handle)
+inline const Internal::Texture& GetImplementation(const Dali::Texture& handle)
{
DALI_ASSERT_ALWAYS(handle && "Texture handle is empty");
const BaseObject& object = handle.GetBaseObject();
- return static_cast<const Internal::NewTexture&>(object);
+ return static_cast<const Internal::Texture&>(object);
}
} // namespace Dali
return textureSet;
}
-void TextureSet::SetTexture( size_t index, NewTexturePtr texture )
+void TextureSet::SetTexture( size_t index, TexturePtr texture )
{
- size_t textureCount( mNewTextures.size() );
+ size_t textureCount( mTextures.size() );
if( index >= textureCount )
{
- mNewTextures.resize(index + 1);
+ mTextures.resize(index + 1);
bool samplerExist = true;
if( mSamplers.size() < index + 1 )
for( size_t i(textureCount); i<=index; ++i )
{
- mNewTextures[i] = NULL;
+ mTextures[i] = NULL;
if( !samplerExist )
{
}
}
- mNewTextures[index]= texture;
+ mTextures[index]= texture;
- Render::NewTexture* renderTexture(0);
+ Render::Texture* renderTexture(0);
if( texture )
{
renderTexture = texture->GetRenderObject();
SceneGraph::SetTextureMessage( mEventThreadServices, *mSceneObject, index, renderTexture );
}
-NewTexture* TextureSet::GetTexture( size_t index ) const
+Texture* TextureSet::GetTexture( size_t index ) const
{
- NewTexture* result(0);
- if( index < mNewTextures.size() )
+ Texture* result(0);
+ if( index < mTextures.size() )
{
- result = mNewTextures[index].Get();
+ result = mTextures[index].Get();
}
else
{
size_t TextureSet::GetTextureCount() const
{
- return mNewTextures.size();
+ return mTextures.size();
}
const SceneGraph::TextureSet* TextureSet::GetTextureSetSceneObject() const
/**
* @copydoc Dali::TextureSet::SetTexture()
*/
- void SetTexture( size_t index, NewTexturePtr texture );
+ void SetTexture( size_t index, TexturePtr texture );
/**
* @copydoc Dali::TextureSet::GetTexture()
*/
- NewTexture* GetTexture( size_t index ) const;
+ Texture* GetTexture( size_t index ) const;
/**
* @copydoc Dali::TextureSet::SetSampler()
EventThreadServices& mEventThreadServices; ///<Used to send messages to the update thread
SceneGraph::TextureSet* mSceneObject;
std::vector<SamplerPtr> mSamplers;
- std::vector<NewTexturePtr> mNewTextures;
+ std::vector<TexturePtr> mTextures;
};
} // namespace Internal
+++ /dev/null
-/*
- * 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.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/event/resources/image-ticket.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-ImageTicket::ImageTicket( ResourceTicketLifetimeObserver& observer, unsigned int id, ResourceTypePath& typePath )
-: ResourceTicket( observer, id, typePath )
-{
-}
-
-int ImageTicket::GetWidth() const
-{
- return mAttributes.GetWidth();
-}
-
-int ImageTicket::GetHeight() const
-{
- return mAttributes.GetHeight();
-}
-
-} // namespace Internal
-
-} // namespace Dali
-
+++ /dev/null
-#ifndef __DALI_INTERNAL_IMAGE_TICKET_H__
-#define __DALI_INTERNAL_IMAGE_TICKET_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/internal/event/resources/resource-ticket.h>
-#include <dali/public-api/images/image.h>
-#include <dali/internal/common/image-attributes.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-class ImageTicket;
-class ResourceManager;
-
-typedef IntrusivePtr<ImageTicket> ImageTicketPtr;
-
-/**
- * ImageTicket is essentially the same as a ResourceTicket,
- * except that it contains additional information about the loaded image resource.
- * The data is the result of the resource loading request.
- *
- * Multi-threading note: this class should be used in the main thread only
- * i.e. not from within Dali::Integration::Core::Render().
- */
-class ImageTicket : public ResourceTicket
-{
-public:
-
- /**
- * Create an image resource request.
- * This should only be done by the ResourceTicketRegistry.
- * @param [in] observer A resource ticket lifetime observer.
- * @param [in] id A unique ID for this ticket (loading request).
- * @param [in] typePath The resource Type & Path pair.
- */
- ImageTicket( ResourceTicketLifetimeObserver& observer, unsigned int id, ResourceTypePath& typePath );
-
- /**
- * Get the attributes of an image.
- * Only to be used after the image has finished loading.
- * (Ticket's LoadingSucceeded callback was called)
- * Reflects the last cached values after a LoadComplete.
- * If requested width or height was 0, they are replaced by concrete dimensions.
- * @return a copy of the image attributes
- */
- const ImageAttributes& GetAttributes() const { return mAttributes;}
-
- /**
- * Get the width of an image.
- * Only to be used after the image has finished loading.
- * (Ticket's LoadingSucceeded callback was called)
- * Reflects the last cached values after a LoadComplete.
- * If requested width or height was 0, they are replaced by concrete dimensions.
- * @return the width
- */
- int GetWidth() const;
-
- /**
- * Get the height of an image.
- * Only to be used after the image has finished loading.
- * (Ticket's LoadingSucceeded callback was called)
- * Reflects the last cached values after a LoadComplete.
- * If requested width or height was 0, they are replaced by concrete dimensions.
- * @return the height
- */
- int GetHeight() const;
-
-protected:
-
- /**
- * A reference counted object may only be deleted by calling Unreference()
- */
- virtual ~ImageTicket()
- {
- }
-
-private:
-
- // Undefined copy constructor.
- ImageTicket(const ImageTicket& typePath);
-
- // Undefined copy constructor.
- ImageTicket& operator=(const ImageTicket& rhs);
-
-private:
-
- /**
- * Loaded Image attributes (width, height, pixelformat etc.).
- * Contains actual values only after the image has finished loading.
- * If requested width or height was 0, the natural size is used.
- */
- ImageAttributes mAttributes;
-};
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_IMAGE_TICKET_H__
+++ /dev/null
-#ifndef __DALI_INTERNAL_RESOURCE_CLIENT_DECLARATIONS_H__
-#define __DALI_INTERNAL_RESOURCE_CLIENT_DECLARATIONS_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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <stdint.h> // for uint32_t
-
-// INTERNAL INCLUDES
-#include <dali/devel-api/common/ref-counted-dali-vector.h>
-#include <dali/integration-api/resource-declarations.h>
-#include <dali/internal/common/type-abstraction.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-typedef Integration::ResourceId ResourceId;
-
-/** Raw bytes of a resource laid out exactly as it wouldbe in a file, but in memory. */
-typedef Dali::RefCountedVector<uint8_t> RequestBuffer;
-/** Counting smart pointer for managing a buffer of raw bytes. */
-typedef IntrusivePtr<RequestBuffer> RequestBufferPtr;
-
-typedef Rect<unsigned int> RectArea;
-
-template <> struct ParameterType< Integration::LoadStatus >
-: public BasicType< Integration::LoadStatus > {};
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_RESOURCE_CLIENT_DECLARATIONS_H__
+++ /dev/null
-#ifndef __DALI_INTERNAL_RESOURCE_TICKET_LIFETIME_OBSERVER_H__
-#define __DALI_INTERNAL_RESOURCE_TICKET_LIFETIME_OBSERVER_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.
- *
- */
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-class ResourceTicket;
-
-/**
- * The ResourceTicketLifetimeObserver observes the lifetime of resource tickets.
- */
-class ResourceTicketLifetimeObserver
-{
-public:
-
- /**
- * Called when a resource ticket is discarded.
- * This occurs during the ResourceTicket destructor.
- * @param[in] ticket The discarded ticket.
- */
- virtual void ResourceTicketDiscarded( const ResourceTicket& ticket ) = 0;
-};
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_RESOURCE_TICKET_LIFETIME_OBSERVER_H__
+++ /dev/null
-#ifndef __DALI_INTERNAL_RESOURCE_TICKET_OBSERVER_H__
-#define __DALI_INTERNAL_RESOURCE_TICKET_OBSERVER_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/object/ref-object.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-class ResourceTicket;
-
-typedef IntrusivePtr<ResourceTicket> ResourceTicketPtr;
-
-/**
- * ResourceTicketObserver is used to observe the status of resource loading requests.
- */
-class ResourceTicketObserver
-{
-public:
-
- /**
- * Called when a resource loads successfully.
- * @param[in] ticket The ticket for this resource.
- */
- virtual void ResourceLoadingSucceeded( const ResourceTicket& ticket ) = 0;
-
- /**
- * Called when a resource fails to load.
- * @param[in] ticket The ticket for this resource.
- */
- virtual void ResourceLoadingFailed( const ResourceTicket& ticket ) = 0;
-
- /**
- * Called when a resource is uploaded to graphics memory.
- * @param[in] ticket The ticket for this resource.
- */
- virtual void ResourceUploaded( const ResourceTicket& ticket ) = 0;
-};
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_RESOURCE_TICKET_OBSERVER_H__
+++ /dev/null
-/*
- * 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.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/event/resources/resource-ticket.h>
-
-// EXTERNAL INCLUDES
-#include <algorithm>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/images/image.h>
-#include <dali/internal/event/common/stage-impl.h>
-#include <dali/internal/event/resources/resource-ticket-observer.h>
-#include <dali/internal/event/resources/resource-ticket-lifetime-observer.h>
-
-namespace // unnamed namespace
-{
-
-// predicate for std::remove_if algorithm for compressing observer list
-bool isNULL(void* ptr)
-{
- return ptr == NULL;
-}
-
-} // unnamed namespace
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-ResourceTicket::ResourceTicket( ResourceTicketLifetimeObserver& observer, unsigned int id, ResourceTypePath& typePath )
-: mLifetimeObserver( &observer ),
- mId( id ),
- mTypePath( typePath ),
- mLoadingState( ResourceLoading )
-{
-}
-
-ResourceTicket::~ResourceTicket()
-{
- // Guard to allow handle destruction after Core has been destroyed
- if ( Stage::IsInstalled() &&
- mLifetimeObserver )
- {
- mLifetimeObserver->ResourceTicketDiscarded( *this );
- }
-}
-
-void ResourceTicket::AddObserver(ResourceTicketObserver& observer)
-{
- mObservers.push_back(&observer);
-}
-
-void ResourceTicket::RemoveObserver(ResourceTicketObserver& observer)
-{
- ObserverIter iter = find(mObservers.begin(), mObservers.end(), &observer);
- DALI_ASSERT_DEBUG( mObservers.end() != iter );
- if( mObservers.end() != iter )
- {
- (*iter) = NULL;
- }
-}
-
-void ResourceTicket::LoadingSucceeded()
-{
- DALI_ASSERT_DEBUG(mLoadingState == ResourceLoading);
-
- mLoadingState = ResourceLoadingSucceeded;
-
- // Using array operator as the call back out to application code might call back in
- // and corrupt the mObservers list. Presumption is the operator gets the current address
- // and adds an offset so a push_back() triggered reallocation should still work.
- size_t count = mObservers.size();
- for(size_t i = 0; i < count; i++)
- {
- if( mObservers[i] != NULL)
- {
- mObservers[i]->ResourceLoadingSucceeded(*this);
- }
- }
-
- // Move NULL pointers to the end...
- ObserverIter endIter = remove_if( mObservers.begin(), mObservers.end(), isNULL );
-
- // ...and remove them
- mObservers.erase( endIter, mObservers.end() );
-}
-
-void ResourceTicket::LoadingFailed()
-{
- DALI_ASSERT_DEBUG(mLoadingState == ResourceLoading);
-
- mLoadingState = ResourceLoadingFailed;
-
- // Using array operator as the call back out to application code might call back in
- // and corrupt the mObservers list. Presumption is the operator gets the current address
- // and adds an offset so a push_back() triggered reallocation should still work.
- size_t count = mObservers.size();
- for(size_t i = 0; i < count; i++)
- {
- if( mObservers[i] != NULL)
- {
- mObservers[i]->ResourceLoadingFailed(*this);
- }
- }
-
- // Move NULL pointers to the end...
- ObserverIter endIter = remove_if( mObservers.begin(), mObservers.end(), isNULL );
-
- // ...and remove them
- mObservers.erase( endIter, mObservers.end() );
-}
-
-void ResourceTicket::Loading()
-{
- mLoadingState = ResourceLoading;
-
- // Move NULL pointers to the end...
- ObserverIter endIter = remove_if( mObservers.begin(), mObservers.end(), isNULL );
-
- // ...and remove them
- mObservers.erase( endIter, mObservers.end() );
-}
-
-void ResourceTicket::Uploaded()
-{
- // Using array operator as the call back out to application code might call back in
- // and corrupt the mObservers list. Presumption is the operator gets the current address
- // and adds an offset so a push_back() triggered reallocation should still work.
- size_t count = mObservers.size();
- for(size_t i = 0; i < count; i++)
- {
- if( mObservers[i] != NULL)
- {
- mObservers[i]->ResourceUploaded(*this);
- }
- }
-
- // Move NULL pointers to the end...
- ObserverIter endIter = remove_if( mObservers.begin(), mObservers.end(), isNULL );
-
- // ...and remove them
- mObservers.erase( endIter, mObservers.end() );
-}
-
-void ResourceTicket::StopLifetimeObservation()
-{
- mLifetimeObserver = NULL;
-}
-
-} // namespace Internal
-
-} // namespace Dali
-
+++ /dev/null
-#ifndef __DALI_INTERNAL_RESOURCE_TICKET_H__
-#define __DALI_INTERNAL_RESOURCE_TICKET_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>
-#include <dali/devel-api/common/map-wrapper.h>
-#include <dali/public-api/common/loading-state.h>
-#include <dali/public-api/object/ref-object.h>
-#include <dali/internal/event/resources/resource-type-path.h>
-#include <dali/integration-api/resource-cache.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-class ResourceTicket;
-typedef IntrusivePtr<ResourceTicket> ResourceTicketPtr;
-typedef std::vector<ResourceTicketPtr> ResourceTicketContainer;
-
-class ResourceTicketObserver;
-class ResourceTicketLifetimeObserver;
-
-/**
- * @brief ResourceTicket records the lifetime of a resource loading request.
- *
- * When a resource is requested from ResourceClient, you get a ticket.
- * The state of the loading operation, can be observed using the ticket.
- * After the ticket is destroyed, the resource will be discarded.
- *
- * Multi-threading note: this class should be used in the main thread only
- * i.e. not from within Dali::Integration::Core::Render().
- */
-class ResourceTicket : public RefObject
-{
-public:
-
- /**
- * Create a resource request.
- * This should only be done by the ResourceTicketRegistry.
- * @param [in] observer The object which observes ticket lifetimes.
- * @param [in] id A unique ID for this ticket (loading request).
- * @param [in] typePath The resource Type & Path pair.
- */
- ResourceTicket( ResourceTicketLifetimeObserver& observer, unsigned int id, ResourceTypePath& typePath );
-
- /**
- * Retrieve the unique ID of the resource request.
- * This can be shared with Nodes etc. which will require the resource when rendering.
- * @return The unique ID for this request.
- */
- unsigned int GetId() const { return mId; }
-
- /**
- * Retrieve the type and path of the resource request.
- * @return The type and path.
- */
- const ResourceTypePath& GetTypePath() const { return mTypePath; }
-
- /**
- * Query the state of the resource loading request.
- * @return The state.
- */
- Dali::LoadingState GetLoadingState() const { return mLoadingState; }
-
- /**
- * Adds an observer.
- * @param[in] observer The observer.
- */
- void AddObserver(ResourceTicketObserver& observer);
-
- /**
- * Removes an observer.
- * @param[in] observer The observer.
- */
- void RemoveObserver(ResourceTicketObserver& observer);
-
-public: // Used by the ResourceClient
-
- /**
- * Called when a resource loads successfully.
- * The ResourceTicketObservers will be notified.
- */
- void LoadingSucceeded();
-
- /**
- * Called when a resource fails to load.
- * The ResourceTicketObservers will be notified.
- */
- void LoadingFailed();
-
- /**
- * Reset state to ResourceLoading.
- */
- void Loading();
-
- /**
- * Notification when a resource has been uploaded to GL.
- * The ResourceTicketObservers will be notified.
- */
- void Uploaded();
-
- /**
- * Called when the ResourceTicketLifetimeObserver is being destroyed.
- * This method should only be called during destruction of the Dali core.
- */
- void StopLifetimeObservation();
-
-protected:
-
- /**
- * A reference counted object may only be deleted by calling Unreference()
- */
- virtual ~ResourceTicket();
-
-private:
-
- /**
- * Undefined copy constructor.
- */
- ResourceTicket(const ResourceTicket&);
-
- /**
- * Undefined assignment operator.
- */
- ResourceTicket& operator=(const ResourceTicket& rhs);
-
-private:
-
- ResourceTicketLifetimeObserver* mLifetimeObserver; ///< reference to the lifetime-observer; not owned
-
- unsigned int mId;
- ResourceTypePath mTypePath;
-
- Dali::LoadingState mLoadingState;
-
- // These ticket observers are not owned by the ticket.
- // Observers must remove themselves by calling RemoveObserver e.g. during destruction.
- typedef std::vector<ResourceTicketObserver*> ObserverContainer;
- typedef ObserverContainer::iterator ObserverIter;
-
- ObserverContainer mObservers;
-};
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_RESOURCE_MANAGER_H__
+++ /dev/null
-/*
- * 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.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/event/resources/resource-type-path.h>
-
-using namespace Dali::Integration;
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace
-{
-
-/**
- * @brief Compare two sets of image loading parameters for equality.
- */
-inline bool AttributesEqual( ImageDimensions aDims, FittingMode::Type aScaling, SamplingMode::Type aSampling, bool aOrient, ImageDimensions bDims, FittingMode::Type bScaling, SamplingMode::Type bSampling, bool bOrient )
-{
- return aDims == bDims &&
- aScaling == bScaling &&
- aSampling == bSampling &&
- aOrient == bOrient;
-}
-
-/**
- * @brief Compare two sets of image loading parameters
- * @pre The two sets are not identical.
- */
-inline bool AttributesLessAssumingNotEqual( ImageDimensions aDims, FittingMode::Type aScaling, SamplingMode::Type aSampling, bool aOrient, ImageDimensions bDims, FittingMode::Type bScaling, SamplingMode::Type bSampling, bool bOrient )
-{
- return aDims < bDims &&
- aScaling < bScaling &&
- aSampling < bSampling &&
- aOrient < bOrient;
-}
-
-/**
- * Compare two resource types.
- * @return zero if the types are equal,
- * less than zero if lhs < rhs or
- * greater than zero if lhs > rhs
- */
-int ResourceTypeCompare(const ResourceType& lhs, const ResourceType& rhs)
-{
- int result = 0;
-
- if (lhs.id != rhs.id)
- {
- result = lhs.id > rhs.id ? 1 : -1;
- }
- else // lhs.id == rhs.id
- {
- // Cast to a derived resource type and compare...
-
- switch (lhs.id)
- {
- case ResourceBitmap:
- {
- // compare bitmap widths & heights
- const BitmapResourceType& lhsBitmap = static_cast<const BitmapResourceType&>(lhs);
- const BitmapResourceType& rhsBitmap = static_cast<const BitmapResourceType&>(rhs);
-
- if( ! AttributesEqual( lhsBitmap.size, lhsBitmap.scalingMode, lhsBitmap.samplingMode, lhsBitmap.orientationCorrection,
- rhsBitmap.size, rhsBitmap.scalingMode, rhsBitmap.samplingMode, rhsBitmap.orientationCorrection ) )
- {
- result = AttributesLessAssumingNotEqual( lhsBitmap.size, lhsBitmap.scalingMode, lhsBitmap.samplingMode, lhsBitmap.orientationCorrection,
- rhsBitmap.size, rhsBitmap.scalingMode, rhsBitmap.samplingMode, rhsBitmap.orientationCorrection );
- }
- // else result = 0
- break;
- }
-
- case ResourceNativeImage:
- {
- // compare native image widths & heights
-
- const NativeImageResourceType& lhsNativeImage = static_cast<const NativeImageResourceType&>(lhs);
- const NativeImageResourceType& rhsNativeImage = static_cast<const NativeImageResourceType&>(rhs);
-
- if (lhsNativeImage.imageDimensions != rhsNativeImage.imageDimensions)
- {
- result = lhsNativeImage.imageDimensions < rhsNativeImage.imageDimensions ? -1 : 1;
- }
- // else result = 0
- break;
- }
-
- case ResourceTargetImage:
- {
- // compare bitmap widths & heights
- const RenderTargetResourceType& lhsImage = static_cast<const RenderTargetResourceType&>(lhs);
- const RenderTargetResourceType& rhsImage = static_cast<const RenderTargetResourceType&>(rhs);
-
- if (lhsImage.imageDimensions != rhsImage.imageDimensions)
- {
- result = lhsImage.imageDimensions < rhsImage.imageDimensions ? -1 : 1;
- }
- // else result = 0
- break;
- }
- }
- }
- return result;
-}
-}
-
-bool ResourceTypePath::operator<(const ResourceTypePath& rhs) const
-{
- int typeComparison = ResourceTypeCompare(*type, *(rhs.type));
-
- if (typeComparison != 0)
- {
- return (typeComparison < 0);
- }
- else
- {
- return path < rhs.path;
- }
-}
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_RESOURCE_TYPE_PATH_H__
-#define __DALI_INTERNAL_RESOURCE_TYPE_PATH_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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <memory>
-// INTERNAL INCLUDES
-#include <dali/integration-api/resource-types.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-/**
- * A resource Type & Path pair. This is used by ResourceManager when creating tickets.
- * A new ticket will only be needed, if the same resource Type & Path has not already been requested.
- */
-class ResourceTypePath
-{
-public:
-
- /**
- * Create a resource Type and Path pair.
- * @param[in] requestType The type of resource.
- * @param[in] requestPath The path of the resource.
- */
- ResourceTypePath(const Integration::ResourceType& requestType,
- const std::string& requestPath)
- : type(requestType.Clone()),
- path(requestPath)
- {
- }
-
- /**
- * Copy constructor.
- * @param[in] typePath The Type & Path to copy.
- */
- ResourceTypePath(const ResourceTypePath& typePath)
- : type(typePath.type->Clone()),
- path(typePath.path)
- {
- }
-
- ~ResourceTypePath()
- {
- delete type;
- }
-
- /**
- * Less than operator.
- * @param[in] rhs The request to compare with.
- */
- bool operator<(const ResourceTypePath& rhs) const;
-
-private:
-
- /**
- * Undefined assignment operator.
- * @param[in] rhs The resource request to copy.
- */
- ResourceTypePath& operator=(const ResourceTypePath& rhs);
-
-public:
-
- const Integration::ResourceType* type;
- const std::string path;
-};
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_RESOURCE_TYPE_PATH_H__
$(internal_src_dir)/event/rendering/renderer-impl.cpp \
$(internal_src_dir)/event/rendering/sampler-impl.cpp \
$(internal_src_dir)/event/rendering/shader-impl.cpp \
- $(internal_src_dir)/event/resources/image-ticket.cpp \
- $(internal_src_dir)/event/resources/resource-ticket.cpp \
- $(internal_src_dir)/event/resources/resource-type-path.cpp \
$(internal_src_dir)/event/size-negotiation/memory-pool-relayout-container.cpp \
$(internal_src_dir)/event/size-negotiation/relayout-controller-impl.cpp \
\
$(internal_src_dir)/render/common/render-tracker.cpp \
$(internal_src_dir)/render/common/render-manager.cpp \
$(internal_src_dir)/render/data-providers/render-data-provider.cpp \
- $(internal_src_dir)/render/gl-resources/bitmap-texture.cpp \
$(internal_src_dir)/render/gl-resources/context.cpp \
$(internal_src_dir)/render/gl-resources/frame-buffer-state-cache.cpp \
- $(internal_src_dir)/render/gl-resources/compressed-bitmap-texture.cpp \
- $(internal_src_dir)/render/gl-resources/frame-buffer-texture.cpp \
$(internal_src_dir)/render/gl-resources/gl-call-debug.cpp \
$(internal_src_dir)/render/gl-resources/gpu-buffer.cpp \
- $(internal_src_dir)/render/gl-resources/native-texture.cpp \
- $(internal_src_dir)/render/gl-resources/gl-texture.cpp \
- $(internal_src_dir)/render/gl-resources/texture-factory.cpp \
- $(internal_src_dir)/render/gl-resources/texture-cache.cpp \
$(internal_src_dir)/render/queue/render-queue.cpp \
$(internal_src_dir)/render/renderers/render-frame-buffer.cpp \
$(internal_src_dir)/render/renderers/render-geometry.cpp \
$(internal_src_dir)/update/common/scene-graph-buffers.cpp \
$(internal_src_dir)/update/common/scene-graph-connection-change-propagator.cpp \
$(internal_src_dir)/update/common/scene-graph-property-notification.cpp \
- $(internal_src_dir)/update/common/texture-cache-dispatcher.cpp \
$(internal_src_dir)/update/common/uniform-map.cpp \
$(internal_src_dir)/update/controllers/render-message-dispatcher.cpp \
$(internal_src_dir)/update/controllers/scene-controller-impl.cpp \
$(internal_src_dir)/update/render-tasks/scene-graph-render-task.cpp \
$(internal_src_dir)/update/render-tasks/scene-graph-render-task-list.cpp \
$(internal_src_dir)/update/rendering/scene-graph-texture-set.cpp \
- $(internal_src_dir)/update/rendering/scene-graph-renderer.cpp \
- $(internal_src_dir)/update/resources/resource-manager.cpp
+ $(internal_src_dir)/update/rendering/scene-graph-renderer.cpp
inline void ProcessRenderList(
const RenderList& renderList,
Context& context,
- SceneGraph::TextureCache& textureCache,
SceneGraph::Shader& defaultShader,
BufferIndex bufferIndex,
const Matrix& viewMatrix,
// Render the item
item.mRenderer->Render( context,
- textureCache,
bufferIndex,
*item.mNode,
defaultShader,
void ProcessRenderInstruction( const RenderInstruction& instruction,
Context& context,
- SceneGraph::TextureCache& textureCache,
SceneGraph::Shader& defaultShader,
BufferIndex bufferIndex )
{
{
ProcessRenderList( *renderList,
context,
- textureCache,
defaultShader,
bufferIndex,
*viewMatrix,
* Process a render-instruction.
* @param[in] instruction The render-instruction to process.
* @param[in] context The GL context.
- * @param[in] textureCache The texture cache used to get textures.
* @param[in] defaultShader The default shader.
* @param[in] bufferIndex The current render buffer index (previous update buffer)
*/
void ProcessRenderInstruction( const SceneGraph::RenderInstruction& instruction,
Context& context,
- SceneGraph::TextureCache& textureCache,
SceneGraph::Shader& defaultShader,
BufferIndex bufferIndex );
#include <dali/internal/render/common/render-instruction-container.h>
#include <dali/internal/render/common/render-instruction.h>
#include <dali/internal/render/gl-resources/context.h>
-#include <dali/internal/render/gl-resources/frame-buffer-texture.h>
-#include <dali/internal/render/gl-resources/texture-cache.h>
#include <dali/internal/render/queue/render-queue.h>
#include <dali/internal/render/renderers/render-frame-buffer.h>
#include <dali/internal/render/renderers/render-geometry.h>
typedef OwnerContainer< Render::Sampler* > SamplerOwnerContainer;
typedef SamplerOwnerContainer::Iterator SamplerOwnerIter;
-typedef OwnerContainer< Render::NewTexture* > TextureOwnerContainer;
+typedef OwnerContainer< Render::Texture* > TextureOwnerContainer;
typedef TextureOwnerContainer::Iterator TextureOwnerIter;
typedef OwnerContainer< Render::FrameBuffer* > FrameBufferOwnerContainer;
struct RenderManager::Impl
{
Impl( Integration::GlAbstraction& glAbstraction,
- Integration::GlSyncAbstraction& glSyncAbstraction,
- LockedResourceQueue& textureUploadedQ,
- TextureUploadedDispatcher& postProcessDispatcher )
+ Integration::GlSyncAbstraction& glSyncAbstraction )
: context( glAbstraction ),
glSyncAbstraction( glSyncAbstraction ),
renderQueue(),
- textureCache( renderQueue, postProcessDispatcher, context ),
- textureUploadedQueue( textureUploadedQ ),
instructions(),
backgroundColor( Dali::Stage::DEFAULT_BACKGROUND_COLOR ),
frameCount( 0 ),
Context context; ///< holds the GL state
Integration::GlSyncAbstraction& glSyncAbstraction; ///< GL sync abstraction
RenderQueue renderQueue; ///< A message queue for receiving messages from the update-thread.
- TextureCache textureCache; ///< Cache for all GL textures
- LockedResourceQueue& textureUploadedQueue; ///< A queue for requesting resource post processing in update thread
// Render instructions describe what should be rendered during RenderManager::Render()
// Owned by RenderManager. Update manager updates instructions for the next frame while we render the current one
};
RenderManager* RenderManager::New( Integration::GlAbstraction& glAbstraction,
- Integration::GlSyncAbstraction& glSyncAbstraction,
- LockedResourceQueue& textureUploadedQ )
+ Integration::GlSyncAbstraction& glSyncAbstraction )
{
RenderManager* manager = new RenderManager;
manager->mImpl = new Impl( glAbstraction,
- glSyncAbstraction,
- textureUploadedQ,
- *manager );
+ glSyncAbstraction );
return manager;
}
return mImpl->renderQueue;
}
-TextureCache& RenderManager::GetTextureCache()
-{
- return mImpl->textureCache;
-}
-
void RenderManager::ContextCreated()
{
mImpl->context.GlContextCreated();
mImpl->context.GlContextDestroyed();
mImpl->programController.GlContextDestroyed();
- // inform texture cache
- mImpl->textureCache.GlContextDestroyed(); // Clears gl texture ids
-
//Inform textures
for( TextureOwnerIter iter = mImpl->textureContainer.Begin(); iter != mImpl->textureContainer.End(); ++iter )
{
}
}
-void RenderManager::DispatchTextureUploaded(ResourceId request)
-{
- mImpl->textureUploadedQueue.PushBack( request );
-}
-
void RenderManager::SetShaderSaver( ShaderSaver& upstream )
{
mImpl->programController.SetShaderSaver( upstream );
void RenderManager::AddRenderer( Render::Renderer* renderer )
{
// Initialize the renderer as we are now in render thread
- renderer->Initialize( mImpl->context, mImpl->textureCache );
+ renderer->Initialize( mImpl->context );
mImpl->rendererContainer.PushBack( renderer );
}
}
-void RenderManager::AddTexture( Render::NewTexture* texture )
+void RenderManager::AddTexture( Render::Texture* texture )
{
mImpl->textureContainer.PushBack( texture );
texture->Initialize(mImpl->context);
}
-void RenderManager::RemoveTexture( Render::NewTexture* texture )
+void RenderManager::RemoveTexture( Render::Texture* texture )
{
DALI_ASSERT_DEBUG( NULL != texture );
}
}
-void RenderManager::UploadTexture( Render::NewTexture* texture, PixelDataPtr pixelData, const NewTexture::UploadParams& params )
+void RenderManager::UploadTexture( Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params )
{
texture->Upload( mImpl->context, pixelData, params );
}
-void RenderManager::GenerateMipmaps( Render::NewTexture* texture )
+void RenderManager::GenerateMipmaps( Render::Texture* texture )
{
texture->GenerateMipmaps( mImpl->context );
}
}
}
-void RenderManager::AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::NewTexture* texture, unsigned int mipmapLevel, unsigned int layer )
+void RenderManager::AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, unsigned int mipmapLevel, unsigned int layer )
{
frameBuffer->AttachColorTexture( mImpl->context, texture, mipmapLevel, layer );
}
DALI_PRINT_RENDER_END();
- // check if anything has been posted to the update thread, if IsEmpty then no update required.
- return !mImpl->textureUploadedQueue.IsEmpty();
+ return false;
}
void RenderManager::DoRender( RenderInstruction& instruction, Shader& defaultShader )
clearColor = Dali::RenderTask::DEFAULT_CLEAR_COLOR;
}
- FrameBufferTexture* offscreen = NULL;
-
if( instruction.mFrameBuffer != 0 )
{
instruction.mFrameBuffer->Bind( mImpl->context );
Render::ProcessRenderInstruction( instruction,
mImpl->context,
- mImpl->textureCache,
defaultShader,
mImpl->renderBufferIndex );
- if( instruction.mRenderTracker && ( offscreen != NULL || instruction.mFrameBuffer != NULL ) )
+ if( instruction.mRenderTracker && ( instruction.mFrameBuffer != NULL ) )
{
// This will create a sync object every frame this render tracker
// is alive (though it should be now be created only for
// INTERNAL INCLUDES
#include <dali/public-api/math/rect.h>
#include <dali/internal/common/shader-saver.h>
-#include <dali/internal/update/resources/resource-manager-declarations.h>
-#include <dali/internal/render/common/texture-uploaded-dispatcher.h>
#include <dali/internal/render/gl-resources/gpu-buffer.h>
#include <dali/internal/render/renderers/render-property-buffer.h>
#include <dali/internal/event/rendering/texture-impl.h>
struct Sampler;
class RenderTracker;
class Geometry;
-class NewTexture;
+class Texture;
}
namespace SceneGraph
{
class RenderQueue;
-class TextureCache;
class RenderInstruction;
class RenderInstructionContainer;
class Shader;
* RenderManager is responsible for rendering the result of the previous "update", which
* is provided in a RenderCommand during UpdateManager::Update().
*/
-class RenderManager : public TextureUploadedDispatcher
+class RenderManager
{
public:
* @param[out] resourcePostProcessQueue A queue for sending rendered texture ids to the update-thread.*
*/
static RenderManager* New( Integration::GlAbstraction& glAbstraction,
- Integration::GlSyncAbstraction& glSyncAbstraction,
- LockedResourceQueue& resourcePostProcessQueue );
+ Integration::GlSyncAbstraction& glSyncAbstraction );
/**
* Non-virtual destructor; not intended as a base class
RenderQueue& GetRenderQueue();
/**
- * Retrieve the texture cache. Messages should only be sent to this from the update thread,
- * accessor methods should only be used from the render thread.
- * @return The texture cache
- */
- TextureCache& GetTextureCache();
-
- /**
* @copydoc Dali::Integration::Core::ContextCreated()
*/
void ContextCreated();
void ContextDestroyed();
/**
- * Dispatch requests onto the postProcessResourcesQueue
- * @param[in] resource The Id of the resource to dispatch
- */
- virtual void DispatchTextureUploaded( ResourceId resource );
-
- /**
* Set the upstream interface for compiled shader binaries to be sent back to for eventual
* caching and saving.
* @param[in] upstream The abstract interface to send any received ShaderDatas onwards to..
* Adds a texture to the render manager
* @param[in] texture The texture to add
*/
- void AddTexture( Render::NewTexture* texture );
+ void AddTexture( Render::Texture* texture );
/**
* Removes a texture from the render manager
* @param[in] texture The texture to remove
*/
- void RemoveTexture( Render::NewTexture* texture );
+ void RemoveTexture( Render::Texture* texture );
/**
* Uploads data to an existing texture
* @param[in] pixelData The pixel data object
* @param[in] params The parameters for the upload
*/
- void UploadTexture( Render::NewTexture* texture, PixelDataPtr pixelData, const NewTexture::UploadParams& params );
+ void UploadTexture( Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params );
/**
* Generates mipmaps for a given texture
* @param[in] texture The texture
*/
- void GenerateMipmaps( Render::NewTexture* texture );
+ void GenerateMipmaps( Render::Texture* texture );
/**
* Adds a framebuffer to the render manager
* @param[in] mipmapLevel The mipmap of the texture to be attached
* @param[in] layer Indicates which layer of a cube map or array texture to attach. Unused for 2D textures
*/
- void AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::NewTexture* texture, unsigned int mipmapLevel, unsigned int layer );
+ void AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, unsigned int mipmapLevel, unsigned int layer );
/**
* Adds a render tracker to the RenderManager. RenderManager takes ownership of the
+++ /dev/null
-#ifndef __DALI_INTERNAL_SCENE_GRAPH_POST_PROCESS_RESOURCE_DISPATCHER_H__
-#define __DALI_INTERNAL_SCENE_GRAPH_POST_PROCESS_RESOURCE_DISPATCHER_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/integration-api/resource-declarations.h>
-
-namespace Dali
-{
-namespace Internal
-{
-typedef Integration::ResourceId ResourceId;
-
-namespace SceneGraph
-{
-
-/**
- * Interface which offers a dispatch mechanism for uploaded notifications on textures
- * Should be offered by a Render Thread object
- */
-class TextureUploadedDispatcher
-{
-public:
- /**
- * Dispatch a post process resource uploaded request to the Update thread
- * @param[in] resource A post process request
- */
- virtual void DispatchTextureUploaded( ResourceId resource ) = 0;
-
-protected:
- /**
- * Virtual destructor
- */
- virtual ~TextureUploadedDispatcher(){}
-};
-
-
-} // namespaces
-}
-}
-
-
-#endif // __DALI_INTERNAL_SCENE_GRAPH_POST_PROCESS_RESOURCE_DISPATCHER_H__
return mSamplers;
}
-std::vector<Render::NewTexture*>& RenderDataProvider::GetNewTextures()
+std::vector<Render::Texture*>& RenderDataProvider::GetTextures()
{
- return mNewTextures;
+ return mTextures;
}
} // SceneGraph
Samplers& GetSamplers();
/**
- * Returns the list of NewTextures
- * @return The list of NewTextures
+ * Returns the list of Textures
+ * @return The list of Textures
*/
- std::vector<Render::NewTexture*>& GetNewTextures();
+ std::vector<Render::Texture*>& GetTextures();
private:
const UniformMapDataProvider* mUniformMapDataProvider;
Shader* mShader;
- std::vector<Render::NewTexture*> mNewTextures;
+ std::vector<Render::Texture*> mTextures;
Samplers mSamplers;
// Give Renderer access to our private data to reduce copying vectors on construction.
+++ /dev/null
-/*
- * Copyright (c) 2016 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.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/render/gl-resources/bitmap-texture.h>
-
-// EXTERNAL INCLUDES
-#include <cstring>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/common/dali-vector.h>
-#include <dali/public-api/images/buffer-image.h> // For PixelBuffer
-#include <dali/integration-api/debug.h>
-#include <dali/internal/render/common/performance-monitor.h>
-#include <dali/internal/render/gl-resources/context.h>
-#include <dali/internal/render/gl-resources/texture-units.h>
-
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-BitmapTexture::BitmapTexture(
- Integration::Bitmap* const bitmap,
- const Integration::Bitmap::PackedPixelsProfile * const bitmapPackedPixelsProfile,
- Context& context,
- ResourcePolicy::Discardable policy)
-: Texture( context,
- bitmapPackedPixelsProfile->GetBufferWidth(),
- bitmapPackedPixelsProfile->GetBufferHeight(),
- bitmap->GetImageWidth(),
- bitmap->GetImageHeight()),
- mBitmap(bitmap),
- mPixelFormat(bitmap->GetPixelFormat()),
- mDiscardPolicy(policy),
- mClearPixels(false)
-{
- DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
- DALI_LOG_SET_OBJECT_STRING(this, DALI_LOG_GET_OBJECT_STRING(bitmap));
-}
-
-BitmapTexture::BitmapTexture(
- unsigned int width,
- unsigned int height,
- Pixel::Format pixelFormat,
- bool clearPixels,
- Context& context,
- ResourcePolicy::Discardable policy)
-: Texture( context,
- width, height,
- width, height),
- mBitmap(NULL),
- mPixelFormat( pixelFormat ),
- mDiscardPolicy(policy),
- mClearPixels(clearPixels)
-{
- DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
-}
-
-BitmapTexture::~BitmapTexture()
-{
- DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
-
- // GlCleanup() should already have been called by TextureCache ensuring the resource is destroyed
- // on the render thread. (And avoiding a potentially problematic virtual call in the destructor)
-}
-
-bool BitmapTexture::HasAlphaChannel() const
-{
- return Pixel::HasAlpha(mPixelFormat);
-}
-
-bool BitmapTexture::IsFullyOpaque() const
-{
- if( mBitmap )
- {
- return mBitmap->IsFullyOpaque();
- }
- else
- {
- return ! HasAlphaChannel(); // Todo: amalgamate updated bitmap's IsFullyOpaque()
- }
-}
-
-// Bitmap buffer has been changed. Upload changes to GPU.
-void BitmapTexture::AreaUpdated( const RectArea& updateArea, const unsigned char* pixels )
-{
- 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);
-
- if( ! updateArea.IsEmpty() )
- {
- mContext.PixelStorei( GL_UNPACK_ALIGNMENT, 1 ); // We always use tightly packed data
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::General, "Update x:%d y:%d w:%d h:%d\n",
- updateArea.x, updateArea.y, updateArea.width ,updateArea.height );
-
- const unsigned int pitchPixels = mWidth;
- const unsigned int pixelDepth = Dali::Pixel::GetBytesPerPixel( mPixelFormat );
-
- // If the width of the source update area is the same as the pitch, then can
- // copy the contents in a single contiguous TexSubImage call.
- if(updateArea.x == 0 && updateArea.width == pitchPixels)
- {
- pixels += updateArea.y * pitchPixels * pixelDepth;
- mContext.TexSubImage2D( GL_TEXTURE_2D,0, updateArea.x, updateArea.y,
- updateArea.width, updateArea.height,
- pixelFormat, pixelDataType, pixels );
- }
- else
- {
- // Otherwise the source buffer needs to be copied line at a time, as OpenGL ES
- // does not support source strides. (no GL_UNPACK_ROW_LENGTH supported)
- unsigned int yBottom = updateArea.y + updateArea.height;
- pixels += (updateArea.y * pitchPixels + updateArea.x) * pixelDepth;
-
- for(unsigned int y = updateArea.y; y < yBottom; y++)
- {
- mContext.TexSubImage2D( GL_TEXTURE_2D,0, updateArea.x, y,
- updateArea.width, 1,
- pixelFormat, pixelDataType, pixels );
- pixels += pitchPixels * pixelDepth;
- }
- }
-
- INCREASE_BY( PerformanceMonitor::TEXTURE_DATA_UPLOADED,
- updateArea.Area()* GetBytesPerPixel( mPixelFormat ));
- }
-}
-
-void BitmapTexture::AssignBitmap( bool generateTexture, const unsigned char* pixels )
-{
- DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
- DALI_LOG_INFO(Debug::Filter::gGLResource, Debug::Verbose, "BitmapTexture::AssignBitmap()\n");
-
- GLenum pixelFormat = GL_RGBA;
- GLenum pixelDataType = GL_UNSIGNED_BYTE;
-
- if( generateTexture )
- {
- mContext.GenTextures(1, &mId);
- }
- DALI_ASSERT_DEBUG( mId != 0 );
-
- mContext.ActiveTexture( TEXTURE_UNIT_UPLOAD );
- mContext.Bind2dTexture(mId);
- Integration::ConvertToGlFormat(mPixelFormat, pixelDataType, pixelFormat);
-
- mContext.PixelStorei(GL_UNPACK_ALIGNMENT, 1); // We always use tightly packed data
- mContext.TexImage2D(GL_TEXTURE_2D, 0, pixelFormat, mWidth, mHeight, 0, pixelFormat, pixelDataType, pixels);
- 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);
-
- // If the resource policy is to discard on upload then release buffer
- DiscardBitmapBuffer();
-
- if( pixels != NULL )
- {
- INCREASE_BY( PerformanceMonitor::TEXTURE_DATA_UPLOADED, GetBytesPerPixel(mPixelFormat) * mWidth * mHeight );
- }
-}
-
-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.\n" );
- 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.\n");
- return;
- }
- mBitmap = bitmap;
-
- const unsigned char* pixels = mBitmap->GetBuffer();
-
- // We should never have null pixel data here - resource manager has deliberately loaded/reloaded data
-
- DALI_ASSERT_DEBUG( pixels != NULL );
-
- if( NULL == pixels )
- {
- DALI_LOG_ERROR("BitmapTexture::Upload() - Bitmap has no pixel data.\n");
- }
- else if( mId != 0 )
- {
- if( mImageWidth == mBitmap->GetImageWidth() &&
- mImageHeight == mBitmap->GetImageHeight() &&
- mWidth == bitmapPackedPixels->GetBufferWidth() &&
- mHeight == bitmapPackedPixels->GetBufferHeight() &&
- mPixelFormat == mBitmap->GetPixelFormat() ) // and size hasn't changed
- {
- RectArea area(0, 0, mImageWidth, mImageHeight); // just update whole texture
- AreaUpdated( area, pixels );
- DiscardBitmapBuffer();
- }
- else // Otherwise, reload the pixel data
- {
- mImageWidth = mBitmap->GetImageWidth();
- mImageHeight = mBitmap->GetImageHeight();
- mWidth = bitmapPackedPixels->GetBufferWidth();
- mHeight = bitmapPackedPixels->GetBufferHeight();
- mPixelFormat = mBitmap->GetPixelFormat();
-
- AssignBitmap( false, pixels );
- }
- }
-}
-
-void BitmapTexture::Update( Integration::Bitmap* srcBitmap, std::size_t xOffset, std::size_t yOffset )
-{
- if( NULL != srcBitmap )
- {
- Update( srcBitmap->GetBuffer(), srcBitmap->GetImageWidth(), srcBitmap->GetImageHeight(),
- srcBitmap->GetPixelFormat(), xOffset, yOffset);
- }
-}
-
-void BitmapTexture::Update( PixelData* srcPixelData, std::size_t xOffset, std::size_t yOffset )
-{
- if( NULL != srcPixelData )
- {
- Update( srcPixelData->GetBuffer(), srcPixelData->GetWidth(), srcPixelData->GetHeight(),
- srcPixelData->GetPixelFormat(), xOffset, yOffset);
- }
-}
-
-void BitmapTexture::Update( const unsigned char* pixels, std::size_t width, std::size_t height, Pixel::Format pixelFormat, std::size_t xOffset, std::size_t yOffset )
-{
-
- GLenum pixelGLFormat = GL_RGBA;
- GLenum pixelDataType = GL_UNSIGNED_BYTE;
- Integration::ConvertToGlFormat( mPixelFormat, pixelDataType, pixelGLFormat );
-
- if( !mId )
- {
- mContext.GenTextures( 1, &mId );
-
- mContext.ActiveTexture( TEXTURE_UNIT_UPLOAD );
- mContext.Bind2dTexture( mId );
- mContext.PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
-
- mContext.TexImage2D( GL_TEXTURE_2D, 0, pixelGLFormat, mWidth, mHeight, 0, pixelGLFormat, pixelDataType, NULL );
- 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 );
- }
- else
- {
- mContext.ActiveTexture( TEXTURE_UNIT_UPLOAD );
- mContext.Bind2dTexture( mId );
- mContext.PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
- }
-
-#if DALI_GLES_VERSION >= 30
- // For GLES 3.0, uploading sub-image with different format is a valid operation.
- Integration::ConvertToGlFormat( pixelFormat, pixelDataType, pixelGLFormat );
-#else
- // Allows RGB888 source bitmap to be added to RGBA8888 texture, need to convert the bitmap format manually.
- if(pixelFormat == Pixel::RGB888 && mPixelFormat == Pixel::RGBA8888 )
- {
- std::size_t size = width * height;
-
- Vector<PixelBuffer> tempBuffer;
- tempBuffer.Reserve( size*4u );
- PixelBuffer* data = tempBuffer.Begin();
-
- for( std::size_t i=0u; i<size; i++ )
- {
- data[i*4u] = pixels[i*3u];
- data[i*4u+1] = pixels[i*3u+1];
- data[i*4u+2] = pixels[i*3u+2];
- data[i*4u+3] = 0xFF;
- }
-
- mContext.TexSubImage2D( GL_TEXTURE_2D, 0,
- xOffset, yOffset,
- width, height,
- pixelGLFormat, pixelDataType,
- data );
-
- return;
- }
-#endif
-
- mContext.TexSubImage2D( GL_TEXTURE_2D, 0,
- xOffset, yOffset,
- width, height,
- pixelGLFormat, pixelDataType,
- pixels );
-}
-
-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();
-
- // Pixel data could be null if we've uploaded to GL and discarded the data.
-
- if( NULL != pixels )
- {
- 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 );
- }
- }
- }
- }
-}
-
-bool BitmapTexture::UpdateOnCreate()
-{
- return true;
-}
-
-bool BitmapTexture::CreateGlTexture()
-{
- DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
- DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "BitmapTexture::CreateGlTexture() Bitmap: %s\n", DALI_LOG_GET_OBJECT_C_STR(this));
-
- if( mBitmap )
- {
- const unsigned char* pixels = mBitmap->GetBuffer();
-
- // pixel data could be NULL here if we've had a context loss and we previously discarded
- // the pixel data on the previous upload. If it is null, then we shouldn't generate a
- // new GL Texture; leaving mId as zero. Eventually, the bitmap will get reloaded,
- // and pixels will become non-null.
-
- if( NULL != pixels )
- {
- AssignBitmap( true, pixels );
- DiscardBitmapBuffer();
- }
- }
- else
- {
- const unsigned char* pixels = NULL;
- Dali::Vector<unsigned char> pixelData; // Okay to create outside branch as empty vector has no heap allocation.
- if( true == mClearPixels )
- {
- unsigned int size = mWidth * mHeight * Pixel::GetBytesPerPixel( mPixelFormat );
- pixelData.Resize( size, 0 );
- pixels = &pixelData[0];
- }
- AssignBitmap( true, pixels );
- }
-
- return mId != 0;
-}
-
-bool BitmapTexture::Init()
-{
- DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
- // mBitmap should be initialized by now
- return (mBitmap != 0);
-}
-
-unsigned int BitmapTexture::GetWidth() const
-{
- unsigned int width = mWidth;
- if( mBitmap )
- {
- width = mBitmap->GetImageWidth();
- }
- return width;
-}
-
-unsigned int BitmapTexture::GetHeight() const
-{
- unsigned int height = mHeight;
- if( mBitmap )
- {
- height = mBitmap->GetImageHeight();
- }
- return height;
-}
-
-void BitmapTexture::DiscardBitmapBuffer()
-{
- DALI_LOG_INFO(Debug::Filter::gImage, Debug::General, "BitmapTexture::DiscardBitmapBuffer() DiscardPolicy: %s\n", mDiscardPolicy == ResourcePolicy::OWNED_DISCARD?"DISCARD":"RETAIN");
-
- if( ResourcePolicy::OWNED_DISCARD == mDiscardPolicy )
- {
- DALI_LOG_INFO(Debug::Filter::gImage, Debug::General, " Discarding bitmap\n");
- if ( mBitmap )
- {
- mBitmap->DiscardBuffer();
- }
- }
-}
-
-
-} //namespace Internal
-
-} //namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_BITMAP_TEXTURE_H__
-#define __DALI_INTERNAL_BITMAP_TEXTURE_H__
-
-/*
- * Copyright (c) 2016 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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <stdint.h> // for uint32_t
-
-// INTERNAL INCLUDES
-#include <dali/internal/common/message.h>
-#include <dali/integration-api/bitmap.h>
-#include <dali/integration-api/debug.h>
-#include <dali/internal/render/gl-resources/texture-cache.h>
-#include <dali/internal/render/gl-resources/gl-texture.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-class BitmapTexture;
-typedef IntrusivePtr<BitmapTexture> BitmapTexturePointer;
-
-/**
- *
- * Texture class.
- * If you want to load a file to a BitmapTexture use
- * TextureManager::GetTexture()
- *
- */
-class BitmapTexture : public Texture
-{
-public:
- /**
- * Constructor
- * Creates a new texture object from a Bitmap
- * @param[in] bitmap The Bitmap
- * @param[in] bitmapPackedPixelsProfile The Bitmap features related to an addressable array of raw pixel data
- * @param context The GL context
- */
- BitmapTexture(Integration::Bitmap* const bitmap, const Integration::Bitmap::PackedPixelsProfile * const bitmapPackedPixelsProfile, Context& context, ResourcePolicy::Discardable discardPolicy);
-
- /**
- * Constructor
- * Creates a new texture object
- * @param[in] width width in pixels
- * @param[in] height height in pixels
- * @param[in] pixelFormat pixel format
- * @param[in] clearPixels True if the pixel data should be cleared before gl texture creation
- * @param[in] context Dali context
- */
- BitmapTexture( unsigned int width, unsigned int height, Pixel::Format pixelFormat,
- bool clearPixels, Context& context, ResourcePolicy::Discardable discardPolicy );
-
- /**
- * Destructor.
- */
- virtual ~BitmapTexture();
-
- /**
- * Retrieve the bitmap
- * @return The bitmap or NULL if already discarded
- */
- Integration::Bitmap* GetBitmap() { return mBitmap.Get(); }
-
-public:
-
- /**
- * @copydoc Texture::Init
- */
- virtual bool Init();
-
- /**
- * @copydoc Texture::GetWidth
- */
- virtual unsigned int GetWidth() const;
-
- /**
- * @copydoc Texture::GetHeight
- */
- virtual unsigned int GetHeight() const;
-
- /**
- * @copydoc Texture::HasAlphaChannel
- */
- virtual bool HasAlphaChannel() const;
-
- /**
- * @copydoc Texture::IsFullyOpaque
- */
- virtual bool IsFullyOpaque() const;
-
- /**
- * Replace current bitmap with a fresh one, for instance after a Bitmap has
- * been reloaded.
- * @param[in] bitmap The new bitmap
- */
- virtual void Update( Integration::Bitmap* bitmap );
-
- /**
- * Update part of the texture with a different bitmap
- * @param[in] srcBitmap The bitmap to copy from
- * @param [in] xOffset Specifies an offset in the x direction within the texture
- * @param [in] yOffset Specifies an offset in the y direction within the texture
- */
- virtual void Update( Integration::Bitmap* srcBitmap, std::size_t xOffset, std::size_t yOffset );
-
- /**
- * Update part of the texture with a pixel buffer
- * @param[in] srcPixelData The pixel data to copy from
- * @param [in] xOffset Specifies an offset in the x direction within the texture
- * @param [in] yOffset Specifies an offset in the y direction within the texture
- */
- virtual void Update( PixelData* srcPixelData, std::size_t xOffset, std::size_t yOffset );
-
- /**
- * Bitmap area has been modified - update the texture appropriately.
- * @pre The bitmap hasn't been discarded (should be external type)
- * @param[in] area The updated area
- */
- virtual void UpdateArea( const RectArea& area );
-
- /**
- * @return Return true if the texture should be updated on GL texture creation.
- */
- virtual bool UpdateOnCreate();
-
-protected:
- /**
- * @copydoc Texture::CreateGlTexture
- */
- virtual bool CreateGlTexture();
-
-private:
-
- /**
- * Uploads changes to GPU after Bitmap buffer has changed.
- * @param [in] updateArea area which changed
- * @param[in] pixels The pixel data
- */
- void AreaUpdated( const RectArea& updateArea, const unsigned char* pixels );
-
- /**
- * Assigns the bitmap data to an OpenGL texture
- * Creates a new texture object and copies
- * the image data held in the pixels parameter
- * @pre The texture has to have a width/height that is a power of 2.
- * @param[in] generateTexture True if we should generate a GL texture id
- * @param[in] pixels The pixel data
- */
- void AssignBitmap( bool generateTexture, const unsigned char* pixels );
-
- /**
- * If the discard policy is not RETAIN, then discards the bitmap's pixel buffer
- */
- void DiscardBitmapBuffer();
-
- /**
- * Update part of the texture.
- * @param [in] pixels The pixel buffer.
- * @param [in] width The buffer width in pixels
- * @param [in] height The buffer height in pixels
- * @param [in] pixelFormat The pixel format
- * @param [in] xOffset Specifies an offset in the x direction within the texture
- * @param [in] yOffset Specifies an offset in the y direction within the texture
- */
- void Update( const unsigned char* pixels, std::size_t width, std::size_t height, Pixel::Format pixelFormat, std::size_t xOffset, std::size_t yOffset );
-
-private:
- Integration::BitmapPtr mBitmap; ///< The Bitmap the Texture was created from (may be NULL)
- Pixel::Format mPixelFormat; ///< Pack pixel format into bitfield
- ResourcePolicy::Discardable mDiscardPolicy; ///< The bitmap discard policy
- bool mClearPixels; ///< true if initial texture should be cleared on creation
-
- // Changes scope, should be at end of class
- DALI_LOG_OBJECT_STRING_DECLARATION;
-};
-
-} //namespace Internal
-
-} //namespace Dali
-
-#endif //__DALI_INTERNAL_BITMAP_TEXTURE_H__
+++ /dev/null
-/*
- * 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.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/render/gl-resources/compressed-bitmap-texture.h>
-
-// INTERNAL INCLUDES
-#include <dali/integration-api/debug.h>
-#include <dali/internal/render/common/performance-monitor.h>
-#include <dali/internal/render/gl-resources/context.h>
-#include <dali/internal/render/gl-resources/texture-units.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-CompressedBitmapTexture::CompressedBitmapTexture(Internal::BitmapCompressed* const bitmap, Context& context, ResourcePolicy::Discardable /*discardPolicy*/)
-: Texture(context,
- bitmap->GetImageWidth(),
- bitmap->GetImageHeight(),
- bitmap->GetImageWidth(),
- bitmap->GetImageHeight()),
- mBitmap(bitmap),
- mPixelFormat( bitmap->GetPixelFormat() )
-{
- DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
- DALI_LOG_SET_OBJECT_STRING(this, DALI_LOG_GET_OBJECT_STRING(bitmap));
-}
-
-CompressedBitmapTexture::~CompressedBitmapTexture()
-{
- DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
- // GlCleanup() should already have been called by TextureCache ensuring the resource is destroyed
- // on the render thread. (And avoiding a potentially problematic virtual call in the destructor)
-}
-
-bool CompressedBitmapTexture::HasAlphaChannel() const
-{
- return Pixel::HasAlpha(mPixelFormat);
-}
-
-bool CompressedBitmapTexture::IsFullyOpaque() const
-{
- if( mBitmap )
- {
- return mBitmap->IsFullyOpaque();
- }
- else
- {
- return ! HasAlphaChannel(); // Todo: amalgamate updated bitmap's IsFullyOpaque()
- }
-}
-
-
-void CompressedBitmapTexture::AssignBitmap( bool generateTexture, const unsigned char* const pixels, const size_t bufferSize )
-{
- DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
- DALI_LOG_INFO(Debug::Filter::gGLResource, Debug::Verbose, "CompressedBitmapTexture::AssignBitmap()\n");
-
- if( generateTexture )
- {
- mContext.GenTextures(1, &mId);
- }
- DALI_ASSERT_DEBUG( mId != 0 );
-
- mContext.ActiveTexture( TEXTURE_UNIT_UPLOAD );
- mContext.Bind2dTexture(mId);
-
- GLenum pixelFormat = GL_RGBA;
- GLenum pixelDataType = GL_UNSIGNED_BYTE;
- Integration::ConvertToGlFormat(mPixelFormat, pixelDataType, pixelFormat);
-
- mContext.PixelStorei(GL_UNPACK_ALIGNMENT, 1); // We always use tightly packed data
- mContext.CompressedTexImage2D(GL_TEXTURE_2D, 0, pixelFormat, mWidth, mHeight, 0, bufferSize, pixels);
- 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);
-
-}
-
-void CompressedBitmapTexture::Update( Integration::Bitmap* bitmap )
-{
- DALI_ASSERT_DEBUG(bitmap);
- DALI_ASSERT_DEBUG(mImageWidth == mWidth && mImageHeight == mHeight);
- DALI_LOG_INFO(Debug::Filter::gGLResource, Debug::General, "CompressedBitmapTexture::Update(bitmap:%p )\n", bitmap);
-
- if( !bitmap )
- {
- DALI_LOG_ERROR( "Passed a null bitmap to update this compressed bitmap texture.\n" );
- return;
- }
-
- Internal::BitmapCompressed * const compressedBitmap = dynamic_cast<Dali::Internal::BitmapCompressed*>( bitmap );
- if( compressedBitmap == 0 )
- {
- DALI_LOG_ERROR("CompressedBitmapTexture was passed a non-compressed bitmap to update with.\n");
- return;
- }
- mBitmap = compressedBitmap;
-
- const unsigned char * const pixels = mBitmap->GetBuffer();
-
- DALI_ASSERT_DEBUG(pixels != NULL);
-
- if ( NULL == pixels )
- {
- DALI_LOG_ERROR("Bitmap has no data\n");
- }
- else
- {
- mImageWidth = mBitmap->GetImageWidth();
- mImageHeight = mBitmap->GetImageHeight();
- mWidth = mImageWidth;
- mHeight = mImageHeight;
- mPixelFormat = mBitmap->GetPixelFormat();
-
- if ( mId ) // If the texture is already bound
- {
- AssignBitmap( false, pixels, mBitmap->GetBufferSize() );
- }
- }
-}
-
-bool CompressedBitmapTexture::UpdateOnCreate()
-{
- return true;
-}
-
-bool CompressedBitmapTexture::CreateGlTexture()
-{
- DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
- DALI_LOG_INFO(Debug::Filter::gImage, Debug::Verbose, "Bitmap: %s\n", DALI_LOG_GET_OBJECT_C_STR(this));
-
- if( mBitmap )
- {
- const unsigned char* pixels = mBitmap->GetBuffer();
-
- DALI_ASSERT_DEBUG(pixels != NULL);
-
- if( NULL != pixels )
- {
- AssignBitmap( true, pixels, mBitmap->GetBufferSize() );
- mBitmap->DiscardBuffer();
- }
- }
- else
- {
- AssignBitmap( true, NULL, 0 );
- }
-
- return mId != 0;
-}
-
-bool CompressedBitmapTexture::Init()
-{
- DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
- // mBitmap should be initialized by now
- return (mBitmap != 0);
-}
-
-unsigned int CompressedBitmapTexture::GetWidth() const
-{
- unsigned int width = mWidth;
- if( mBitmap )
- {
- width = mBitmap->GetImageWidth();
- }
- return width;
-}
-
-unsigned int CompressedBitmapTexture::GetHeight() const
-{
- unsigned int height = mHeight;
- if( mBitmap )
- {
- height = mBitmap->GetImageHeight();
- }
- return height;
-}
-
-} //namespace Internal
-
-} //namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_COMPRESSED_BITMAP_TEXTURE_H__
-#define __DALI_INTERNAL_COMPRESSED_BITMAP_TEXTURE_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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <string>
-#include <stdint.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/images/buffer-image.h>
-#include <dali/internal/common/message.h>
-#include <dali/internal/render/gl-resources/texture-cache.h>
-#include <dali/integration-api/bitmap.h>
-#include <dali/internal/event/images/bitmap-compressed.h>
-#include <dali/integration-api/debug.h>
-#include <dali/internal/render/gl-resources/gl-texture.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-class CompressedBitmapTexture;
-typedef IntrusivePtr<CompressedBitmapTexture> CompressedBitmapTexturePointer;
-
-/**
- * Compressed Texture class.
- * If you want to load a file to a CompressedBitmapTexture use
- * TextureManager::GetTexture()
- * Compressed textures differ from ordinary ones in that their in-memory
- * representation cannot be inspected at a pixel level by simple pointer
- * arithmetic and in that they cannot be partially updated.
- */
-class CompressedBitmapTexture : public Texture
-{
-public:
- /**
- * Constructor
- * Creates a new texture object from a Bitmap
- * @param[in] bitmap The Bitmap
- * @param[in] context The GL context
- * @param[in] discardPolicy The discard policy
- */
- CompressedBitmapTexture( Internal::BitmapCompressed* const bitmap, Context& context, ResourcePolicy::Discardable discardPolicy );
-
- /**
- * Destructor.
- */
- virtual ~CompressedBitmapTexture();
-
-public:
- /**
- * @copydoc Texture::Init
- */
- virtual bool Init();
-
- /**
- * @copydoc Texture::GetWidth
- */
- virtual unsigned int GetWidth() const;
-
- /**
- * @copydoc Texture::GetHeight
- */
- virtual unsigned int GetHeight() const;
-
- /**
- * @copydoc Texture::HasAlphaChannel
- */
- virtual bool HasAlphaChannel() const;
-
- /**
- * @copydoc Texture::IsFullyOpaque
- * Always returns false as we can't know what is going on inside the encoded pixel data. ///!Todo: Revise this decision: Paul, didn't you want the opposite assumption?
- */
- virtual bool IsFullyOpaque() const;
-
- /**
- * Bitmap has been reloaded - update the texture appropriately.
- * @param[in] bitmap The new bitmap
- */
- virtual void Update( Integration::Bitmap* bitmap );
-
- /**
- * @return Return true if the texture should be updated on GL texture creation.
- */
- virtual bool UpdateOnCreate();
-
-protected:
- /**
- * @copydoc Texture::CreateGlTexture
- */
- virtual bool CreateGlTexture();
-
-private:
-
- /**
- * Assigns the bitmap data to an OpenGL texture
- * Creates a new texture object and copies
- * the image data held in the pixels parameter
- * @param[in] generateTexture True if we should generate a GL texture id
- * @param[in] pixels The pixel data
- */
- void AssignBitmap( bool generateTexture, const unsigned char* pixels, const size_t bufferSize );
-
-private:
- Internal::BitmapCompressedPtr mBitmap; ///< The Bitmap the Texture was created from (may be NULL)
- Pixel::Format mPixelFormat;
-
- // Changes scope, should be at end of class
- DALI_LOG_OBJECT_STRING_DECLARATION;
-};
-} //namespace Internal
-} //namespace Dali
-
-#endif //__DALI_INTERNAL_COMPRESSED_BITMAP_TEXTURE_H__
+++ /dev/null
-/*
- * 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.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/render/gl-resources/frame-buffer-texture.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/images/native-image-interface.h>
-#include <dali/internal/render/gl-resources/context.h>
-#include <dali/internal/render/gl-resources/texture-units.h>
-#include <dali/integration-api/debug.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-FrameBufferTexture::FrameBufferTexture(unsigned int width, unsigned int height, Context& context)
-: Texture( context,
- width, height ),
- mFrameBufferName(0),
- mRenderBufferName(0),
- mStencilBufferName(0),
- mPixelFormat(Pixel::RGBA8888),
- mBufferFormat(RenderBuffer::COLOR),
- mNativeImage(NULL)
-{
- DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
-
-}
-
-FrameBufferTexture::FrameBufferTexture(unsigned int width, unsigned int height, Pixel::Format pixelFormat, Context& context)
-: Texture( context,
- width, height ),
- mFrameBufferName(0),
- mRenderBufferName(0),
- mStencilBufferName(0),
- mPixelFormat( pixelFormat ),
- mBufferFormat(RenderBuffer::COLOR),
- mNativeImage(NULL)
-{
- DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
-
-}
-
-FrameBufferTexture::FrameBufferTexture(unsigned int width, unsigned int height, Pixel::Format pixelFormat, RenderBuffer::Format bufferFormat, Context& context)
-: Texture( context,
- width, height ),
- mFrameBufferName(0),
- mRenderBufferName(0),
- mStencilBufferName(0),
- mPixelFormat( pixelFormat ),
- mBufferFormat( bufferFormat ),
- mNativeImage(NULL)
-{
- DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
-}
-
-FrameBufferTexture::FrameBufferTexture( NativeImageInterfacePtr nativeImage, Context& context )
-: Texture( context,
- nativeImage->GetWidth(), nativeImage->GetHeight() ),
- mFrameBufferName(0),
- mRenderBufferName(0),
- mStencilBufferName(0),
- mPixelFormat( Pixel::RGBA8888 ), // Not really used for nativeImage
- mBufferFormat(RenderBuffer::COLOR_DEPTH),
- mNativeImage( nativeImage )
-{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::General, "NativeFrameBufferTexture created 0x%x\n", &nativeImage );
-}
-
-FrameBufferTexture::~FrameBufferTexture()
-{
- DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
- // GlCleanup() should already have been called by TextureCache ensuring the resource is destroyed
- // on the render thread. (And avoiding a potentially problematic virtual call in the destructor)
-}
-
-bool FrameBufferTexture::IsFullyOpaque() const
-{
- return !HasAlphaChannel();
-}
-
-bool FrameBufferTexture::HasAlphaChannel() const
-{
- if( mNativeImage )
- {
- return mNativeImage->RequiresBlending();
- }
-
- return false;
-}
-
-bool FrameBufferTexture::Init()
-{
- DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
- return true;
-}
-
-bool FrameBufferTexture::Prepare()
-{
- // bind texture
- Bind( GL_TEXTURE_2D, TEXTURE_UNIT_FRAMEBUFFER );
-
- if( 0 != mId )
- {
- // bind frame buffer
- mContext.BindFramebuffer(GL_FRAMEBUFFER, mFrameBufferName);
-
- return true;
- }
-
- // Texture could not be bound
- return false;
-}
-
-bool FrameBufferTexture::CreateGlTexture()
-{
- DALI_LOG_TRACE_METHOD(Debug::Filter::gImage);
-
- if( mNativeImage &&
- !mNativeImage->GlExtensionCreate() )
- {
- DALI_LOG_ERROR( "Error creating native image!\n" );
- return false;
- }
-
- mContext.GenTextures(1, &mId);
- mContext.ActiveTexture( TEXTURE_UNIT_UPLOAD ); // bind in unused unit so rebind works the first time
- mContext.Bind2dTexture(mId);
-
- // set texture parameters
- mContext.PixelStorei(GL_UNPACK_ALIGNMENT, 1);
- 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);
-
- if( mNativeImage )
- {
- // platform specific implementation decides on what GL extension to use
- mNativeImage->TargetTexture();
- }
- else
- {
- // Assign memory for texture in GL memory space
- GLenum pixelFormat = GL_RGBA;
- GLenum pixelDataType = GL_UNSIGNED_BYTE;
- Integration::ConvertToGlFormat(mPixelFormat, pixelDataType, pixelFormat);
-
- mContext.TexImage2D(GL_TEXTURE_2D, 0, pixelFormat, mWidth, mHeight, 0, pixelFormat, pixelDataType, NULL);
- }
-
- // generate frame and render buffer names
- mContext.GenFramebuffers(1, &mFrameBufferName);
-
- /* WE ALWAYS HAVE COLOR COMPONENT */
-
- // bind frame buffer
- mContext.BindFramebuffer(GL_FRAMEBUFFER, mFrameBufferName);
- // attach texture to the color attachment point
- mContext.FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mId, 0);
-
- if (mBufferFormat == RenderBuffer::COLOR_DEPTH_STENCIL)
- {
- mContext.GenRenderbuffers(1, &mRenderBufferName);
- mContext.GenRenderbuffers(1, &mStencilBufferName);
-
- // Bind render buffer and create 16 depth buffer
- mContext.BindRenderbuffer(GL_RENDERBUFFER, mRenderBufferName);
- mContext.RenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, mWidth, mHeight);
-
- // Bind render buffer and create 8 stencil buffer
- mContext.BindRenderbuffer(GL_RENDERBUFFER, mStencilBufferName);
- mContext.RenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, mWidth, mHeight);
-
- // attach render buffer to the depth buffer attachment point
- mContext.FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mRenderBufferName);
- // attach render buffer to the stencil buffer attachment point
- mContext.FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mStencilBufferName);
- }
- else if (mBufferFormat == RenderBuffer::COLOR_DEPTH)
- {
- mContext.GenRenderbuffers(1, &mRenderBufferName);
-
- // Bind render buffer and create 8 stencil buffer
- mContext.BindRenderbuffer(GL_RENDERBUFFER, mRenderBufferName);
- mContext.RenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, mWidth, mHeight);
-
- // attach render buffer to the depth buffer attachment point
- mContext.FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mRenderBufferName);
- }
- else if (mBufferFormat == RenderBuffer::COLOR_STENCIL)
- {
- mContext.GenRenderbuffers(1, &mStencilBufferName);
-
- // Bind render buffer and create 8 stencil buffer
- mContext.BindRenderbuffer(GL_RENDERBUFFER, mStencilBufferName);
- mContext.RenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, mWidth, mHeight);
-
- // attach render buffer to the depth buffer attachment point
- mContext.FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mStencilBufferName);
- }
-
- int status = mContext.CheckFramebufferStatus(GL_FRAMEBUFFER);
- if ( GL_FRAMEBUFFER_COMPLETE != status )
- {
- DALI_LOG_ERROR( "status (0x%x), glError (0x%x)\n", status, mContext.GetError() );
- }
-
- return mId != 0;
-}
-
-void FrameBufferTexture::GlCleanup()
-{
- Texture::GlCleanup();
-
- if (mFrameBufferName != 0)
- {
- mContext.DeleteFramebuffers(1, &mFrameBufferName );
- mFrameBufferName = 0;
- }
-
- if (mRenderBufferName != 0)
- {
- mContext.DeleteRenderbuffers(1, &mRenderBufferName );
- mRenderBufferName = 0;
- }
-
- if (mStencilBufferName != 0)
- {
- mContext.DeleteRenderbuffers(1, &mStencilBufferName );
- mStencilBufferName = 0;
- }
-
- if( mNativeImage )
- {
- mNativeImage->GlExtensionDestroy();
- mNativeImage.Reset();
- }
-}
-
-} //namespace Internal
-
-} //namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_FRAME_BUFFER_TEXTURE_H__
-#define __DALI_INTERNAL_FRAME_BUFFER_TEXTURE_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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <string>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/images/frame-buffer-image.h>
-#include <dali/integration-api/bitmap.h>
-#include <dali/integration-api/debug.h>
-#include <dali/internal/render/gl-resources/gl-texture.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-/**
- * Texture class.
- * Used as a frame buffer for RenderTask
- */
-class FrameBufferTexture : public Texture
-{
-public:
-
- /**
- * Creates a new texture object
- * @param[in] width The width (pixels)
- * @param[in] height The height (pixels)
- * @param[in] context The GL context
- */
- FrameBufferTexture(unsigned int width, unsigned int height, Context& context);
-
- /**
- * Creates a new texture object
- * @param[in] width The width (pixels)
- * @param[in] height The height (pixels)
- * @param[in] pixelFormat The pixel format
- * @param[in] context The GL context
- */
- FrameBufferTexture(unsigned int width, unsigned int height, Pixel::Format pixelFormat, Context& context);
-
- /**
- * Creates a new texture object
- * @param[in] width The width (pixels)
- * @param[in] height The height (pixels)
- * @param[in] pixelFormat The pixel format
- * @param[in] bufferFormat The buffer formats to be attached in the FBO
- * @param[in] context The GL context
- */
- FrameBufferTexture(unsigned int width, unsigned int height, Pixel::Format pixelFormat, RenderBuffer::Format bufferFormat, Context& context);
-
- /**
- * Creates a new texture object
- * @param[in] nativeImage The NativeImage
- * @param context The GL context
- */
- FrameBufferTexture( NativeImageInterfacePtr nativeImage, Context& context );
-
- /**
- * Destructor.
- */
- virtual ~FrameBufferTexture();
-
- /**
- * @copydoc Texture::IsFullyOpaque
- */
- virtual bool IsFullyOpaque() const;
-
- /**
- * @copydoc Texture::HasAlphaChannel
- */
- virtual bool HasAlphaChannel() const;
-
- /**
- * @copydoc Texture::Init
- */
- virtual bool Init();
-
- /**
- * Prepare FBO for rendering.
- * @return true if the FBO is prepared and its status is GL_FRAMEBUFFER_COMPLETE, otherwise false.
- */
- virtual bool Prepare();
-
-protected:
- unsigned int mFrameBufferName;
- unsigned int mRenderBufferName;
- unsigned int mStencilBufferName;
- Pixel::Format mPixelFormat;
- RenderBuffer::Format mBufferFormat;
- NativeImageInterfacePtr mNativeImage; ///< For native FBOs only
-
- /**
- * @copydoc Texture::CreateGlTexture
- */
- virtual bool CreateGlTexture();
-
- /**
- * @copydoc Texture::GlCleanup
- */
- virtual void GlCleanup();
-
-}; // class FrameBufferTexture
-
-} //namespace Internal
-
-} //namespace Dali
-#endif //__DALI_INTERNAL_FRAME_BUFFER_TEXTURE_H__
-
+++ /dev/null
-/*
- * Copyright (c) 2015 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.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/render/gl-resources/gl-texture.h>
-
-// EXTERNAL INCLUDES
-#include <math.h>
-#include <memory.h>
-
-// INTERNAL INCLUDES
-#include <dali/integration-api/debug.h>
-#include <dali/internal/render/gl-resources/context.h>
-#include <dali/internal/common/image-sampler.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-namespace
-{
-
-// These match the GL specification
-const GLint SYSTEM_MINIFY_DEFAULT = GL_NEAREST_MIPMAP_LINEAR;
-const GLint SYSTEM_MAGNIFY_DEFAULT = GL_LINEAR;
-const GLint SYSTEM_WRAP_DEFAULT = GL_CLAMP_TO_EDGE;
-
-// These are the Dali defaults
-const GLint DALI_MINIFY_DEFAULT = GL_LINEAR;
-const GLint DALI_MAGNIFY_DEFAULT = GL_LINEAR;
-
-} // namespace
-
-/**
- * @brief Convert a FilterMode to it's corresponding GL type.
- *
- * @param[in] filterMode The FilterMode type.
- * @param[in] defaultfilterMode The filter mode to use if filterMode is DEFAULT.
- * @param[in] defaultSystemFilterMode The filter mode to use if filterMode is NONE.
- * @return Return the equivalent GL type.
- */
-GLint FilterModeToGL( FilterMode::Type filterMode, GLint defaultfilterMode, GLint defaultSystemFilterMode )
-{
- switch( filterMode )
- {
- case FilterMode::NEAREST:
- {
- return GL_NEAREST;
- }
- case FilterMode::LINEAR:
- {
- return GL_LINEAR;
- }
- case FilterMode::NONE:
- {
- return defaultSystemFilterMode;
- }
- case FilterMode::NEAREST_MIPMAP_NEAREST:
- {
- return GL_NEAREST_MIPMAP_NEAREST;
- }
- case FilterMode::LINEAR_MIPMAP_NEAREST:
- {
- return GL_LINEAR_MIPMAP_NEAREST;
- }
- case FilterMode::NEAREST_MIPMAP_LINEAR:
- {
- return GL_NEAREST_MIPMAP_LINEAR;
- }
- case FilterMode::LINEAR_MIPMAP_LINEAR:
- {
- return GL_LINEAR_MIPMAP_LINEAR;
- }
- case FilterMode::DEFAULT:
- {
- return defaultfilterMode;
- }
- }
-
- return defaultfilterMode;
-}
-
-GLint WrapModeToGL( WrapMode::Type wrapMode, GLint defaultWrapMode )
-{
- switch( wrapMode )
- {
- case WrapMode::DEFAULT:
- {
- return defaultWrapMode;
- }
- case WrapMode::CLAMP_TO_EDGE:
- {
- return GL_CLAMP_TO_EDGE;
- }
- case WrapMode::REPEAT:
- {
- return GL_REPEAT;
- }
- case WrapMode::MIRRORED_REPEAT:
- {
- return GL_MIRRORED_REPEAT;
- }
- }
-
- return defaultWrapMode;
-}
-
-using Dali::Internal::Vertex2D;
-
-using namespace Dali::Pixel;
-
-Texture::Texture(Context& context,
- unsigned int width,
- unsigned int height,
- unsigned int imageWidth,
- unsigned int imageHeight)
-: mContext(context),
- mId(0),
- mSamplerBitfield( 0 ),
- mWidth(width),
- mHeight(height),
- mImageWidth(imageWidth),
- mImageHeight(imageHeight)
-{
-}
-
-Texture::Texture(Context& context,
- unsigned int width,
- unsigned int height)
-: mContext(context),
- mId(0),
- mSamplerBitfield( 0 ),
- mWidth(width),
- mHeight(height),
- mImageWidth(width),
- mImageHeight(height)
-{
-}
-
-Texture::~Texture()
-{
- // GlCleanup() should already have been called by TextureCache ensuring the resource is destroyed
- // on the render thread. (And avoiding a potentially problematic virtual call in the destructor)
-}
-
-void Texture::SetTextureId(GLuint id)
-{
- mId=id;
-}
-
-void Texture::Update(Integration::Bitmap* bitmap)
-{
- DALI_ASSERT_DEBUG( "Updating incorrect texture type" == NULL );
-}
-
-void Texture::UpdateArea( const RectArea& area )
-{
- DALI_ASSERT_DEBUG( "Updating incorrect texture type" == NULL );
-}
-
-bool Texture::UpdateOnCreate()
-{
- return false;
-}
-
-bool Texture::Bind(GLenum target, TextureUnit textureunit )
-{
- // This is the only supported type at the moment
- DALI_ASSERT_DEBUG( target == GL_TEXTURE_2D );
- bool result = true;
-
- if( mId == 0 )
- {
- result = CreateGlTexture();
- }
-
- // Bind the texture id
- mContext.BindTextureForUnit(textureunit, mId );
-
- return result;
-}
-
-void Texture::GlContextDestroyed()
-{
- // texture is gone
- mId = 0;
- // reset sampler state as well
- mSamplerBitfield = 0;
-}
-
-void Texture::GlCleanup()
-{
- // delete the gl texture
- if (mId != 0)
- {
- mContext.DeleteTextures(1,&mId);
- mId = 0;
- }
-}
-
-unsigned int Texture::GetWidth() const
-{
- return mWidth;
-}
-
-unsigned int Texture::GetHeight() const
-{
- return mHeight;
-}
-
-void Texture::ApplyFilterModeParameter( TextureUnit unit, GLint filterType, FilterMode::Type currentFilterMode, FilterMode::Type newFilterMode, GLint daliDefault, GLint systemDefault )
-{
- GLint newFilterModeGL = FilterModeToGL( newFilterMode, daliDefault, systemDefault );
- GLint currentFilterModeGL = FilterModeToGL( currentFilterMode, daliDefault, systemDefault );
-
- if( newFilterModeGL != currentFilterModeGL )
- {
- mContext.ActiveTexture( unit );
- mContext.TexParameteri( GL_TEXTURE_2D, filterType, newFilterModeGL );
- }
-}
-
-void Texture::ApplyWrapModeParameter( TextureUnit unit, GLint wrapType, WrapMode::Type currentWrapMode, WrapMode::Type newWrapMode )
-{
- GLint newWrapModeGL = WrapModeToGL( newWrapMode, SYSTEM_WRAP_DEFAULT );
- GLint currentWrapModeGL = WrapModeToGL( currentWrapMode, SYSTEM_WRAP_DEFAULT );
-
- if( newWrapModeGL != currentWrapModeGL )
- {
- mContext.ActiveTexture( unit );
- mContext.TexParameteri( GL_TEXTURE_2D, wrapType, newWrapModeGL );
- }
-}
-
-void Texture::ApplySampler( TextureUnit unit, unsigned int samplerBitfield )
-{
- if( mSamplerBitfield != samplerBitfield && mId != 0 )
- {
- ApplyFilterModeParameter( unit,
- GL_TEXTURE_MIN_FILTER,
- ImageSampler::GetMinifyFilterMode( mSamplerBitfield ),
- ImageSampler::GetMinifyFilterMode( samplerBitfield ),
- DALI_MINIFY_DEFAULT,
- SYSTEM_MINIFY_DEFAULT );
-
- ApplyFilterModeParameter( unit,
- GL_TEXTURE_MAG_FILTER,
- ImageSampler::GetMagnifyFilterMode( mSamplerBitfield ),
- ImageSampler::GetMagnifyFilterMode( samplerBitfield ),
- DALI_MAGNIFY_DEFAULT,
- SYSTEM_MAGNIFY_DEFAULT );
-
- ApplyWrapModeParameter( unit,
- GL_TEXTURE_WRAP_S,
- ImageSampler::GetUWrapMode( mSamplerBitfield ),
- ImageSampler::GetUWrapMode( samplerBitfield ));
-
- ApplyWrapModeParameter( unit,
- GL_TEXTURE_WRAP_T,
- ImageSampler::GetVWrapMode( mSamplerBitfield ),
- ImageSampler::GetVWrapMode( samplerBitfield ));
-
-
-
- mSamplerBitfield = samplerBitfield;
- }
-}
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_TEXTURE_H__
-#define __DALI_INTERNAL_TEXTURE_H__
-
-/*
- * Copyright (c) 2015 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/actors/sampling.h>
-#include <dali/public-api/images/image.h>
-#include <dali/public-api/images/pixel.h>
-#include <dali/public-api/images/native-image.h>
-#include <dali/public-api/math/rect.h>
-#include <dali/public-api/object/ref-object.h>
-#include <dali/integration-api/bitmap.h>
-#include <dali/integration-api/gl-abstraction.h>
-#include <dali/internal/event/images/pixel-data-impl.h>
-#include <dali/internal/render/gl-resources/gl-resource-owner.h>
-#include <dali/internal/render/gl-resources/texture-units.h>
-
-
-namespace Dali
-{
-
-class NativeImage;
-
-namespace Internal
-{
-
-class Context;
-struct Vertex2D;
-
-/**
- * Texture class.
- */
-class Texture: public RefObject,
- public GlResourceOwner
-{
-public:
-
- /**
- * Used to define the area of the texture to display
- */
- typedef Rect<int> PixelArea;
-
- /**
- * Used to define a region of a bitmap.
- */
- typedef Rect<unsigned int> RectArea; ///< rectangular area (x,y,w,h)
-
- /**
- * Initialization method for Texture.
- * Might or might not be needed in specific implementations.
- * @return true if successful, false otherwise
- */
- virtual bool Init() = 0;
-
- /**
- * Update the texture with the bitmap.
- */
- virtual void Update(Integration::Bitmap* bitmap);
-
- /**
- * Update the texture from the modified bitmap.
- * @param area to update
- */
- virtual void UpdateArea( const RectArea& area );
-
- /**
- * Update part of the texture with a different bitmap
- * @param[in] srcBitmap The bitmap to copy from
- * @param [in] xOffset Specifies an offset in the x direction within the texture
- * @param [in] yOffset Specifies an offset in the y direction within the texture
- */
- virtual void Update( Integration::Bitmap* srcBitmap, std::size_t xOffset, std::size_t yOffset ) {}
-
- /**
- * Update part of the texture with a pixel buffer
- * @param[in] srcPixelData The pixel data to copy from
- * @param [in] xOffset Specifies an offset in the x direction within the texture
- * @param [in] yOffset Specifies an offset in the y direction within the texture
- */
- virtual void Update( PixelData* srcPixelData, std::size_t xOffset, std::size_t yOffset ) {}
-
- /**
- * @return Return true if the texture should be updated on GL texture creation.
- */
- virtual bool UpdateOnCreate();
-
- /**
- * Binds the texture for use.
- * If there is no GL texture yet, it tries to create one.
- *
- * @param target (e.g. GL_TEXTURE_2D)
- * @param textureunit to bind to
- *
- * @return true if the bind succeeded, or false if either the create or bind failed
- */
- virtual bool Bind(GLenum target, TextureUnit textureunit);
-
- /**
- * Returns GL texture ID
- * @return texture id
- */
- unsigned int GetTextureId()
- {
- return mId;
- }
-
- /**
- * Return the width of image in pixels.
- * @return width
- */
- virtual unsigned int GetWidth() const;
-
- /**
- * Return the height of image in pixels.
- * @return height
- */
- virtual unsigned int GetHeight() const;
-
- /**
- * Query whether the texture data has an alpha channel.
- * @return True if the texture data has an alpha channel.
- */
- virtual bool HasAlphaChannel() const = 0;
-
- /**
- * Query whether the texture is completely opaque
- * @return True if all pixels of the texture data are opaque
- */
- virtual bool IsFullyOpaque() const = 0;
-
- /**
- * Sets the texture id.
- * @param id OpenGL texture id
- */
- void SetTextureId(GLuint id);
-
- /**
- * @brief Apply the given sampler to the texture.
- *
- * @param[in] texture unit to use
- * @param[in] samplerBitfield A bitfield with packed sampler options.
- */
- void ApplySampler( TextureUnit unit, unsigned int samplerBitfield );
-
-protected:
-
- /**
- * Constructor.
- * @param[in] context The GL context
- * @param[in] width The buffer width
- * @param[in] height The buffer height
- * @param[in] imageWidth The image width
- * @param[in] imageHeight The image height
- */
- Texture( Context& context,
- unsigned int width,
- unsigned int height,
- unsigned int imageWidth,
- unsigned int imageHeight );
- /**
- * Constructor.
- * @param[in] context The GL context
- * @param[in] width Both the buffer width and the image width (they are equal)
- * @param[in] height Both the buffer height and the image height.
- */
- Texture( Context& context,
- unsigned int width,
- unsigned int height );
-public:
- /**
- * Initialize texture for rendering.
- * @return true on success
- */
- virtual bool CreateGlTexture() = 0;
-
- /**
- * Destructor.
- * Delete the GL texture associated with it.
- */
- virtual ~Texture();
-
-public: // From GlResourceOwner
-
- /**
- * @copydoc Dali::Internal::GlResourceOwner::GlContextDestroyed()
- */
- virtual void GlContextDestroyed();
-
- /**
- * @copydoc Dali::Internal::GlResourceOwner::GlCleanup()
- */
- virtual void GlCleanup();
-
-private:
-
- // Undefined
- Texture(const Texture&);
-
- // Undefined
- Texture& operator=(const Texture& rhs);
-
- /**
- * @brief Apply the given texture filtering parameters.
- *
- * @param[in] texture unit to use
- * @param[in] filterType Minification or magnification.
- * @param[in] currentFilterMode The current filter mode.
- * @param[in] newFilterMode The new filter mode.
- * @param[in] daliDefault The default dali filter mode for the given filterType.
- * @param[in] systemDefault The default system filter mode for the given filterType.
- */
- void ApplyFilterModeParameter( TextureUnit unit, GLint filterType, FilterMode::Type currentFilterMode, FilterMode::Type newFilterMode, GLint daliDefault, GLint systemDefault );
-
- /**
- * @brief Apply the given texture wrap mode.
- *
- * @param[in] texture unit to use
- * @param[in] wrapType UWrap or VWrap
- * @param[in] currentWrapMode The current wrap mode.
- * @param[in] newWrapMode The new wrap mode.
- */
- void ApplyWrapModeParameter( TextureUnit unit, GLint wrapType, WrapMode::Type currentWrapMode, WrapMode::Type newWrapMode );
-
-protected:
-
- Context& mContext; ///< The GL Context
-
- GLuint mId; ///< Texture id
-
- unsigned int mSamplerBitfield; ///< The packed bitfield of the current sampler
-
- unsigned int mWidth; ///< texture width, may be scaled power of 2 (if not in an atlas)
- unsigned int mHeight; ///< texture width, may be scaled power of 2 (if not in an atlas)
-
- unsigned int mImageWidth; ///< width of the original image (may be smaller than texture width)
- unsigned int mImageHeight; ///< height of the original image (may be smaller than texture height)
-};
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_TEXTURE_H__
+++ /dev/null
-/*
- * 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.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/render/gl-resources/native-texture.h>
-
-// INTERNAL INCLUDES
-#include <dali/integration-api/debug.h>
-#include <dali/internal/render/gl-resources/context.h>
-#include <dali/internal/render/gl-resources/texture-units.h>
-#include <dali/internal/render/gl-resources/gl-texture.h>
-#include <dali/devel-api/images/native-image-interface-extension.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-NativeTexture::NativeTexture(NativeImageInterface* nativeImg, Context& context)
-: Texture(context,
- nativeImg->GetWidth(),
- nativeImg->GetHeight(),
- nativeImg->GetWidth(),
- nativeImg->GetHeight()),
- mNativeImage(nativeImg)
-{
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::General, "NativeTexture created 0x%x\n", &nativeImg );
-}
-
-NativeTexture::~NativeTexture()
-{
- DALI_LOG_INFO (Debug::Filter::gImage, Debug::General, "NativeTexture destroyed\n");
-
- // GlCleanup() should already have been called by TextureCache ensuring the resource is destroyed
- // on the render thread. (And avoiding a potentially problematic virtual call in the destructor)
-}
-
-bool NativeTexture::Bind( GLenum target, TextureUnit textureunit )
-{
- bool result = true;
-
- if( mId == 0 )
- {
- result = CreateGlTexture();
- }
-
- if( result )
- {
- // Bind the texture id
- mContext.ActiveTexture( textureunit );
-
- int textureTarget = GL_TEXTURE_2D;
- NativeImageInterface::Extension* extension = mNativeImage->GetExtension();
- if( extension )
- {
- textureTarget = extension->GetEglImageTextureTarget();
- }
-
- mContext.BindTexture( textureTarget, mId );
- mNativeImage->PrepareTexture();
- }
-
- return result;
-}
-
-bool NativeTexture::IsFullyOpaque() const
-{
- return !HasAlphaChannel();
-}
-
-bool NativeTexture::HasAlphaChannel() const
-{
- return mNativeImage->RequiresBlending();
-}
-
-bool NativeTexture::CreateGlTexture()
-{
- if( mId != 0 )
- {
- DALI_LOG_INFO( Debug::Filter::gImage, Debug::General, "GL texture creation duplicate for GL id: %d\n", &mId );
- return true;
- }
-
- if( mNativeImage->GlExtensionCreate() )
- {
- mContext.GenTextures( 1, &mId );
- mContext.ActiveTexture( TEXTURE_UNIT_UPLOAD ); // bind in unused unit so rebind works the first time
-
- int textureTarget = GL_TEXTURE_2D;
- NativeImageInterface::Extension* extension = mNativeImage->GetExtension();
- if( extension )
- {
- textureTarget = extension->GetEglImageTextureTarget();
- }
-
- mContext.BindTexture( textureTarget, mId );
-
- mContext.PixelStorei( GL_UNPACK_ALIGNMENT, 1 ); // We always use tightly packed data
-
- 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();
- }
- else
- {
- DALI_LOG_ERROR( "Error creating native image!\n" );
- }
-
- return mId != 0;
-}
-
-void NativeTexture::GlCleanup()
-{
- Texture::GlCleanup();
-
- DALI_ASSERT_DEBUG( mNativeImage );
-
- mNativeImage->GlExtensionDestroy();
- mNativeImage.Reset();
-}
-
-bool NativeTexture::Init()
-{
- return true;
-}
-
-} //namespace Internal
-
-} //namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_NATIVE_TEXTURE_H__
-#define __DALI_INTERNAL_NATIVE_TEXTURE_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/integration-api/gl-defines.h>
-#include <dali/public-api/images/native-image-interface.h>
-#include <dali/internal/render/gl-resources/gl-texture.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-class Texture;
-
-/**
- *
- * Native texture class.
- * Used for handing already loaded image data to Dali.
- *
- */
-class NativeTexture : public Texture
-{
-public:
- /**
- * Constructor.
- * @pre nativeImg has to be initialized. (GLTexture is already created)
- * @param nativeImg the NativeImage to be used
- * @param context the GL context
- */
- NativeTexture(NativeImageInterface* nativeImg, Context& context);
-
- /**
- * Destructor.
- */
- virtual ~NativeTexture();
-
- /**
- * @copydoc Texture::Bind
- */
- virtual bool Bind( GLenum target, TextureUnit textureunit );
-
- /**
- * @copydoc Texture::IsFullyOpaque
- */
- virtual bool IsFullyOpaque() const;
-
- /**
- * @copydoc Texture::HasAlphaChannel
- */
- virtual bool HasAlphaChannel() const;
-
- /**
- * @copydoc Texture::Init
- */
- virtual bool Init();
-
-protected:
- /**
- * @copydoc Texture::CreateGlTexture
- */
- virtual bool CreateGlTexture();
-
- /**
- * @copydoc Texture::GlCleanup
- */
- virtual void GlCleanup();
-
-
-private:
-
- NativeImageInterfacePtr mNativeImage; ///< reference to NativeImage the Texture was created from
-};
-
-} //namespace Internal
-
-} //namespace Dali
-
-#endif //__DALI_INTERNAL_NATIVE_TEXTURE_H__
+++ /dev/null
-/*
- * Copyright (c) 2016 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.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/render/gl-resources/texture-cache.h>
-
-// INTERNAL HEADERS
-#include <dali/integration-api/debug.h>
-#include <dali/integration-api/bitmap.h>
-#include <dali/internal/render/common/texture-uploaded-dispatcher.h>
-#include <dali/internal/render/queue/render-queue.h>
-#include <dali/internal/render/gl-resources/context.h>
-#include <dali/internal/render/gl-resources/texture-factory.h>
-#include <dali/internal/render/gl-resources/texture-cache.h>
-#include <dali/internal/render/gl-resources/texture-observer.h>
-#include <dali/internal/render/gl-resources/bitmap-texture.h>
-#include <dali/internal/render/gl-resources/native-texture.h>
-#include <dali/internal/render/gl-resources/frame-buffer-texture.h>
-#include <dali/internal/update/resources/resource-manager-declarations.h>
-#include <dali/internal/render/gl-resources/gl-texture.h>
-
-using Dali::Internal::Texture;
-using Dali::Internal::FrameBufferTexture;
-using Dali::Integration::Bitmap;
-
-namespace
-{
-#if defined(DEBUG_ENABLED)
-Debug::Filter* gTextureCacheFilter = Debug::Filter::New(Debug::Concise, false, "LOG_TEXTURE_CACHE");
-#endif
-}
-
-
-namespace Dali
-{
-namespace Internal
-{
-
-
-namespace SceneGraph
-{
-
-namespace
-{
-
-/**
- * @brief Forward to all textures in container the news that the GL Context is down.
- */
-void GlContextDestroyed( TextureContainer& textures )
-{
- TextureIter end = textures.end();
- TextureIter iter = textures.begin();
- for( ; iter != end; ++iter )
- {
- (*iter->second).GlContextDestroyed();
- }
-}
-
-}
-
-TextureCache::TextureCache( RenderQueue& renderQueue,
- TextureUploadedDispatcher& postProcessResourceDispatcher,
- Context& context)
-: mTextureUploadedDispatcher(postProcessResourceDispatcher),
- mContext(context),
- mDiscardBitmapsPolicy(ResourcePolicy::OWNED_DISCARD)
-{
-}
-
-TextureCache::~TextureCache()
-{
-}
-
-void TextureCache::CreateTexture( ResourceId id,
- unsigned int width,
- unsigned int height,
- Pixel::Format pixelFormat,
- bool clearPixels )
-{
- DALI_LOG_INFO(Debug::Filter::gGLResource, Debug::General, "TextureCache::CreateTexture(id=%i width:%u height:%u)\n", id, width, height);
-
- Texture* texture = TextureFactory::NewBitmapTexture(width, height, pixelFormat, clearPixels, mContext, GetDiscardBitmapsPolicy() );
- mTextures.insert(TexturePair(id, texture));
-}
-
-void TextureCache::AddBitmap(ResourceId id, Integration::BitmapPtr bitmap)
-{
- DALI_LOG_INFO(Debug::Filter::gGLResource, Debug::General, "TextureCache::AddBitmap(id=%i Bitmap:%p)\n", id, bitmap.Get());
-
- Texture* texture = TextureFactory::NewBitmapTexture(bitmap.Get(), mContext, GetDiscardBitmapsPolicy());
- mTextures.insert(TexturePair(id, texture));
-}
-
-void TextureCache::AddNativeImage(ResourceId id, NativeImageInterfacePtr nativeImage)
-{
- DALI_LOG_INFO(Debug::Filter::gGLResource, Debug::General, "TextureCache::AddNativeImage(id=%i NativeImg:%p)\n", id, nativeImage.Get());
-
- /// WARNING - currently a new Texture is created even if we reuse the same NativeImage
- Texture* texture = TextureFactory::NewNativeImageTexture(*nativeImage, mContext);
- mTextures.insert(TexturePair(id, texture));
-}
-
-void TextureCache::AddFrameBuffer( ResourceId id, unsigned int width, unsigned int height, Pixel::Format pixelFormat, RenderBuffer::Format bufferFormat )
-{
- DALI_LOG_INFO(Debug::Filter::gGLResource, Debug::General, "TextureCache::AddFrameBuffer(id=%i width:%u height:%u)\n", id, width, height);
-
- // Note: Do not throttle framebuffer generation - a request for a framebuffer should always be honoured
- // as soon as possible.
- Texture* texture = TextureFactory::NewFrameBufferTexture( width, height, pixelFormat, bufferFormat, mContext );
- mFramebufferTextures.insert(TexturePair(id, texture));
-}
-
-void TextureCache::AddFrameBuffer( ResourceId id, NativeImageInterfacePtr nativeImage )
-{
- DALI_LOG_INFO(Debug::Filter::gGLResource, Debug::General, "TextureCache::AddFrameBuffer(id=%i width:%u height:%u)\n", id, nativeImage->GetWidth(), nativeImage->GetHeight());
-
- // Note: Do not throttle framebuffer generation - a request for a framebuffer should always be honoured
- // as soon as possible.
- Texture* texture = TextureFactory::NewFrameBufferTexture( nativeImage, mContext );
- mFramebufferTextures.insert(TexturePair(id, texture));
-}
-
-void TextureCache::CreateGlTexture( ResourceId id )
-{
- TextureIter textureIter = mTextures.find(id);
- // If we found a non-null texture object pointer for the resource id, force it
- // to eagerly allocate a backing GL texture:
- if( textureIter != mTextures.end() )
- {
- TexturePointer texturePtr = textureIter->second;
- if( texturePtr )
- {
- texturePtr->CreateGlTexture();
- }
- }
-}
-
-void TextureCache::UpdateTexture( ResourceId id, Integration::BitmapPtr bitmap )
-{
- DALI_LOG_INFO(Debug::Filter::gGLResource, Debug::General, "TextureCache::UpdateTexture(id=%i bitmap:%p )\n", id, bitmap.Get());
-
- TextureIter textureIter = mTextures.find(id);
- if( textureIter != mTextures.end() )
- {
- // we have reloaded the image from file, update texture
- TexturePointer texturePtr = textureIter->second;
- if( texturePtr )
- {
- texturePtr->Update( bitmap.Get() );
-
- ResourceId ppRequest( id );
- mTextureUploadedDispatcher.DispatchTextureUploaded(ppRequest);
- }
- }
-}
-
-void TextureCache::UpdateTexture( ResourceId id, Integration::BitmapPtr bitmap, std::size_t xOffset, std::size_t yOffset )
-{
- DALI_LOG_INFO(Debug::Filter::gGLResource, Debug::General, "TextureCache::UpdateTexture(id=%i bitmap:%p )\n", id, bitmap.Get());
-
- TextureIter textureIter = mTextures.find(id);
- if( textureIter != mTextures.end() )
- {
- TexturePointer texturePtr = textureIter->second;
- if( texturePtr )
- {
- texturePtr->Update( bitmap.Get(), xOffset, yOffset );
-
- ResourceId ppRequest( id );
- mTextureUploadedDispatcher.DispatchTextureUploaded(ppRequest);
- }
- }
-}
-
-void TextureCache::UpdateTexture( ResourceId destId, ResourceId srcId, std::size_t xOffset, std::size_t yOffset )
-{
- DALI_LOG_INFO(Debug::Filter::gGLResource, Debug::General, "TextureCache::UpdateTexture(destId=%i srcId=%i )\n", destId, srcId );
-
- BitmapTexture* srcTexture = TextureCache::GetBitmapTexture( srcId );
- Integration::BitmapPtr srcBitmap = ( srcTexture != NULL ) ? srcTexture->GetBitmap() : NULL;
-
- if( srcBitmap )
- {
- UpdateTexture( destId, srcBitmap, xOffset, yOffset );
- }
-}
-
-void TextureCache::UpdateTexture( ResourceId id, PixelDataPtr pixelData, std::size_t xOffset, std::size_t yOffset )
-{
- DALI_LOG_INFO(Debug::Filter::gGLResource, Debug::General, "TextureCache::UpdateTexture(id=%i pixel data:%p )\n", id, pixelData.Get());
-
- TextureIter textureIter = mTextures.find(id);
- if( textureIter != mTextures.end() )
- {
- TexturePointer texturePtr = textureIter->second;
- if( texturePtr )
- {
- texturePtr->Update( pixelData.Get(), xOffset, yOffset );
-
- ResourceId ppRequest( id );
- mTextureUploadedDispatcher.DispatchTextureUploaded(ppRequest);
- }
- }
-}
-
-void TextureCache::UpdateTextureArea( ResourceId id, const RectArea& area )
-{
- DALI_LOG_INFO(Debug::Filter::gGLResource, Debug::General, "TextureCache::UpdateTextureArea(id=%i)\n", id );
-
- TextureIter textureIter = mTextures.find(id);
- if( textureIter != mTextures.end() )
- {
- TexturePointer texturePtr = textureIter->second;
- if( texturePtr )
- {
- texturePtr->UpdateArea( area );
-
- ResourceId ppRequest( id );
- mTextureUploadedDispatcher.DispatchTextureUploaded(ppRequest);
- }
- }
-}
-
-void TextureCache::DiscardTexture( ResourceId id )
-{
- bool deleted = false;
-
- DALI_LOG_INFO(Debug::Filter::gGLResource, Debug::General, "TextureCache::DiscardTexture(id:%u)\n", id);
-
- if( mTextures.size() > 0)
- {
- TextureIter iter = mTextures.find(id);
- if( iter != mTextures.end() )
- {
- TexturePointer texturePtr = iter->second;
- if( texturePtr )
- {
- // if valid texture pointer, cleanup GL resources
- texturePtr->GlCleanup();
- }
- mTextures.erase(iter);
- deleted = true;
- }
- }
-
- if( mFramebufferTextures.size() > 0)
- {
- TextureIter iter = mFramebufferTextures.find(id);
- if( iter != mFramebufferTextures.end() )
- {
- TexturePointer texturePtr = iter->second;
- if( texturePtr )
- {
- // if valid texture pointer, cleanup GL resources
- texturePtr->GlCleanup();
- }
- mFramebufferTextures.erase(iter);
- deleted = true;
- }
- }
-
- if(deleted)
- {
- if( mObservers.size() > 0 )
- {
- TextureResourceObserversIter observersIter = mObservers.find(id);
- if( observersIter != mObservers.end() )
- {
- TextureObservers observers = observersIter->second;
- for( TextureObserversIter iter = observers.begin(); iter != observers.end(); ++iter )
- {
- TextureObserver* observer = *iter;
- observer->TextureDiscarded( id );
- }
-
- mObservers.erase( observersIter );
- }
- }
- }
-}
-
-bool TextureCache::BindTexture( Texture *texture, ResourceId id, GLenum target, TextureUnit textureunit )
-{
- unsigned int glTextureId = texture->GetTextureId();
-
- bool success = texture->Bind(target, textureunit);
- bool created = ( glTextureId == 0 ) && ( texture->GetTextureId() != 0 );
-
- if( created && texture->UpdateOnCreate() ) // i.e. the pixel data was sent to GL
- {
- ResourceId ppRequest( id );
- mTextureUploadedDispatcher.DispatchTextureUploaded(ppRequest);
- }
- return success;
-}
-
-Texture* TextureCache::GetTexture(ResourceId id)
-{
- Texture* texture = NULL;
- TextureIter iter = mTextures.find(id);
-
- if( iter != mTextures.end() )
- {
- TexturePointer texturePtr = iter->second;
- if( texturePtr )
- {
- texture = texturePtr.Get();
- }
- }
-
- if( texture == NULL )
- {
- TextureIter iter = mFramebufferTextures.find(id);
- if( iter != mFramebufferTextures.end() )
- {
- TexturePointer texturePtr = iter->second;
- if( texturePtr )
- {
- texture = texturePtr.Get();
- }
- }
- }
-
- DALI_LOG_INFO(Debug::Filter::gGLResource, Debug::General, "TextureCache::GetTexture(id:%u) : %p\n", id, texture);
-
- return texture;
-}
-
-BitmapTexture* TextureCache::GetBitmapTexture(ResourceId id)
-{
- BitmapTexture* texture = NULL;
- TextureIter iter = mTextures.find( id );
-
- if( iter != mTextures.end() )
- {
- TexturePointer texturePtr = iter->second;
- if( texturePtr )
- {
- texture = dynamic_cast< BitmapTexture* >( texturePtr.Get() );
- }
- }
-
- return texture;
-}
-
-FrameBufferTexture* TextureCache::GetFramebuffer(ResourceId id)
-{
- FrameBufferTexture* offscreen = NULL;
- TextureIter iter = mFramebufferTextures.find(id);
-
- DALI_ASSERT_DEBUG( iter != mFramebufferTextures.end() );
-
- if( iter != mFramebufferTextures.end() )
- {
- TexturePointer texturePtr = iter->second;
- if( texturePtr )
- {
- offscreen = dynamic_cast< FrameBufferTexture* >( texturePtr.Get() );
- }
- }
- DALI_ASSERT_DEBUG( offscreen );
-
- DALI_LOG_INFO(Debug::Filter::gGLResource, Debug::General, "TextureCache::GetFramebuffer(id:%u) : %p\n", id, offscreen);
-
- return offscreen;
-}
-
-void TextureCache::AddObserver( ResourceId id, TextureObserver* observer )
-{
- TextureResourceObserversIter observersIter = mObservers.find(id);
- if( observersIter != mObservers.end() )
- {
- TextureObservers& observers = observersIter->second;
- bool foundObserver = false;
- for( TextureObserversIter iter = observers.begin(); iter != observers.end(); ++iter )
- {
- if( *iter == observer )
- {
- foundObserver = true;
- break;
- }
- }
- if( ! foundObserver )
- {
- observers.push_back(observer);
- }
- }
- else
- {
- TextureObservers observers;
- observers.push_back(observer);
- mObservers.insert(std::pair<ResourceId, TextureObservers>(id, observers));
- }
-}
-
-void TextureCache::RemoveObserver( ResourceId id, TextureObserver* observer )
-{
- TextureResourceObserversIter observersIter = mObservers.find(id);
- if( observersIter != mObservers.end() )
- {
- TextureObservers& observers = observersIter->second;
- for( TextureObserversIter iter = observers.begin(); iter != observers.end(); ++iter )
- {
- if(*iter == observer)
- {
- observers.erase(iter);
- break;
- }
- }
- }
-}
-
-void TextureCache::GlContextDestroyed()
-{
- SceneGraph::GlContextDestroyed( mTextures );
- SceneGraph::GlContextDestroyed( mFramebufferTextures );
-}
-
-void TextureCache::SetDiscardBitmapsPolicy( ResourcePolicy::Discardable policy )
-{
- DALI_LOG_INFO( gTextureCacheFilter, Debug::General, "TextureCache::SetDiscardBitmapsPolicy(%s)\n",
- policy==ResourcePolicy::OWNED_DISCARD?"DISCARD":"RETAIN" );
- mDiscardBitmapsPolicy = policy;
-}
-
-ResourcePolicy::Discardable TextureCache::GetDiscardBitmapsPolicy()
-{
- return mDiscardBitmapsPolicy;
-}
-
-} // SceneGraph
-
-} // Internal
-
-} // Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_SCENE_GRAPH_TEXTURE_CACHE_H__
-#define __DALI_INTERNAL_SCENE_GRAPH_TEXTURE_CACHE_H__
-
-/*
- * Copyright (c) 2016 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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <stdint.h>
-
-// INTERNAL INCLUDES
-#include <dali/devel-api/common/map-wrapper.h>
-#include <dali/public-api/common/intrusive-ptr.h>
-#include <dali/public-api/images/frame-buffer-image.h>
-#include <dali/public-api/images/native-image.h>
-#include <dali/public-api/math/rect.h>
-#include <dali/public-api/math/vector4.h>
-#include <dali/integration-api/platform-abstraction.h>
-#include <dali/integration-api/resource-policies.h>
-#include <dali/integration-api/gl-abstraction.h>
-#include <dali/internal/common/owner-pointer.h>
-#include <dali/internal/event/images/pixel-data-impl.h>
-#include <dali/internal/event/resources/resource-client-declarations.h> // For RectArea
-#include <dali/internal/update/common/scene-graph-buffers.h>
-#include <dali/internal/render/gl-resources/texture-declarations.h>
-#include <dali/internal/render/gl-resources/texture-units.h>
-
-namespace Dali
-{
-class NativeImageInterface;
-
-
-namespace Integration
-{
-class Bitmap;
-typedef IntrusivePtr<Bitmap> BitmapPtr;
-}
-
-
-namespace Internal
-{
-class Context;
-class Texture;
-class BitmapTexture;
-class FrameBufferTexture;
-class TextureObserver;
-
-namespace SceneGraph
-{
-class RenderQueue;
-class TextureUploadedDispatcher;
-
-typedef std::map<ResourceId, TexturePointer > TextureContainer;
-typedef std::pair<ResourceId, TexturePointer > TexturePair;
-typedef TextureContainer::iterator TextureIter;
-typedef TextureContainer::const_iterator TextureConstIter;
-
-/**
- * Caches textures. Owned by Render Thread
- */
-class TextureCache
-{
-public:
- /**
- * Constructor
- * @param[in] renderQueue Queue to use for dispatching messages to this object
- * @param[in] postProcessDispatcher Dispatcher for resource post processing requests
- * @param[in] context GL Context
- */
- TextureCache( RenderQueue& renderQueue,
- TextureUploadedDispatcher& postProcessDispatcher,
- Context& context );
-
- /**
- * Destructor
- */
- ~TextureCache();
-
- /**
- * Creates a new empty texture object with the given dimensions.
- * @param[in] width The width (pixels)
- * @param[in] height The height (pixels)
- * @param[in] pixelFormat The pixel format
- * @param[in] clearPixels True if the pixel data should be cleared first
- */
- void CreateTexture( ResourceId id,
- unsigned int width,
- unsigned int height,
- Pixel::Format pixelFormat,
- bool clearPixels );
-
- /**
- * Add a bitmap to the texture cache
- * @param[in] id Resource Id of the bitmap
- * @param[in] bitmap The bitmap
- */
- void AddBitmap( ResourceId id, Integration::BitmapPtr bitmap );
-
- /**
- * Add a native image to the texture cache
- * @param[in] id Resource Id of the native image
- * @param[in] nativeImage The native image
- */
- void AddNativeImage( ResourceId id, NativeImageInterfacePtr nativeImage );
-
- /**
- * Create a framebuffer texture and add it to the texture cache
- * @param[in] id Resource Id of the native image
- * @param[in] width Width of the framebuffer
- * @param[in] height Height of the framebuffer
- * @param[in] pixelFormat Pixel format of the framebuffer
- * @param[in] bufferFormat Renderbuffer format of the framebuffer
- */
- void AddFrameBuffer( ResourceId id, unsigned int width, unsigned int height, Pixel::Format pixelFormat, RenderBuffer::Format bufferFormat );
-
- /**
- * Create a framebuffer texture and add it to the texture cache
- * @param[in] id Resource Id of the native image
- * @param[in] nativeImage The NativeImage
- */
- void AddFrameBuffer( ResourceId id, NativeImageInterfacePtr nativeImage );
-
- /**
- * Create GL texture eagerly right now instead of waiting for first use.
- * @param[in] id The resource id corresponding to the texture.
- */
- void CreateGlTexture( ResourceId id );
-
- /**
- * Update the texture with a newly loaded bitmap
- * @param[in] id Resource Id of the bitmap
- * @param[in] bitmap The bitmap
- */
- void UpdateTexture( ResourceId id, Integration::BitmapPtr bitmap );
-
- /**
- * Update the texture with a newly loaded bitmap
- * @param[in] id Resource Id of the bitmap
- * @param[in] bitmap The bitmap
- * @param[in] xOffset Specifies an offset in the x direction within the texture
- * @param[in] yOffset Specifies an offset in the y direction within the texture
- */
- void UpdateTexture( ResourceId id, Integration::BitmapPtr bitmap, std::size_t xOffset, std::size_t yOffset );
-
- /**
- * Update the part of a texture with a newly loaded bitmap
- * May be called from Update thread
- * @param[in] destId The ID of the texture to update
- * @param[in] srcId The resource ID of the source bitmap
- * @param[in] xOffset Specifies an offset in the x direction within the texture
- * @param[in] yOffset Specifies an offset in the y direction within the texture
- */
- void UpdateTexture( ResourceId destId, ResourceId srcId, std::size_t xOffset, std::size_t yOffset );
-
- /**
- * Update the texture with a pixel buffer
- * @param[in] id Resource Id of the bitmap
- * @param[in] pixelData The pixel data
- * @param[in] xOffset Specifies an offset in the x direction within the texture
- * @param[in] yOffset Specifies an offset in the y direction within the texture
- */
- void UpdateTexture( ResourceId id, PixelDataPtr pixelData, std::size_t xOffset, std::size_t yOffset );
-
- /**
- * Update the area of the texture from the associated bitmap
- * @param[in] id Resource Id of the bitmap
- * @param[in] area The area of the bitmap that has changed
- */
- void UpdateTextureArea( ResourceId id, const RectArea& area );
-
- /**
- * Discard texture associated with resource ID
- * @param[in] id Resource Id of the texture
- */
- void DiscardTexture( ResourceId id );
-
- /**
- * Bind a texture. On the first call, the texture will copy it's
- * pixel data to an OpenGL texture. If it's a BitmapTexture, then
- * it will also trigger SignalUpdated to be sent on the event thread
- * object.
- *
- * @param[in] texture pointer to the texture
- * @param[in] id Resource id of texture
- * @param[in] target (e.g. GL_TEXTURE_2D)
- * @param[in] textureunit to use
- *
- * @return true if the bind succeeded, false if either the create or bind failed.
- */
- bool BindTexture( Texture* texture, ResourceId id, GLenum target, TextureUnit textureunit );
-
- /**
- * Get the texture associated with the resource ID
- * May be a texture or a framebuffer
- * @param[in] id Resource Id of the texture
- * @return NULL if the GL resource hasn't yet been created,
- * or a valid pointer if it has.
- */
- Texture* GetTexture( ResourceId id );
-
- /**
- * Get the bitmaptexture associated with the resource ID
- * @param[in] id Resource Id of the texture
- * @return The texture or NULL
- */
- BitmapTexture* GetBitmapTexture(ResourceId id);
-
- /**
- * Get the framebuffer texture associated with the resource ID
- * Used for writing to the framebuffer
- * @param[in] id Resource Id of the framebuffer
- * @return the framebuffer
- */
- FrameBufferTexture* GetFramebuffer(ResourceId id);
-
- /**
- * Add a texture observer. Should be called in render thread
- * @param[in] id The resource id to watch
- * @param[in] observer The observer to add
- */
- void AddObserver( ResourceId id, TextureObserver* observer );
-
- /**
- * Remove a texture observer. Should be called in render thread
- * @param[in] id The resource id to stop watching
- * @param[in] observer The observer to remove
- */
- void RemoveObserver( ResourceId id, TextureObserver* observer );
-
- /**
- * Reset all textures.
- * This method is called when context is or has been deleted.
- */
- void GlContextDestroyed();
-
- /**
- * Set whether textures should retain or discard their bitmaps after upload to GL
- * @param[in] policy Whether to retain or discard bitmaps
- */
- void SetDiscardBitmapsPolicy( ResourcePolicy::Discardable policy );
-
- /**
- * Get the discard policy.
- * @return The discard policy.
- */
- ResourcePolicy::Discardable GetDiscardBitmapsPolicy();
-
-private:
-
- TextureUploadedDispatcher& mTextureUploadedDispatcher;
- Context& mContext;
- TextureContainer mTextures;
- TextureContainer mFramebufferTextures;
-
- typedef std::vector< TextureObserver* > TextureObservers;
- typedef TextureObservers::iterator TextureObserversIter;
-
- typedef std::map< ResourceId, TextureObservers > TextureResourceObservers;
- typedef TextureResourceObservers::iterator TextureResourceObserversIter;
-
- TextureResourceObservers mObservers;
- ResourcePolicy::Discardable mDiscardBitmapsPolicy;
-};
-
-
-
-} // SceneGraph
-} // Internal
-} // Dali
-
-#endif //__DALI_INTERNAL_SCENE_GRAPH_TEXTURE_CACHE_H__
+++ /dev/null
-#ifndef __DALI_INTERNAL_TEXTURE_DECLARATIONS_H__
-#define __DALI_INTERNAL_TEXTURE_DECLARATIONS_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/object/ref-object.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-class Texture;
-typedef IntrusivePtr<Texture> TexturePointer;
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_TEXTURE_DECLARATIONS_H__
+++ /dev/null
-/*
- * 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.
- *
- */
-
-#include "texture-factory.h"
-
-#include <dali/integration-api/bitmap.h>
-#include <dali/integration-api/gl-defines.h>
-#include <dali/internal/render/gl-resources/bitmap-texture.h>
-#include <dali/internal/render/gl-resources/compressed-bitmap-texture.h>
-#include <dali/internal/render/gl-resources/native-texture.h>
-#include <dali/internal/render/gl-resources/frame-buffer-texture.h>
-#include <dali/internal/render/gl-resources/gl-texture.h>
-
-
-namespace Dali
-{
-class NativeImageInterface;
-
-namespace Internal
-{
-
-namespace TextureFactory
-{
-
-Internal::Texture* NewBitmapTexture( Integration::Bitmap* const bitmap, Context& context, ResourcePolicy::Discardable discardPolicy )
-{
- DALI_ASSERT_DEBUG( bitmap );
- Texture * texture = 0;
- Integration::Bitmap::PackedPixelsProfile * const packedPixelBitmapView = bitmap->GetPackedPixelsProfile();
- if( packedPixelBitmapView )
- {
- texture = new BitmapTexture( bitmap, packedPixelBitmapView, context, discardPolicy );
- }
- else
- {
- Internal::BitmapCompressed * const compressedBitmap = dynamic_cast<Dali::Internal::BitmapCompressed*>( bitmap );
- if( compressedBitmap != 0 )
- {
- texture = new CompressedBitmapTexture( compressedBitmap, context, discardPolicy );
- }
- }
- if( texture )
- {
- if( !texture->Init() )
- {
- delete texture;
- return NULL;
- }
- }
- return texture;
-}
-
-Internal::Texture* NewBitmapTexture( unsigned int width,
- unsigned int height,
- Pixel::Format pixelFormat,
- bool clearPixels,
- Context& context,
- ResourcePolicy::Discardable discardPolicy )
-{
- Texture *texture=new BitmapTexture(width, height, pixelFormat, clearPixels, context, discardPolicy);
-
- return texture;
-}
-
-
-Internal::Texture* NewNativeImageTexture( NativeImageInterface& nativeImg, Context& context )
-{
- NativeTexture* texture = new NativeTexture(&nativeImg, context);
- if (!texture->Init())
- {
- delete texture;
- return NULL;
- }
- return texture;
-}
-
-Internal::Texture* NewFrameBufferTexture( unsigned int width,
- unsigned int height,
- Pixel::Format pixelFormat,
- RenderBuffer::Format bufferFormat,
- Context& context )
-{
- FrameBufferTexture* texture = new FrameBufferTexture(width, height, pixelFormat, bufferFormat, context);
- if (!texture->Init())
- {
- delete texture;
- return NULL;
- }
- return texture;
-}
-
-Internal::Texture* NewFrameBufferTexture( NativeImageInterfacePtr nativeImage,
- Context& context )
-{
- FrameBufferTexture* texture = new FrameBufferTexture(nativeImage, context);
- if (!texture->Init())
- {
- delete texture;
- return NULL;
- }
- return texture;
-}
-
-
-
-} // TextureFactory
-} // Internal
-} // Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_TEXTURE_FACTORY_H__
-#define __DALI_INTERNAL_TEXTURE_FACTORY_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/object/ref-object.h>
-#include <dali/public-api/images/native-image-interface.h>
-#include <dali/internal/render/gl-resources/texture-cache.h>
-
-namespace Dali
-{
-class NativeImageInterface;
-
-namespace Integration
-{
-class Bitmap;
-}
-
-namespace Internal
-{
-class Context;
-class Texture;
-
-namespace TextureFactory
-{
-/**
- * Creates a new texture object from a Bitmap
- * @param[in] bitmap The Bitmap
- * @param[in] context The GL context
- * @return A newly allocated texture
- */
-Internal::Texture* NewBitmapTexture( Integration::Bitmap* const bitmap,
- Context& context,
- ResourcePolicy::Discardable discardPolicy );
-
-/**
- * Creates a new bitmap texture object of the given dimensions.
- * @param[in] width The width (pixels)
- * @param[in] height The height (pixels)
- * @param[in] pixelFormat The pixel format
- * @param[in] clearPixels True if the pixel data should be cleared first
- * @param[in] context The GL context
- */
-Internal::Texture* NewBitmapTexture( unsigned int width,
- unsigned int height,
- Pixel::Format pixelFormat,
- bool clearPixels,
- Context& context,
- ResourcePolicy::Discardable discardPolicy );
-
-/**
- * Creates a texture object from a native image (eg.: EGLImage).
- * @param[in] nativeImage The native image to load
- * @param[in] context The GL context
- * @return A newly allocated texture
- */
-Internal::Texture* NewNativeImageTexture( NativeImageInterface& nativeImage, Context& context );
-
-/**
- * @copydoc FrameBufferTexture::FrameBufferTexture
- * @return A newly allocated texture
- */
-Internal::Texture* NewFrameBufferTexture( unsigned int width,
- unsigned int height,
- Pixel::Format pixelFormat,
- RenderBuffer::Format bufferFormat,
- Context& context );
-
-/**
- * @copydoc FrameBufferTexture::FrameBufferTexture
- * @return A newly allocated texture
- */
-Internal::Texture* NewFrameBufferTexture( NativeImageInterfacePtr nativeImage, Context& context );
-
-};
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_TEXTURE_FACTORY_H__
+++ /dev/null
-#ifndef __DALI_INTERNAL_TEXTURE_OBSERVER_H__
-#define __DALI_INTERNAL_TEXTURE_OBSERVER_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.
- *
- */
-
-namespace Dali
-{
-namespace Internal
-{
-
-/**
- * The TextureObserver observes texture lifetime
- */
-class TextureObserver
-{
-public:
- /**
- * Called when a texture is discarded. This occurs in the render thread.
- * @param[in] textureId The resource id of the discarded texture
- */
- virtual void TextureDiscarded( unsigned int textureId ) = 0;
-
-protected:
- /**
- * Virtual destructor
- */
- virtual ~TextureObserver(){}
-};
-
-}//Internal
-}//Dali
-
-#endif // __DALI_INTERNAL_TEXTURE_OBSERVER_H__
context.BindFramebuffer( GL_FRAMEBUFFER, 0 );
}
-void FrameBuffer::AttachColorTexture( Context& context, Render::NewTexture* texture, unsigned int mipmapLevel, unsigned int layer )
+void FrameBuffer::AttachColorTexture( Context& context, Render::Texture* texture, unsigned int mipmapLevel, unsigned int layer )
{
context.BindFramebuffer( GL_FRAMEBUFFER, mId );
{
namespace Render
{
-class NewTexture;
+class Texture;
class FrameBuffer
{
* @param[in] mipmapLevel The mipmap of the texture to be attached
* @param[in] layer Indicates which layer of a cube map or array texture to attach. Unused for 2D textures
*/
- void AttachColorTexture( Context& context, Render::NewTexture* texture, unsigned int mipmapLevel, unsigned int layer );
+ void AttachColorTexture( Context& context, Render::Texture* texture, unsigned int mipmapLevel, unsigned int layer );
/**
* @brief Bind the framebuffer
#include <dali/internal/render/shaders/scene-graph-shader.h>
#include <dali/internal/render/shaders/program.h>
#include <dali/internal/render/data-providers/node-data-provider.h>
-#include <dali/internal/render/gl-resources/texture-cache.h>
-#include <dali/internal/render/gl-resources/gl-texture.h>
namespace Dali
{
StencilParameters& stencilParameters )
: mRenderDataProvider( dataProvider ),
mContext( NULL),
- mTextureCache( NULL ),
mGeometry( geometry ),
mUniformIndexMap(),
mAttributesLocation(),
}
}
-void Renderer::Initialize( Context& context, SceneGraph::TextureCache& textureCache )
+void Renderer::Initialize( Context& context )
{
mContext = &context;
- mTextureCache = &textureCache;
}
Renderer::~Renderer()
mUpdateAttributesLocation = true;
//Check that the number of textures match the number of samplers in the shader
- size_t textureCount = dataProvider->GetNewTextures().size();
+ size_t textureCount = dataProvider->GetTextures().size();
Program* program = dataProvider->GetShader().GetProgram();
if( program && program->GetActiveSamplerCount() != textureCount )
{
}
}
-bool Renderer::BindTextures( Context& context, SceneGraph::TextureCache& textureCache, Program& program )
+bool Renderer::BindTextures( Context& context, Program& program )
{
unsigned int textureUnit = 0;
bool result = true;
GLint uniformLocation(-1);
std::vector<Render::Sampler*>& samplers( mRenderDataProvider->GetSamplers() );
- std::vector<Render::NewTexture*>& newTextures( mRenderDataProvider->GetNewTextures() );
- for( size_t i(0); i<newTextures.size() && result; ++i )
+ std::vector<Render::Texture*>& textures( mRenderDataProvider->GetTextures() );
+ for( size_t i(0); i<textures.size() && result; ++i )
{
- if( newTextures[i] )
+ if( textures[i] )
{
- result = newTextures[i]->Bind(context, textureUnit, samplers[i] );
+ result = textures[i]->Bind(context, textureUnit, samplers[i] );
if( result && program.GetSamplerUniformLocation( i, uniformLocation ) )
{
program.SetUniform1i( uniformLocation, textureUnit );
}
void Renderer::Render( Context& context,
- SceneGraph::TextureCache& textureCache,
BufferIndex bufferIndex,
const SceneGraph::NodeDataProvider& node,
SceneGraph::Shader& defaultShader,
// Take the program into use so we can send uniforms to it
program->Use();
- if( DALI_LIKELY( BindTextures( context, textureCache, *program ) ) )
+ if( DALI_LIKELY( BindTextures( context, *program ) ) )
{
// Only set up and draw if we have textures and they are all valid
{
class SceneController;
class Shader;
-class TextureCache;
class NodeDataProvider;
}
* Second-phase construction.
* This is called when the renderer is inside render thread
* @param[in] context Context used by the renderer
- * @param[in] textureCache The texture cache to use
*/
- void Initialize( Context& context, SceneGraph::TextureCache& textureCache );
+ void Initialize( Context& context );
/**
* Destructor
/**
* Called to render during RenderManager::Render().
* @param[in] context The context used for rendering
- * @param[in] textureCache The texture cache used to get textures
* @param[in] bufferIndex The index of the previous update buffer.
* @param[in] node The node using this renderer
* @param[in] defaultShader in case there is no custom shader
* @param[in] blend If true, blending is enabled
*/
void Render( Context& context,
- SceneGraph::TextureCache& textureCache,
BufferIndex bufferIndex,
const SceneGraph::NodeDataProvider& node,
SceneGraph::Shader& defaultShader,
/**
* Bind the textures and setup the samplers
* @param[in] context The GL context
- * @param[in] textureCache The texture cache
* @param[in] program The shader program
* @return False if create or bind failed, true if success.
*/
- bool BindTextures( Context& context, SceneGraph::TextureCache& textureCache, Program& program );
+ bool BindTextures( Context& context, Program& program );
private:
OwnerPointer< SceneGraph::RenderDataProvider > mRenderDataProvider;
Context* mContext;
- SceneGraph::TextureCache* mTextureCache;
Render::Geometry* mGeometry;
struct UniformIndexMap
} //Unnamed namespace
-NewTexture::NewTexture( Type type, Pixel::Format format, unsigned int width, unsigned int height )
+Texture::Texture( Type type, Pixel::Format format, unsigned int width, unsigned int height )
:mId( 0 ),
mTarget( (type == TextureType::TEXTURE_2D)? GL_TEXTURE_2D : GL_TEXTURE_CUBE_MAP ),
mType( type ),
PixelFormatToGl( format, mPixelDataType, mInternalFormat );
}
-NewTexture::NewTexture( NativeImageInterfacePtr nativeImageInterface )
+Texture::Texture( NativeImageInterfacePtr nativeImageInterface )
:mId( 0 ),
mTarget( GL_TEXTURE_2D ),
mType( TextureType::TEXTURE_2D ),
{
}
-NewTexture::~NewTexture()
+Texture::~Texture()
{}
-void NewTexture::Destroy( Context& context )
+void Texture::Destroy( Context& context )
{
if( mId )
{
}
}
-void NewTexture::GlContextDestroyed()
+void Texture::GlContextDestroyed()
{
mId = 0u;
}
-void NewTexture::Initialize(Context& context)
+void Texture::Initialize(Context& context)
{
if( mNativeImage )
{
}
}
-void NewTexture::Upload( Context& context, PixelDataPtr pixelData, const Internal::NewTexture::UploadParams& params )
+void Texture::Upload( Context& context, PixelDataPtr pixelData, const Internal::Texture::UploadParams& params )
{
DALI_ASSERT_ALWAYS( mNativeImage == NULL );
delete[] tempBuffer;
}
-bool NewTexture::Bind( Context& context, unsigned int textureUnit, Render::Sampler* sampler )
+bool Texture::Bind( Context& context, unsigned int textureUnit, Render::Sampler* sampler )
{
if( mNativeImage && mId == 0 )
{
return false;
}
-void NewTexture::ApplySampler( Context& context, Render::Sampler* sampler )
+void Texture::ApplySampler( Context& context, Render::Sampler* sampler )
{
Render::Sampler oldSampler = mSampler;
mSampler = sampler ? *sampler : Sampler();
}
}
-bool NewTexture::HasAlphaChannel()
+bool Texture::HasAlphaChannel()
{
return mHasAlpha;
}
-void NewTexture::GenerateMipmaps( Context& context )
+void Texture::GenerateMipmaps( Context& context )
{
context.BindTexture( mTarget, mId );
context.GenerateMipmap( mTarget );
#include <dali/internal/render/gl-resources/context.h>
#include <dali/internal/render/renderers/render-sampler.h>
#include <dali/integration-api/gl-defines.h>
-#include <dali/integration-api/resource-declarations.h>
namespace Dali
{
{
struct Sampler;
-/**
- * This class is the mapping between texture id, sampler and sampler uniform name
- */
class Texture
{
public:
- /**
- * Constructor
- */
- Texture()
- : mSampler( 0 ),
- mTextureId( Integration::InvalidResourceId )
- {}
-
- /**
- * Constructor
- */
- Texture( Integration::ResourceId textureId, Render::Sampler* sampler )
- : mSampler( sampler ),
- mTextureId( textureId)
- {}
-
- /**
- * Destructor
- */
- ~Texture()
- {}
-
- /*
- * Get the Render::Sampler used by the texture
- * @Return The Render::Sampler being used or 0 if using the default
- */
- inline const Render::Sampler* GetSampler() const
- {
- return mSampler;
- }
-
-public: // called from RenderThread
-
- /**
- * Get the texture ID
- * @return the id of the associated texture
- */
- inline Integration::ResourceId GetTextureId() const
- {
- return mTextureId;
- }
-
-private:
-
- Render::Sampler* mSampler;
- Integration::ResourceId mTextureId;
-};
-
-
-//TODO : Remove the old Render::Texture class (see above) once it is no longer needed by Image
-class NewTexture
-{
-public:
-
typedef Dali::TextureType::Type Type;
/**
* @param[in] width The width of the texture
* @param[in] height The height of the texture
*/
- NewTexture( Type type, Pixel::Format format, unsigned int width, unsigned int height );
+ Texture( Type type, Pixel::Format format, unsigned int width, unsigned int height );
/**
* Constructor from native image
* @param[in] nativeImageInterface The native image
*/
- NewTexture( NativeImageInterfacePtr nativeImageInterface );
+ Texture( NativeImageInterfacePtr nativeImageInterface );
/**
* Destructor
*/
- ~NewTexture();
+ ~Texture();
/**
* Creates the texture in the GPU.
* @param[in] pixelData A pixel data object
* @param[in] params Upload parameters. See UploadParams
*/
- void Upload( Context& context, PixelDataPtr pixelData, const Internal::NewTexture::UploadParams& params );
+ void Upload( Context& context, PixelDataPtr pixelData, const Internal::Texture::UploadParams& params );
/**
* Bind the texture to the given texture unit and applies the given sampler
// INTERNAL INCLUDES
#include <dali/integration-api/gl-defines.h>
#include <dali/internal/common/shader-saver.h>
-#include <dali/internal/render/common/texture-uploaded-dispatcher.h>
#include <dali/internal/render/gl-resources/gl-call-debug.h>
#include <dali/internal/render/shaders/program.h>
-#include <dali/internal/update/resources/resource-manager-declarations.h>
namespace Dali
{
+++ /dev/null
-/*
- * Copyright (c) 2016 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.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/update/common/texture-cache-dispatcher.h>
-
-// INTERNAL INCLUDES
-#include <dali/internal/render/queue/render-queue.h>
-#include <dali/internal/render/gl-resources/texture-cache.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-// value types used by messages
-template <> struct ParameterType< Pixel::Format > : public BasicType< Pixel::Format > {};
-template <> struct ParameterType< RenderBuffer::Format > : public BasicType< RenderBuffer::Format > {};
-
-namespace SceneGraph
-{
-
-TextureCacheDispatcher::TextureCacheDispatcher( RenderQueue& renderQueue, TextureCache& textureCache )
-: mRenderQueue( renderQueue ),
- mTextureCache( textureCache ),
- mSceneGraphBuffers(NULL)
-{
-}
-
-TextureCacheDispatcher::~TextureCacheDispatcher()
-{
-}
-
-void TextureCacheDispatcher::SetBufferIndices( const SceneGraphBuffers* bufferIndices )
-{
- mSceneGraphBuffers = bufferIndices;
-}
-
-/********************************************************************************
- ********************** Implements TextureCacheDispatcher *********************
- ********************************************************************************/
-
-void TextureCacheDispatcher::DispatchCreateTexture( ResourceId id,
- unsigned int width,
- unsigned int height,
- Pixel::Format pixelFormat,
- bool clearPixels )
-{
- // NULL, means being shutdown, so ignore msgs
- if( mSceneGraphBuffers != NULL )
- {
- typedef MessageValue5< TextureCache, ResourceId, unsigned int, unsigned int, Pixel::Format, bool > 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( &mTextureCache, &TextureCache::CreateTexture, id, width, height, pixelFormat, clearPixels );
- }
-}
-
-void TextureCacheDispatcher::DispatchCreateTextureForBitmap( ResourceId id, Integration::Bitmap* bitmap )
-{
- // NULL, means being shutdown, so ignore msgs
- if( mSceneGraphBuffers != NULL )
- {
- typedef MessageValue2< TextureCache, ResourceId, Integration::BitmapPtr > 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( &mTextureCache, &TextureCache::AddBitmap, id, bitmap );
- }
-}
-
-void TextureCacheDispatcher::DispatchCreateTextureForNativeImage( ResourceId id, NativeImageInterfacePtr nativeImage )
-{
- // NULL, means being shutdown, so ignore msgs
- if( mSceneGraphBuffers != NULL )
- {
- typedef MessageValue2< TextureCache, ResourceId, NativeImageInterfacePtr > 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( &mTextureCache, &TextureCache::AddNativeImage, id, nativeImage );
- }
-}
-
-void TextureCacheDispatcher::DispatchCreateGlTexture( ResourceId id )
-{
- // NULL, means being shutdown, so ignore msgs
- if( mSceneGraphBuffers != NULL )
- {
- typedef MessageValue1< TextureCache, ResourceId > 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( &mTextureCache, &TextureCache::CreateGlTexture, id );
- }
-}
-
-void TextureCacheDispatcher::DispatchCreateTextureForFrameBuffer( ResourceId id, unsigned int width, unsigned int height, Pixel::Format pixelFormat, RenderBuffer::Format bufferFormat )
-{
- // NULL, means being shutdown, so ignore msgs
- if( mSceneGraphBuffers != NULL )
- {
- typedef MessageValue5< TextureCache, ResourceId, unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format > 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( &mTextureCache, &TextureCache::AddFrameBuffer, id, width, height, pixelFormat, bufferFormat );
- }
-}
-
-void TextureCacheDispatcher::DispatchCreateTextureForFrameBuffer( ResourceId id, NativeImageInterfacePtr nativeImage )
-{
- // NULL, means being shutdown, so ignore msgs
- if( mSceneGraphBuffers != NULL )
- {
- typedef MessageValue2< TextureCache, ResourceId, NativeImageInterfacePtr > 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( &mTextureCache, &TextureCache::AddFrameBuffer, id, nativeImage );
- }
-}
-
-void TextureCacheDispatcher::DispatchUpdateTexture( ResourceId id, Integration::Bitmap* bitmap )
-{
- // NULL, means being shutdown, so ignore msgs
- if( mSceneGraphBuffers != NULL )
- {
- typedef MessageValue2< TextureCache, ResourceId, Integration::BitmapPtr > 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( &mTextureCache, &TextureCache::UpdateTexture, id, bitmap );
- }
-}
-
-void TextureCacheDispatcher::DispatchUpdateTexture( ResourceId id, Integration::BitmapPtr bitmap , std::size_t xOffset, std::size_t yOffset)
-{
- // NULL, means being shutdown, so ignore msgs
- if( mSceneGraphBuffers != NULL )
- {
- typedef MessageValue4< TextureCache, ResourceId, Integration::BitmapPtr, std::size_t, std::size_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( &mTextureCache, &TextureCache::UpdateTexture, id, bitmap, xOffset, yOffset );
- }
-}
-
-void TextureCacheDispatcher::DispatchUpdateTexture( ResourceId destId, ResourceId srcId, std::size_t xOffset, std::size_t yOffset )
-{
- // NULL, means being shutdown, so ignore msgs
- if( mSceneGraphBuffers != NULL )
- {
- typedef MessageValue4< TextureCache, ResourceId, ResourceId, std::size_t, std::size_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( &mTextureCache, &TextureCache::UpdateTexture, destId, srcId, xOffset, yOffset );
- }
-}
-
-void TextureCacheDispatcher::DispatchUpdateTexture( ResourceId id, PixelDataPtr pixelData , std::size_t xOffset, std::size_t yOffset)
-{
- // NULL, means being shutdown, so ignore msgs
- if( mSceneGraphBuffers != NULL )
- {
- typedef MessageValue4< TextureCache, ResourceId, PixelDataPtr, std::size_t, std::size_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( &mTextureCache, &TextureCache::UpdateTexture, id, pixelData, xOffset, yOffset );
- }
-}
-
-void TextureCacheDispatcher::DispatchUpdateTextureArea( ResourceId id, const Dali::RectArea& area )
-{
- // NULL, means being shutdown, so ignore msgs
- if( mSceneGraphBuffers != NULL )
- {
- typedef MessageValue2< TextureCache, ResourceId, Dali::RectArea > 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( &mTextureCache, &TextureCache::UpdateTextureArea, id, area );
- }
-}
-
-void TextureCacheDispatcher::DispatchDiscardTexture( ResourceId id )
-{
- // NULL, means being shutdown, so ignore msgs
- if( mSceneGraphBuffers != NULL )
- {
- typedef MessageValue1< TextureCache, ResourceId > 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( &mTextureCache, &TextureCache::DiscardTexture, id );
- }
-}
-
-} // SceneGraph
-
-} // Internal
-
-} // Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_TEXTURE_CACHE_DISPATCHER_H__
-#define __DALI_INTERNAL_TEXTURE_CACHE_DISPATCHER_H__
-
-/*
- * Copyright (c) 2016 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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <stdint.h>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/images/buffer-image.h>
-#include <dali/public-api/images/frame-buffer-image.h>
-#include <dali/public-api/images/native-image-interface.h>
-#include <dali/public-api/images/pixel.h>
-#include <dali/internal/common/message.h>
-#include <dali/internal/event/images/pixel-data-impl.h>
-#include <dali/internal/update/common/scene-graph-buffers.h>
-#include <dali/integration-api/resource-declarations.h>
-#include <dali/integration-api/bitmap.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-typedef Integration::ResourceId ResourceId;
-
-namespace SceneGraph
-{
-
-class RenderQueue;
-class TextureCache;
-
-class TextureCacheDispatcher
-{
-public:
-
- /**
- * Constructor
- * @param[in] renderQueue The queue on which to send messages
- * @param[in] textureCache The Texture Cache object to which to send messages
- */
- TextureCacheDispatcher( RenderQueue& renderQueue, TextureCache& textureCache );
-
- /**
- * Destructor.
- */
- ~TextureCacheDispatcher();
-
- /**
- * mRenderQueue needs the update buffer index when any of the dispatch methods are
- * called. Should really store a functor to get this index, but existing functors
- * use references. Could heap allocate the functor, but that seems overly wasteful.
- * Instead, store a pointer to the SceneGraphBuffers object, and call the relevant
- * function when required. (increases coupling, requires object lifetime management :/ )
- *
- * @param[in] bufferIndices Pointer to SceneGraphBuffers object that can query
- * the current RenderQueue buffer index.
- */
- void SetBufferIndices( const SceneGraphBuffers* bufferIndices );
-
- /**
- * Dispatch a message to create an empty texture and add it to the texture cache.
- * May be called from Update thread
- * @param[in] id Resource Id of the texture
- * @param[in] width Width of the texture
- * @param[in] height Height of the texture
- * @param[in] pixelFormat Pixel format of the texture
- * @param[in] clearPixels True if the data should be cleared to 0 on creation
- */
- void DispatchCreateTexture( ResourceId id,
- unsigned int width,
- unsigned int height,
- Pixel::Format pixelFormat,
- bool clearPixels );
-
- /**
- * Dispatch a message to add a texture for bitmap.
- * May be called from Update thread
- * @param[in] id Resource Id of the bitmap
- * @param[in] bitmap The bitmap
- */
- void DispatchCreateTextureForBitmap( ResourceId id, Integration::Bitmap* bitmap );
-
- /**
- * Dispatch a message to add a native image to the texture cache
- * May be called from Update thread
- * @param[in] id Resource Id of the native image
- * @param[in] nativeImage The native image
- */
- void DispatchCreateTextureForNativeImage( ResourceId id, NativeImageInterfacePtr nativeImage );
-
- /**
- * Dispatch a message to create a framebuffer texture and add it to the texture cache
- * May be called from Update thread
- * @param[in] id Resource Id of the framebuffer
- * @param[in] width Width of the framebuffer
- * @param[in] height Height of the framebuffer
- * @param[in] pixelFormat Pixel format of the framebuffer
- */
- void DispatchCreateTextureForFrameBuffer( ResourceId id, unsigned int width, unsigned int height, Pixel::Format pixelFormat, RenderBuffer::Format bufferFormat );
-
- /**
- * Dispatch a message to create a framebuffer texture and add it to the texture cache
- * May be called from Update thread
- * @param[in] id Resource Id of the framebuffer
- * @param[in] nativeImage The NativeImage
- */
- void DispatchCreateTextureForFrameBuffer( ResourceId id, NativeImageInterfacePtr nativeImage );
-
- /**
- * @brief Create GL texture for native image resource.
- * @param[in] id The resource id.
- */
- void DispatchCreateGlTexture( ResourceId id );
-
- /**
- * Dispatch a message to update the texture.
- * May be called from Update thread
- * @param[in] id Resource Id of the texture
- * @param[in] bitmap The updated bitmap
- */
- void DispatchUpdateTexture( ResourceId id, Integration::Bitmap* bitmap );
-
- /**
- * Dispatch a message to update the part of a texture with the bitmap data.
- * May be called from Update thread
- * @param[in] destId The ID of the texture to update
- * @param[in] bitmap The pointer pointing to the source bitmap data.
- * @param [in] xOffset Specifies an offset in the x direction within the texture
- * @param [in] yOffset Specifies an offset in the y direction within the texture
- */
- void DispatchUpdateTexture( ResourceId id, Integration::BitmapPtr bitmap, std::size_t xOffset, std::size_t yOffset );
-
- /**
- * Dispatch a message to update the part of a texture with a newly loaded bitmap
- * May be called from Update thread
- * @param[in] destId The ID of the texture to update
- * @param[in] srcId The resource ID of the source bitmap
- * @param [in] xOffset Specifies an offset in the x direction within the texture
- * @param [in] yOffset Specifies an offset in the y direction within the texture
- */
- void DispatchUpdateTexture( ResourceId destId, ResourceId srcId, std::size_t xOffset, std::size_t yOffset );
-
- /**
- * Dispatch a message to update the part of a texture with the pixel data.
- * May be called from Update thread
- * @param[in] destId The ID of the texture to update
- * @param[in] pixelData The pointer pointing to the pixel data to upload.
- * @param [in] xOffset Specifies an offset in the x direction within the texture
- * @param [in] yOffset Specifies an offset in the y direction within the texture
- */
- void DispatchUpdateTexture( ResourceId id, PixelDataPtr pixelData, std::size_t xOffset, std::size_t yOffset );
-
- /**
- * Dispatch a message to update the texture area
- * May be called from the Update thread
- * @param[in] id Resource Id of the texture
- * @param[in] area The area of the bitmap that has changed
- */
- void DispatchUpdateTextureArea( ResourceId id, const RectArea& area );
-
- /**
- * Dispatch a message to discard a texture
- * May be called from Update thread
- * @param[in] id Resource Id of the texture
- */
- void DispatchDiscardTexture( ResourceId id );
-
-protected:
-
- RenderQueue& mRenderQueue;
- TextureCache& mTextureCache;
- const SceneGraphBuffers* mSceneGraphBuffers;
-};
-
-} // SceneGraph
-
-} // Internal
-
-} // Dali
-
-#endif // __DALI_INTERNAL_TEXTURE_CACHE_DISPATCHER_H__
#include <dali/internal/update/manager/sorted-layers.h>
#include <dali/internal/update/render-tasks/scene-graph-render-task.h>
#include <dali/internal/update/rendering/scene-graph-texture-set.h>
-#include <dali/internal/update/resources/resource-manager-declarations.h>
#include <dali/internal/render/common/render-item.h>
#include <dali/internal/render/common/render-tracker.h>
#include <dali/internal/render/common/render-instruction.h>
* Whilst iterating through each layer, update the RenderItems ModelView matrices
*
* The opaque and transparent render lists are sorted first by depth
- * index, then by Z (for transparent only), then by shader, texture
+ * index, then by Z (for transparent only), then by shader
* and geometry. The render algorithm should then work through both
* lists simultaneously, working through opaque then transparent
* items at each depth index, resetting the flags appropriately.
#include <dali/public-api/actors/draw-mode.h>
#include <dali/public-api/math/matrix.h>
#include <dali/public-api/math/vector3.h>
-#include <dali/internal/update/resources/resource-manager.h>
#include <dali/internal/update/nodes/node.h>
#include <dali/internal/update/animation/scene-graph-constraint-base.h>
#include <dali/internal/update/nodes/scene-graph-layer.h>
inline int UpdateNodes( Node& node,
int parentFlags,
BufferIndex updateBufferIndex,
- ResourceManager& resourceManager,
RenderQueue& renderQueue,
Layer& currentLayer,
int inheritedDrawMode )
cumulativeDirtyFlags |=UpdateNodes( child,
nodeDirtyFlags,
updateBufferIndex,
- resourceManager,
renderQueue,
*layer,
inheritedDrawMode );
*/
int UpdateNodeTree( Layer& rootNode,
BufferIndex updateBufferIndex,
- ResourceManager& resourceManager,
RenderQueue& renderQueue )
{
DALI_ASSERT_DEBUG( rootNode.IsRoot() );
cumulativeDirtyFlags |= UpdateNodes( child,
nodeDirtyFlags,
updateBufferIndex,
- resourceManager,
renderQueue,
rootNode,
drawMode );
namespace Internal
{
-class ResourceManager;
-
namespace SceneGraph
{
* The inherited properties of each node are recalculated if necessary.
* @param[in] rootNode The root of a tree of nodes.
* @param[in] updateBufferIndex The current update buffer index.
- * @param[in] resourceManager The resource manager.
* @param[in] renderQueue Used to query messages for the next Render.
* @return The cumulative (ORed) dirty flags for the updated nodes
*/
int UpdateNodeTree( Layer& rootNode,
BufferIndex updateBufferIndex,
- ResourceManager& resourceManager,
RenderQueue& renderQueue );
} // namespace SceneGraph
#include <dali/internal/update/animation/scene-graph-animation.h>
#include <dali/internal/update/common/discard-queue.h>
#include <dali/internal/update/common/scene-graph-buffers.h>
-#include <dali/internal/update/common/texture-cache-dispatcher.h>
#include <dali/internal/update/controllers/render-message-dispatcher.h>
#include <dali/internal/update/controllers/scene-controller-impl.h>
#include <dali/internal/update/gestures/scene-graph-pan-gesture.h>
#include <dali/internal/update/render-tasks/scene-graph-render-task.h>
#include <dali/internal/update/render-tasks/scene-graph-render-task-list.h>
#include <dali/internal/update/rendering/scene-graph-texture-set.h>
-#include <dali/internal/update/resources/resource-manager.h>
#include <dali/internal/update/render-tasks/scene-graph-camera.h>
#include <dali/internal/render/common/render-instruction-container.h>
#include <dali/internal/render/common/render-manager.h>
#include <dali/internal/render/queue/render-queue.h>
-#include <dali/internal/render/gl-resources/texture-cache.h>
#include <dali/internal/render/shaders/scene-graph-shader.h>
// Un-comment to enable node tree debug logging
Impl( NotificationManager& notificationManager,
CompleteNotificationInterface& animationFinishedNotifier,
PropertyNotifier& propertyNotifier,
- ResourceManager& resourceManager,
DiscardQueue& discardQueue,
RenderController& renderController,
RenderManager& renderManager,
animationFinishedNotifier( animationFinishedNotifier ),
propertyNotifier( propertyNotifier ),
shaderSaver( NULL ),
- resourceManager( resourceManager ),
discardQueue( discardQueue ),
renderController( renderController ),
sceneController( NULL ),
renderInstructions( renderManager.GetRenderInstructionContainer() ),
renderTaskProcessor( renderTaskProcessor ),
backgroundColor( Dali::Stage::DEFAULT_BACKGROUND_COLOR ),
- taskList( renderMessageDispatcher, resourceManager ),
- systemLevelTaskList( renderMessageDispatcher, resourceManager ),
+ taskList( renderMessageDispatcher ),
+ systemLevelTaskList( renderMessageDispatcher ),
root( NULL ),
systemLevelRoot( NULL ),
renderers( sceneGraphBuffers, discardQueue ),
CompleteNotificationInterface& animationFinishedNotifier; ///< Provides notification to applications when animations are finished.
PropertyNotifier& propertyNotifier; ///< Provides notification to applications when properties are modified.
ShaderSaver* shaderSaver; ///< Saves shader binaries.
- ResourceManager& resourceManager; ///< resource manager
DiscardQueue& discardQueue; ///< Nodes are added here when disconnected from the scene-graph.
RenderController& renderController; ///< render controller
SceneControllerImpl* sceneController; ///< scene controller
UpdateManager::UpdateManager( NotificationManager& notificationManager,
CompleteNotificationInterface& animationFinishedNotifier,
PropertyNotifier& propertyNotifier,
- ResourceManager& resourceManager,
DiscardQueue& discardQueue,
RenderController& controller,
RenderManager& renderManager,
RenderQueue& renderQueue,
- TextureCacheDispatcher& textureCacheDispatcher,
RenderTaskProcessor& renderTaskProcessor )
: mImpl(NULL)
{
mImpl = new Impl( notificationManager,
animationFinishedNotifier,
propertyNotifier,
- resourceManager,
discardQueue,
controller,
renderManager,
mSceneGraphBuffers,
renderTaskProcessor );
- textureCacheDispatcher.SetBufferIndices( &mSceneGraphBuffers );
}
UpdateManager::~UpdateManager()
// And add the renderers to the sorted layers. Start from root, which is also a layer
mImpl->nodeDirtyFlags = UpdateNodeTree( *( mImpl->root ),
bufferIndex,
- mImpl->resourceManager,
mImpl->renderQueue );
if ( mImpl->systemLevelRoot )
{
mImpl->nodeDirtyFlags |= UpdateNodeTree( *( mImpl->systemLevelRoot ),
bufferIndex,
- mImpl->resourceManager,
mImpl->renderQueue );
}
}
//Clear nodes/resources which were previously discarded
mImpl->discardQueue.Clear( bufferIndex );
- //Grab any loaded resources
- bool resourceChanged = mImpl->resourceManager.UpdateCache( bufferIndex );
-
//Process Touches & Gestures
const bool gestureUpdated = ProcessGestures( bufferIndex, lastVSyncTimeMilliseconds, nextVSyncTimeMilliseconds );
(mImpl->nodeDirtyFlags & RenderableUpdateFlags) || // ..nodes were dirty in previous frame OR
IsAnimationRunning() || // ..at least one animation is running OR
mImpl->messageQueue.IsSceneUpdateRequired() || // ..a message that modifies the scene graph node tree is queued OR
- resourceChanged || // ..one or more resources were updated/changed OR
gestureUpdated; // ..a gesture property was updated
new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AddVertexBuffer, geometry, propertyBuffer );
}
-void UpdateManager::AddTexture( Render::NewTexture* texture )
+void UpdateManager::AddTexture( Render::Texture* texture )
{
- typedef MessageValue1< RenderManager, Render::NewTexture* > DerivedType;
+ typedef MessageValue1< RenderManager, Render::Texture* > DerivedType;
// Reserve some memory inside the render queue
unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
new (slot) DerivedType( &mImpl->renderManager, &RenderManager::AddTexture, texture );
}
-void UpdateManager::RemoveTexture( Render::NewTexture* texture)
+void UpdateManager::RemoveTexture( Render::Texture* texture)
{
- typedef MessageValue1< RenderManager, Render::NewTexture* > DerivedType;
+ typedef MessageValue1< RenderManager, Render::Texture* > DerivedType;
// Reserve some memory inside the render queue
unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
new (slot) DerivedType( &mImpl->renderManager, &RenderManager::RemoveTexture, texture );
}
-void UpdateManager::UploadTexture( Render::NewTexture* texture, PixelDataPtr pixelData, const NewTexture::UploadParams& params )
+void UpdateManager::UploadTexture( Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params )
{
- typedef MessageValue3< RenderManager, Render::NewTexture*, PixelDataPtr, NewTexture::UploadParams > DerivedType;
+ typedef MessageValue3< RenderManager, Render::Texture*, PixelDataPtr, Texture::UploadParams > DerivedType;
// Reserve some memory inside the message queue
unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
new (slot) DerivedType( &mImpl->renderManager, &RenderManager::UploadTexture, texture, pixelData, params );
}
-void UpdateManager::GenerateMipmaps( Render::NewTexture* texture )
+void UpdateManager::GenerateMipmaps( Render::Texture* texture )
{
- typedef MessageValue1< RenderManager, Render::NewTexture* > DerivedType;
+ typedef MessageValue1< RenderManager, Render::Texture* > DerivedType;
// Reserve some memory inside the render queue
unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
new (slot) DerivedType( &mImpl->renderManager, &RenderManager::RemoveFrameBuffer, frameBuffer );
}
-void UpdateManager::AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::NewTexture* texture, unsigned int mipmapLevel, unsigned int layer )
+void UpdateManager::AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, unsigned int mipmapLevel, unsigned int layer )
{
- typedef MessageValue4< RenderManager, Render::FrameBuffer*, Render::NewTexture*, unsigned int, unsigned int > DerivedType;
+ typedef MessageValue4< RenderManager, Render::FrameBuffer*, Render::Texture*, unsigned int, unsigned int > DerivedType;
// Reserve some memory inside the render queue
unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
class PropertyNotifier;
class NotificationManager;
class CompleteNotificationInterface;
-class ResourceManager;
class TouchResampler;
namespace Render
class RenderTaskList;
class RenderTaskProcessor;
class RenderQueue;
-class TextureCacheDispatcher;
class PropertyBuffer;
class TextureSet;
class Camera;
* @param[in] notificationManager This should be notified when animations have finished.
* @param[in] animationFinishedNotifier The CompleteNotificationInterface that handles animation completions
* @param[in] propertyNotifier The PropertyNotifier
- * @param[in] resourceManager The resource manager used to load textures etc.
* @param[in] discardQueue Nodes are added here when disconnected from the scene-graph.
* @param[in] controller After messages are flushed, we request a render from the RenderController.
* @param[in] renderManager This is responsible for rendering the results of each "update".
* @param[in] renderQueue Used to queue messages for the next render.
- * @param[in] textureCacheDispatcher Used for sending messages to texture cache.
* @param[in] renderTaskProcessor Handles RenderTasks and RenderInstrucitons.
*/
UpdateManager( NotificationManager& notificationManager,
CompleteNotificationInterface& animationFinishedNotifier,
PropertyNotifier& propertyNotifier,
- ResourceManager& resourceManager,
DiscardQueue& discardQueue,
Integration::RenderController& controller,
RenderManager& renderManager,
RenderQueue& renderQueue,
- TextureCacheDispatcher& textureCacheDispatcher,
RenderTaskProcessor& renderTaskProcessor );
/**
* @param[in] texture The texture to add
* The texture will be owned by RenderManager
*/
- void AddTexture( Render::NewTexture* texture );
+ void AddTexture( Render::Texture* texture );
/**
* Removes a texture from the render manager
* @param[in] texture The texture to remove
* @post The texture will be destroyed in the render thread
*/
- void RemoveTexture( Render::NewTexture* texture );
+ void RemoveTexture( Render::Texture* texture );
/**
* Uploads data to a texture owned by the RenderManager
* @param[in] pixelData The pixel data object
* @param[in] params The parameters for the upload
*/
- void UploadTexture( Render::NewTexture* texture, PixelDataPtr pixelData, const NewTexture::UploadParams& params );
+ void UploadTexture( Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params );
/**
* Generates mipmaps for a texture owned by the RenderManager
* @param[in] texture The texture
*/
- void GenerateMipmaps( Render::NewTexture* texture );
+ void GenerateMipmaps( Render::Texture* texture );
/**
* Adds a framebuffer to the render manager
* @param[in] mipmapLevel The mipmap of the texture to be attached
* @param[in] layer Indicates which layer of a cube map or array texture to attach. Unused for 2D textures
*/
- void AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::NewTexture* texture, unsigned int mipmapLevel, unsigned int face );
+ void AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, unsigned int mipmapLevel, unsigned int face );
public:
new (slot) LocalType( &manager, &UpdateManager::SetGeometryType, &geometry, geometryType );
}
-inline void AddTexture( UpdateManager& manager, Render::NewTexture& texture )
+inline void AddTexture( UpdateManager& manager, Render::Texture& texture )
{
- typedef MessageValue1< UpdateManager, Render::NewTexture* > LocalType;
+ typedef MessageValue1< UpdateManager, Render::Texture* > LocalType;
// Reserve some memory inside the message queue
unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
new (slot) LocalType( &manager, &UpdateManager::AddTexture, &texture );
}
-inline void RemoveTexture( UpdateManager& manager, Render::NewTexture& texture )
+inline void RemoveTexture( UpdateManager& manager, Render::Texture& texture )
{
- typedef MessageValue1< UpdateManager, Render::NewTexture* > LocalType;
+ typedef MessageValue1< UpdateManager, Render::Texture* > LocalType;
// Reserve some memory inside the message queue
unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
new (slot) LocalType( &manager, &UpdateManager::RemoveTexture, &texture );
}
-inline void UploadTextureMessage( UpdateManager& manager, Render::NewTexture& texture, PixelDataPtr pixelData, const NewTexture::UploadParams& params )
+inline void UploadTextureMessage( UpdateManager& manager, Render::Texture& texture, PixelDataPtr pixelData, const Texture::UploadParams& params )
{
- typedef MessageValue3< UpdateManager, Render::NewTexture*, PixelDataPtr, NewTexture::UploadParams > LocalType;
+ typedef MessageValue3< UpdateManager, Render::Texture*, PixelDataPtr, Texture::UploadParams > LocalType;
// Reserve some memory inside the message queue
unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
new (slot) LocalType( &manager, &UpdateManager::UploadTexture, &texture, pixelData, params );
}
-inline void GenerateMipmapsMessage( UpdateManager& manager, Render::NewTexture& texture )
+inline void GenerateMipmapsMessage( UpdateManager& manager, Render::Texture& texture )
{
- typedef MessageValue1< UpdateManager, Render::NewTexture* > LocalType;
+ typedef MessageValue1< UpdateManager, Render::Texture* > LocalType;
// Reserve some memory inside the message queue
unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
new (slot) LocalType( &manager, &UpdateManager::RemoveFrameBuffer, &frameBuffer );
}
-inline void AttachColorTextureToFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer, Render::NewTexture* texture, unsigned int mipmapLevel, unsigned int layer )
+inline void AttachColorTextureToFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer, Render::Texture* texture, unsigned int mipmapLevel, unsigned int layer )
{
- typedef MessageValue4< UpdateManager, Render::FrameBuffer*, Render::NewTexture*, unsigned int, unsigned int > LocalType;
+ typedef MessageValue4< UpdateManager, Render::FrameBuffer*, Render::Texture*, unsigned int, unsigned int > LocalType;
// Reserve some memory inside the message queue
unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
namespace SceneGraph
{
-RenderTaskList::RenderTaskList( RenderMessageDispatcher& renderMessageDispatcher, ResourceManager& resourceManager )
+RenderTaskList::RenderTaskList( RenderMessageDispatcher& renderMessageDispatcher )
: mNotificationObject( NULL ),
- mRenderMessageDispatcher( renderMessageDispatcher ),
- mResourceManager( resourceManager )
+ mRenderMessageDispatcher( renderMessageDispatcher )
{
}
// mRenderTasks container takes ownership
mRenderTasks.PushBack( newTask );
- newTask->Initialize( mRenderMessageDispatcher, mResourceManager );
+ newTask->Initialize( mRenderMessageDispatcher );
}
void RenderTaskList::RemoveTask( RenderTask* task )
namespace Internal
{
-class ResourceManager;
+
class CompleteNotificationInterface;
namespace SceneGraph
/**
* Constructor
* @param renderMessageDispatcher to send messages
- * @param resourceManager to pass to render tasks
*/
- RenderTaskList( RenderMessageDispatcher& renderMessageDispatcher, ResourceManager& resourceManager );
+ RenderTaskList( RenderMessageDispatcher& renderMessageDispatcher );
/**
* Destructor
CompleteNotificationInterface* mNotificationObject; ///< object to pass in to the complete notification
RenderMessageDispatcher& mRenderMessageDispatcher; ///< for sending messages to render thread
- ResourceManager& mResourceManager; ///< The resource manager (render tasks need this)
RenderTaskContainer mRenderTasks; ///< A container of owned RenderTasks
};
// INTERNAL INCLUDES
#include <dali/public-api/math/matrix.h>
#include <dali/internal/update/controllers/render-message-dispatcher.h>
-#include <dali/internal/update/resources/resource-manager.h>
#include <dali/internal/update/nodes/node.h>
#include <dali/internal/render/common/render-instruction.h>
#include <dali/internal/render/common/render-tracker.h>
}
}
-void RenderTask::Initialize( RenderMessageDispatcher& renderMessageDispatcher, ResourceManager& resourceManager )
+void RenderTask::Initialize( RenderMessageDispatcher& renderMessageDispatcher )
{
mRenderMessageDispatcher = &renderMessageDispatcher;
- mResourceManager = &resourceManager;
}
void RenderTask::SetSourceNode( Node* node )
mViewportSize( Vector2::ZERO),
mClearColor( Dali::RenderTask::DEFAULT_CLEAR_COLOR ),
mRenderMessageDispatcher( NULL ),
- mResourceManager( NULL ),
mRenderSyncTracker( NULL ),
mSourceNode( NULL ),
mCameraNode( NULL ),
namespace Internal
{
class FrameBufferTexture;
-class ResourceManager;
namespace Render
{
/**
* Initialize the render task. Called in update thread
* @param[in] renderMessageDispatcher to send messages to render thread
- * @param[in] resourceManager to check and update status of FBOs
*/
- void Initialize( RenderMessageDispatcher& renderMessageDispatcher, ResourceManager& resourceManager );
+ void Initialize( RenderMessageDispatcher& renderMessageDispatcher );
/**
* Set the nodes to be rendered.
private:
RenderMessageDispatcher* mRenderMessageDispatcher;
- ResourceManager* mResourceManager;
Render::RenderTracker* mRenderSyncTracker;
Node* mSourceNode;
Node* mCameraNode;
if( mTextureSet )
{
- size_t textureCount = mTextureSet->GetNewTextureCount();
- dataProvider->mNewTextures.resize( textureCount );
+ size_t textureCount = mTextureSet->GetTextureCount();
+ dataProvider->mTextures.resize( textureCount );
dataProvider->mSamplers.resize( textureCount );
for( unsigned int i(0); i<textureCount; ++i )
{
- dataProvider->mNewTextures[i] = mTextureSet->GetNewTexture(i);
+ dataProvider->mTextures[i] = mTextureSet->GetTexture(i);
dataProvider->mSamplers[i] = mTextureSet->GetTextureSampler(i);
}
}
NotifyChangeToRenderers();
}
-void TextureSet::SetTexture( size_t index, Render::NewTexture* texture )
+void TextureSet::SetTexture( size_t index, Render::Texture* texture )
{
const size_t textureCount( mTextures.Size() );
if( textureCount < index + 1 )
{
namespace Internal
{
-class ResourceManager;
namespace Render
{
struct Sampler;
-class NewTexture;
+class Texture;
}
namespace SceneGraph
{
* @param[in] index The index of the texture
* @param[in] texture The texture
*/
- void SetTexture( size_t index, Render::NewTexture* texture );
+ void SetTexture( size_t index, Render::Texture* texture );
/**
* Return whether any texture in the texture set has an alpha channel
}
/**
- * Get the number of NewTextures in the texture set
- * @return The number of NewTextures
+ * Get the number of Textures in the texture set
+ * @return The number of Textures
*/
- size_t GetNewTextureCount()
+ size_t GetTextureCount()
{
return mTextures.Size();
}
/**
- * Get the pointer to a NewTexture in the TextureSet
+ * Get the pointer to a Texture in the TextureSet
* @param[in] index The index of the texture in the textures array
- * @return the pointer to the NewTexture in that position
+ * @return the pointer to the Texture in that position
*/
- Render::NewTexture* GetNewTexture( size_t index )
+ Render::Texture* GetTexture( size_t index )
{
return mTextures[index];
}
private: // Data
Vector< Render::Sampler* > mSamplers; ///< List of samplers used by each texture. Not owned
- Vector< Render::NewTexture* > mTextures; ///< List of NewTextures. Not owned
+ Vector< Render::Texture* > mTextures; ///< List of Textures. Not owned
Vector<Renderer*> mRenderers; ///< List of renderers using the TextureSet
bool mHasAlpha; ///< if any of the textures has an alpha channel
};
-inline void SetTextureMessage( EventThreadServices& eventThreadServices, const TextureSet& textureSet, size_t index, Render::NewTexture* texture )
+inline void SetTextureMessage( EventThreadServices& eventThreadServices, const TextureSet& textureSet, size_t index, Render::Texture* texture )
{
- typedef MessageValue2< TextureSet, size_t, Render::NewTexture* > LocalType;
+ typedef MessageValue2< TextureSet, size_t, Render::Texture* > LocalType;
// Reserve some memory inside the message queue
unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+++ /dev/null
-#ifndef __DALI_INTERNAL_RESOURCE_MANAGER_DECLARATIONS_H__
-#define __DALI_INTERNAL_RESOURCE_MANAGER_DECLARATIONS_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/devel-api/threading/mutex.h>
-#include <dali/integration-api/resource-cache.h>
-#include <dali/internal/update/common/double-buffered.h>
-#include <dali/public-api/common/dali-vector.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-typedef Integration::ResourceId ResourceId;
-
-/**
- * Post processing required on the resource after the resource has been modified by the render thread
- * Should only be handled by update thread
- */
-
-typedef Dali::Vector< ResourceId > TextureUploadedQueue;
-
-class LockedResourceQueue
-{
-
-public:
- void PushBack( ResourceId request )
- {
- Dali::Mutex::ScopedLock lock( mMutex );
- mQueue.PushBack( request );
- }
-
- bool IsEmpty() const
- {
- Dali::Mutex::ScopedLock lock( mMutex );
- return mQueue.Empty();
- }
-
- void SwapQueue( TextureUploadedQueue& list )
- {
- Dali::Mutex::ScopedLock lock( mMutex );
- list.Clear();
- mQueue.Swap( list );
- }
-
-private:
-
- TextureUploadedQueue mQueue;
- mutable Dali::Mutex mMutex;
-};
-
-
-} // Internal
-} // Dali
-
-#endif // __DALI_INTERNAL_RESOURCE_MANAGER_DECLARATIONS_H__
+++ /dev/null
-/*
- * Copyright (c) 2015 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.
- *
- */
-
-// CLASS HEADER
-#include <dali/internal/update/resources/resource-manager.h>
-
-// EXTERNAL INCLUDES
-#include <stdio.h>
-
-// INTERNAL INCLUDES
-#include <dali/devel-api/common/map-wrapper.h>
-#include <dali/devel-api/common/set-wrapper.h>
-
-#include <dali/public-api/math/vector2.h>
-#include <dali/public-api/common/dali-vector.h>
-
-#include <dali/integration-api/debug.h>
-
-#include <dali/internal/common/message.h>
-#include <dali/internal/common/image-attributes.h>
-
-#include <dali/internal/event/common/notification-manager.h>
-#include <dali/internal/event/resources/resource-type-path.h>
-
-#include <dali/internal/update/common/discard-queue.h>
-#include <dali/internal/update/common/texture-cache-dispatcher.h>
-#include <dali/internal/update/resources/texture-metadata.h>
-
-#include <dali/internal/render/queue/render-queue.h>
-
-using namespace Dali::Integration;
-
-using Dali::Internal::SceneGraph::DiscardQueue;
-using Dali::Internal::SceneGraph::RenderQueue;
-using Dali::Internal::SceneGraph::TextureCacheDispatcher;
-
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-typedef std::set<ResourceId> LiveRequestContainer;
-typedef LiveRequestContainer::iterator LiveRequestIter;
-typedef LiveRequestContainer::size_type LiveRequestSize;
-
-typedef std::map<ResourceId, ResourceTypeId> DeadRequestContainer;
-typedef DeadRequestContainer::iterator DeadRequestIter;
-typedef std::pair<ResourceId, ResourceTypeId> DeadRequestPair;
-
-typedef std::vector<ResourceId> NotifyQueue;
-typedef NotifyQueue::iterator NotifyQueueIter;
-
-typedef Dali::Vector<TextureMetadata> TextureMetadataCache;
-typedef TextureMetadataCache::Iterator TextureMetadataIter;
-
-static inline bool RemoveId( LiveRequestContainer& container, ResourceId id )
-{
- return container.erase(id) != 0;
-}
-
-struct ResourceManager::ResourceManagerImpl
-{
- ResourceManagerImpl( PlatformAbstraction& platformAbstraction,
- NotificationManager& notificationManager,
- SceneGraph::TextureCacheDispatcher& textureCacheDispatcher,
- LockedResourceQueue& textureUploadedQueue,
- DiscardQueue& discardQueue,
- RenderQueue& renderQueue )
- : mPlatformAbstraction(platformAbstraction),
- mNotificationManager(notificationManager),
- mTextureCacheDispatcher(textureCacheDispatcher),
- mTextureUploadedQueue(textureUploadedQueue),
- mTextureUploadedProcessingQueue(),
- mDiscardQueue(discardQueue),
- mRenderQueue(renderQueue),
- mNotificationCount(0),
- cacheUpdated(false)
- {
- mTextureMetadata.Reserve( 256 ); // reserve size for metadata to avoid early re-allocs in application startup
- }
-
- ~ResourceManagerImpl()
- {
- }
-
- PlatformAbstraction& mPlatformAbstraction;
- NotificationManager& mNotificationManager;
- TextureCacheDispatcher& mTextureCacheDispatcher;
- LockedResourceQueue& mTextureUploadedQueue;
- TextureUploadedQueue mTextureUploadedProcessingQueue;
- DiscardQueue& mDiscardQueue; ///< Unwanted resources are added here during UpdateCache()
- RenderQueue& mRenderQueue;
- unsigned int mNotificationCount;
- bool cacheUpdated; ///< returned by UpdateCache(). Set true in NotifyTickets to indicate a change in a resource
-
- /**
- * These containers are used to processs requests, and ResourceCache callbacks.
- * The live request containers are simply sets of integer resource ids.
- * The ID of a new request will be placed in the loading container.
- * If the Ticket is destroyed during the load, the ID will be removed.
- * If the load fails, the ID will be moved to the failed container.
- * When the Ticket is notified of the failure, the ID will be removed.
- * If the load succeeds, the ID will be moved to the new-completed container.
- * When the Ticket is notified of the completion, the ID will be moved to the old-completed container.
- * If a Ticket is destroyed after a successful load, the ID will be moved to the dead container.
- * When the resources are eventually deleted, the ID will be removed from the dead container.
- */
- LiveRequestContainer loadingRequests;
- LiveRequestContainer newCompleteRequests;
- LiveRequestContainer oldCompleteRequests;
- LiveRequestContainer newFailedRequests;
- LiveRequestContainer oldFailedRequests;
- DeadRequestContainer deadRequests;
-
- /**
- * This is the resource cache; metadata of the textures
- */
- TextureMetadataCache mTextureMetadata;
-};
-
-ResourceManager::ResourceManager( PlatformAbstraction& platformAbstraction,
- NotificationManager& notificationManager,
- TextureCacheDispatcher& textureCacheDispatcher,
- LockedResourceQueue& resourcePostProcessQueue,
- DiscardQueue& discardQueue,
- RenderQueue& renderQueue )
-{
- mImpl = new ResourceManagerImpl( platformAbstraction,
- notificationManager,
- textureCacheDispatcher,
- resourcePostProcessQueue,
- discardQueue,
- renderQueue );
-}
-
-ResourceManager::~ResourceManager()
-{
- delete mImpl;
-}
-
-/********************************************************************************
- ************************ UpdateManager direct interface ***********************
- ********************************************************************************/
-
-bool ResourceManager::UpdateCache( BufferIndex updateBufferIndex )
-{
- DALI_LOG_INFO(Debug::Filter::gResource, Debug::Verbose, "ResourceManager: UpdateCache(bufferIndex:%u)\n", updateBufferIndex);
-
- // 1) Move unwanted resources to the DiscardQueue
-
- DiscardDeadResources( updateBufferIndex );
-
- // 2) Fill the resource cache
- mImpl->cacheUpdated = false;
-
- mImpl->mPlatformAbstraction.GetResources(*this);
-
- return mImpl->cacheUpdated;
-}
-
-/********************************************************************************
- *************************** CoreImpl direct interface *************************
- ********************************************************************************/
-
-bool ResourceManager::ResourcesToProcess()
-{
- bool workTodo = false;
-
- // need to make sure we have passed all the notifications to the event handling side
- workTodo |= !mImpl->newCompleteRequests.empty();
- workTodo |= !mImpl->newFailedRequests.empty();
- // check if there's something still loading
- workTodo |= !mImpl->loadingRequests.empty();
-
- return workTodo;
-}
-
-
-/********************************************************************************
- ********************************* Message handlers *****************************
- ********************************************************************************/
-
-void ResourceManager::HandleLoadResourceRequest( ResourceId id, const ResourceTypePath& typePath, LoadResourcePriority priority )
-{
- DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceManager: HandleLoadResourceRequest(id:%u, path:%s, type.id:%d)\n", id, typePath.path.c_str(), typePath.type->id);
-
- // Add ID to the loading set
- mImpl->loadingRequests.insert(id);
-
- // Make the load request last
- mImpl->mPlatformAbstraction.LoadResource(ResourceRequest(id, *typePath.type, typePath.path, priority));
-}
-
-void ResourceManager::HandleDecodeResourceRequest(
- ResourceId id,
- const ResourceTypePath& typePath,
- RequestBufferPtr buffer,
- Integration::LoadResourcePriority priority )
-{
- DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceManager: HandleDecodeResourceRequest(id:%u, buffer.size:%u, type.id:%u)\n", id, buffer->GetVector().Size(), typePath.type->id);
-
- // Add ID to the loading set
- mImpl->loadingRequests.insert(id);
-
- // Make the load request, stuffing the buffer of encoded bytes into the same field used when saving resources:
- mImpl->mPlatformAbstraction.LoadResource(ResourceRequest(id, *typePath.type, "", buffer, priority));
-}
-
-void ResourceManager::HandleAddBitmapImageRequest( ResourceId id, BitmapPtr bitmap )
-{
- DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceManager: HandleAddBitmapImageRequest(id:%u)\n", id);
-
- mImpl->oldCompleteRequests.insert(id);
- mImpl->mTextureMetadata.PushBack( TextureMetadata::New( id, bitmap.Get() ) );
- mImpl->mTextureCacheDispatcher.DispatchCreateTextureForBitmap( id, bitmap.Get() );
-}
-
-void ResourceManager::HandleAddNativeImageRequest(ResourceId id, NativeImageInterfacePtr nativeImage)
-{
- DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceManager: HandleAddNativeImageRequest(id:%u)\n", id);
-
- mImpl->oldCompleteRequests.insert(id);
-
- mImpl->mTextureMetadata.PushBack( TextureMetadata::New( id, nativeImage ) );
- mImpl->mTextureCacheDispatcher.DispatchCreateTextureForNativeImage( id, nativeImage );
-}
-
-void ResourceManager::HandleAddFrameBufferImageRequest( ResourceId id, unsigned int width, unsigned int height, Pixel::Format pixelFormat, RenderBuffer::Format bufferFormat )
-{
- DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceManager: HandleAddFrameBufferImageRequest(id:%u)\n", id);
-
- mImpl->oldCompleteRequests.insert(id);
-
- TextureMetadata bitmapMetadata = TextureMetadata::New( id, width, height, Pixel::HasAlpha(pixelFormat) );
- bitmapMetadata.SetIsFramebuffer(true);
- mImpl->mTextureMetadata.PushBack( bitmapMetadata );
-
- mImpl->mTextureCacheDispatcher.DispatchCreateTextureForFrameBuffer( id, width, height, pixelFormat, bufferFormat );
-}
-
-void ResourceManager::HandleAddFrameBufferImageRequest( ResourceId id, NativeImageInterfacePtr nativeImage )
-{
- DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceManager: HandleAddFrameBufferImageRequest(id:%u)\n", id);
-
- mImpl->oldCompleteRequests.insert(id);
-
- TextureMetadata bitmapMetadata = TextureMetadata::New(id, nativeImage);
- bitmapMetadata.SetIsNativeImage(true);
- bitmapMetadata.SetIsFramebuffer(true);
- mImpl->mTextureMetadata.PushBack( bitmapMetadata );
-
- mImpl->mTextureCacheDispatcher.DispatchCreateTextureForFrameBuffer( id, nativeImage );
-}
-
-void ResourceManager::HandleAllocateTextureRequest( ResourceId id, unsigned int width, unsigned int height, Pixel::Format pixelFormat )
-{
- DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceManager: HandleAllocateTextureRequest(id:%u)\n", id);
-
- mImpl->oldCompleteRequests.insert(id);
- // atlas needs metadata as well
- TextureMetadata bitmapMetadata = TextureMetadata::New( id, width, height, Pixel::HasAlpha(pixelFormat) );
- mImpl->mTextureMetadata.PushBack( bitmapMetadata );
-
- mImpl->mTextureCacheDispatcher.DispatchCreateTexture( id, width, height, pixelFormat, true /* true = clear the texture */ );
-}
-
-void ResourceManager::HandleUpdateBitmapAreaRequest( ResourceId textureId, const RectArea& area )
-{
- if( textureId )
- {
- mImpl->mTextureCacheDispatcher.DispatchUpdateTextureArea( textureId, area );
- }
-}
-
-void ResourceManager::HandleUploadBitmapRequest( ResourceId destId, Integration::BitmapPtr bitmap, std::size_t xOffset, std::size_t yOffset )
-{
- if( destId && bitmap )
- {
- mImpl->mTextureCacheDispatcher.DispatchUpdateTexture( destId, bitmap, xOffset, yOffset );
- }
-}
-
-void ResourceManager::HandleUploadBitmapRequest( ResourceId destId, ResourceId srcId, std::size_t xOffset, std::size_t yOffset )
-{
- if( destId && srcId )
- {
- mImpl->mTextureCacheDispatcher.DispatchUpdateTexture( destId, srcId, xOffset, yOffset );
- }
-}
-
-void ResourceManager::HandleUploadBitmapRequest( ResourceId destId, PixelDataPtr pixelData, std::size_t xOffset, std::size_t yOffset )
-{
- if( destId && pixelData )
- {
- mImpl->mTextureCacheDispatcher.DispatchUpdateTexture( destId, pixelData, xOffset, yOffset );
- }
-}
-
-void ResourceManager::HandleReloadResourceRequest( ResourceId id, const ResourceTypePath& typePath, LoadResourcePriority priority, bool resetFinishedStatus )
-{
- DALI_LOG_INFO( Debug::Filter::gResource, Debug::General, "ResourceManager: HandleReloadRequest(id:%u, path:%s)\n", id, typePath.path.c_str() );
-
- if( resetFinishedStatus )
- {
- if( ! RemoveId( mImpl->newCompleteRequests, id ) )
- {
- RemoveId( mImpl->oldCompleteRequests, id );
- }
- }
-
- // ID might be in the loading set
- LiveRequestIter iter = mImpl->loadingRequests.find( id );
- if ( iter == mImpl->loadingRequests.end() )
- {
- // Add ID to the loading set
- mImpl->loadingRequests.insert(id);
- }
-}
-
-void ResourceManager::HandleDiscardResourceRequest( ResourceId deadId, ResourceTypeId typeId )
-{
- bool wasComplete = false;
- bool wasLoading = false;
-
- DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceManager: HandleDiscardResourceRequest(id:%u)\n", deadId);
-
- // Search for the ID in one of the live containers
- // IDs are only briefly held in the new-completed or failed containers; check those last
- // Try removing from the old-completed requests
- bool foundLiveRequest = wasComplete = RemoveId(mImpl->oldCompleteRequests, deadId);
-
- // Try removing from the loading requests
- if (!foundLiveRequest)
- {
- foundLiveRequest = wasLoading = RemoveId(mImpl->loadingRequests, deadId);
- }
-
- // Try removing from the new completed requests
- if (!foundLiveRequest)
- {
- foundLiveRequest = wasComplete = RemoveId(mImpl->newCompleteRequests, deadId);
- }
-
- // Try removing from the new failed requests
- if (!foundLiveRequest)
- {
- foundLiveRequest = RemoveId(mImpl->newFailedRequests, deadId);
- }
-
- // Try removing from the old failed requests
- if (!foundLiveRequest)
- {
- foundLiveRequest = RemoveId(mImpl->oldFailedRequests, deadId);
- }
-
- // ID should be in one of the live sets
- if (!foundLiveRequest)
- {
- DALI_LOG_WARNING("HandleDiscardResourceRequest: ID should be in one of the live sets!\n");
- }
- DALI_ASSERT_DEBUG(foundLiveRequest);
-
- if (wasComplete)
- {
- if(typeId == ResourceBitmap ||
- typeId == ResourceNativeImage ||
- typeId == ResourceTargetImage )
- {
- // remove the meta data
-
- TextureMetadataCache::Iterator iter = mImpl->mTextureMetadata.Begin();
- const TextureMetadataCache::Iterator end = mImpl->mTextureMetadata.End();
- for( ; iter != end; ++iter )
- {
- if( (*iter).GetId() == deadId )
- {
- break;
- }
- }
- if( iter != end )
- {
- mImpl->mTextureMetadata.Erase( iter );
- }
-
- // destroy the texture
- mImpl->mTextureCacheDispatcher.DispatchDiscardTexture( deadId );
- }
- else
- {
- // Move ID from completed to dead set
- mImpl->deadRequests.insert(DeadRequestPair(deadId, typeId));
- }
- }
-
- if (wasLoading)
- {
- mImpl->mPlatformAbstraction.CancelLoad(deadId, typeId);
- }
-}
-
-void ResourceManager::HandleCreateGlTextureRequest(ResourceId id)
-{
- mImpl->mTextureCacheDispatcher.DispatchCreateGlTexture( id );
-}
-
-/********************************************************************************
- ******************** Update thread object direct interface ********************
- ********************************************************************************/
-
-bool ResourceManager::IsResourceLoaded( ResourceId id ) const
-{
- bool loaded = false;
-
- if( id > 0 )
- {
- LiveRequestIter iter = mImpl->newCompleteRequests.find(id);
- if( iter != mImpl->newCompleteRequests.end() )
- {
- loaded = true;
- }
- else
- {
- iter = mImpl->oldCompleteRequests.find(id);
- if( iter != mImpl->oldCompleteRequests.end() )
- {
- loaded = true;
- }
- }
- }
-
- return loaded;
-}
-
-bool ResourceManager::HasResourceLoadFailed( ResourceId id ) const
-{
- bool loadFailed = false;
-
- if( id > 0 )
- {
- LiveRequestIter iter = mImpl->newFailedRequests.find(id);
- if( iter != mImpl->newFailedRequests.end() )
- {
- loadFailed = true;
- }
- else
- {
- iter = mImpl->oldFailedRequests.find(id);
- if( iter != mImpl->oldFailedRequests.end() )
- {
- loadFailed = true;
- }
- }
- }
-
- return loadFailed;
-}
-
-void ResourceManager::SetFrameBufferBeenRenderedTo( ResourceId id, bool value )
-{
- TextureMetadata* metadata = NULL;
- if( GetTextureMetadata( id, metadata ) )
- {
- metadata->SetFrameBufferBeenRenderedTo( value );
- }
-}
-
-bool ResourceManager::HasFrameBufferBeenRenderedTo( ResourceId id ) const
-{
- bool retval( false );
- TextureMetadata* metadata = NULL;
- if( GetTextureMetadata( id, metadata ) )
- {
- retval = metadata->HasFrameBufferBeenRenderedTo();
- }
- return retval;
-}
-
-bool ResourceManager::GetTextureMetadata( ResourceId id, TextureMetadata*& metadata ) const
-{
- if( id > 0 )
- {
- const size_t count = mImpl->mTextureMetadata.Count();
- for( size_t index = 0; index < count; ++index )
- {
- if( id == mImpl->mTextureMetadata[ index ].GetId() )
- {
- metadata = &mImpl->mTextureMetadata[ index ];
- return true;
- }
- }
- }
-
- return false;
-}
-
-/********************************************************************************
- ************************* ResourceCache Implementation ************************
- ********************************************************************************/
-
-void ResourceManager::LoadResponse( ResourceId id, ResourceTypeId type, ResourcePointer resource, LoadStatus loadStatus )
-{
- DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceManager: LoadResponse(id:%u, status=%s)\n", id, loadStatus==RESOURCE_LOADING?"LOADING":loadStatus==RESOURCE_PARTIALLY_LOADED?"PARTIAL":"COMPLETE");
-
- // ID might be in the loading set
- LiveRequestIter iter = mImpl->loadingRequests.find(id);
-
- if ( iter != mImpl->loadingRequests.end() )
- {
- if( loadStatus == RESOURCE_COMPLETELY_LOADED )
- {
- // Remove from the loading set
- mImpl->loadingRequests.erase(iter);
-
- // Add the ID to the new-completed set, and store the resource
- mImpl->newCompleteRequests.insert(id);
- }
-
- switch ( type )
- {
- case ResourceBitmap:
- {
- DALI_ASSERT_DEBUG( loadStatus == RESOURCE_COMPLETELY_LOADED && "Partial results not handled for image loading.\n" );
- Bitmap* const bitmap = static_cast<Bitmap*>( resource.Get() );
- if( !bitmap )
- {
- DALI_LOG_ERROR( "Missing bitmap in loaded resource with id %u.\n", id );
- break;
- }
- unsigned int bitmapWidth = bitmap->GetImageWidth();
- unsigned int bitmapHeight = bitmap->GetImageHeight();
-
- if( Bitmap::PackedPixelsProfile * packedBitmap = bitmap->GetPackedPixelsProfile() )
- {
- bitmapWidth = packedBitmap->GetBufferWidth();
- bitmapHeight = packedBitmap->GetBufferHeight();
- }
- ImageAttributes attrs = ImageAttributes::New( bitmapWidth, bitmapHeight ); ///!< Issue #AHC01
-
- // Check for reloaded bitmap
- TextureMetadataCache::Iterator iter = mImpl->mTextureMetadata.Begin();
- const TextureMetadataCache::Iterator end = mImpl->mTextureMetadata.End();
- for( ; iter != end; ++iter )
- {
- if( (*iter).GetId() == id )
- {
- break;
- }
- }
- if( iter != end )
- {
- iter->Update( bitmap );
- mImpl->mTextureCacheDispatcher.DispatchUpdateTexture( id, bitmap );
- }
- else
- {
- mImpl->mTextureCacheDispatcher.DispatchCreateTextureForBitmap( id, bitmap );
- mImpl->mTextureMetadata.PushBack( TextureMetadata::New( id, bitmap ) );
- }
-
- break;
- }
-
- case ResourceNativeImage:
- {
- NativeImageInterfacePtr nativeImg( static_cast<NativeImageInterface*>(resource.Get()) );
-
- ImageAttributes attrs = ImageAttributes::New(nativeImg->GetWidth(), nativeImg->GetHeight());
-
- mImpl->mTextureMetadata.PushBack( TextureMetadata::New( id, nativeImg ) );
- mImpl->mTextureCacheDispatcher.DispatchCreateTextureForNativeImage( id, nativeImg );
-
- break;
- }
-
- case ResourceTargetImage:
- {
- break;
- }
- }
-
- // flag that a load has completed and the cache updated
- mImpl->cacheUpdated = true;
- }
- else
- {
- // This warning can fire if a cancelled load is forgotten here while already complete on a resource thread:
- DALI_LOG_WARNING( "Received a notification for an untracked resource: (id:%u, status=%s)\n", id, loadStatus==RESOURCE_LOADING?"LOADING":loadStatus==RESOURCE_PARTIALLY_LOADED?"PARTIAL":"COMPLETE");
- }
-}
-
-void ResourceManager::LoadFailed(ResourceId id, ResourceFailure failure)
-{
- DALI_LOG_INFO(Debug::Filter::gResource, Debug::General, "ResourceManager: LoadFailed(id:%u)\n", id);
-
- // ID might be in the loading set
- LiveRequestIter iter = mImpl->loadingRequests.find(id);
-
- if (iter != mImpl->loadingRequests.end())
- {
- // Remove from the loading set
- mImpl->loadingRequests.erase(iter);
-
- // Add the ID to the failed set, this will trigger a notification during UpdateTickets
- mImpl->newFailedRequests.insert(id);
-
- mImpl->cacheUpdated = true;
- }
-}
-
-/********************************************************************************
- ********************************* Private Methods *****************************
- ********************************************************************************/
-
-void ResourceManager::DiscardDeadResources( BufferIndex updateBufferIndex )
-{
- for (DeadRequestIter iter = mImpl->deadRequests.begin(); iter != mImpl->deadRequests.end(); )
- {
- // Erase the item and increment the iterator
- mImpl->deadRequests.erase(iter++);
- }
-}
-
-} // namespace Internal
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_INTERNAL_RESOURCE_MANAGER_H__
-#define __DALI_INTERNAL_RESOURCE_MANAGER_H__
-
-/*
- * Copyright (c) 2015 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.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <string>
-
-// INTERNAL INCLUDES
-#include <dali/public-api/images/image.h>
-#include <dali/public-api/images/frame-buffer-image.h>
-#include <dali/public-api/images/native-image-interface.h>
-#include <dali/public-api/images/buffer-image.h>
-#include <dali/devel-api/common/ref-counted-dali-vector.h>
-
-#include <dali/integration-api/bitmap.h>
-#include <dali/integration-api/platform-abstraction.h>
-#include <dali/integration-api/resource-cache.h>
-
-#include <dali/internal/common/message.h>
-#include <dali/internal/event/common/event-thread-services.h>
-#include <dali/internal/event/common/thread-local-storage.h>
-#include <dali/internal/event/images/pixel-data-impl.h>
-#include <dali/internal/event/resources/resource-type-path.h>
-#include <dali/internal/update/resources/resource-manager-declarations.h>
-
-namespace Dali
-{
-
-class NativeImageInterface;
-
-namespace Integration
-{
-struct ResourceType;
-}
-
-namespace Internal
-{
-class TextureMetadata;
-class ImageAttributes;
-
-// value types used by messages
-template <> struct ParameterType< Integration::LoadResourcePriority >
-: public BasicType< Integration::LoadResourcePriority > {};
-template <> struct ParameterType< Pixel::Format >
-: public BasicType< Pixel::Format > {};
-template <> struct ParameterType< RenderBuffer::Format >
-: public BasicType< RenderBuffer::Format > {};
-template <> struct ParameterType< Integration::ResourceTypeId >
-: public BasicType< Integration::ResourceTypeId > {};
-
-namespace SceneGraph
-{
-class DiscardQueue;
-class RenderQueue;
-class TextureCacheDispatcher;
-}
-
-class NotificationManager;
-
-/** Raw bytes of a resource laid out exactly as it wouldbe in a file, but in memory. */
-typedef Dali::RefCountedVector<uint8_t> RequestBuffer;
-/** Counting smart pointer for managing a buffer of raw bytes. */
-typedef IntrusivePtr<RequestBuffer> RequestBufferPtr;
-
-/**
- * ResourceManager keeps track of resource loading requests, and caches resources that are loaded.
- * It uses ResourceTicket objects, to keep track of the lifetime of each request.
- * If the same resource is required by two client objects, they will share the same ResourceTicket
- * i.e. only one load will occur using the native filesystem.
- *
- * Multi-threading notes:
- * Resources are received from the PlatformAbstraction API during the Core::Render() method, which
- * may be called from a dedicated rendering thread.
- * Loading requests must be made from the application's main thread e.g. when Dali::Image is created.
- */
-class ResourceManager : public Integration::ResourceCache
-{
-public:
-
- /**
- * Create a resource manager.
- * There should exactly one of these objects per Dali Core.
- * @param[in] platformAbstraction Used to request resources from the native filesystem.
- * @param[in] notificationManager Used to send NotifyTickets message.
- * @param[in] textureUploadedProcessResourcesQueue Used for performing post processing on resources
- * @param[in] discardQueue Used to cleanup nodes & resources when no longer in use.
- * @param[in] renderQueue Used to queue resource updates until the next Render.
- */
- ResourceManager( Integration::PlatformAbstraction& platformAbstraction,
- NotificationManager& notificationManager,
- SceneGraph::TextureCacheDispatcher& textureCacheDispatcher,
- LockedResourceQueue& textureUploadedProcessResourcesQueue,
- SceneGraph::DiscardQueue& discardQueue,
- SceneGraph::RenderQueue& renderQueue );
-
- /**
- * Virtual destructor.
- */
- virtual ~ResourceManager();
-
-public:
-
- /********************************************************************************
- ************************ UpdateManager direct interface ***********************
- ********************************************************************************/
-
- /**
- * Called to update the resource cache before rendering.
- * New resources will be added to the cache using PlatformAbstraction::FillResourceCache().
- * Unwanted resources will be added to the DiscardQueue.
- * @param[in] updateBufferIndex The current update buffer index.
- * @return true, if a resource load was completed or failed
- */
- bool UpdateCache( BufferIndex updateBufferIndex );
-
- /********************************************************************************
- *************************** CoreImpl direct interface *************************
- ********************************************************************************/
-
- /**
- * Returns whether the Resource Manager is still processing any resource requests.
- * @return true if still processing, false otherwise.
- */
- bool ResourcesToProcess();
-
- /********************************************************************************
- ********************************* Message handlers *****************************
- ********************************************************************************/
-
- /**
- * Request a resource from the native filesystem.
- * @param[in] id The Id of the requested resource
- * @param[in] typePath The type & path of requested resource.
- * @param[in] priority The priority of the request. This is ignored if the resource is already being loaded.
- */
- void HandleLoadResourceRequest( ResourceId id,
- const ResourceTypePath& typePath,
- Integration::LoadResourcePriority priority );
-
- /**
- * Decode a resource from a memory buffer with the semantics of loading.
- * Notifications of partial completion, success, and failure will happen via
- * the same loading notification path used for loading from files: Update()
- * will retrieve loading events in its main loop and notify listeners to its
- * own loading events, and forward them, still as loading events, to the event
- * thread via its update queue.
- * Resource manager and lower levels make no attempt to detect resource
- * aliases as is done for multiple requests to load the same resource
- * file, so the caller is responsible for ensuring that it only requests
- * the decoding of an in-memory resource once and for doing the sharing of the
- * resulting object itself. Ultimately this responsibility resides with the
- * application.
- * @note ! Only Bitmap resources are supported for decoding from memory !
- * @param[in] id The Id of the requested resource.
- * @param[in] typePath The type of the requested resource and a path that is ignored.
- * @param[in] buffer The raw encoded bytes of the resource as they would appear in a file.
- * @param[in] priority The priority of the request. This is ignored if the resource is already being loaded.
- */
- void HandleDecodeResourceRequest( ResourceId id,
- const ResourceTypePath& typePath,
- RequestBufferPtr buffer,
- Integration::LoadResourcePriority priority );
-
- /**
- * Injects a bitmap resource (does not require loading).
- * @pre bitmap has to be initialized
- * @param[in] id The resource id
- * @param[in] bitmap an initialized bitmap
- */
- void HandleAddBitmapImageRequest(ResourceId id, Integration::BitmapPtr bitmap);
-
- /**
- * Add an existing resource to the resource manager.
- * @param[in] id The resource id
- * @param [in] resourceData the NativeImageInterface object
- * @return A ref-counted request object. Keep a copy until the resource is no longer required.
- */
- void HandleAddNativeImageRequest( ResourceId id, NativeImageInterfacePtr resourceData );
-
- /**
- * Add an existing resource to the resource manager.
- * @param[in] id The resource id
- * @param[in] width width in pixels
- * @param[in] height height in pixels
- * @param[in] pixelFormat Pixel format
- */
- void HandleAddFrameBufferImageRequest( ResourceId id, unsigned int width, unsigned int height, Pixel::Format pixelFormat, RenderBuffer::Format bufferFormat );
-
- /**
- * Add an existing resource to the resource manager.
- * @param[in] id The resource id
- * @param[in] nativeImage The NativeImage
- */
- void HandleAddFrameBufferImageRequest( ResourceId id, NativeImageInterfacePtr nativeImage );
-
- /**
- * Allocate a new empty texture.
- * @param[in] id The resource id
- * @param[in] width width in pixels
- * @param[in] height height in pixels
- * @param[in] pixelFormat Pixel format
- */
- void HandleAllocateTextureRequest( ResourceId id, unsigned int width, unsigned int height, Pixel::Format pixelFormat );
-
- /**
- * Update bitmap area request
- * @param[in] textureId The resource ID of a bitmap-texture to remove.
- * @param[in] area The updated area. Zero width/height indicates the whole bitmap has been updated
- */
- void HandleUpdateBitmapAreaRequest( ResourceId textureId, const RectArea& area );
-
- /**
- * Upload a bitmap to a position within a specified texture
- * @param[in] destId The destination texture ID
- * @param[in] bitmap The pointer pointing to the bitmap data to upload
- * @param [in] xOffset Specifies an offset in the x direction within the texture
- * @param [in] yOffset Specifies an offset in the y direction within the texture
- */
- void HandleUploadBitmapRequest( ResourceId destId, Integration::BitmapPtr bitmap, std::size_t xOffset, std::size_t yOffset );
-
- /**
- * Upload a bitmap to a position within a specified texture
- * @param[in] destId The destination texture ID
- * @param[in] srcId The resource ID of the bitmap to upload
- * @param [in] xOffset Specifies an offset in the x direction within the texture
- * @param [in] yOffset Specifies an offset in the y direction within the texture
- */
- void HandleUploadBitmapRequest( ResourceId destId, ResourceId srcId, std::size_t xOffset, std::size_t yOffset );
-
- /**
- * Upload a pixel buffer to a position within a specified texture
- * @param[in] destId The destination texture ID
- * @param[in] pixelData pointer pointing to the pixel data to upload
- * @param [in] xOffset Specifies an offset in the x direction within the texture
- * @param [in] yOffset Specifies an offset in the y direction within the texture
- */
- void HandleUploadBitmapRequest( ResourceId destId, PixelDataPtr pixelData, std::size_t xOffset, std::size_t yOffset );
-
- /**
- * Request reloading a resource from the native filesystem.
- * @param[in] id The resource id
- * @param[in] typePath The type & path of the resource
- * @param[in] priority The priority of the request. This is ignored if the resource is already being refreshed.
- * @param[in] resetFinishedStatus True if the finished status of the resource id should be reset
- */
- void HandleReloadResourceRequest( ResourceId id, const ResourceTypePath& typePath, Integration::LoadResourcePriority priority, bool resetFinishedStatus );
-
- /**
- * Resource ticket has been discarded, throw away the actual resource
- */
- void HandleDiscardResourceRequest( ResourceId id, Integration::ResourceTypeId typeId );
-
- /**
- * @brief Create GL texture for resource.
- * @param[in] id The resource id.
- */
- void HandleCreateGlTextureRequest( ResourceId id );
-
- /********************************************************************************
- ******************** Update thread object direct interface ********************
- ********************************************************************************/
-
- /**
- * Check if a resource has completed loading.
- * @param[in] id The ID of a bitmap/texture resource.
- * @return true if the bitmap or texture has finished loading
- */
- bool IsResourceLoaded( ResourceId id ) const;
-
- /**
- * Check if a resource has failed to load, e.g. file not found, etc.
- * @param[in] id The ID of a bitmap/texture resource.
- * @return true if the bitmap or texture has failed to load
- */
- bool HasResourceLoadFailed( ResourceId id ) const;
-
- /**
- * @param[in] id The ID of a texture resource.
- * @param[in] value if the FBO has been rendered to
- */
- void SetFrameBufferBeenRenderedTo( ResourceId id, bool value );
-
- /**
- * @param[in] id The ID of a texture resource.
- * @return true if the FBO has been rendered to
- */
- bool HasFrameBufferBeenRenderedTo( ResourceId id ) const;
-
- /**
- * Get texture metadata. This stores meta data about the resource, but
- * doesn't keep track of the resource
- * @param id of the texture
- * @param metadata reference
- * @return false if metadata does not exist
- */
- bool GetTextureMetadata( ResourceId id, TextureMetadata*& metadata ) const;
-
- /********************************************************************************
- ************************* ResourceCache Implementation ************************
- ********************************************************************************/
-public:
-
- /**
- * @copydoc Integration::ResourceCache::LoadResponse
- */
- virtual void LoadResponse(ResourceId id, Integration::ResourceTypeId type, Integration::ResourcePointer resource, Integration::LoadStatus loadStatus);
-
- /**
- * @copydoc Integration::ResourceCache::LoadFailed
- */
- virtual void LoadFailed(ResourceId id, Integration::ResourceFailure failure);
-
- /********************************************************************************
- ********************************* Private Methods *****************************
- ********************************************************************************/
-
- /**
- * Discard all dead resources.
- * @param[in] updateBufferIndex The current update buffer index.
- */
- void DiscardDeadResources( BufferIndex updateBufferIndex );
-
-private:
-
- // Undefined
- ResourceManager( const ResourceManager& resourceManager );
-
- // Undefined
- ResourceManager& operator=( const ResourceManager& rhs );
-
-private:
- struct ResourceManagerImpl;
- ResourceManagerImpl* mImpl;
-};
-
-// Messages sent to resource manager from other threads:
-// These functions are run on other threads and insert messages to be
-// picked-up by the update thread in its main loop and executed on that in
-// submission order.
-
-inline void RequestLoadResourceMessage( EventThreadServices& eventThreadServices,
- ResourceManager& manager,
- ResourceId id,
- const ResourceTypePath& typePath,
- Integration::LoadResourcePriority priority )
-{
- typedef MessageValue3< ResourceManager, ResourceId, ResourceTypePath, Integration::LoadResourcePriority > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &manager, &ResourceManager::HandleLoadResourceRequest, id, typePath, priority );
-}
-
-inline void RequestDecodeResourceMessage( EventThreadServices& eventThreadServices,
- ResourceManager& manager,
- const ResourceId id,
- /// We use typePath instead of the raw type for ownership and to enable copying of a concrete type.
- const ResourceTypePath& typePath,
- RequestBufferPtr buffer,
- Integration::LoadResourcePriority priority )
-{
- typedef MessageValue4< ResourceManager, ResourceId, ResourceTypePath, RequestBufferPtr, Integration::LoadResourcePriority > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &manager, &ResourceManager::HandleDecodeResourceRequest, id, typePath, buffer, priority );
-}
-
-inline void RequestAddBitmapImageMessage( EventThreadServices& eventThreadServices,
- ResourceManager& manager,
- ResourceId id,
- Integration::Bitmap* resourceData )
-{
- typedef MessageValue2< ResourceManager, ResourceId, Integration::BitmapPtr > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.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::HandleAddBitmapImageRequest, id, resourceData );
-}
-
-inline void RequestAddNativeImageMessage( EventThreadServices& eventThreadServices,
- ResourceManager& manager,
- ResourceId id,
- NativeImageInterfacePtr resourceData )
-{
- typedef MessageValue2< ResourceManager, ResourceId, NativeImageInterfacePtr > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.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::HandleAddNativeImageRequest, id, resourceData );
-}
-
-inline void RequestAddFrameBufferImageMessage( EventThreadServices& eventThreadServices,
- ResourceManager& manager,
- ResourceId id,
- unsigned int width,
- unsigned int height,
- Pixel::Format pixelFormat,
- RenderBuffer::Format bufferFormat
- )
-{
- typedef MessageValue5< ResourceManager, ResourceId, unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.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::HandleAddFrameBufferImageRequest, id, width, height, pixelFormat, bufferFormat );
-}
-
-inline void RequestAddFrameBufferImageMessage( EventThreadServices& eventThreadServices,
- ResourceManager& manager,
- ResourceId id,
- NativeImageInterfacePtr resourceData )
-{
- typedef MessageValue2< ResourceManager, ResourceId, NativeImageInterfacePtr > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.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::HandleAddFrameBufferImageRequest, id, resourceData );
-}
-
-inline void RequestAllocateTextureMessage( EventThreadServices& eventThreadServices,
- ResourceManager& manager,
- ResourceId id,
- unsigned int width,
- unsigned int height,
- Pixel::Format pixelFormat)
-{
- typedef MessageValue4< ResourceManager, ResourceId, unsigned int, unsigned int, Pixel::Format > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.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::HandleAllocateTextureRequest, id, width, height, pixelFormat );
-}
-
-inline void RequestUpdateBitmapAreaMessage( EventThreadServices& eventThreadServices,
- ResourceManager& manager,
- ResourceId id,
- const Dali::RectArea& area )
-{
- typedef MessageValue2< ResourceManager, ResourceId, Dali::RectArea > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &manager, &ResourceManager::HandleUpdateBitmapAreaRequest, id, area );
-}
-
-inline void RequestUploadBitmapMessage( EventThreadServices& eventThreadServices,
- ResourceManager& manager,
- ResourceId destId,
- Integration::BitmapPtr bitmap,
- std::size_t xOffset,
- std::size_t yOffset )
-{
- typedef MessageValue4< ResourceManager, ResourceId, Integration::BitmapPtr , std::size_t, std::size_t > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &manager, &ResourceManager::HandleUploadBitmapRequest, destId, bitmap, xOffset, yOffset );
-}
-
-inline void RequestUploadBitmapMessage( EventThreadServices& eventThreadServices,
- ResourceManager& manager,
- ResourceId destId,
- ResourceId srcId,
- std::size_t xOffset,
- std::size_t yOffset )
-{
- typedef MessageValue4< ResourceManager, ResourceId, ResourceId, std::size_t, std::size_t > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &manager, &ResourceManager::HandleUploadBitmapRequest, destId, srcId, xOffset, yOffset );
-}
-
-inline void RequestUploadBitmapMessage(EventThreadServices& eventThreadServices,
- ResourceManager& manager,
- ResourceId destId,
- PixelDataPtr pixelData,
- std::size_t xOffset,
- std::size_t yOffset)
-{
- typedef MessageValue4< ResourceManager, ResourceId, PixelDataPtr , std::size_t, std::size_t > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &manager, &ResourceManager::HandleUploadBitmapRequest, destId, pixelData, xOffset, yOffset );
-}
-
-inline void RequestReloadResourceMessage( EventThreadServices& eventThreadServices,
- ResourceManager& manager,
- ResourceId id,
- const ResourceTypePath& typePath,
- Integration::LoadResourcePriority priority,
- bool resetFinishedStatus )
-{
- typedef MessageValue4< ResourceManager, ResourceId, ResourceTypePath, Integration::LoadResourcePriority, bool > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ), false );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &manager, &ResourceManager::HandleReloadResourceRequest, id, typePath, priority, resetFinishedStatus );
-}
-
-inline void RequestDiscardResourceMessage( EventThreadServices& eventThreadServices,
- ResourceManager& manager,
- ResourceId id,
- Integration::ResourceTypeId typeId )
-{
- typedef MessageValue2< ResourceManager, ResourceId, Integration::ResourceTypeId > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.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::HandleDiscardResourceRequest, id, typeId );
-}
-
-inline void RequestCreateGlTextureMessage( EventThreadServices& eventThreadServices,
- ResourceManager& manager,
- ResourceId id )
-{
- typedef MessageValue1< ResourceManager, ResourceId > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventThreadServices.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::HandleCreateGlTextureRequest, id );
-}
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_RESOURCE_MANAGER_H__
+++ /dev/null
-#ifndef __DALI_TEXTURE_METADATA_H__
-#define __DALI_TEXTURE_METADATA_H__
-
-/*
- * Copyright (c) 2015 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/type-traits.h>
-#include <dali/public-api/images/image-operations.h>
-#include <dali/public-api/images/native-image-interface.h>
-#include <dali/integration-api/bitmap.h>
-#include <dali/internal/update/resources/resource-manager-declarations.h>
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-/**
- * Texture metadata.
- */
-class TextureMetadata
-{
-public:
- /**
- * Creates a BitmapMetadata object from a native image (eg.: EGLImage).
- * @param[in] nativeImage The native image to load
- * @return A newly allocated BitmapMetadata
- */
- static TextureMetadata New( ResourceId id, NativeImageInterfacePtr nativeImage )
- {
- return TextureMetadata( id, nativeImage->GetWidth(), nativeImage->GetHeight(), nativeImage->RequiresBlending(), ! nativeImage->RequiresBlending() );
- }
-
- /**
- * Creates a new BitmapMetadata object from a Bitmap
- * @param[in] bitmap The bitmap
- * @return A newly allocated BitmapMetadata
- */
- static TextureMetadata New( ResourceId id, Integration::Bitmap* const bitmap )
- {
- return TextureMetadata( id, bitmap->GetImageWidth(), bitmap->GetImageHeight(), Pixel::HasAlpha(bitmap->GetPixelFormat()), bitmap->IsFullyOpaque() );
- }
-
- /**
- * Creates a new BitmapMetadata object
- * @return A newly allocated BitmapMetadata
- */
- static TextureMetadata New( ResourceId id, unsigned int width, unsigned int height, bool hasAlphaChannel )
- {
- return TextureMetadata( id, width, height, hasAlphaChannel, !hasAlphaChannel );
- }
-
- /**
- * Default Constructor
- */
- TextureMetadata()
- : mSize( 0, 0 ),
- mId( 0 ),
- mHasAlphaChannel( true ),
- mOpaqueness( false ),
- mIsNativeImage( false ),
- mIsFramebuffer( false ),
- mHasFrameBufferBeenRenderedTo( false )
- {
- }
-
- /**
- * Constructor
- */
- TextureMetadata( ResourceId id, unsigned int width, unsigned int height, bool hasAlphaChannel, bool opaqueness )
- : mSize( width, height ),
- mId( id ),
- mHasAlphaChannel( hasAlphaChannel ),
- mOpaqueness( opaqueness ),
- mIsNativeImage( false ),
- mIsFramebuffer( false ),
- mHasFrameBufferBeenRenderedTo( false )
- {
- }
-
- /**
- * As this class is POD, compiler generated copy constructor and assignment operator are ok (bitwise copy)
- */
-
- /**
- * @return the id
- */
- ResourceId GetId() const
- {
- return mId;
- }
-
- /**
- * Updates the metadata with information from the native image
- * @param[in] nativeImage The native image that was updated
- */
- void Update( NativeImageInterfacePtr nativeImage )
- {
- mSize = ImageDimensions( nativeImage->GetWidth(), nativeImage->GetHeight() );
- mHasAlphaChannel = nativeImage->RequiresBlending();
- mOpaqueness = ! mHasAlphaChannel;
- mIsNativeImage = true;
- }
-
- /**
- * Updates the metadata with information from the bitmap
- * @param[in] bitmap The bitmap that was updated
- */
- void Update( Integration::Bitmap* const bitmap )
- {
- mSize = ImageDimensions( bitmap->GetImageWidth(), bitmap->GetImageHeight() );
- mHasAlphaChannel = Pixel::HasAlpha(bitmap->GetPixelFormat());
- mOpaqueness = bitmap->IsFullyOpaque();
- mIsNativeImage = false;
- }
-
- /**
- * Set the width of image
- * @param[in] width The width of the image
- */
- void SetWidth( unsigned int width )
- {
- mSize.SetWidth( width );
- }
-
- /**
- * Return the width of image in pixels.
- * @return width
- */
- unsigned int GetWidth() const
- {
- return mSize.GetWidth();
- }
-
- /**
- * Set the height of image
- * @param[in] height The height of the image in pixels
- */
- void SetHeight(unsigned int height)
- {
- mSize.SetHeight( height );
- }
-
- /**
- * Return the height of image in pixels.
- * @return height
- */
- unsigned int GetHeight() const
- {
- return mSize.GetHeight();
- }
-
- /**
- * Query whether the texture data has an alpha channel.
- * @return True if the texture data has an alpha channel.
- */
- bool HasAlphaChannel() const
- {
- return mHasAlphaChannel;
- }
-
- /**
- * Set whether the texture is completely opaque, i.e.
- * true if all pixels of the texture data are opaque.
- * @param[in] opaqueness If the alpha channel is set to fully opaque.
- */
- void SetOpaqueness( bool opaqueness )
- {
- mOpaqueness = opaqueness;
- }
-
- /**
- * Query whether the texture is completely opaque
- * @return True if all pixels of the texture data are opaque
- */
- bool IsFullyOpaque() const
- {
- return mOpaqueness;
- }
-
- /**
- * @param isNativeImage flag
- */
- void SetIsNativeImage( bool isNativeImage )
- {
- mIsNativeImage = isNativeImage;
- }
-
- /**
- * @return isNativeImage flag
- */
- bool IsNativeImage() const
- {
- return mIsNativeImage;
- }
-
- /**
- * @param isFramebuffer flag
- */
- void SetIsFramebuffer( bool isFramebuffer )
- {
- mIsFramebuffer = isFramebuffer;
- }
-
- /**
- * @return isFramebuffer flag
- */
- bool IsFramebuffer() const
- {
- return mIsFramebuffer;
- }
-
- /**
- * @param value if the framebuffer has been rendered to
- */
- void SetFrameBufferBeenRenderedTo( bool value )
- {
- mHasFrameBufferBeenRenderedTo = value;
- }
-
- /**
- * @return true if the framebuffer has been rendered to
- */
- bool HasFrameBufferBeenRenderedTo() const
- {
- return mHasFrameBufferBeenRenderedTo;
- }
-
-private: // Data
-
- ImageDimensions mSize; ///< size compressed into 32 bits
- ResourceId mId; ///< Unique resource/texture ID
- bool mHasAlphaChannel:1; ///< Pixel format of the contained image data.
- bool mOpaqueness:1; ///< Whether the bitmap was fully opaque when loaded / updated
- bool mIsNativeImage:1; ///< Whether the image is native or not
- bool mIsFramebuffer:1; ///< Whether the image is an FBO
- bool mHasFrameBufferBeenRenderedTo:1; /// If the FBO has been rendered to
-
-};
-
-} // namespace Internal
-
-// Allow BitmapMetadataEntry to be treated as a POD type (need to do this in Dali namespace)
-template <> struct TypeTraits< Internal::TextureMetadata > : public BasicTypes< Internal::TextureMetadata > { enum { IS_TRIVIAL_TYPE = true }; };
-
-} // namespace Dali
-
-#endif // __DALI_TEXTURE_METADATA_H__
{
if( texture )
{
- Internal::NewTexturePtr texturePtr( &GetImplementation( texture ) );
+ Internal::TexturePtr texturePtr( &GetImplementation( texture ) );
GetImplementation(*this).AttachColorTexture( texturePtr, mipmapLevel, layer );
}
}
Texture FrameBuffer::GetColorTexture()
{
- Internal::NewTexture* texturePtr = GetImplementation(*this).GetColorTexture();
+ Internal::Texture* texturePtr = GetImplementation(*this).GetColorTexture();
return Dali::Texture( texturePtr );
}
{
if( texture )
{
- Internal::NewTexturePtr texturePtr( &GetImplementation( texture ) );
+ Internal::TexturePtr texturePtr( &GetImplementation( texture ) );
GetImplementation(*this).SetTexture( index, texturePtr );
}
else
Texture TextureSet::GetTexture( size_t index ) const
{
- Internal::NewTexture* texturePtr = GetImplementation(*this).GetTexture( index );
+ Internal::Texture* texturePtr = GetImplementation(*this).GetTexture( index );
return Dali::Texture( texturePtr );
}
Texture Texture::New( TextureType::Type type, Pixel::Format format, unsigned int width, unsigned int height )
{
- Internal::NewTexturePtr texture = Internal::NewTexture::New(type, format, width, height );
+ Internal::TexturePtr texture = Internal::Texture::New(type, format, width, height );
return Texture( texture.Get() );
}
Texture Texture::New( NativeImageInterface& nativeImageInterface )
{
- Internal::NewTexturePtr texture = Internal::NewTexture::New( nativeImageInterface );
+ Internal::TexturePtr texture = Internal::Texture::New( nativeImageInterface );
return Texture( texture.Get() );
}
Texture Texture::DownCast( BaseHandle handle )
{
- return Texture( dynamic_cast<Dali::Internal::NewTexture*>(handle.GetObjectPtr()));
+ return Texture( dynamic_cast<Dali::Internal::Texture*>(handle.GetObjectPtr()));
}
Texture& Texture::operator=( const Texture& handle )
return GetImplementation(*this).GetHeight();
}
-Texture::Texture( Internal::NewTexture* pointer )
+Texture::Texture( Internal::Texture* pointer )
: BaseHandle( pointer )
{
}
namespace Internal DALI_INTERNAL
{
-class NewTexture;
+class Texture;
}
namespace TextureType
* @SINCE_1_1.43
* @param[in] pointer A pointer to a newly allocated Texture
*/
- explicit DALI_INTERNAL Texture( Internal::NewTexture* pointer );
+ explicit DALI_INTERNAL Texture( Internal::Texture* pointer );
};
} //namespace Dali