summaryrefslogtreecommitdiff
path: root/cogl
diff options
context:
space:
mode:
authorJonas Ã…dahl <jadahl@gmail.com>2020-10-20 11:14:38 +0200
committerRobert Mader <robert.mader@posteo.de>2021-01-30 09:11:46 +0000
commit0fcb26075fcc6e5879f50b1addb1b97cc06f3200 (patch)
tree543f9da9ac0e1eafff8db645b3f9c412e2f6f3b5 /cogl
parent1e5f105836198d19d71135f30dd3122865dc116b (diff)
downloadmutter-0fcb26075fcc6e5879f50b1addb1b97cc06f3200.tar.gz
cogl/framebuffer: Move read_pixels_into_bitmap() to driver class
This was the last driver vfunc used specifically to implement the CoglFramebuffer driver. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
Diffstat (limited to 'cogl')
-rw-r--r--cogl/cogl/cogl-driver.h8
-rw-r--r--cogl/cogl/cogl-framebuffer-driver.c14
-rw-r--r--cogl/cogl/cogl-framebuffer-driver.h15
-rw-r--r--cogl/cogl/cogl-framebuffer.c13
-rw-r--r--cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h8
-rw-r--r--cogl/cogl/driver/gl/cogl-framebuffer-gl.c18
-rw-r--r--cogl/cogl/driver/gl/gl/cogl-driver-gl.c1
-rw-r--r--cogl/cogl/driver/gl/gles/cogl-driver-gles.c1
-rw-r--r--cogl/cogl/driver/nop/cogl-driver-nop.c2
-rw-r--r--cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h48
-rw-r--r--cogl/cogl/driver/nop/cogl-framebuffer-nop.c47
-rw-r--r--cogl/cogl/driver/nop/cogl-nop-framebuffer.c13
-rw-r--r--cogl/cogl/meson.build2
13 files changed, 58 insertions, 132 deletions
diff --git a/cogl/cogl/cogl-driver.h b/cogl/cogl/cogl-driver.h
index f2ae3e7b9..21519085b 100644
--- a/cogl/cogl/cogl-driver.h
+++ b/cogl/cogl/cogl-driver.h
@@ -85,14 +85,6 @@ struct _CoglDriverVtable
CoglFramebuffer *read_buffer,
CoglFramebufferState state);
- gboolean
- (* framebuffer_read_pixels_into_bitmap) (CoglFramebuffer *framebuffer,
- int x,
- int y,
- CoglReadPixelsFlags source,
- CoglBitmap *bitmap,
- GError **error);
-
/* Destroys any driver specific resources associated with the given
* 2D texture. */
void
diff --git a/cogl/cogl/cogl-framebuffer-driver.c b/cogl/cogl/cogl-framebuffer-driver.c
index d49f90d29..bd99a795d 100644
--- a/cogl/cogl/cogl-framebuffer-driver.c
+++ b/cogl/cogl/cogl-framebuffer-driver.c
@@ -145,6 +145,20 @@ cogl_framebuffer_driver_draw_indexed_attributes (CoglFramebufferDriver *driver,
flags);
}
+gboolean
+cogl_framebuffer_driver_read_pixels_into_bitmap (CoglFramebufferDriver *driver,
+ int x,
+ int y,
+ CoglReadPixelsFlags source,
+ CoglBitmap *bitmap,
+ GError **error)
+{
+ CoglFramebufferDriverClass *klass =
+ COGL_FRAMEBUFFER_DRIVER_GET_CLASS (driver);
+
+ return klass->read_pixels_into_bitmap (driver, x, y, source, bitmap, error);
+}
+
static void
cogl_framebuffer_driver_get_property (GObject *object,
guint prop_id,
diff --git a/cogl/cogl/cogl-framebuffer-driver.h b/cogl/cogl/cogl-framebuffer-driver.h
index 7608701e0..d8815234b 100644
--- a/cogl/cogl/cogl-framebuffer-driver.h
+++ b/cogl/cogl/cogl-framebuffer-driver.h
@@ -78,6 +78,13 @@ struct _CoglFramebufferDriverClass
CoglAttribute **attributes,
int n_attributes,
CoglDrawFlags flags);
+
+ gboolean (* read_pixels_into_bitmap) (CoglFramebufferDriver *driver,
+ int x,
+ int y,
+ CoglReadPixelsFlags source,
+ CoglBitmap *bitmap,
+ GError **error);
};
CoglFramebuffer *
@@ -126,4 +133,12 @@ cogl_framebuffer_driver_draw_indexed_attributes (CoglFramebufferDriver *driver,
int n_attributes,
CoglDrawFlags flags);
+gboolean
+cogl_framebuffer_driver_read_pixels_into_bitmap (CoglFramebufferDriver *driver,
+ int x,
+ int y,
+ CoglReadPixelsFlags source,
+ CoglBitmap *bitmap,
+ GError **error);
+
#endif /* COGL_FRAMEBUFFER_DRIVER_H */
diff --git a/cogl/cogl/cogl-framebuffer.c b/cogl/cogl/cogl-framebuffer.c
index c02eabd9c..41194829c 100644
--- a/cogl/cogl/cogl-framebuffer.c
+++ b/cogl/cogl/cogl-framebuffer.c
@@ -1483,7 +1483,6 @@ _cogl_framebuffer_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
{
CoglFramebufferPrivate *priv =
cogl_framebuffer_get_instance_private (framebuffer);
- CoglContext *ctx;
int width;
int height;
@@ -1511,18 +1510,16 @@ _cogl_framebuffer_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
return TRUE;
}
- ctx = cogl_framebuffer_get_context (framebuffer);
-
/* make sure any batched primitives get emitted to the driver
* before issuing our read pixels...
*/
_cogl_framebuffer_flush_journal (framebuffer);
- return ctx->driver_vtable->framebuffer_read_pixels_into_bitmap (framebuffer,
- x, y,
- source,
- bitmap,
- error);
+ return cogl_framebuffer_driver_read_pixels_into_bitmap (priv->driver,
+ x, y,
+ source,
+ bitmap,
+ error);
}
gboolean
diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h b/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h
index c7e2995c6..4bdd076a6 100644
--- a/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h
+++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl-private.h
@@ -55,14 +55,6 @@ void
cogl_gl_framebuffer_bind (CoglGlFramebuffer *gl_framebuffer,
GLenum target);
-gboolean
-_cogl_framebuffer_gl_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
- int x,
- int y,
- CoglReadPixelsFlags source,
- CoglBitmap *bitmap,
- GError **error);
-
void
cogl_gl_framebuffer_flush_state_differences (CoglGlFramebuffer *gl_framebuffer,
unsigned long differences);
diff --git a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
index fee3f2233..e053d0ad4 100644
--- a/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
+++ b/cogl/cogl/driver/gl/cogl-framebuffer-gl.c
@@ -419,14 +419,16 @@ cogl_gl_framebuffer_draw_indexed_attributes (CoglFramebufferDriver *driver,
_cogl_buffer_gl_unbind (buffer);
}
-gboolean
-_cogl_framebuffer_gl_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
- int x,
- int y,
- CoglReadPixelsFlags source,
- CoglBitmap *bitmap,
- GError **error)
+static gboolean
+cogl_gl_framebuffer_read_pixels_into_bitmap (CoglFramebufferDriver *driver,
+ int x,
+ int y,
+ CoglReadPixelsFlags source,
+ CoglBitmap *bitmap,
+ GError **error)
{
+ CoglFramebuffer *framebuffer =
+ cogl_framebuffer_driver_get_framebuffer (driver);
CoglContext *ctx = cogl_framebuffer_get_context (framebuffer);
int framebuffer_height = cogl_framebuffer_get_height (framebuffer);
int width = cogl_bitmap_get_width (bitmap);
@@ -693,4 +695,6 @@ cogl_gl_framebuffer_class_init (CoglGlFramebufferClass *klass)
driver_class->draw_attributes = cogl_gl_framebuffer_draw_attributes;
driver_class->draw_indexed_attributes =
cogl_gl_framebuffer_draw_indexed_attributes;
+ driver_class->read_pixels_into_bitmap =
+ cogl_gl_framebuffer_read_pixels_into_bitmap;
}
diff --git a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
index 76f213b74..35577518d 100644
--- a/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
+++ b/cogl/cogl/driver/gl/gl/cogl-driver-gl.c
@@ -571,7 +571,6 @@ _cogl_driver_gl =
_cogl_driver_update_features,
_cogl_driver_gl_create_framebuffer_driver,
_cogl_driver_gl_flush_framebuffer_state,
- _cogl_framebuffer_gl_read_pixels_into_bitmap,
_cogl_texture_2d_gl_free,
_cogl_texture_2d_gl_can_create,
_cogl_texture_2d_gl_init,
diff --git a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
index 5b50b7691..3e8ea8a0a 100644
--- a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
+++ b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
@@ -459,7 +459,6 @@ _cogl_driver_gles =
_cogl_driver_update_features,
_cogl_driver_gl_create_framebuffer_driver,
_cogl_driver_gl_flush_framebuffer_state,
- _cogl_framebuffer_gl_read_pixels_into_bitmap,
_cogl_texture_2d_gl_free,
_cogl_texture_2d_gl_can_create,
_cogl_texture_2d_gl_init,
diff --git a/cogl/cogl/driver/nop/cogl-driver-nop.c b/cogl/cogl/driver/nop/cogl-driver-nop.c
index 0d47bf28b..2cde8576b 100644
--- a/cogl/cogl/driver/nop/cogl-driver-nop.c
+++ b/cogl/cogl/driver/nop/cogl-driver-nop.c
@@ -36,7 +36,6 @@
#include "cogl-context-private.h"
#include "cogl-feature-private.h"
#include "cogl-renderer-private.h"
-#include "cogl-framebuffer-nop-private.h"
#include "cogl-texture-2d-nop-private.h"
#include "cogl-attribute-nop-private.h"
#include "cogl-clip-stack-nop-private.h"
@@ -99,7 +98,6 @@ _cogl_driver_nop =
_cogl_driver_update_features,
_cogl_driver_nop_create_framebuffer_driver,
_cogl_driver_nop_flush_framebuffer_state,
- _cogl_framebuffer_nop_read_pixels_into_bitmap,
_cogl_texture_2d_nop_free,
_cogl_texture_2d_nop_can_create,
_cogl_texture_2d_nop_init,
diff --git a/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h b/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h
deleted file mode 100644
index 1fd031e5c..000000000
--- a/cogl/cogl/driver/nop/cogl-framebuffer-nop-private.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Cogl
- *
- * A Low Level GPU Graphics and Utilities API
- *
- * Copyright (C) 2012 Intel Corporation.
- *
- * 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.
- *
- *
- *
- * Authors:
- * Robert Bragg <robert@linux.intel.com>
- */
-
-#ifndef _COGL_FRAMEBUFFER_NOP_PRIVATE_H_
-#define _COGL_FRAMEBUFFER_NOP_PRIVATE_H_
-
-#include "cogl-types.h"
-#include "cogl-context-private.h"
-
-gboolean
-_cogl_framebuffer_nop_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
- int x,
- int y,
- CoglReadPixelsFlags source,
- CoglBitmap *bitmap,
- GError **error);
-
-#endif /* _COGL_FRAMEBUFFER_NOP_PRIVATE_H_ */
diff --git a/cogl/cogl/driver/nop/cogl-framebuffer-nop.c b/cogl/cogl/driver/nop/cogl-framebuffer-nop.c
deleted file mode 100644
index e0e290586..000000000
--- a/cogl/cogl/driver/nop/cogl-framebuffer-nop.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Cogl
- *
- * A Low Level GPU Graphics and Utilities API
- *
- * Copyright (C) 2007,2008,2009,2012 Intel Corporation.
- *
- * 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 "cogl-config.h"
-
-#include "cogl-framebuffer-nop-private.h"
-
-#include <glib.h>
-#include <string.h>
-
-gboolean
-_cogl_framebuffer_nop_read_pixels_into_bitmap (CoglFramebuffer *framebuffer,
- int x,
- int y,
- CoglReadPixelsFlags source,
- CoglBitmap *bitmap,
- GError **error)
-{
- return TRUE;
-}
diff --git a/cogl/cogl/driver/nop/cogl-nop-framebuffer.c b/cogl/cogl/driver/nop/cogl-nop-framebuffer.c
index 20ec514a5..3ab05338e 100644
--- a/cogl/cogl/driver/nop/cogl-nop-framebuffer.c
+++ b/cogl/cogl/driver/nop/cogl-nop-framebuffer.c
@@ -95,6 +95,17 @@ cogl_nop_framebuffer_draw_indexed_attributes (CoglFramebufferDriver *driver,
{
}
+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)
{
@@ -114,4 +125,6 @@ cogl_nop_framebuffer_class_init (CoglNopFramebufferClass *klass)
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/meson.build b/cogl/cogl/meson.build
index f8ae283a8..a76b9685c 100644
--- a/cogl/cogl/meson.build
+++ b/cogl/cogl/meson.build
@@ -130,8 +130,6 @@ cogl_nodist_headers = [
cogl_noop_driver_sources = [
'driver/nop/cogl-driver-nop.c',
- 'driver/nop/cogl-framebuffer-nop-private.h',
- 'driver/nop/cogl-framebuffer-nop.c',
'driver/nop/cogl-nop-framebuffer.c',
'driver/nop/cogl-nop-framebuffer.h',
'driver/nop/cogl-attribute-nop-private.h',