X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fvisual-factory-cache.cpp;h=05e32ff23a385de447db3f638e21e46eb40d8c63;hb=6b6c1a325a1a66f17225e712f3b94054a771e7c8;hp=aef0fc826f2a23e44d7dd6624cfdea146274afa3;hpb=4ee66864e6f96d6de8c4f0b8beed439c0f3508d1;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/visual-factory-cache.cpp b/dali-toolkit/internal/visuals/visual-factory-cache.cpp index aef0fc8..05e32ff 100644 --- a/dali-toolkit/internal/visuals/visual-factory-cache.cpp +++ b/dali-toolkit/internal/visuals/visual-factory-cache.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * 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. @@ -17,12 +17,19 @@ // CLASS HEADER #include "visual-factory-cache.h" -// EXTERNAL HEADER +// EXTERNAL INCLUDES #include +#include -// INTERNAL HEADER +// INTERNAL INCLUDES #include #include +#include + +namespace +{ +const char * const BROKEN_VISUAL_IMAGE_URL( DALI_IMAGE_DIR "broken.png"); +} namespace Dali { @@ -45,6 +52,11 @@ VisualFactoryCache::~VisualFactoryCache() Geometry VisualFactoryCache::GetGeometry( GeometryType type ) { + if( !mGeometry[type] && type == QUAD_GEOMETRY ) + { + mGeometry[type] = CreateQuadGeometry(); + } + return mGeometry[type]; } @@ -143,16 +155,6 @@ bool VisualFactoryCache::CleanRendererCache( const std::string& key ) return false; } -void VisualFactoryCache::CacheDebugRenderer( Renderer& renderer ) -{ - mDebugRenderer = renderer; -} - -Renderer VisualFactoryCache::GetDebugRenderer() -{ - return mDebugRenderer; -} - Geometry VisualFactoryCache::CreateQuadGeometry() { const float halfWidth = 0.5f; @@ -179,6 +181,22 @@ Geometry VisualFactoryCache::CreateQuadGeometry() return geometry; } +ImageAtlasManagerPtr VisualFactoryCache::GetAtlasManager() +{ + if( !mAtlasManager ) + { + mAtlasManager = new ImageAtlasManager(); + mAtlasManager->SetBrokenImage( BROKEN_VISUAL_IMAGE_URL ); + } + + return mAtlasManager; +} + +NPatchLoader& VisualFactoryCache::GetNPatchLoader() +{ + return mNPatchLoader; +} + SvgRasterizeThread* VisualFactoryCache::GetSVGRasterizationThread() { if( !mSvgRasterizeThread ) @@ -266,6 +284,54 @@ Geometry VisualFactoryCache::CreateGridGeometry( Uint16Pair gridSize ) return geometry; } +Geometry VisualFactoryCache::CreateBatchQuadGeometry( Vector4 texCoords ) +{ + const float halfWidth = 0.5f; + const float halfHeight = 0.5f; + struct QuadVertex { + QuadVertex( const Vector2& vertexPosition, const Vector2& vertexTexCoords ) + : position( vertexPosition ), + texCoords( vertexTexCoords ) + {} + Vector2 position; + Vector2 texCoords; + }; + + // special case, when texture takes whole space + if( texCoords == Vector4::ZERO ) + { + texCoords = Vector4(0.0f, 0.0f, 1.0f, 1.0f); + } + + QuadVertex quadVertexData[6] = + { + QuadVertex( Vector2(-halfWidth, -halfHeight ), Vector2(texCoords.x, texCoords.y) ), + QuadVertex( Vector2( halfWidth, -halfHeight ), Vector2(texCoords.z, texCoords.y) ), + QuadVertex( Vector2(-halfWidth, halfHeight ), Vector2(texCoords.x, texCoords.w) ), + QuadVertex( Vector2( halfWidth, -halfHeight ), Vector2(texCoords.z, texCoords.y) ), + QuadVertex( Vector2(-halfWidth, halfHeight ), Vector2(texCoords.x, texCoords.w) ), + QuadVertex( Vector2( halfWidth, halfHeight ), Vector2(texCoords.z, texCoords.w) ), + }; + + Property::Map vertexFormat; + vertexFormat[ "aPosition" ] = Property::VECTOR2; + vertexFormat[ "aTexCoord" ] = Property::VECTOR2; + PropertyBuffer vertexBuffer = PropertyBuffer::New( vertexFormat ); + vertexBuffer.SetData( quadVertexData, 6 ); + + // create geometry as normal, single quad + Geometry geometry = Geometry::New(); + geometry.AddVertexBuffer( vertexBuffer ); + geometry.SetType( Geometry::TRIANGLES ); + + return geometry; +} + +Image VisualFactoryCache::GetBrokenVisualImage() +{ + return ResourceImage::New( BROKEN_VISUAL_IMAGE_URL ); +} + } // namespace Internal } // namespace Toolkit