Merge "Added Scaling and cropping properties to the image visual mask" into devel...
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / image-loader / atlas-upload-observer.cpp
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include "atlas-upload-observer.h"
20
21 // INTERNAL INCLUDES
22 #include <dali-toolkit/internal/image-loader/image-atlas-impl.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 AtlasUploadObserver::AtlasUploadObserver()
31 {}
32
33 AtlasUploadObserver::~AtlasUploadObserver()
34 {
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 )
38   {
39     if( mAtlasList[i] )
40     {
41       mAtlasList[i]->ObserverDestroyed( this );
42     }
43   }
44   mAtlasList.Clear();
45 }
46
47 void AtlasUploadObserver::Register( Internal::ImageAtlas& imageAtlas )
48 {
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 );
52 }
53
54 void AtlasUploadObserver::Unregister( Internal::ImageAtlas& imageAtlas )
55 {
56   const std::size_t size( mAtlasList.Count() );
57   for( std::size_t i = 0; i < size; i++ )
58   {
59     if( mAtlasList[i] == &imageAtlas )
60     {
61       // Remove from list
62       mAtlasList.Erase( mAtlasList.Begin() + i );
63       // If there are duplicated copies of same pointer, only the first one is removed
64       return;
65     }
66   }
67 }
68
69 }
70
71 }