1 #ifndef DALI_INTERNAL_SCENE_GRAPH_MATERIAL_H
2 #define DALI_INTERNAL_SCENE_GRAPH_MATERIAL_H
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 #include <dali/public-api/actors/renderable-actor.h> // For CullFaceMode
21 #include <dali/internal/common/buffer-index.h>
22 #include <dali/internal/common/blending-options.h>
23 #include <dali/internal/common/event-to-update.h>
24 #include <dali/internal/update/common/double-buffered.h>
25 #include <dali/internal/update/common/property-owner.h>
26 #include <dali/internal/render/renderers/material-data-provider.h>
37 class Material : public PropertyOwner, public MaterialDataProvider
40 typedef Dali::Vector< Sampler* > Samplers;
53 * Set the shader effect for this material
54 * @param[in] shader The shader effect to use
56 void SetShader( Shader* shader );
59 * Get the shader effect of this material
60 * @return the shader effect;
65 * Add a sampler (image + sampler modes) to the material
66 * @param[in] sampler A sampler to add
68 void AddSampler( const Sampler* sampler );
71 * Remove a sampler (image + sampler modes) from the material
72 * @param[in] sampler A sampler to remove
74 void RemoveSampler( const Sampler* sampler );
77 * Get the samplers this material uses.
78 * @return the samplers
80 const Samplers& GetSamplers() const;
84 Samplers mSamplers; // Not owned (though who does?)
86 // @todo MESH_REWORK add property values for cull face mode, blending options, blend color
87 // Add getters/setters?
90 inline void SetShaderMessage( EventToUpdate& eventToUpdate, const Material& material, Shader& shader )
92 typedef MessageValue1< Material, Shader* > LocalType;
94 // Reserve some memory inside the message queue
95 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
97 // Construct message in the message queue memory; note that delete should not be called on the return value
98 new (slot) LocalType( &material, &Material::SetShader, &shader );
101 inline void AddSamplerMessage( EventToUpdate& eventToUpdate, const Material& material, const Sampler& sampler )
103 typedef MessageValue1< Material, const Sampler* > LocalType;
105 // Reserve some memory inside the message queue
106 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
108 // Construct message in the message queue memory; note that delete should not be called on the return value
109 new (slot) LocalType( &material, &Material::AddSampler, &sampler );
112 inline void RemoveSamplerMessage( EventToUpdate& eventToUpdate, const Material& material, const Sampler& sampler )
114 typedef MessageValue1< Material, const Sampler* > LocalType;
116 // Reserve some memory inside the message queue
117 unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
119 // Construct message in the message queue memory; note that delete should not be called on the return value
120 new (slot) LocalType( &material, &Material::RemoveSampler, &sampler );
123 } // namespace SceneGraph
124 } // namespace Internal
127 #endif // DALI_INTERNAL_SCENE_GRAPH_MATERIAL_H