• 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 LAYER_CONTEXT_H
17 #define LAYER_CONTEXT_H
18 
19 #include <display_type.h>
20 #include <surface.h>
21 #include "hdi_layer_info.h"
22 #include "sync_fence.h"
23 
24 namespace OHOS {
25 namespace Rosen {
26 enum LayerType : uint32_t {
27     LAYER_STATUS,
28     LAYER_LAUNCHER,
29     LAYER_NAVIGATION,
30     LAYER_EXTRA
31 };
32 
33 class LayerContext : public IBufferConsumerListenerClazz {
34 public:
35     LayerContext(IRect dst, IRect src, uint32_t zorder, LayerType layerType);
36     virtual ~LayerContext();
37 
38     virtual void OnBufferAvailable() override;
39     SurfaceError DrawBufferColor();
40     SurfaceError FillHDILayer();
41     const std::shared_ptr<HdiLayerInfo> GetHdiLayer();
42 
43 private:
44     const std::vector<uint32_t> colors_ = {0xff0000ff, 0xffff00ff, 0xaa00ff00, 0xff00ffaa, 0xff0f0f00};
45     IRect dst_;
46     IRect src_;
47     uint32_t colorIndex_ = 0;
48     uint32_t frameCounter_ = 0;
49     uint32_t color_ = 0xffff1111;
50     uint32_t zorder_ = 0;
51     sptr<SyncFence> prevFence_;
52     OHOS::sptr<Surface> pSurface_;
53     OHOS::sptr<Surface> cSurface_;
54     OHOS::sptr<SurfaceBuffer> prevBuffer_;
55     std::shared_ptr<HdiLayerInfo> hdiLayer_;
56     LayerType layerType_ = LayerType::LAYER_EXTRA;
57 
58     void DrawColor(void *image, int width, int height);
59     void DrawExtraColor(void *image, uint32_t width, uint32_t height);
60     void DrawBaseColor(void *image, uint32_t width, uint32_t height);
61 };
62 } // namespace Rosen
63 } // namespace OHOS
64 
65 #endif // LAYER_CONTEXT_H