Core: Replace C math headers with C++ equivalents
- Minor restructuring to ensure `math_funcs.h` is the central point for math functions
This commit is contained in:
@ -1056,31 +1056,31 @@ Ref<Image> DisplayServerWindows::clipboard_get_image() const {
|
||||
if (dc) {
|
||||
HDC hdc = CreateCompatibleDC(dc);
|
||||
if (hdc) {
|
||||
HBITMAP hbm = CreateCompatibleBitmap(dc, info->biWidth, abs(info->biHeight));
|
||||
HBITMAP hbm = CreateCompatibleBitmap(dc, info->biWidth, std::abs(info->biHeight));
|
||||
if (hbm) {
|
||||
SelectObject(hdc, hbm);
|
||||
SetDIBitsToDevice(hdc, 0, 0, info->biWidth, abs(info->biHeight), 0, 0, 0, abs(info->biHeight), dib_bits, ptr, DIB_RGB_COLORS);
|
||||
SetDIBitsToDevice(hdc, 0, 0, info->biWidth, std::abs(info->biHeight), 0, 0, 0, std::abs(info->biHeight), dib_bits, ptr, DIB_RGB_COLORS);
|
||||
|
||||
BITMAPINFO bmp_info = {};
|
||||
bmp_info.bmiHeader.biSize = sizeof(bmp_info.bmiHeader);
|
||||
bmp_info.bmiHeader.biWidth = info->biWidth;
|
||||
bmp_info.bmiHeader.biHeight = -abs(info->biHeight);
|
||||
bmp_info.bmiHeader.biHeight = -std::abs(info->biHeight);
|
||||
bmp_info.bmiHeader.biPlanes = 1;
|
||||
bmp_info.bmiHeader.biBitCount = 32;
|
||||
bmp_info.bmiHeader.biCompression = BI_RGB;
|
||||
|
||||
Vector<uint8_t> img_data;
|
||||
img_data.resize(info->biWidth * abs(info->biHeight) * 4);
|
||||
GetDIBits(hdc, hbm, 0, abs(info->biHeight), img_data.ptrw(), &bmp_info, DIB_RGB_COLORS);
|
||||
img_data.resize(info->biWidth * std::abs(info->biHeight) * 4);
|
||||
GetDIBits(hdc, hbm, 0, std::abs(info->biHeight), img_data.ptrw(), &bmp_info, DIB_RGB_COLORS);
|
||||
|
||||
uint8_t *wr = (uint8_t *)img_data.ptrw();
|
||||
for (int i = 0; i < info->biWidth * abs(info->biHeight); i++) {
|
||||
for (int i = 0; i < info->biWidth * std::abs(info->biHeight); i++) {
|
||||
SWAP(wr[i * 4 + 0], wr[i * 4 + 2]); // Swap B and R.
|
||||
if (info->biBitCount != 32) {
|
||||
wr[i * 4 + 3] = 255; // Set A to solid if it's not in the source image.
|
||||
}
|
||||
}
|
||||
image = Image::create_from_data(info->biWidth, abs(info->biHeight), false, Image::Format::FORMAT_RGBA8, img_data);
|
||||
image = Image::create_from_data(info->biWidth, std::abs(info->biHeight), false, Image::Format::FORMAT_RGBA8, img_data);
|
||||
|
||||
DeleteObject(hbm);
|
||||
}
|
||||
@ -3003,7 +3003,7 @@ void DisplayServerWindows::cursor_set_custom_image(const Ref<Resource> &p_cursor
|
||||
|
||||
bool fully_transparent = true;
|
||||
for (UINT index = 0; index < image_size; index++) {
|
||||
int row_index = floor(index / texture_size.width);
|
||||
int row_index = std::floor(index / texture_size.width);
|
||||
int column_index = index % int(texture_size.width);
|
||||
|
||||
const Color &c = image->get_pixel(column_index, row_index);
|
||||
@ -5574,7 +5574,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
} else {
|
||||
mb->set_button_index(MouseButton::WHEEL_DOWN);
|
||||
}
|
||||
mb->set_factor(fabs((double)motion / (double)WHEEL_DELTA));
|
||||
mb->set_factor(std::fabs((double)motion / (double)WHEEL_DELTA));
|
||||
} break;
|
||||
case WM_MOUSEHWHEEL: {
|
||||
mb->set_pressed(true);
|
||||
@ -5588,7 +5588,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
} else {
|
||||
mb->set_button_index(MouseButton::WHEEL_RIGHT);
|
||||
}
|
||||
mb->set_factor(fabs((double)motion / (double)WHEEL_DELTA));
|
||||
mb->set_factor(std::fabs((double)motion / (double)WHEEL_DELTA));
|
||||
} break;
|
||||
case WM_XBUTTONDOWN: {
|
||||
mb->set_pressed(true);
|
||||
|
||||
@ -58,7 +58,7 @@ HBITMAP NativeMenuWindows::_make_bitmap(const Ref<Image> &p_img) const {
|
||||
HDC dc = GetDC(nullptr);
|
||||
HBITMAP bitmap = CreateDIBSection(dc, reinterpret_cast<BITMAPINFO *>(&bi), DIB_RGB_COLORS, reinterpret_cast<void **>(&buffer), nullptr, 0);
|
||||
for (UINT index = 0; index < image_size; index++) {
|
||||
int row_index = floor(index / texture_size.width);
|
||||
int row_index = std::floor(index / texture_size.width);
|
||||
int column_index = (index % int(texture_size.width));
|
||||
const Color &c = p_img->get_pixel(column_index, row_index);
|
||||
*(buffer + index) = c.to_argb32();
|
||||
|
||||
@ -104,7 +104,7 @@ void TTS_Windows::process_events() {
|
||||
ut.id = message.id;
|
||||
|
||||
synth->SetVolume(message.volume);
|
||||
synth->SetRate(10.f * log10(message.rate) / log10(3.f));
|
||||
synth->SetRate(10.f * std::log10(message.rate) / std::log10(3.f));
|
||||
synth->Speak((LPCWSTR)ut.string.get_data(), flags, &stream_number);
|
||||
|
||||
ids[(uint32_t)stream_number] = ut;
|
||||
|
||||
Reference in New Issue
Block a user