+++ /dev/null
-#ifndef __DALI_INTERNAL_RENDERING_TYPES_H__
-#define __DALI_INTERNAL_RENDERING_TYPES_H__
-
-/*
- * Copyright (c) 2014 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.
- *
- */
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-/*
- * Paint style used for certain nodes
- */
-struct PaintStyle
-{
- /**
- * Default constructor, initializes everything to zero
- */
- PaintStyle()
- : mStyleMode( STYLE_1x1 ),
- mFadeIn(false),
- mFadeInTime(0),
- mBorderX0( 0.0f ), mBorderY0( 0.0f ), mBorderX1( 0.0f ), mBorderY1( 0.0f ),
- mClipX0( 0.0f ), mClipY0( 0.0f ), mClipX1( 0.0f ), mClipY1( 0.0f )
- { }
-
- enum StyleMode
- {
- STYLE_1x1,
- STYLE_3x1,
- STYLE_1x3,
- STYLE_3x3,
- STYLE_GRID,
- STYLE_BORDER_1x1
- };
-
- StyleMode mStyleMode;
- bool mFadeIn; ///< whether to fade the image in
- unsigned int mFadeInTime; ///< how quickly to fade an image in, in milliseconds
-
- float mBorderX0; // Border for 3x3 grid
- float mBorderY0;
- float mBorderX1;
- float mBorderY1;
-
- float mClipX0; // clip region for centre rectangle
- float mClipY0;
- float mClipX1;
- float mClipY1;
-};
-
-} // namespace Dali
-
-} // namespace Internal
-
-#endif // __DALI_INTERNAL_RENDERING_TYPES_H__
+++ /dev/null
-#ifndef __DALI_INTERNAL_UV_RECT_H__
-#define __DALI_INTERNAL_UV_RECT_H__
-
-/*
- * Copyright (c) 2014 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.
- *
- */
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-/**
- * UV co-ordinates for a rectangle
- */
-struct UvRect
- {
- float u0; ///< u texture coordinate (x) -bottom left
- float v0; ///< v texture coordinate (y) -bottom left
- float u2; ///< u texture coordinate (x) -top right
- float v2; ///< v texture coordinate (y) -top right
-
- /**
- * Constructor.
- */
- UvRect()
- : u0(0.0f), v0(0.0f),
- u2(1.0f), v2(1.0f)
- {
- }
-
- /**
- * Reset the UV coordinates to default values
- */
- void Reset()
- {
- u0 = 0.0f;
- v0 = 0.0f;
- u2 = 1.0f;
- v2 = 1.0f;
- }
-
- /**
- * Assignment operator
- */
- UvRect& operator= (const UvRect& rhs)
- {
- if (this != &rhs)
- {
- u0 = rhs.u0;
- v0 = rhs.v0;
- u2 = rhs.u2;
- v2 = rhs.v2;
- }
- return *this;
- }
-
- /**
- * Adjusts the uv coordinates, relative to the atlas uv coordinates.
- * Use for displaying part of a bitmap, which is held in an atlas.
- * For example:
- * \code
- *
- * (0,0)
- * |-----------------------------|
- * | Atlas |
- * | |
- * | /----------------------\ |
- * | | Bitmap | |
- * | | | |
- * | | /---------\ | |
- * | | | | | |
- * | | | Area to | | |
- * | | | display | | |
- * | | \---------/ | |
- * | \______________________/ |
- * | |
- * |_____________________________|
- * (1,1)
- *
- * \endcode
- */
- void AdjustToAtlasUV(const UvRect &atlasUV)
- {
- // this = Area To Display
- // atlasUV = UV coordinates of bitmap in the atlas.
-
- // 1. calculate the bitmap uv width / height in the atlas
- float parentWidth = atlasUV.u2 - atlasUV.u0;
- float parentHeight = atlasUV.v2 - atlasUV.v0;
-
- // algorithm = bitmap.start + displayArea.position * bitmap.width or height
-
- u0 = atlasUV.u0 + u0 * parentWidth;
- v0 = atlasUV.v0 + v0 * parentHeight;
- u2 = atlasUV.u0 + u2 * parentWidth;
- v2 = atlasUV.v0 + v2 * parentHeight;
-
- }
-
- }; // struct UV
-
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_UV_H__
+++ /dev/null
-#ifndef __DALI_INTERNAL_VERTEX_H__
-#define __DALI_INTERNAL_VERTEX_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.
- *
- */
-
-namespace Dali
-{
-
-namespace Internal
-{
-
-struct Vertex2D
-{
- float mX;
- float mY;
- float mU;
- float mV;
-};
-
-} // namespace Internal
-
-} // namespace Dali
-
-#endif // __DALI_INTERNAL_VERTEX_H__
// INTERNAL INCLUDES
#include <dali/public-api/common/dali-vector.h>
#include <dali/integration-api/debug.h>
-#include <dali/internal/render/common/vertex.h>
#include <dali/internal/render/common/performance-monitor.h>
#include <dali/internal/render/gl-resources/context.h>
#include <dali/internal/render/gl-resources/texture-units.h>
// INTERNAL INCLUDES
#include <dali/integration-api/debug.h>
-#include <dali/internal/render/common/vertex.h>
#include <dali/internal/render/common/performance-monitor.h>
#include <dali/internal/render/gl-resources/context.h>
#include <dali/internal/render/gl-resources/texture-units.h>
// INTERNAL INCLUDES
#include <dali/integration-api/debug.h>
-#include <dali/internal/render/common/vertex.h>
#include <dali/internal/render/gl-resources/context.h>
#include <dali/internal/render/gl-resources/texture.h>
#include <dali/internal/render/gl-resources/texture-units.h>
// INTERNAL INCLUDES
#include <dali/integration-api/debug.h>
-#include <dali/internal/render/common/vertex.h>
#include <dali/internal/render/gl-resources/context.h>
#include <dali/internal/common/image-sampler.h>
}
}
-void Texture::MapUV(unsigned int numVerts,Vertex2D *verts, const PixelArea* pixelArea)
-{
- MapUV(numVerts, (float*)(&verts->mU), sizeof(Vertex2D)/sizeof(float), pixelArea);
-}
-
-void Texture::MapUV(unsigned int numVerts, float* verts, unsigned int stride, const PixelArea* pixelArea)
-{
- UvRect uv;
-
- GetTextureCoordinates(uv, pixelArea);
-
- float uScale = fabsf(uv.u2 - uv.u0);
- float vScale = fabsf(uv.v2 - uv.v0);
-
- for (unsigned int i = 0; i < numVerts; ++i)
- {
- verts[0] = uv.u0 + verts[0] * uScale;
- verts[1] = uv.v0 + verts[1] * vScale;
- verts += stride;
- }
-}
-
unsigned int Texture::GetWidth() const
{
return mWidth;
return mHeight;
}
-void Texture::GetTextureCoordinates(UvRect& uv, const PixelArea* pixelArea)
-{
- if( pixelArea == NULL )
- {
- GetDefaultTextureCoordinates(uv);
- return;
- }
-
- // pre-calulate the normalized values
-
- const float uScale = 1.0f / float(mWidth);
- const float vScale = 1.0f / float(mHeight);
- const float x = uScale * float(pixelArea->x);
- const float y = vScale * float(pixelArea->y);
- const float width = uScale * float(pixelArea->width);
- const float height = vScale * float(pixelArea->height);
-
-
- // bottom left
- uv.u0 = x;
- uv.v0 = y;
-
- // top right
- uv.u2 = x + width;
- uv.v2 = y + height;
-
-};
-
-void Texture::GetDefaultTextureCoordinates(UvRect& uv) const
-{
- if ((mWidth == mImageWidth) && (mHeight == mImageHeight))
- {
- // set the uv's to display 0,0 to 1,1
- uv.Reset();
- return;
- }
-
- // the texture co-ordinates go from 0 to 1. But the image is smaller than the
- // texture, so we need to adjust the uv values.
- float uScale = float(mImageWidth) / float(mWidth);
- float vScale = float(mImageHeight) / float(mHeight);
-
- // bottom left
- uv.u0 = 0.0f;
- uv.v0 = 0.0f;
-
- // top right
- uv.u2 = uScale;
- uv.v2 = vScale;
-
-}
-
void Texture::ApplyFilterModeParameter( TextureUnit unit, GLint filterType, FilterMode::Type currentFilterMode, FilterMode::Type newFilterMode, GLint daliDefault, GLint systemDefault )
{
GLint newFilterModeGL = FilterModeToGL( newFilterMode, daliDefault, systemDefault );
#include <dali/public-api/object/ref-object.h>
#include <dali/devel-api/images/pixel-data.h>
#include <dali/integration-api/bitmap.h>
-#include <dali/internal/render/common/uv-rect.h>
#include <dali/integration-api/gl-abstraction.h>
#include <dali/internal/render/gl-resources/gl-resource-owner.h>
#include <dali/internal/render/gl-resources/texture-units.h>
void SetTextureId(GLuint id);
/**
- * When creating a texture mapped object, the developer can
- * assume the texture u,v coordinates have a range of 0 to 1.
- * They then just call MapUV which will adjust uv values depending on
- * whether a pixel area is being used or not.
- *@param[in] numVerts number of vertices
- *@param[out] verts pointer to an array of vertex objects
- *@param[in] pixelArea the area of the texture to display, null = use default image area
- */
- void MapUV(unsigned int numVerts, Dali::Internal::Vertex2D* verts, const PixelArea* pixelArea = NULL);
-
- /**
- * @copydoc MapUV(unsigned int,Dali::Internal::Vertex2D*, const PixelArea* pixelArea)
- * @param[in] stride The number of floats on each row of the vertex object table
- */
- void MapUV(unsigned int numVerts, float* verts, unsigned int stride, const PixelArea* pixelArea = NULL);
-
- /**
- * Gets the texture coordinates for the texture.
- * The texture maybe in an atlas or may only be part of a texture (that's been padded to be a power of 2).
- * Why do we specify u,v coordinates for all 4 points of a texture, instead of just having bottom left u,v and top right u,v?
- * If the texture is an atlas it maybe rotated, to encode that information we need to use all 4 u,v points.
- * @param[out] uv coordinates.
- * @param[in] pixelArea the area of the texture to display, null = use default image area
- */
- void GetTextureCoordinates(UvRect& uv, const PixelArea* pixelArea = NULL);
-
- /**
* @brief Apply the given sampler to the texture.
*
* @param[in] texture unit to use
Texture& operator=(const Texture& rhs);
/**
- * Helper function for GetTextureCoordinates.
- * Gets the texture co-ordinates without using a pixel area.
- * It is possible the image is smaller than the texture
- * so the texture co-ordinates have to be adjusted.
- * @param uv texture co-ordinates
- */
- void GetDefaultTextureCoordinates(UvRect& uv) const;
-
- /**
* @brief Apply the given texture filtering parameters.
*
* @param[in] texture unit to use
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * 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.
}
/**
- * Rebuild the Layer::opaqueRenderables, transparentRenderables and overlayRenderables members,
+ * Rebuild the Layer::colorRenderables, stencilRenderables and overlayRenderables members,
* including only renderers which are included in the current render-task.
* Returns true if all renderers have finshed acquiring resources.
*/
if( node.ResolveVisibility( updateBufferIndex ) )
{
- for( unsigned int i(0); i<node.GetRendererCount(); ++i )
+ const unsigned int count = node.GetRendererCount();
+ for( unsigned int i = 0; i < count; ++i )
{
Renderer* renderer = node.GetRendererAt( i );
bool ready = false;
resourcesFinished = !complete ? complete : resourcesFinished;
- resourcesFinished = !complete ? complete : resourcesFinished;
-
- if( ready ) // i.e. some resources are ready
+ if( ready ) // i.e. should be rendered (all resources are available)
{
if( DrawMode::STENCIL == inheritedDrawMode )
{
// If world-matrix needs to be recalculated
if ( nodeDirtyFlags & TransformFlag )
{
- if( node.GetInhibitLocalTransform() )
- {
- node.SetWorldMatrix( updateBufferIndex,
- node.GetWorldScale(updateBufferIndex),
- node.GetWorldOrientation(updateBufferIndex) / node.GetOrientation(updateBufferIndex),
- node.GetWorldPosition(updateBufferIndex) - node.GetPosition(updateBufferIndex) );
- }
- else
- {
- node.SetWorldMatrix( updateBufferIndex,
- node.GetWorldScale(updateBufferIndex),
- node.GetWorldOrientation(updateBufferIndex),
- node.GetWorldPosition(updateBufferIndex) );
- }
+ node.SetWorldMatrix( updateBufferIndex,
+ node.GetWorldScale(updateBufferIndex),
+ node.GetWorldOrientation(updateBufferIndex),
+ node.GetWorldPosition(updateBufferIndex) );
}
else
{
#include <dali/internal/render/common/render-instruction-container.h>
#include <dali/internal/render/common/render-manager.h>
#include <dali/internal/render/queue/render-queue.h>
-#include <dali/internal/render/common/performance-monitor.h>
#include <dali/internal/render/gl-resources/texture-cache.h>
#include <dali/internal/render/shaders/scene-graph-shader.h>
#include <dali/internal/render/renderers/render-sampler.h>
void UpdateManager::ResetProperties( BufferIndex bufferIndex )
{
- PERF_MONITOR_START(PerformanceMonitor::RESET_PROPERTIES);
-
// Clear the "animations finished" flag; This should be set if any (previously playing) animation is stopped
mImpl->animationFinishedDuringUpdate = false;
{
(*iter)->ResetToBaseValues( bufferIndex );
}
-
- PERF_MONITOR_END(PerformanceMonitor::RESET_PROPERTIES);
}
bool UpdateManager::ProcessGestures( BufferIndex bufferIndex, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds )
void UpdateManager::Animate( BufferIndex bufferIndex, float elapsedSeconds )
{
- PERF_MONITOR_START(PerformanceMonitor::ANIMATE_NODES);
-
AnimationContainer &animations = mImpl->animations;
AnimationIter iter = animations.Begin();
while ( iter != animations.End() )
// The application should be notified by NotificationManager, in another thread
mImpl->notificationManager.QueueCompleteNotification( &mImpl->animationFinishedNotifier );
}
-
- PERF_MONITOR_END(PerformanceMonitor::ANIMATE_NODES);
}
void UpdateManager::ApplyConstraints( BufferIndex bufferIndex )
{
- PERF_MONITOR_START(PerformanceMonitor::APPLY_CONSTRAINTS);
-
// constrain custom objects... (in construction order)
OwnerContainer< PropertyOwner* >& customObjects = mImpl->customObjects;
// e.g. ShaderEffect uniform a function of Actor's position.
// Mesh vertex a function of Actor's position or world position.
- // TODO: refactor this code (and reset nodes) as these are all just lists of property-owners
- // they can be all processed in a super-list of property-owners.
-
// Constrain system-level render-tasks
const RenderTaskList::RenderTaskContainer& systemLevelTasks = mImpl->systemLevelTaskList.GetTasks();
Shader& shader = **iter;
ConstrainPropertyOwner( shader, bufferIndex );
}
-
- PERF_MONITOR_END(PerformanceMonitor::APPLY_CONSTRAINTS);
}
void UpdateManager::ProcessPropertyNotifications( BufferIndex bufferIndex )
return;
}
- PERF_MONITOR_START( PerformanceMonitor::UPDATE_NODES );
-
// Prepare resources, update shaders, update attachments, for each node
// And add the renderers to the sorted layers. Start from root, which is also a layer
mImpl->nodeDirtyFlags = UpdateNodesAndAttachments( *( mImpl->root ),
mImpl->resourceManager,
mImpl->renderQueue );
}
-
- PERF_MONITOR_END( PerformanceMonitor::UPDATE_NODES );
}
unsigned int UpdateManager::Update( float elapsedSeconds,
unsigned int lastVSyncTimeMilliseconds,
unsigned int nextVSyncTimeMilliseconds )
{
- PERF_MONITOR_END(PerformanceMonitor::FRAME_RATE); // Mark the End of the last frame
- PERF_MONITOR_NEXT_FRAME(); // Prints out performance info for the last frame (if enabled)
- PERF_MONITOR_START(PerformanceMonitor::FRAME_RATE); // Mark the start of this current frame
-
- // Measure the time spent in UpdateManager::Update
- PERF_MONITOR_START(PerformanceMonitor::UPDATE);
-
const BufferIndex bufferIndex = mSceneGraphBuffers.GetUpdateBufferIndex();
// 1) Clear nodes/resources which were previously discarded
UpdateNodes( bufferIndex );
UpdateRenderers( bufferIndex );
-
- PERF_MONITOR_START(PerformanceMonitor::PROCESS_RENDER_TASKS);
-
- // 12) Process the RenderTasks; this creates the instructions for rendering the next frame.
+ // 13) Process the RenderTasks; this creates the instructions for rendering the next frame.
// reset the update buffer index and make sure there is enough room in the instruction container
mImpl->renderInstructions.ResetAndReserve( bufferIndex,
mImpl->taskList.GetTasks().Count() + mImpl->systemLevelTaskList.GetTasks().Count() );
mImpl->notificationManager.QueueCompleteNotification( mImpl->taskList.GetCompleteNotificationInterface() );
}
- PERF_MONITOR_END(PerformanceMonitor::PROCESS_RENDER_TASKS);
-
// Macro is undefined in release build.
SNAPSHOT_NODE_LOGGING;
// Check whether further updates are required
unsigned int keepUpdating = KeepUpdatingCheck( elapsedSeconds );
-#ifdef PERFORMANCE_MONITOR_ENABLED
- // Always keep rendering when measuring FPS
- keepUpdating |= KeepUpdating::MONITORING_PERFORMANCE;
-#endif
-
// tell the update manager that we're done so the queue can be given to event thread
mImpl->notificationManager.UpdateCompleted();
// The update has finished; swap the double-buffering indices
mSceneGraphBuffers.Swap();
- PERF_MONITOR_END(PerformanceMonitor::UPDATE);
-
return keepUpdating;
}
mIsRoot( false ),
mInheritOrientation( true ),
mInheritScale( true ),
- mInhibitLocalTransform( false ),
mIsActive( true ),
mDrawMode( DrawMode::NORMAL ),
mPositionInheritanceMode( DEFAULT_POSITION_INHERITANCE_MODE ),
#define __DALI_INTERNAL_SCENE_GRAPH_NODE_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * 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.
return false;
}
- /**
- * Set the inhibit local transform flag.@n
- * Setting this flag will stop the node's local transform (position, scale and orientation)
- * being applied on top of its parents transformation.
- * @param[in] flag When true, local transformation is inhibited when calculating the world matrix.
- */
- void SetInhibitLocalTransform( bool flag )
- {
- SetDirtyFlag( TransformFlag );
- mInhibitLocalTransform = flag;
- }
-
- /**
- * Get the inhibit local transform flag.@n
- * See @ref SetInhibitLocalTransform
- * @result A flag, when true, local transformation is inhibited when calculating the world matrix.
- */
- bool GetInhibitLocalTransform() const
- {
- return mInhibitLocalTransform;
- }
-
unsigned short GetDepth() const
{
return mDepth;
bool mIsRoot:1; ///< True if the node cannot have a parent
bool mInheritOrientation:1; ///< Whether the parent's orientation should be inherited.
bool mInheritScale:1; ///< Whether the parent's scale should be inherited.
- bool mInhibitLocalTransform:1; ///< whether local transform should be applied.
bool mIsActive:1; ///< When a Node is marked "active" it has been disconnected, and its properties have not been modified
DrawMode::Type mDrawMode:2; ///< How the Node and its children should be drawn