X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fnpatch-data.cpp;h=cb144b83c95ab5d3a1444cb4b9d56c9d590a50b6;hb=HEAD;hp=e8a60424b64aa5bb6f7fd2994ca96ba7f761c4bd;hpb=57f2c014e61cff22236c0459757c41134fc7785f;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/npatch-data.cpp b/dali-toolkit/internal/visuals/npatch-data.cpp deleted file mode 100644 index e8a6042..0000000 --- a/dali-toolkit/internal/visuals/npatch-data.cpp +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Copyright (c) 2021 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. - * - */ - -// CLASS HEADER -#include - -// INTERNAL HEADERS -#include - -// EXTERNAL HEADERS -#include - -namespace Dali -{ -namespace Toolkit -{ -namespace Internal -{ -NPatchData::NPatchData() -: mId(INVALID_NPATCH_DATA_ID), - mUrl(), - mTextureSet(), - mHash(0), - mCroppedWidth(0), - mCroppedHeight(0), - mBorder(0, 0, 0, 0), - mLoadingState(LoadingState::LOADING), - mPreMultiplyOnLoad(false), - mRenderingMap{nullptr} -{ -} - -NPatchData::~NPatchData() -{ - // If there is an opacity map, it has to be destroyed using addon call - if(mRenderingMap) - { - RenderingAddOn::Get().DestroyNPatch(mRenderingMap); - } -} - -void NPatchData::SetId(const NPatchDataId id) -{ - mId = id; -} - -NPatchData::NPatchDataId NPatchData::GetId() const -{ - return mId; -} - -void NPatchData::AddObserver(TextureUploadObserver* textureObserver) -{ - mObserverList.PushBack(textureObserver); -} - -void NPatchData::RemoveObserver(TextureUploadObserver* textureObserver) -{ - for(uint32_t index = 0; index < mObserverList.Count(); ++index) - { - if(textureObserver == mObserverList[index]) - { - mObserverList.Erase(mObserverList.begin() + index); - break; - } - } -} - -uint32_t NPatchData::GetObserverCount() const -{ - return mObserverList.Count(); -} - -void NPatchData::SetUrl(const VisualUrl& url) -{ - mUrl = url; -} - -VisualUrl NPatchData::GetUrl() const -{ - return mUrl; -} - -void NPatchData::SetTextures(const TextureSet textureSet) -{ - mTextureSet = textureSet; -} - -TextureSet NPatchData::GetTextures() const -{ - return mTextureSet; -} - -void NPatchData::SetStretchPixelsX(const NPatchUtility::StretchRanges stretchPixelsX) -{ - mStretchPixelsX = stretchPixelsX; -} - -void NPatchData::SetStretchPixelsY(const NPatchUtility::StretchRanges stretchPixelsY) -{ - mStretchPixelsY = stretchPixelsY; -} - -NPatchUtility::StretchRanges NPatchData::GetStretchPixelsX() const -{ - return mStretchPixelsX; -} - -NPatchUtility::StretchRanges NPatchData::GetStretchPixelsY() const -{ - return mStretchPixelsY; -} - -void NPatchData::SetHash(std::size_t hash) -{ - mHash = hash; -} - -std::size_t NPatchData::GetHash() const -{ - return mHash; -} - -void NPatchData::SetCroppedWidth(uint32_t croppedWidth) -{ - mCroppedWidth = croppedWidth; -} - -void NPatchData::SetCroppedHeight(uint32_t croppedHeight) -{ - mCroppedHeight = croppedHeight; -} - -uint32_t NPatchData::GetCroppedWidth() const -{ - return mCroppedWidth; -} - -uint32_t NPatchData::GetCroppedHeight() const -{ - return mCroppedHeight; -} - -void NPatchData::SetBorder(const Rect border) -{ - mBorder = border; -} - -Rect NPatchData::GetBorder() const -{ - return mBorder; -} - -void NPatchData::SetPreMultiplyOnLoad(bool preMultiplyOnLoad) -{ - mPreMultiplyOnLoad = preMultiplyOnLoad; -} - -bool NPatchData::IsPreMultiplied() const -{ - return mPreMultiplyOnLoad; -} - -void NPatchData::SetLoadingState(const LoadingState loadingState) -{ - mLoadingState = loadingState; -} - -NPatchData::LoadingState NPatchData::GetLoadingState() const -{ - return mLoadingState; -} - -void* NPatchData::GetRenderingMap() const -{ - return mRenderingMap; -} - -void NPatchData::SetLoadedNPatchData(Devel::PixelBuffer& pixelBuffer, bool preMultiplied) -{ - if(mBorder == Rect(0, 0, 0, 0)) - { - NPatchUtility::ParseBorders(pixelBuffer, mStretchPixelsX, mStretchPixelsY); - - // Crop the image - pixelBuffer.Crop(1, 1, pixelBuffer.GetWidth() - 2, pixelBuffer.GetHeight() - 2); - } - else - { - mStretchPixelsX.PushBack(Uint16Pair(mBorder.left, ((pixelBuffer.GetWidth() >= static_cast(mBorder.right)) ? pixelBuffer.GetWidth() - mBorder.right : 0))); - mStretchPixelsY.PushBack(Uint16Pair(mBorder.top, ((pixelBuffer.GetHeight() >= static_cast(mBorder.bottom)) ? pixelBuffer.GetHeight() - mBorder.bottom : 0))); - } - - mCroppedWidth = pixelBuffer.GetWidth(); - mCroppedHeight = pixelBuffer.GetHeight(); - - // Create opacity map - mRenderingMap = RenderingAddOn::Get().IsValid() ? RenderingAddOn::Get().BuildNPatch(pixelBuffer, this) : nullptr; - - PixelData pixels = Devel::PixelBuffer::Convert(pixelBuffer); // takes ownership of buffer - - Texture texture = Texture::New(TextureType::TEXTURE_2D, pixels.GetPixelFormat(), pixels.GetWidth(), pixels.GetHeight()); - texture.Upload(pixels); - - mTextureSet = TextureSet::New(); - mTextureSet.SetTexture(0u, texture); - - mPreMultiplyOnLoad = preMultiplied; - - mLoadingState = LoadingState::LOAD_COMPLETE; -} - -void NPatchData::LoadComplete(bool loadSuccess, TextureInformation textureInformation) -{ - if(loadSuccess) - { - SetLoadedNPatchData(textureInformation.pixelBuffer, textureInformation.preMultiplied); - } - else - { - mLoadingState = LoadingState::LOAD_FAILED; - } - - for(uint32_t index = 0; index < mObserverList.Count(); ++index) - { - TextureUploadObserver* observer = mObserverList[index]; - observer->LoadComplete(loadSuccess, TextureUploadObserver::TextureInformation(TextureUploadObserver::ReturnType::TEXTURE, TextureManager::INVALID_TEXTURE_ID, mTextureSet, false, Vector4(), textureInformation.preMultiplied)); - } -} - -} // namespace Internal - -} // namespace Toolkit - -} // namespace Dali