• 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 VIDEODISPLAYMANAGER_H
17 #define VIDEODISPLAYMANAGER_H
18 
19 #include <refbase.h>
20 #include <surface.h>
21 
22 #include "display_type.h"
23 #include "ibuffer_producer.h"
24 
25 namespace OHOS {
26 class Listener : public IBufferConsumerListener {
27 public:
Listener(sptr<Surface> impl,uint32_t id)28     Listener(sptr<Surface> impl, uint32_t id)
29     {
30         surface_ = impl;
31         layerId_ = id;
32         preBuffer = nullptr;
33         timestamp = 0;
34     }
35 
36     ~Listener();
37     void OnBufferAvailable() override;
38 
39 private:
40     wptr<Surface> surface_;
41     uint32_t layerId_;
42     int64_t timestamp;
43     Rect damage;
44     sptr<SurfaceBuffer> preBuffer;
45 };
46 
47 class VideoDisplayManager : public RefBase  {
48 public:
49     VideoDisplayManager();
50     virtual ~VideoDisplayManager();
51     static int32_t CreateLayer(const LayerInfo &layerInfo, uint32_t &layerId, sptr<Surface>& surface);
52     static void DestroyLayer(uint32_t layerId);
53     sptr<IBufferProducer> AttachLayer(sptr<Surface>& surface, uint32_t layerId);
54     void DetachLayer(uint32_t layerId);
55     int32_t SetRect(uint32_t layerId, IRect rect);
56     int32_t GetRect(uint32_t layerId, IRect &rect);
57     int32_t SetZorder(uint32_t layerId, uint32_t zorder);
58     int32_t GetZorder(uint32_t layerId, uint32_t &zorder);
59     int32_t SetTransformMode(uint32_t layerId, TransformType type);
60     int32_t SetVisable(uint32_t layerId, bool visible);
61     int32_t IsVisable(uint32_t layerId, bool &visible);
62 
63 private:
64     sptr<Surface> surface_;
65     sptr<IBufferConsumerListener> listener;
66 };
67 } // namespace OHOS
68 #endif // VIDEODISPLAYMANAGER_H
69