From 42cb0dcc5acc5024059b36600080e2c804fa1aa4 Mon Sep 17 00:00:00 2001 From: David Steele Date: Fri, 6 Mar 2015 15:32:15 +0000 Subject: [PATCH] Addition of update geometry properties and quads Change-Id: Ib8e72b4388012a427a701ca3c5e16e6e8a2b69a9 --- dali/internal/update/common/property-boolean.h | 132 +++++++++++++++++++++ .../update/common/scene-graph-property-buffer.cpp | 30 +++++ .../update/common/scene-graph-property-buffer.h | 9 +- .../update/geometry/scene-graph-geometry.cpp | 5 +- .../update/geometry/scene-graph-geometry.h | 8 +- 5 files changed, 181 insertions(+), 3 deletions(-) create mode 100644 dali/internal/update/common/property-boolean.h diff --git a/dali/internal/update/common/property-boolean.h b/dali/internal/update/common/property-boolean.h new file mode 100644 index 0000000..2181466 --- /dev/null +++ b/dali/internal/update/common/property-boolean.h @@ -0,0 +1,132 @@ +#ifndef __DALI_INTERNAL_SCENE_GRAPH_BOOLEAN_PROPERTY_H__ +#define __DALI_INTERNAL_SCENE_GRAPH_BOOLEAN_PROPERTY_H__ + +/* + * Copyright (c) 2015 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// INTERNAL INCLUDES +#include +#include +#include +#include +#include +#include +#include + +namespace Dali +{ + +namespace Internal +{ + +namespace SceneGraph +{ + +/** + * A Boolean non-animatable property. + */ +class PropertyBoolean : public PropertyInputImpl +{ +public: + + /** + * Create an non-animatable property. + * @param [in] initialValue The initial value of the property. + */ + PropertyBoolean( bool initialValue ) + : mValue( initialValue ), + mDirtyFlag( true ) + { + } + + /** + * Virtual destructor. + */ + virtual ~PropertyBoolean() + { + } + + /** + * Clear the dirty flag + */ + void Clear() + { + mDirtyFlag = false; + } + + /** + * @copydoc Dali::Internal::PropertyInputImpl::GetType() + */ + virtual Dali::Property::Type GetType() const + { + return Dali::PropertyTypes::Get(); + } + + /** + * @copydoc Dali::Internal::PropertyInputImpl::InputInitialized() + */ + virtual bool InputInitialized() const + { + return true; + } + + /** + * @copydoc Dali::Internal::PropertyInputImpl::InputChanged() + */ + virtual bool InputChanged() const + { + return mDirtyFlag; + } + + /** + * @copydoc Dali::PropertyInput::GetBoolean() + */ + virtual const bool& GetBoolean( BufferIndex bufferIndex ) const + { + return mValue; + } + + /** + * Flag that the property has been Set during the current frame. + */ + void OnSet() + { + mDirtyFlag = true; + } + +private: + + // Undefined + PropertyBoolean(const PropertyBoolean& property); + + // Undefined + PropertyBoolean& operator=(const PropertyBoolean& rhs); + +public: + boolean mValue; ///< The property value + +private: + boolean mDirtyFlag; +}; + +} // namespace SceneGraph + +} // namespace Internal + +} // namespace Dali + +#endif // __DALI_INTERNAL_SCENE_GRAPH_BOOLEAN_PROPERTY_H__ diff --git a/dali/internal/update/common/scene-graph-property-buffer.cpp b/dali/internal/update/common/scene-graph-property-buffer.cpp index b1a1396..dcdf83a 100644 --- a/dali/internal/update/common/scene-graph-property-buffer.cpp +++ b/dali/internal/update/common/scene-graph-property-buffer.cpp @@ -31,6 +31,36 @@ PropertyBuffer::~PropertyBuffer() { } +//@todo MESH_REWORK Remove when we have working property buffers +PropertyBuffer* PropertyBuffer::NewQuadVertices() +{ + PropertyBuffer* propertyBuffer = new PropertyBuffer(); + propertyBuffer->mVertexSize = sizeof(Vector4); + propertyBuffer->mData.Resize( propertyBuffer->mVertexSize * 4 ); + Vector4* vertices = reinterpret_cast(propertyBuffer->mData[0]); + + vertices[ 0 ] = Vector4( -0.5f, -0.5f, 1.0f, 0.0f ); + vertices[ 1 ] = Vector4( 0.5f, -0.5f, 1.0f, 1.0f ); + vertices[ 2 ] = Vector4( -0.5f, 0.5f, 0.0f, 0.0f ); + vertices[ 3 ] = Vector4( 0.5f, 0.5f, 0.0f, 1.0f ); + + return propertyBuffer; +} + +//@todo MESH_REWORK Remove when we have working property buffers +PropertyBuffer* PropertyBuffer::NewQuadIndices() +{ + PropertyBuffer* propertyBuffer = new PropertyBuffer(); + + propertyBuffer->mVertexSize = sizeof( unsigned short ); + propertyBuffer->mData.Resize( propertyBuffer->mVertexSize * 6 ); + unsigned short* indices = reinterpret_cast(propertyBuffer->mData[0]); + + indices[0] = 0; indices[1] = 3; indices[2] = 1; + indices[3] = 0; indices[4] = 2; indices[5] = 3; + + return propertyBuffer; +} } // namespace SceneGraph } // namespace Internal diff --git a/dali/internal/update/common/scene-graph-property-buffer.h b/dali/internal/update/common/scene-graph-property-buffer.h index bbc1425..b930f2f 100644 --- a/dali/internal/update/common/scene-graph-property-buffer.h +++ b/dali/internal/update/common/scene-graph-property-buffer.h @@ -17,6 +17,9 @@ * limitations under the License. */ +#include +#include + namespace Dali { namespace Internal @@ -44,7 +47,11 @@ public: ~PropertyBuffer(); private: - // Data + + // @todo MESH_REWORK - TEMPORARY TYPES - REMOVE WHEN WE HAVE WORKING BUFFERS + typedef Dali::Vector< char > CharBuffer; + CharBuffer mData; + std::size_t mVertexSize; }; } // namespace SceneGraph diff --git a/dali/internal/update/geometry/scene-graph-geometry.cpp b/dali/internal/update/geometry/scene-graph-geometry.cpp index 6a07a39..8ae76a6 100644 --- a/dali/internal/update/geometry/scene-graph-geometry.cpp +++ b/dali/internal/update/geometry/scene-graph-geometry.cpp @@ -24,7 +24,10 @@ namespace SceneGraph { Geometry::Geometry() -: mGeometryType(Dali::Geometry::TRIANGLES) +: mCenter(), + mHalfExtents(), + mGeometryType(Dali::Geometry::TRIANGLES), + mRequiresDepthTest(false) { // @todo MESH_REWORK Remove this code when we have working property buffers // @todo It's also the wrong place to do this temporary work diff --git a/dali/internal/update/geometry/scene-graph-geometry.h b/dali/internal/update/geometry/scene-graph-geometry.h index 86da67d..0830833 100644 --- a/dali/internal/update/geometry/scene-graph-geometry.h +++ b/dali/internal/update/geometry/scene-graph-geometry.h @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -101,7 +102,12 @@ public: // GeometryDataProvider private: VertexBuffers mVertexBuffers; ///< The vertex buffers OwnerPointer mIndexBuffer; ///< The index buffer if required - GeometryType mGeometryType; ///< The type of geometry (tris/lines etc) + +private: // Properties + AnimatableProperty mCenter; + AnimatableProperty mHalfExtents; + GeometryType mGeometryType; ///< The type of geometry (tris/lines etc) + AnimatableProperty mRequiresDepthTest; }; inline void AddVertexBufferMessage( EventToUpdate& eventToUpdate, const Geometry& geometry, PropertyBuffer& vertexBuffer ) -- 2.7.4