2 * Copyright (c) 2016 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>
30 AtlasUploadObserver::AtlasUploadObserver()
33 AtlasUploadObserver::~AtlasUploadObserver()
35 // Notify the registerd ImageAtlas object about the destruction of observer.
36 const std::size_t size( mAtlasList.Count() );
37 for( std::size_t i = 0; i < size; ++i )
41 mAtlasList[i]->ObserverDestroyed( this );
47 void AtlasUploadObserver::Register( Internal::ImageAtlas& imageAtlas )
49 // Add to the list so that the ImageAtlas could get notified in the destructor.
50 // If the same atlas is exist in the list already, we would still save the duplicated copy.
51 mAtlasList.PushBack( &imageAtlas );
54 void AtlasUploadObserver::Unregister( Internal::ImageAtlas& imageAtlas )
56 const std::size_t size( mAtlasList.Count() );
57 for( std::size_t i = 0; i < size; i++ )
59 if( mAtlasList[i] == &imageAtlas )
62 mAtlasList.Erase( mAtlasList.Begin() + i );
63 // If there are duplicated copies of same pointer, only the first one is removed