/*
- * 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.
// CLASS HEADER
#include "visual-factory-cache.h"
-// EXTERNAL HEADER
+// EXTERNAL INCLUDES
#include <dali/devel-api/common/hash.h>
+#include <dali/public-api/images/resource-image.h>
-// INTERNAL HEADER
+// INTERNAL INCLUDES
#include <dali-toolkit/internal/visuals/color/color-visual.h>
#include <dali-toolkit/internal/visuals/svg/svg-visual.h>
+#include <dali-toolkit/internal/visuals/image-atlas-manager.h>
+
+namespace
+{
+const char * const BROKEN_VISUAL_IMAGE_URL( DALI_IMAGE_DIR "broken.png");
+}
namespace Dali
{
return false;
}
-void VisualFactoryCache::CacheDebugVisual( Renderer& renderer )
+void VisualFactoryCache::CacheWireframeRenderer( Renderer& renderer )
{
- mDebugVisual = renderer;
+ mWireframeRenderer = renderer;
}
-Renderer VisualFactoryCache::GetDebugVisual()
+Renderer VisualFactoryCache::GetWireframeRenderer()
{
- return mDebugVisual;
+ return mWireframeRenderer;
}
Geometry VisualFactoryCache::CreateQuadGeometry()
// Create the geometry object
Geometry geometry = Geometry::New();
geometry.AddVertexBuffer( quadVertices );
- geometry.SetGeometryType( Geometry::TRIANGLE_STRIP );
+ geometry.SetType( Geometry::TRIANGLE_STRIP );
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 )
geometry.SetIndexBuffer( &indices[ 0 ], indices.Size() );
}
- geometry.SetGeometryType( Geometry::TRIANGLE_STRIP );
+ geometry.SetType( Geometry::TRIANGLE_STRIP );
+
+ 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