X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=dali-toolkit%2Finternal%2Fvisuals%2Fnpatch%2Fnpatch-visual.cpp;h=98d6d3026d65e549ae854e6c6c3ca441f2a8d453;hb=145f62f674d8ae90930470756889e2346f7aa118;hp=c251193c7bd679b1b0acc95a67cf4f43e8c0bd62;hpb=177a529f5796ca4abe24fc5eafd7cddff423be3b;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/npatch/npatch-visual.cpp b/dali-toolkit/internal/visuals/npatch/npatch-visual.cpp index c251193..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,43 +489,11 @@ void NPatchVisual::ApplyTextureAndUniforms() { imageSize = actor.GetProperty(Actor::Property::SIZE).Get(); } - mFactoryCache.UpdateBrokenImageRenderer(mImpl->mRenderer, imageSize); - Texture croppedImage = mImpl->mRenderer.GetTextures().GetTexture(0); - textureSet.SetTexture(0u, croppedImage); - mImpl->mRenderer.RegisterProperty("uFixed[0]", Vector2::ZERO); - mImpl->mRenderer.RegisterProperty("uFixed[1]", Vector2::ZERO); - mImpl->mRenderer.RegisterProperty("uFixed[2]", Vector2::ZERO); - mImpl->mRenderer.RegisterProperty("uStretchTotal", Vector2(croppedImage.GetWidth(), croppedImage.GetHeight())); - } - - 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)