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>
This commit is contained in:
Jonas Ådahl 2020-10-20 11:14:38 +02:00 committed by Robert Mader
parent 1e5f105836
commit 0fcb26075f
13 changed files with 58 additions and 132 deletions

View File

@ -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

View File

@ -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,

View File

@ -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 */

View File

@ -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

View File

@ -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);

View File

@ -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;
}

View File

@ -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,

View File

@ -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,

View File

@ -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,

View File

@ -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_ */

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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',