summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry Song <henry.song@samsung.com>2013-01-16 15:32:32 +0100
committerMartin Robinson <mrobinson@igalia.com>2013-01-23 16:55:38 -0800
commit7054c9969cb0e41845635d6658935da223899f08 (patch)
treed8ceda757ef507af276cc566a68ad2e1fa1bf51d
parentfa4f48cccb6c7f4e1afb2ff4b98b906b7d8d4afc (diff)
gl: Don't query the display when checking if the context changed
If display has changed, the associated context must change. A context is tied a display so we can avoid this check, eliminating unnecessary work during context acquisition and release.
-rw-r--r--src/cairo-egl-context.c13
-rw-r--r--src/cairo-glx-context.c13
2 files changed, 8 insertions, 18 deletions
diff --git a/src/cairo-egl-context.c b/src/cairo-egl-context.c
index 12924cc8..ba8f60f1 100644
--- a/src/cairo-egl-context.c
+++ b/src/cairo-egl-context.c
@@ -50,7 +50,6 @@ typedef struct _cairo_egl_context {
EGLSurface dummy_surface;
- EGLDisplay previous_display;
EGLContext previous_context;
EGLSurface previous_surface;
} cairo_egl_context_t;
@@ -66,9 +65,8 @@ static cairo_bool_t
_context_acquisition_changed_egl_state (cairo_egl_context_t *ctx,
EGLSurface current_surface)
{
- return !(ctx->previous_display == ctx->display &&
- ctx->previous_surface == current_surface &&
- ctx->previous_context == ctx->context);
+ return ctx->previous_context != ctx->context ||
+ ctx->previous_surface != current_surface;
}
static EGLSurface
@@ -85,18 +83,15 @@ _egl_get_current_surface (cairo_egl_context_t *ctx)
static void
_egl_query_current_state (cairo_egl_context_t *ctx)
{
- ctx->previous_display = eglGetCurrentDisplay ();
ctx->previous_surface = eglGetCurrentSurface (EGL_DRAW);
ctx->previous_context = eglGetCurrentContext ();
/* If any of the values were none, assume they are all none. Not all
drivers seem well behaved when it comes to using these values across
multiple threads. */
- if (ctx->previous_surface == EGL_NO_SURFACE
- || ctx->previous_display == EGL_NO_DISPLAY
- || ctx->previous_context == EGL_NO_CONTEXT) {
+ if (ctx->previous_surface == EGL_NO_SURFACE ||
+ ctx->previous_context == EGL_NO_CONTEXT) {
ctx->previous_surface = EGL_NO_SURFACE;
- ctx->previous_display = EGL_NO_DISPLAY;
ctx->previous_context = EGL_NO_CONTEXT;
}
}
diff --git a/src/cairo-glx-context.c b/src/cairo-glx-context.c
index ebe53608..3761b907 100644
--- a/src/cairo-glx-context.c
+++ b/src/cairo-glx-context.c
@@ -53,7 +53,6 @@ typedef struct _cairo_glx_context {
Window dummy_window;
GLXContext context;
- Display *previous_display;
GLXDrawable previous_drawable;
GLXContext previous_context;
@@ -70,9 +69,8 @@ static cairo_bool_t
_context_acquisition_changed_glx_state (cairo_glx_context_t *ctx,
GLXDrawable current_drawable)
{
- return !(ctx->previous_display == ctx->display &&
- ctx->previous_drawable == current_drawable &&
- ctx->previous_context == ctx->context);
+ return ctx->previous_drawable != current_drawable ||
+ ctx->previous_context != ctx->context;
}
static GLXDrawable
@@ -90,17 +88,14 @@ static void
_glx_query_current_state (cairo_glx_context_t * ctx)
{
ctx->previous_drawable = glXGetCurrentDrawable ();
- ctx->previous_display = glXGetCurrentDisplay ();
ctx->previous_context = glXGetCurrentContext ();
/* If any of the values were none, assume they are all none. Not all
drivers seem well behaved when it comes to using these values across
multiple threads. */
- if (ctx->previous_drawable == None
- || ctx->previous_display == None
- || ctx->previous_context == None) {
+ if (ctx->previous_drawable == None ||
+ ctx->previous_context == None) {
ctx->previous_drawable = None;
- ctx->previous_display = None;
ctx->previous_context = None;
}
}