• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 PIXEL_MAP_MANAGER_H
17 #define PIXEL_MAP_MANAGER_H
18 
19 #include "pixel_map.h"
20 
21 namespace OHOS {
22 namespace Media {
23 class PixelMapManager {
24 public:
PixelMapManager(PixelMap * pixelMap)25     explicit PixelMapManager(PixelMap *pixelMap) : pixelMap_(pixelMap)
26     {}
27 
FreePixels()28     void FreePixels()
29     {
30         pixelMap_.clear();
31     }
32 
Invalid()33     bool Invalid()
34     {
35         return pixelMap_ == nullptr;
36     }
37 
GetPixelMap()38     PixelMap &GetPixelMap()
39     {
40         return *pixelMap_;
41     }
42 
GetByteCount()43     int32_t GetByteCount()
44     {
45         return pixelMap_->GetByteCount();
46     }
47 
Ref()48     void Ref()
49     {
50         pixelMap_->IncStrongRef(nullptr);
51     }
52 
UnRef()53     void UnRef()
54     {
55         pixelMap_->DecStrongRef(nullptr);
56     }
57 
~PixelMapManager()58     ~PixelMapManager()
59     {}
60 
61 private:
62     ::OHOS::sptr<PixelMap> pixelMap_ = nullptr;
63 };
64 } // namespace Media
65 } // namespace OHOS
66 #endif // PIXEL_MAP_MANAGER_H
67