X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fimage%2Fimage-visual.cpp;h=da12c4ff7b319cf90e43811fa91f2a1fa6115635;hp=ef7178682d195d13da44726b6bde300a5a48967c;hb=2bba756a645043d8c1c4023a75966401d531827c;hpb=45ad62cd772319bc585a48c868b31892881374bb diff --git a/dali-toolkit/internal/visuals/image/image-visual.cpp b/dali-toolkit/internal/visuals/image/image-visual.cpp index ef71786..da12c4f 100644 --- a/dali-toolkit/internal/visuals/image/image-visual.cpp +++ b/dali-toolkit/internal/visuals/image/image-visual.cpp @@ -180,18 +180,6 @@ ImageVisual::~ImageVisual() { if(Stage::IsInstalled()) { - if(mMaskingData) - { - // TextureManager could have been deleted before the actor that contains this - // ImageVisual is destroyed (e.g. due to stage shutdown). Ensure the stage - // is still valid before accessing texture manager. - if(mMaskingData->mAlphaMaskId != TextureManager::INVALID_TEXTURE_ID) - { - TextureManager& textureManager = mFactoryCache.GetTextureManager(); - textureManager.Remove(mMaskingData->mAlphaMaskId, this); - } - } - if(mImageUrl.IsValid()) { // Decrease reference count of External Resources : @@ -618,7 +606,7 @@ void ImageVisual::LoadTexture(bool& atlasing, Vector4& atlasRect, TextureSet& te bool synchronousLoading = IsSynchronousLoadingRequired(); bool loadingStatus; - textures = textureManager.LoadTexture(mImageUrl, mDesiredSize, mFittingMode, mSamplingMode, mMaskingData, synchronousLoading, mTextureId, atlasRect, mAtlasRectSize, atlasing, loadingStatus, mWrapModeU, mWrapModeV, textureObserver, atlasUploadObserver, atlasManager, mOrientationCorrection, forceReload, preMultiplyOnLoad); + textures = textureManager.LoadTexture(mImageUrl, mDesiredSize, mFittingMode, mSamplingMode, mMaskingData, synchronousLoading, mTextureId, atlasRect, mAtlasRectSize, atlasing, loadingStatus, textureObserver, atlasUploadObserver, atlasManager, mOrientationCorrection, forceReload, preMultiplyOnLoad); if(textures) { @@ -632,6 +620,12 @@ void ImageVisual::LoadTexture(bool& atlasing, Vector4& atlasRect, TextureSet& te } EnablePreMultipliedAlpha(preMultiplyOnLoad == TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD); + if(!atlasing) + { + Sampler sampler = Sampler::New(); + sampler.SetWrapMode(mWrapModeU, mWrapModeV); + textures.SetSampler(0u, sampler); + } } else if(synchronousLoading) { @@ -676,6 +670,12 @@ void ImageVisual::InitializeRenderer() else { mTextures = mFactoryCache.GetTextureManager().GetTextureSet(mTextureId); + if(!(mImpl->mFlags & Visual::Base::Impl::IS_ATLASING_APPLIED) && mTextures) + { + Sampler sampler = Sampler::New(); + sampler.SetWrapMode(mWrapModeU, mWrapModeV); + mTextures.SetSampler(0u, sampler); + } } } @@ -684,7 +684,19 @@ void ImageVisual::InitializeRenderer() mImpl->mRenderer.SetTextures(mTextures); ComputeTextureSize(); CheckMaskTexture(); - if(DevelTexture::IsNative(mTextures.GetTexture(0))) + + bool needToUpdateShader = DevelTexture::IsNative(mTextures.GetTexture(0)); + + if(mTextures.GetTextureCount() == 3) + { + if(mTextures.GetTexture(0).GetPixelFormat() == Pixel::L8 && mTextures.GetTexture(1).GetPixelFormat() == Pixel::CHROMINANCE_U && mTextures.GetTexture(2).GetPixelFormat() == Pixel::CHROMINANCE_V) + { + mNeedYuvToRgb = true; + needToUpdateShader = true; + } + } + + if(needToUpdateShader) { UpdateShader(); } @@ -900,12 +912,25 @@ void ImageVisual::LoadComplete(bool loadingSuccess, TextureInformation textureIn } else { - Sampler sampler = Sampler::New(); - sampler.SetWrapMode(mWrapModeU, mWrapModeV); - textureInformation.textureSet.SetSampler(0u, sampler); + if(!textureInformation.useAtlasing) + { + Sampler sampler = Sampler::New(); + sampler.SetWrapMode(mWrapModeU, mWrapModeV); + textureInformation.textureSet.SetSampler(0u, sampler); + } + mImpl->mRenderer.SetTextures(textureInformation.textureSet); ComputeTextureSize(); CheckMaskTexture(); + + if(textureInformation.textureSet.GetTextureCount() == 3) + { + if(textureInformation.textureSet.GetTexture(0).GetPixelFormat() == Pixel::L8 && textureInformation.textureSet.GetTexture(1).GetPixelFormat() == Pixel::CHROMINANCE_U && textureInformation.textureSet.GetTexture(2).GetPixelFormat() == Pixel::CHROMINANCE_V) + { + mNeedYuvToRgb = true; + UpdateShader(); + } + } } if(actor) @@ -1068,7 +1093,8 @@ Shader ImageVisual::GenerateShader() const .EnableRoundedCorner(IsRoundedCornerRequired()) .EnableBorderline(IsBorderlineRequired()) .SetTextureForFragmentShaderCheck(useNativeImage ? mTextures.GetTexture(0) : Dali::Texture()) - .EnableAlphaMaskingOnRendering(requiredAlphaMaskingOnRendering)); + .EnableAlphaMaskingOnRendering(requiredAlphaMaskingOnRendering) + .EnableYuvToRgb(mNeedYuvToRgb)); } else {