/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
#include <dali/integration-api/debug.h>
#include <dali/integration-api/platform-abstraction.h>
#include <dali/internal/event/common/thread-local-storage.h>
-#include <dali/internal/event/effects/shader-effect-impl.h>
-#include <dali/internal/event/effects/shader-declarations.h>
-
-// compile time generated shader strings
-#include "dali-shaders.h"
namespace
{
}
-ShaderFactory::ShaderFactory()
-{
-}
+ShaderFactory::ShaderFactory() = default;
ShaderFactory::~ShaderFactory()
{
// Let all the cached objects destroy themselves:
- for( int i = 0, cacheSize = mShaderBinaryCache.Size(); i < cacheSize; ++i )
+ for( std::size_t i = 0, cacheSize = mShaderBinaryCache.Size(); i < cacheSize; ++i )
{
if( mShaderBinaryCache[i] )
{
}
}
-ShaderDataPtr ShaderFactory::Load( const std::string& vertexSource, const std::string& fragmentSource, size_t& shaderHash )
+ShaderDataPtr ShaderFactory::Load( const std::string& vertexSource, const std::string& fragmentSource, const Dali::Shader::Hint::Value hints, size_t& shaderHash )
{
// Work out the filename for the binary that the glsl source will be compiled and linked to:
shaderHash = CalculateHash( vertexSource.c_str(), fragmentSource.c_str() );
ShaderDataPtr shaderData;
/// Check a cache of previously loaded shaders:
- for( int i = 0, cacheSize = mShaderBinaryCache.Size(); i < cacheSize; ++i )
+ for( std::size_t i = 0, cacheSize = mShaderBinaryCache.Size(); i < cacheSize; ++i )
{
if( mShaderBinaryCache[i]->GetHashValue() == shaderHash )
{
}
// If memory cache failed check the file system for a binary or return a source-only ShaderData:
- if( shaderData.Get() == NULL )
+ if( shaderData.Get() == nullptr )
{
// Allocate the structure that returns the loaded shader:
- shaderData = new ShaderData( vertexSource, fragmentSource );
+ shaderData = new ShaderData( vertexSource, fragmentSource, hints );
shaderData->SetHashValue( shaderHash );
shaderData->GetBuffer().Clear();
ThreadLocalStorage& tls = ThreadLocalStorage::Get();
Integration::PlatformAbstraction& platformAbstraction = tls.GetPlatformAbstraction();
- const bool saved = platformAbstraction.SaveShaderBinaryFile( binaryShaderFilename, &shaderData->GetBuffer()[0], shaderData->GetBufferSize() );
+ const bool saved = platformAbstraction.SaveShaderBinaryFile( binaryShaderFilename, &shaderData->GetBuffer()[0], static_cast<unsigned int>( shaderData->GetBufferSize() ) ); // don't expect buffer larger than unsigned int
// Save the binary into to memory cache:
MemoryCacheInsert( *shaderData );
if( saved ) {} // Avoid unused variable warning in release builds
}
-void ShaderFactory::LoadDefaultShaders()
-{
- mDefaultShader = ShaderEffect::New();
-}
-
void ShaderFactory::MemoryCacheInsert( ShaderData& shaderData )
{
DALI_ASSERT_DEBUG( shaderData.GetBufferSize() > 0 );