mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2025-12-28 05:10:12 +01:00
Merge branch 'fix_device_errors' into 'master'
Fix device errors See merge request cairo/cairo!30
This commit is contained in:
commit
fa1b02d7e5
2 changed files with 52 additions and 8 deletions
|
|
@ -27,6 +27,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* Alexandros Frantzis <alexandros.frantzis@linaro.org>
|
||||
* Heiko Lewin <heiko.lewin@gmx.de>
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
|
@ -57,22 +58,53 @@ _cairo_gl_get_version (void)
|
|||
return CAIRO_GL_VERSION_ENCODE (major, minor);
|
||||
}
|
||||
|
||||
|
||||
cairo_gl_flavor_t
|
||||
_cairo_gl_degrade_flavor_by_build_features (cairo_gl_flavor_t flavor) {
|
||||
switch(flavor) {
|
||||
case CAIRO_GL_FLAVOR_DESKTOP:
|
||||
#if CAIRO_HAS_GL_SURFACE
|
||||
return CAIRO_GL_FLAVOR_DESKTOP;
|
||||
#else
|
||||
return CAIRO_GL_FLAVOR_NONE;
|
||||
#endif
|
||||
|
||||
case CAIRO_GL_FLAVOR_ES3:
|
||||
#if CAIRO_HAS_GLESV3_SURFACE
|
||||
return CAIRO_GL_FLAVOR_ES3;
|
||||
#else
|
||||
/* intentional fall through: degrade to GLESv2 if GLESv3-surfaces are not available */
|
||||
#endif
|
||||
|
||||
case CAIRO_GL_FLAVOR_ES2:
|
||||
#if CAIRO_HAS_GLESV2_SURFACE
|
||||
return CAIRO_GL_FLAVOR_ES2;
|
||||
#else
|
||||
/* intentional fall through: no OpenGL in first place or no surfaces for it's version */
|
||||
#endif
|
||||
|
||||
default:
|
||||
return CAIRO_GL_FLAVOR_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
cairo_gl_flavor_t
|
||||
_cairo_gl_get_flavor (void)
|
||||
{
|
||||
const char *version = (const char *) glGetString (GL_VERSION);
|
||||
cairo_gl_flavor_t flavor;
|
||||
|
||||
if (version == NULL)
|
||||
if (version == NULL) {
|
||||
flavor = CAIRO_GL_FLAVOR_NONE;
|
||||
else if (strstr (version, "OpenGL ES 3") != NULL)
|
||||
} else if (strstr (version, "OpenGL ES 3") != NULL) {
|
||||
flavor = CAIRO_GL_FLAVOR_ES3;
|
||||
else if (strstr (version, "OpenGL ES 2") != NULL)
|
||||
} else if (strstr (version, "OpenGL ES 2") != NULL) {
|
||||
flavor = CAIRO_GL_FLAVOR_ES2;
|
||||
else
|
||||
} else {
|
||||
flavor = CAIRO_GL_FLAVOR_DESKTOP;
|
||||
}
|
||||
|
||||
return flavor;
|
||||
return _cairo_gl_degrade_flavor_by_build_features(flavor);
|
||||
}
|
||||
|
||||
unsigned long
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
* Eric Anholt <eric@anholt.net>
|
||||
* T. Zachary Laine <whatwasthataddress@gmail.com>
|
||||
* Alexandros Frantzis <alexandros.frantzis@linaro.org>
|
||||
* H. Lewin <heiko.lewin@gmx.de>
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
|
@ -900,7 +901,7 @@ _cairo_gl_shader_compile_and_link (cairo_gl_context_t *ctx,
|
|||
* texture unit 1 if present, so we can just initialize these once at
|
||||
* compile time.
|
||||
*/
|
||||
static void
|
||||
static cairo_status_t
|
||||
_cairo_gl_shader_set_samplers (cairo_gl_context_t *ctx,
|
||||
cairo_gl_shader_t *shader)
|
||||
{
|
||||
|
|
@ -924,8 +925,14 @@ _cairo_gl_shader_set_samplers (cairo_gl_context_t *ctx,
|
|||
if (location != -1) {
|
||||
dispatch->Uniform1i (location, CAIRO_GL_TEX_MASK);
|
||||
}
|
||||
|
||||
if(_cairo_gl_get_error()) return CAIRO_STATUS_DEVICE_ERROR;
|
||||
dispatch->UseProgram (saved_program);
|
||||
/* Pop and ignore a possible gl-error when restoring the previous program.
|
||||
* It may be that being selected in the gl-context was the last reference
|
||||
* to the shader.
|
||||
*/
|
||||
_cairo_gl_get_error();
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -1084,7 +1091,12 @@ _cairo_gl_get_shader_by_type (cairo_gl_context_t *ctx,
|
|||
return status;
|
||||
}
|
||||
|
||||
_cairo_gl_shader_set_samplers (ctx, &entry->shader);
|
||||
status = _cairo_gl_shader_set_samplers (ctx, &entry->shader);
|
||||
if (unlikely (status)) {
|
||||
_cairo_gl_shader_fini (ctx, &entry->shader);
|
||||
free (entry);
|
||||
return status;
|
||||
}
|
||||
|
||||
status = _cairo_cache_insert (&ctx->shaders, &entry->base);
|
||||
if (unlikely (status)) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue