mirror of
https://github.com/LizardByte/Sunshine.git
synced 2024-11-18 02:09:49 +00:00
Fix colors of the cursor on Windows
This commit is contained in:
parent
e3ef2f1c1d
commit
1cd5572020
@ -167,10 +167,9 @@ void blend_cursor_monochrome(const cursor_t &cursor, img_t &img) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void blend_cursor_color(const cursor_t &cursor, img_t &img) {
|
void blend_cursor_color(const cursor_t &cursor, img_t &img) {
|
||||||
int height = cursor.shape_info.Height / 2;
|
int height = cursor.shape_info.Height;
|
||||||
int width = cursor.shape_info.Width;
|
int width = cursor.shape_info.Width;
|
||||||
int pitch = cursor.shape_info.Pitch;
|
int pitch = cursor.shape_info.Pitch;
|
||||||
int stride = cursor.shape_info.Pitch / width;
|
|
||||||
|
|
||||||
// img cursor.y < 0, skip parts of the cursor.img_data
|
// img cursor.y < 0, skip parts of the cursor.img_data
|
||||||
auto cursor_skip_y = std::min(0, cursor.y);
|
auto cursor_skip_y = std::min(0, cursor.y);
|
||||||
@ -184,7 +183,7 @@ void blend_cursor_color(const cursor_t &cursor, img_t &img) {
|
|||||||
|
|
||||||
height -= cursor_skip_y;
|
height -= cursor_skip_y;
|
||||||
width -= cursor_skip_x;
|
width -= cursor_skip_x;
|
||||||
auto cursor_img_data = cursor.img_data.data() + cursor_skip_y * pitch;
|
auto cursor_img_data = (int*)&cursor.img_data[cursor_skip_y * pitch];
|
||||||
|
|
||||||
int delta_height = std::min(height, std::max(0, img.height - img_skip_y));
|
int delta_height = std::min(height, std::max(0, img.height - img_skip_y));
|
||||||
int delta_width = std::min(width, std::max(0, img.width - img_skip_x));
|
int delta_width = std::min(width, std::max(0, img.width - img_skip_x));
|
||||||
@ -192,27 +191,26 @@ void blend_cursor_color(const cursor_t &cursor, img_t &img) {
|
|||||||
auto img_data = (int*)img.data;
|
auto img_data = (int*)img.data;
|
||||||
|
|
||||||
for(int i = 0; i < delta_height; ++i) {
|
for(int i = 0; i < delta_height; ++i) {
|
||||||
auto cursor_begin = &cursor_img_data[i * pitch + cursor_skip_x * stride];
|
auto cursor_begin = &cursor_img_data[i * width + cursor_skip_x];
|
||||||
auto cursor_end = &cursor_begin[delta_width * stride];
|
auto cursor_end = &cursor_begin[delta_width];
|
||||||
|
|
||||||
auto img_pixel_p = &img_data[(i + img_skip_y) * img.width + img_skip_x];
|
auto img_pixel_p = &img_data[(i + img_skip_y) * img.width + img_skip_x];
|
||||||
for(auto cursor_p = cursor_begin; cursor_p != cursor_end; cursor_p += stride) {
|
std::for_each(cursor_begin, cursor_end, [&](int cursor_pixel) {
|
||||||
auto colors_in = (uint8_t*)img_pixel_p;
|
auto colors_out = (std::uint8_t*)&cursor_pixel;
|
||||||
|
auto colors_in = (std::uint8_t*)img_pixel_p;
|
||||||
|
|
||||||
//TODO: When use of IDXGIOutput5 is implemented, support different color formats
|
//TODO: When use of IDXGIOutput5 is implemented, support different color formats
|
||||||
auto alpha = cursor_p[0];
|
auto alpha = colors_out[3];
|
||||||
if(alpha == 255) {
|
if(alpha == 255) {
|
||||||
colors_in[0] = cursor_p[3];
|
*img_pixel_p = cursor_pixel;
|
||||||
colors_in[1] = cursor_p[2];
|
|
||||||
colors_in[2] = cursor_p[1];
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
colors_in[0] = cursor_p[3] + (colors_in[0] * (255 - alpha) + 255/2) / 255;
|
colors_in[0] = colors_out[0] + (colors_in[0] * (255 - alpha) + 255/2) / 255;
|
||||||
colors_in[1] = cursor_p[2] + (colors_in[1] * (255 - alpha) + 255/2) / 255;
|
colors_in[1] = colors_out[1] + (colors_in[1] * (255 - alpha) + 255/2) / 255;
|
||||||
colors_in[2] = cursor_p[1] + (colors_in[2] * (255 - alpha) + 255/2) / 255;
|
colors_in[2] = colors_out[2] + (colors_in[2] * (255 - alpha) + 255/2) / 255;
|
||||||
}
|
}
|
||||||
++img_pixel_p;
|
++img_pixel_p;
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,12 +220,6 @@ void capture_display(packet_queue_t packets, idr_event_t idr_events, config_t co
|
|||||||
}
|
}
|
||||||
|
|
||||||
images->raise(std::move(img));
|
images->raise(std::move(img));
|
||||||
|
|
||||||
auto t = std::chrono::steady_clock::now();
|
|
||||||
if(t > next_snapshot) {
|
|
||||||
BOOST_LOG(warning) << "Taking snapshot took "sv << std::chrono::floor<std::chrono::milliseconds>(t - next_snapshot).count() << " milliseconds too long"sv;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::this_thread::sleep_until(next_snapshot);
|
std::this_thread::sleep_until(next_snapshot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user