OSDN Git Service

Add Render Buffer Compression support in HWComposer.
[android-x86/external-IA-Hardware-Composer.git] / wsi / drm / drmbuffer.h
1 /*
2 // Copyright (c) 2016 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16 #ifndef WSI_DRMBUFFER_H_
17 #define WSI_DRMBUFFER_H_
18
19 #include <platformdefines.h>
20
21 #include "overlaybuffer.h"
22
23 namespace hwcomposer {
24
25 class NativeBufferHandler;
26
27 class DrmBuffer : public OverlayBuffer {
28  public:
29   DrmBuffer(DrmBuffer&& rhs) = default;
30   DrmBuffer& operator=(DrmBuffer&& other) = default;
31
32   DrmBuffer() = default;
33
34   ~DrmBuffer() override;
35
36   void InitializeFromNativeHandle(HWCNativeHandle handle,
37                                   ResourceManager* buffer_manager) override;
38
39   uint32_t GetWidth() const override {
40     return width_;
41   }
42
43   uint32_t GetHeight() const override {
44     return height_;
45   }
46
47   uint32_t GetFormat() const override {
48     return format_;
49   }
50
51   HWCLayerType GetUsage() const override {
52     return usage_;
53   }
54
55   uint32_t GetFb() const override {
56     return image_.drm_fd_;
57   }
58
59   uint32_t GetPrimeFD() const override {
60     return image_.handle_->meta_data_.prime_fds_[0];
61   }
62
63   const uint32_t* GetPitches() const override {
64     return pitches_;
65   }
66
67   const uint32_t* GetOffsets() const override {
68     return offsets_;
69   }
70
71   uint32_t GetTilingMode() const override {
72     return tiling_mode_;
73   }
74
75   const ResourceHandle& GetGpuResource(GpuDisplay egl_display,
76                                        bool external_import) override;
77
78   const ResourceHandle& GetGpuResource() override;
79
80   const MediaResourceHandle& GetMediaResource(MediaDisplay display,
81                                               uint32_t width,
82                                               uint32_t height) override;
83
84   bool CreateFrameBuffer() override;
85
86   void Dump() override;
87
88  private:
89   void Initialize(const HwcBuffer& bo);
90   uint32_t width_ = 0;
91   uint32_t height_ = 0;
92   uint32_t format_ = 0;
93   uint32_t tiling_mode_ = 0;
94   uint32_t frame_buffer_format_ = 0;
95   uint32_t pitches_[4];
96   uint32_t offsets_[4];
97   uint32_t gem_handles_[4];
98   HWCLayerType usage_ = kLayerNormal;
99   uint32_t previous_width_ = 0;   // For Media usage.
100   uint32_t previous_height_ = 0;  // For Media usage.
101   uint64_t modifier_ = 0;
102   ResourceManager* resource_manager_ = 0;
103   ResourceHandle image_;
104   MediaResourceHandle media_image_;
105 };
106
107 }  // namespace hwcomposer
108 #endif  // WSI_DRMBUFFER_H_