CPU Alpha Masking for Animated Image Visual
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / animated-image / image-cache.cpp
1 /*
2  * Copyright (c) 2021 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 #include "image-cache.h"
18
19 namespace Dali
20 {
21 namespace Toolkit
22 {
23 namespace Internal
24 {
25 ImageCache::ImageCache(TextureManager&                     textureManager,
26                        TextureManager::MaskingDataPointer& maskingData,
27                        ImageCache::FrameReadyObserver&     observer,
28                        uint32_t                            batchSize,
29                        uint32_t                            interval)
30 : mTextureManager(textureManager),
31   mObserver(observer),
32   mMaskingData(maskingData),
33   mBatchSize(batchSize),
34   mInterval(interval),
35   mLoadState(TextureManager::LoadState::NOT_STARTED),
36   mRequestingLoad(false),
37   mTextureManagerAlive(true)
38 {
39   mTextureManager.AddObserver(*this);
40 }
41
42 ImageCache::~ImageCache()
43 {
44   if(mTextureManagerAlive)
45   {
46     mTextureManager.RemoveObserver(*this);
47   }
48 }
49
50 void ImageCache::TextureManagerDestroyed()
51 {
52   mTextureManagerAlive = false;
53 }
54
55 void ImageCache::SetInterval(uint32_t interval)
56 {
57   mInterval = interval;
58 }
59
60 } //namespace Internal
61 } //namespace Toolkit
62 } //namespace Dali