[mutter] clutter/stage: Use rounded values to create image surfaces
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] clutter/stage: Use rounded values to create image surfaces
- Date: Fri, 1 Mar 2019 18:07:36 +0000 (UTC)
commit 97a3b88f2516efcea868b05903b64797600d2315
Author: Marco Trevisan (Treviño) <mail 3v1n0 net>
Date: Sat Dec 23 00:57:03 2017 +0100
clutter/stage: Use rounded values to create image surfaces
This needs to be an integer, and since the assumptions we
have in Monitor this multiplication should always return
an integer, however in case of precision loss it could
return something very close to the next/prev integer, so
let's be sure this won't happen, by just rounding it.
https://bugzilla.gnome.org/show_bug.cgi?id=765011
https://gitlab.gnome.org/GNOME/mutter/merge_requests/3
clutter/clutter/clutter-stage.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index 67992d816..d284692c0 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -4769,6 +4769,8 @@ capture_view (ClutterStage *stage,
CoglBitmap *bitmap;
cairo_rectangle_int_t view_layout;
float view_scale;
+ float texture_width;
+ float texture_height;
framebuffer = clutter_stage_view_get_framebuffer (view);
@@ -4780,9 +4782,10 @@ capture_view (ClutterStage *stage,
}
view_scale = clutter_stage_view_get_scale (view);
+ texture_width = roundf (rect->width * view_scale);
+ texture_height = roundf (rect->height * view_scale);
image = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
- rect->width * view_scale,
- rect->height * view_scale);
+ texture_width, texture_height);
cairo_surface_set_device_scale (image, view_scale, view_scale);
data = cairo_image_surface_get_data (image);
@@ -4790,9 +4793,7 @@ capture_view (ClutterStage *stage,
backend = clutter_get_default_backend ();
context = clutter_backend_get_cogl_context (backend);
- bitmap = cogl_bitmap_new_for_data (context,
- rect->width * view_scale,
- rect->height * view_scale,
+ bitmap = cogl_bitmap_new_for_data (context, texture_width, texture_height,
CLUTTER_CAIRO_FORMAT_ARGB32,
stride,
data);
@@ -4800,8 +4801,8 @@ capture_view (ClutterStage *stage,
clutter_stage_view_get_layout (view, &view_layout);
cogl_framebuffer_read_pixels_into_bitmap (framebuffer,
- (rect->x - view_layout.x) * view_scale,
- (rect->y - view_layout.y) * view_scale,
+ roundf ((rect->x - view_layout.x) * view_scale),
+ roundf ((rect->y - view_layout.y) * view_scale),
COGL_READ_PIXELS_COLOR_BUFFER,
bitmap);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]