drivers/gpu/drm/tests/drm_rect_test.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/tests/drm_rect_test.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/tests/drm_rect_test.c
Extension
.c
Size
18591 bytes
Lines
565
Domain
Driver Families
Bucket
drivers/gpu
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct drm_rect_intersect_case {
	const char *description;
	struct drm_rect r1, r2;
	bool should_be_visible;
	struct drm_rect expected_intersection;
};

static const struct drm_rect_intersect_case drm_rect_intersect_cases[] = {
	{
		.description = "top-left x bottom-right",
		.r1 = DRM_RECT_INIT(1, 1, 2, 2),
		.r2 = DRM_RECT_INIT(0, 0, 2, 2),
		.should_be_visible = true,
		.expected_intersection = DRM_RECT_INIT(1, 1, 1, 1),
	},
	{
		.description = "top-right x bottom-left",
		.r1 = DRM_RECT_INIT(0, 0, 2, 2),
		.r2 = DRM_RECT_INIT(1, -1, 2, 2),
		.should_be_visible = true,
		.expected_intersection = DRM_RECT_INIT(1, 0, 1, 1),
	},
	{
		.description = "bottom-left x top-right",
		.r1 = DRM_RECT_INIT(1, -1, 2, 2),
		.r2 = DRM_RECT_INIT(0, 0, 2, 2),
		.should_be_visible = true,
		.expected_intersection = DRM_RECT_INIT(1, 0, 1, 1),
	},
	{
		.description = "bottom-right x top-left",
		.r1 = DRM_RECT_INIT(0, 0, 2, 2),
		.r2 = DRM_RECT_INIT(1, 1, 2, 2),
		.should_be_visible = true,
		.expected_intersection = DRM_RECT_INIT(1, 1, 1, 1),
	},
	{
		.description = "right x left",
		.r1 = DRM_RECT_INIT(0, 0, 2, 1),
		.r2 = DRM_RECT_INIT(1, 0, 3, 1),
		.should_be_visible = true,
		.expected_intersection = DRM_RECT_INIT(1, 0, 1, 1),
	},
	{
		.description = "left x right",
		.r1 = DRM_RECT_INIT(1, 0, 3, 1),
		.r2 = DRM_RECT_INIT(0, 0, 2, 1),
		.should_be_visible = true,
		.expected_intersection = DRM_RECT_INIT(1, 0, 1, 1),
	},
	{
		.description = "up x bottom",
		.r1 = DRM_RECT_INIT(0, 0, 1, 2),
		.r2 = DRM_RECT_INIT(0, -1, 1, 3),
		.should_be_visible = true,
		.expected_intersection = DRM_RECT_INIT(0, 0, 1, 2),
	},
	{
		.description = "bottom x up",
		.r1 = DRM_RECT_INIT(0, -1, 1, 3),
		.r2 = DRM_RECT_INIT(0, 0, 1, 2),
		.should_be_visible = true,
		.expected_intersection = DRM_RECT_INIT(0, 0, 1, 2),
	},
	{
		.description = "touching corner",
		.r1 = DRM_RECT_INIT(0, 0, 1, 1),
		.r2 = DRM_RECT_INIT(1, 1, 2, 2),
		.should_be_visible = false,
		.expected_intersection = DRM_RECT_INIT(1, 1, 0, 0),
	},
	{
		.description = "touching side",
		.r1 = DRM_RECT_INIT(0, 0, 1, 1),
		.r2 = DRM_RECT_INIT(1, 0, 1, 1),
		.should_be_visible = false,
		.expected_intersection = DRM_RECT_INIT(1, 0, 0, 1),
	},
	{
		.description = "equal rects",
		.r1 = DRM_RECT_INIT(0, 0, 2, 2),
		.r2 = DRM_RECT_INIT(0, 0, 2, 2),
		.should_be_visible = true,
		.expected_intersection = DRM_RECT_INIT(0, 0, 2, 2),
	},
	{
		.description = "inside another",
		.r1 = DRM_RECT_INIT(0, 0, 2, 2),
		.r2 = DRM_RECT_INIT(1, 1, 1, 1),
		.should_be_visible = true,

Annotation

Implementation Notes