Squashed backup commit (no shallow-clone history issues) of xiaomi-mt6833-dev/kernel_xiaomi_mt6833 (lineage-23.2 branch, upstream commit 9eece662e) plus all fixes applied to get everpal_defconfig building clean against a modern (GCC 15.2.0) toolchain -- see the previous commit message on the lineage-23.2 branch (also in this repo history is not available here since this is a squashed snapshot; full incremental history lives in the local DL380 checkout and the upstream GitHub remote). Upstream: https://github.com/xiaomi-mt6833-dev/kernel_xiaomi_mt6833 (lineage-23.2)
72 lines
2.0 KiB
C
72 lines
2.0 KiB
C
/*
|
|
* Copyright (C) 2016 MediaTek Inc.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
* See http://www.gnu.org/licenses/gpl-2.0.html for more details.
|
|
*/
|
|
|
|
#include "mtk_rect.h"
|
|
#include "mtk_log.h"
|
|
|
|
void mtk_rect_make(struct mtk_rect *in, int left, int top, int width,
|
|
int height)
|
|
{
|
|
in->x = left;
|
|
in->y = top;
|
|
in->width = width;
|
|
in->height = height;
|
|
}
|
|
|
|
void mtk_rect_set(struct mtk_rect *in, int left, int top, int right, int bottom)
|
|
{
|
|
in->x = left;
|
|
in->y = top;
|
|
in->width = right - left + 1;
|
|
in->height = bottom - top + 1;
|
|
}
|
|
|
|
void mtk_rect_join(const struct mtk_rect *in1, const struct mtk_rect *in2,
|
|
struct mtk_rect *out)
|
|
{
|
|
int left = in1->x;
|
|
int top = in1->y;
|
|
int right = in1->x + in1->width - 1;
|
|
int bottom = in1->y + in1->height - 1;
|
|
int fLeft = in2->x;
|
|
int fTop = in2->y;
|
|
int fRight = in2->x + in2->width - 1;
|
|
int fBottom = in2->y + in2->height - 1;
|
|
|
|
int in2_x = in2->x;
|
|
int in2_y = in2->y;
|
|
int in2_w = in2->width;
|
|
int in2_h = in2->height;
|
|
|
|
/* do nothing if the params are empty */
|
|
if (left > right || top > bottom) {
|
|
mtk_rect_set(out, fLeft, fTop, fRight, fBottom);
|
|
} else if (fLeft > fRight || fTop > fBottom) {
|
|
/* if we are empty, just assign */
|
|
mtk_rect_set(out, left, top, right, bottom);
|
|
} else {
|
|
if (left < fLeft)
|
|
fLeft = left;
|
|
if (top < fTop)
|
|
fTop = top;
|
|
if (right > fRight)
|
|
fRight = right;
|
|
if (bottom > fBottom)
|
|
fBottom = bottom;
|
|
mtk_rect_set(out, fLeft, fTop, fRight, fBottom);
|
|
}
|
|
DDPDBG("%s (%d,%d,%d,%d) & (%d,%d,%d,%d) to (%d,%d,%d,%d)\n", __func__,
|
|
in1->x, in1->y, in1->width, in1->height, in2_x, in2_y, in2_w,
|
|
in2_h, in2->x, in2->y, in2->width, in2->height);
|
|
}
|