renderer/native: Refactor into secondary_gpu_get_next_dumb_buffer
Extract the next buffer -logic into a new function. This allows to simplify copy_shared_framebuffer_cpu () making it more readable. This change is a pure refactoring, no functional changes. https://gitlab.gnome.org/GNOME/mutter/merge_requests/593
This commit is contained in:
parent
1b61b9cd73
commit
2145333969
@ -2126,6 +2126,18 @@ copy_shared_framebuffer_gpu (CoglOnscreen *onscreen,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static MetaDumbBuffer *
|
||||||
|
secondary_gpu_get_next_dumb_buffer (MetaOnscreenNativeSecondaryGpuState *secondary_gpu_state)
|
||||||
|
{
|
||||||
|
MetaDumbBuffer *current_dumb_fb;
|
||||||
|
|
||||||
|
current_dumb_fb = secondary_gpu_state->cpu.dumb_fb;
|
||||||
|
if (current_dumb_fb == &secondary_gpu_state->cpu.dumb_fbs[0])
|
||||||
|
return &secondary_gpu_state->cpu.dumb_fbs[1];
|
||||||
|
else
|
||||||
|
return &secondary_gpu_state->cpu.dumb_fbs[0];
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct _PixelFormatMap {
|
typedef struct _PixelFormatMap {
|
||||||
uint32_t drm_format;
|
uint32_t drm_format;
|
||||||
CoglPixelFormat cogl_format;
|
CoglPixelFormat cogl_format;
|
||||||
@ -2192,47 +2204,28 @@ copy_shared_framebuffer_cpu (CoglOnscreen *onscreen,
|
|||||||
{
|
{
|
||||||
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
|
CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
|
||||||
CoglContext *cogl_context = framebuffer->context;
|
CoglContext *cogl_context = framebuffer->context;
|
||||||
int width, height;
|
MetaDumbBuffer *dumb_fb;
|
||||||
uint8_t *target_data;
|
|
||||||
int target_stride_bytes;
|
|
||||||
uint32_t target_fb_id;
|
|
||||||
uint32_t target_drm_format;
|
|
||||||
MetaDumbBuffer *next_dumb_fb;
|
|
||||||
MetaDumbBuffer *current_dumb_fb;
|
|
||||||
CoglBitmap *dumb_bitmap;
|
CoglBitmap *dumb_bitmap;
|
||||||
CoglPixelFormat cogl_format;
|
CoglPixelFormat cogl_format;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
MetaDrmBufferDumb *buffer_dumb;
|
MetaDrmBufferDumb *buffer_dumb;
|
||||||
|
|
||||||
width = cogl_framebuffer_get_width (framebuffer);
|
dumb_fb = secondary_gpu_get_next_dumb_buffer (secondary_gpu_state);
|
||||||
height = cogl_framebuffer_get_height (framebuffer);
|
|
||||||
|
|
||||||
current_dumb_fb = secondary_gpu_state->cpu.dumb_fb;
|
g_assert (cogl_framebuffer_get_width (framebuffer) == dumb_fb->width);
|
||||||
if (current_dumb_fb == &secondary_gpu_state->cpu.dumb_fbs[0])
|
g_assert (cogl_framebuffer_get_height (framebuffer) == dumb_fb->height);
|
||||||
next_dumb_fb = &secondary_gpu_state->cpu.dumb_fbs[1];
|
|
||||||
else
|
|
||||||
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);
|
ret = cogl_pixel_format_from_drm_format (dumb_fb->drm_format,
|
||||||
g_assert (height == secondary_gpu_state->cpu.dumb_fb->height);
|
|
||||||
|
|
||||||
target_data = secondary_gpu_state->cpu.dumb_fb->map;
|
|
||||||
target_stride_bytes = secondary_gpu_state->cpu.dumb_fb->stride_bytes;
|
|
||||||
target_fb_id = secondary_gpu_state->cpu.dumb_fb->fb_id;
|
|
||||||
target_drm_format = secondary_gpu_state->cpu.dumb_fb->drm_format;
|
|
||||||
|
|
||||||
ret = cogl_pixel_format_from_drm_format (target_drm_format,
|
|
||||||
&cogl_format,
|
&cogl_format,
|
||||||
NULL);
|
NULL);
|
||||||
g_assert (ret);
|
g_assert (ret);
|
||||||
|
|
||||||
dumb_bitmap = cogl_bitmap_new_for_data (cogl_context,
|
dumb_bitmap = cogl_bitmap_new_for_data (cogl_context,
|
||||||
width,
|
dumb_fb->width,
|
||||||
height,
|
dumb_fb->height,
|
||||||
cogl_format,
|
cogl_format,
|
||||||
target_stride_bytes,
|
dumb_fb->stride_bytes,
|
||||||
target_data);
|
dumb_fb->map);
|
||||||
|
|
||||||
if (!cogl_framebuffer_read_pixels_into_bitmap (framebuffer,
|
if (!cogl_framebuffer_read_pixels_into_bitmap (framebuffer,
|
||||||
0 /* x */,
|
0 /* x */,
|
||||||
@ -2244,8 +2237,9 @@ copy_shared_framebuffer_cpu (CoglOnscreen *onscreen,
|
|||||||
cogl_object_unref (dumb_bitmap);
|
cogl_object_unref (dumb_bitmap);
|
||||||
|
|
||||||
g_clear_object (&secondary_gpu_state->gbm.next_fb);
|
g_clear_object (&secondary_gpu_state->gbm.next_fb);
|
||||||
buffer_dumb = meta_drm_buffer_dumb_new (target_fb_id);
|
buffer_dumb = meta_drm_buffer_dumb_new (dumb_fb->fb_id);
|
||||||
secondary_gpu_state->gbm.next_fb = META_DRM_BUFFER (buffer_dumb);
|
secondary_gpu_state->gbm.next_fb = META_DRM_BUFFER (buffer_dumb);
|
||||||
|
secondary_gpu_state->cpu.dumb_fb = dumb_fb;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user