From 98bd2aa2c228110a58c9730ccabbc8f5d734376a Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 22 Jun 2023 13:46:50 +0200 Subject: [PATCH] clutter: Move cairo pixel format to cogl As Cogl already defines a pixel format enum, it makes sense to move such endian dependant pixel format there Part-of: --- clutter/clutter/clutter-cairo.h | 50 ------------------- clutter/clutter/clutter-canvas.c | 3 +- clutter/clutter/clutter-stage.c | 3 +- clutter/clutter/clutter.h | 1 - clutter/clutter/meson.build | 1 - cogl/cogl/cogl-pixel-format.h | 11 ++++ .../meta-screen-cast-area-stream-src.c | 2 +- .../meta-screen-cast-monitor-stream-src.c | 2 +- .../meta-screen-cast-virtual-stream-src.c | 2 +- .../x11/cm/meta-cursor-sprite-xfixes.c | 2 +- src/compositor/meta-shaped-texture.c | 2 +- src/compositor/meta-window-actor.c | 2 +- src/tests/meta-ref-test.c | 2 +- 13 files changed, 20 insertions(+), 63 deletions(-) delete mode 100644 clutter/clutter/clutter-cairo.h diff --git a/clutter/clutter/clutter-cairo.h b/clutter/clutter/clutter-cairo.h deleted file mode 100644 index d24ad0e78..000000000 --- a/clutter/clutter/clutter-cairo.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Clutter. - * - * An OpenGL based 'interactive canvas' library. - * - * Copyright (C) 2012 Intel Corporation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#pragma once - -#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) -#error "Only can be included directly." -#endif - -#include "clutter/clutter-types.h" - -G_BEGIN_DECLS - -/** - * CLUTTER_CAIRO_FORMAT_ARGB32: - * - * The #CoglPixelFormat to be used when uploading image data from - * and to a Cairo image surface using %CAIRO_FORMAT_ARGB32 and - * %CAIRO_FORMAT_RGB24 as #cairo_format_t. - */ - -/* Cairo stores the data in native byte order as ARGB but Cogl's pixel - * formats specify the actual byte order. Therefore we need to use a - * different format depending on the architecture - */ -#if G_BYTE_ORDER == G_LITTLE_ENDIAN -#define CLUTTER_CAIRO_FORMAT_ARGB32 (COGL_PIXEL_FORMAT_BGRA_8888_PRE) -#else -#define CLUTTER_CAIRO_FORMAT_ARGB32 (COGL_PIXEL_FORMAT_ARGB_8888_PRE) -#endif - -G_END_DECLS diff --git a/clutter/clutter/clutter-canvas.c b/clutter/clutter/clutter-canvas.c index c1125ec7f..736bcd033 100644 --- a/clutter/clutter/clutter-canvas.c +++ b/clutter/clutter/clutter-canvas.c @@ -48,7 +48,6 @@ #include "clutter/clutter-canvas.h" #include "clutter/clutter-actor-private.h" #include "clutter/clutter-backend.h" -#include "clutter/clutter-cairo.h" #include "clutter/clutter-color.h" #include "clutter/clutter-content-private.h" #include "clutter/clutter-debug.h" @@ -369,7 +368,7 @@ clutter_canvas_emit_draw (ClutterCanvas *self) priv->buffer = cogl_bitmap_new_with_size (ctx, real_width, real_height, - CLUTTER_CAIRO_FORMAT_ARGB32); + COGL_PIXEL_FORMAT_CAIRO_ARGB32_COMPAT); } buffer = COGL_BUFFER (cogl_bitmap_get_buffer (priv->buffer)); diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c index 55bb81c2b..d1fe2ce24 100644 --- a/clutter/clutter/clutter-stage.c +++ b/clutter/clutter/clutter-stage.c @@ -48,7 +48,6 @@ #include "clutter/clutter-action-private.h" #include "clutter/clutter-actor-private.h" #include "clutter/clutter-backend-private.h" -#include "clutter/clutter-cairo.h" #include "clutter/clutter-container.h" #include "clutter/clutter-debug.h" #include "clutter/clutter-enum-types.h" @@ -2932,7 +2931,7 @@ clutter_stage_capture_view_into (ClutterStage *stage, context = clutter_backend_get_cogl_context (backend); bitmap = cogl_bitmap_new_for_data (context, texture_width, texture_height, - CLUTTER_CAIRO_FORMAT_ARGB32, + COGL_PIXEL_FORMAT_CAIRO_ARGB32_COMPAT, stride, data); diff --git a/clutter/clutter/clutter.h b/clutter/clutter/clutter.h index 0d35cee00..7a0ce80cd 100644 --- a/clutter/clutter/clutter.h +++ b/clutter/clutter/clutter.h @@ -41,7 +41,6 @@ #include "clutter/clutter-blur-effect.h" #include "clutter/clutter-box-layout.h" #include "clutter/clutter-brightness-contrast-effect.h" -#include "clutter/clutter-cairo.h" #include "clutter/clutter-canvas.h" #include "clutter/clutter-child-meta.h" #include "clutter/clutter-click-action.h" diff --git a/clutter/clutter/meson.build b/clutter/clutter/meson.build index 837951f27..b9ba6555f 100644 --- a/clutter/clutter/meson.build +++ b/clutter/clutter/meson.build @@ -16,7 +16,6 @@ clutter_headers = [ 'clutter-blur-effect.h', 'clutter-box-layout.h', 'clutter-brightness-contrast-effect.h', - 'clutter-cairo.h', 'clutter-canvas.h', 'clutter-child-meta.h', 'clutter-click-action.h', diff --git a/cogl/cogl/cogl-pixel-format.h b/cogl/cogl/cogl-pixel-format.h index 161b8c3c1..0db184405 100644 --- a/cogl/cogl/cogl-pixel-format.h +++ b/cogl/cogl/cogl-pixel-format.h @@ -272,6 +272,17 @@ typedef enum /*< prefix=COGL_PIXEL_FORMAT >*/ COGL_PIXEL_FORMAT_DEPTH_24_STENCIL_8 = (3 | COGL_DEPTH_BIT | COGL_STENCIL_BIT) } CoglPixelFormat; +/** + * COGL_PIXEL_FORMAT_CAIRO_ARGB32_COMPAT: + * + * Architecture dependant format, similar to CAIRO_ARGB32. +*/ +#if G_BYTE_ORDER == G_LITTLE_ENDIAN +#define COGL_PIXEL_FORMAT_CAIRO_ARGB32_COMPAT COGL_PIXEL_FORMAT_BGRA_8888_PRE +#else +#define COGL_PIXEL_FORMAT_CAIRO_ARGB32_COMPAT COGL_PIXEL_FORMAT_ARGB_8888_PRE +#endif + /** * COGL_PIXEL_FORMAT_MAX_PLANES: * diff --git a/src/backends/meta-screen-cast-area-stream-src.c b/src/backends/meta-screen-cast-area-stream-src.c index 957074bb8..3f3095e5e 100644 --- a/src/backends/meta-screen-cast-area-stream-src.c +++ b/src/backends/meta-screen-cast-area-stream-src.c @@ -486,7 +486,7 @@ meta_screen_cast_area_stream_src_record_to_buffer (MetaScreenCastStreamSrc *src if (!clutter_stage_paint_to_buffer (stage, area, scale, data, stride, - CLUTTER_CAIRO_FORMAT_ARGB32, + COGL_PIXEL_FORMAT_CAIRO_ARGB32_COMPAT, paint_flags, error)) return FALSE; diff --git a/src/backends/meta-screen-cast-monitor-stream-src.c b/src/backends/meta-screen-cast-monitor-stream-src.c index 9f6eedd7c..10f65f7b8 100644 --- a/src/backends/meta-screen-cast-monitor-stream-src.c +++ b/src/backends/meta-screen-cast-monitor-stream-src.c @@ -570,7 +570,7 @@ meta_screen_cast_monitor_stream_src_record_to_buffer (MetaScreenCastStreamSrc * if (!clutter_stage_paint_to_buffer (stage, &logical_monitor->rect, scale, data, stride, - CLUTTER_CAIRO_FORMAT_ARGB32, + COGL_PIXEL_FORMAT_CAIRO_ARGB32_COMPAT, paint_flags, error)) return FALSE; diff --git a/src/backends/meta-screen-cast-virtual-stream-src.c b/src/backends/meta-screen-cast-virtual-stream-src.c index ebe9db32d..19f2ddb59 100644 --- a/src/backends/meta-screen-cast-virtual-stream-src.c +++ b/src/backends/meta-screen-cast-virtual-stream-src.c @@ -401,7 +401,7 @@ meta_screen_cast_virtual_stream_src_record_to_buffer (MetaScreenCastStreamSrc * scale, data, stride, - CLUTTER_CAIRO_FORMAT_ARGB32, + COGL_PIXEL_FORMAT_CAIRO_ARGB32_COMPAT, paint_flags, error)) return FALSE; diff --git a/src/backends/x11/cm/meta-cursor-sprite-xfixes.c b/src/backends/x11/cm/meta-cursor-sprite-xfixes.c index 45aca3009..721fb47ac 100644 --- a/src/backends/x11/cm/meta-cursor-sprite-xfixes.c +++ b/src/backends/x11/cm/meta-cursor-sprite-xfixes.c @@ -177,7 +177,7 @@ meta_cursor_sprite_xfixes_initable_init (GInitable *initable, texture = cogl_texture_2d_new_from_data (cogl_context, cursor_image->width, cursor_image->height, - CLUTTER_CAIRO_FORMAT_ARGB32, + COGL_PIXEL_FORMAT_CAIRO_ARGB32_COMPAT, cursor_image->width * 4, /* stride */ cursor_data, error); diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c index 24bce7161..974e70b16 100644 --- a/src/compositor/meta-shaped-texture.c +++ b/src/compositor/meta-shaped-texture.c @@ -1475,7 +1475,7 @@ meta_shaped_texture_get_image (MetaShapedTexture *stex, cogl_texture_get_width (texture), cogl_texture_get_height (texture)); - cogl_texture_get_data (texture, CLUTTER_CAIRO_FORMAT_ARGB32, + cogl_texture_get_data (texture, COGL_PIXEL_FORMAT_CAIRO_ARGB32_COMPAT, cairo_image_surface_get_stride (surface), cairo_image_surface_get_data (surface)); diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c index 9074b24bb..f79a5bd06 100644 --- a/src/compositor/meta-window-actor.c +++ b/src/compositor/meta-window-actor.c @@ -1724,7 +1724,7 @@ meta_window_actor_get_image (MetaWindowActor *self, 0, 0, framebuffer_clip.width * resource_scale, framebuffer_clip.height * resource_scale, - CLUTTER_CAIRO_FORMAT_ARGB32, + COGL_PIXEL_FORMAT_CAIRO_ARGB32_COMPAT, cairo_image_surface_get_data (surface)); g_object_unref (framebuffer); diff --git a/src/tests/meta-ref-test.c b/src/tests/meta-ref-test.c index 3fc7aebe9..366a2ba4e 100644 --- a/src/tests/meta-ref-test.c +++ b/src/tests/meta-ref-test.c @@ -245,7 +245,7 @@ capture_view_into (ClutterStageView *view, context = clutter_backend_get_cogl_context (backend); bitmap = cogl_bitmap_new_for_data (context, texture_width, texture_height, - CLUTTER_CAIRO_FORMAT_ARGB32, + COGL_PIXEL_FORMAT_CAIRO_ARGB32_COMPAT, stride, buffer);