2 // Copyright (c) 2016 Intel Corporation
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef WSI_DRMBUFFER_H_
17 #define WSI_DRMBUFFER_H_
19 #include <platformdefines.h>
21 #include "overlaybuffer.h"
23 namespace hwcomposer {
25 class NativeBufferHandler;
27 class DrmBuffer : public OverlayBuffer {
29 DrmBuffer(DrmBuffer&& rhs) = default;
30 DrmBuffer& operator=(DrmBuffer&& other) = default;
32 DrmBuffer() = default;
34 ~DrmBuffer() override;
36 void InitializeFromNativeHandle(HWCNativeHandle handle,
37 ResourceManager* buffer_manager) override;
39 uint32_t GetWidth() const override {
43 uint32_t GetHeight() const override {
47 uint32_t GetFormat() const override {
51 HWCLayerType GetUsage() const override {
55 uint32_t GetFb() const override {
56 return image_.drm_fd_;
59 uint32_t GetPrimeFD() const override {
60 return image_.handle_->meta_data_.prime_fds_[0];
63 const uint32_t* GetPitches() const override {
67 const uint32_t* GetOffsets() const override {
71 uint32_t GetTilingMode() const override {
75 const ResourceHandle& GetGpuResource(GpuDisplay egl_display,
76 bool external_import) override;
78 const ResourceHandle& GetGpuResource() override;
80 const MediaResourceHandle& GetMediaResource(MediaDisplay display,
82 uint32_t height) override;
84 bool CreateFrameBuffer() override;
89 void Initialize(const HwcBuffer& bo);
93 uint32_t tiling_mode_ = 0;
94 uint32_t frame_buffer_format_ = 0;
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_;
107 } // namespace hwcomposer
108 #endif // WSI_DRMBUFFER_H_