summaryrefslogtreecommitdiffhomepage
path: root/dev/Modules/FB/WS.h
blob: f16cabb4833be9a4daac286df8b2c2f6a36899d8 (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
56
57
58
59
60
61
62
63
64
65
/* -------------------------------------------

	Copyright (C) 2024, ELMH Group, all rights reserved.

------------------------------------------- */

#pragma once

#include <ArchKit/ArchKit.h>
#include <NewKit/Utils.h>

/// @file WS.h
/// @brief WindowServer's window ownership implementation.
/// It is used to draw within a window.

#define rtl_allocate_backbuffer(width, height) new WS::WSBackBufferKind[width * height]
#define rtl_compute_fb_geometry(width, height) (width * height)

namespace WS
{
	using namespace Kernel;

	class WSWindowTexture;
	class WSWindowContainer;

	typedef UInt32* WSBackBufferKind;

	class WSWindowContainer final
	{
	public:
		WSWindowContainer()	 = default;
		~WSWindowContainer() = default;

		ZKA_COPY_DEFAULT(WSWindowContainer);

		/// @note the trick is, it could be GPU processed data, that's the cool thing.
		BOOL Fill(WSBackBufferKind contents_buf, SizeT contents_len)
		{
			if (contents_len > BackBufferLength)
				return NO;

			if (!contents_buf)
				return NO;

			if (!BackBuffer ||
				!BackBufferLength)
				return NO;

			rt_copy_memory(contents_buf, BackBuffer, contents_len);
			return YES;
		}

		BOOL Fill(WSWindowContainer* container)
		{
			if (!container)
				return NO;

			return this->Fill(container->BackBuffer, container->BackBufferLength);
		}

	public:
		WSBackBufferKind BackBuffer{nullptr};
		SizeT			 BackBufferLength{0UL};
	};
} // namespace WS