2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/update/rendering/scene-graph-shader.h>
30 Shader::Shader( Dali::Shader::Hint::Value& hints )
31 : mGraphics( nullptr ),
32 mGraphicsShader( nullptr ),
33 mShaderCache( nullptr ),
35 mConnectionObservers()
37 AddUniformMapObserver( *this );
42 mConnectionObservers.Destroy( *this );
45 void Shader::Initialize( Integration::Graphics::Graphics& graphics, ShaderCache& shaderCache )
47 mGraphics = &graphics;
48 mShaderCache = &shaderCache;
51 Graphics::API::Accessor<Graphics::API::Shader>& Shader::GetGfxObject()
53 return mGraphicsShader;
56 void Shader::AddConnectionObserver( ConnectionChangePropagator::Observer& observer )
58 mConnectionObservers.Add(observer);
61 void Shader::RemoveConnectionObserver( ConnectionChangePropagator::Observer& observer )
63 mConnectionObservers.Remove(observer);
66 void Shader::UniformMappingsChanged( const UniformMap& mappings )
68 // Our uniform map, or that of one of the watched children has changed.
69 // Inform connected observers.
70 mConnectionObservers.ConnectedUniformMapChanged();
73 void Shader::SetShaderProgram( Internal::ShaderDataPtr shaderData, bool modifiesGeometry )
75 // TODO: for now we will use hardcoded binary SPIRV shaders which will replace anything
76 // that is passed by the caller
77 if (shaderData->GetType() == ShaderData::Type::BINARY)
79 mGraphicsShader = mShaderCache->GetShader(
80 Graphics::API::ShaderDetails::ShaderSource(shaderData->GetShaderForStage(ShaderData::ShaderStage::VERTEX)),
81 Graphics::API::ShaderDetails::ShaderSource(shaderData->GetShaderForStage(ShaderData::ShaderStage::FRAGMENT)));
86 } // namespace SceneGraph
88 } // namespace Internal