[mutter/wip/rstrode/rhel-8.0.0: 14/30] renderer/native: assert dumb buffer size on CPU copy



commit 19ed21b75c677c1b7398772ccb3339e97bacbe0a
Author: Pekka Paalanen <pekka paalanen collabora co uk>
Date:   Wed Sep 5 11:48:08 2018 +0300

    renderer/native: assert dumb buffer size on CPU copy
    
    Track the allocated dumb buffer size in MetaDumbBuffer. Assert that the
    size is as expected in copy_shared_framebuffer_cpu().
    
    This is just to ensure that Cogl and the real size match. The size from
    Cogl was used in the copy, so getting that wrong might have written
    beyond the allocation.
    
    This is a safety measure and has not been observed to happen yet.

 src/backends/native/meta-renderer-native.c | 7 +++++++
 1 file changed, 7 insertions(+)
---
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
index 34dfb77a6..5d6664678 100644
--- a/src/backends/native/meta-renderer-native.c
+++ b/src/backends/native/meta-renderer-native.c
@@ -123,6 +123,8 @@ typedef struct _MetaDumbBuffer
   uint32_t handle;
   void *map;
   uint64_t map_size;
+  int width;
+  int height;
 } MetaDumbBuffer;
 
 typedef struct _MetaOnscreenNativeSecondaryGpuState
@@ -1805,6 +1807,9 @@ copy_shared_framebuffer_cpu (CoglOnscreen                        *onscreen,
     next_dumb_fb = &secondary_gpu_state->cpu.dumb_fbs[0];
   secondary_gpu_state->cpu.dumb_fb = next_dumb_fb;
 
+  g_assert (width == secondary_gpu_state->cpu.dumb_fb->width);
+  g_assert (height == secondary_gpu_state->cpu.dumb_fb->height);
+
   target_data = secondary_gpu_state->cpu.dumb_fb->map;
   target_fb_id = secondary_gpu_state->cpu.dumb_fb->fb_id;
 
@@ -2303,6 +2308,8 @@ init_dumb_fb (MetaDumbBuffer  *dumb_fb,
   dumb_fb->handle = create_arg.handle;
   dumb_fb->map = map;
   dumb_fb->map_size = create_arg.size;
+  dumb_fb->width = width;
+  dumb_fb->height = height;
 
   return TRUE;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]