X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fmesh%2Fmesh-visual.cpp;h=7fbb28e8198c19a068df170f0efbc91915abae19;hb=3ad20543558830da2b46ec83e3be4f8daf77add0;hp=051dfa3a8211f190801129bc7d74929b90f9eed7;hpb=cb30ef68af0383b073ba2d425d3d95c1e916cbb4;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/mesh/mesh-visual.cpp b/dali-toolkit/internal/visuals/mesh/mesh-visual.cpp index 051dfa3..7fbb28e 100644 --- a/dali-toolkit/internal/visuals/mesh/mesh-visual.cpp +++ b/dali-toolkit/internal/visuals/mesh/mesh-visual.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -21,14 +21,13 @@ // EXTERNAL INCLUDES #include #include -#include +#include #include #include #include -#include //INTERNAL INCLUDES -#include +#include #include #include @@ -46,12 +45,12 @@ namespace Texture LoadTexture( const char* imageUrl, bool generateMipmaps ) { Texture texture; - Dali::BitmapLoader loader = Dali::BitmapLoader::New( imageUrl ); - loader.Load(); - PixelData pixelData = loader.GetPixelData(); - if( pixelData ) + + Devel::PixelBuffer pixelBuffer = LoadImageFromFile( imageUrl ); + if( pixelBuffer ) { - texture = Texture::New( TextureType::TEXTURE_2D, pixelData.GetPixelFormat(), pixelData.GetWidth(), pixelData.GetHeight() ); + texture = Texture::New( TextureType::TEXTURE_2D, pixelBuffer.GetPixelFormat(), pixelBuffer.GetWidth(), pixelBuffer.GetHeight() ); + PixelData pixelData = Devel::PixelBuffer::Convert( pixelBuffer ); texture.Upload( pixelData ); if( generateMipmaps ) @@ -83,14 +82,6 @@ enum TextureIndex GLOSS_INDEX = 2u }; -//Property names -const char * const OBJECT_URL_NAME( "objectUrl" ); -const char * const MATERIAL_URL_NAME( "materialUrl" ); -const char * const TEXTURES_PATH_NAME( "texturesPath" ); -const char * const SHADING_MODE_NAME( "shadingMode" ); -const char * const USE_MIPMAPPING_NAME( "useMipmapping" ); -const char * const USE_SOFT_NORMALS_NAME( "useSoftNormals" ); -const char * const LIGHT_POSITION_NAME( "lightPosition" ); //Shading mode DALI_ENUM_TO_STRING_TABLE_BEGIN( SHADING_MODE ) @@ -165,16 +156,11 @@ const char* SIMPLE_FRAGMENT_SHADER = DALI_COMPOSE_SHADER( varying mediump vec3 vIllumination;\n uniform lowp vec4 uColor;\n uniform lowp vec3 mixColor;\n - uniform lowp float opacity;\n uniform lowp float preMultipliedAlpha;\n - lowp vec4 visualMixColor()\n - {\n - return vec4( mixColor * mix( 1.0, opacity, preMultipliedAlpha ), opacity );\n - }\n void main()\n {\n - gl_FragColor = vec4( vIllumination.rgb * uColor.rgb, uColor.a ) * visualMixColor();\n + gl_FragColor = vec4( vIllumination.rgb * uColor.rgb, uColor.a ) * vec4( mixColor, 1.0 );\n }\n ); @@ -249,17 +235,12 @@ const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER( uniform sampler2D sDiffuse;\n uniform lowp vec4 uColor;\n uniform lowp vec3 mixColor;\n - uniform lowp float opacity;\n uniform lowp float preMultipliedAlpha;\n - lowp vec4 visualMixColor()\n - {\n - return vec4( mixColor * mix( 1.0, opacity, preMultipliedAlpha ), opacity );\n - }\n void main()\n {\n vec4 texture = texture2D( sDiffuse, vTexCoord );\n - vec4 visualMixColor = visualMixColor();\n + vec4 visualMixColor = vec4( mixColor, 1.0 );\n gl_FragColor = vec4( vIllumination.rgb * texture.rgb * uColor.rgb * visualMixColor.rgb + vSpecular * 0.3, texture.a * uColor.a * visualMixColor.a );\n }\n ); @@ -342,19 +323,14 @@ const char* NORMAL_MAP_FRAGMENT_SHADER = DALI_COMPOSE_SHADER( uniform sampler2D sGloss;\n uniform lowp vec4 uColor;\n uniform lowp vec3 mixColor;\n - uniform lowp float opacity;\n uniform lowp float preMultipliedAlpha;\n - lowp vec4 visualMixColor()\n - {\n - return vec4( mixColor * mix( 1.0, opacity, preMultipliedAlpha ), opacity );\n - }\n void main()\n {\n vec4 texture = texture2D( sDiffuse, vTexCoord );\n vec3 normal = normalize( texture2D( sNormal, vTexCoord ).xyz * 2.0 - 1.0 );\n vec4 glossMap = texture2D( sGloss, vTexCoord );\n - vec4 visualMixColor = visualMixColor();\n + vec4 visualMixColor = vec4( mixColor, 1.0 );\n float lightDiffuse = max( 0.0, dot( normal, normalize( vLightDirection ) ) );\n lightDiffuse = lightDiffuse * 0.5 + 0.5;\n @@ -375,7 +351,7 @@ MeshVisualPtr MeshVisual::New( VisualFactoryCache& factoryCache, const Property: } MeshVisual::MeshVisual( VisualFactoryCache& factoryCache ) -: Visual::Base( factoryCache ), +: Visual::Base( factoryCache, Visual::FittingMode::FIT_KEEP_ASPECT_RATIO ), mShadingMode( Toolkit::MeshVisual::ShadingMode::TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING ), mUseTexture( true ), mUseMipmapping( true ), @@ -518,12 +494,15 @@ void MeshVisual::DoSetOnStage( Actor& actor ) InitializeRenderer(); actor.AddRenderer( mImpl->mRenderer ); + + // Mesh loaded and ready to display + ResourceReady( Toolkit::Visual::ResourceStatus::READY ); } void MeshVisual::DoCreatePropertyMap( Property::Map& map ) const { map.Clear(); - map.Insert( Toolkit::DevelVisual::Property::TYPE, Toolkit::Visual::MESH ); + map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::MESH ); map.Insert( Toolkit::MeshVisual::Property::OBJECT_URL, mObjectUrl ); map.Insert( Toolkit::MeshVisual::Property::MATERIAL_URL, mMaterialUrl ); map.Insert( Toolkit::MeshVisual::Property::TEXTURES_PATH, mTexturesPath ); @@ -533,6 +512,11 @@ void MeshVisual::DoCreatePropertyMap( Property::Map& map ) const map.Insert( Toolkit::MeshVisual::Property::LIGHT_POSITION, mLightPosition ); } +void MeshVisual::DoCreateInstancePropertyMap( Property::Map& map ) const +{ + // Do nothing +} + void MeshVisual::InitializeRenderer() { //Try to load the geometry from the file.