X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fnpatch%2Fnpatch-visual.cpp;h=98d6d3026d65e549ae854e6c6c3ca441f2a8d453;hp=bca8d0376eabf49ad11a01fbd6464578f20fae50;hb=145f62f674d8ae90930470756889e2346f7aa118;hpb=1d71a8f7d7abd7729aa645ad062e530958097214 diff --git a/dali-toolkit/internal/visuals/npatch/npatch-visual.cpp b/dali-toolkit/internal/visuals/npatch/npatch-visual.cpp index bca8d03..98d6d30 100644 --- a/dali-toolkit/internal/visuals/npatch/npatch-visual.cpp +++ b/dali-toolkit/internal/visuals/npatch/npatch-visual.cpp @@ -46,7 +46,7 @@ namespace Internal { namespace { -const int CUSTOM_PROPERTY_COUNT(10); // 5 transform properties + fixed(3),stretch,aux +const int CUSTOM_PROPERTY_COUNT(5); // fixed(3),stretch,aux } /////////////////NPatchVisual//////////////// @@ -236,7 +236,7 @@ void NPatchVisual::OnSetTransform() { if(mImpl->mRenderer) { - mImpl->mTransform.RegisterUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT); + mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT); } } @@ -300,11 +300,11 @@ void NPatchVisual::OnInitialize() mFactoryCache, ImageVisualShaderFeature::FeatureBuilder()); - mImpl->mRenderer = Renderer::New(geometry, shader); + mImpl->mRenderer = VisualRenderer::New(geometry, shader); mImpl->mRenderer.ReserveCustomProperties(CUSTOM_PROPERTY_COUNT); //Register transform properties - mImpl->mTransform.RegisterUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT); + mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT); } Geometry NPatchVisual::CreateGeometry() @@ -451,6 +451,32 @@ void NPatchVisual::ApplyTextureAndUniforms() { textureSet = data->GetTextures(); NPatchHelper::ApplyTextureAndUniforms(mImpl->mRenderer, data); + + if(mAuxiliaryPixelBuffer) + { + // If the auxiliary image is smaller than the un-stretched NPatch, use CPU resizing to enlarge it to the + // same size as the unstretched NPatch. This will give slightly higher quality results than just relying + // on GL interpolation alone. + if(mAuxiliaryPixelBuffer.GetWidth() < data->GetCroppedWidth() && + mAuxiliaryPixelBuffer.GetHeight() < data->GetCroppedHeight()) + { + mAuxiliaryPixelBuffer.Resize(data->GetCroppedWidth(), data->GetCroppedHeight()); + } + + // Note, this resets mAuxiliaryPixelBuffer handle + auto auxiliaryPixelData = Devel::PixelBuffer::Convert(mAuxiliaryPixelBuffer); + + auto texture = Texture::New(TextureType::TEXTURE_2D, + auxiliaryPixelData.GetPixelFormat(), + auxiliaryPixelData.GetWidth(), + auxiliaryPixelData.GetHeight()); + texture.Upload(auxiliaryPixelData); + textureSet.SetTexture(1, texture); + mImpl->mRenderer.RegisterProperty(DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA, + AUXILIARY_IMAGE_ALPHA_NAME, + mAuxiliaryImageAlpha); + } + mImpl->mRenderer.SetTextures(textureSet); } else { @@ -463,37 +489,11 @@ void NPatchVisual::ApplyTextureAndUniforms() { imageSize = actor.GetProperty(Actor::Property::SIZE).Get(); } - mFactoryCache.UpdateBrokenImageRenderer(mImpl->mRenderer, imageSize); - } - - if(mAuxiliaryPixelBuffer) - { - // If the auxiliary image is smaller than the un-stretched NPatch, use CPU resizing to enlarge it to the - // same size as the unstretched NPatch. This will give slightly higher quality results than just relying - // on GL interpolation alone. - if(mAuxiliaryPixelBuffer.GetWidth() < data->GetCroppedWidth() && - mAuxiliaryPixelBuffer.GetHeight() < data->GetCroppedHeight()) - { - mAuxiliaryPixelBuffer.Resize(data->GetCroppedWidth(), data->GetCroppedHeight()); - } - - // Note, this resets mAuxiliaryPixelBuffer handle - auto auxiliaryPixelData = Devel::PixelBuffer::Convert(mAuxiliaryPixelBuffer); - - auto texture = Texture::New(TextureType::TEXTURE_2D, - auxiliaryPixelData.GetPixelFormat(), - auxiliaryPixelData.GetWidth(), - auxiliaryPixelData.GetHeight()); - texture.Upload(auxiliaryPixelData); - textureSet.SetTexture(1, texture); - mImpl->mRenderer.RegisterProperty(DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA, - AUXILIARY_IMAGE_ALPHA_NAME, - mAuxiliaryImageAlpha); + mFactoryCache.UpdateBrokenImageRenderer(mImpl->mRenderer, imageSize, false); } - mImpl->mRenderer.SetTextures(textureSet); // Register transform properties - mImpl->mTransform.RegisterUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT); + mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT); } Geometry NPatchVisual::GetNinePatchGeometry(VisualFactoryCache::GeometryType subType)