Added connection for sampler texture
[platform/core/uifw/dali-core.git] / dali / internal / update / common / double-buffered-property.h
1 #ifndef __DALI_INTERNAL_SCENE_GRAPH_DOUBLE_BUFFERED_PROPERTY_H__
2 #define __DALI_INTERNAL_SCENE_GRAPH_DOUBLE_BUFFERED_PROPERTY_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <limits>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/common/dali-common.h>
26 #include <dali/public-api/object/property.h>
27 #include <dali/public-api/object/property-input.h>
28 #include <dali/public-api/object/property-types.h>
29 #include <dali/internal/common/message.h>
30 #include <dali/internal/event/common/event-thread-services.h>
31 #include <dali/internal/event/common/property-input-impl.h>
32 #include <dali/internal/update/common/double-buffered.h>
33 #include <dali/internal/update/common/scene-graph-buffers.h>
34
35 namespace Dali
36 {
37
38 namespace Internal
39 {
40
41 namespace SceneGraph
42 {
43
44 namespace DoubleBufferedPropertyFlags
45 {
46 /**
47  * Dirty flags record whether a doubleBuffered property has changed.
48  * In the frame following a change, the property is copied from the most recent
49  * buffer to the old buffer.
50  */
51 static const unsigned int CLEAN_FLAG  = 0x00; ///< Indicates that the value did not change in this, or the previous frame
52 static const unsigned int COPIED_FLAG = 0x01; ///< Indicates that the value was copied during the previous frame
53 static const unsigned int SET_FLAG    = 0x02; ///< Indicates that the value was Set during the previous frame
54 }
55
56 template <class T>
57 class DoubleBufferedProperty;
58
59 /**
60  * Base class to reduce code size from the templates.
61  */
62 class DoubleBufferedPropertyBase : public PropertyInputImpl
63 {
64 public:
65
66   /**
67    * Constructor, initialize the dirty flag
68    */
69   DoubleBufferedPropertyBase()
70   : PropertyInputImpl(),
71     mDirtyFlags( DoubleBufferedPropertyFlags::COPIED_FLAG )
72   {}
73
74   /**
75    * Virtual destructor.
76    */
77   virtual ~DoubleBufferedPropertyBase()
78   {}
79
80   /**
81    * Auto-age the property: if it was set the previous frame,
82    * then copy the value into the current frame's buffer.
83    */
84   virtual void CopyPrevious( BufferIndex updateBufferIndex ) = 0;
85
86
87 protected: // for derived classes
88   /**
89    * Flag that the property has been Set during the current frame.
90    */
91   void OnSet()
92   {
93     mDirtyFlags = DoubleBufferedPropertyFlags::SET_FLAG;
94   }
95
96 public: // From PropertyBase
97
98   /**
99    * @copydoc Dali::Internal::PropertyInputImpl::InputChanged()
100    */
101   virtual bool InputChanged() const
102   {
103     return ( DoubleBufferedPropertyFlags::CLEAN_FLAG != mDirtyFlags );
104   }
105
106   /**
107    * @copydoc Dali::Internal::PropertyInputImpl::InputInitialized()
108    */
109   virtual bool InputInitialized() const
110   {
111     return true; // DoubleBuffered properties are always valid
112   }
113
114 protected: // so that ResetToBaseValue can set it directly
115
116   unsigned int mDirtyFlags; ///< Flag whether value changed during previous 2 frames
117
118 };
119
120
121 /**
122  * A boolean doubleBuffered property of a scene-graph object.
123  */
124 template <>
125 class DoubleBufferedProperty<bool> : public DoubleBufferedPropertyBase
126 {
127 public:
128
129   /**
130    * Create an doubleBuffered property.
131    * @param [in] initialValue The initial value of the property.
132    */
133   DoubleBufferedProperty( bool initialValue )
134   : mValue( initialValue )
135   {
136   }
137
138   /**
139    * Virtual destructor.
140    */
141   virtual ~DoubleBufferedProperty()
142   {
143   }
144
145   /**
146    * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
147    */
148   virtual Dali::Property::Type GetType() const
149   {
150     return Dali::PropertyTypes::Get<bool>();
151   }
152
153   /**
154    * @copydoc Dali::Internal::SceneGraph::DoubleBufferedPropertyBase::CopyPrevious()
155    */
156   virtual void CopyPrevious( BufferIndex updateBufferIndex )
157   {
158     if( DoubleBufferedPropertyFlags::SET_FLAG == mDirtyFlags)
159     {
160       mValue[ updateBufferIndex ] = mValue[ 1-updateBufferIndex ];
161       mDirtyFlags = ( mDirtyFlags >> 1 );
162     }
163   }
164
165   /**
166    * @copydoc Dali::Internal::PropertyInputImpl::GetBoolean()
167    */
168   virtual const bool& GetBoolean( BufferIndex bufferIndex ) const
169   {
170     return mValue[ bufferIndex ];
171   }
172
173   /**
174    * Set the property value. This will persist for the current frame, and will
175    * be copied to the other buffer next frame (unless it is set again)
176    * @param[in] bufferIndex The buffer to write.
177    * @param[in] value The new property value.
178    */
179   void Set(BufferIndex bufferIndex, bool value)
180   {
181     // check if the value actually changed to avoid dirtying nodes unnecessarily
182     if( mValue[bufferIndex] != value )
183     {
184       mValue[bufferIndex] = value;
185
186       OnSet();
187     }
188   }
189
190   /**
191    * @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
192    */
193   bool& Get(size_t bufferIndex)
194   {
195     return mValue[bufferIndex];
196   }
197
198   /**
199    * @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
200    */
201   const bool& Get(size_t bufferIndex) const
202   {
203     return mValue[bufferIndex];
204   }
205
206   /**
207    * Retrieve the property value.
208    * @param[in] bufferIndex The buffer to read.
209    * @return The property value.
210    */
211   bool& operator[](size_t bufferIndex)
212   {
213     return mValue[bufferIndex];
214   }
215
216   /**
217    * Retrieve the property value.
218    * @param[in] bufferIndex The buffer to read.
219    * @return The property value.
220    */
221   const bool& operator[](size_t bufferIndex) const
222   {
223     return mValue[bufferIndex];
224   }
225
226 private:
227   // Undefined
228   DoubleBufferedProperty(const DoubleBufferedProperty& property);
229
230   // Undefined
231   DoubleBufferedProperty& operator=(const DoubleBufferedProperty& rhs);
232
233 private:
234   DoubleBuffered<bool> mValue; ///< The double-buffered property value
235 };
236
237
238 /**
239  * A double buffered integer property of a scene-graph object.
240  */
241 template <>
242 class DoubleBufferedProperty<int> : public DoubleBufferedPropertyBase
243 {
244 public:
245
246   /**
247    * Create a double buffered property.
248    * @param [in] initialValue The initial value of the property.
249    */
250   DoubleBufferedProperty( int initialValue )
251   : mValue( initialValue )
252   {
253   }
254
255   /**
256    * Virtual destructor.
257    */
258   virtual ~DoubleBufferedProperty()
259   {
260   }
261
262   /**
263    * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
264    */
265   virtual Dali::Property::Type GetType() const
266   {
267     return Dali::PropertyTypes::Get<int>();
268   }
269
270   /**
271    * @copydoc Dali::Internal::SceneGraph::DoubleBufferedPropertyBase::CopyPrevious()
272    */
273   virtual void CopyPrevious( BufferIndex updateBufferIndex )
274   {
275     if( DoubleBufferedPropertyFlags::SET_FLAG == mDirtyFlags)
276     {
277       mValue[ updateBufferIndex ] = mValue[ 1-updateBufferIndex ];
278       mDirtyFlags = ( mDirtyFlags >> 1 );
279     }
280   }
281
282   /**
283    * @copydoc Dali::Internal::PropertyInputImpl::GetInteger()
284    */
285   virtual const int& GetInteger( BufferIndex bufferIndex ) const
286   {
287     return mValue[ bufferIndex ];
288   }
289
290   /**
291    * Set the property value. This will persist for the current frame, and will
292    * be copied to the other buffer next frame (unless it is set again)
293    * @param[in] bufferIndex The buffer to write.
294    * @param[in] value The new property value.
295    */
296   void Set(BufferIndex bufferIndex, int value)
297   {
298     // check if the value actually changed to avoid dirtying nodes unnecessarily
299     if( mValue[bufferIndex] != value )
300     {
301       mValue[bufferIndex] = value;
302
303       OnSet();
304     }
305   }
306
307   /**
308    * @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
309    */
310   int& Get(size_t bufferIndex)
311   {
312     return mValue[bufferIndex];
313   }
314
315   /**
316    * @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
317    */
318   const int& Get(size_t bufferIndex) const
319   {
320     return mValue[bufferIndex];
321   }
322
323   /**
324    * Retrieve the property value.
325    * @param[in] bufferIndex The buffer to read.
326    * @return The property value.
327    */
328   int& operator[](size_t bufferIndex)
329   {
330     return mValue[bufferIndex];
331   }
332
333   /**
334    * Retrieve the property value.
335    * @param[in] bufferIndex The buffer to read.
336    * @return The property value.
337    */
338   const int& operator[](size_t bufferIndex) const
339   {
340     return mValue[bufferIndex];
341   }
342
343 private:
344   // Undefined
345   DoubleBufferedProperty(const DoubleBufferedProperty& property);
346
347   // Undefined
348   DoubleBufferedProperty& operator=(const DoubleBufferedProperty& rhs);
349
350 private:
351   DoubleBuffered<int> mValue; ///< The double-buffered property value
352 };
353
354
355 /**
356  * A double buffered unsigned integer property of a scene-graph object.
357  */
358 template <>
359 class DoubleBufferedProperty<unsigned int> : public DoubleBufferedPropertyBase
360 {
361 public:
362   typedef unsigned int OwnType;
363
364   /**
365    * Create a double buffered property.
366    * @param [in] initialValue The initial value of the property.
367    */
368   DoubleBufferedProperty( OwnType initialValue )
369   : mValue( initialValue )
370   {
371   }
372
373   /**
374    * Virtual destructor.
375    */
376   virtual ~DoubleBufferedProperty()
377   {
378   }
379
380   /**
381    * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
382    */
383   virtual Dali::Property::Type GetType() const
384   {
385     return Dali::PropertyTypes::Get<OwnType>();
386   }
387
388   /**
389    * @copydoc Dali::Internal::SceneGraph::DoubleBufferedPropertyBase::CopyPrevious()
390    */
391   virtual void CopyPrevious( BufferIndex updateBufferIndex )
392   {
393     if( DoubleBufferedPropertyFlags::SET_FLAG == mDirtyFlags)
394     {
395       mValue[ updateBufferIndex ] = mValue[ 1-updateBufferIndex ];
396       mDirtyFlags = ( mDirtyFlags >> 1 );
397     }
398   }
399
400   /**
401    * @copydoc Dali::Internal::PropertyInputImpl::GetInteger()
402    */
403   virtual const OwnType& GetUnsignedInteger( BufferIndex bufferIndex ) const
404   {
405     return mValue[ bufferIndex ];
406   }
407
408   /**
409    * Set the property value. This will persist for the current frame, and will
410    * be copied to the other buffer next frame (unless it is set again)
411    * @param[in] bufferIndex The buffer to write.
412    * @param[in] value The new property value.
413    */
414   void Set(BufferIndex bufferIndex, OwnType value)
415   {
416     // check if the value actually changed to avoid dirtying nodes unnecessarily
417     if( mValue[bufferIndex] != value )
418     {
419       mValue[bufferIndex] = value;
420
421       OnSet();
422     }
423   }
424
425   /**
426    * @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
427    */
428   OwnType& Get(size_t bufferIndex)
429   {
430     return mValue[bufferIndex];
431   }
432
433   /**
434    * @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
435    */
436   const OwnType& Get(size_t bufferIndex) const
437   {
438     return mValue[bufferIndex];
439   }
440
441   /**
442    * Retrieve the property value.
443    * @param[in] bufferIndex The buffer to read.
444    * @return The property value.
445    */
446   OwnType& operator[](size_t bufferIndex)
447   {
448     return mValue[bufferIndex];
449   }
450
451   /**
452    * Retrieve the property value.
453    * @param[in] bufferIndex The buffer to read.
454    * @return The property value.
455    */
456   const OwnType& operator[](size_t bufferIndex) const
457   {
458     return mValue[bufferIndex];
459   }
460
461 private:
462   // Undefined
463   DoubleBufferedProperty(const DoubleBufferedProperty& property);
464
465   // Undefined
466   DoubleBufferedProperty& operator=(const DoubleBufferedProperty& rhs);
467
468 private:
469   DoubleBuffered<OwnType> mValue; ///< The double-buffered property value
470 };
471
472
473 /**
474  * A float doubleBuffered property of a scene-graph object.
475  */
476 template <>
477 class DoubleBufferedProperty<float> : public DoubleBufferedPropertyBase
478 {
479 public:
480
481   /**
482    * Create a doubleBuffered property.
483    * @param[in] initialValue The initial value of the property.
484    */
485   DoubleBufferedProperty( float initialValue )
486   : mValue( initialValue )
487   {
488   }
489
490   /**
491    * Virtual destructor.
492    */
493   virtual ~DoubleBufferedProperty()
494   {
495   }
496
497   /**
498    * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
499    */
500   virtual Dali::Property::Type GetType() const
501   {
502     return Dali::PropertyTypes::Get<float>();
503   }
504
505   /**
506    * @copydoc Dali::Internal::SceneGraph::DoubleBufferedPropertyBase::CopyPrevious()
507    */
508   virtual void CopyPrevious( BufferIndex updateBufferIndex )
509   {
510     if( DoubleBufferedPropertyFlags::SET_FLAG == mDirtyFlags)
511     {
512       mValue[ updateBufferIndex ] = mValue[ 1-updateBufferIndex ];
513       mDirtyFlags = ( mDirtyFlags >> 1 );
514     }
515   }
516
517   /**
518    * @copydoc Dali::Internal::PropertyInputImpl::GetFloat()
519    */
520   virtual const float& GetFloat( BufferIndex bufferIndex ) const
521   {
522     return mValue[ bufferIndex ];
523   }
524
525   /**
526    * Set the property value. This will persist for the current frame, and will
527    * be copied to the other buffer next frame (unless it is set again)
528    * @param[in] bufferIndex The buffer to write.
529    * @param[in] value The new property value.
530    */
531   void Set(BufferIndex bufferIndex, float value)
532   {
533     mValue[bufferIndex] = value;
534     OnSet();
535   }
536
537   /**
538    * @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
539    */
540   float& Get(size_t bufferIndex)
541   {
542     return mValue[bufferIndex];
543   }
544
545   /**
546    * @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
547    */
548   const float& Get(size_t bufferIndex) const
549   {
550     return mValue[bufferIndex];
551   }
552
553   /**
554    * Retrieve the property value.
555    * @param[in] bufferIndex The buffer to read.
556    * @return The property value.
557    */
558   float& operator[](size_t bufferIndex)
559   {
560     return mValue[bufferIndex];
561   }
562
563   /**
564    * Retrieve the property value.
565    * @param[in] bufferIndex The buffer to read.
566    * @return The property value.
567    */
568   const float& operator[](size_t bufferIndex) const
569   {
570     return mValue[bufferIndex];
571   }
572
573 private:
574   // Undefined
575   DoubleBufferedProperty(const DoubleBufferedProperty& property);
576
577   // Undefined
578   DoubleBufferedProperty& operator=(const DoubleBufferedProperty& rhs);
579
580 private:
581   DoubleBuffered<float> mValue; ///< The double-buffered property value
582 };
583
584 /**
585  * A double buffered Vector2  property of a scene-graph object.
586  */
587 template <>
588 class DoubleBufferedProperty<Vector2> : public DoubleBufferedPropertyBase
589 {
590 public:
591
592   /**
593    * Create a double buffered property.
594    * @param [in] initialValue The initial value of the property.
595    */
596   DoubleBufferedProperty( Vector2 initialValue )
597   : mValue( initialValue )
598   {
599   }
600
601   /**
602    * Virtual destructor.
603    */
604   virtual ~DoubleBufferedProperty()
605   {
606   }
607
608   /**
609    * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
610    */
611   virtual Dali::Property::Type GetType() const
612   {
613     return Dali::PropertyTypes::Get<Vector2>();
614   }
615
616   /**
617    * @copydoc Dali::Internal::SceneGraph::DoubleBufferedPropertyBase::CopyPrevious()
618    */
619   virtual void CopyPrevious( BufferIndex updateBufferIndex )
620   {
621     if( DoubleBufferedPropertyFlags::SET_FLAG == mDirtyFlags)
622     {
623       mValue[ updateBufferIndex ] = mValue[ 1-updateBufferIndex ];
624       mDirtyFlags = ( mDirtyFlags >> 1 );
625     }
626   }
627
628   /**
629    * @copydoc Dali::Internal::PropertyInputImpl::GetVector2()
630    */
631   virtual const Vector2& GetVector2( BufferIndex bufferIndex ) const
632   {
633     return mValue[ bufferIndex ];
634   }
635
636   /**
637    * Set the property value. This will persist for the current frame, and will
638    * be copied to the other buffer next frame (unless it is set again)
639    * @param[in] bufferIndex The buffer to write.
640    * @param[in] value The new property value.
641    */
642   void Set(BufferIndex bufferIndex, Vector2 value)
643   {
644     mValue[bufferIndex] = value;
645     OnSet();
646   }
647
648   /**
649    * @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
650    */
651   Vector2& Get(size_t bufferIndex)
652   {
653     return mValue[bufferIndex];
654   }
655
656   /**
657    * @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
658    */
659   const Vector2& Get(size_t bufferIndex) const
660   {
661     return mValue[bufferIndex];
662   }
663
664   /**
665    * Retrieve the property value.
666    * @param[in] bufferIndex The buffer to read.
667    * @return The property value.
668    */
669   Vector2& operator[](size_t bufferIndex)
670   {
671     return mValue[bufferIndex];
672   }
673
674   /**
675    * Retrieve the property value.
676    * @param[in] bufferIndex The buffer to read.
677    * @return The property value.
678    */
679   const Vector2& operator[](size_t bufferIndex) const
680   {
681     return mValue[bufferIndex];
682   }
683
684 private:
685   // Undefined
686   DoubleBufferedProperty(const DoubleBufferedProperty& property);
687
688   // Undefined
689   DoubleBufferedProperty& operator=(const DoubleBufferedProperty& rhs);
690
691 private:
692   DoubleBuffered<Vector2> mValue; ///< The double-buffered property value
693 };
694
695 /**
696  * A double buffered Vector3  property of a scene-graph object.
697  */
698 template <>
699 class DoubleBufferedProperty<Vector3> : public DoubleBufferedPropertyBase
700 {
701 public:
702
703   /**
704    * Create a double buffered property.
705    * @param [in] initialValue The initial value of the property.
706    */
707   DoubleBufferedProperty( Vector3 initialValue )
708   : mValue( initialValue )
709   {
710   }
711
712   /**
713    * Virtual destructor.
714    */
715   virtual ~DoubleBufferedProperty()
716   {
717   }
718
719   /**
720    * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
721    */
722   virtual Dali::Property::Type GetType() const
723   {
724     return Dali::PropertyTypes::Get<Vector3>();
725   }
726
727   /**
728    * @copydoc Dali::Internal::SceneGraph::DoubleBufferedPropertyBase::CopyPrevious()
729    */
730   virtual void CopyPrevious( BufferIndex updateBufferIndex )
731   {
732     if( DoubleBufferedPropertyFlags::SET_FLAG == mDirtyFlags)
733     {
734       mValue[ updateBufferIndex ] = mValue[ 1-updateBufferIndex ];
735       mDirtyFlags = ( mDirtyFlags >> 1 );
736     }
737   }
738
739   /**
740    * @copydoc Dali::Internal::PropertyInputImpl::GetVector3()
741    */
742   virtual const Vector3& GetVector3( BufferIndex bufferIndex ) const
743   {
744     return mValue[ bufferIndex ];
745   }
746
747   /**
748    * Set the property value. This will persist for the current frame, and will
749    * be copied to the other buffer next frame (unless it is set again)
750    * @param[in] bufferIndex The buffer to write.
751    * @param[in] value The new property value.
752    */
753   void Set(BufferIndex bufferIndex, Vector3 value)
754   {
755     mValue[bufferIndex] = value;
756     OnSet();
757   }
758
759   /**
760    * @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
761    */
762   Vector3& Get(size_t bufferIndex)
763   {
764     return mValue[bufferIndex];
765   }
766
767   /**
768    * @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
769    */
770   const Vector3& Get(size_t bufferIndex) const
771   {
772     return mValue[bufferIndex];
773   }
774
775   /**
776    * Retrieve the property value.
777    * @param[in] bufferIndex The buffer to read.
778    * @return The property value.
779    */
780   Vector3& operator[](size_t bufferIndex)
781   {
782     return mValue[bufferIndex];
783   }
784
785   /**
786    * Retrieve the property value.
787    * @param[in] bufferIndex The buffer to read.
788    * @return The property value.
789    */
790   const Vector3& operator[](size_t bufferIndex) const
791   {
792     return mValue[bufferIndex];
793   }
794
795 private:
796   // Undefined
797   DoubleBufferedProperty(const DoubleBufferedProperty& property);
798
799   // Undefined
800   DoubleBufferedProperty& operator=(const DoubleBufferedProperty& rhs);
801
802 private:
803   DoubleBuffered<Vector3> mValue; ///< The double-buffered property value
804 };
805
806 /**
807  * A double buffered Vector4  property of a scene-graph object.
808  */
809 template <>
810 class DoubleBufferedProperty<Vector4> : public DoubleBufferedPropertyBase
811 {
812 public:
813
814   /**
815    * Create a double buffered property.
816    * @param [in] initialValue The initial value of the property.
817    */
818   DoubleBufferedProperty( Vector4 initialValue )
819   : mValue( initialValue )
820   {
821   }
822
823   /**
824    * Virtual destructor.
825    */
826   virtual ~DoubleBufferedProperty()
827   {
828   }
829
830   /**
831    * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
832    */
833   virtual Dali::Property::Type GetType() const
834   {
835     return Dali::PropertyTypes::Get<Vector4>();
836   }
837
838   /**
839    * @copydoc Dali::Internal::SceneGraph::DoubleBufferedPropertyBase::CopyPrevious()
840    */
841   virtual void CopyPrevious( BufferIndex updateBufferIndex )
842   {
843     if( DoubleBufferedPropertyFlags::SET_FLAG == mDirtyFlags)
844     {
845       mValue[ updateBufferIndex ] = mValue[ 1-updateBufferIndex ];
846       mDirtyFlags = ( mDirtyFlags >> 1 );
847     }
848   }
849
850   /**
851    * @copydoc Dali::Internal::PropertyInputImpl::GetVector4()
852    */
853   virtual const Vector4& GetVector4( BufferIndex bufferIndex ) const
854   {
855     return mValue[ bufferIndex ];
856   }
857
858   /**
859    * Set the property value. This will persist for the current frame, and will
860    * be copied to the other buffer next frame (unless it is set again)
861    * @param[in] bufferIndex The buffer to write.
862    * @param[in] value The new property value.
863    */
864   void Set(BufferIndex bufferIndex, Vector4 value)
865   {
866     mValue[bufferIndex] = value;
867     OnSet();
868   }
869
870   /**
871    * @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
872    */
873   Vector4& Get(size_t bufferIndex)
874   {
875     return mValue[bufferIndex];
876   }
877
878   /**
879    * @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
880    */
881   const Vector4& Get(size_t bufferIndex) const
882   {
883     return mValue[bufferIndex];
884   }
885
886   /**
887    * Retrieve the property value.
888    * @param[in] bufferIndex The buffer to read.
889    * @return The property value.
890    */
891   Vector4& operator[](size_t bufferIndex)
892   {
893     return mValue[bufferIndex];
894   }
895
896   /**
897    * Retrieve the property value.
898    * @param[in] bufferIndex The buffer to read.
899    * @return The property value.
900    */
901   const Vector4& operator[](size_t bufferIndex) const
902   {
903     return mValue[bufferIndex];
904   }
905
906 private:
907   // Undefined
908   DoubleBufferedProperty(const DoubleBufferedProperty& property);
909
910   // Undefined
911   DoubleBufferedProperty& operator=(const DoubleBufferedProperty& rhs);
912
913 private:
914   DoubleBuffered<Vector4> mValue; ///< The double-buffered property value
915 };
916
917
918 /**
919  * A double buffered Quaternion  property of a scene-graph object.
920  */
921 template <>
922 class DoubleBufferedProperty<Quaternion> : public DoubleBufferedPropertyBase
923 {
924 public:
925
926   /**
927    * Create a double buffered property.
928    * @param [in] initialValue The initial value of the property.
929    */
930   DoubleBufferedProperty( Quaternion initialValue )
931   : mValue( initialValue )
932   {
933   }
934
935   /**
936    * Virtual destructor.
937    */
938   virtual ~DoubleBufferedProperty()
939   {
940   }
941
942   /**
943    * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
944    */
945   virtual Dali::Property::Type GetType() const
946   {
947     return Dali::PropertyTypes::Get<Quaternion>();
948   }
949
950   /**
951    * @copydoc Dali::Internal::SceneGraph::DoubleBufferedPropertyBase::CopyPrevious()
952    */
953   virtual void CopyPrevious( BufferIndex updateBufferIndex )
954   {
955     if( DoubleBufferedPropertyFlags::SET_FLAG == mDirtyFlags)
956     {
957       mValue[ updateBufferIndex ] = mValue[ 1-updateBufferIndex ];
958       mDirtyFlags = ( mDirtyFlags >> 1 );
959     }
960   }
961
962   /**
963    * @copydoc Dali::Internal::PropertyInputImpl::GetQuaternion()
964    */
965   virtual const Quaternion& GetQuaternion( BufferIndex bufferIndex ) const
966   {
967     return mValue[ bufferIndex ];
968   }
969
970   /**
971    * Set the property value. This will persist for the current frame, and will
972    * be copied to the other buffer next frame (unless it is set again)
973    * @param[in] bufferIndex The buffer to write.
974    * @param[in] value The new property value.
975    */
976   void Set(BufferIndex bufferIndex, Quaternion value)
977   {
978     mValue[bufferIndex] = value;
979     OnSet();
980   }
981
982   /**
983    * @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
984    */
985   Quaternion& Get(size_t bufferIndex)
986   {
987     return mValue[bufferIndex];
988   }
989
990   /**
991    * @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
992    */
993   const Quaternion& Get(size_t bufferIndex) const
994   {
995     return mValue[bufferIndex];
996   }
997
998   /**
999    * Retrieve the property value.
1000    * @param[in] bufferIndex The buffer to read.
1001    * @return The property value.
1002    */
1003   Quaternion& operator[](size_t bufferIndex)
1004   {
1005     return mValue[bufferIndex];
1006   }
1007
1008   /**
1009    * Retrieve the property value.
1010    * @param[in] bufferIndex The buffer to read.
1011    * @return The property value.
1012    */
1013   const Quaternion& operator[](size_t bufferIndex) const
1014   {
1015     return mValue[bufferIndex];
1016   }
1017
1018 private:
1019   // Undefined
1020   DoubleBufferedProperty(const DoubleBufferedProperty& property);
1021
1022   // Undefined
1023   DoubleBufferedProperty& operator=(const DoubleBufferedProperty& rhs);
1024
1025 private:
1026   DoubleBuffered<Quaternion> mValue; ///< The double-buffered property value
1027 };
1028
1029 /**
1030  * A double buffered Matrix  property of a scene-graph object.
1031  */
1032 template <>
1033 class DoubleBufferedProperty<Matrix> : public DoubleBufferedPropertyBase
1034 {
1035 public:
1036
1037   /**
1038    * Create a double buffered property.
1039    * @param [in] initialValue The initial value of the property.
1040    */
1041   DoubleBufferedProperty( Matrix initialValue )
1042   : mValue( initialValue )
1043   {
1044   }
1045
1046   /**
1047    * Virtual destructor.
1048    */
1049   virtual ~DoubleBufferedProperty()
1050   {
1051   }
1052
1053   /**
1054    * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
1055    */
1056   virtual Dali::Property::Type GetType() const
1057   {
1058     return Dali::PropertyTypes::Get<Matrix>();
1059   }
1060
1061   /**
1062    * @copydoc Dali::Internal::SceneGraph::DoubleBufferedPropertyBase::CopyPrevious()
1063    */
1064   virtual void CopyPrevious( BufferIndex updateBufferIndex )
1065   {
1066     if( DoubleBufferedPropertyFlags::SET_FLAG == mDirtyFlags)
1067     {
1068       mValue[ updateBufferIndex ] = mValue[ 1-updateBufferIndex ];
1069       mDirtyFlags = ( mDirtyFlags >> 1 );
1070     }
1071   }
1072
1073   /**
1074    * @copydoc Dali::Internal::PropertyInputImpl::GetMatrix()
1075    */
1076   virtual const Matrix& GetMatrix( BufferIndex bufferIndex ) const
1077   {
1078     return mValue[ bufferIndex ];
1079   }
1080
1081   /**
1082    * Set the property value. This will persist for the current frame, and will
1083    * be copied to the other buffer next frame (unless it is set again)
1084    * @param[in] bufferIndex The buffer to write.
1085    * @param[in] value The new property value.
1086    */
1087   void Set(BufferIndex bufferIndex, Matrix value)
1088   {
1089     mValue[bufferIndex] = value;
1090     OnSet();
1091   }
1092
1093   /**
1094    * @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
1095    */
1096   Matrix& Get(size_t bufferIndex)
1097   {
1098     return mValue[bufferIndex];
1099   }
1100
1101   /**
1102    * @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
1103    */
1104   const Matrix& Get(size_t bufferIndex) const
1105   {
1106     return mValue[bufferIndex];
1107   }
1108
1109   /**
1110    * Retrieve the property value.
1111    * @param[in] bufferIndex The buffer to read.
1112    * @return The property value.
1113    */
1114   Matrix& operator[](size_t bufferIndex)
1115   {
1116     return mValue[bufferIndex];
1117   }
1118
1119   /**
1120    * Retrieve the property value.
1121    * @param[in] bufferIndex The buffer to read.
1122    * @return The property value.
1123    */
1124   const Matrix& operator[](size_t bufferIndex) const
1125   {
1126     return mValue[bufferIndex];
1127   }
1128
1129 private:
1130   // Undefined
1131   DoubleBufferedProperty(const DoubleBufferedProperty& property);
1132
1133   // Undefined
1134   DoubleBufferedProperty& operator=(const DoubleBufferedProperty& rhs);
1135
1136 private:
1137   DoubleBuffered<Matrix> mValue; ///< The double-buffered property value
1138 };
1139
1140
1141 /**
1142  * A double buffered Matrix3  property of a scene-graph object.
1143  */
1144 template <>
1145 class DoubleBufferedProperty<Matrix3> : public DoubleBufferedPropertyBase
1146 {
1147 public:
1148
1149   /**
1150    * Create a double buffered property.
1151    * @param [in] initialValue The initial value of the property.
1152    */
1153   DoubleBufferedProperty( Matrix3 initialValue )
1154   : mValue( initialValue )
1155   {
1156   }
1157
1158   /**
1159    * Virtual destructor.
1160    */
1161   virtual ~DoubleBufferedProperty()
1162   {
1163   }
1164
1165   /**
1166    * @copydoc Dali::Internal::SceneGraph::PropertyBase::GetType()
1167    */
1168   virtual Dali::Property::Type GetType() const
1169   {
1170     return Dali::PropertyTypes::Get<Matrix3>();
1171   }
1172
1173   /**
1174    * @copydoc Dali::Internal::SceneGraph::DoubleBufferedPropertyBase::CopyPrevious()
1175    */
1176   virtual void CopyPrevious( BufferIndex updateBufferIndex )
1177   {
1178     if( DoubleBufferedPropertyFlags::SET_FLAG == mDirtyFlags)
1179     {
1180       mValue[ updateBufferIndex ] = mValue[ 1-updateBufferIndex ];
1181       mDirtyFlags = ( mDirtyFlags >> 1 );
1182     }
1183   }
1184
1185   /**
1186    * @copydoc Dali::Internal::PropertyInputImpl::GetMatrix3()
1187    */
1188   virtual const Matrix3& GetMatrix3( BufferIndex bufferIndex ) const
1189   {
1190     return mValue[ bufferIndex ];
1191   }
1192
1193   /**
1194    * Set the property value. This will persist for the current frame, and will
1195    * be copied to the other buffer next frame (unless it is set again)
1196    * @param[in] bufferIndex The buffer to write.
1197    * @param[in] value The new property value.
1198    */
1199   void Set(BufferIndex bufferIndex, Matrix3 value)
1200   {
1201     mValue[bufferIndex] = value;
1202     OnSet();
1203   }
1204
1205   /**
1206    * @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
1207    */
1208   Matrix3& Get(size_t bufferIndex)
1209   {
1210     return mValue[bufferIndex];
1211   }
1212
1213   /**
1214    * @copydoc Dali::SceneGraph::DoubleBufferedProperty::Get()
1215    */
1216   const Matrix3& Get(size_t bufferIndex) const
1217   {
1218     return mValue[bufferIndex];
1219   }
1220
1221   /**
1222    * Retrieve the property value.
1223    * @param[in] bufferIndex The buffer to read.
1224    * @return The property value.
1225    */
1226   Matrix3& operator[](size_t bufferIndex)
1227   {
1228     return mValue[bufferIndex];
1229   }
1230
1231   /**
1232    * Retrieve the property value.
1233    * @param[in] bufferIndex The buffer to read.
1234    * @return The property value.
1235    */
1236   const Matrix3& operator[](size_t bufferIndex) const
1237   {
1238     return mValue[bufferIndex];
1239   }
1240
1241 private:
1242   // Undefined
1243   DoubleBufferedProperty(const DoubleBufferedProperty& property);
1244
1245   // Undefined
1246   DoubleBufferedProperty& operator=(const DoubleBufferedProperty& rhs);
1247
1248 private:
1249   DoubleBuffered<Matrix3> mValue; ///< The double-buffered property value
1250 };
1251
1252 } // namespace SceneGraph
1253
1254 // Messages for DoubleBufferedProperty<T>
1255
1256 template <class T>
1257 void SetMessage( EventThreadServices& eventThreadServices,
1258                   const SceneGraph::DoubleBufferedProperty<T>& property,
1259                   typename ParameterType< T >::PassingType newValue )
1260 {
1261   typedef MessageDoubleBuffered1< SceneGraph::DoubleBufferedProperty<T>, T > LocalType;
1262
1263   // Reserve some memory inside the message queue
1264   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
1265
1266   // Construct message in the message queue memory; note that delete should not be called on the return value
1267   new (slot) LocalType( &property,
1268                         &SceneGraph::DoubleBufferedProperty<T>::Set,
1269                         newValue );
1270 }
1271
1272 } // namespace Internal
1273
1274 } // namespace Dali
1275
1276 #endif // __DALI_INTERNAL_SCENE_GRAPH_DOUBLE_BUFFERED_PROPERTY_H__