From b0219f0697f1e971c740abda767358a7c7876899 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 14 Nov 2024 10:46:16 +0100 Subject: [PATCH] cogl: Add default impls for FramebufferDriver Allowing to simplify the NopFramebufferDriver. Part-of: --- cogl/cogl/cogl-framebuffer-driver.c | 81 ++++++++++++ cogl/cogl/driver/nop/cogl-driver-nop.c | 26 +++- cogl/cogl/driver/nop/cogl-nop-framebuffer.c | 130 -------------------- cogl/cogl/driver/nop/cogl-nop-framebuffer.h | 33 ----- cogl/cogl/meson.build | 2 - 5 files changed, 106 insertions(+), 166 deletions(-) delete mode 100644 cogl/cogl/driver/nop/cogl-nop-framebuffer.c delete mode 100644 cogl/cogl/driver/nop/cogl-nop-framebuffer.h diff --git a/cogl/cogl/cogl-framebuffer-driver.c b/cogl/cogl/cogl-framebuffer-driver.c index a1f595f1c..f0c5cedec 100644 --- a/cogl/cogl/cogl-framebuffer-driver.c +++ b/cogl/cogl/cogl-framebuffer-driver.c @@ -28,6 +28,7 @@ #include "config.h" #include "cogl/cogl-framebuffer-driver.h" +#include "cogl/cogl-framebuffer-private.h" enum { @@ -199,6 +200,75 @@ cogl_framebuffer_driver_set_property (GObject *object, } } +static void +cogl_framebuffer_real_query_bits (CoglFramebufferDriver *driver, + CoglFramebufferBits *bits) +{ + memset (bits, 0, sizeof (CoglFramebufferBits)); +} + +static void +cogl_framebuffer_real_clear (CoglFramebufferDriver *driver, + unsigned long buffers, + float red, + float green, + float blue, + float alpha) +{ +} + +static void +cogl_framebuffer_real_finish (CoglFramebufferDriver *driver) +{ +} + +static void +cogl_framebuffer_real_flush (CoglFramebufferDriver *driver) +{ +} + +static void +cogl_framebuffer_real_discard_buffers (CoglFramebufferDriver *driver, + unsigned long buffers) +{ +} + +static void +cogl_framebuffer_real_draw_attributes (CoglFramebufferDriver *driver, + CoglPipeline *pipeline, + CoglVerticesMode mode, + int first_vertex, + int n_vertices, + CoglAttribute **attributes, + int n_attributes, + CoglDrawFlags flags) +{ +} + +static void +cogl_framebuffer_real_draw_indexed_attributes (CoglFramebufferDriver *driver, + CoglPipeline *pipeline, + CoglVerticesMode mode, + int first_vertex, + int n_vertices, + CoglIndices *indices, + CoglAttribute **attributes, + int n_attributes, + CoglDrawFlags flags) +{ +} + +static gboolean +cogl_framebuffer_real_read_pixels_into_bitmap (CoglFramebufferDriver *framebuffer, + int x, + int y, + CoglReadPixelsFlags source, + CoglBitmap *bitmap, + GError **error) +{ + return TRUE; +} + static void cogl_framebuffer_driver_init (CoglFramebufferDriver *driver) { @@ -219,4 +289,15 @@ cogl_framebuffer_driver_class_init (CoglFramebufferDriverClass *klass) G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); g_object_class_install_properties (object_class, N_PROPS, obj_props); + + klass->query_bits = cogl_framebuffer_real_query_bits; + klass->clear = cogl_framebuffer_real_clear; + klass->finish = cogl_framebuffer_real_finish; + klass->flush = cogl_framebuffer_real_flush; + klass->discard_buffers = cogl_framebuffer_real_discard_buffers; + klass->draw_attributes = cogl_framebuffer_real_draw_attributes; + klass->draw_indexed_attributes = + cogl_framebuffer_real_draw_indexed_attributes; + klass->read_pixels_into_bitmap = + cogl_framebuffer_real_read_pixels_into_bitmap; } diff --git a/cogl/cogl/driver/nop/cogl-driver-nop.c b/cogl/cogl/driver/nop/cogl-driver-nop.c index a87de8c7a..19f020ad5 100644 --- a/cogl/cogl/driver/nop/cogl-driver-nop.c +++ b/cogl/cogl/driver/nop/cogl-driver-nop.c @@ -37,7 +37,31 @@ #include "cogl/cogl-feature-private.h" #include "cogl/cogl-renderer-private.h" #include "cogl/driver/nop/cogl-texture-2d-nop-private.h" -#include "cogl/driver/nop/cogl-nop-framebuffer.h" + +#define COGL_TYPE_NOP_FRAMEBUFFER (cogl_nop_framebuffer_get_type ()) +G_DECLARE_FINAL_TYPE (CoglNopFramebuffer, cogl_nop_framebuffer, + COGL, NOP_FRAMEBUFFER_DRIVER, + CoglFramebufferDriver) + + +struct _CoglNopFramebuffer +{ + CoglFramebufferDriver parent; +}; + +G_DEFINE_FINAL_TYPE (CoglNopFramebuffer, cogl_nop_framebuffer, + COGL_TYPE_FRAMEBUFFER_DRIVER) + + +static void +cogl_nop_framebuffer_init (CoglNopFramebuffer *nop_framebuffer) +{ +} + +static void +cogl_nop_framebuffer_class_init (CoglNopFramebufferClass *klass) +{ +} static gboolean _cogl_driver_update_features (CoglContext *ctx, diff --git a/cogl/cogl/driver/nop/cogl-nop-framebuffer.c b/cogl/cogl/driver/nop/cogl-nop-framebuffer.c deleted file mode 100644 index 6a2833e55..000000000 --- a/cogl/cogl/driver/nop/cogl-nop-framebuffer.c +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2020 Red Hat - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#include "config.h" - -#include "cogl/driver/nop/cogl-nop-framebuffer.h" - -#include "cogl/cogl-framebuffer-private.h" - -struct _CoglNopFramebuffer -{ - CoglFramebufferDriver parent; -}; - -G_DEFINE_FINAL_TYPE (CoglNopFramebuffer, cogl_nop_framebuffer, - COGL_TYPE_FRAMEBUFFER_DRIVER) - -static void -cogl_nop_framebuffer_query_bits (CoglFramebufferDriver *driver, - CoglFramebufferBits *bits) -{ - memset (bits, 0, sizeof (CoglFramebufferBits)); -} - -static void -cogl_nop_framebuffer_clear (CoglFramebufferDriver *driver, - unsigned long buffers, - float red, - float green, - float blue, - float alpha) -{ -} - -static void -cogl_nop_framebuffer_finish (CoglFramebufferDriver *driver) -{ -} - -static void -cogl_nop_framebuffer_flush (CoglFramebufferDriver *driver) -{ -} - -static void -cogl_nop_framebuffer_discard_buffers (CoglFramebufferDriver *driver, - unsigned long buffers) -{ -} - -static void -cogl_nop_framebuffer_draw_attributes (CoglFramebufferDriver *driver, - CoglPipeline *pipeline, - CoglVerticesMode mode, - int first_vertex, - int n_vertices, - CoglAttribute **attributes, - int n_attributes, - CoglDrawFlags flags) -{ -} - -static void -cogl_nop_framebuffer_draw_indexed_attributes (CoglFramebufferDriver *driver, - CoglPipeline *pipeline, - CoglVerticesMode mode, - int first_vertex, - int n_vertices, - CoglIndices *indices, - CoglAttribute **attributes, - int n_attributes, - CoglDrawFlags flags) -{ -} - -static gboolean -cogl_nop_framebuffer_read_pixels_into_bitmap (CoglFramebufferDriver *framebuffer, - int x, - int y, - CoglReadPixelsFlags source, - CoglBitmap *bitmap, - GError **error) -{ - return TRUE; -} - -static void -cogl_nop_framebuffer_init (CoglNopFramebuffer *nop_framebuffer) -{ -} - -static void -cogl_nop_framebuffer_class_init (CoglNopFramebufferClass *klass) -{ - CoglFramebufferDriverClass *driver_class = - COGL_FRAMEBUFFER_DRIVER_CLASS (klass); - - driver_class->query_bits = cogl_nop_framebuffer_query_bits; - driver_class->clear = cogl_nop_framebuffer_clear; - driver_class->finish = cogl_nop_framebuffer_finish; - driver_class->flush = cogl_nop_framebuffer_flush; - driver_class->discard_buffers = cogl_nop_framebuffer_discard_buffers; - driver_class->draw_attributes = cogl_nop_framebuffer_draw_attributes; - driver_class->draw_indexed_attributes = - cogl_nop_framebuffer_draw_indexed_attributes; - driver_class->read_pixels_into_bitmap = - cogl_nop_framebuffer_read_pixels_into_bitmap; -} diff --git a/cogl/cogl/driver/nop/cogl-nop-framebuffer.h b/cogl/cogl/driver/nop/cogl-nop-framebuffer.h deleted file mode 100644 index db9f3533e..000000000 --- a/cogl/cogl/driver/nop/cogl-nop-framebuffer.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2020 Red Hat - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -#pragma once - -#include "cogl/cogl-framebuffer-driver.h" - -#define COGL_TYPE_NOP_FRAMEBUFFER (cogl_nop_framebuffer_get_type ()) -G_DECLARE_FINAL_TYPE (CoglNopFramebuffer, cogl_nop_framebuffer, - COGL, NOP_FRAMEBUFFER_DRIVER, - CoglFramebufferDriver) diff --git a/cogl/cogl/meson.build b/cogl/cogl/meson.build index 2cfcea3a7..e67ab00ac 100644 --- a/cogl/cogl/meson.build +++ b/cogl/cogl/meson.build @@ -64,8 +64,6 @@ cogl_nodist_headers = [ cogl_noop_driver_sources = [ 'driver/nop/cogl-driver-nop.c', - 'driver/nop/cogl-nop-framebuffer.c', - 'driver/nop/cogl-nop-framebuffer.h', 'driver/nop/cogl-texture-2d-nop-private.h', 'driver/nop/cogl-texture-2d-nop.c', ]