2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "atlas-upload-observer.h"
22 #include <dali-toolkit/internal/image-loader/image-atlas-impl.h>
28 AtlasUploadObserver::AtlasUploadObserver()
32 AtlasUploadObserver::~AtlasUploadObserver()
34 // Notify the registerd ImageAtlas object about the destruction of observer.
35 const std::size_t size(mAtlasList.Count());
36 for(std::size_t i = 0; i < size; ++i)
40 mAtlasList[i]->ObserverDestroyed(this);
46 void AtlasUploadObserver::Register(Internal::ImageAtlas& imageAtlas)
48 // Add to the list so that the ImageAtlas could get notified in the destructor.
49 // If the same atlas is exist in the list already, we would still save the duplicated copy.
50 mAtlasList.PushBack(&imageAtlas);
53 void AtlasUploadObserver::Unregister(Internal::ImageAtlas& imageAtlas)
55 const std::size_t size(mAtlasList.Count());
56 for(std::size_t i = 0; i < size; i++)
58 if(mAtlasList[i] == &imageAtlas)
61 mAtlasList.Erase(mAtlasList.Begin() + i);
62 // If there are duplicated copies of same pointer, only the first one is removed
68 } // namespace Toolkit