• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_HDI_DISPLAY_V1_0_DEVICE_CACHE_MANAGER_H
17 #define OHOS_HDI_DISPLAY_V1_0_DEVICE_CACHE_MANAGER_H
18 
19 #include <mutex>
20 #include <memory>
21 #include <unordered_map>
22 #include "cache_manager.h"
23 #include "device_cache.h"
24 #include "nocopyable.h"
25 
26 namespace OHOS {
27 namespace HDI {
28 namespace Display {
29 namespace Composer {
30 
31 class DeviceCacheManager : public NoCopyable {
32 public:
33     DeviceCacheManager();
34     ~DeviceCacheManager();
35     static std::shared_ptr<DeviceCacheManager> GetInstance();
36     int32_t AddDeviceCache(uint32_t deviceId);
37     int32_t RemoveDeviceCache(uint32_t deviceId);
38     int32_t CreateVirtualDisplayCache(uint32_t deviceId);
39     int32_t DestroyVirtualDisplayCache(uint32_t deviceId);
40     int32_t DestroyCaches();
SetNeedMap(bool needMap)41     void SetNeedMap(bool needMap)
42     {
43         LayerCache::needMap_ = needMap;
44     }
45     DeviceCache* DeviceCacheInstance(uint32_t deviceId) const;
46     LayerCache* LayerCacheInstance(uint32_t deviceId, uint32_t layerId) const;
47     void Dump() const;
48     static std::mutex& GetCacheMgrMutex();
49 private:
50     int32_t Init();
51     int32_t AddCacheInternal(uint32_t deviceId, DeviceCache::DeviceType type);
52     std::unique_ptr<CacheManager<uint32_t, DeviceCache>> deviceCaches_;
53 };
54 } // namespace Composer
55 } // namespace Display
56 } // namespace HDI
57 } // namespace OHOS
58 #endif // OHOS_HDI_DISPLAY_V1_0_DEVICE_CACHE_MANAGER_H
59