1 /* 2 * Copyright (c) 2024 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 DRAWING_NATIVE_PIXEL_MAP_MANAGER_H 17 #define DRAWING_NATIVE_PIXEL_MAP_MANAGER_H 18 #include <mutex> 19 #include <unordered_map> 20 21 enum class NativePixelMapType : uint8_t { 22 OBJECT_UNKNOWN, 23 OBJECT_FROM_JS, 24 OBJECT_FROM_C 25 }; 26 27 class NativePixelMapManager { 28 public: 29 static NativePixelMapManager& GetInstance(); 30 ~NativePixelMapManager() = default; 31 32 void Register(void* handle, NativePixelMapType type); 33 void Unregister(void* handle); 34 NativePixelMapType GetNativePixelMapType(void* handle); 35 36 NativePixelMapManager(const NativePixelMapManager&) = delete; 37 NativePixelMapManager(const NativePixelMapManager&&) = delete; 38 NativePixelMapManager& operator=(const NativePixelMapManager&) = delete; 39 NativePixelMapManager& operator=(const NativePixelMapManager&&) = delete; 40 private: 41 NativePixelMapManager() = default; 42 std::unordered_map<void*, NativePixelMapType> mapper_; 43 std::mutex mutex_; 44 }; 45 #endif // DRAWING_NATIVE_PIXEL_MAP_MANAGER_H