summaryrefslogtreecommitdiffhomepage
path: root/src/kernel/GfxKit/FB.h
blob: f9b39421d3519a16e5d0b905e6226a5e26a52416 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org)
// Licensed under the Apache License, Version 2.0 (see LICENSE file)
// Official repository: https://github.com/nekernel-org/nekernel

#ifndef GFXKIT_FB_H
#define GFXKIT_FB_H

#include <KernelKit/DeviceMgr.h>

namespace Kernel {

class FBDeviceInterface;
struct FBDevicePacket;

using FBCoord2x2     = UInt32;
using FBDim2x2       = UInt32;
using FBColorProfile = UInt32;
using FBFlags        = UInt32;

/// @brief Framebuffer device interface packet.
/// @details This structure is used to send and receive data from the framebuffer device.
/// @note The structure is packed to ensure that the data is aligned correctly for the device.
struct PACKED FBDevicePacket final {
  FBCoord2x2     fX;
  FBCoord2x2     fY;
  FBDim2x2       fWidth;
  FBDim2x2       fHeight;
  FBColorProfile fColor;
  FBFlags        fFlags;
};

/// @brief Framebuffer device interface.
/// @details This class is used to send and receive data from the framebuffer device.
/// @note The class is derived from the IDevice class.
class FBDeviceInterface NE_DEVICE<FBDevicePacket*> {
 public:
  FBDeviceInterface(void (*out)(IDevice* self, FBDevicePacket* out),
                    void (*in)(IDevice* self, FBDevicePacket* in));

  virtual ~FBDeviceInterface() override;

 public:
  FBDeviceInterface& operator=(const FBDeviceInterface&) = default;
  FBDeviceInterface(const FBDeviceInterface&)            = default;

  const Char* Name() const override;

 public:
  FBDeviceInterface& operator<<(FBDevicePacket* dat) override;
  FBDeviceInterface& operator>>(FBDevicePacket* dat) override;
};

}  // namespace Kernel

#endif