/* Generated by Cython 0.19.1 on Sun Aug 04 15:59:48 2013 */

#define PY_SSIZE_T_CLEAN
#ifndef CYTHON_USE_PYLONG_INTERNALS
#ifdef PYLONG_BITS_IN_DIGIT
#define CYTHON_USE_PYLONG_INTERNALS 0
#else
#include "pyconfig.h"
#ifdef PYLONG_BITS_IN_DIGIT
#define CYTHON_USE_PYLONG_INTERNALS 1
#else
#define CYTHON_USE_PYLONG_INTERNALS 0
#endif
#endif
#endif
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02040000
    #error Cython requires Python 2.4+.
#else
#include <stddef.h> /* For offsetof */
#ifndef offsetof
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif
#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
#define CYTHON_COMPILING_IN_PYPY 1
#define CYTHON_COMPILING_IN_CPYTHON 0
#else
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_CPYTHON 1
#endif
#if PY_VERSION_HEX < 0x02050000
  typedef int Py_ssize_t;
  #define PY_SSIZE_T_MAX INT_MAX
  #define PY_SSIZE_T_MIN INT_MIN
  #define PY_FORMAT_SIZE_T ""
  #define CYTHON_FORMAT_SSIZE_T ""
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)   __Pyx_PyInt_AsInt(o)
  #define PyNumber_Index(o)    ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \
                                (PyErr_Format(PyExc_TypeError, \
                                              "expected index value, got %.200s", Py_TYPE(o)->tp_name), \
                                 (PyObject*)0))
  #define __Pyx_PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && \
                                  !PyComplex_Check(o))
  #define PyIndex_Check __Pyx_PyIndex_Check
  #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
  #define __PYX_BUILD_PY_SSIZE_T "i"
#else
  #define __PYX_BUILD_PY_SSIZE_T "n"
  #define CYTHON_FORMAT_SSIZE_T "z"
  #define __Pyx_PyIndex_Check PyIndex_Check
#endif
#if PY_VERSION_HEX < 0x02060000
  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
  #define PyVarObject_HEAD_INIT(type, size) \
          PyObject_HEAD_INIT(type) size,
  #define PyType_Modified(t)
  typedef struct {
     void *buf;
     PyObject *obj;
     Py_ssize_t len;
     Py_ssize_t itemsize;
     int readonly;
     int ndim;
     char *format;
     Py_ssize_t *shape;
     Py_ssize_t *strides;
     Py_ssize_t *suboffsets;
     void *internal;
  } Py_buffer;
  #define PyBUF_SIMPLE 0
  #define PyBUF_WRITABLE 0x0001
  #define PyBUF_FORMAT 0x0004
  #define PyBUF_ND 0x0008
  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
  #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE)
  #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE)
  typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
  typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
#endif
#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
          PyCode_New(a, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#endif
#if PY_MAJOR_VERSION < 3 && PY_MINOR_VERSION < 6
  #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict")
#endif
#if PY_MAJOR_VERSION >= 3
  #define Py_TPFLAGS_CHECKTYPES 0
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#if PY_VERSION_HEX < 0x02060000
  #define Py_TPFLAGS_HAVE_VERSION_TAG 0
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  #define CYTHON_PEP393_ENABLED 1
  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ? \
                                              0 : _PyUnicode_Ready((PyObject *)(op)))
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
#else
  #define CYTHON_PEP393_ENABLED 0
  #define __Pyx_PyUnicode_READY(op)       (0)
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  #define __Pyx_PyUnicode_READ(k, d, i)   ((k=k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#endif
#if PY_VERSION_HEX < 0x02060000
  #define PyBytesObject                PyStringObject
  #define PyBytes_Type                 PyString_Type
  #define PyBytes_Check                PyString_Check
  #define PyBytes_CheckExact           PyString_CheckExact
  #define PyBytes_FromString           PyString_FromString
  #define PyBytes_FromStringAndSize    PyString_FromStringAndSize
  #define PyBytes_FromFormat           PyString_FromFormat
  #define PyBytes_DecodeEscape         PyString_DecodeEscape
  #define PyBytes_AsString             PyString_AsString
  #define PyBytes_AsStringAndSize      PyString_AsStringAndSize
  #define PyBytes_Size                 PyString_Size
  #define PyBytes_AS_STRING            PyString_AS_STRING
  #define PyBytes_GET_SIZE             PyString_GET_SIZE
  #define PyBytes_Repr                 PyString_Repr
  #define PyBytes_Concat               PyString_Concat
  #define PyBytes_ConcatAndDel         PyString_ConcatAndDel
#endif
#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
#else
  #define __Pyx_PyBaseString_Check(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj) || \
                                         PyString_Check(obj) || PyUnicode_Check(obj))
  #define __Pyx_PyBaseString_CheckExact(obj) (Py_TYPE(obj) == &PyBaseString_Type)
#endif
#if PY_VERSION_HEX < 0x02060000
  #define PySet_Check(obj)             PyObject_TypeCheck(obj, &PySet_Type)
  #define PyFrozenSet_Check(obj)       PyObject_TypeCheck(obj, &PyFrozenSet_Type)
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif
#if PY_VERSION_HEX < 0x03020000
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
#endif
#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
  #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
  #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
#else
  #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
  #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
#endif
#if PY_MAJOR_VERSION >= 3
  #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#endif
#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
#else
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
#endif
#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_NAMESTR(n) ((char *)(n))
  #define __Pyx_DOCSTR(n)  ((char *)(n))
#else
  #define __Pyx_NAMESTR(n) (n)
  #define __Pyx_DOCSTR(n)  (n)
#endif
#ifndef CYTHON_INLINE
  #if defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif
#ifndef CYTHON_RESTRICT
  #if defined(__GNUC__)
    #define CYTHON_RESTRICT __restrict__
  #elif defined(_MSC_VER)
    #define CYTHON_RESTRICT __restrict
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_RESTRICT restrict
  #else
    #define CYTHON_RESTRICT
  #endif
#endif
#ifdef NAN
#define __PYX_NAN() ((float) NAN)
#else
static CYTHON_INLINE float __PYX_NAN() {
  /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and
   a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is
   a quiet NaN. */
  float value;
  memset(&value, 0xFF, sizeof(value));
  return value;
}
#endif


#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif

#ifndef __PYX_EXTERN_C
  #ifdef __cplusplus
    #define __PYX_EXTERN_C extern "C"
  #else
    #define __PYX_EXTERN_C extern
  #endif
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#define __PYX_HAVE__kivy__graphics__texture
#define __PYX_HAVE_API__kivy__graphics__texture
#include "gl_redirect.h"
#include "math.h"
#include "stdlib.h"
#include "string.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif

#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif
typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding;
                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/

#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
#define __PYX_DEFAULT_STRING_ENCODING "utf-8"
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
#define __Pyx_PyBytes_FromString        PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char*);
#if PY_MAJOR_VERSION < 3
    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#else
    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
#endif
#define __Pyx_PyObject_AsUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromUString(s)  __Pyx_PyObject_FromString((char*)s)
#define __Pyx_PyBytes_FromUString(s)   __Pyx_PyBytes_FromString((char*)s)
#define __Pyx_PyStr_FromUString(s)     __Pyx_PyStr_FromString((char*)s)
#define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((char*)s)
#if PY_MAJOR_VERSION < 3
static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
{
    const Py_UNICODE *u_end = u;
    while (*u_end++) ;
    return u_end - u - 1;
}
#else
#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
#endif
#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
#if CYTHON_COMPILING_IN_CPYTHON
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params() {
    PyObject* sys = NULL;
    PyObject* default_encoding = NULL;
    PyObject* ascii_chars_u = NULL;
    PyObject* ascii_chars_b = NULL;
    sys = PyImport_ImportModule("sys");
    if (sys == NULL) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    if (default_encoding == NULL) goto bad;
    if (strcmp(PyBytes_AsString(default_encoding), "ascii") == 0) {
        __Pyx_sys_getdefaultencoding_not_ascii = 0;
    } else {
        const char* default_encoding_c = PyBytes_AS_STRING(default_encoding);
        char ascii_chars[128];
        int c;
        for (c = 0; c < 128; c++) {
            ascii_chars[c] = c;
        }
        __Pyx_sys_getdefaultencoding_not_ascii = 1;
        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
        if (ascii_chars_u == NULL) goto bad;
        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
        if (ascii_chars_b == NULL || strncmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
            PyErr_Format(
                PyExc_ValueError,
                "This module compiled with c_string_encoding=ascii, but default encoding '%s' is not a superset of ascii.",
                default_encoding_c);
            goto bad;
        }
    }
    Py_XDECREF(sys);
    Py_XDECREF(default_encoding);
    Py_XDECREF(ascii_chars_u);
    Py_XDECREF(ascii_chars_b);
    return 0;
bad:
    Py_XDECREF(sys);
    Py_XDECREF(default_encoding);
    Py_XDECREF(ascii_chars_u);
    Py_XDECREF(ascii_chars_b);
    return -1;
}
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#else
#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
static char* __PYX_DEFAULT_STRING_ENCODING;
static int __Pyx_init_sys_getdefaultencoding_params() {
    PyObject* sys = NULL;
    PyObject* default_encoding = NULL;
    char* default_encoding_c;
    sys = PyImport_ImportModule("sys");
    if (sys == NULL) goto bad;
    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
    if (default_encoding == NULL) goto bad;
    default_encoding_c = PyBytes_AS_STRING(default_encoding);
    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
    Py_DECREF(sys);
    Py_DECREF(default_encoding);
    return 0;
bad:
    Py_XDECREF(sys);
    Py_XDECREF(default_encoding);
    return -1;
}
#endif
#endif


#ifdef __GNUC__
  /* Test for GCC > 2.95 */
  #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
    #define likely(x)   __builtin_expect(!!(x), 1)
    #define unlikely(x) __builtin_expect(!!(x), 0)
  #else /* __GNUC__ > 2 ... */
    #define likely(x)   (x)
    #define unlikely(x) (x)
  #endif /* __GNUC__ > 2 ... */
#else /* __GNUC__ */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */

static PyObject *__pyx_m;
static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;


static const char *__pyx_f[] = {
  "texture.pyx",
  "buffer.pxd",
  "vertex.pxd",
  "vbo.pxd",
  "transformation.pxd",
  "context_instructions.pxd",
  "compiler.pxd",
  "shader.pxd",
  "_event.pxd",
  "instructions.pxd",
  "fbo.pxd",
  "context.pxd",
  "opengl_utils_def.pxi",
};

/*--- Type declarations ---*/
struct __pyx_obj_4kivy_6_event_ObjectWithUid;
struct __pyx_obj_4kivy_8graphics_12instructions_Instruction;
struct __pyx_obj_4kivy_8graphics_12instructions_ContextInstruction;
struct __pyx_obj_4kivy_8graphics_20context_instructions_UpdateNormalMatrix;
struct __pyx_obj_4kivy_8graphics_7texture_Texture;
struct __pyx_obj_4kivy_8graphics_7context_Context;
struct __pyx_obj_4kivy_8graphics_20context_instructions_MatrixInstruction;
struct __pyx_obj_4kivy_8graphics_20context_instructions_Transform;
struct __pyx_obj_4kivy_8graphics_20context_instructions_Rotate;
struct __pyx_obj_4kivy_8graphics_20context_instructions_LoadIdentity;
struct __pyx_obj_4kivy_8graphics_20context_instructions_LineWidth;
struct __pyx_obj_4kivy_6_event_EventDispatcher;
struct __pyx_obj_4kivy_8graphics_20context_instructions_Scale;
struct __pyx_obj_4kivy_8graphics_20context_instructions_PopMatrix;
struct __pyx_obj_4kivy_8graphics_12instructions_InstructionGroup;
struct __pyx_obj_4kivy_8graphics_12instructions_CanvasBase;
struct __pyx_obj_4kivy_8graphics_6shader_ShaderSource;
struct __pyx_obj_4kivy_8graphics_20context_instructions_PushMatrix;
struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion;
struct __pyx_obj_4kivy_8graphics_3vbo_VBO;
struct __pyx_obj_4kivy_8graphics_20context_instructions_ChangeState;
struct __pyx_obj_4kivy_8graphics_6vertex_VertexFormat;
struct __pyx_obj_4kivy_8graphics_20context_instructions_PopState;
struct __pyx_obj_4kivy_8graphics_20context_instructions_Translate;
struct __pyx_obj_4kivy_8graphics_3vbo_VertexBatch;
struct __pyx_obj_4kivy_8graphics_6shader_Shader;
struct __pyx_obj_4kivy_8graphics_20context_instructions_BindTexture;
struct __pyx_obj_4kivy_8graphics_12instructions_Canvas;
struct __pyx_obj_4kivy_8graphics_12instructions_RenderContext;
struct __pyx_obj_4kivy_8graphics_6buffer_Buffer;
struct __pyx_obj_4kivy_8graphics_12instructions_Callback;
struct __pyx_obj_4kivy_8graphics_14transformation_Matrix;
struct __pyx_obj_4kivy_8graphics_3fbo_Fbo;
struct __pyx_obj_4kivy_8graphics_20context_instructions_ApplyContextMatrix;
struct __pyx_obj_4kivy_8graphics_20context_instructions_Color;
struct __pyx_obj_4kivy_8graphics_8compiler_GraphicsCompiler;
struct __pyx_obj_4kivy_8graphics_20context_instructions_PushState;
struct __pyx_obj_4kivy_8graphics_12instructions_VertexInstruction;
struct __pyx_t_4kivy_8graphics_6vertex_vertex_t;
struct __pyx_t_4kivy_8graphics_6vertex_vertex_attr_t;
typedef struct __pyx_t_4kivy_8graphics_6vertex_vertex_attr_t __pyx_t_4kivy_8graphics_6vertex_vertex_attr_t;

/* "vertex.pxd":3
 * from c_opengl cimport GLuint
 * 
 * cdef struct vertex_t:             # <<<<<<<<<<<<<<
 *     float x, y
 *     float s0, t0
 */
struct __pyx_t_4kivy_8graphics_6vertex_vertex_t {
  float x;
  float y;
  float s0;
  float t0;
};

/* "vertex.pxd":7
 *     float s0, t0
 * 
 * ctypedef struct vertex_attr_t:             # <<<<<<<<<<<<<<
 *     char *name
 *     unsigned int index
 */
struct __pyx_t_4kivy_8graphics_6vertex_vertex_attr_t {
  char *name;
  unsigned int index;
  unsigned int size;
  GLuint type;
  unsigned int bytesize;
  int per_vertex;
};
struct __pyx_opt_args_4kivy_8graphics_14transformation_6Matrix_transform_point;

/* "transformation.pxd":1
 * ctypedef double matrix_t[16]             # <<<<<<<<<<<<<<
 * 
 * cdef class Matrix:
 */
typedef double __pyx_t_4kivy_8graphics_14transformation_matrix_t[16];

/* "transformation.pxd":34
 *     cpdef Matrix normal_matrix(self)
 * 
 *     cpdef tuple transform_point(Matrix self, double x, double y, double z,             # <<<<<<<<<<<<<<
 *             t=?)
 * 
 */
struct __pyx_opt_args_4kivy_8graphics_14transformation_6Matrix_transform_point {
  int __pyx_n;
  PyObject *t;
};
struct __pyx_opt_args_4kivy_8graphics_6shader_6Shader_build_vertex;
struct __pyx_opt_args_4kivy_8graphics_6shader_6Shader_build_fragment;
struct __pyx_opt_args_4kivy_8graphics_6shader_6Shader_build_vertex {
  int __pyx_n;
  int link;
};

/* "shader.pxd":35
 *     cdef void build(self)
 *     cdef void build_vertex(self, int link=*)
 *     cdef void build_fragment(self, int link=*)             # <<<<<<<<<<<<<<
 *     cdef void link_program(self)
 *     cdef int is_linked(self)
 */
struct __pyx_opt_args_4kivy_8graphics_6shader_6Shader_build_fragment {
  int __pyx_n;
  int link;
};
struct __pyx_opt_args_4kivy_8graphics_12instructions_11Instruction_flag_update;
struct __pyx_opt_args_4kivy_8graphics_12instructions_13RenderContext_set_state;

/* "kivy\graphics\instructions.pxd":29
 * 
 *     cdef void apply(self)
 *     cdef void flag_update(self, int do_parent=?)             # <<<<<<<<<<<<<<
 *     cdef void flag_update_done(self)
 *     cdef void set_parent(self, Instruction parent)
 */
struct __pyx_opt_args_4kivy_8graphics_12instructions_11Instruction_flag_update {
  int __pyx_n;
  int do_parent;
};

/* "kivy\graphics\instructions.pxd":107
 * 
 *     cdef void set_texture(self, int index, Texture texture)
 *     cdef void set_state(self, str name, value, int apply_now=?)             # <<<<<<<<<<<<<<
 *     cdef get_state(self, str name)
 *     cdef void set_states(self, dict states)
 */
struct __pyx_opt_args_4kivy_8graphics_12instructions_13RenderContext_set_state {
  int __pyx_n;
  int apply_now;
};
struct __pyx_opt_args_4kivy_8graphics_3fbo_3Fbo_raise_exception;

/* "kivy\graphics\fbo.pxd":25
 *     cdef void delete_fbo(self)
 *     cdef void apply(self)
 *     cdef void raise_exception(self, str message, int status=?)             # <<<<<<<<<<<<<<
 *     cdef str resolve_status(self, int status)
 *     cdef void reload(self)
 */
struct __pyx_opt_args_4kivy_8graphics_3fbo_3Fbo_raise_exception {
  int __pyx_n;
  int status;
};

/* "kivy\_event.pxd":1
 * cdef class ObjectWithUid(object):             # <<<<<<<<<<<<<<
 *     cdef readonly int uid
 * 
 */
struct __pyx_obj_4kivy_6_event_ObjectWithUid {
  PyObject_HEAD
  int uid;
};

struct __pyx_obj_4kivy_8graphics_12instructions_Instruction {
  struct __pyx_obj_4kivy_6_event_ObjectWithUid __pyx_base;
  struct __pyx_vtabstruct_4kivy_8graphics_12instructions_Instruction *__pyx_vtab;
  int flags;
  PyObject *group;
  struct __pyx_obj_4kivy_8graphics_12instructions_InstructionGroup *parent;
  PyObject *__weakref__;
  PyObject *__pyx___proxy_ref;
};


/* "kivy\graphics\instructions.pxd":3
 * cdef class Instruction
 * cdef class InstructionGroup
 * cdef class ContextInstruction             # <<<<<<<<<<<<<<
 * cdef class VertexInstruction
 * cdef class CanvasBase
 */
struct __pyx_obj_4kivy_8graphics_12instructions_ContextInstruction {
  struct __pyx_obj_4kivy_8graphics_12instructions_Instruction __pyx_base;
  PyObject *context_state;
  PyObject *context_push;
  PyObject *context_pop;
};


/* "context_instructions.pxd":45
 *     cdef void apply(self)
 * 
 * cdef class UpdateNormalMatrix(ContextInstruction):             # <<<<<<<<<<<<<<
 *     cdef void apply(self)
 * 
 */
struct __pyx_obj_4kivy_8graphics_20context_instructions_UpdateNormalMatrix {
  struct __pyx_obj_4kivy_8graphics_12instructions_ContextInstruction __pyx_base;
};


/* "kivy\graphics\texture.pxd":3
 * from c_opengl cimport GLuint
 * 
 * cdef class Texture:             # <<<<<<<<<<<<<<
 *     cdef object __weakref__
 *     cdef unsigned int flags
 */
struct __pyx_obj_4kivy_8graphics_7texture_Texture {
  PyObject_HEAD
  struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *__pyx_vtab;
  PyObject *__weakref__;
  unsigned int flags;
  PyObject *_source;
  float _tex_coords[8];
  int _width;
  int _height;
  GLuint _target;
  GLuint _id;
  int _mipmap;
  PyObject *_wrap;
  PyObject *_min_filter;
  PyObject *_mag_filter;
  int _rectangle;
  PyObject *_colorfmt;
  PyObject *_bufferfmt;
  float _uvx;
  float _uvy;
  float _uvw;
  float _uvh;
  int _is_allocated;
  int _nofree;
  PyObject *observers;
  PyObject *_proxyimage;
  PyObject *_callback;
};


/* "kivy\graphics\context.pxd":7
 * from kivy.graphics.fbo cimport Fbo
 * 
 * cdef class Context:             # <<<<<<<<<<<<<<
 *     cdef list observers
 *     cdef list observers_before
 */
struct __pyx_obj_4kivy_8graphics_7context_Context {
  PyObject_HEAD
  struct __pyx_vtabstruct_4kivy_8graphics_7context_Context *__pyx_vtab;
  PyObject *observers;
  PyObject *observers_before;
  PyObject *l_texture;
  PyObject *l_canvas;
  PyObject *l_vbo;
  PyObject *l_vertexbatch;
  PyObject *l_shader;
  PyObject *l_fbo;
  PyObject *lr_texture;
  PyObject *lr_canvas;
  PyObject *lr_vbo;
  PyObject *lr_fbo_rb;
  PyObject *lr_fbo_fb;
  PyObject *trigger_gl_dealloc;
};


/* "context_instructions.pxd":48
 *     cdef void apply(self)
 * 
 * cdef class MatrixInstruction(ContextInstruction):             # <<<<<<<<<<<<<<
 *     cdef object _stack
 *     cdef Matrix _matrix
 */
struct __pyx_obj_4kivy_8graphics_20context_instructions_MatrixInstruction {
  struct __pyx_obj_4kivy_8graphics_12instructions_ContextInstruction __pyx_base;
  PyObject *_stack;
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *_matrix;
};


/* "context_instructions.pxd":53
 *     cdef void apply(self)
 * 
 * cdef class Transform(MatrixInstruction):             # <<<<<<<<<<<<<<
 *     cpdef transform(self, Matrix trans)
 *     cpdef translate(self, float tx, float ty, float tz)
 */
struct __pyx_obj_4kivy_8graphics_20context_instructions_Transform {
  struct __pyx_obj_4kivy_8graphics_20context_instructions_MatrixInstruction __pyx_base;
};


/* "context_instructions.pxd":60
 *     cpdef identity(self)
 * 
 * cdef class Rotate(Transform):             # <<<<<<<<<<<<<<
 *     cdef float _angle
 *     cdef tuple _axis
 */
struct __pyx_obj_4kivy_8graphics_20context_instructions_Rotate {
  struct __pyx_obj_4kivy_8graphics_20context_instructions_Transform __pyx_base;
  float _angle;
  PyObject *_axis;
  PyObject *_origin;
};


/* "context_instructions.pxd":31
 * 
 * 
 * cdef class LoadIdentity(ContextInstruction):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
struct __pyx_obj_4kivy_8graphics_20context_instructions_LoadIdentity {
  struct __pyx_obj_4kivy_8graphics_12instructions_ContextInstruction __pyx_base;
};


/* "context_instructions.pxd":1
 * cdef class LineWidth             # <<<<<<<<<<<<<<
 * cdef class Color
 * cdef class BindTexture
 */
struct __pyx_obj_4kivy_8graphics_20context_instructions_LineWidth {
  struct __pyx_obj_4kivy_8graphics_12instructions_ContextInstruction __pyx_base;
};


/* "kivy\_event.pxd":4
 *     cdef readonly int uid
 * 
 * cdef class EventDispatcher(ObjectWithUid):             # <<<<<<<<<<<<<<
 *     cdef dict __event_stack
 *     cdef dict __properties
 */
struct __pyx_obj_4kivy_6_event_EventDispatcher {
  struct __pyx_obj_4kivy_6_event_ObjectWithUid __pyx_base;
  struct __pyx_vtabstruct_4kivy_6_event_EventDispatcher *__pyx_vtab;
  PyObject *__pyx___event_stack;
  PyObject *__pyx___properties;
  PyObject *__pyx___storage;
  PyObject *__weakref__;
};


/* "context_instructions.pxd":67
 *     cdef void compute(self)
 * 
 * cdef class Scale(Transform):             # <<<<<<<<<<<<<<
 *     cdef float _x, _y, _z
 *     cdef void apply(self)
 */
struct __pyx_obj_4kivy_8graphics_20context_instructions_Scale {
  struct __pyx_obj_4kivy_8graphics_20context_instructions_Transform __pyx_base;
  float _x;
  float _y;
  float _z;
};


/* "context_instructions.pxd":37
 *     cdef void apply(self)
 * 
 * cdef class PopMatrix(ContextInstruction):             # <<<<<<<<<<<<<<
 *     cdef void apply(self)
 * 
 */
struct __pyx_obj_4kivy_8graphics_20context_instructions_PopMatrix {
  struct __pyx_obj_4kivy_8graphics_12instructions_ContextInstruction __pyx_base;
};


/* "kivy\graphics\instructions.pxd":2
 * cdef class Instruction
 * cdef class InstructionGroup             # <<<<<<<<<<<<<<
 * cdef class ContextInstruction
 * cdef class VertexInstruction
 */
struct __pyx_obj_4kivy_8graphics_12instructions_InstructionGroup {
  struct __pyx_obj_4kivy_8graphics_12instructions_Instruction __pyx_base;
  PyObject *children;
  struct __pyx_obj_4kivy_8graphics_12instructions_InstructionGroup *compiled_children;
  struct __pyx_obj_4kivy_8graphics_8compiler_GraphicsCompiler *compiler;
};


/* "kivy\graphics\instructions.pxd":5
 * cdef class ContextInstruction
 * cdef class VertexInstruction
 * cdef class CanvasBase             # <<<<<<<<<<<<<<
 * cdef class Canvas
 * cdef class RenderContext
 */
struct __pyx_obj_4kivy_8graphics_12instructions_CanvasBase {
  struct __pyx_obj_4kivy_8graphics_12instructions_InstructionGroup __pyx_base;
};

struct __pyx_obj_4kivy_8graphics_6shader_ShaderSource {
  PyObject_HEAD
  struct __pyx_vtabstruct_4kivy_8graphics_6shader_ShaderSource *__pyx_vtab;
  int shader;
  int shadertype;
};


/* "context_instructions.pxd":34
 *     pass
 * 
 * cdef class PushMatrix(ContextInstruction):             # <<<<<<<<<<<<<<
 *     cdef void apply(self)
 * 
 */
struct __pyx_obj_4kivy_8graphics_20context_instructions_PushMatrix {
  struct __pyx_obj_4kivy_8graphics_12instructions_ContextInstruction __pyx_base;
};


/* "kivy\graphics\texture.pxd":42
 *     cpdef bind(self)
 * 
 * cdef class TextureRegion(Texture):             # <<<<<<<<<<<<<<
 *     cdef int x
 *     cdef int y
 */
struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion {
  struct __pyx_obj_4kivy_8graphics_7texture_Texture __pyx_base;
  int x;
  int y;
  struct __pyx_obj_4kivy_8graphics_7texture_Texture *owner;
};


/* "vbo.pxd":7
 * cdef VertexFormat default_vertex
 * 
 * cdef class VBO:             # <<<<<<<<<<<<<<
 *     cdef object __weakref__
 * 
 */
struct __pyx_obj_4kivy_8graphics_3vbo_VBO {
  PyObject_HEAD
  struct __pyx_vtabstruct_4kivy_8graphics_3vbo_VBO *__pyx_vtab;
  PyObject *__weakref__;
  GLuint id;
  int usage;
  int target;
  __pyx_t_4kivy_8graphics_6vertex_vertex_attr_t *format;
  int format_count;
  int format_size;
  struct __pyx_obj_4kivy_8graphics_6buffer_Buffer *data;
  short flags;
  int vbo_size;
  struct __pyx_obj_4kivy_8graphics_6vertex_VertexFormat *vertex_format;
};


/* "context_instructions.pxd":12
 *     pass
 * 
 * cdef class ChangeState(ContextInstruction):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
struct __pyx_obj_4kivy_8graphics_20context_instructions_ChangeState {
  struct __pyx_obj_4kivy_8graphics_12instructions_ContextInstruction __pyx_base;
};


/* "vertex.pxd":15
 *     int per_vertex
 * 
 * cdef class VertexFormat:             # <<<<<<<<<<<<<<
 *     cdef vertex_attr_t *vattr
 *     cdef int vattr_count
 */
struct __pyx_obj_4kivy_8graphics_6vertex_VertexFormat {
  PyObject_HEAD
  __pyx_t_4kivy_8graphics_6vertex_vertex_attr_t *vattr;
  int vattr_count;
  unsigned int vsize;
  unsigned int vbytesize;
  PyObject *last_shader;
};

struct __pyx_obj_4kivy_8graphics_20context_instructions_PopState {
  struct __pyx_obj_4kivy_8graphics_12instructions_ContextInstruction __pyx_base;
};


/* "context_instructions.pxd":72
 *     cdef set_scale(self, double x, double y, double z)
 * 
 * cdef class Translate(Transform):             # <<<<<<<<<<<<<<
 *     cdef double _x, _y, _z
 *     cdef void apply(self)
 */
struct __pyx_obj_4kivy_8graphics_20context_instructions_Translate {
  struct __pyx_obj_4kivy_8graphics_20context_instructions_Transform __pyx_base;
  double _x;
  double _y;
  double _z;
};


/* "vbo.pxd":31
 * 
 * 
 * cdef class VertexBatch:             # <<<<<<<<<<<<<<
 *     cdef object __weakref__
 * 
 */
struct __pyx_obj_4kivy_8graphics_3vbo_VertexBatch {
  PyObject_HEAD
  struct __pyx_vtabstruct_4kivy_8graphics_3vbo_VertexBatch *__pyx_vtab;
  PyObject *__weakref__;
  struct __pyx_obj_4kivy_8graphics_3vbo_VBO *vbo;
  struct __pyx_obj_4kivy_8graphics_6buffer_Buffer *elements;
  struct __pyx_obj_4kivy_8graphics_6buffer_Buffer *vbo_index;
  GLuint mode;
  PyObject *mode_str;
  GLuint id;
  int usage;
  short flags;
  int elements_size;
};


/* "shader.pxd":13
 *     cdef int is_compiled(self)
 * 
 * cdef class Shader:             # <<<<<<<<<<<<<<
 *     cdef object __weakref__
 * 
 */
struct __pyx_obj_4kivy_8graphics_6shader_Shader {
  PyObject_HEAD
  struct __pyx_vtabstruct_4kivy_8graphics_6shader_Shader *__pyx_vtab;
  PyObject *__weakref__;
  int _success;
  struct __pyx_obj_4kivy_8graphics_6vertex_VertexFormat *_current_vertex_format;
  int program;
  struct __pyx_obj_4kivy_8graphics_6shader_ShaderSource *vertex_shader;
  struct __pyx_obj_4kivy_8graphics_6shader_ShaderSource *fragment_shader;
  PyObject *_source;
  PyObject *vert_src;
  PyObject *frag_src;
  PyObject *uniform_locations;
  PyObject *uniform_values;
};


/* "context_instructions.pxd":3
 * cdef class LineWidth
 * cdef class Color
 * cdef class BindTexture             # <<<<<<<<<<<<<<
 * 
 * from transformation cimport Matrix
 */
struct __pyx_obj_4kivy_8graphics_20context_instructions_BindTexture {
  struct __pyx_obj_4kivy_8graphics_12instructions_ContextInstruction __pyx_base;
  int _index;
  PyObject *_source;
  struct __pyx_obj_4kivy_8graphics_7texture_Texture *_texture;
};


/* "kivy\graphics\instructions.pxd":6
 * cdef class VertexInstruction
 * cdef class CanvasBase
 * cdef class Canvas             # <<<<<<<<<<<<<<
 * cdef class RenderContext
 * 
 */
struct __pyx_obj_4kivy_8graphics_12instructions_Canvas {
  struct __pyx_obj_4kivy_8graphics_12instructions_CanvasBase __pyx_base;
  float _opacity;
  struct __pyx_obj_4kivy_8graphics_12instructions_CanvasBase *_before;
  struct __pyx_obj_4kivy_8graphics_12instructions_CanvasBase *_after;
};


/* "kivy\graphics\instructions.pxd":7
 * cdef class CanvasBase
 * cdef class Canvas
 * cdef class RenderContext             # <<<<<<<<<<<<<<
 * 
 * from vbo cimport *
 */
struct __pyx_obj_4kivy_8graphics_12instructions_RenderContext {
  struct __pyx_obj_4kivy_8graphics_12instructions_Canvas __pyx_base;
  struct __pyx_obj_4kivy_8graphics_6shader_Shader *_shader;
  PyObject *state_stacks;
  struct __pyx_obj_4kivy_8graphics_7texture_Texture *default_texture;
  PyObject *bind_texture;
  int _use_parent_projection;
  int _use_parent_modelview;
};


/* "buffer.pxd":1
 * cdef class Buffer:             # <<<<<<<<<<<<<<
 *     cdef void *data
 *     cdef int *l_free
 */
struct __pyx_obj_4kivy_8graphics_6buffer_Buffer {
  PyObject_HEAD
  struct __pyx_vtabstruct_4kivy_8graphics_6buffer_Buffer *__pyx_vtab;
  void *data;
  int *l_free;
  int i_free;
  int block_size;
  int block_count;
};


/* "kivy\graphics\instructions.pxd":72
 *     cdef void build(self)
 * 
 * cdef class Callback(Instruction):             # <<<<<<<<<<<<<<
 *     cdef Shader _shader
 *     cdef object func
 */
struct __pyx_obj_4kivy_8graphics_12instructions_Callback {
  struct __pyx_obj_4kivy_8graphics_12instructions_Instruction __pyx_base;
  struct __pyx_obj_4kivy_8graphics_6shader_Shader *_shader;
  PyObject *func;
  int _reset_context;
};


/* "transformation.pxd":3
 * ctypedef double matrix_t[16]
 * 
 * cdef class Matrix:             # <<<<<<<<<<<<<<
 *     cdef matrix_t mat
 * 
 */
struct __pyx_obj_4kivy_8graphics_14transformation_Matrix {
  PyObject_HEAD
  struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *__pyx_vtab;
  __pyx_t_4kivy_8graphics_14transformation_matrix_t mat;
};


/* "kivy\graphics\fbo.pxd":5
 * from texture cimport Texture
 * 
 * cdef class Fbo(RenderContext):             # <<<<<<<<<<<<<<
 *     cdef int _width
 *     cdef int _height
 */
struct __pyx_obj_4kivy_8graphics_3fbo_Fbo {
  struct __pyx_obj_4kivy_8graphics_12instructions_RenderContext __pyx_base;
  int _width;
  int _height;
  int _depthbuffer_attached;
  int _push_viewport;
  float _clear_color[4];
  GLuint buffer_id;
  GLuint depthbuffer_id;
  GLint _viewport[4];
  struct __pyx_obj_4kivy_8graphics_7texture_Texture *_texture;
  int _is_bound;
  PyObject *observers;
};


/* "context_instructions.pxd":40
 *     cdef void apply(self)
 * 
 * cdef class ApplyContextMatrix(ContextInstruction):             # <<<<<<<<<<<<<<
 *     cdef object _target_stack
 *     cdef object _source_stack
 */
struct __pyx_obj_4kivy_8graphics_20context_instructions_ApplyContextMatrix {
  struct __pyx_obj_4kivy_8graphics_12instructions_ContextInstruction __pyx_base;
  PyObject *_target_stack;
  PyObject *_source_stack;
};


/* "context_instructions.pxd":2
 * cdef class LineWidth
 * cdef class Color             # <<<<<<<<<<<<<<
 * cdef class BindTexture
 * 
 */
struct __pyx_obj_4kivy_8graphics_20context_instructions_Color {
  struct __pyx_obj_4kivy_8graphics_12instructions_ContextInstruction __pyx_base;
};


/* "compiler.pxd":1
 * cdef class GraphicsCompiler             # <<<<<<<<<<<<<<
 * 
 * from instructions cimport InstructionGroup
 */
struct __pyx_obj_4kivy_8graphics_8compiler_GraphicsCompiler {
  PyObject_HEAD
  struct __pyx_vtabstruct_4kivy_8graphics_8compiler_GraphicsCompiler *__pyx_vtab;
};


/* "context_instructions.pxd":9
 * from texture cimport Texture
 * 
 * cdef class PushState(ContextInstruction):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
struct __pyx_obj_4kivy_8graphics_20context_instructions_PushState {
  struct __pyx_obj_4kivy_8graphics_12instructions_ContextInstruction __pyx_base;
};


/* "kivy\graphics\instructions.pxd":4
 * cdef class InstructionGroup
 * cdef class ContextInstruction
 * cdef class VertexInstruction             # <<<<<<<<<<<<<<
 * cdef class CanvasBase
 * cdef class Canvas
 */
struct __pyx_obj_4kivy_8graphics_12instructions_VertexInstruction {
  struct __pyx_obj_4kivy_8graphics_12instructions_Instruction __pyx_base;
  struct __pyx_obj_4kivy_8graphics_20context_instructions_BindTexture *texture_binding;
  struct __pyx_obj_4kivy_8graphics_3vbo_VertexBatch *batch;
  PyObject *_tex_coords;
};



/* "kivy\graphics\instructions.pxd":1
 * cdef class Instruction             # <<<<<<<<<<<<<<
 * cdef class InstructionGroup
 * cdef class ContextInstruction
 */

struct __pyx_vtabstruct_4kivy_8graphics_12instructions_Instruction {
  void (*apply)(struct __pyx_obj_4kivy_8graphics_12instructions_Instruction *);
  void (*flag_update)(struct __pyx_obj_4kivy_8graphics_12instructions_Instruction *, struct __pyx_opt_args_4kivy_8graphics_12instructions_11Instruction_flag_update *__pyx_optional_args);
  void (*flag_update_done)(struct __pyx_obj_4kivy_8graphics_12instructions_Instruction *);
  void (*set_parent)(struct __pyx_obj_4kivy_8graphics_12instructions_Instruction *, struct __pyx_obj_4kivy_8graphics_12instructions_Instruction *);
  void (*reload)(struct __pyx_obj_4kivy_8graphics_12instructions_Instruction *);
  void (*radd)(struct __pyx_obj_4kivy_8graphics_12instructions_Instruction *, struct __pyx_obj_4kivy_8graphics_12instructions_InstructionGroup *);
  void (*rinsert)(struct __pyx_obj_4kivy_8graphics_12instructions_Instruction *, struct __pyx_obj_4kivy_8graphics_12instructions_InstructionGroup *, int);
  void (*rremove)(struct __pyx_obj_4kivy_8graphics_12instructions_Instruction *, struct __pyx_obj_4kivy_8graphics_12instructions_InstructionGroup *);
};
static struct __pyx_vtabstruct_4kivy_8graphics_12instructions_Instruction *__pyx_vtabptr_4kivy_8graphics_12instructions_Instruction;


/* "kivy\graphics\instructions.pxd":3
 * cdef class Instruction
 * cdef class InstructionGroup
 * cdef class ContextInstruction             # <<<<<<<<<<<<<<
 * cdef class VertexInstruction
 * cdef class CanvasBase
 */

struct __pyx_vtabstruct_4kivy_8graphics_12instructions_ContextInstruction {
  struct __pyx_vtabstruct_4kivy_8graphics_12instructions_Instruction __pyx_base;
  struct __pyx_obj_4kivy_8graphics_12instructions_RenderContext *(*get_context)(struct __pyx_obj_4kivy_8graphics_12instructions_ContextInstruction *);
  void (*set_state)(struct __pyx_obj_4kivy_8graphics_12instructions_ContextInstruction *, PyObject *, PyObject *);
  void (*push_state)(struct __pyx_obj_4kivy_8graphics_12instructions_ContextInstruction *, PyObject *);
  void (*pop_state)(struct __pyx_obj_4kivy_8graphics_12instructions_ContextInstruction *, PyObject *);
};
static struct __pyx_vtabstruct_4kivy_8graphics_12instructions_ContextInstruction *__pyx_vtabptr_4kivy_8graphics_12instructions_ContextInstruction;


/* "context_instructions.pxd":45
 *     cdef void apply(self)
 * 
 * cdef class UpdateNormalMatrix(ContextInstruction):             # <<<<<<<<<<<<<<
 *     cdef void apply(self)
 * 
 */

struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_UpdateNormalMatrix {
  struct __pyx_vtabstruct_4kivy_8graphics_12instructions_ContextInstruction __pyx_base;
  void (*apply)(struct __pyx_obj_4kivy_8graphics_20context_instructions_UpdateNormalMatrix *);
};
static struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_UpdateNormalMatrix *__pyx_vtabptr_4kivy_8graphics_20context_instructions_UpdateNormalMatrix;


/* "context_instructions.pxd":34
 *     pass
 * 
 * cdef class PushMatrix(ContextInstruction):             # <<<<<<<<<<<<<<
 *     cdef void apply(self)
 * 
 */

struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_PushMatrix {
  struct __pyx_vtabstruct_4kivy_8graphics_12instructions_ContextInstruction __pyx_base;
  void (*apply)(struct __pyx_obj_4kivy_8graphics_20context_instructions_PushMatrix *);
};
static struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_PushMatrix *__pyx_vtabptr_4kivy_8graphics_20context_instructions_PushMatrix;


/* "context_instructions.pxd":48
 *     cdef void apply(self)
 * 
 * cdef class MatrixInstruction(ContextInstruction):             # <<<<<<<<<<<<<<
 *     cdef object _stack
 *     cdef Matrix _matrix
 */

struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_MatrixInstruction {
  struct __pyx_vtabstruct_4kivy_8graphics_12instructions_ContextInstruction __pyx_base;
  void (*apply)(struct __pyx_obj_4kivy_8graphics_20context_instructions_MatrixInstruction *);
};
static struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_MatrixInstruction *__pyx_vtabptr_4kivy_8graphics_20context_instructions_MatrixInstruction;


/* "context_instructions.pxd":53
 *     cdef void apply(self)
 * 
 * cdef class Transform(MatrixInstruction):             # <<<<<<<<<<<<<<
 *     cpdef transform(self, Matrix trans)
 *     cpdef translate(self, float tx, float ty, float tz)
 */

struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Transform {
  struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_MatrixInstruction __pyx_base;
  PyObject *(*transform)(struct __pyx_obj_4kivy_8graphics_20context_instructions_Transform *, struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, int __pyx_skip_dispatch);
  PyObject *(*translate)(struct __pyx_obj_4kivy_8graphics_20context_instructions_Transform *, float, float, float, int __pyx_skip_dispatch);
  PyObject *(*rotate)(struct __pyx_obj_4kivy_8graphics_20context_instructions_Transform *, float, float, float, float, int __pyx_skip_dispatch);
  PyObject *(*scale)(struct __pyx_obj_4kivy_8graphics_20context_instructions_Transform *, float, int __pyx_skip_dispatch);
  PyObject *(*identity)(struct __pyx_obj_4kivy_8graphics_20context_instructions_Transform *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Transform *__pyx_vtabptr_4kivy_8graphics_20context_instructions_Transform;


/* "context_instructions.pxd":72
 *     cdef set_scale(self, double x, double y, double z)
 * 
 * cdef class Translate(Transform):             # <<<<<<<<<<<<<<
 *     cdef double _x, _y, _z
 *     cdef void apply(self)
 */

struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Translate {
  struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Transform __pyx_base;
  PyObject *(*set_translate)(struct __pyx_obj_4kivy_8graphics_20context_instructions_Translate *, double, double, double);
};
static struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Translate *__pyx_vtabptr_4kivy_8graphics_20context_instructions_Translate;


/* "vbo.pxd":31
 * 
 * 
 * cdef class VertexBatch:             # <<<<<<<<<<<<<<
 *     cdef object __weakref__
 * 
 */

struct __pyx_vtabstruct_4kivy_8graphics_3vbo_VertexBatch {
  void (*clear_data)(struct __pyx_obj_4kivy_8graphics_3vbo_VertexBatch *);
  void (*set_data)(struct __pyx_obj_4kivy_8graphics_3vbo_VertexBatch *, void *, int, unsigned short *, int);
  void (*append_data)(struct __pyx_obj_4kivy_8graphics_3vbo_VertexBatch *, void *, int, unsigned short *, int);
  void (*draw)(struct __pyx_obj_4kivy_8graphics_3vbo_VertexBatch *);
  void (*set_mode)(struct __pyx_obj_4kivy_8graphics_3vbo_VertexBatch *, PyObject *);
  PyObject *(*get_mode)(struct __pyx_obj_4kivy_8graphics_3vbo_VertexBatch *);
  int (*count)(struct __pyx_obj_4kivy_8graphics_3vbo_VertexBatch *);
  void (*reload)(struct __pyx_obj_4kivy_8graphics_3vbo_VertexBatch *);
  int (*have_id)(struct __pyx_obj_4kivy_8graphics_3vbo_VertexBatch *);
};
static struct __pyx_vtabstruct_4kivy_8graphics_3vbo_VertexBatch *__pyx_vtabptr_4kivy_8graphics_3vbo_VertexBatch;


/* "kivy\graphics\instructions.pxd":2
 * cdef class Instruction
 * cdef class InstructionGroup             # <<<<<<<<<<<<<<
 * cdef class ContextInstruction
 * cdef class VertexInstruction
 */

struct __pyx_vtabstruct_4kivy_8graphics_12instructions_InstructionGroup {
  struct __pyx_vtabstruct_4kivy_8graphics_12instructions_Instruction __pyx_base;
  void (*build)(struct __pyx_obj_4kivy_8graphics_12instructions_InstructionGroup *);
  PyObject *(*add)(struct __pyx_obj_4kivy_8graphics_12instructions_InstructionGroup *, struct __pyx_obj_4kivy_8graphics_12instructions_Instruction *, int __pyx_skip_dispatch);
  PyObject *(*insert)(struct __pyx_obj_4kivy_8graphics_12instructions_InstructionGroup *, int, struct __pyx_obj_4kivy_8graphics_12instructions_Instruction *, int __pyx_skip_dispatch);
  PyObject *(*remove)(struct __pyx_obj_4kivy_8graphics_12instructions_InstructionGroup *, struct __pyx_obj_4kivy_8graphics_12instructions_Instruction *, int __pyx_skip_dispatch);
  PyObject *(*clear)(struct __pyx_obj_4kivy_8graphics_12instructions_InstructionGroup *, int __pyx_skip_dispatch);
  PyObject *(*remove_group)(struct __pyx_obj_4kivy_8graphics_12instructions_InstructionGroup *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*get_group)(struct __pyx_obj_4kivy_8graphics_12instructions_InstructionGroup *, PyObject *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4kivy_8graphics_12instructions_InstructionGroup *__pyx_vtabptr_4kivy_8graphics_12instructions_InstructionGroup;


/* "kivy\graphics\instructions.pxd":5
 * cdef class ContextInstruction
 * cdef class VertexInstruction
 * cdef class CanvasBase             # <<<<<<<<<<<<<<
 * cdef class Canvas
 * cdef class RenderContext
 */

struct __pyx_vtabstruct_4kivy_8graphics_12instructions_CanvasBase {
  struct __pyx_vtabstruct_4kivy_8graphics_12instructions_InstructionGroup __pyx_base;
};
static struct __pyx_vtabstruct_4kivy_8graphics_12instructions_CanvasBase *__pyx_vtabptr_4kivy_8graphics_12instructions_CanvasBase;


/* "kivy\graphics\instructions.pxd":6
 * cdef class VertexInstruction
 * cdef class CanvasBase
 * cdef class Canvas             # <<<<<<<<<<<<<<
 * cdef class RenderContext
 * 
 */

struct __pyx_vtabstruct_4kivy_8graphics_12instructions_Canvas {
  struct __pyx_vtabstruct_4kivy_8graphics_12instructions_CanvasBase __pyx_base;
  PyObject *(*draw)(struct __pyx_obj_4kivy_8graphics_12instructions_Canvas *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4kivy_8graphics_12instructions_Canvas *__pyx_vtabptr_4kivy_8graphics_12instructions_Canvas;


/* "kivy\graphics\instructions.pxd":4
 * cdef class InstructionGroup
 * cdef class ContextInstruction
 * cdef class VertexInstruction             # <<<<<<<<<<<<<<
 * cdef class CanvasBase
 * cdef class Canvas
 */

struct __pyx_vtabstruct_4kivy_8graphics_12instructions_VertexInstruction {
  struct __pyx_vtabstruct_4kivy_8graphics_12instructions_Instruction __pyx_base;
  void (*build)(struct __pyx_obj_4kivy_8graphics_12instructions_VertexInstruction *);
};
static struct __pyx_vtabstruct_4kivy_8graphics_12instructions_VertexInstruction *__pyx_vtabptr_4kivy_8graphics_12instructions_VertexInstruction;


/* "context_instructions.pxd":40
 *     cdef void apply(self)
 * 
 * cdef class ApplyContextMatrix(ContextInstruction):             # <<<<<<<<<<<<<<
 *     cdef object _target_stack
 *     cdef object _source_stack
 */

struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_ApplyContextMatrix {
  struct __pyx_vtabstruct_4kivy_8graphics_12instructions_ContextInstruction __pyx_base;
  void (*apply)(struct __pyx_obj_4kivy_8graphics_20context_instructions_ApplyContextMatrix *);
};
static struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_ApplyContextMatrix *__pyx_vtabptr_4kivy_8graphics_20context_instructions_ApplyContextMatrix;


/* "context_instructions.pxd":3
 * cdef class LineWidth
 * cdef class Color
 * cdef class BindTexture             # <<<<<<<<<<<<<<
 * 
 * from transformation cimport Matrix
 */

struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_BindTexture {
  struct __pyx_vtabstruct_4kivy_8graphics_12instructions_ContextInstruction __pyx_base;
  void (*apply)(struct __pyx_obj_4kivy_8graphics_20context_instructions_BindTexture *);
};
static struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_BindTexture *__pyx_vtabptr_4kivy_8graphics_20context_instructions_BindTexture;


/* "context_instructions.pxd":1
 * cdef class LineWidth             # <<<<<<<<<<<<<<
 * cdef class Color
 * cdef class BindTexture
 */

struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_LineWidth {
  struct __pyx_vtabstruct_4kivy_8graphics_12instructions_ContextInstruction __pyx_base;
  void (*apply)(struct __pyx_obj_4kivy_8graphics_20context_instructions_LineWidth *);
};
static struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_LineWidth *__pyx_vtabptr_4kivy_8graphics_20context_instructions_LineWidth;


/* "shader.pxd":13
 *     cdef int is_compiled(self)
 * 
 * cdef class Shader:             # <<<<<<<<<<<<<<
 *     cdef object __weakref__
 * 
 */

struct __pyx_vtabstruct_4kivy_8graphics_6shader_Shader {
  void (*use)(struct __pyx_obj_4kivy_8graphics_6shader_Shader *);
  void (*stop)(struct __pyx_obj_4kivy_8graphics_6shader_Shader *);
  void (*set_uniform)(struct __pyx_obj_4kivy_8graphics_6shader_Shader *, PyObject *, PyObject *);
  void (*upload_uniform)(struct __pyx_obj_4kivy_8graphics_6shader_Shader *, PyObject *, PyObject *);
  void (*upload_uniform_matrix)(struct __pyx_obj_4kivy_8graphics_6shader_Shader *, int, struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *);
  int (*get_uniform_loc)(struct __pyx_obj_4kivy_8graphics_6shader_Shader *, PyObject *);
  void (*build)(struct __pyx_obj_4kivy_8graphics_6shader_Shader *);
  void (*build_vertex)(struct __pyx_obj_4kivy_8graphics_6shader_Shader *, struct __pyx_opt_args_4kivy_8graphics_6shader_6Shader_build_vertex *__pyx_optional_args);
  void (*build_fragment)(struct __pyx_obj_4kivy_8graphics_6shader_Shader *, struct __pyx_opt_args_4kivy_8graphics_6shader_6Shader_build_fragment *__pyx_optional_args);
  void (*link_program)(struct __pyx_obj_4kivy_8graphics_6shader_Shader *);
  int (*is_linked)(struct __pyx_obj_4kivy_8graphics_6shader_Shader *);
  struct __pyx_obj_4kivy_8graphics_6shader_ShaderSource *(*compile_shader)(struct __pyx_obj_4kivy_8graphics_6shader_Shader *, char *, int);
  PyObject *(*get_program_log)(struct __pyx_obj_4kivy_8graphics_6shader_Shader *, PyObject *);
  void (*process_message)(struct __pyx_obj_4kivy_8graphics_6shader_Shader *, PyObject *, PyObject *);
  void (*reload)(struct __pyx_obj_4kivy_8graphics_6shader_Shader *);
  void (*bind_vertex_format)(struct __pyx_obj_4kivy_8graphics_6shader_Shader *, struct __pyx_obj_4kivy_8graphics_6vertex_VertexFormat *);
};
static struct __pyx_vtabstruct_4kivy_8graphics_6shader_Shader *__pyx_vtabptr_4kivy_8graphics_6shader_Shader;


/* "kivy\graphics\instructions.pxd":7
 * cdef class CanvasBase
 * cdef class Canvas
 * cdef class RenderContext             # <<<<<<<<<<<<<<
 * 
 * from vbo cimport *
 */

struct __pyx_vtabstruct_4kivy_8graphics_12instructions_RenderContext {
  struct __pyx_vtabstruct_4kivy_8graphics_12instructions_Canvas __pyx_base;
  void (*set_texture)(struct __pyx_obj_4kivy_8graphics_12instructions_RenderContext *, int, struct __pyx_obj_4kivy_8graphics_7texture_Texture *);
  void (*set_state)(struct __pyx_obj_4kivy_8graphics_12instructions_RenderContext *, PyObject *, PyObject *, struct __pyx_opt_args_4kivy_8graphics_12instructions_13RenderContext_set_state *__pyx_optional_args);
  PyObject *(*get_state)(struct __pyx_obj_4kivy_8graphics_12instructions_RenderContext *, PyObject *);
  void (*set_states)(struct __pyx_obj_4kivy_8graphics_12instructions_RenderContext *, PyObject *);
  void (*push_state)(struct __pyx_obj_4kivy_8graphics_12instructions_RenderContext *, PyObject *);
  void (*push_states)(struct __pyx_obj_4kivy_8graphics_12instructions_RenderContext *, PyObject *);
  void (*pop_state)(struct __pyx_obj_4kivy_8graphics_12instructions_RenderContext *, PyObject *);
  void (*pop_states)(struct __pyx_obj_4kivy_8graphics_12instructions_RenderContext *, PyObject *);
  void (*enter)(struct __pyx_obj_4kivy_8graphics_12instructions_RenderContext *);
  void (*leave)(struct __pyx_obj_4kivy_8graphics_12instructions_RenderContext *);
};
static struct __pyx_vtabstruct_4kivy_8graphics_12instructions_RenderContext *__pyx_vtabptr_4kivy_8graphics_12instructions_RenderContext;


/* "transformation.pxd":3
 * ctypedef double matrix_t[16]
 * 
 * cdef class Matrix:             # <<<<<<<<<<<<<<
 *     cdef matrix_t mat
 * 
 */

struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix {
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*identity)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, int __pyx_skip_dispatch);
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*inverse)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, int __pyx_skip_dispatch);
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*transpose)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, int __pyx_skip_dispatch);
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*multiply)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, int __pyx_skip_dispatch);
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*scale)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, int __pyx_skip_dispatch);
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*translate)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, int __pyx_skip_dispatch);
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*rotate)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, double, int __pyx_skip_dispatch);
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*view_clip)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, double, double, double, int, int __pyx_skip_dispatch);
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*perspective)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, double, int __pyx_skip_dispatch);
  PyObject *(*look_at)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, double, double, double, double, double, double, int __pyx_skip_dispatch);
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*normal_matrix)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, int __pyx_skip_dispatch);
  PyObject *(*transform_point)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, int __pyx_skip_dispatch, struct __pyx_opt_args_4kivy_8graphics_14transformation_6Matrix_transform_point *__pyx_optional_args);
  PyObject *(*project)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, double, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *__pyx_vtabptr_4kivy_8graphics_14transformation_Matrix;


/* "vbo.pxd":7
 * cdef VertexFormat default_vertex
 * 
 * cdef class VBO:             # <<<<<<<<<<<<<<
 *     cdef object __weakref__
 * 
 */

struct __pyx_vtabstruct_4kivy_8graphics_3vbo_VBO {
  void (*update_buffer)(struct __pyx_obj_4kivy_8graphics_3vbo_VBO *);
  void (*bind)(struct __pyx_obj_4kivy_8graphics_3vbo_VBO *);
  void (*unbind)(struct __pyx_obj_4kivy_8graphics_3vbo_VBO *);
  void (*add_vertex_data)(struct __pyx_obj_4kivy_8graphics_3vbo_VBO *, void *, unsigned short *, int);
  void (*update_vertex_data)(struct __pyx_obj_4kivy_8graphics_3vbo_VBO *, int, void *, int);
  void (*remove_vertex_data)(struct __pyx_obj_4kivy_8graphics_3vbo_VBO *, unsigned short *, int);
  void (*reload)(struct __pyx_obj_4kivy_8graphics_3vbo_VBO *);
  int (*have_id)(struct __pyx_obj_4kivy_8graphics_3vbo_VBO *);
};
static struct __pyx_vtabstruct_4kivy_8graphics_3vbo_VBO *__pyx_vtabptr_4kivy_8graphics_3vbo_VBO;


/* "context_instructions.pxd":60
 *     cpdef identity(self)
 * 
 * cdef class Rotate(Transform):             # <<<<<<<<<<<<<<
 *     cdef float _angle
 *     cdef tuple _axis
 */

struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Rotate {
  struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Transform __pyx_base;
  void (*compute)(struct __pyx_obj_4kivy_8graphics_20context_instructions_Rotate *);
};
static struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Rotate *__pyx_vtabptr_4kivy_8graphics_20context_instructions_Rotate;


/* "kivy\graphics\texture.pyx":586
 * 
 * 
 * cdef class Texture:             # <<<<<<<<<<<<<<
 *     '''Handle a OpenGL texture. This class can be used to create simple texture
 *     or complex texture based on ImageData.'''
 */

struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture {
  void (*update_tex_coords)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *);
  void (*set_min_filter)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, PyObject *);
  void (*set_mag_filter)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, PyObject *);
  void (*set_wrap)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, PyObject *);
  void (*reload)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *);
  void (*_reload_propagate)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, struct __pyx_obj_4kivy_8graphics_7texture_Texture *);
  void (*allocate)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *);
  PyObject *(*flip_vertical)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, int __pyx_skip_dispatch);
  PyObject *(*get_region)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*bind)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *__pyx_vtabptr_4kivy_8graphics_7texture_Texture;


/* "kivy\graphics\texture.pyx":1081
 * 
 * 
 * cdef class TextureRegion(Texture):             # <<<<<<<<<<<<<<
 *     '''Handle a region of a Texture class. Useful for non power-of-2
 *     texture handling.'''
 */

struct __pyx_vtabstruct_4kivy_8graphics_7texture_TextureRegion {
  struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture __pyx_base;
};
static struct __pyx_vtabstruct_4kivy_8graphics_7texture_TextureRegion *__pyx_vtabptr_4kivy_8graphics_7texture_TextureRegion;


/* "context_instructions.pxd":37
 *     cdef void apply(self)
 * 
 * cdef class PopMatrix(ContextInstruction):             # <<<<<<<<<<<<<<
 *     cdef void apply(self)
 * 
 */

struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_PopMatrix {
  struct __pyx_vtabstruct_4kivy_8graphics_12instructions_ContextInstruction __pyx_base;
  void (*apply)(struct __pyx_obj_4kivy_8graphics_20context_instructions_PopMatrix *);
};
static struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_PopMatrix *__pyx_vtabptr_4kivy_8graphics_20context_instructions_PopMatrix;


/* "kivy\graphics\instructions.pxd":72
 *     cdef void build(self)
 * 
 * cdef class Callback(Instruction):             # <<<<<<<<<<<<<<
 *     cdef Shader _shader
 *     cdef object func
 */

struct __pyx_vtabstruct_4kivy_8graphics_12instructions_Callback {
  struct __pyx_vtabstruct_4kivy_8graphics_12instructions_Instruction __pyx_base;
  void (*enter)(struct __pyx_obj_4kivy_8graphics_12instructions_Callback *);
};
static struct __pyx_vtabstruct_4kivy_8graphics_12instructions_Callback *__pyx_vtabptr_4kivy_8graphics_12instructions_Callback;


/* "kivy\_event.pxd":4
 *     cdef readonly int uid
 * 
 * cdef class EventDispatcher(ObjectWithUid):             # <<<<<<<<<<<<<<
 *     cdef dict __event_stack
 *     cdef dict __properties
 */

struct __pyx_vtabstruct_4kivy_6_event_EventDispatcher {
  PyObject *(*properties)(struct __pyx_obj_4kivy_6_event_EventDispatcher *, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4kivy_6_event_EventDispatcher *__pyx_vtabptr_4kivy_6_event_EventDispatcher;


/* "kivy\graphics\fbo.pxd":5
 * from texture cimport Texture
 * 
 * cdef class Fbo(RenderContext):             # <<<<<<<<<<<<<<
 *     cdef int _width
 *     cdef int _height
 */

struct __pyx_vtabstruct_4kivy_8graphics_3fbo_Fbo {
  struct __pyx_vtabstruct_4kivy_8graphics_12instructions_RenderContext __pyx_base;
  PyObject *(*clear_buffer)(struct __pyx_obj_4kivy_8graphics_3fbo_Fbo *, int __pyx_skip_dispatch);
  PyObject *(*bind)(struct __pyx_obj_4kivy_8graphics_3fbo_Fbo *, int __pyx_skip_dispatch);
  PyObject *(*release)(struct __pyx_obj_4kivy_8graphics_3fbo_Fbo *, int __pyx_skip_dispatch);
  void (*create_fbo)(struct __pyx_obj_4kivy_8graphics_3fbo_Fbo *);
  void (*delete_fbo)(struct __pyx_obj_4kivy_8graphics_3fbo_Fbo *);
  void (*raise_exception)(struct __pyx_obj_4kivy_8graphics_3fbo_Fbo *, PyObject *, struct __pyx_opt_args_4kivy_8graphics_3fbo_3Fbo_raise_exception *__pyx_optional_args);
  PyObject *(*resolve_status)(struct __pyx_obj_4kivy_8graphics_3fbo_Fbo *, int);
};
static struct __pyx_vtabstruct_4kivy_8graphics_3fbo_Fbo *__pyx_vtabptr_4kivy_8graphics_3fbo_Fbo;


/* "compiler.pxd":1
 * cdef class GraphicsCompiler             # <<<<<<<<<<<<<<
 * 
 * from instructions cimport InstructionGroup
 */

struct __pyx_vtabstruct_4kivy_8graphics_8compiler_GraphicsCompiler {
  struct __pyx_obj_4kivy_8graphics_12instructions_InstructionGroup *(*compile)(struct __pyx_obj_4kivy_8graphics_8compiler_GraphicsCompiler *, struct __pyx_obj_4kivy_8graphics_12instructions_InstructionGroup *);
};
static struct __pyx_vtabstruct_4kivy_8graphics_8compiler_GraphicsCompiler *__pyx_vtabptr_4kivy_8graphics_8compiler_GraphicsCompiler;


/* "context_instructions.pxd":2
 * cdef class LineWidth
 * cdef class Color             # <<<<<<<<<<<<<<
 * cdef class BindTexture
 * 
 */

struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Color {
  struct __pyx_vtabstruct_4kivy_8graphics_12instructions_ContextInstruction __pyx_base;
  void (*apply)(struct __pyx_obj_4kivy_8graphics_20context_instructions_Color *);
};
static struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Color *__pyx_vtabptr_4kivy_8graphics_20context_instructions_Color;


/* "kivy\graphics\context.pxd":7
 * from kivy.graphics.fbo cimport Fbo
 * 
 * cdef class Context:             # <<<<<<<<<<<<<<
 *     cdef list observers
 *     cdef list observers_before
 */

struct __pyx_vtabstruct_4kivy_8graphics_7context_Context {
  void (*register_texture)(struct __pyx_obj_4kivy_8graphics_7context_Context *, struct __pyx_obj_4kivy_8graphics_7texture_Texture *);
  void (*register_canvas)(struct __pyx_obj_4kivy_8graphics_7context_Context *, struct __pyx_obj_4kivy_8graphics_12instructions_Canvas *);
  void (*register_vbo)(struct __pyx_obj_4kivy_8graphics_7context_Context *, struct __pyx_obj_4kivy_8graphics_3vbo_VBO *);
  void (*register_vertexbatch)(struct __pyx_obj_4kivy_8graphics_7context_Context *, struct __pyx_obj_4kivy_8graphics_3vbo_VertexBatch *);
  void (*register_shader)(struct __pyx_obj_4kivy_8graphics_7context_Context *, struct __pyx_obj_4kivy_8graphics_6shader_Shader *);
  void (*register_fbo)(struct __pyx_obj_4kivy_8graphics_7context_Context *, struct __pyx_obj_4kivy_8graphics_3fbo_Fbo *);
  void (*dealloc_texture)(struct __pyx_obj_4kivy_8graphics_7context_Context *, struct __pyx_obj_4kivy_8graphics_7texture_Texture *);
  void (*dealloc_vbo)(struct __pyx_obj_4kivy_8graphics_7context_Context *, struct __pyx_obj_4kivy_8graphics_3vbo_VBO *);
  void (*dealloc_vertexbatch)(struct __pyx_obj_4kivy_8graphics_7context_Context *, struct __pyx_obj_4kivy_8graphics_3vbo_VertexBatch *);
  void (*dealloc_shader)(struct __pyx_obj_4kivy_8graphics_7context_Context *, struct __pyx_obj_4kivy_8graphics_6shader_Shader *);
  void (*dealloc_fbo)(struct __pyx_obj_4kivy_8graphics_7context_Context *, struct __pyx_obj_4kivy_8graphics_3fbo_Fbo *);
  void (*flush)(struct __pyx_obj_4kivy_8graphics_7context_Context *);
};
static struct __pyx_vtabstruct_4kivy_8graphics_7context_Context *__pyx_vtabptr_4kivy_8graphics_7context_Context;


/* "context_instructions.pxd":67
 *     cdef void compute(self)
 * 
 * cdef class Scale(Transform):             # <<<<<<<<<<<<<<
 *     cdef float _x, _y, _z
 *     cdef void apply(self)
 */

struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Scale {
  struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Transform __pyx_base;
  PyObject *(*set_scale)(struct __pyx_obj_4kivy_8graphics_20context_instructions_Scale *, double, double, double);
};
static struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Scale *__pyx_vtabptr_4kivy_8graphics_20context_instructions_Scale;


/* "buffer.pxd":1
 * cdef class Buffer:             # <<<<<<<<<<<<<<
 *     cdef void *data
 *     cdef int *l_free
 */

struct __pyx_vtabstruct_4kivy_8graphics_6buffer_Buffer {
  void (*clear)(struct __pyx_obj_4kivy_8graphics_6buffer_Buffer *);
  void (*grow)(struct __pyx_obj_4kivy_8graphics_6buffer_Buffer *, int);
  void (*add)(struct __pyx_obj_4kivy_8graphics_6buffer_Buffer *, void *, unsigned short *, int);
  void (*remove)(struct __pyx_obj_4kivy_8graphics_6buffer_Buffer *, unsigned short *, int);
  int (*count)(struct __pyx_obj_4kivy_8graphics_6buffer_Buffer *);
  int (*size)(struct __pyx_obj_4kivy_8graphics_6buffer_Buffer *);
  void *(*pointer)(struct __pyx_obj_4kivy_8graphics_6buffer_Buffer *);
  void *(*offset_pointer)(struct __pyx_obj_4kivy_8graphics_6buffer_Buffer *, int);
  void (*update)(struct __pyx_obj_4kivy_8graphics_6buffer_Buffer *, int, void *, int);
};
static struct __pyx_vtabstruct_4kivy_8graphics_6buffer_Buffer *__pyx_vtabptr_4kivy_8graphics_6buffer_Buffer;


/* "shader.pxd":5
 * from vertex cimport VertexFormat
 * 
 * cdef class ShaderSource:             # <<<<<<<<<<<<<<
 *     cdef int shader
 *     cdef int shadertype
 */

struct __pyx_vtabstruct_4kivy_8graphics_6shader_ShaderSource {
  PyObject *(*set_source)(struct __pyx_obj_4kivy_8graphics_6shader_ShaderSource *, char *);
  PyObject *(*get_shader_log)(struct __pyx_obj_4kivy_8graphics_6shader_ShaderSource *, int);
  void (*process_message)(struct __pyx_obj_4kivy_8graphics_6shader_ShaderSource *, PyObject *, PyObject *);
  int (*is_compiled)(struct __pyx_obj_4kivy_8graphics_6shader_ShaderSource *);
};
static struct __pyx_vtabstruct_4kivy_8graphics_6shader_ShaderSource *__pyx_vtabptr_4kivy_8graphics_6shader_ShaderSource;
#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
          if (acquire_gil) { \
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
              PyGILState_Release(__pyx_gilstate_save); \
          } else { \
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
          }
#else
  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
  #define __Pyx_RefNannyFinishContext() \
          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name, acquire_gil)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif /* CYTHON_REFNANNY */
#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro))
        return tp->tp_getattro(obj, attr_name);
#if PY_MAJOR_VERSION < 3
    if (likely(tp->tp_getattr))
        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
#endif
    return PyObject_GetAttr(obj, attr_name);
}
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

static PyObject *__Pyx_GetBuiltinName(PyObject *name); /*proto*/

#if PY_MAJOR_VERSION >= 3
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
    PyObject *value;
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (!PyErr_Occurred()) {
            PyObject* args = PyTuple_Pack(1, key);
            if (likely(args))
                PyErr_SetObject(PyExc_KeyError, args);
            Py_XDECREF(args);
        }
        return NULL;
    }
    Py_INCREF(value);
    return value;
}
#else
    #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#endif

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/

static void __Pyx_WriteUnraisable(const char *name, int clineno,
                                  int lineno, const char *filename); /*proto*/

static int __Pyx_PyBytes_SingleTailmatch(PyObject* self, PyObject* arg, Py_ssize_t start,
                                         Py_ssize_t end, int direction)
{
    const char* self_ptr = PyBytes_AS_STRING(self);
    Py_ssize_t self_len = PyBytes_GET_SIZE(self);
    const char* sub_ptr;
    Py_ssize_t sub_len;
    int retval;
#if PY_VERSION_HEX >= 0x02060000
    Py_buffer view;
    view.obj = NULL;
#endif
    if ( PyBytes_Check(arg) ) {
        sub_ptr = PyBytes_AS_STRING(arg);
        sub_len = PyBytes_GET_SIZE(arg);
    }
#if PY_MAJOR_VERSION < 3
    else if ( PyUnicode_Check(arg) ) {
        return PyUnicode_Tailmatch(self, arg, start, end, direction);
    }
#endif
    else {
#if PY_VERSION_HEX < 0x02060000
        if (unlikely(PyObject_AsCharBuffer(arg, &sub_ptr, &sub_len)))
            return -1;
#else
        if (unlikely(PyObject_GetBuffer(self, &view, PyBUF_SIMPLE) == -1))
            return -1;
        sub_ptr = (const char*) view.buf;
        sub_len = view.len;
#endif
    }
    if (end > self_len)
        end = self_len;
    else if (end < 0)
        end += self_len;
    if (end < 0)
        end = 0;
    if (start < 0)
        start += self_len;
    if (start < 0)
        start = 0;
    if (direction > 0) {
        if (end-sub_len > start)
            start = end - sub_len;
    }
    if (start + sub_len <= end)
        retval = !memcmp(self_ptr+start, sub_ptr, sub_len);
    else
        retval = 0;
#if PY_VERSION_HEX >= 0x02060000
    if (view.obj)
        PyBuffer_Release(&view);
#endif
    return retval;
}
static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr, Py_ssize_t start,
                                   Py_ssize_t end, int direction)
{
    if (unlikely(PyTuple_Check(substr))) {
        Py_ssize_t i, count = PyTuple_GET_SIZE(substr);
        for (i = 0; i < count; i++) {
            int result;
#if CYTHON_COMPILING_IN_CPYTHON
            result = __Pyx_PyBytes_SingleTailmatch(self, PyTuple_GET_ITEM(substr, i),
                                                   start, end, direction);
#else
            PyObject* sub = PySequence_GetItem(substr, i);
            if (unlikely(!sub)) return -1;
            result = __Pyx_PyBytes_SingleTailmatch(self, sub, start, end, direction);
            Py_DECREF(sub);
#endif
            if (result) {
                return result;
            }
        }
        return 0;
    }
    return __Pyx_PyBytes_SingleTailmatch(self, substr, start, end, direction);
}

static int __Pyx_PyUnicode_Tailmatch(PyObject* s, PyObject* substr,
                                     Py_ssize_t start, Py_ssize_t end, int direction) {
    if (unlikely(PyTuple_Check(substr))) {
        Py_ssize_t i, count = PyTuple_GET_SIZE(substr);
        for (i = 0; i < count; i++) {
            int result;
#if CYTHON_COMPILING_IN_CPYTHON
            result = PyUnicode_Tailmatch(s, PyTuple_GET_ITEM(substr, i),
                                         start, end, direction);
#else
            PyObject* sub = PySequence_GetItem(substr, i);
            if (unlikely(!sub)) return -1;
            result = PyUnicode_Tailmatch(s, sub, start, end, direction);
            Py_DECREF(sub);
#endif
            if (result) {
                return result;
            }
        }
        return 0;
    }
    return PyUnicode_Tailmatch(s, substr, start, end, direction);
}

static CYTHON_INLINE int __Pyx_PyStr_Tailmatch(PyObject* self, PyObject* arg, Py_ssize_t start,
                                               Py_ssize_t end, int direction);

#include <string.h>

static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/

static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/

#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
#else
#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
#endif

static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); /*proto*/

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/

static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/

static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \
    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \
    const char* function_name); /*proto*/

static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

static CYTHON_INLINE int __Pyx_IterFinish(void); /*proto*/

static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /*proto*/

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
        Py_INCREF(x);
        PyList_SET_ITEM(list, len, x);
        Py_SIZE(list) = len+1;
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
#endif

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
#else
#define __Pyx_PyList_GetSlice(seq, start, stop)   PySequence_GetSlice(seq, start, stop)
#define __Pyx_PyTuple_GetSlice(seq, start, stop)  PySequence_GetSlice(seq, start, stop)
#endif

#define __Pyx_GetItemInt(o, i, size, to_py_func, is_list, wraparound, boundscheck) \
    (((size) <= sizeof(Py_ssize_t)) ? \
    __Pyx_GetItemInt_Fast(o, i, is_list, wraparound, boundscheck) : \
    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
#define __Pyx_GetItemInt_List(o, i, size, to_py_func, is_list, wraparound, boundscheck) \
    (((size) <= sizeof(Py_ssize_t)) ? \
    __Pyx_GetItemInt_List_Fast(o, i, wraparound, boundscheck) : \
    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func, is_list, wraparound, boundscheck) \
    (((size) <= sizeof(Py_ssize_t)) ? \
    __Pyx_GetItemInt_Tuple_Fast(o, i, wraparound, boundscheck) : \
    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck);

static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); /*proto*/

static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact); /*proto*/

#ifndef __PYX_FORCE_INIT_THREADS
  #define __PYX_FORCE_INIT_THREADS 0
#endif

static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/

static void* __Pyx_GetVtable(PyObject *dict); /*proto*/

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /*proto*/

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_GLuint(GLuint);

static CYTHON_INLINE GLuint __Pyx_PyInt_from_py_GLuint(PyObject *);

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);

static int __Pyx_check_binary_version(void);

#if !defined(__Pyx_PyIdentifier_FromString)
#if PY_MAJOR_VERSION < 3
  #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
#else
  #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
#endif
#endif

static PyObject *__Pyx_ImportModule(const char *name); /*proto*/

static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);  /*proto*/

static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig); /*proto*/

static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig); /*proto*/

typedef struct {
    int code_line;
    PyCodeObject* code_object;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
    int count;
    int max_count;
    __Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);

static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename); /*proto*/

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/


/* Module declarations from 'kivy.graphics.c_opengl' */

/* Module declarations from 'kivy.graphics.buffer' */
static PyTypeObject *__pyx_ptype_4kivy_8graphics_6buffer_Buffer = 0;

/* Module declarations from 'kivy.graphics.vertex' */
static PyTypeObject *__pyx_ptype_4kivy_8graphics_6vertex_VertexFormat = 0;

/* Module declarations from 'kivy.graphics.vbo' */
static PyTypeObject *__pyx_ptype_4kivy_8graphics_3vbo_VBO = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_3vbo_VertexBatch = 0;
static struct __pyx_obj_4kivy_8graphics_6vertex_VertexFormat **__pyx_vp_4kivy_8graphics_3vbo_default_vertex = 0;
#define __pyx_v_4kivy_8graphics_3vbo_default_vertex (*__pyx_vp_4kivy_8graphics_3vbo_default_vertex)

/* Module declarations from 'kivy.graphics.transformation' */
static PyTypeObject *__pyx_ptype_4kivy_8graphics_14transformation_Matrix = 0;

/* Module declarations from 'kivy.graphics.context_instructions' */
static PyTypeObject *__pyx_ptype_4kivy_8graphics_20context_instructions_LineWidth = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_20context_instructions_Color = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_20context_instructions_BindTexture = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_20context_instructions_PushState = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_20context_instructions_ChangeState = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_20context_instructions_PopState = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_20context_instructions_LoadIdentity = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_20context_instructions_PushMatrix = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_20context_instructions_PopMatrix = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_20context_instructions_ApplyContextMatrix = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_20context_instructions_UpdateNormalMatrix = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_20context_instructions_MatrixInstruction = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_20context_instructions_Transform = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_20context_instructions_Rotate = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_20context_instructions_Scale = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_20context_instructions_Translate = 0;

/* Module declarations from 'kivy.graphics.compiler' */
static PyTypeObject *__pyx_ptype_4kivy_8graphics_8compiler_GraphicsCompiler = 0;

/* Module declarations from 'kivy.graphics.shader' */
static PyTypeObject *__pyx_ptype_4kivy_8graphics_6shader_ShaderSource = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_6shader_Shader = 0;

/* Module declarations from 'kivy._event' */
static PyTypeObject *__pyx_ptype_4kivy_6_event_ObjectWithUid = 0;
static PyTypeObject *__pyx_ptype_4kivy_6_event_EventDispatcher = 0;

/* Module declarations from 'kivy.graphics.instructions' */
static PyTypeObject *__pyx_ptype_4kivy_8graphics_12instructions_Instruction = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_12instructions_InstructionGroup = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_12instructions_ContextInstruction = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_12instructions_VertexInstruction = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_12instructions_CanvasBase = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_12instructions_Canvas = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_12instructions_RenderContext = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_12instructions_Callback = 0;

/* Module declarations from 'kivy.graphics.fbo' */
static PyTypeObject *__pyx_ptype_4kivy_8graphics_3fbo_Fbo = 0;

/* Module declarations from 'kivy.graphics.context' */
static PyTypeObject *__pyx_ptype_4kivy_8graphics_7context_Context = 0;
static struct __pyx_obj_4kivy_8graphics_7context_Context *(*__pyx_f_4kivy_8graphics_7context_get_context)(int __pyx_skip_dispatch); /*proto*/

/* Module declarations from 'kivy.graphics.opengl_utils' */
static int (*__pyx_f_4kivy_8graphics_12opengl_utils_gl_has_capability)(int, int __pyx_skip_dispatch); /*proto*/
static int (*__pyx_f_4kivy_8graphics_12opengl_utils_gl_has_texture_native_format)(PyObject *, int __pyx_skip_dispatch); /*proto*/
static int (*__pyx_f_4kivy_8graphics_12opengl_utils_gl_has_texture_conversion)(PyObject *, int __pyx_skip_dispatch); /*proto*/

/* Module declarations from 'kivy.graphics.texture' */
static PyTypeObject *__pyx_ptype_4kivy_8graphics_7texture_Texture = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_7texture_TextureRegion = 0;
static double __pyx_v_4kivy_8graphics_7texture_pi;
static int __pyx_v_4kivy_8graphics_7texture_c_GLCAP_BGRA;
static int __pyx_v_4kivy_8graphics_7texture_c_GLCAP_NPOT;
static int __pyx_v_4kivy_8graphics_7texture_c_GLCAP_S3TC;
static int __pyx_v_4kivy_8graphics_7texture_c_GLCAP_DXT1;
static int __pyx_v_4kivy_8graphics_7texture_c_GLCAP_PVRTC;
static int __pyx_v_4kivy_8graphics_7texture_c_GLCAP_ETC1;
static int __pyx_v_4kivy_8graphics_7texture_TI_MIN_FILTER;
static int __pyx_v_4kivy_8graphics_7texture_TI_MAG_FILTER;
static int __pyx_v_4kivy_8graphics_7texture_TI_WRAP;
static int __pyx_v_4kivy_8graphics_7texture_TI_NEED_GEN;
static int __pyx_v_4kivy_8graphics_7texture_TI_NEED_ALLOCATE;
static int __pyx_v_4kivy_8graphics_7texture_TI_NEED_PIXELS;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_BGR;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_BGRA;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_ETC1_RGB8_OES;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_PALETTE4_RGB8_OES;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_PALETTE4_RGBA8_OES;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_PALETTE4_R5_G6_B5_OES;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_PALETTE4_RGBA4_OES;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_PALETTE4_RGB5_A1_OES;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_PALETTE8_RGB8_OES;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_PALETTE8_RGBA8_OES;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_PALETTE8_R5_G6_B5_OES;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_PALETTE8_RGBA4_OES;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_PALETTE8_RGB5_A1_OES;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
static PyObject *__pyx_v_4kivy_8graphics_7texture__gl_color_fmt = 0;
static PyObject *__pyx_v_4kivy_8graphics_7texture__gl_buffer_fmt = 0;
static PyObject *__pyx_v_4kivy_8graphics_7texture__gl_buffer_size = 0;
static PyObject *__pyx_v_4kivy_8graphics_7texture__gl_texture_min_filter = 0;
static CYTHON_INLINE int __pyx_f_4kivy_8graphics_7texture__nearest_pow2(int); /*proto*/
static CYTHON_INLINE int __pyx_f_4kivy_8graphics_7texture__is_pow2(int); /*proto*/
static CYTHON_INLINE int __pyx_f_4kivy_8graphics_7texture__color_fmt_to_gl(PyObject *); /*proto*/
static CYTHON_INLINE int __pyx_f_4kivy_8graphics_7texture__is_compressed_fmt(PyObject *); /*proto*/
static CYTHON_INLINE int __pyx_f_4kivy_8graphics_7texture__buffer_fmt_to_gl(PyObject *); /*proto*/
static CYTHON_INLINE int __pyx_f_4kivy_8graphics_7texture__buffer_type_to_gl_size(PyObject *); /*proto*/
static CYTHON_INLINE GLuint __pyx_f_4kivy_8graphics_7texture__str_to_gl_texture_min_filter(PyObject *); /*proto*/
static CYTHON_INLINE GLuint __pyx_f_4kivy_8graphics_7texture__str_to_gl_texture_mag_filter(PyObject *); /*proto*/
static CYTHON_INLINE GLuint __pyx_f_4kivy_8graphics_7texture__str_to_gl_texture_wrap(PyObject *); /*proto*/
static CYTHON_INLINE int __pyx_f_4kivy_8graphics_7texture__gl_format_size(GLuint); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_4kivy_8graphics_7texture__convert_gl_format(PyObject *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_4kivy_8graphics_7texture__convert_buffer(PyObject *, PyObject *); /*proto*/
static CYTHON_INLINE void __pyx_f_4kivy_8graphics_7texture__gl_prepare_pixels_upload(int); /*proto*/
static struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_f_4kivy_8graphics_7texture__texture_create(int, int, PyObject *, PyObject *, int, int, PyObject *); /*proto*/
#define __Pyx_MODULE_NAME "kivy.graphics.texture"
int __pyx_module_is_main_kivy__graphics__texture = 0;

/* Implementation of 'kivy.graphics.texture' */
static PyObject *__pyx_builtin_staticmethod;
static PyObject *__pyx_builtin_KeyError;
static PyObject *__pyx_builtin_Exception;
static PyObject *__pyx_builtin_format;
static PyObject *__pyx_builtin_id;
static PyObject *__pyx_pf_4kivy_8graphics_7texture_texture_create(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_size, PyObject *__pyx_v_colorfmt, PyObject *__pyx_v_bufferfmt, PyObject *__pyx_v_mipmap, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_2texture_create_from_data(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_im, PyObject *__pyx_v_mipmap); /* proto */
static int __pyx_pf_4kivy_8graphics_7texture_7Texture___init__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_width, PyObject *__pyx_v_height, PyObject *__pyx_v_target, PyObject *__pyx_v_texid, PyObject *__pyx_v_colorfmt, PyObject *__pyx_v_bufferfmt, PyObject *__pyx_v_mipmap, PyObject *__pyx_v_source, PyObject *__pyx_v_callback); /* proto */
static void __pyx_pf_4kivy_8graphics_7texture_7Texture_2__dealloc__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_4add_reload_observer(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6remove_reload_observer(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_8flip_vertical(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_10get_region(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x, PyObject *__pyx_v_y, PyObject *__pyx_v_width, PyObject *__pyx_v_height); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_12ask_update(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_14bind(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_16blit_data(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_im, PyObject *__pyx_v_pos); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_18blit_buffer(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_pbuffer, PyObject *__pyx_v_size, PyObject *__pyx_v_colorfmt, PyObject *__pyx_v_pos, PyObject *__pyx_v_bufferfmt, PyObject *__pyx_v_mipmap_level, PyObject *__pyx_v_mipmap_generation); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_20_on_proxyimage_loaded(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_image); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_22save(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_filename); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_24__repr__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_4size___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6mipmap___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_2id___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6target___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_5width___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6height___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_10tex_coords___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_5uvpos___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static int __pyx_pf_4kivy_8graphics_7texture_7Texture_5uvpos_2__set__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6uvsize___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static int __pyx_pf_4kivy_8graphics_7texture_7Texture_6uvsize_2__set__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_8colorfmt___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_9bufferfmt___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_10min_filter___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static int __pyx_pf_4kivy_8graphics_7texture_7Texture_10min_filter_2__set__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_10mag_filter___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static int __pyx_pf_4kivy_8graphics_7texture_7Texture_10mag_filter_2__set__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_4wrap___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static int __pyx_pf_4kivy_8graphics_7texture_7Texture_4wrap_2__set__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_wrap); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6pixels___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static int __pyx_pf_4kivy_8graphics_7texture_13TextureRegion___init__(struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *__pyx_v_self, int __pyx_v_x, int __pyx_v_y, int __pyx_v_width, int __pyx_v_height, struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_origin); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_13TextureRegion_2__repr__(struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_13TextureRegion_4ask_update(struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_13TextureRegion_6bind(struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_13TextureRegion_6pixels___get__(struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *__pyx_v_self); /* proto */
static PyObject *__pyx_tp_new_4kivy_8graphics_7texture_Texture(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_4kivy_8graphics_7texture_TextureRegion(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static char __pyx_k_1[] = "Unknown <%s> color format";
static char __pyx_k_2[] = "Unknown <%s> buffer format";
static char __pyx_k_3[] = "Unknown <%s> format";
static char __pyx_k_4[] = "Unknown <%s> texture min filter";
static char __pyx_k_5[] = "Unknown <%s> texture mag filter";
static char __pyx_k_6[] = "Unsupported format size <%s>";
static char __pyx_k_7[] = "Unimplemented texture conversion for %s";
static char __pyx_k_16[] = "Non implemented texture conversion !";
static char __pyx_k_17[] = "linear_mipmap_nearest";
static char __pyx_k_21[] = "Unable to allocate memory for texture (size is %s)";
static char __pyx_k_24[] = ":";
static char __pyx_k_26[] = "kivy.loader";
static char __pyx_k_27[] = "_on_proxyimage_loaded";
static char __pyx_k_28[] = "kivy.core.image";
static char __pyx_k_29[] = "<Texture hash=%r id=%d size=%r colorfmt=%r bufferfmt=%r source=%r observers=%d>";
static char __pyx_k_30[] = "kivy.graphics.fbo";
static char __pyx_k_31[] = "<TextureRegion of %r hash=%r id=%d size=%r colorfmt=%r bufferfmt=%r source=%r observers=%d>";
static char __pyx_k_32[] = "kivy.graphics";
static char __pyx_k_35[] = "Return the (width, height) of the texture (readonly)\n        ";
static char __pyx_k_36[] = "Return True if the texture have mipmap enabled (readonly)\n        ";
static char __pyx_k_37[] = "Return the OpenGL ID of the texture (readonly)\n        ";
static char __pyx_k_38[] = "Return the OpenGL target of the texture (readonly)\n        ";
static char __pyx_k_39[] = "Return the width of the texture (readonly)\n        ";
static char __pyx_k_40[] = "Return the height of the texture (readonly)\n        ";
static char __pyx_k_41[] = "Return the list of tex_coords (opengl)\n        ";
static char __pyx_k_42[] = "Get/set the UV position inside texture\n        ";
static char __pyx_k_43[] = "Get/set the UV size inside texture.\n\n        .. warning::\n            The size can be negative is the texture is flipped.\n        ";
static char __pyx_k_44[] = "Return the color format used in this texture. (readonly)\n\n        .. versionadded:: 1.0.7\n        ";
static char __pyx_k_45[] = "Return the buffer format used in this texture. (readonly)\n\n        .. versionadded:: 1.2.0\n        ";
static char __pyx_k_46[] = "Get/set the min filter texture. Available values:\n\n        - linear\n        - nearest\n        - linear_mipmap_linear\n        - linear_mipmap_nearest\n        - nearest_mipmap_nearest\n        - nearest_mipmap_linear\n\n        Check opengl documentation for more information about the behavior of\n        theses values : http://www.khronos.org/opengles/sdk/docs/man/xhtml/glTexParameter.xml.\n        ";
static char __pyx_k_47[] = "Get/set the mag filter texture. Available values:\n\n        - linear\n        - nearest\n\n        Check opengl documentation for more information about the behavior of\n        theses values : http://www.khronos.org/opengles/sdk/docs/man/xhtml/glTexParameter.xml.\n        ";
static char __pyx_k_48[] = "Get/set the wrap texture. Available values:\n\n        - repeat\n        - mirrored_repeat\n        - clamp_to_edge\n\n        Check opengl documentation for more information about the behavior of\n        theses values : http://www.khronos.org/opengles/sdk/docs/man/xhtml/glTexParameter.xml.\n        ";
static char __pyx_k_49[] = "Get the pixels texture, in RGBA format only, unsigned byte.\n\n        .. versionadded:: 1.7.0\n        ";
static char __pyx_k_50[] = "\nTexture\n=======\n\n.. versionchanged:: 1.6.0\n    Added support for paletted texture on OES: 'palette4_rgb8', 'palette4_rgba8', 'palette4_r5_g6_b5', 'palette4_rgba4', 'palette4_rgb5_a1', 'palette8_rgb8', 'palette8_rgba8', 'palette8_r5_g6_b5', 'palette8_rgba4', 'palette8_rgb5_a1'\n\n:class:`Texture` is a class to handle OpenGL texture. Depending of the hardware,\nsome OpenGL capabilities might not be available (BGRA support, NPOT support,\netc.)\n\nYou cannot instanciate the class yourself. You must use the function\n:func:`Texture.create` to create a new texture::\n\n    texture = Texture.create(size=(640, 480))\n\nWhen you are creating a texture, you must be aware of the default color format\nand buffer format:\n\n    - the color/pixel format (:data:`Texture.colorfmt`), that can be one of\n      'rgb', 'rgba', 'luminance', 'luminance_alpha', 'bgr', 'bgra'. The default\n      value is 'rgb'\n    - the buffer format is how a color component is stored into memory. This can\n      be one of 'ubyte', 'ushort', 'uint', 'byte', 'short', 'int', 'float'. The\n      default value and the most commonly used is 'ubyte'.\n\nSo, if you want to create an RGBA texture::\n\n    texture = Texture.create(size=(640, 480), colorfmt='rgba')\n\nYou can use your texture in almost all vertex instructions with the\n:data:`kivy.graphics.VertexIntruction.texture` parameter. If you want to use\nyour texture in kv lang, you can save it in an\n:class:`~kivy.properties.ObjectProperty` inside your widget.\n\n\nBlitting custom data\n--------------------\n\nYou can create your own data and blit it on the texture using\n:func:`Texture.blit_data`::\n\n    # create a 64x64 texture, default to rgb / ubyte\n    texture = Texture.create(size=(64, 64))\n\n    # create 64x64 rgb tab, and fill with value from 0 to 255\n    # we'll have a gradient from black to white\n    size = 64 * 64 * 3\n    buf = [int(x * 255 / size) for x in xrange(size)]\n\n    # then, convert the array to a ubyte string\n    buf = ""''.join(map(chr, buf))\n\n    # then blit the buffer\n    texture.blit_buffer(buf, colorfmt='rgb', bufferfmt='ubyte')\n\n    # that's all ! you can use it in your graphics now :)\n    # if self is a widget, you can do that\n    with self.canvas:\n        Rectangle(texture=texture, pos=self.pos, size=(64, 64))\n\n\nBGR/BGRA support\n----------------\n\nThe first time you'll try to create a BGR or BGRA texture, we are checking if\nyour hardware support BGR / BGRA texture by checking the extension\n'GL_EXT_bgra'.\n\nIf the extension is not found, a conversion to RGB / RGBA will be done in\nsoftware.\n\n\nNPOT texture\n------------\n\n.. versionadded:: 1.0.7\n\n    If hardware can support NPOT, no POT are created.\n\nAs OpenGL documentation said, a texture must be power-of-two sized. That's mean\nyour width and height can be one of 64, 32, 256... but not 3, 68, 42. NPOT mean\nnon-power-of-two. OpenGL ES 2 support NPOT texture natively, but with some\ndrawbacks. Another type of NPOT texture are also called rectangle texture.\nPOT, NPOT and texture have their own pro/cons.\n\n================= ============= ============= =================================\n    Features           POT           NPOT                Rectangle\n----------------- ------------- ------------- ---------------------------------\nOpenGL Target     GL_TEXTURE_2D GL_TEXTURE_2D GL_TEXTURE_RECTANGLE_(NV|ARB|EXT)\nTexture coords    0-1 range     0-1 range     width-height range\nMipmapping        Supported     Partially     No\nWrap mode         Supported     Supported     No\n================= ============= ============= =================================\n\nIf you are creating a NPOT texture, we first are checking if your hardware is\ncapable of it by checking the extensions GL_ARB_texture_non_power_of_two or\nOES_texture_npot. If none of theses are availables, we are creating the nearest\nPOT texture that can contain your NPOT texture. The :func:`Texture.create` will\nreturn a :class:`TextureRegion` ins""tead.\n\n\nTexture atlas\n-------------\n\nWe are calling texture atlas a texture that contain many images in it.\nIf you want to seperate the original texture into many single one, you don't\nneed to. You can get a region of the original texture. That will return you the\noriginal texture with custom texture coordinates::\n\n    # for example, load a 128x128 image that contain 4 64x64 images\n    from kivy.core.image import Image\n    texture = Image('mycombinedimage.png').texture\n\n    bottomleft = texture.get_region(0, 0, 64, 64)\n    bottomright = texture.get_region(0, 64, 64, 64)\n    topleft = texture.get_region(0, 64, 64, 64)\n    topright = texture.get_region(64, 64, 64, 64)\n\n\n.. _mipmap:\n\nMipmapping\n----------\n\n.. versionadded:: 1.0.7\n\nMipmapping is an OpenGL technique for enhancing the rendering of large texture\nto small surface. Without mipmapping, you might seen pixels when you are\nrendering to small surface.\nThe idea is to precalculate subtexture and apply some image filter, as linear\nfilter. Then, when you rendering a small surface, instead of using the biggest\ntexture, it will use a lower filtered texture. The result can look better with\nthat way.\n\nTo make that happen, you need to specify mipmap=True when you're creating a\ntexture. Some widget already give you the possibility to create mipmapped\ntexture like :class:`~kivy.uix.label.Label` or :class:`~kivy.uix.image.Image`.\n\nFrom the OpenGL Wiki : \"So a 64x16 2D texture can have 5 mip-maps: 32x8, 16x4,\n8x2, 4x1, 2x1, and 1x1\". Check http://www.opengl.org/wiki/Texture for more\ninformation.\n\n.. note::\n\n    As the table in previous section said, if your texture is NPOT, we are\n    actually creating the nearest POT texture and generate mipmap on it. This\n    might change in the future.\n\nReloading the Texture\n---------------------\n\n.. versionadded:: 1.2.0\n\nIf the OpenGL context is lost, the Texture must be reloaded. Texture having a\nsource are automatically reloaded ""without any help. But generated textures must\nbe reloaded by the user.\n\nUse the :func:`Texture.add_reload_observer` to add a reloading function that will be\nautomatically called when needed::\n\n    def __init__(self, **kwargs):\n        super(...).__init__(**kwargs)\n        self.texture = Texture.create(size=(512, 512), colorfmt='RGB',\n            bufferfmt='ubyte')\n        self.texture.add_reload_observer(self.populate_texture)\n\n        # and load the data now.\n        self.cbuffer = '\000\303\260\303\277' * 512 * 512\n        self.populate_texture(self.texture)\n\n    def populate_texture(self, texture):\n        texture.blit_buffer(self.cbuffer)\n\nThis way, you could use the same method for initialization and for reloading.\n\n.. note::\n\n    For all text rendering with our core text renderer, texture is generated,\n    but we are binding already a method to redo the text rendering and reupload\n    the text to the texture. You have nothing to do on that case.\n";
static char __pyx_k_52[] = "kivy.weakmethod";
static char __pyx_k_53[] = "nearest_mipmap_nearest";
static char __pyx_k_54[] = "nearest_mipmap_linear";
static char __pyx_k_55[] = "linear_mipmap_linear";
static char __pyx_k_58[] = "c:\\Users\\tito\\Desktop\\Kivy-dev\\kivy\\Kivy-1.7.2-w32\\Kivy-1.7.2\\kivy\\graphics\\texture.pyx";
static char __pyx_k_59[] = "kivy.graphics.texture";
static char __pyx_k_62[] = "texture_create_from_data";
static char __pyx_k__b[] = "b";
static char __pyx_k__x[] = "x";
static char __pyx_k__y[] = "y";
static char __pyx_k__id[] = "id";
static char __pyx_k__im[] = "im";
static char __pyx_k__Fbo[] = "Fbo";
static char __pyx_k__bgr[] = "bgr";
static char __pyx_k__fmt[] = "fmt";
static char __pyx_k__ftp[] = "ftp";
static char __pyx_k__int[] = "int";
static char __pyx_k__pos[] = "pos";
static char __pyx_k__rgb[] = "rgb";
static char __pyx_k__smb[] = "smb";
static char __pyx_k__bgra[] = "bgra";
static char __pyx_k__bind[] = "bind";
static char __pyx_k__byte[] = "byte";
static char __pyx_k__data[] = "data";
static char __pyx_k__draw[] = "draw";
static char __pyx_k__http[] = "http";
static char __pyx_k__rgba[] = "rgba";
static char __pyx_k__save[] = "save";
static char __pyx_k__size[] = "size";
static char __pyx_k__uint[] = "uint";
static char __pyx_k__wrap[] = "wrap";
static char __pyx_k__Color[] = "Color";
static char __pyx_k__Image[] = "Image";
static char __pyx_k__array[] = "array";
static char __pyx_k__clear[] = "clear";
static char __pyx_k__etc1_[] = "etc1_";
static char __pyx_k__float[] = "float";
static char __pyx_k__https[] = "https";
static char __pyx_k__image[] = "image";
static char __pyx_k__lower[] = "lower";
static char __pyx_k__short[] = "short";
static char __pyx_k__split[] = "split";
static char __pyx_k__texid[] = "texid";
static char __pyx_k__ubyte[] = "ubyte";
static char __pyx_k__width[] = "width";
static char __pyx_k__Loader[] = "Loader";
static char __pyx_k__create[] = "create";
static char __pyx_k__format[] = "format";
static char __pyx_k__height[] = "height";
static char __pyx_k__linear[] = "linear";
static char __pyx_k__loaded[] = "loaded";
static char __pyx_k__mipmap[] = "mipmap";
static char __pyx_k__origin[] = "origin";
static char __pyx_k__pixels[] = "pixels";
static char __pyx_k__pvrtc_[] = "pvrtc_";
static char __pyx_k__remove[] = "remove";
static char __pyx_k__repeat[] = "repeat";
static char __pyx_k__source[] = "source";
static char __pyx_k__target[] = "target";
static char __pyx_k__ushort[] = "ushort";
static char __pyx_k__Texture[] = "Texture";
static char __pyx_k____all__[] = "__all__";
static char __pyx_k__is_dead[] = "is_dead";
static char __pyx_k__nearest[] = "nearest";
static char __pyx_k__no_blit[] = "no_blit";
static char __pyx_k__nocache[] = "nocache";
static char __pyx_k__on_load[] = "on_load";
static char __pyx_k__palette[] = "palette";
static char __pyx_k__pbuffer[] = "pbuffer";
static char __pyx_k__texture[] = "texture";
static char __pyx_k__KeyError[] = "KeyError";
static char __pyx_k____exit__[] = "__exit__";
static char __pyx_k____init__[] = "__init__";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k__allocate[] = "allocate";
static char __pyx_k__callback[] = "callback";
static char __pyx_k__colorfmt[] = "colorfmt";
static char __pyx_k__s3tc_dxt[] = "s3tc_dxt";
static char __pyx_k__tostring[] = "tostring";
static char __pyx_k__Exception[] = "Exception";
static char __pyx_k__Rectangle[] = "Rectangle";
static char __pyx_k____enter__[] = "__enter__";
static char __pyx_k__blit_data[] = "blit_data";
static char __pyx_k__bufferfmt[] = "bufferfmt";
static char __pyx_k__etc1_rgb8[] = "etc1_rgb8";
static char __pyx_k__luminance[] = "luminance";
static char __pyx_k__s3tc_dxt1[] = "s3tc_dxt1";
static char __pyx_k__s3tc_dxt3[] = "s3tc_dxt3";
static char __pyx_k__s3tc_dxt5[] = "s3tc_dxt5";
static char __pyx_k__GLCAP_BGRA[] = "GLCAP_BGRA";
static char __pyx_k__GLCAP_DXT1[] = "GLCAP_DXT1";
static char __pyx_k__GLCAP_ETC1[] = "GLCAP_ETC1";
static char __pyx_k__GLCAP_NPOT[] = "GLCAP_NPOT";
static char __pyx_k__GLCAP_S3TC[] = "GLCAP_S3TC";
static char __pyx_k__WeakMethod[] = "WeakMethod";
static char __pyx_k____import__[] = "__import__";
static char __pyx_k__ask_update[] = "ask_update";
static char __pyx_k__get_region[] = "get_region";
static char __pyx_k__mag_filter[] = "mag_filter";
static char __pyx_k__min_filter[] = "min_filter";
static char __pyx_k__pvrtc_rgb2[] = "pvrtc_rgb2";
static char __pyx_k__pvrtc_rgb4[] = "pvrtc_rgb4";
static char __pyx_k__tex_coords[] = "tex_coords";
static char __pyx_k__GLCAP_PVRTC[] = "GLCAP_PVRTC";
static char __pyx_k__blit_buffer[] = "blit_buffer";
static char __pyx_k__have_mipmap[] = "have_mipmap";
static char __pyx_k__pvrtc_rgba2[] = "pvrtc_rgba2";
static char __pyx_k__pvrtc_rgba4[] = "pvrtc_rgba4";
static char __pyx_k__mipmap_level[] = "mipmap_level";
static char __pyx_k__staticmethod[] = "staticmethod";
static char __pyx_k__TextureRegion[] = "TextureRegion";
static char __pyx_k__clamp_to_edge[] = "clamp_to_edge";
static char __pyx_k__flip_vertical[] = "flip_vertical";
static char __pyx_k__palette4_rgb8[] = "palette4_rgb8";
static char __pyx_k__palette8_rgb8[] = "palette8_rgb8";
static char __pyx_k____pyx_vtable__[] = "__pyx_vtable__";
static char __pyx_k__palette4_rgba4[] = "palette4_rgba4";
static char __pyx_k__palette4_rgba8[] = "palette4_rgba8";
static char __pyx_k__palette8_rgba4[] = "palette8_rgba4";
static char __pyx_k__palette8_rgba8[] = "palette8_rgba8";
static char __pyx_k__texture_create[] = "texture_create";
static char __pyx_k__iterate_mipmaps[] = "iterate_mipmaps";
static char __pyx_k__luminance_alpha[] = "luminance_alpha";
static char __pyx_k__mirrored_repeat[] = "mirrored_repeat";
static char __pyx_k__create_from_data[] = "create_from_data";
static char __pyx_k__palette4_rgb5_a1[] = "palette4_rgb5_a1";
static char __pyx_k__palette8_rgb5_a1[] = "palette8_rgb5_a1";
static char __pyx_k__mipmap_generation[] = "mipmap_generation";
static char __pyx_k__palette4_r5_g6_b5[] = "palette4_r5_g6_b5";
static char __pyx_k__palette8_r5_g6_b5[] = "palette8_r5_g6_b5";
static char __pyx_k__flag_update_canvas[] = "flag_update_canvas";
static PyObject *__pyx_kp_s_1;
static PyObject *__pyx_kp_s_16;
static PyObject *__pyx_n_s_17;
static PyObject *__pyx_kp_s_2;
static PyObject *__pyx_kp_s_21;
static PyObject *__pyx_kp_s_24;
static PyObject *__pyx_n_s_26;
static PyObject *__pyx_n_s_27;
static PyObject *__pyx_n_s_28;
static PyObject *__pyx_kp_s_29;
static PyObject *__pyx_kp_s_3;
static PyObject *__pyx_n_s_30;
static PyObject *__pyx_kp_s_31;
static PyObject *__pyx_n_s_32;
static PyObject *__pyx_kp_s_4;
static PyObject *__pyx_kp_s_5;
static PyObject *__pyx_n_s_52;
static PyObject *__pyx_n_s_53;
static PyObject *__pyx_n_s_54;
static PyObject *__pyx_n_s_55;
static PyObject *__pyx_kp_s_58;
static PyObject *__pyx_n_s_59;
static PyObject *__pyx_kp_s_6;
static PyObject *__pyx_n_s_62;
static PyObject *__pyx_kp_s_7;
static PyObject *__pyx_n_s__Color;
static PyObject *__pyx_n_s__Exception;
static PyObject *__pyx_n_s__Fbo;
static PyObject *__pyx_n_s__GLCAP_BGRA;
static PyObject *__pyx_n_s__GLCAP_DXT1;
static PyObject *__pyx_n_s__GLCAP_ETC1;
static PyObject *__pyx_n_s__GLCAP_NPOT;
static PyObject *__pyx_n_s__GLCAP_PVRTC;
static PyObject *__pyx_n_s__GLCAP_S3TC;
static PyObject *__pyx_n_s__Image;
static PyObject *__pyx_n_s__KeyError;
static PyObject *__pyx_n_s__Loader;
static PyObject *__pyx_n_s__Rectangle;
static PyObject *__pyx_n_s__Texture;
static PyObject *__pyx_n_s__TextureRegion;
static PyObject *__pyx_n_s__WeakMethod;
static PyObject *__pyx_n_s____all__;
static PyObject *__pyx_n_s____enter__;
static PyObject *__pyx_n_s____exit__;
static PyObject *__pyx_n_s____import__;
static PyObject *__pyx_n_s____init__;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____pyx_vtable__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s__allocate;
static PyObject *__pyx_n_s__array;
static PyObject *__pyx_n_s__ask_update;
static PyObject *__pyx_n_s__b;
static PyObject *__pyx_n_s__bgr;
static PyObject *__pyx_n_s__bgra;
static PyObject *__pyx_n_s__bind;
static PyObject *__pyx_n_s__blit_buffer;
static PyObject *__pyx_n_s__blit_data;
static PyObject *__pyx_n_s__bufferfmt;
static PyObject *__pyx_n_s__byte;
static PyObject *__pyx_n_s__callback;
static PyObject *__pyx_n_s__clamp_to_edge;
static PyObject *__pyx_n_s__clear;
static PyObject *__pyx_n_s__colorfmt;
static PyObject *__pyx_n_s__create;
static PyObject *__pyx_n_s__create_from_data;
static PyObject *__pyx_n_s__data;
static PyObject *__pyx_n_s__draw;
static PyObject *__pyx_n_s__etc1_;
static PyObject *__pyx_n_s__etc1_rgb8;
static PyObject *__pyx_n_s__flag_update_canvas;
static PyObject *__pyx_n_s__flip_vertical;
static PyObject *__pyx_n_s__float;
static PyObject *__pyx_n_s__fmt;
static PyObject *__pyx_n_s__format;
static PyObject *__pyx_n_s__ftp;
static PyObject *__pyx_n_s__get_region;
static PyObject *__pyx_n_s__have_mipmap;
static PyObject *__pyx_n_s__height;
static PyObject *__pyx_n_s__http;
static PyObject *__pyx_n_s__https;
static PyObject *__pyx_n_s__id;
static PyObject *__pyx_n_s__im;
static PyObject *__pyx_n_s__image;
static PyObject *__pyx_n_s__int;
static PyObject *__pyx_n_s__is_dead;
static PyObject *__pyx_n_s__iterate_mipmaps;
static PyObject *__pyx_n_s__linear;
static PyObject *__pyx_n_s__loaded;
static PyObject *__pyx_n_s__lower;
static PyObject *__pyx_n_s__luminance;
static PyObject *__pyx_n_s__luminance_alpha;
static PyObject *__pyx_n_s__mag_filter;
static PyObject *__pyx_n_s__min_filter;
static PyObject *__pyx_n_s__mipmap;
static PyObject *__pyx_n_s__mipmap_generation;
static PyObject *__pyx_n_s__mipmap_level;
static PyObject *__pyx_n_s__mirrored_repeat;
static PyObject *__pyx_n_s__nearest;
static PyObject *__pyx_n_s__no_blit;
static PyObject *__pyx_n_s__nocache;
static PyObject *__pyx_n_s__on_load;
static PyObject *__pyx_n_s__origin;
static PyObject *__pyx_n_s__palette;
static PyObject *__pyx_n_s__palette4_r5_g6_b5;
static PyObject *__pyx_n_s__palette4_rgb5_a1;
static PyObject *__pyx_n_s__palette4_rgb8;
static PyObject *__pyx_n_s__palette4_rgba4;
static PyObject *__pyx_n_s__palette4_rgba8;
static PyObject *__pyx_n_s__palette8_r5_g6_b5;
static PyObject *__pyx_n_s__palette8_rgb5_a1;
static PyObject *__pyx_n_s__palette8_rgb8;
static PyObject *__pyx_n_s__palette8_rgba4;
static PyObject *__pyx_n_s__palette8_rgba8;
static PyObject *__pyx_n_s__pbuffer;
static PyObject *__pyx_n_s__pixels;
static PyObject *__pyx_n_s__pos;
static PyObject *__pyx_n_s__pvrtc_;
static PyObject *__pyx_n_s__pvrtc_rgb2;
static PyObject *__pyx_n_s__pvrtc_rgb4;
static PyObject *__pyx_n_s__pvrtc_rgba2;
static PyObject *__pyx_n_s__pvrtc_rgba4;
static PyObject *__pyx_n_s__remove;
static PyObject *__pyx_n_s__repeat;
static PyObject *__pyx_n_s__rgb;
static PyObject *__pyx_n_s__rgba;
static PyObject *__pyx_n_s__s3tc_dxt;
static PyObject *__pyx_n_s__s3tc_dxt1;
static PyObject *__pyx_n_s__s3tc_dxt3;
static PyObject *__pyx_n_s__s3tc_dxt5;
static PyObject *__pyx_n_s__save;
static PyObject *__pyx_n_s__short;
static PyObject *__pyx_n_s__size;
static PyObject *__pyx_n_s__smb;
static PyObject *__pyx_n_s__source;
static PyObject *__pyx_n_s__split;
static PyObject *__pyx_n_s__staticmethod;
static PyObject *__pyx_n_s__target;
static PyObject *__pyx_n_s__tex_coords;
static PyObject *__pyx_n_s__texid;
static PyObject *__pyx_n_s__texture;
static PyObject *__pyx_n_s__texture_create;
static PyObject *__pyx_n_s__tostring;
static PyObject *__pyx_n_s__ubyte;
static PyObject *__pyx_n_s__uint;
static PyObject *__pyx_n_s__ushort;
static PyObject *__pyx_n_s__width;
static PyObject *__pyx_n_s__wrap;
static PyObject *__pyx_n_s__x;
static PyObject *__pyx_n_s__y;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_1;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_3;
static PyObject *__pyx_int_4;
static PyObject *__pyx_k_18;
static PyObject *__pyx_k_19;
static PyObject *__pyx_k_20;
static PyObject *__pyx_k_22;
static PyObject *__pyx_k_slice_8;
static PyObject *__pyx_k_slice_9;
static PyObject *__pyx_k_slice_10;
static PyObject *__pyx_k_slice_11;
static PyObject *__pyx_k_slice_12;
static PyObject *__pyx_k_slice_13;
static PyObject *__pyx_k_slice_14;
static PyObject *__pyx_k_slice_15;
static PyObject *__pyx_k_tuple_23;
static PyObject *__pyx_k_tuple_25;
static PyObject *__pyx_k_tuple_33;
static PyObject *__pyx_k_tuple_34;
static PyObject *__pyx_k_tuple_51;
static PyObject *__pyx_k_tuple_56;
static PyObject *__pyx_k_tuple_60;
static PyObject *__pyx_k_codeobj_57;
static PyObject *__pyx_k_codeobj_61;

/* "kivy\graphics\texture.pyx":275
 * 
 * 
 * cdef inline int _nearest_pow2(int v):             # <<<<<<<<<<<<<<
 *     # From http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
 *     # Credit: Sean Anderson
 */

static CYTHON_INLINE int __pyx_f_4kivy_8graphics_7texture__nearest_pow2(int __pyx_v_v) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_nearest_pow2", 0);

  /* "kivy\graphics\texture.pyx":278
 *     # From http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
 *     # Credit: Sean Anderson
 *     v -= 1             # <<<<<<<<<<<<<<
 *     v |= v >> 1
 *     v |= v >> 2
 */
  __pyx_v_v = (__pyx_v_v - 1);

  /* "kivy\graphics\texture.pyx":279
 *     # Credit: Sean Anderson
 *     v -= 1
 *     v |= v >> 1             # <<<<<<<<<<<<<<
 *     v |= v >> 2
 *     v |= v >> 4
 */
  __pyx_v_v = (__pyx_v_v | (__pyx_v_v >> 1));

  /* "kivy\graphics\texture.pyx":280
 *     v -= 1
 *     v |= v >> 1
 *     v |= v >> 2             # <<<<<<<<<<<<<<
 *     v |= v >> 4
 *     v |= v >> 8
 */
  __pyx_v_v = (__pyx_v_v | (__pyx_v_v >> 2));

  /* "kivy\graphics\texture.pyx":281
 *     v |= v >> 1
 *     v |= v >> 2
 *     v |= v >> 4             # <<<<<<<<<<<<<<
 *     v |= v >> 8
 *     v |= v >> 16
 */
  __pyx_v_v = (__pyx_v_v | (__pyx_v_v >> 4));

  /* "kivy\graphics\texture.pyx":282
 *     v |= v >> 2
 *     v |= v >> 4
 *     v |= v >> 8             # <<<<<<<<<<<<<<
 *     v |= v >> 16
 *     return v + 1
 */
  __pyx_v_v = (__pyx_v_v | (__pyx_v_v >> 8));

  /* "kivy\graphics\texture.pyx":283
 *     v |= v >> 4
 *     v |= v >> 8
 *     v |= v >> 16             # <<<<<<<<<<<<<<
 *     return v + 1
 * 
 */
  __pyx_v_v = (__pyx_v_v | (__pyx_v_v >> 16));

  /* "kivy\graphics\texture.pyx":284
 *     v |= v >> 8
 *     v |= v >> 16
 *     return v + 1             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = (__pyx_v_v + 1);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":287
 * 
 * 
 * cdef inline int _is_pow2(int v):             # <<<<<<<<<<<<<<
 *     # http://graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2
 *     return (v & (v - 1)) == 0
 */

static CYTHON_INLINE int __pyx_f_4kivy_8graphics_7texture__is_pow2(int __pyx_v_v) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_is_pow2", 0);

  /* "kivy\graphics\texture.pyx":289
 * cdef inline int _is_pow2(int v):
 *     # http://graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2
 *     return (v & (v - 1)) == 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = ((__pyx_v_v & (__pyx_v_v - 1)) == 0);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":292
 * 
 * 
 * cdef inline int _color_fmt_to_gl(bytes x):             # <<<<<<<<<<<<<<
 *     '''Return the GL numeric value from a color string format
 *     '''
 */

static CYTHON_INLINE int __pyx_f_4kivy_8graphics_7texture__color_fmt_to_gl(PyObject *__pyx_v_x) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_color_fmt_to_gl", 0);
  __Pyx_INCREF(__pyx_v_x);

  /* "kivy\graphics\texture.pyx":295
 *     '''Return the GL numeric value from a color string format
 *     '''
 *     x = x.lower()             # <<<<<<<<<<<<<<
 *     try:
 *         return _gl_color_fmt[x]
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x), __pyx_n_s__lower); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_v_x));
  __pyx_v_x = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "kivy\graphics\texture.pyx":296
 *     '''
 *     x = x.lower()
 *     try:             # <<<<<<<<<<<<<<
 *         return _gl_color_fmt[x]
 *     except KeyError:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {

      /* "kivy\graphics\texture.pyx":297
 *     x = x.lower()
 *     try:
 *         return _gl_color_fmt[x]             # <<<<<<<<<<<<<<
 *     except KeyError:
 *         raise Exception('Unknown <%s> color format' % x)
 */
      if (unlikely(((PyObject *)__pyx_v_4kivy_8graphics_7texture__gl_color_fmt) == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __pyx_t_2 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_4kivy_8graphics_7texture__gl_color_fmt), ((PyObject *)__pyx_v_x)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      goto __pyx_L7_try_return;
    }
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L10_try_end;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L0;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "kivy\graphics\texture.pyx":298
 *     try:
 *         return _gl_color_fmt[x]
 *     except KeyError:             # <<<<<<<<<<<<<<
 *         raise Exception('Unknown <%s> color format' % x)
 * 
 */
    __pyx_t_6 = PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_6) {
      __Pyx_AddTraceback("kivy.graphics.texture._color_fmt_to_gl", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_7);

      /* "kivy\graphics\texture.pyx":299
 *         return _gl_color_fmt[x]
 *     except KeyError:
 *         raise Exception('Unknown <%s> color format' % x)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_1), ((PyObject *)__pyx_v_x)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_8));
      __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_t_8));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_8));
      __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    __pyx_L10_try_end:;
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_WriteUnraisable("kivy.graphics.texture._color_fmt_to_gl", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":302
 * 
 * 
 * cdef inline int _is_compressed_fmt(str x):             # <<<<<<<<<<<<<<
 *     '''Return 1 if the color string format is a compressed one
 *     '''
 */

static CYTHON_INLINE int __pyx_f_4kivy_8graphics_7texture__is_compressed_fmt(PyObject *__pyx_v_x) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_is_compressed_fmt", 0);

  /* "kivy\graphics\texture.pyx":305
 *     '''Return 1 if the color string format is a compressed one
 *     '''
 *     if x.startswith('palette'):             # <<<<<<<<<<<<<<
 *         return 1
 *     if x.startswith('pvrtc_'):
 */
  if (unlikely(((PyObject *)__pyx_v_x) == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "startswith");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_PyStr_Tailmatch(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_n_s__palette), 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if ((__pyx_t_1 != 0)) {

    /* "kivy\graphics\texture.pyx":306
 *     '''
 *     if x.startswith('palette'):
 *         return 1             # <<<<<<<<<<<<<<
 *     if x.startswith('pvrtc_'):
 *         return 1
 */
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "kivy\graphics\texture.pyx":307
 *     if x.startswith('palette'):
 *         return 1
 *     if x.startswith('pvrtc_'):             # <<<<<<<<<<<<<<
 *         return 1
 *     if x.startswith('etc1_'):
 */
  if (unlikely(((PyObject *)__pyx_v_x) == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "startswith");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_PyStr_Tailmatch(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_n_s__pvrtc_), 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if ((__pyx_t_1 != 0)) {

    /* "kivy\graphics\texture.pyx":308
 *         return 1
 *     if x.startswith('pvrtc_'):
 *         return 1             # <<<<<<<<<<<<<<
 *     if x.startswith('etc1_'):
 *         return 1
 */
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "kivy\graphics\texture.pyx":309
 *     if x.startswith('pvrtc_'):
 *         return 1
 *     if x.startswith('etc1_'):             # <<<<<<<<<<<<<<
 *         return 1
 *     return x.startswith('s3tc_dxt')
 */
  if (unlikely(((PyObject *)__pyx_v_x) == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "startswith");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_PyStr_Tailmatch(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_n_s__etc1_), 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if ((__pyx_t_1 != 0)) {

    /* "kivy\graphics\texture.pyx":310
 *         return 1
 *     if x.startswith('etc1_'):
 *         return 1             # <<<<<<<<<<<<<<
 *     return x.startswith('s3tc_dxt')
 * 
 */
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "kivy\graphics\texture.pyx":311
 *     if x.startswith('etc1_'):
 *         return 1
 *     return x.startswith('s3tc_dxt')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  if (unlikely(((PyObject *)__pyx_v_x) == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "startswith");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_PyStr_Tailmatch(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_n_s__s3tc_dxt), 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("kivy.graphics.texture._is_compressed_fmt", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":314
 * 
 * 
 * cdef inline int _buffer_fmt_to_gl(bytes x):             # <<<<<<<<<<<<<<
 *     '''Return the GL numeric value from a buffer string format
 *     '''
 */

static CYTHON_INLINE int __pyx_f_4kivy_8graphics_7texture__buffer_fmt_to_gl(PyObject *__pyx_v_x) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buffer_fmt_to_gl", 0);
  __Pyx_INCREF(__pyx_v_x);

  /* "kivy\graphics\texture.pyx":317
 *     '''Return the GL numeric value from a buffer string format
 *     '''
 *     x = x.lower()             # <<<<<<<<<<<<<<
 *     try:
 *         return _gl_buffer_fmt[x]
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x), __pyx_n_s__lower); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_v_x));
  __pyx_v_x = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "kivy\graphics\texture.pyx":318
 *     '''
 *     x = x.lower()
 *     try:             # <<<<<<<<<<<<<<
 *         return _gl_buffer_fmt[x]
 *     except KeyError:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {

      /* "kivy\graphics\texture.pyx":319
 *     x = x.lower()
 *     try:
 *         return _gl_buffer_fmt[x]             # <<<<<<<<<<<<<<
 *     except KeyError:
 *         raise Exception('Unknown <%s> buffer format' % x)
 */
      if (unlikely(((PyObject *)__pyx_v_4kivy_8graphics_7texture__gl_buffer_fmt) == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __pyx_t_2 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_4kivy_8graphics_7texture__gl_buffer_fmt), ((PyObject *)__pyx_v_x)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      goto __pyx_L7_try_return;
    }
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L10_try_end;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L0;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "kivy\graphics\texture.pyx":320
 *     try:
 *         return _gl_buffer_fmt[x]
 *     except KeyError:             # <<<<<<<<<<<<<<
 *         raise Exception('Unknown <%s> buffer format' % x)
 * 
 */
    __pyx_t_6 = PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_6) {
      __Pyx_AddTraceback("kivy.graphics.texture._buffer_fmt_to_gl", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_7);

      /* "kivy\graphics\texture.pyx":321
 *         return _gl_buffer_fmt[x]
 *     except KeyError:
 *         raise Exception('Unknown <%s> buffer format' % x)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_2), ((PyObject *)__pyx_v_x)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_8));
      __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_t_8));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_8));
      __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    __pyx_L10_try_end:;
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_WriteUnraisable("kivy.graphics.texture._buffer_fmt_to_gl", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":324
 * 
 * 
 * cdef inline int _buffer_type_to_gl_size(bytes x):             # <<<<<<<<<<<<<<
 *     '''Return the size of a buffer string format in bytes
 *     '''
 */

static CYTHON_INLINE int __pyx_f_4kivy_8graphics_7texture__buffer_type_to_gl_size(PyObject *__pyx_v_x) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_buffer_type_to_gl_size", 0);
  __Pyx_INCREF(__pyx_v_x);

  /* "kivy\graphics\texture.pyx":327
 *     '''Return the size of a buffer string format in bytes
 *     '''
 *     x = x.lower()             # <<<<<<<<<<<<<<
 *     try:
 *         return _gl_buffer_size[x]
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x), __pyx_n_s__lower); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_v_x));
  __pyx_v_x = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "kivy\graphics\texture.pyx":328
 *     '''
 *     x = x.lower()
 *     try:             # <<<<<<<<<<<<<<
 *         return _gl_buffer_size[x]
 *     except KeyError:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {

      /* "kivy\graphics\texture.pyx":329
 *     x = x.lower()
 *     try:
 *         return _gl_buffer_size[x]             # <<<<<<<<<<<<<<
 *     except KeyError:
 *         raise Exception('Unknown <%s> format' % x)
 */
      if (unlikely(((PyObject *)__pyx_v_4kivy_8graphics_7texture__gl_buffer_size) == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __pyx_t_2 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_4kivy_8graphics_7texture__gl_buffer_size), ((PyObject *)__pyx_v_x)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      goto __pyx_L7_try_return;
    }
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L10_try_end;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L0;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "kivy\graphics\texture.pyx":330
 *     try:
 *         return _gl_buffer_size[x]
 *     except KeyError:             # <<<<<<<<<<<<<<
 *         raise Exception('Unknown <%s> format' % x)
 * 
 */
    __pyx_t_6 = PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_6) {
      __Pyx_AddTraceback("kivy.graphics.texture._buffer_type_to_gl_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_7);

      /* "kivy\graphics\texture.pyx":331
 *         return _gl_buffer_size[x]
 *     except KeyError:
 *         raise Exception('Unknown <%s> format' % x)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_3), ((PyObject *)__pyx_v_x)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_8));
      __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_9);
      PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_t_8));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_8));
      __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    __pyx_L10_try_end:;
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_WriteUnraisable("kivy.graphics.texture._buffer_type_to_gl_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":334
 * 
 * 
 * cdef inline GLuint _str_to_gl_texture_min_filter(str x):             # <<<<<<<<<<<<<<
 *     '''Return the GL numeric value from a texture min filter string
 *     '''
 */

static CYTHON_INLINE GLuint __pyx_f_4kivy_8graphics_7texture__str_to_gl_texture_min_filter(PyObject *__pyx_v_x) {
  GLuint __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  GLuint __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_str_to_gl_texture_min_filter", 0);
  __Pyx_INCREF(__pyx_v_x);

  /* "kivy\graphics\texture.pyx":337
 *     '''Return the GL numeric value from a texture min filter string
 *     '''
 *     x = x.lower()             # <<<<<<<<<<<<<<
 *     try:
 *         return _gl_texture_min_filter[x]
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x), __pyx_n_s__lower); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(PyString_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_v_x));
  __pyx_v_x = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "kivy\graphics\texture.pyx":338
 *     '''
 *     x = x.lower()
 *     try:             # <<<<<<<<<<<<<<
 *         return _gl_texture_min_filter[x]
 *     except KeyError:
 */
  {
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {

      /* "kivy\graphics\texture.pyx":339
 *     x = x.lower()
 *     try:
 *         return _gl_texture_min_filter[x]             # <<<<<<<<<<<<<<
 *     except KeyError:
 *         raise Exception('Unknown <%s> texture min filter' % x)
 */
      if (unlikely(((PyObject *)__pyx_v_4kivy_8graphics_7texture__gl_texture_min_filter) == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      __pyx_t_2 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_4kivy_8graphics_7texture__gl_texture_min_filter), ((PyObject *)__pyx_v_x)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = __Pyx_PyInt_from_py_GLuint(__pyx_t_2); if (unlikely((__pyx_t_6 == (GLuint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_6;
      goto __pyx_L7_try_return;
    }
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L10_try_end;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L0;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "kivy\graphics\texture.pyx":340
 *     try:
 *         return _gl_texture_min_filter[x]
 *     except KeyError:             # <<<<<<<<<<<<<<
 *         raise Exception('Unknown <%s> texture min filter' % x)
 * 
 */
    __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_7) {
      __Pyx_AddTraceback("kivy.graphics.texture._str_to_gl_texture_min_filter", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_8);

      /* "kivy\graphics\texture.pyx":341
 *         return _gl_texture_min_filter[x]
 *     except KeyError:
 *         raise Exception('Unknown <%s> texture min filter' % x)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), ((PyObject *)__pyx_v_x)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_9));
      __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_10);
      PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_t_9));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_9));
      __pyx_t_9 = 0;
      __pyx_t_9 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
      __Pyx_Raise(__pyx_t_9, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    __pyx_L10_try_end:;
  }

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_WriteUnraisable("kivy.graphics.texture._str_to_gl_texture_min_filter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":344
 * 
 * 
 * cdef inline GLuint _str_to_gl_texture_mag_filter(str x):             # <<<<<<<<<<<<<<
 *     '''Return the GL numeric value from a texture mag filter string
 *     '''
 */

static CYTHON_INLINE GLuint __pyx_f_4kivy_8graphics_7texture__str_to_gl_texture_mag_filter(PyObject *__pyx_v_x) {
  GLuint __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_str_to_gl_texture_mag_filter", 0);
  __Pyx_INCREF(__pyx_v_x);

  /* "kivy\graphics\texture.pyx":347
 *     '''Return the GL numeric value from a texture mag filter string
 *     '''
 *     x = x.lower()             # <<<<<<<<<<<<<<
 *     if x == 'nearest':
 *         return GL_NEAREST
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_x), __pyx_n_s__lower); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (!(likely(PyString_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_v_x));
  __pyx_v_x = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "kivy\graphics\texture.pyx":348
 *     '''
 *     x = x.lower()
 *     if x == 'nearest':             # <<<<<<<<<<<<<<
 *         return GL_NEAREST
 *     elif x == 'linear':
 */
  __pyx_t_3 = (__Pyx_PyString_Equals(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_n_s__nearest), Py_EQ)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "kivy\graphics\texture.pyx":349
 *     x = x.lower()
 *     if x == 'nearest':
 *         return GL_NEAREST             # <<<<<<<<<<<<<<
 *     elif x == 'linear':
 *         return GL_LINEAR
 */
    __pyx_r = GL_NEAREST;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "kivy\graphics\texture.pyx":350
 *     if x == 'nearest':
 *         return GL_NEAREST
 *     elif x == 'linear':             # <<<<<<<<<<<<<<
 *         return GL_LINEAR
 *     raise Exception('Unknown <%s> texture mag filter' % x)
 */
  __pyx_t_4 = (__Pyx_PyString_Equals(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_n_s__linear), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = (__pyx_t_4 != 0);
  if (__pyx_t_3) {

    /* "kivy\graphics\texture.pyx":351
 *         return GL_NEAREST
 *     elif x == 'linear':
 *         return GL_LINEAR             # <<<<<<<<<<<<<<
 *     raise Exception('Unknown <%s> texture mag filter' % x)
 * 
 */
    __pyx_r = GL_LINEAR;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "kivy\graphics\texture.pyx":352
 *     elif x == 'linear':
 *         return GL_LINEAR
 *     raise Exception('Unknown <%s> texture mag filter' % x)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), ((PyObject *)__pyx_v_x)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_2));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_Raise(__pyx_t_2, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_WriteUnraisable("kivy.graphics.texture._str_to_gl_texture_mag_filter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_x);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":355
 * 
 * 
 * cdef inline GLuint _str_to_gl_texture_wrap(str x):             # <<<<<<<<<<<<<<
 *     '''Return the GL numeric value from a texture wrap string
 *     '''
 */

static CYTHON_INLINE GLuint __pyx_f_4kivy_8graphics_7texture__str_to_gl_texture_wrap(PyObject *__pyx_v_x) {
  GLuint __pyx_r;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_str_to_gl_texture_wrap", 0);

  /* "kivy\graphics\texture.pyx":358
 *     '''Return the GL numeric value from a texture wrap string
 *     '''
 *     if x == 'clamp_to_edge':             # <<<<<<<<<<<<<<
 *         return GL_CLAMP_TO_EDGE
 *     elif x == 'repeat':
 */
  __pyx_t_1 = (__Pyx_PyString_Equals(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_n_s__clamp_to_edge), Py_EQ)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "kivy\graphics\texture.pyx":359
 *     '''
 *     if x == 'clamp_to_edge':
 *         return GL_CLAMP_TO_EDGE             # <<<<<<<<<<<<<<
 *     elif x == 'repeat':
 *         return GL_REPEAT
 */
    __pyx_r = GL_CLAMP_TO_EDGE;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "kivy\graphics\texture.pyx":360
 *     if x == 'clamp_to_edge':
 *         return GL_CLAMP_TO_EDGE
 *     elif x == 'repeat':             # <<<<<<<<<<<<<<
 *         return GL_REPEAT
 *     elif x == 'mirrored_repeat':
 */
  __pyx_t_2 = (__Pyx_PyString_Equals(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_n_s__repeat), Py_EQ)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "kivy\graphics\texture.pyx":361
 *         return GL_CLAMP_TO_EDGE
 *     elif x == 'repeat':
 *         return GL_REPEAT             # <<<<<<<<<<<<<<
 *     elif x == 'mirrored_repeat':
 *         return GL_MIRRORED_REPEAT
 */
    __pyx_r = GL_REPEAT;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "kivy\graphics\texture.pyx":362
 *     elif x == 'repeat':
 *         return GL_REPEAT
 *     elif x == 'mirrored_repeat':             # <<<<<<<<<<<<<<
 *         return GL_MIRRORED_REPEAT
 * 
 */
  __pyx_t_1 = (__Pyx_PyString_Equals(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_n_s__mirrored_repeat), Py_EQ)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "kivy\graphics\texture.pyx":363
 *         return GL_REPEAT
 *     elif x == 'mirrored_repeat':
 *         return GL_MIRRORED_REPEAT             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_r = GL_MIRRORED_REPEAT;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("kivy.graphics.texture._str_to_gl_texture_wrap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":366
 * 
 * 
 * cdef inline int _gl_format_size(GLuint x):             # <<<<<<<<<<<<<<
 *     '''Return the GL numeric value from a texture wrap string
 *     '''
 */

static CYTHON_INLINE int __pyx_f_4kivy_8graphics_7texture__gl_format_size(GLuint __pyx_v_x) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  GLuint __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_gl_format_size", 0);

  /* "kivy\graphics\texture.pyx":369
 *     '''Return the GL numeric value from a texture wrap string
 *     '''
 *     if x in (GL_RGB, GL_BGR):             # <<<<<<<<<<<<<<
 *         return 3
 *     elif x in (GL_RGBA, GL_BGRA):
 */
  __pyx_t_1 = __pyx_v_x;
  __pyx_t_2 = ((int)(__pyx_t_1 == GL_RGB));
  if (!__pyx_t_2) {
    __pyx_t_3 = ((int)(__pyx_t_1 == __pyx_v_4kivy_8graphics_7texture_GL_BGR));
    __pyx_t_4 = __pyx_t_3;
  } else {
    __pyx_t_4 = __pyx_t_2;
  }
  __pyx_t_2 = (__pyx_t_4 != 0);
  if (__pyx_t_2) {

    /* "kivy\graphics\texture.pyx":370
 *     '''
 *     if x in (GL_RGB, GL_BGR):
 *         return 3             # <<<<<<<<<<<<<<
 *     elif x in (GL_RGBA, GL_BGRA):
 *         return 4
 */
    __pyx_r = 3;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "kivy\graphics\texture.pyx":371
 *     if x in (GL_RGB, GL_BGR):
 *         return 3
 *     elif x in (GL_RGBA, GL_BGRA):             # <<<<<<<<<<<<<<
 *         return 4
 *     elif x == GL_LUMINANCE_ALPHA:
 */
  __pyx_t_1 = __pyx_v_x;
  __pyx_t_2 = ((int)(__pyx_t_1 == GL_RGBA));
  if (!__pyx_t_2) {
    __pyx_t_4 = ((int)(__pyx_t_1 == __pyx_v_4kivy_8graphics_7texture_GL_BGRA));
    __pyx_t_3 = __pyx_t_4;
  } else {
    __pyx_t_3 = __pyx_t_2;
  }
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "kivy\graphics\texture.pyx":372
 *         return 3
 *     elif x in (GL_RGBA, GL_BGRA):
 *         return 4             # <<<<<<<<<<<<<<
 *     elif x == GL_LUMINANCE_ALPHA:
 *         return 2
 */
    __pyx_r = 4;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "kivy\graphics\texture.pyx":373
 *     elif x in (GL_RGBA, GL_BGRA):
 *         return 4
 *     elif x == GL_LUMINANCE_ALPHA:             # <<<<<<<<<<<<<<
 *         return 2
 *     elif x == GL_LUMINANCE:
 */
  __pyx_t_2 = ((__pyx_v_x == GL_LUMINANCE_ALPHA) != 0);
  if (__pyx_t_2) {

    /* "kivy\graphics\texture.pyx":374
 *         return 4
 *     elif x == GL_LUMINANCE_ALPHA:
 *         return 2             # <<<<<<<<<<<<<<
 *     elif x == GL_LUMINANCE:
 *         return 1
 */
    __pyx_r = 2;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "kivy\graphics\texture.pyx":375
 *     elif x == GL_LUMINANCE_ALPHA:
 *         return 2
 *     elif x == GL_LUMINANCE:             # <<<<<<<<<<<<<<
 *         return 1
 *     elif x in (GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
 */
  __pyx_t_2 = ((__pyx_v_x == GL_LUMINANCE) != 0);
  if (__pyx_t_2) {

    /* "kivy\graphics\texture.pyx":376
 *         return 2
 *     elif x == GL_LUMINANCE:
 *         return 1             # <<<<<<<<<<<<<<
 *     elif x in (GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
 *             GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
 */
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "kivy\graphics\texture.pyx":377
 *     elif x == GL_LUMINANCE:
 *         return 1
 *     elif x in (GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,             # <<<<<<<<<<<<<<
 *             GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
 *             GL_COMPRESSED_RGBA_S3TC_DXT5_EXT):
 */
  __pyx_t_1 = __pyx_v_x;
  __pyx_t_2 = ((int)(__pyx_t_1 == __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT));
  if (!__pyx_t_2) {

    /* "kivy\graphics\texture.pyx":378
 *         return 1
 *     elif x in (GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
 *             GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,             # <<<<<<<<<<<<<<
 *             GL_COMPRESSED_RGBA_S3TC_DXT5_EXT):
 *         return 4
 */
    __pyx_t_3 = ((int)(__pyx_t_1 == __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT));
    __pyx_t_4 = __pyx_t_3;
  } else {
    __pyx_t_4 = __pyx_t_2;
  }
  if (!__pyx_t_4) {

    /* "kivy\graphics\texture.pyx":379
 *     elif x in (GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
 *             GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
 *             GL_COMPRESSED_RGBA_S3TC_DXT5_EXT):             # <<<<<<<<<<<<<<
 *         return 4
 *     raise Exception('Unsupported format size <%s>' % str(format))
 */
    __pyx_t_2 = ((int)(__pyx_t_1 == __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT));
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_4;
  }
  __pyx_t_4 = (__pyx_t_3 != 0);
  if (__pyx_t_4) {

    /* "kivy\graphics\texture.pyx":380
 *             GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
 *             GL_COMPRESSED_RGBA_S3TC_DXT5_EXT):
 *         return 4             # <<<<<<<<<<<<<<
 *     raise Exception('Unsupported format size <%s>' % str(format))
 * 
 */
    __pyx_r = 4;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "kivy\graphics\texture.pyx":381
 *             GL_COMPRESSED_RGBA_S3TC_DXT5_EXT):
 *         return 4
 *     raise Exception('Unsupported format size <%s>' % str(format))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_builtin_format);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_builtin_format);
  __Pyx_GIVEREF(__pyx_builtin_format);
  __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_6), __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
  __pyx_t_5 = 0;
  __pyx_t_5 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  __Pyx_Raise(__pyx_t_5, 0, 0, 0);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("kivy.graphics.texture._gl_format_size", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":384
 * 
 * 
 * cdef inline int _is_gl_format_supported(str x):             # <<<<<<<<<<<<<<
 *     if x in ('bgr', 'bgra'):
 *         return gl_has_capability(GLCAP_BGRA)
 */

static CYTHON_INLINE int __pyx_f_4kivy_8graphics_7texture__is_gl_format_supported(PyObject *__pyx_v_x) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_is_gl_format_supported", 0);

  /* "kivy\graphics\texture.pyx":385
 * 
 * cdef inline int _is_gl_format_supported(str x):
 *     if x in ('bgr', 'bgra'):             # <<<<<<<<<<<<<<
 *         return gl_has_capability(GLCAP_BGRA)
 *     elif x == 's3tc_dxt1':
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_x));
  __pyx_t_1 = __pyx_v_x;
  __pyx_t_2 = (__Pyx_PyString_Equals(((PyObject *)__pyx_t_1), ((PyObject *)__pyx_n_s__bgr), Py_EQ)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!((int)__pyx_t_2)) {
    __pyx_t_3 = (__Pyx_PyString_Equals(((PyObject *)__pyx_t_1), ((PyObject *)__pyx_n_s__bgra), Py_EQ)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = ((int)__pyx_t_3);
  } else {
    __pyx_t_4 = ((int)__pyx_t_2);
  }
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_2 = (__pyx_t_4 != 0);
  if (__pyx_t_2) {

    /* "kivy\graphics\texture.pyx":386
 * cdef inline int _is_gl_format_supported(str x):
 *     if x in ('bgr', 'bgra'):
 *         return gl_has_capability(GLCAP_BGRA)             # <<<<<<<<<<<<<<
 *     elif x == 's3tc_dxt1':
 *         return gl_has_capability(GLCAP_DXT1)
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__GLCAP_BGRA); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_r = __pyx_f_4kivy_8graphics_12opengl_utils_gl_has_capability(__pyx_t_6, 0);
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "kivy\graphics\texture.pyx":387
 *     if x in ('bgr', 'bgra'):
 *         return gl_has_capability(GLCAP_BGRA)
 *     elif x == 's3tc_dxt1':             # <<<<<<<<<<<<<<
 *         return gl_has_capability(GLCAP_DXT1)
 *     elif x.startswith('s3tc_dxt'):
 */
  __pyx_t_2 = (__Pyx_PyString_Equals(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_n_s__s3tc_dxt1), Py_EQ)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = (__pyx_t_2 != 0);
  if (__pyx_t_4) {

    /* "kivy\graphics\texture.pyx":388
 *         return gl_has_capability(GLCAP_BGRA)
 *     elif x == 's3tc_dxt1':
 *         return gl_has_capability(GLCAP_DXT1)             # <<<<<<<<<<<<<<
 *     elif x.startswith('s3tc_dxt'):
 *         return gl_has_capability(GLCAP_S3TC)
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__GLCAP_DXT1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_r = __pyx_f_4kivy_8graphics_12opengl_utils_gl_has_capability(__pyx_t_6, 0);
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "kivy\graphics\texture.pyx":389
 *     elif x == 's3tc_dxt1':
 *         return gl_has_capability(GLCAP_DXT1)
 *     elif x.startswith('s3tc_dxt'):             # <<<<<<<<<<<<<<
 *         return gl_has_capability(GLCAP_S3TC)
 *     elif x.startswith('etc1_'):
 */
  if (unlikely(((PyObject *)__pyx_v_x) == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "startswith");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = __Pyx_PyStr_Tailmatch(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_n_s__s3tc_dxt), 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if ((__pyx_t_4 != 0)) {

    /* "kivy\graphics\texture.pyx":390
 *         return gl_has_capability(GLCAP_DXT1)
 *     elif x.startswith('s3tc_dxt'):
 *         return gl_has_capability(GLCAP_S3TC)             # <<<<<<<<<<<<<<
 *     elif x.startswith('etc1_'):
 *         return gl_has_capability(GLCAP_ETC1)
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__GLCAP_S3TC); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_r = __pyx_f_4kivy_8graphics_12opengl_utils_gl_has_capability(__pyx_t_6, 0);
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "kivy\graphics\texture.pyx":391
 *     elif x.startswith('s3tc_dxt'):
 *         return gl_has_capability(GLCAP_S3TC)
 *     elif x.startswith('etc1_'):             # <<<<<<<<<<<<<<
 *         return gl_has_capability(GLCAP_ETC1)
 *     return 1
 */
  if (unlikely(((PyObject *)__pyx_v_x) == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "startswith");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_4 = __Pyx_PyStr_Tailmatch(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_n_s__etc1_), 0, PY_SSIZE_T_MAX, -1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if ((__pyx_t_4 != 0)) {

    /* "kivy\graphics\texture.pyx":392
 *         return gl_has_capability(GLCAP_S3TC)
 *     elif x.startswith('etc1_'):
 *         return gl_has_capability(GLCAP_ETC1)             # <<<<<<<<<<<<<<
 *     return 1
 * 
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__GLCAP_ETC1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_r = __pyx_f_4kivy_8graphics_12opengl_utils_gl_has_capability(__pyx_t_6, 0);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "kivy\graphics\texture.pyx":393
 *     elif x.startswith('etc1_'):
 *         return gl_has_capability(GLCAP_ETC1)
 *     return 1             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(((PyObject *)__pyx_t_1));
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("kivy.graphics.texture._is_gl_format_supported", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":396
 * 
 * 
 * cdef inline str _convert_gl_format(str x):             # <<<<<<<<<<<<<<
 *     if x == 'bgr':
 *         return 'rgb'
 */

static CYTHON_INLINE PyObject *__pyx_f_4kivy_8graphics_7texture__convert_gl_format(PyObject *__pyx_v_x) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_convert_gl_format", 0);

  /* "kivy\graphics\texture.pyx":397
 * 
 * cdef inline str _convert_gl_format(str x):
 *     if x == 'bgr':             # <<<<<<<<<<<<<<
 *         return 'rgb'
 *     elif x == 'bgra':
 */
  __pyx_t_1 = (__Pyx_PyString_Equals(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_n_s__bgr), Py_EQ)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "kivy\graphics\texture.pyx":398
 * cdef inline str _convert_gl_format(str x):
 *     if x == 'bgr':
 *         return 'rgb'             # <<<<<<<<<<<<<<
 *     elif x == 'bgra':
 *         return 'rgba'
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_n_s__rgb));
    __pyx_r = __pyx_n_s__rgb;
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "kivy\graphics\texture.pyx":399
 *     if x == 'bgr':
 *         return 'rgb'
 *     elif x == 'bgra':             # <<<<<<<<<<<<<<
 *         return 'rgba'
 *     return x
 */
  __pyx_t_2 = (__Pyx_PyString_Equals(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_n_s__bgra), Py_EQ)); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "kivy\graphics\texture.pyx":400
 *         return 'rgb'
 *     elif x == 'bgra':
 *         return 'rgba'             # <<<<<<<<<<<<<<
 *     return x
 * 
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_n_s__rgba));
    __pyx_r = __pyx_n_s__rgba;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "kivy\graphics\texture.pyx":401
 *     elif x == 'bgra':
 *         return 'rgba'
 *     return x             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_x));
  __pyx_r = __pyx_v_x;
  goto __pyx_L0;

  __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("kivy.graphics.texture._convert_gl_format", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":404
 * 
 * 
 * cdef inline _convert_buffer(bytes data, str fmt):             # <<<<<<<<<<<<<<
 *     cdef bytes ret_buffer
 *     cdef str ret_format
 */

static CYTHON_INLINE PyObject *__pyx_f_4kivy_8graphics_7texture__convert_buffer(PyObject *__pyx_v_data, PyObject *__pyx_v_fmt) {
  PyObject *__pyx_v_ret_buffer = 0;
  PyObject *__pyx_v_ret_format = 0;
  PyObject *__pyx_v_a = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_convert_buffer", 0);

  /* "kivy\graphics\texture.pyx":409
 * 
 *     # if native support of this format is available, use it
 *     if gl_has_texture_native_format(fmt):             # <<<<<<<<<<<<<<
 *         return data, fmt
 * 
 */
  __pyx_t_1 = (__pyx_f_4kivy_8graphics_12opengl_utils_gl_has_texture_native_format(__pyx_v_fmt, 0) != 0);
  if (__pyx_t_1) {

    /* "kivy\graphics\texture.pyx":410
 *     # if native support of this format is available, use it
 *     if gl_has_texture_native_format(fmt):
 *         return data, fmt             # <<<<<<<<<<<<<<
 * 
 *     # no native support, can we at least convert it ?
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_INCREF(((PyObject *)__pyx_v_data));
    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_data));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_data));
    __Pyx_INCREF(((PyObject *)__pyx_v_fmt));
    PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_fmt));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_fmt));
    __pyx_r = ((PyObject *)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "kivy\graphics\texture.pyx":413
 * 
 *     # no native support, can we at least convert it ?
 *     if not gl_has_texture_conversion(fmt):             # <<<<<<<<<<<<<<
 *         raise Exception('Unimplemented texture conversion for %s' % fmt)
 * 
 */
  __pyx_t_1 = ((!(__pyx_f_4kivy_8graphics_12opengl_utils_gl_has_texture_conversion(__pyx_v_fmt, 0) != 0)) != 0);
  if (__pyx_t_1) {

    /* "kivy\graphics\texture.pyx":414
 *     # no native support, can we at least convert it ?
 *     if not gl_has_texture_conversion(fmt):
 *         raise Exception('Unimplemented texture conversion for %s' % fmt)             # <<<<<<<<<<<<<<
 * 
 *     # do appropriate conversion, since we accepted it
 */
    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_7), ((PyObject *)__pyx_v_fmt)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "kivy\graphics\texture.pyx":417
 * 
 *     # do appropriate conversion, since we accepted it
 *     ret_format = fmt             # <<<<<<<<<<<<<<
 *     ret_buffer = data
 * 
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_fmt));
  __pyx_v_ret_format = __pyx_v_fmt;

  /* "kivy\graphics\texture.pyx":418
 *     # do appropriate conversion, since we accepted it
 *     ret_format = fmt
 *     ret_buffer = data             # <<<<<<<<<<<<<<
 * 
 *     # BGR -> RGB
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_data));
  __pyx_v_ret_buffer = __pyx_v_data;

  /* "kivy\graphics\texture.pyx":421
 * 
 *     # BGR -> RGB
 *     if fmt == 'bgr':             # <<<<<<<<<<<<<<
 *         ret_format = 'rgb'
 *         a = array('b', data)
 */
  __pyx_t_1 = (__Pyx_PyString_Equals(((PyObject *)__pyx_v_fmt), ((PyObject *)__pyx_n_s__bgr), Py_EQ)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = (__pyx_t_1 != 0);
  if (__pyx_t_4) {

    /* "kivy\graphics\texture.pyx":422
 *     # BGR -> RGB
 *     if fmt == 'bgr':
 *         ret_format = 'rgb'             # <<<<<<<<<<<<<<
 *         a = array('b', data)
 *         a[0::3], a[2::3] = a[2::3], a[0::3]
 */
    __Pyx_INCREF(((PyObject *)__pyx_n_s__rgb));
    __Pyx_DECREF(((PyObject *)__pyx_v_ret_format));
    __pyx_v_ret_format = __pyx_n_s__rgb;

    /* "kivy\graphics\texture.pyx":423
 *     if fmt == 'bgr':
 *         ret_format = 'rgb'
 *         a = array('b', data)             # <<<<<<<<<<<<<<
 *         a[0::3], a[2::3] = a[2::3], a[0::3]
 *         ret_buffer = a.tostring()
 */
    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s__array); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_n_s__b));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__b));
    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__b));
    __Pyx_INCREF(((PyObject *)__pyx_v_data));
    PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_data));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_data));
    __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __pyx_v_a = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "kivy\graphics\texture.pyx":424
 *         ret_format = 'rgb'
 *         a = array('b', data)
 *         a[0::3], a[2::3] = a[2::3], a[0::3]             # <<<<<<<<<<<<<<
 *         ret_buffer = a.tostring()
 * 
 */
    __pyx_t_5 = PyObject_GetItem(__pyx_v_a, __pyx_k_slice_8); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyObject_GetItem(__pyx_v_a, __pyx_k_slice_9); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyObject_SetItem(__pyx_v_a, __pyx_k_slice_10, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (PyObject_SetItem(__pyx_v_a, __pyx_k_slice_11, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "kivy\graphics\texture.pyx":425
 *         a = array('b', data)
 *         a[0::3], a[2::3] = a[2::3], a[0::3]
 *         ret_buffer = a.tostring()             # <<<<<<<<<<<<<<
 * 
 *     # BGRA -> RGBA
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s__tostring); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (!(likely(PyBytes_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_v_ret_buffer));
    __pyx_v_ret_buffer = ((PyObject*)__pyx_t_5);
    __pyx_t_5 = 0;
    goto __pyx_L5;
  }

  /* "kivy\graphics\texture.pyx":428
 * 
 *     # BGRA -> RGBA
 *     elif fmt == 'bgra':             # <<<<<<<<<<<<<<
 *         ret_format = 'rgba'
 *         a = array('b', data)
 */
  __pyx_t_4 = (__Pyx_PyString_Equals(((PyObject *)__pyx_v_fmt), ((PyObject *)__pyx_n_s__bgra), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = (__pyx_t_4 != 0);
  if (__pyx_t_1) {

    /* "kivy\graphics\texture.pyx":429
 *     # BGRA -> RGBA
 *     elif fmt == 'bgra':
 *         ret_format = 'rgba'             # <<<<<<<<<<<<<<
 *         a = array('b', data)
 *         a[0::4], a[2::4] = a[2::4], a[0::4]
 */
    __Pyx_INCREF(((PyObject *)__pyx_n_s__rgba));
    __Pyx_DECREF(((PyObject *)__pyx_v_ret_format));
    __pyx_v_ret_format = __pyx_n_s__rgba;

    /* "kivy\graphics\texture.pyx":430
 *     elif fmt == 'bgra':
 *         ret_format = 'rgba'
 *         a = array('b', data)             # <<<<<<<<<<<<<<
 *         a[0::4], a[2::4] = a[2::4], a[0::4]
 *         ret_buffer = a.tostring()
 */
    __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s__array); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_INCREF(((PyObject *)__pyx_n_s__b));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__b));
    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__b));
    __Pyx_INCREF(((PyObject *)__pyx_v_data));
    PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_data));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_data));
    __pyx_t_2 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __pyx_v_a = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "kivy\graphics\texture.pyx":431
 *         ret_format = 'rgba'
 *         a = array('b', data)
 *         a[0::4], a[2::4] = a[2::4], a[0::4]             # <<<<<<<<<<<<<<
 *         ret_buffer = a.tostring()
 * 
 */
    __pyx_t_2 = PyObject_GetItem(__pyx_v_a, __pyx_k_slice_12); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_GetItem(__pyx_v_a, __pyx_k_slice_13); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyObject_SetItem(__pyx_v_a, __pyx_k_slice_14, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (PyObject_SetItem(__pyx_v_a, __pyx_k_slice_15, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "kivy\graphics\texture.pyx":432
 *         a = array('b', data)
 *         a[0::4], a[2::4] = a[2::4], a[0::4]
 *         ret_buffer = a.tostring()             # <<<<<<<<<<<<<<
 * 
 *     else:
 */
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_a, __pyx_n_s__tostring); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_v_ret_buffer));
    __pyx_v_ret_buffer = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "kivy\graphics\texture.pyx":435
 * 
 *     else:
 *         assert False, 'Non implemented texture conversion !' % fmt             # <<<<<<<<<<<<<<
 * 
 *     return ret_buffer, ret_format
 */
    #ifndef CYTHON_WITHOUT_ASSERTIONS
    if (unlikely(!0)) {
      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_16), ((PyObject *)__pyx_v_fmt)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_t_2));
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #endif
  }
  __pyx_L5:;

  /* "kivy\graphics\texture.pyx":437
 *         assert False, 'Non implemented texture conversion !' % fmt
 * 
 *     return ret_buffer, ret_format             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_ret_buffer));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_ret_buffer));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_ret_buffer));
  __Pyx_INCREF(((PyObject *)__pyx_v_ret_format));
  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_ret_format));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_ret_format));
  __pyx_r = ((PyObject *)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("kivy.graphics.texture._convert_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_ret_buffer);
  __Pyx_XDECREF(__pyx_v_ret_format);
  __Pyx_XDECREF(__pyx_v_a);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":440
 * 
 * 
 * cdef inline void _gl_prepare_pixels_upload(int width) nogil:             # <<<<<<<<<<<<<<
 *     '''Set the best pixel alignement for the current width
 *     '''
 */

static CYTHON_INLINE void __pyx_f_4kivy_8graphics_7texture__gl_prepare_pixels_upload(int __pyx_v_width) {
  int __pyx_t_1;

  /* "kivy\graphics\texture.pyx":443
 *     '''Set the best pixel alignement for the current width
 *     '''
 *     if not (width & 0x7):             # <<<<<<<<<<<<<<
 *         glPixelStorei(GL_UNPACK_ALIGNMENT, 8)
 *     elif not (width & 0x3):
 */
  __pyx_t_1 = ((!((__pyx_v_width & 0x7) != 0)) != 0);
  if (__pyx_t_1) {

    /* "kivy\graphics\texture.pyx":444
 *     '''
 *     if not (width & 0x7):
 *         glPixelStorei(GL_UNPACK_ALIGNMENT, 8)             # <<<<<<<<<<<<<<
 *     elif not (width & 0x3):
 *         glPixelStorei(GL_UNPACK_ALIGNMENT, 4)
 */
    glPixelStorei(GL_UNPACK_ALIGNMENT, 8);
    goto __pyx_L3;
  }

  /* "kivy\graphics\texture.pyx":445
 *     if not (width & 0x7):
 *         glPixelStorei(GL_UNPACK_ALIGNMENT, 8)
 *     elif not (width & 0x3):             # <<<<<<<<<<<<<<
 *         glPixelStorei(GL_UNPACK_ALIGNMENT, 4)
 *     elif not (width & 0x1):
 */
  __pyx_t_1 = ((!((__pyx_v_width & 0x3) != 0)) != 0);
  if (__pyx_t_1) {

    /* "kivy\graphics\texture.pyx":446
 *         glPixelStorei(GL_UNPACK_ALIGNMENT, 8)
 *     elif not (width & 0x3):
 *         glPixelStorei(GL_UNPACK_ALIGNMENT, 4)             # <<<<<<<<<<<<<<
 *     elif not (width & 0x1):
 *         glPixelStorei(GL_UNPACK_ALIGNMENT, 2)
 */
    glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
    goto __pyx_L3;
  }

  /* "kivy\graphics\texture.pyx":447
 *     elif not (width & 0x3):
 *         glPixelStorei(GL_UNPACK_ALIGNMENT, 4)
 *     elif not (width & 0x1):             # <<<<<<<<<<<<<<
 *         glPixelStorei(GL_UNPACK_ALIGNMENT, 2)
 *     else:
 */
  __pyx_t_1 = ((!((__pyx_v_width & 0x1) != 0)) != 0);
  if (__pyx_t_1) {

    /* "kivy\graphics\texture.pyx":448
 *         glPixelStorei(GL_UNPACK_ALIGNMENT, 4)
 *     elif not (width & 0x1):
 *         glPixelStorei(GL_UNPACK_ALIGNMENT, 2)             # <<<<<<<<<<<<<<
 *     else:
 *         glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
 */
    glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
    goto __pyx_L3;
  }
  /*else*/ {

    /* "kivy\graphics\texture.pyx":450
 *         glPixelStorei(GL_UNPACK_ALIGNMENT, 2)
 *     else:
 *         glPixelStorei(GL_UNPACK_ALIGNMENT, 1)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  }
  __pyx_L3:;

}

/* "kivy\graphics\texture.pyx":453
 * 
 * 
 * cdef Texture _texture_create(int width, int height, str colorfmt, str bufferfmt,             # <<<<<<<<<<<<<<
 *                      int mipmap, int allocate, object callback):
 *     '''Create the OpenGL texture.
 */

static struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_f_4kivy_8graphics_7texture__texture_create(int __pyx_v_width, int __pyx_v_height, PyObject *__pyx_v_colorfmt, PyObject *__pyx_v_bufferfmt, int __pyx_v_mipmap, int __pyx_v_allocate, PyObject *__pyx_v_callback) {
  GLuint __pyx_v_target;
  CYTHON_UNUSED GLuint __pyx_v_texid;
  struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_texture = 0;
  int __pyx_v_texture_width;
  int __pyx_v_texture_height;
  CYTHON_UNUSED int __pyx_v_glbufferfmt;
  int __pyx_v_make_npot;
  struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_texture_create", 0);
  __Pyx_INCREF(__pyx_v_colorfmt);

  /* "kivy\graphics\texture.pyx":457
 *     '''Create the OpenGL texture.
 *     '''
 *     cdef GLuint target = GL_TEXTURE_2D             # <<<<<<<<<<<<<<
 *     cdef GLuint texid = 0
 *     cdef Texture texture
 */
  __pyx_v_target = GL_TEXTURE_2D;

  /* "kivy\graphics\texture.pyx":458
 *     '''
 *     cdef GLuint target = GL_TEXTURE_2D
 *     cdef GLuint texid = 0             # <<<<<<<<<<<<<<
 *     cdef Texture texture
 *     cdef int texture_width, texture_height
 */
  __pyx_v_texid = 0;

  /* "kivy\graphics\texture.pyx":461
 *     cdef Texture texture
 *     cdef int texture_width, texture_height
 *     cdef int glbufferfmt = _buffer_fmt_to_gl(<bytes>bufferfmt)             # <<<<<<<<<<<<<<
 *     cdef int make_npot = 0
 * 
 */
  __pyx_v_glbufferfmt = __pyx_f_4kivy_8graphics_7texture__buffer_fmt_to_gl(((PyObject*)__pyx_v_bufferfmt));

  /* "kivy\graphics\texture.pyx":462
 *     cdef int texture_width, texture_height
 *     cdef int glbufferfmt = _buffer_fmt_to_gl(<bytes>bufferfmt)
 *     cdef int make_npot = 0             # <<<<<<<<<<<<<<
 * 
 *     # check if it's a pot or not
 */
  __pyx_v_make_npot = 0;

  /* "kivy\graphics\texture.pyx":465
 * 
 *     # check if it's a pot or not
 *     if not _is_pow2(width) or not _is_pow2(height):             # <<<<<<<<<<<<<<
 *         make_npot = 1
 * 
 */
  __pyx_t_1 = ((!(__pyx_f_4kivy_8graphics_7texture__is_pow2(__pyx_v_width) != 0)) != 0);
  if (!__pyx_t_1) {
    __pyx_t_2 = ((!(__pyx_f_4kivy_8graphics_7texture__is_pow2(__pyx_v_height) != 0)) != 0);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "kivy\graphics\texture.pyx":466
 *     # check if it's a pot or not
 *     if not _is_pow2(width) or not _is_pow2(height):
 *         make_npot = 1             # <<<<<<<<<<<<<<
 * 
 *     IF not USE_OPENGL_ES2:
 */
    __pyx_v_make_npot = 1;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "kivy\graphics\texture.pyx":473
 * 
 *     # in case of mipmap is asked for npot texture, make it pot compatible
 *     if mipmap:             # <<<<<<<<<<<<<<
 *         make_npot = 0
 *         allocate = 1
 */
  __pyx_t_3 = (__pyx_v_mipmap != 0);
  if (__pyx_t_3) {

    /* "kivy\graphics\texture.pyx":474
 *     # in case of mipmap is asked for npot texture, make it pot compatible
 *     if mipmap:
 *         make_npot = 0             # <<<<<<<<<<<<<<
 *         allocate = 1
 * 
 */
    __pyx_v_make_npot = 0;

    /* "kivy\graphics\texture.pyx":475
 *     if mipmap:
 *         make_npot = 0
 *         allocate = 1             # <<<<<<<<<<<<<<
 * 
 *     # depending if npot is available, use the real size or pot size
 */
    __pyx_v_allocate = 1;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "kivy\graphics\texture.pyx":478
 * 
 *     # depending if npot is available, use the real size or pot size
 *     if make_npot and gl_has_capability(c_GLCAP_NPOT):             # <<<<<<<<<<<<<<
 *         texture_width = width
 *         texture_height = height
 */
  if ((__pyx_v_make_npot != 0)) {
    __pyx_t_3 = (__pyx_f_4kivy_8graphics_12opengl_utils_gl_has_capability(__pyx_v_4kivy_8graphics_7texture_c_GLCAP_NPOT, 0) != 0);
    __pyx_t_1 = __pyx_t_3;
  } else {
    __pyx_t_1 = (__pyx_v_make_npot != 0);
  }
  if (__pyx_t_1) {

    /* "kivy\graphics\texture.pyx":479
 *     # depending if npot is available, use the real size or pot size
 *     if make_npot and gl_has_capability(c_GLCAP_NPOT):
 *         texture_width = width             # <<<<<<<<<<<<<<
 *         texture_height = height
 *     else:
 */
    __pyx_v_texture_width = __pyx_v_width;

    /* "kivy\graphics\texture.pyx":480
 *     if make_npot and gl_has_capability(c_GLCAP_NPOT):
 *         texture_width = width
 *         texture_height = height             # <<<<<<<<<<<<<<
 *     else:
 *         texture_width = _nearest_pow2(width)
 */
    __pyx_v_texture_height = __pyx_v_height;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "kivy\graphics\texture.pyx":482
 *         texture_height = height
 *     else:
 *         texture_width = _nearest_pow2(width)             # <<<<<<<<<<<<<<
 *         texture_height = _nearest_pow2(height)
 * 
 */
    __pyx_v_texture_width = __pyx_f_4kivy_8graphics_7texture__nearest_pow2(__pyx_v_width);

    /* "kivy\graphics\texture.pyx":483
 *     else:
 *         texture_width = _nearest_pow2(width)
 *         texture_height = _nearest_pow2(height)             # <<<<<<<<<<<<<<
 * 
 *     # create the texture with the future color format.
 */
    __pyx_v_texture_height = __pyx_f_4kivy_8graphics_7texture__nearest_pow2(__pyx_v_height);
  }
  __pyx_L5:;

  /* "kivy\graphics\texture.pyx":486
 * 
 *     # create the texture with the future color format.
 *     colorfmt = _convert_gl_format(colorfmt)             # <<<<<<<<<<<<<<
 *     texture = Texture(texture_width, texture_height, target,
 *                       colorfmt=colorfmt, bufferfmt=bufferfmt, mipmap=mipmap,
 */
  __pyx_t_4 = ((PyObject *)__pyx_f_4kivy_8graphics_7texture__convert_gl_format(__pyx_v_colorfmt)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__pyx_v_colorfmt));
  __pyx_v_colorfmt = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":487
 *     # create the texture with the future color format.
 *     colorfmt = _convert_gl_format(colorfmt)
 *     texture = Texture(texture_width, texture_height, target,             # <<<<<<<<<<<<<<
 *                       colorfmt=colorfmt, bufferfmt=bufferfmt, mipmap=mipmap,
 *                       callback=callback)
 */
  __pyx_t_4 = PyInt_FromLong(__pyx_v_texture_width); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyInt_FromLong(__pyx_v_texture_height); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyInt_to_py_GLuint(__pyx_v_target); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));

  /* "kivy\graphics\texture.pyx":488
 *     colorfmt = _convert_gl_format(colorfmt)
 *     texture = Texture(texture_width, texture_height, target,
 *                       colorfmt=colorfmt, bufferfmt=bufferfmt, mipmap=mipmap,             # <<<<<<<<<<<<<<
 *                       callback=callback)
 *     if allocate or make_npot:
 */
  if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__colorfmt), ((PyObject *)__pyx_v_colorfmt)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__bufferfmt), ((PyObject *)__pyx_v_bufferfmt)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = PyInt_FromLong(__pyx_v_mipmap); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__mipmap), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":489
 *     texture = Texture(texture_width, texture_height, target,
 *                       colorfmt=colorfmt, bufferfmt=bufferfmt, mipmap=mipmap,
 *                       callback=callback)             # <<<<<<<<<<<<<<
 *     if allocate or make_npot:
 *         texture.flags |= TI_NEED_ALLOCATE
 */
  if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__callback), __pyx_v_callback) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4kivy_8graphics_7texture_Texture)), ((PyObject *)__pyx_t_7), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  __pyx_v_texture = ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":490
 *                       colorfmt=colorfmt, bufferfmt=bufferfmt, mipmap=mipmap,
 *                       callback=callback)
 *     if allocate or make_npot:             # <<<<<<<<<<<<<<
 *         texture.flags |= TI_NEED_ALLOCATE
 * 
 */
  if (!(__pyx_v_allocate != 0)) {
    __pyx_t_1 = (__pyx_v_make_npot != 0);
  } else {
    __pyx_t_1 = (__pyx_v_allocate != 0);
  }
  if (__pyx_t_1) {

    /* "kivy\graphics\texture.pyx":491
 *                       callback=callback)
 *     if allocate or make_npot:
 *         texture.flags |= TI_NEED_ALLOCATE             # <<<<<<<<<<<<<<
 * 
 *     # set default parameter for this texture
 */
    __pyx_v_texture->flags = (__pyx_v_texture->flags | __pyx_v_4kivy_8graphics_7texture_TI_NEED_ALLOCATE);
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "kivy\graphics\texture.pyx":494
 * 
 *     # set default parameter for this texture
 *     texture.set_wrap('clamp_to_edge')             # <<<<<<<<<<<<<<
 *     if mipmap:
 *         texture.set_min_filter('linear_mipmap_nearest')
 */
  ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_texture->__pyx_vtab)->set_wrap(__pyx_v_texture, __pyx_n_s__clamp_to_edge);

  /* "kivy\graphics\texture.pyx":495
 *     # set default parameter for this texture
 *     texture.set_wrap('clamp_to_edge')
 *     if mipmap:             # <<<<<<<<<<<<<<
 *         texture.set_min_filter('linear_mipmap_nearest')
 *         texture.set_mag_filter('linear')
 */
  __pyx_t_1 = (__pyx_v_mipmap != 0);
  if (__pyx_t_1) {

    /* "kivy\graphics\texture.pyx":496
 *     texture.set_wrap('clamp_to_edge')
 *     if mipmap:
 *         texture.set_min_filter('linear_mipmap_nearest')             # <<<<<<<<<<<<<<
 *         texture.set_mag_filter('linear')
 *     else:
 */
    ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_texture->__pyx_vtab)->set_min_filter(__pyx_v_texture, __pyx_n_s_17);

    /* "kivy\graphics\texture.pyx":497
 *     if mipmap:
 *         texture.set_min_filter('linear_mipmap_nearest')
 *         texture.set_mag_filter('linear')             # <<<<<<<<<<<<<<
 *     else:
 *         texture.set_min_filter('linear')
 */
    ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_texture->__pyx_vtab)->set_mag_filter(__pyx_v_texture, __pyx_n_s__linear);
    goto __pyx_L7;
  }
  /*else*/ {

    /* "kivy\graphics\texture.pyx":499
 *         texture.set_mag_filter('linear')
 *     else:
 *         texture.set_min_filter('linear')             # <<<<<<<<<<<<<<
 *         texture.set_mag_filter('linear')
 * 
 */
    ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_texture->__pyx_vtab)->set_min_filter(__pyx_v_texture, __pyx_n_s__linear);

    /* "kivy\graphics\texture.pyx":500
 *     else:
 *         texture.set_min_filter('linear')
 *         texture.set_mag_filter('linear')             # <<<<<<<<<<<<<<
 * 
 *     # if the texture size is the same as initial size, return the texture
 */
    ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_texture->__pyx_vtab)->set_mag_filter(__pyx_v_texture, __pyx_n_s__linear);
  }
  __pyx_L7:;

  /* "kivy\graphics\texture.pyx":504
 *     # if the texture size is the same as initial size, return the texture
 *     # unmodified
 *     if texture_width == width and texture_height == height:             # <<<<<<<<<<<<<<
 *         return texture
 * 
 */
  __pyx_t_1 = ((__pyx_v_texture_width == __pyx_v_width) != 0);
  if (__pyx_t_1) {
    __pyx_t_3 = ((__pyx_v_texture_height == __pyx_v_height) != 0);
    __pyx_t_2 = __pyx_t_3;
  } else {
    __pyx_t_2 = __pyx_t_1;
  }
  if (__pyx_t_2) {

    /* "kivy\graphics\texture.pyx":505
 *     # unmodified
 *     if texture_width == width and texture_height == height:
 *         return texture             # <<<<<<<<<<<<<<
 * 
 *     # otherwise, return a region of that texture
 */
    __Pyx_XDECREF(((PyObject *)__pyx_r));
    __Pyx_INCREF(((PyObject *)__pyx_v_texture));
    __pyx_r = __pyx_v_texture;
    goto __pyx_L0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "kivy\graphics\texture.pyx":508
 * 
 *     # otherwise, return a region of that texture
 *     return texture.get_region(0, 0, width, height)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __pyx_t_5 = PyInt_FromLong(__pyx_v_width); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyInt_FromLong(__pyx_v_height); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_texture->__pyx_vtab)->get_region(__pyx_v_texture, __pyx_int_0, __pyx_int_0, __pyx_t_5, __pyx_t_6, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_4kivy_8graphics_7texture_Texture))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_t_7);
  __pyx_t_7 = 0;
  goto __pyx_L0;

  __pyx_r = ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("kivy.graphics.texture._texture_create", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_texture);
  __Pyx_XDECREF(__pyx_v_colorfmt);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_1texture_create(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_texture_create[] = "Create a texture based on size.\n\n    :Parameters:\n        `size`: tuple, default to (128, 128)\n            Size of the texture\n        `colorfmt`: str, default to 'rgba'\n            Internal color format of the texture. Can be 'rgba' or 'rgb',\n            'luminance', 'luminance_alpha'\n        `bufferfmt`: str, default to 'ubyte'\n            Internal buffer format of the texture. Can be 'ubyte', 'ushort',\n            'uint', 'bute', 'short', 'int', 'float'\n        `mipmap`: bool, default to False\n            If True, it will automatically generate mipmap texture.\n        `callback`: callable(), default to False\n            If a function is provided, it will be called when data will be\n            needed in the texture.\n\n    .. versionchanged:: 1.7.0\n        :data:`callback` has been added\n    ";
static PyMethodDef __pyx_mdef_4kivy_8graphics_7texture_1texture_create = {__Pyx_NAMESTR("texture_create"), (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_1texture_create, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_texture_create)};
static PyObject *__pyx_pw_4kivy_8graphics_7texture_1texture_create(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_size = 0;
  PyObject *__pyx_v_colorfmt = 0;
  PyObject *__pyx_v_bufferfmt = 0;
  PyObject *__pyx_v_mipmap = 0;
  PyObject *__pyx_v_callback = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("texture_create (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__size,&__pyx_n_s__colorfmt,&__pyx_n_s__bufferfmt,&__pyx_n_s__mipmap,&__pyx_n_s__callback,0};
    PyObject* values[5] = {0,0,0,0,0};

    /* "kivy\graphics\texture.pyx":511
 * 
 * 
 * def texture_create(size=None, colorfmt=None, bufferfmt=None, mipmap=False,             # <<<<<<<<<<<<<<
 *     callback=None):
 *     '''Create a texture based on size.
 */
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = __pyx_k_18;

    /* "kivy\graphics\texture.pyx":512
 * 
 * def texture_create(size=None, colorfmt=None, bufferfmt=None, mipmap=False,
 *     callback=None):             # <<<<<<<<<<<<<<
 *     '''Create a texture based on size.
 * 
 */
    values[4] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__size);
          if (value) { values[0] = value; kw_args--; }
        }
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__colorfmt);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__bufferfmt);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mipmap);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__callback);
          if (value) { values[4] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "texture_create") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_size = values[0];
    __pyx_v_colorfmt = values[1];
    __pyx_v_bufferfmt = values[2];
    __pyx_v_mipmap = values[3];
    __pyx_v_callback = values[4];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("texture_create", 0, 0, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("kivy.graphics.texture.texture_create", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_texture_create(__pyx_self, __pyx_v_size, __pyx_v_colorfmt, __pyx_v_bufferfmt, __pyx_v_mipmap, __pyx_v_callback);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":511
 * 
 * 
 * def texture_create(size=None, colorfmt=None, bufferfmt=None, mipmap=False,             # <<<<<<<<<<<<<<
 *     callback=None):
 *     '''Create a texture based on size.
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_texture_create(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_size, PyObject *__pyx_v_colorfmt, PyObject *__pyx_v_bufferfmt, PyObject *__pyx_v_mipmap, PyObject *__pyx_v_callback) {
  int __pyx_v_width;
  int __pyx_v_height;
  int __pyx_v_allocate;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *(*__pyx_t_6)(PyObject *);
  int __pyx_t_7;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("texture_create", 0);
  __Pyx_INCREF(__pyx_v_colorfmt);
  __Pyx_INCREF(__pyx_v_bufferfmt);

  /* "kivy\graphics\texture.pyx":533
 *         :data:`callback` has been added
 *     '''
 *     cdef int width = 128, height = 128, allocate = 1             # <<<<<<<<<<<<<<
 *     if size is not None:
 *         width, height = size
 */
  __pyx_v_width = 128;
  __pyx_v_height = 128;
  __pyx_v_allocate = 1;

  /* "kivy\graphics\texture.pyx":534
 *     '''
 *     cdef int width = 128, height = 128, allocate = 1
 *     if size is not None:             # <<<<<<<<<<<<<<
 *         width, height = size
 *     if colorfmt is None:
 */
  __pyx_t_1 = (__pyx_v_size != Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "kivy\graphics\texture.pyx":535
 *     cdef int width = 128, height = 128, allocate = 1
 *     if size is not None:
 *         width, height = size             # <<<<<<<<<<<<<<
 *     if colorfmt is None:
 *         colorfmt = 'rgba'
 */
    if ((likely(PyTuple_CheckExact(__pyx_v_size))) || (PyList_CheckExact(__pyx_v_size))) {
      PyObject* sequence = __pyx_v_size;
      #if CYTHON_COMPILING_IN_CPYTHON
      Py_ssize_t size = Py_SIZE(sequence);
      #else
      Py_ssize_t size = PySequence_Size(sequence);
      #endif
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      #if CYTHON_COMPILING_IN_CPYTHON
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); 
      } else {
        __pyx_t_3 = PyList_GET_ITEM(sequence, 0); 
        __pyx_t_4 = PyList_GET_ITEM(sequence, 1); 
      }
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      #else
      __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      #endif
    } else
    {
      Py_ssize_t index = -1;
      __pyx_t_5 = PyObject_GetIter(__pyx_v_size); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext;
      index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L4_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L4_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_4);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_6 = NULL;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L5_unpacking_done;
      __pyx_L4_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_6 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_L5_unpacking_done:;
    }
    __pyx_t_7 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_v_width = __pyx_t_7;
    __pyx_v_height = __pyx_t_8;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "kivy\graphics\texture.pyx":536
 *     if size is not None:
 *         width, height = size
 *     if colorfmt is None:             # <<<<<<<<<<<<<<
 *         colorfmt = 'rgba'
 *     if bufferfmt is None:
 */
  __pyx_t_2 = (__pyx_v_colorfmt == Py_None);
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "kivy\graphics\texture.pyx":537
 *         width, height = size
 *     if colorfmt is None:
 *         colorfmt = 'rgba'             # <<<<<<<<<<<<<<
 *     if bufferfmt is None:
 *         bufferfmt = 'ubyte'
 */
    __Pyx_INCREF(((PyObject *)__pyx_n_s__rgba));
    __Pyx_DECREF(__pyx_v_colorfmt);
    __pyx_v_colorfmt = ((PyObject *)__pyx_n_s__rgba);
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "kivy\graphics\texture.pyx":538
 *     if colorfmt is None:
 *         colorfmt = 'rgba'
 *     if bufferfmt is None:             # <<<<<<<<<<<<<<
 *         bufferfmt = 'ubyte'
 *     if callback is not None:
 */
  __pyx_t_1 = (__pyx_v_bufferfmt == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "kivy\graphics\texture.pyx":539
 *         colorfmt = 'rgba'
 *     if bufferfmt is None:
 *         bufferfmt = 'ubyte'             # <<<<<<<<<<<<<<
 *     if callback is not None:
 *         allocate = 0
 */
    __Pyx_INCREF(((PyObject *)__pyx_n_s__ubyte));
    __Pyx_DECREF(__pyx_v_bufferfmt);
    __pyx_v_bufferfmt = ((PyObject *)__pyx_n_s__ubyte);
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "kivy\graphics\texture.pyx":540
 *     if bufferfmt is None:
 *         bufferfmt = 'ubyte'
 *     if callback is not None:             # <<<<<<<<<<<<<<
 *         allocate = 0
 *     return _texture_create(width, height, colorfmt, bufferfmt, mipmap,
 */
  __pyx_t_2 = (__pyx_v_callback != Py_None);
  __pyx_t_1 = (__pyx_t_2 != 0);
  if (__pyx_t_1) {

    /* "kivy\graphics\texture.pyx":541
 *         bufferfmt = 'ubyte'
 *     if callback is not None:
 *         allocate = 0             # <<<<<<<<<<<<<<
 *     return _texture_create(width, height, colorfmt, bufferfmt, mipmap,
 *             allocate, callback)
 */
    __pyx_v_allocate = 0;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "kivy\graphics\texture.pyx":542
 *     if callback is not None:
 *         allocate = 0
 *     return _texture_create(width, height, colorfmt, bufferfmt, mipmap,             # <<<<<<<<<<<<<<
 *             allocate, callback)
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  if (!(likely(PyString_CheckExact(__pyx_v_colorfmt))||((__pyx_v_colorfmt) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_v_colorfmt)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(likely(PyString_CheckExact(__pyx_v_bufferfmt))||((__pyx_v_bufferfmt) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_v_bufferfmt)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_v_mipmap); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "kivy\graphics\texture.pyx":543
 *         allocate = 0
 *     return _texture_create(width, height, colorfmt, bufferfmt, mipmap,
 *             allocate, callback)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = ((PyObject *)__pyx_f_4kivy_8graphics_7texture__texture_create(__pyx_v_width, __pyx_v_height, ((PyObject*)__pyx_v_colorfmt), ((PyObject*)__pyx_v_bufferfmt), __pyx_t_8, __pyx_v_allocate, __pyx_v_callback)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("kivy.graphics.texture.texture_create", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_colorfmt);
  __Pyx_XDECREF(__pyx_v_bufferfmt);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_3texture_create_from_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_2texture_create_from_data[] = "Create a texture from an ImageData class\n    ";
static PyMethodDef __pyx_mdef_4kivy_8graphics_7texture_3texture_create_from_data = {__Pyx_NAMESTR("texture_create_from_data"), (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_3texture_create_from_data, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_2texture_create_from_data)};
static PyObject *__pyx_pw_4kivy_8graphics_7texture_3texture_create_from_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_im = 0;
  PyObject *__pyx_v_mipmap = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("texture_create_from_data (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__im,&__pyx_n_s__mipmap,0};
    PyObject* values[2] = {0,0};
    values[1] = __pyx_k_19;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__im)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mipmap);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "texture_create_from_data") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_im = values[0];
    __pyx_v_mipmap = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("texture_create_from_data", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("kivy.graphics.texture.texture_create_from_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_2texture_create_from_data(__pyx_self, __pyx_v_im, __pyx_v_mipmap);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":546
 * 
 * 
 * def texture_create_from_data(im, mipmap=False):             # <<<<<<<<<<<<<<
 *     '''Create a texture from an ImageData class
 *     '''
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_2texture_create_from_data(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_im, PyObject *__pyx_v_mipmap) {
  int __pyx_v_width;
  int __pyx_v_height;
  int __pyx_v_allocate;
  int __pyx_v_no_blit;
  struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_texture = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("texture_create_from_data", 0);
  __Pyx_INCREF(__pyx_v_mipmap);

  /* "kivy\graphics\texture.pyx":549
 *     '''Create a texture from an ImageData class
 *     '''
 *     cdef int width = im.width             # <<<<<<<<<<<<<<
 *     cdef int height = im.height
 *     cdef int allocate = 1
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_im, __pyx_n_s__width); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_width = __pyx_t_2;

  /* "kivy\graphics\texture.pyx":550
 *     '''
 *     cdef int width = im.width
 *     cdef int height = im.height             # <<<<<<<<<<<<<<
 *     cdef int allocate = 1
 *     cdef int no_blit = 0
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_im, __pyx_n_s__height); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_height = __pyx_t_2;

  /* "kivy\graphics\texture.pyx":551
 *     cdef int width = im.width
 *     cdef int height = im.height
 *     cdef int allocate = 1             # <<<<<<<<<<<<<<
 *     cdef int no_blit = 0
 *     cdef Texture texture
 */
  __pyx_v_allocate = 1;

  /* "kivy\graphics\texture.pyx":552
 *     cdef int height = im.height
 *     cdef int allocate = 1
 *     cdef int no_blit = 0             # <<<<<<<<<<<<<<
 *     cdef Texture texture
 * 
 */
  __pyx_v_no_blit = 0;

  /* "kivy\graphics\texture.pyx":557
 *     # optimization, if the texture is power of 2, don't allocate in
 *     # _texture_create, but allocate in blit_data => only 1 upload
 *     if _is_pow2(width) and _is_pow2(height):             # <<<<<<<<<<<<<<
 *         allocate = 0
 *     elif gl_has_capability(c_GLCAP_NPOT):
 */
  __pyx_t_3 = (__pyx_f_4kivy_8graphics_7texture__is_pow2(__pyx_v_width) != 0);
  if (__pyx_t_3) {
    __pyx_t_4 = (__pyx_f_4kivy_8graphics_7texture__is_pow2(__pyx_v_height) != 0);
    __pyx_t_5 = __pyx_t_4;
  } else {
    __pyx_t_5 = __pyx_t_3;
  }
  if (__pyx_t_5) {

    /* "kivy\graphics\texture.pyx":558
 *     # _texture_create, but allocate in blit_data => only 1 upload
 *     if _is_pow2(width) and _is_pow2(height):
 *         allocate = 0             # <<<<<<<<<<<<<<
 *     elif gl_has_capability(c_GLCAP_NPOT):
 *         allocate = 0
 */
    __pyx_v_allocate = 0;
    goto __pyx_L3;
  }

  /* "kivy\graphics\texture.pyx":559
 *     if _is_pow2(width) and _is_pow2(height):
 *         allocate = 0
 *     elif gl_has_capability(c_GLCAP_NPOT):             # <<<<<<<<<<<<<<
 *         allocate = 0
 * 
 */
  __pyx_t_5 = (__pyx_f_4kivy_8graphics_12opengl_utils_gl_has_capability(__pyx_v_4kivy_8graphics_7texture_c_GLCAP_NPOT, 0) != 0);
  if (__pyx_t_5) {

    /* "kivy\graphics\texture.pyx":560
 *         allocate = 0
 *     elif gl_has_capability(c_GLCAP_NPOT):
 *         allocate = 0             # <<<<<<<<<<<<<<
 * 
 *     # if imagedata have more than one image, activate mipmap
 */
    __pyx_v_allocate = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "kivy\graphics\texture.pyx":563
 * 
 *     # if imagedata have more than one image, activate mipmap
 *     if im.have_mipmap:             # <<<<<<<<<<<<<<
 *         mipmap = True
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_im, __pyx_n_s__have_mipmap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "kivy\graphics\texture.pyx":564
 *     # if imagedata have more than one image, activate mipmap
 *     if im.have_mipmap:
 *         mipmap = True             # <<<<<<<<<<<<<<
 * 
 *     IF not USE_OPENGL_ES2:
 */
    __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_v_mipmap);
    __pyx_v_mipmap = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "kivy\graphics\texture.pyx":570
 *             mipmap = False
 * 
 *     if width == 0 or height == 0:             # <<<<<<<<<<<<<<
 *         height = width = 1
 *         allocate = 1
 */
  __pyx_t_5 = ((__pyx_v_width == 0) != 0);
  if (!__pyx_t_5) {
    __pyx_t_3 = ((__pyx_v_height == 0) != 0);
    __pyx_t_4 = __pyx_t_3;
  } else {
    __pyx_t_4 = __pyx_t_5;
  }
  if (__pyx_t_4) {

    /* "kivy\graphics\texture.pyx":571
 * 
 *     if width == 0 or height == 0:
 *         height = width = 1             # <<<<<<<<<<<<<<
 *         allocate = 1
 *         no_blit = 1
 */
    __pyx_v_height = 1;
    __pyx_v_width = 1;

    /* "kivy\graphics\texture.pyx":572
 *     if width == 0 or height == 0:
 *         height = width = 1
 *         allocate = 1             # <<<<<<<<<<<<<<
 *         no_blit = 1
 *     texture = _texture_create(width, height, im.fmt, 'ubyte', mipmap, allocate,
 */
    __pyx_v_allocate = 1;

    /* "kivy\graphics\texture.pyx":573
 *         height = width = 1
 *         allocate = 1
 *         no_blit = 1             # <<<<<<<<<<<<<<
 *     texture = _texture_create(width, height, im.fmt, 'ubyte', mipmap, allocate,
 *                              None)
 */
    __pyx_v_no_blit = 1;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "kivy\graphics\texture.pyx":574
 *         allocate = 1
 *         no_blit = 1
 *     texture = _texture_create(width, height, im.fmt, 'ubyte', mipmap, allocate,             # <<<<<<<<<<<<<<
 *                              None)
 *     if texture is None:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_im, __pyx_n_s__fmt); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_v_mipmap); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "kivy\graphics\texture.pyx":575
 *         no_blit = 1
 *     texture = _texture_create(width, height, im.fmt, 'ubyte', mipmap, allocate,
 *                              None)             # <<<<<<<<<<<<<<
 *     if texture is None:
 *         return None
 */
  __pyx_t_6 = ((PyObject *)__pyx_f_4kivy_8graphics_7texture__texture_create(__pyx_v_width, __pyx_v_height, ((PyObject*)__pyx_t_1), __pyx_n_s__ubyte, __pyx_t_2, __pyx_v_allocate, Py_None)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_texture = ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "kivy\graphics\texture.pyx":576
 *     texture = _texture_create(width, height, im.fmt, 'ubyte', mipmap, allocate,
 *                              None)
 *     if texture is None:             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  __pyx_t_4 = (((PyObject *)__pyx_v_texture) == Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "kivy\graphics\texture.pyx":577
 *                              None)
 *     if texture is None:
 *         return None             # <<<<<<<<<<<<<<
 * 
 *     texture._source = im.source
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "kivy\graphics\texture.pyx":579
 *         return None
 * 
 *     texture._source = im.source             # <<<<<<<<<<<<<<
 *     if no_blit == 0:
 *         texture.blit_data(im)
 */
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_im, __pyx_n_s__source); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __Pyx_GOTREF(__pyx_v_texture->_source);
  __Pyx_DECREF(__pyx_v_texture->_source);
  __pyx_v_texture->_source = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "kivy\graphics\texture.pyx":580
 * 
 *     texture._source = im.source
 *     if no_blit == 0:             # <<<<<<<<<<<<<<
 *         texture.blit_data(im)
 * 
 */
  __pyx_t_5 = ((__pyx_v_no_blit == 0) != 0);
  if (__pyx_t_5) {

    /* "kivy\graphics\texture.pyx":581
 *     texture._source = im.source
 *     if no_blit == 0:
 *         texture.blit_data(im)             # <<<<<<<<<<<<<<
 * 
 *     return texture
 */
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_texture), __pyx_n_s__blit_data); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_v_im);
    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_im);
    __Pyx_GIVEREF(__pyx_v_im);
    __pyx_t_7 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    goto __pyx_L7;
  }
  __pyx_L7:;

  /* "kivy\graphics\texture.pyx":583
 *         texture.blit_data(im)
 * 
 *     return texture             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_texture));
  __pyx_r = ((PyObject *)__pyx_v_texture);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("kivy.graphics.texture.texture_create_from_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_texture);
  __Pyx_XDECREF(__pyx_v_mipmap);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4kivy_8graphics_7texture_7Texture_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4kivy_8graphics_7texture_7Texture_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_width = 0;
  PyObject *__pyx_v_height = 0;
  PyObject *__pyx_v_target = 0;
  PyObject *__pyx_v_texid = 0;
  PyObject *__pyx_v_colorfmt = 0;
  PyObject *__pyx_v_bufferfmt = 0;
  PyObject *__pyx_v_mipmap = 0;
  PyObject *__pyx_v_source = 0;
  PyObject *__pyx_v_callback = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__width,&__pyx_n_s__height,&__pyx_n_s__target,&__pyx_n_s__texid,&__pyx_n_s__colorfmt,&__pyx_n_s__bufferfmt,&__pyx_n_s__mipmap,&__pyx_n_s__source,&__pyx_n_s__callback,0};
    PyObject* values[9] = {0,0,0,0,0,0,0,0,0};
    values[3] = ((PyObject *)__pyx_int_0);
    values[4] = ((PyObject *)__pyx_n_s__rgb);
    values[5] = ((PyObject *)__pyx_n_s__ubyte);
    values[6] = __pyx_k_20;

    /* "kivy\graphics\texture.pyx":594
 * 
 *     def __init__(self, width, height, target, texid=0, colorfmt='rgb',
 *             bufferfmt='ubyte', mipmap=False, source=None, callback=None):             # <<<<<<<<<<<<<<
 *         self.observers = []
 *         self._width         = width
 */
    values[7] = ((PyObject *)Py_None);
    values[8] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__width)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__height)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 9, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__target)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 9, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__texid);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__colorfmt);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__bufferfmt);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mipmap);
          if (value) { values[6] = value; kw_args--; }
        }
        case  7:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__source);
          if (value) { values[7] = value; kw_args--; }
        }
        case  8:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__callback);
          if (value) { values[8] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
        case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_width = values[0];
    __pyx_v_height = values[1];
    __pyx_v_target = values[2];
    __pyx_v_texid = values[3];
    __pyx_v_colorfmt = values[4];
    __pyx_v_bufferfmt = values[5];
    __pyx_v_mipmap = values[6];
    __pyx_v_source = values[7];
    __pyx_v_callback = values[8];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture___init__(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), __pyx_v_width, __pyx_v_height, __pyx_v_target, __pyx_v_texid, __pyx_v_colorfmt, __pyx_v_bufferfmt, __pyx_v_mipmap, __pyx_v_source, __pyx_v_callback);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":593
 *     create_from_data = staticmethod(texture_create_from_data)
 * 
 *     def __init__(self, width, height, target, texid=0, colorfmt='rgb',             # <<<<<<<<<<<<<<
 *             bufferfmt='ubyte', mipmap=False, source=None, callback=None):
 *         self.observers = []
 */

static int __pyx_pf_4kivy_8graphics_7texture_7Texture___init__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_width, PyObject *__pyx_v_height, PyObject *__pyx_v_target, PyObject *__pyx_v_texid, PyObject *__pyx_v_colorfmt, PyObject *__pyx_v_bufferfmt, PyObject *__pyx_v_mipmap, PyObject *__pyx_v_source, PyObject *__pyx_v_callback) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  GLuint __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "kivy\graphics\texture.pyx":595
 *     def __init__(self, width, height, target, texid=0, colorfmt='rgb',
 *             bufferfmt='ubyte', mipmap=False, source=None, callback=None):
 *         self.observers = []             # <<<<<<<<<<<<<<
 *         self._width         = width
 *         self._height        = height
 */
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
  __Pyx_GOTREF(__pyx_v_self->observers);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->observers));
  __pyx_v_self->observers = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "kivy\graphics\texture.pyx":596
 *             bufferfmt='ubyte', mipmap=False, source=None, callback=None):
 *         self.observers = []
 *         self._width         = width             # <<<<<<<<<<<<<<
 *         self._height        = height
 *         self._target        = target
 */
  __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_v_width); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->_width = __pyx_t_2;

  /* "kivy\graphics\texture.pyx":597
 *         self.observers = []
 *         self._width         = width
 *         self._height        = height             # <<<<<<<<<<<<<<
 *         self._target        = target
 *         self._id            = texid
 */
  __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_v_height); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->_height = __pyx_t_2;

  /* "kivy\graphics\texture.pyx":598
 *         self._width         = width
 *         self._height        = height
 *         self._target        = target             # <<<<<<<<<<<<<<
 *         self._id            = texid
 *         self._mipmap        = mipmap
 */
  __pyx_t_3 = __Pyx_PyInt_from_py_GLuint(__pyx_v_target); if (unlikely((__pyx_t_3 == (GLuint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->_target = __pyx_t_3;

  /* "kivy\graphics\texture.pyx":599
 *         self._height        = height
 *         self._target        = target
 *         self._id            = texid             # <<<<<<<<<<<<<<
 *         self._mipmap        = mipmap
 *         self._wrap          = None
 */
  __pyx_t_3 = __Pyx_PyInt_from_py_GLuint(__pyx_v_texid); if (unlikely((__pyx_t_3 == (GLuint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->_id = __pyx_t_3;

  /* "kivy\graphics\texture.pyx":600
 *         self._target        = target
 *         self._id            = texid
 *         self._mipmap        = mipmap             # <<<<<<<<<<<<<<
 *         self._wrap          = None
 *         self._min_filter    = None
 */
  __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_v_mipmap); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_self->_mipmap = __pyx_t_2;

  /* "kivy\graphics\texture.pyx":601
 *         self._id            = texid
 *         self._mipmap        = mipmap
 *         self._wrap          = None             # <<<<<<<<<<<<<<
 *         self._min_filter    = None
 *         self._mag_filter    = None
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_wrap);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->_wrap));
  __pyx_v_self->_wrap = ((PyObject*)Py_None);

  /* "kivy\graphics\texture.pyx":602
 *         self._mipmap        = mipmap
 *         self._wrap          = None
 *         self._min_filter    = None             # <<<<<<<<<<<<<<
 *         self._mag_filter    = None
 *         self._is_allocated  = 0
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_min_filter);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->_min_filter));
  __pyx_v_self->_min_filter = ((PyObject*)Py_None);

  /* "kivy\graphics\texture.pyx":603
 *         self._wrap          = None
 *         self._min_filter    = None
 *         self._mag_filter    = None             # <<<<<<<<<<<<<<
 *         self._is_allocated  = 0
 *         self._uvx           = 0.
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_mag_filter);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->_mag_filter));
  __pyx_v_self->_mag_filter = ((PyObject*)Py_None);

  /* "kivy\graphics\texture.pyx":604
 *         self._min_filter    = None
 *         self._mag_filter    = None
 *         self._is_allocated  = 0             # <<<<<<<<<<<<<<
 *         self._uvx           = 0.
 *         self._uvy           = 0.
 */
  __pyx_v_self->_is_allocated = 0;

  /* "kivy\graphics\texture.pyx":605
 *         self._mag_filter    = None
 *         self._is_allocated  = 0
 *         self._uvx           = 0.             # <<<<<<<<<<<<<<
 *         self._uvy           = 0.
 *         self._uvw           = 1.
 */
  __pyx_v_self->_uvx = 0.;

  /* "kivy\graphics\texture.pyx":606
 *         self._is_allocated  = 0
 *         self._uvx           = 0.
 *         self._uvy           = 0.             # <<<<<<<<<<<<<<
 *         self._uvw           = 1.
 *         self._uvh           = 1.
 */
  __pyx_v_self->_uvy = 0.;

  /* "kivy\graphics\texture.pyx":607
 *         self._uvx           = 0.
 *         self._uvy           = 0.
 *         self._uvw           = 1.             # <<<<<<<<<<<<<<
 *         self._uvh           = 1.
 *         self._colorfmt      = colorfmt
 */
  __pyx_v_self->_uvw = 1.;

  /* "kivy\graphics\texture.pyx":608
 *         self._uvy           = 0.
 *         self._uvw           = 1.
 *         self._uvh           = 1.             # <<<<<<<<<<<<<<
 *         self._colorfmt      = colorfmt
 *         self._bufferfmt     = bufferfmt
 */
  __pyx_v_self->_uvh = 1.;

  /* "kivy\graphics\texture.pyx":609
 *         self._uvw           = 1.
 *         self._uvh           = 1.
 *         self._colorfmt      = colorfmt             # <<<<<<<<<<<<<<
 *         self._bufferfmt     = bufferfmt
 *         self._source        = source
 */
  if (!(likely(PyBytes_CheckExact(__pyx_v_colorfmt))||((__pyx_v_colorfmt) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_colorfmt)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(__pyx_v_colorfmt);
  __Pyx_GIVEREF(__pyx_v_colorfmt);
  __Pyx_GOTREF(__pyx_v_self->_colorfmt);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->_colorfmt));
  __pyx_v_self->_colorfmt = ((PyObject*)__pyx_v_colorfmt);

  /* "kivy\graphics\texture.pyx":610
 *         self._uvh           = 1.
 *         self._colorfmt      = colorfmt
 *         self._bufferfmt     = bufferfmt             # <<<<<<<<<<<<<<
 *         self._source        = source
 *         self._nofree        = 0
 */
  if (!(likely(PyBytes_CheckExact(__pyx_v_bufferfmt))||((__pyx_v_bufferfmt) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_bufferfmt)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(__pyx_v_bufferfmt);
  __Pyx_GIVEREF(__pyx_v_bufferfmt);
  __Pyx_GOTREF(__pyx_v_self->_bufferfmt);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->_bufferfmt));
  __pyx_v_self->_bufferfmt = ((PyObject*)__pyx_v_bufferfmt);

  /* "kivy\graphics\texture.pyx":611
 *         self._colorfmt      = colorfmt
 *         self._bufferfmt     = bufferfmt
 *         self._source        = source             # <<<<<<<<<<<<<<
 *         self._nofree        = 0
 *         self._callback      = callback
 */
  __Pyx_INCREF(__pyx_v_source);
  __Pyx_GIVEREF(__pyx_v_source);
  __Pyx_GOTREF(__pyx_v_self->_source);
  __Pyx_DECREF(__pyx_v_self->_source);
  __pyx_v_self->_source = __pyx_v_source;

  /* "kivy\graphics\texture.pyx":612
 *         self._bufferfmt     = bufferfmt
 *         self._source        = source
 *         self._nofree        = 0             # <<<<<<<<<<<<<<
 *         self._callback      = callback
 * 
 */
  __pyx_v_self->_nofree = 0;

  /* "kivy\graphics\texture.pyx":613
 *         self._source        = source
 *         self._nofree        = 0
 *         self._callback      = callback             # <<<<<<<<<<<<<<
 * 
 *         if texid == 0:
 */
  __Pyx_INCREF(__pyx_v_callback);
  __Pyx_GIVEREF(__pyx_v_callback);
  __Pyx_GOTREF(__pyx_v_self->_callback);
  __Pyx_DECREF(__pyx_v_self->_callback);
  __pyx_v_self->_callback = __pyx_v_callback;

  /* "kivy\graphics\texture.pyx":615
 *         self._callback      = callback
 * 
 *         if texid == 0:             # <<<<<<<<<<<<<<
 *             self.flags |= TI_NEED_GEN
 *         if callback is not None:
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_texid, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_4) {

    /* "kivy\graphics\texture.pyx":616
 * 
 *         if texid == 0:
 *             self.flags |= TI_NEED_GEN             # <<<<<<<<<<<<<<
 *         if callback is not None:
 *             self.flags |= TI_NEED_PIXELS
 */
    __pyx_v_self->flags = (__pyx_v_self->flags | __pyx_v_4kivy_8graphics_7texture_TI_NEED_GEN);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "kivy\graphics\texture.pyx":617
 *         if texid == 0:
 *             self.flags |= TI_NEED_GEN
 *         if callback is not None:             # <<<<<<<<<<<<<<
 *             self.flags |= TI_NEED_PIXELS
 * 
 */
  __pyx_t_4 = (__pyx_v_callback != Py_None);
  __pyx_t_5 = (__pyx_t_4 != 0);
  if (__pyx_t_5) {

    /* "kivy\graphics\texture.pyx":618
 *             self.flags |= TI_NEED_GEN
 *         if callback is not None:
 *             self.flags |= TI_NEED_PIXELS             # <<<<<<<<<<<<<<
 * 
 *         self.update_tex_coords()
 */
    __pyx_v_self->flags = (__pyx_v_self->flags | __pyx_v_4kivy_8graphics_7texture_TI_NEED_PIXELS);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "kivy\graphics\texture.pyx":620
 *             self.flags |= TI_NEED_PIXELS
 * 
 *         self.update_tex_coords()             # <<<<<<<<<<<<<<
 *         get_context().register_texture(self)
 * 
 */
  ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_self->__pyx_vtab)->update_tex_coords(__pyx_v_self);

  /* "kivy\graphics\texture.pyx":621
 * 
 *         self.update_tex_coords()
 *         get_context().register_texture(self)             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4kivy_8graphics_7context_get_context(0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  ((struct __pyx_vtabstruct_4kivy_8graphics_7context_Context *)((struct __pyx_obj_4kivy_8graphics_7context_Context *)__pyx_t_1)->__pyx_vtab)->register_texture(((struct __pyx_obj_4kivy_8graphics_7context_Context *)__pyx_t_1), __pyx_v_self);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static void __pyx_pw_4kivy_8graphics_7texture_7Texture_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pw_4kivy_8graphics_7texture_7Texture_3__dealloc__(PyObject *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
  __pyx_pf_4kivy_8graphics_7texture_7Texture_2__dealloc__(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
}

/* "kivy\graphics\texture.pyx":623
 *         get_context().register_texture(self)
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         get_context().dealloc_texture(self)
 * 
 */

static void __pyx_pf_4kivy_8graphics_7texture_7Texture_2__dealloc__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__dealloc__", 0);

  /* "kivy\graphics\texture.pyx":624
 * 
 *     def __dealloc__(self):
 *         get_context().dealloc_texture(self)             # <<<<<<<<<<<<<<
 * 
 *     cdef void update_tex_coords(self):
 */
  __pyx_t_1 = ((PyObject *)__pyx_f_4kivy_8graphics_7context_get_context(0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  ((struct __pyx_vtabstruct_4kivy_8graphics_7context_Context *)((struct __pyx_obj_4kivy_8graphics_7context_Context *)__pyx_t_1)->__pyx_vtab)->dealloc_texture(((struct __pyx_obj_4kivy_8graphics_7context_Context *)__pyx_t_1), __pyx_v_self);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "kivy\graphics\texture.pyx":626
 *         get_context().dealloc_texture(self)
 * 
 *     cdef void update_tex_coords(self):             # <<<<<<<<<<<<<<
 *         self._tex_coords[0] = self._uvx
 *         self._tex_coords[1] = self._uvy
 */

static void __pyx_f_4kivy_8graphics_7texture_7Texture_update_tex_coords(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  __Pyx_RefNannyDeclarations
  float __pyx_t_1;
  __Pyx_RefNannySetupContext("update_tex_coords", 0);

  /* "kivy\graphics\texture.pyx":627
 * 
 *     cdef void update_tex_coords(self):
 *         self._tex_coords[0] = self._uvx             # <<<<<<<<<<<<<<
 *         self._tex_coords[1] = self._uvy
 *         self._tex_coords[2] = self._uvx + self._uvw
 */
  __pyx_t_1 = __pyx_v_self->_uvx;
  (__pyx_v_self->_tex_coords[0]) = __pyx_t_1;

  /* "kivy\graphics\texture.pyx":628
 *     cdef void update_tex_coords(self):
 *         self._tex_coords[0] = self._uvx
 *         self._tex_coords[1] = self._uvy             # <<<<<<<<<<<<<<
 *         self._tex_coords[2] = self._uvx + self._uvw
 *         self._tex_coords[3] = self._uvy
 */
  __pyx_t_1 = __pyx_v_self->_uvy;
  (__pyx_v_self->_tex_coords[1]) = __pyx_t_1;

  /* "kivy\graphics\texture.pyx":629
 *         self._tex_coords[0] = self._uvx
 *         self._tex_coords[1] = self._uvy
 *         self._tex_coords[2] = self._uvx + self._uvw             # <<<<<<<<<<<<<<
 *         self._tex_coords[3] = self._uvy
 *         self._tex_coords[4] = self._uvx + self._uvw
 */
  (__pyx_v_self->_tex_coords[2]) = (__pyx_v_self->_uvx + __pyx_v_self->_uvw);

  /* "kivy\graphics\texture.pyx":630
 *         self._tex_coords[1] = self._uvy
 *         self._tex_coords[2] = self._uvx + self._uvw
 *         self._tex_coords[3] = self._uvy             # <<<<<<<<<<<<<<
 *         self._tex_coords[4] = self._uvx + self._uvw
 *         self._tex_coords[5] = self._uvy + self._uvh
 */
  __pyx_t_1 = __pyx_v_self->_uvy;
  (__pyx_v_self->_tex_coords[3]) = __pyx_t_1;

  /* "kivy\graphics\texture.pyx":631
 *         self._tex_coords[2] = self._uvx + self._uvw
 *         self._tex_coords[3] = self._uvy
 *         self._tex_coords[4] = self._uvx + self._uvw             # <<<<<<<<<<<<<<
 *         self._tex_coords[5] = self._uvy + self._uvh
 *         self._tex_coords[6] = self._uvx
 */
  (__pyx_v_self->_tex_coords[4]) = (__pyx_v_self->_uvx + __pyx_v_self->_uvw);

  /* "kivy\graphics\texture.pyx":632
 *         self._tex_coords[3] = self._uvy
 *         self._tex_coords[4] = self._uvx + self._uvw
 *         self._tex_coords[5] = self._uvy + self._uvh             # <<<<<<<<<<<<<<
 *         self._tex_coords[6] = self._uvx
 *         self._tex_coords[7] = self._uvy + self._uvh
 */
  (__pyx_v_self->_tex_coords[5]) = (__pyx_v_self->_uvy + __pyx_v_self->_uvh);

  /* "kivy\graphics\texture.pyx":633
 *         self._tex_coords[4] = self._uvx + self._uvw
 *         self._tex_coords[5] = self._uvy + self._uvh
 *         self._tex_coords[6] = self._uvx             # <<<<<<<<<<<<<<
 *         self._tex_coords[7] = self._uvy + self._uvh
 * 
 */
  __pyx_t_1 = __pyx_v_self->_uvx;
  (__pyx_v_self->_tex_coords[6]) = __pyx_t_1;

  /* "kivy\graphics\texture.pyx":634
 *         self._tex_coords[5] = self._uvy + self._uvh
 *         self._tex_coords[6] = self._uvx
 *         self._tex_coords[7] = self._uvy + self._uvh             # <<<<<<<<<<<<<<
 * 
 *     def add_reload_observer(self, callback):
 */
  (__pyx_v_self->_tex_coords[7]) = (__pyx_v_self->_uvy + __pyx_v_self->_uvh);

  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_5add_reload_observer(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_7Texture_4add_reload_observer[] = "Add a callback to be called after the whole graphics context have\n        been reloaded. This is where you can reupload your custom data in GPU.\n\n        .. versionadded:: 1.2.0\n\n        :Parameters:\n            `callback`: func(context) -> return None\n                The first parameter will be the context itself\n        ";
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_5add_reload_observer(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("add_reload_observer (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_4add_reload_observer(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), ((PyObject *)__pyx_v_callback));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":636
 *         self._tex_coords[7] = self._uvy + self._uvh
 * 
 *     def add_reload_observer(self, callback):             # <<<<<<<<<<<<<<
 *         '''Add a callback to be called after the whole graphics context have
 *         been reloaded. This is where you can reupload your custom data in GPU.
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_4add_reload_observer(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("add_reload_observer", 0);

  /* "kivy\graphics\texture.pyx":646
 *                 The first parameter will be the context itself
 *         '''
 *         self.observers.append(WeakMethod(callback))             # <<<<<<<<<<<<<<
 * 
 *     def remove_reload_observer(self, callback):
 */
  if (unlikely(((PyObject *)__pyx_v_self->observers) == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "append");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s__WeakMethod); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_callback);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_callback);
  __Pyx_GIVEREF(__pyx_v_callback);
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyList_Append(__pyx_v_self->observers, __pyx_t_3); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.add_reload_observer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_7remove_reload_observer(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_7Texture_6remove_reload_observer[] = "Remove a callback from the observer list, previously added by\n        :func:`add_reload_observer`.\n\n        .. versionadded:: 1.2.0\n\n        ";
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_7remove_reload_observer(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remove_reload_observer (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_6remove_reload_observer(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), ((PyObject *)__pyx_v_callback));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":648
 *         self.observers.append(WeakMethod(callback))
 * 
 *     def remove_reload_observer(self, callback):             # <<<<<<<<<<<<<<
 *         '''Remove a callback from the observer list, previously added by
 *         :func:`add_reload_observer`.
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6remove_reload_observer(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_callback) {
  PyObject *__pyx_v_cb = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remove_reload_observer", 0);

  /* "kivy\graphics\texture.pyx":655
 * 
 *         '''
 *         for cb in self.observers[:]:             # <<<<<<<<<<<<<<
 *             if cb.is_dead() or cb() is callback:
 *                 self.observers.remove(cb)
 */
  if (unlikely(((PyObject *)__pyx_v_self->observers) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_PyList_GetSlice(((PyObject *)__pyx_v_self->observers), 0, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (unlikely(((PyObject *)__pyx_t_1) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_2 = ((PyObject *)__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  for (;;) {
    if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #endif
    __Pyx_XDECREF(__pyx_v_cb);
    __pyx_v_cb = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "kivy\graphics\texture.pyx":656
 *         '''
 *         for cb in self.observers[:]:
 *             if cb.is_dead() or cb() is callback:             # <<<<<<<<<<<<<<
 *                 self.observers.remove(cb)
 *                 continue
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_cb, __pyx_n_s__is_dead); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (!__pyx_t_5) {
      __pyx_t_4 = PyObject_Call(__pyx_v_cb, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = (__pyx_t_4 == __pyx_v_callback);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = __pyx_t_6;
    } else {
      __pyx_t_7 = __pyx_t_5;
    }
    if (__pyx_t_7) {

      /* "kivy\graphics\texture.pyx":657
 *         for cb in self.observers[:]:
 *             if cb.is_dead() or cb() is callback:
 *                 self.observers.remove(cb)             # <<<<<<<<<<<<<<
 *                 continue
 * 
 */
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->observers), __pyx_n_s__remove); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_v_cb);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_cb);
      __Pyx_GIVEREF(__pyx_v_cb);
      __pyx_t_8 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "kivy\graphics\texture.pyx":658
 *             if cb.is_dead() or cb() is callback:
 *                 self.observers.remove(cb)
 *                 continue             # <<<<<<<<<<<<<<
 * 
 *     cdef void allocate(self):
 */
      goto __pyx_L3_continue;
      goto __pyx_L5;
    }
    __pyx_L5:;
    __pyx_L3_continue:;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.remove_reload_observer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_cb);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":660
 *                 continue
 * 
 *     cdef void allocate(self):             # <<<<<<<<<<<<<<
 *         cdef int glfmt, iglbufferfmt, datasize, dataerr = 0
 *         cdef void *data = NULL
 */

static void __pyx_f_4kivy_8graphics_7texture_7Texture_allocate(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  int __pyx_v_glfmt;
  int __pyx_v_iglbufferfmt;
  int __pyx_v_datasize;
  int __pyx_v_dataerr;
  void *__pyx_v_data;
  int __pyx_v_is_npot;
  CYTHON_UNUSED long __pyx_v_make_npot;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("allocate", 0);

  /* "kivy\graphics\texture.pyx":661
 * 
 *     cdef void allocate(self):
 *         cdef int glfmt, iglbufferfmt, datasize, dataerr = 0             # <<<<<<<<<<<<<<
 *         cdef void *data = NULL
 *         cdef int is_npot = 0
 */
  __pyx_v_dataerr = 0;

  /* "kivy\graphics\texture.pyx":662
 *     cdef void allocate(self):
 *         cdef int glfmt, iglbufferfmt, datasize, dataerr = 0
 *         cdef void *data = NULL             # <<<<<<<<<<<<<<
 *         cdef int is_npot = 0
 * 
 */
  __pyx_v_data = NULL;

  /* "kivy\graphics\texture.pyx":663
 *         cdef int glfmt, iglbufferfmt, datasize, dataerr = 0
 *         cdef void *data = NULL
 *         cdef int is_npot = 0             # <<<<<<<<<<<<<<
 * 
 *         # check if it's a pot or not
 */
  __pyx_v_is_npot = 0;

  /* "kivy\graphics\texture.pyx":666
 * 
 *         # check if it's a pot or not
 *         if not _is_pow2(self._width) or not _is_pow2(self._height):             # <<<<<<<<<<<<<<
 *             make_npot = is_npot = 1
 * 
 */
  __pyx_t_1 = ((!(__pyx_f_4kivy_8graphics_7texture__is_pow2(__pyx_v_self->_width) != 0)) != 0);
  if (!__pyx_t_1) {
    __pyx_t_2 = ((!(__pyx_f_4kivy_8graphics_7texture__is_pow2(__pyx_v_self->_height) != 0)) != 0);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_1;
  }
  if (__pyx_t_3) {

    /* "kivy\graphics\texture.pyx":667
 *         # check if it's a pot or not
 *         if not _is_pow2(self._width) or not _is_pow2(self._height):
 *             make_npot = is_npot = 1             # <<<<<<<<<<<<<<
 * 
 *         # prepare information needed for nogil
 */
    __pyx_v_make_npot = 1;
    __pyx_v_is_npot = 1;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "kivy\graphics\texture.pyx":670
 * 
 *         # prepare information needed for nogil
 *         glfmt = _color_fmt_to_gl(self._colorfmt)             # <<<<<<<<<<<<<<
 *         iglbufferfmt = _buffer_fmt_to_gl(self._bufferfmt)
 *         datasize = self._width * self._height * \
 */
  __pyx_t_4 = ((PyObject *)__pyx_v_self->_colorfmt);
  __Pyx_INCREF(__pyx_t_4);
  __pyx_v_glfmt = __pyx_f_4kivy_8graphics_7texture__color_fmt_to_gl(((PyObject*)__pyx_t_4));
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":671
 *         # prepare information needed for nogil
 *         glfmt = _color_fmt_to_gl(self._colorfmt)
 *         iglbufferfmt = _buffer_fmt_to_gl(self._bufferfmt)             # <<<<<<<<<<<<<<
 *         datasize = self._width * self._height * \
 *                 _gl_format_size(glfmt) * _buffer_type_to_gl_size(self._bufferfmt)
 */
  __pyx_t_4 = ((PyObject *)__pyx_v_self->_bufferfmt);
  __Pyx_INCREF(__pyx_t_4);
  __pyx_v_iglbufferfmt = __pyx_f_4kivy_8graphics_7texture__buffer_fmt_to_gl(((PyObject*)__pyx_t_4));
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":673
 *         iglbufferfmt = _buffer_fmt_to_gl(self._bufferfmt)
 *         datasize = self._width * self._height * \
 *                 _gl_format_size(glfmt) * _buffer_type_to_gl_size(self._bufferfmt)             # <<<<<<<<<<<<<<
 * 
 *         # act as we have been able to allocate the texture
 */
  __pyx_t_4 = ((PyObject *)__pyx_v_self->_bufferfmt);
  __Pyx_INCREF(__pyx_t_4);
  __pyx_v_datasize = (((__pyx_v_self->_width * __pyx_v_self->_height) * __pyx_f_4kivy_8graphics_7texture__gl_format_size(__pyx_v_glfmt)) * __pyx_f_4kivy_8graphics_7texture__buffer_type_to_gl_size(((PyObject*)__pyx_t_4)));
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":676
 * 
 *         # act as we have been able to allocate the texture
 *         self._is_allocated = 1             # <<<<<<<<<<<<<<
 * 
 *         # do the rest outside the Python GIL
 */
  __pyx_v_self->_is_allocated = 1;

  /* "kivy\graphics\texture.pyx":679
 * 
 *         # do the rest outside the Python GIL
 *         with nogil:             # <<<<<<<<<<<<<<
 *             data = calloc(1, datasize)
 *             if data != NULL:
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      #endif
      /*try:*/ {

        /* "kivy\graphics\texture.pyx":680
 *         # do the rest outside the Python GIL
 *         with nogil:
 *             data = calloc(1, datasize)             # <<<<<<<<<<<<<<
 *             if data != NULL:
 *                 # ensure pixel upload is correct
 */
        __pyx_v_data = calloc(1, __pyx_v_datasize);

        /* "kivy\graphics\texture.pyx":681
 *         with nogil:
 *             data = calloc(1, datasize)
 *             if data != NULL:             # <<<<<<<<<<<<<<
 *                 # ensure pixel upload is correct
 *                 _gl_prepare_pixels_upload(self._width)
 */
        __pyx_t_3 = ((__pyx_v_data != NULL) != 0);
        if (__pyx_t_3) {

          /* "kivy\graphics\texture.pyx":683
 *             if data != NULL:
 *                 # ensure pixel upload is correct
 *                 _gl_prepare_pixels_upload(self._width)             # <<<<<<<<<<<<<<
 * 
 *                 # do the initial upload with fake data
 */
          __pyx_f_4kivy_8graphics_7texture__gl_prepare_pixels_upload(__pyx_v_self->_width);

          /* "kivy\graphics\texture.pyx":687
 *                 # do the initial upload with fake data
 *                 glTexImage2D(self._target, 0, glfmt, self._width, self._height,
 *                         0, glfmt, iglbufferfmt, data)             # <<<<<<<<<<<<<<
 * 
 *                 # free the data !
 */
          glTexImage2D(__pyx_v_self->_target, 0, __pyx_v_glfmt, __pyx_v_self->_width, __pyx_v_self->_height, 0, __pyx_v_glfmt, __pyx_v_iglbufferfmt, __pyx_v_data);

          /* "kivy\graphics\texture.pyx":690
 * 
 *                 # free the data !
 *                 free(data)             # <<<<<<<<<<<<<<
 * 
 *                 # create mipmap if needed
 */
          free(__pyx_v_data);

          /* "kivy\graphics\texture.pyx":693
 * 
 *                 # create mipmap if needed
 *                 if self._mipmap and is_npot == 0:             # <<<<<<<<<<<<<<
 *                     glGenerateMipmap(self._target)
 *             else:
 */
          if ((__pyx_v_self->_mipmap != 0)) {
            __pyx_t_3 = (__pyx_v_is_npot == 0);
            __pyx_t_1 = __pyx_t_3;
          } else {
            __pyx_t_1 = (__pyx_v_self->_mipmap != 0);
          }
          if (__pyx_t_1) {

            /* "kivy\graphics\texture.pyx":694
 *                 # create mipmap if needed
 *                 if self._mipmap and is_npot == 0:
 *                     glGenerateMipmap(self._target)             # <<<<<<<<<<<<<<
 *             else:
 *                 dataerr = 1
 */
            glGenerateMipmap(__pyx_v_self->_target);
            goto __pyx_L8;
          }
          __pyx_L8:;
          goto __pyx_L7;
        }
        /*else*/ {

          /* "kivy\graphics\texture.pyx":696
 *                     glGenerateMipmap(self._target)
 *             else:
 *                 dataerr = 1             # <<<<<<<<<<<<<<
 * 
 *         if dataerr:
 */
          __pyx_v_dataerr = 1;
        }
        __pyx_L7:;
      }

      /* "kivy\graphics\texture.pyx":679
 * 
 *         # do the rest outside the Python GIL
 *         with nogil:             # <<<<<<<<<<<<<<
 *             data = calloc(1, datasize)
 *             if data != NULL:
 */
      /*finally:*/ {
        #ifdef WITH_THREAD
        Py_BLOCK_THREADS
        #endif
      }
  }

  /* "kivy\graphics\texture.pyx":698
 *                 dataerr = 1
 * 
 *         if dataerr:             # <<<<<<<<<<<<<<
 *             self._is_allocated = 0
 *             raise Exception('Unable to allocate memory for texture (size is %s)' %
 */
  __pyx_t_1 = (__pyx_v_dataerr != 0);
  if (__pyx_t_1) {

    /* "kivy\graphics\texture.pyx":699
 * 
 *         if dataerr:
 *             self._is_allocated = 0             # <<<<<<<<<<<<<<
 *             raise Exception('Unable to allocate memory for texture (size is %s)' %
 *                             datasize)
 */
    __pyx_v_self->_is_allocated = 0;

    /* "kivy\graphics\texture.pyx":701
 *             self._is_allocated = 0
 *             raise Exception('Unable to allocate memory for texture (size is %s)' %
 *                             datasize)             # <<<<<<<<<<<<<<
 * 
 *     cpdef flip_vertical(self):
 */
    __pyx_t_4 = PyInt_FromLong(__pyx_v_datasize); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_21), __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_5));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
    __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_5, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L9;
  }
  __pyx_L9:;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("kivy.graphics.texture.Texture.allocate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "kivy\graphics\texture.pyx":703
 *                             datasize)
 * 
 *     cpdef flip_vertical(self):             # <<<<<<<<<<<<<<
 *         '''Flip tex_coords for vertical displaying'''
 *         self._uvy += self._uvh
 */

static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_9flip_vertical(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4kivy_8graphics_7texture_7Texture_flip_vertical(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("flip_vertical", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__flip_vertical); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_7Texture_9flip_vertical)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "kivy\graphics\texture.pyx":705
 *     cpdef flip_vertical(self):
 *         '''Flip tex_coords for vertical displaying'''
 *         self._uvy += self._uvh             # <<<<<<<<<<<<<<
 *         self._uvh = -self._uvh
 *         self.update_tex_coords()
 */
  __pyx_v_self->_uvy = (__pyx_v_self->_uvy + __pyx_v_self->_uvh);

  /* "kivy\graphics\texture.pyx":706
 *         '''Flip tex_coords for vertical displaying'''
 *         self._uvy += self._uvh
 *         self._uvh = -self._uvh             # <<<<<<<<<<<<<<
 *         self.update_tex_coords()
 * 
 */
  __pyx_v_self->_uvh = (-__pyx_v_self->_uvh);

  /* "kivy\graphics\texture.pyx":707
 *         self._uvy += self._uvh
 *         self._uvh = -self._uvh
 *         self.update_tex_coords()             # <<<<<<<<<<<<<<
 * 
 *     cpdef get_region(self, x, y, width, height):
 */
  ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_self->__pyx_vtab)->update_tex_coords(__pyx_v_self);

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.flip_vertical", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_9flip_vertical(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_7Texture_8flip_vertical[] = "Flip tex_coords for vertical displaying";
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_9flip_vertical(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("flip_vertical (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_8flip_vertical(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":703
 *                             datasize)
 * 
 *     cpdef flip_vertical(self):             # <<<<<<<<<<<<<<
 *         '''Flip tex_coords for vertical displaying'''
 *         self._uvy += self._uvh
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_8flip_vertical(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("flip_vertical", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_self->__pyx_vtab)->flip_vertical(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.flip_vertical", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":709
 *         self.update_tex_coords()
 * 
 *     cpdef get_region(self, x, y, width, height):             # <<<<<<<<<<<<<<
 *         '''Return a part of the texture defined by the rectangle arguments
 *         (x, y, width, height). Returns a :class:`TextureRegion` instance.'''
 */

static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_11get_region(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4kivy_8graphics_7texture_7Texture_get_region(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x, PyObject *__pyx_v_y, PyObject *__pyx_v_width, PyObject *__pyx_v_height, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_region", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__get_region); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_7Texture_11get_region)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      __Pyx_INCREF(__pyx_v_y);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_y);
      __Pyx_GIVEREF(__pyx_v_y);
      __Pyx_INCREF(__pyx_v_width);
      PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_width);
      __Pyx_GIVEREF(__pyx_v_width);
      __Pyx_INCREF(__pyx_v_height);
      PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_height);
      __Pyx_GIVEREF(__pyx_v_height);
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "kivy\graphics\texture.pyx":712
 *         '''Return a part of the texture defined by the rectangle arguments
 *         (x, y, width, height). Returns a :class:`TextureRegion` instance.'''
 *         return TextureRegion(x, y, width, height, self)             # <<<<<<<<<<<<<<
 * 
 *     def ask_update(self, callback):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_x);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_x);
  __Pyx_GIVEREF(__pyx_v_x);
  __Pyx_INCREF(__pyx_v_y);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_y);
  __Pyx_GIVEREF(__pyx_v_y);
  __Pyx_INCREF(__pyx_v_width);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_width);
  __Pyx_GIVEREF(__pyx_v_width);
  __Pyx_INCREF(__pyx_v_height);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_height);
  __Pyx_GIVEREF(__pyx_v_height);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4kivy_8graphics_7texture_TextureRegion)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.get_region", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_11get_region(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_7Texture_10get_region[] = "Return a part of the texture defined by the rectangle arguments\n        (x, y, width, height). Returns a :class:`TextureRegion` instance.";
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_11get_region(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_x = 0;
  PyObject *__pyx_v_y = 0;
  PyObject *__pyx_v_width = 0;
  PyObject *__pyx_v_height = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_region (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__x,&__pyx_n_s__y,&__pyx_n_s__width,&__pyx_n_s__height,0};
    PyObject* values[4] = {0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_region", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__width)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_region", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__height)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("get_region", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_region") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
    }
    __pyx_v_x = values[0];
    __pyx_v_y = values[1];
    __pyx_v_width = values[2];
    __pyx_v_height = values[3];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_region", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.get_region", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_10get_region(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), __pyx_v_x, __pyx_v_y, __pyx_v_width, __pyx_v_height);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":709
 *         self.update_tex_coords()
 * 
 *     cpdef get_region(self, x, y, width, height):             # <<<<<<<<<<<<<<
 *         '''Return a part of the texture defined by the rectangle arguments
 *         (x, y, width, height). Returns a :class:`TextureRegion` instance.'''
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_10get_region(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x, PyObject *__pyx_v_y, PyObject *__pyx_v_width, PyObject *__pyx_v_height) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_region", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_self->__pyx_vtab)->get_region(__pyx_v_self, __pyx_v_x, __pyx_v_y, __pyx_v_width, __pyx_v_height, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.get_region", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_13ask_update(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_7Texture_12ask_update[] = "Indicate that the content of the texture should be updated, and the\n        callback function need to be called when the texture will be really\n        used.\n        ";
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_13ask_update(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ask_update (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_12ask_update(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), ((PyObject *)__pyx_v_callback));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":714
 *         return TextureRegion(x, y, width, height, self)
 * 
 *     def ask_update(self, callback):             # <<<<<<<<<<<<<<
 *         '''Indicate that the content of the texture should be updated, and the
 *         callback function need to be called when the texture will be really
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_12ask_update(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ask_update", 0);

  /* "kivy\graphics\texture.pyx":719
 *         used.
 *         '''
 *         self.flags |= TI_NEED_PIXELS             # <<<<<<<<<<<<<<
 *         self._callback = callback
 * 
 */
  __pyx_v_self->flags = (__pyx_v_self->flags | __pyx_v_4kivy_8graphics_7texture_TI_NEED_PIXELS);

  /* "kivy\graphics\texture.pyx":720
 *         '''
 *         self.flags |= TI_NEED_PIXELS
 *         self._callback = callback             # <<<<<<<<<<<<<<
 * 
 *     cpdef bind(self):
 */
  __Pyx_INCREF(__pyx_v_callback);
  __Pyx_GIVEREF(__pyx_v_callback);
  __Pyx_GOTREF(__pyx_v_self->_callback);
  __Pyx_DECREF(__pyx_v_self->_callback);
  __pyx_v_self->_callback = __pyx_v_callback;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":722
 *         self._callback = callback
 * 
 *     cpdef bind(self):             # <<<<<<<<<<<<<<
 *         '''Bind the texture to current opengl state'''
 *         cdef GLuint value
 */

static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_15bind(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4kivy_8graphics_7texture_7Texture_bind(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, int __pyx_skip_dispatch) {
  GLuint __pyx_v_value;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("bind", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__bind); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_7Texture_15bind)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "kivy\graphics\texture.pyx":727
 * 
 *         # if we have no change to apply, just bind and exit
 *         if not self.flags:             # <<<<<<<<<<<<<<
 *             glBindTexture(self._target, self._id)
 *             return
 */
  __pyx_t_3 = ((!(__pyx_v_self->flags != 0)) != 0);
  if (__pyx_t_3) {

    /* "kivy\graphics\texture.pyx":728
 *         # if we have no change to apply, just bind and exit
 *         if not self.flags:
 *             glBindTexture(self._target, self._id)             # <<<<<<<<<<<<<<
 *             return
 * 
 */
    glBindTexture(__pyx_v_self->_target, __pyx_v_self->_id);

    /* "kivy\graphics\texture.pyx":729
 *         if not self.flags:
 *             glBindTexture(self._target, self._id)
 *             return             # <<<<<<<<<<<<<<
 * 
 *         if self.flags & TI_NEED_GEN:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "kivy\graphics\texture.pyx":731
 *             return
 * 
 *         if self.flags & TI_NEED_GEN:             # <<<<<<<<<<<<<<
 *             self.flags &= ~TI_NEED_GEN
 *             glGenTextures(1, &self._id)
 */
  __pyx_t_3 = ((__pyx_v_self->flags & __pyx_v_4kivy_8graphics_7texture_TI_NEED_GEN) != 0);
  if (__pyx_t_3) {

    /* "kivy\graphics\texture.pyx":732
 * 
 *         if self.flags & TI_NEED_GEN:
 *             self.flags &= ~TI_NEED_GEN             # <<<<<<<<<<<<<<
 *             glGenTextures(1, &self._id)
 * 
 */
    __pyx_v_self->flags = (__pyx_v_self->flags & (~__pyx_v_4kivy_8graphics_7texture_TI_NEED_GEN));

    /* "kivy\graphics\texture.pyx":733
 *         if self.flags & TI_NEED_GEN:
 *             self.flags &= ~TI_NEED_GEN
 *             glGenTextures(1, &self._id)             # <<<<<<<<<<<<<<
 * 
 *         glBindTexture(self._target, self._id)
 */
    glGenTextures(1, (&__pyx_v_self->_id));
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "kivy\graphics\texture.pyx":735
 *             glGenTextures(1, &self._id)
 * 
 *         glBindTexture(self._target, self._id)             # <<<<<<<<<<<<<<
 * 
 *         if self.flags & TI_NEED_ALLOCATE:
 */
  glBindTexture(__pyx_v_self->_target, __pyx_v_self->_id);

  /* "kivy\graphics\texture.pyx":737
 *         glBindTexture(self._target, self._id)
 * 
 *         if self.flags & TI_NEED_ALLOCATE:             # <<<<<<<<<<<<<<
 *             self.flags &= ~TI_NEED_ALLOCATE
 *             self.allocate()
 */
  __pyx_t_3 = ((__pyx_v_self->flags & __pyx_v_4kivy_8graphics_7texture_TI_NEED_ALLOCATE) != 0);
  if (__pyx_t_3) {

    /* "kivy\graphics\texture.pyx":738
 * 
 *         if self.flags & TI_NEED_ALLOCATE:
 *             self.flags &= ~TI_NEED_ALLOCATE             # <<<<<<<<<<<<<<
 *             self.allocate()
 * 
 */
    __pyx_v_self->flags = (__pyx_v_self->flags & (~__pyx_v_4kivy_8graphics_7texture_TI_NEED_ALLOCATE));

    /* "kivy\graphics\texture.pyx":739
 *         if self.flags & TI_NEED_ALLOCATE:
 *             self.flags &= ~TI_NEED_ALLOCATE
 *             self.allocate()             # <<<<<<<<<<<<<<
 * 
 *         if self.flags & TI_NEED_PIXELS:
 */
    ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_self->__pyx_vtab)->allocate(__pyx_v_self);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "kivy\graphics\texture.pyx":741
 *             self.allocate()
 * 
 *         if self.flags & TI_NEED_PIXELS:             # <<<<<<<<<<<<<<
 *             self.flags &= ~TI_NEED_PIXELS
 *             if self._callback:
 */
  __pyx_t_3 = ((__pyx_v_self->flags & __pyx_v_4kivy_8graphics_7texture_TI_NEED_PIXELS) != 0);
  if (__pyx_t_3) {

    /* "kivy\graphics\texture.pyx":742
 * 
 *         if self.flags & TI_NEED_PIXELS:
 *             self.flags &= ~TI_NEED_PIXELS             # <<<<<<<<<<<<<<
 *             if self._callback:
 *                 self._callback(self)
 */
    __pyx_v_self->flags = (__pyx_v_self->flags & (~__pyx_v_4kivy_8graphics_7texture_TI_NEED_PIXELS));

    /* "kivy\graphics\texture.pyx":743
 *         if self.flags & TI_NEED_PIXELS:
 *             self.flags &= ~TI_NEED_PIXELS
 *             if self._callback:             # <<<<<<<<<<<<<<
 *                 self._callback(self)
 *                 self._callback = None
 */
    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_self->_callback); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (__pyx_t_3) {

      /* "kivy\graphics\texture.pyx":744
 *             self.flags &= ~TI_NEED_PIXELS
 *             if self._callback:
 *                 self._callback(self)             # <<<<<<<<<<<<<<
 *                 self._callback = None
 * 
 */
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(((PyObject *)__pyx_v_self));
      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
      __pyx_t_2 = PyObject_Call(__pyx_v_self->_callback, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "kivy\graphics\texture.pyx":745
 *             if self._callback:
 *                 self._callback(self)
 *                 self._callback = None             # <<<<<<<<<<<<<<
 * 
 *         if self.flags & TI_MIN_FILTER:
 */
      __Pyx_INCREF(Py_None);
      __Pyx_GIVEREF(Py_None);
      __Pyx_GOTREF(__pyx_v_self->_callback);
      __Pyx_DECREF(__pyx_v_self->_callback);
      __pyx_v_self->_callback = Py_None;
      goto __pyx_L7;
    }
    __pyx_L7:;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "kivy\graphics\texture.pyx":747
 *                 self._callback = None
 * 
 *         if self.flags & TI_MIN_FILTER:             # <<<<<<<<<<<<<<
 *             self.flags &= ~TI_MIN_FILTER
 *             value = _str_to_gl_texture_min_filter(self._min_filter)
 */
  __pyx_t_3 = ((__pyx_v_self->flags & __pyx_v_4kivy_8graphics_7texture_TI_MIN_FILTER) != 0);
  if (__pyx_t_3) {

    /* "kivy\graphics\texture.pyx":748
 * 
 *         if self.flags & TI_MIN_FILTER:
 *             self.flags &= ~TI_MIN_FILTER             # <<<<<<<<<<<<<<
 *             value = _str_to_gl_texture_min_filter(self._min_filter)
 *             glTexParameteri(self._target, GL_TEXTURE_MIN_FILTER, value)
 */
    __pyx_v_self->flags = (__pyx_v_self->flags & (~__pyx_v_4kivy_8graphics_7texture_TI_MIN_FILTER));

    /* "kivy\graphics\texture.pyx":749
 *         if self.flags & TI_MIN_FILTER:
 *             self.flags &= ~TI_MIN_FILTER
 *             value = _str_to_gl_texture_min_filter(self._min_filter)             # <<<<<<<<<<<<<<
 *             glTexParameteri(self._target, GL_TEXTURE_MIN_FILTER, value)
 * 
 */
    __pyx_t_2 = ((PyObject *)__pyx_v_self->_min_filter);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v_value = __pyx_f_4kivy_8graphics_7texture__str_to_gl_texture_min_filter(((PyObject*)__pyx_t_2));
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "kivy\graphics\texture.pyx":750
 *             self.flags &= ~TI_MIN_FILTER
 *             value = _str_to_gl_texture_min_filter(self._min_filter)
 *             glTexParameteri(self._target, GL_TEXTURE_MIN_FILTER, value)             # <<<<<<<<<<<<<<
 * 
 *         if self.flags & TI_MAG_FILTER:
 */
    glTexParameteri(__pyx_v_self->_target, GL_TEXTURE_MIN_FILTER, __pyx_v_value);
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "kivy\graphics\texture.pyx":752
 *             glTexParameteri(self._target, GL_TEXTURE_MIN_FILTER, value)
 * 
 *         if self.flags & TI_MAG_FILTER:             # <<<<<<<<<<<<<<
 *             self.flags &= ~TI_MAG_FILTER
 *             value = _str_to_gl_texture_mag_filter(self._mag_filter)
 */
  __pyx_t_3 = ((__pyx_v_self->flags & __pyx_v_4kivy_8graphics_7texture_TI_MAG_FILTER) != 0);
  if (__pyx_t_3) {

    /* "kivy\graphics\texture.pyx":753
 * 
 *         if self.flags & TI_MAG_FILTER:
 *             self.flags &= ~TI_MAG_FILTER             # <<<<<<<<<<<<<<
 *             value = _str_to_gl_texture_mag_filter(self._mag_filter)
 *             glTexParameteri(self._target, GL_TEXTURE_MAG_FILTER, value)
 */
    __pyx_v_self->flags = (__pyx_v_self->flags & (~__pyx_v_4kivy_8graphics_7texture_TI_MAG_FILTER));

    /* "kivy\graphics\texture.pyx":754
 *         if self.flags & TI_MAG_FILTER:
 *             self.flags &= ~TI_MAG_FILTER
 *             value = _str_to_gl_texture_mag_filter(self._mag_filter)             # <<<<<<<<<<<<<<
 *             glTexParameteri(self._target, GL_TEXTURE_MAG_FILTER, value)
 * 
 */
    __pyx_t_2 = ((PyObject *)__pyx_v_self->_mag_filter);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v_value = __pyx_f_4kivy_8graphics_7texture__str_to_gl_texture_mag_filter(((PyObject*)__pyx_t_2));
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "kivy\graphics\texture.pyx":755
 *             self.flags &= ~TI_MAG_FILTER
 *             value = _str_to_gl_texture_mag_filter(self._mag_filter)
 *             glTexParameteri(self._target, GL_TEXTURE_MAG_FILTER, value)             # <<<<<<<<<<<<<<
 * 
 *         if self.flags & TI_WRAP:
 */
    glTexParameteri(__pyx_v_self->_target, GL_TEXTURE_MAG_FILTER, __pyx_v_value);
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "kivy\graphics\texture.pyx":757
 *             glTexParameteri(self._target, GL_TEXTURE_MAG_FILTER, value)
 * 
 *         if self.flags & TI_WRAP:             # <<<<<<<<<<<<<<
 *             self.flags &= ~TI_WRAP
 *             value = _str_to_gl_texture_wrap(self._wrap)
 */
  __pyx_t_3 = ((__pyx_v_self->flags & __pyx_v_4kivy_8graphics_7texture_TI_WRAP) != 0);
  if (__pyx_t_3) {

    /* "kivy\graphics\texture.pyx":758
 * 
 *         if self.flags & TI_WRAP:
 *             self.flags &= ~TI_WRAP             # <<<<<<<<<<<<<<
 *             value = _str_to_gl_texture_wrap(self._wrap)
 *             glTexParameteri(self._target, GL_TEXTURE_WRAP_S, value)
 */
    __pyx_v_self->flags = (__pyx_v_self->flags & (~__pyx_v_4kivy_8graphics_7texture_TI_WRAP));

    /* "kivy\graphics\texture.pyx":759
 *         if self.flags & TI_WRAP:
 *             self.flags &= ~TI_WRAP
 *             value = _str_to_gl_texture_wrap(self._wrap)             # <<<<<<<<<<<<<<
 *             glTexParameteri(self._target, GL_TEXTURE_WRAP_S, value)
 *             glTexParameteri(self._target, GL_TEXTURE_WRAP_T, value)
 */
    __pyx_t_2 = ((PyObject *)__pyx_v_self->_wrap);
    __Pyx_INCREF(__pyx_t_2);
    __pyx_v_value = __pyx_f_4kivy_8graphics_7texture__str_to_gl_texture_wrap(((PyObject*)__pyx_t_2));
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "kivy\graphics\texture.pyx":760
 *             self.flags &= ~TI_WRAP
 *             value = _str_to_gl_texture_wrap(self._wrap)
 *             glTexParameteri(self._target, GL_TEXTURE_WRAP_S, value)             # <<<<<<<<<<<<<<
 *             glTexParameteri(self._target, GL_TEXTURE_WRAP_T, value)
 * 
 */
    glTexParameteri(__pyx_v_self->_target, GL_TEXTURE_WRAP_S, __pyx_v_value);

    /* "kivy\graphics\texture.pyx":761
 *             value = _str_to_gl_texture_wrap(self._wrap)
 *             glTexParameteri(self._target, GL_TEXTURE_WRAP_S, value)
 *             glTexParameteri(self._target, GL_TEXTURE_WRAP_T, value)             # <<<<<<<<<<<<<<
 * 
 *     cdef void set_min_filter(self, str x):
 */
    glTexParameteri(__pyx_v_self->_target, GL_TEXTURE_WRAP_T, __pyx_v_value);
    goto __pyx_L10;
  }
  __pyx_L10:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.bind", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_15bind(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_7Texture_14bind[] = "Bind the texture to current opengl state";
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_15bind(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bind (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_14bind(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":722
 *         self._callback = callback
 * 
 *     cpdef bind(self):             # <<<<<<<<<<<<<<
 *         '''Bind the texture to current opengl state'''
 *         cdef GLuint value
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_14bind(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("bind", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_self->__pyx_vtab)->bind(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.bind", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":763
 *             glTexParameteri(self._target, GL_TEXTURE_WRAP_T, value)
 * 
 *     cdef void set_min_filter(self, str x):             # <<<<<<<<<<<<<<
 *         if self._min_filter != x:
 *             self._min_filter = x
 */

static void __pyx_f_4kivy_8graphics_7texture_7Texture_set_min_filter(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set_min_filter", 0);

  /* "kivy\graphics\texture.pyx":764
 * 
 *     cdef void set_min_filter(self, str x):
 *         if self._min_filter != x:             # <<<<<<<<<<<<<<
 *             self._min_filter = x
 *             self.flags |= TI_MIN_FILTER
 */
  __pyx_t_1 = (__Pyx_PyString_Equals(((PyObject *)__pyx_v_self->_min_filter), ((PyObject *)__pyx_v_x), Py_NE)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "kivy\graphics\texture.pyx":765
 *     cdef void set_min_filter(self, str x):
 *         if self._min_filter != x:
 *             self._min_filter = x             # <<<<<<<<<<<<<<
 *             self.flags |= TI_MIN_FILTER
 * 
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_x));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_x));
    __Pyx_GOTREF(__pyx_v_self->_min_filter);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->_min_filter));
    __pyx_v_self->_min_filter = __pyx_v_x;

    /* "kivy\graphics\texture.pyx":766
 *         if self._min_filter != x:
 *             self._min_filter = x
 *             self.flags |= TI_MIN_FILTER             # <<<<<<<<<<<<<<
 * 
 *     cdef void set_mag_filter(self, str x):
 */
    __pyx_v_self->flags = (__pyx_v_self->flags | __pyx_v_4kivy_8graphics_7texture_TI_MIN_FILTER);
    goto __pyx_L3;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("kivy.graphics.texture.Texture.set_min_filter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "kivy\graphics\texture.pyx":768
 *             self.flags |= TI_MIN_FILTER
 * 
 *     cdef void set_mag_filter(self, str x):             # <<<<<<<<<<<<<<
 *         if self._mag_filter != x:
 *             self._mag_filter = x
 */

static void __pyx_f_4kivy_8graphics_7texture_7Texture_set_mag_filter(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set_mag_filter", 0);

  /* "kivy\graphics\texture.pyx":769
 * 
 *     cdef void set_mag_filter(self, str x):
 *         if self._mag_filter != x:             # <<<<<<<<<<<<<<
 *             self._mag_filter = x
 *             self.flags |= TI_MAG_FILTER
 */
  __pyx_t_1 = (__Pyx_PyString_Equals(((PyObject *)__pyx_v_self->_mag_filter), ((PyObject *)__pyx_v_x), Py_NE)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "kivy\graphics\texture.pyx":770
 *     cdef void set_mag_filter(self, str x):
 *         if self._mag_filter != x:
 *             self._mag_filter = x             # <<<<<<<<<<<<<<
 *             self.flags |= TI_MAG_FILTER
 * 
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_x));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_x));
    __Pyx_GOTREF(__pyx_v_self->_mag_filter);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->_mag_filter));
    __pyx_v_self->_mag_filter = __pyx_v_x;

    /* "kivy\graphics\texture.pyx":771
 *         if self._mag_filter != x:
 *             self._mag_filter = x
 *             self.flags |= TI_MAG_FILTER             # <<<<<<<<<<<<<<
 * 
 *     cdef void set_wrap(self, str x):
 */
    __pyx_v_self->flags = (__pyx_v_self->flags | __pyx_v_4kivy_8graphics_7texture_TI_MAG_FILTER);
    goto __pyx_L3;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("kivy.graphics.texture.Texture.set_mag_filter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "kivy\graphics\texture.pyx":773
 *             self.flags |= TI_MAG_FILTER
 * 
 *     cdef void set_wrap(self, str x):             # <<<<<<<<<<<<<<
 *         if self._wrap != x:
 *             self._wrap = x
 */

static void __pyx_f_4kivy_8graphics_7texture_7Texture_set_wrap(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x) {
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set_wrap", 0);

  /* "kivy\graphics\texture.pyx":774
 * 
 *     cdef void set_wrap(self, str x):
 *         if self._wrap != x:             # <<<<<<<<<<<<<<
 *             self._wrap = x
 *             self.flags |= TI_WRAP
 */
  __pyx_t_1 = (__Pyx_PyString_Equals(((PyObject *)__pyx_v_self->_wrap), ((PyObject *)__pyx_v_x), Py_NE)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "kivy\graphics\texture.pyx":775
 *     cdef void set_wrap(self, str x):
 *         if self._wrap != x:
 *             self._wrap = x             # <<<<<<<<<<<<<<
 *             self.flags |= TI_WRAP
 * 
 */
    __Pyx_INCREF(((PyObject *)__pyx_v_x));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_x));
    __Pyx_GOTREF(__pyx_v_self->_wrap);
    __Pyx_DECREF(((PyObject *)__pyx_v_self->_wrap));
    __pyx_v_self->_wrap = __pyx_v_x;

    /* "kivy\graphics\texture.pyx":776
 *         if self._wrap != x:
 *             self._wrap = x
 *             self.flags |= TI_WRAP             # <<<<<<<<<<<<<<
 * 
 *     def blit_data(self, im, pos=None):
 */
    __pyx_v_self->flags = (__pyx_v_self->flags | __pyx_v_4kivy_8graphics_7texture_TI_WRAP);
    goto __pyx_L3;
  }
  __pyx_L3:;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("kivy.graphics.texture.Texture.set_wrap", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_17blit_data(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_7Texture_16blit_data[] = "Replace a whole texture with a image data\n        ";
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_17blit_data(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_im = 0;
  PyObject *__pyx_v_pos = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("blit_data (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__im,&__pyx_n_s__pos,0};
    PyObject* values[2] = {0,0};

    /* "kivy\graphics\texture.pyx":778
 *             self.flags |= TI_WRAP
 * 
 *     def blit_data(self, im, pos=None):             # <<<<<<<<<<<<<<
 *         '''Replace a whole texture with a image data
 *         '''
 */
    values[1] = ((PyObject *)Py_None);
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__im)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pos);
          if (value) { values[1] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "blit_data") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_im = values[0];
    __pyx_v_pos = values[1];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("blit_data", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.blit_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_16blit_data(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), __pyx_v_im, __pyx_v_pos);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_16blit_data(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_im, PyObject *__pyx_v_pos) {
  PyObject *__pyx_v_blit = NULL;
  PyObject *__pyx_v_level = NULL;
  PyObject *__pyx_v_width = NULL;
  PyObject *__pyx_v_height = NULL;
  PyObject *__pyx_v_data = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *(*__pyx_t_12)(PyObject *);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("blit_data", 0);

  /* "kivy\graphics\texture.pyx":781
 *         '''Replace a whole texture with a image data
 *         '''
 *         blit = self.blit_buffer             # <<<<<<<<<<<<<<
 * 
 *         # depending if imagedata have mipmap, think different.
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__blit_buffer); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_blit = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "kivy\graphics\texture.pyx":784
 * 
 *         # depending if imagedata have mipmap, think different.
 *         if not im.have_mipmap:             # <<<<<<<<<<<<<<
 *             blit(im.data, size=im.size, colorfmt=im.fmt, pos=pos)
 *         else:
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_im, __pyx_n_s__have_mipmap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = ((!__pyx_t_2) != 0);
  if (__pyx_t_3) {

    /* "kivy\graphics\texture.pyx":785
 *         # depending if imagedata have mipmap, think different.
 *         if not im.have_mipmap:
 *             blit(im.data, size=im.size, colorfmt=im.fmt, pos=pos)             # <<<<<<<<<<<<<<
 *         else:
 *             # upload each level
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_im, __pyx_n_s__data); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;
    __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_im, __pyx_n_s__size); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__size), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_im, __pyx_n_s__fmt); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__colorfmt), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__pos), __pyx_v_pos) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = PyObject_Call(__pyx_v_blit, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "kivy\graphics\texture.pyx":788
 *         else:
 *             # upload each level
 *             for level, width, height, data in im.iterate_mipmaps():             # <<<<<<<<<<<<<<
 *                 blit(data, size=(width, height),
 *                      colorfmt=im.fmt, pos=pos,
 */
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_im, __pyx_n_s__iterate_mipmaps); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
      __pyx_t_5 = __pyx_t_1; __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = 0;
      __pyx_t_7 = NULL;
    } else {
      __pyx_t_6 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = Py_TYPE(__pyx_t_5)->tp_iternext;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (;;) {
      if (!__pyx_t_7 && PyList_CheckExact(__pyx_t_5)) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else if (!__pyx_t_7 && PyTuple_CheckExact(__pyx_t_5)) {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
        #if CYTHON_COMPILING_IN_CPYTHON
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #else
        __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        #endif
      } else {
        __pyx_t_1 = __pyx_t_7(__pyx_t_5);
        if (unlikely(!__pyx_t_1)) {
          if (PyErr_Occurred()) {
            if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          }
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
        PyObject* sequence = __pyx_t_1;
        #if CYTHON_COMPILING_IN_CPYTHON
        Py_ssize_t size = Py_SIZE(sequence);
        #else
        Py_ssize_t size = PySequence_Size(sequence);
        #endif
        if (unlikely(size != 4)) {
          if (size > 4) __Pyx_RaiseTooManyValuesError(4);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        }
        #if CYTHON_COMPILING_IN_CPYTHON
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyTuple_GET_ITEM(sequence, 1); 
          __pyx_t_9 = PyTuple_GET_ITEM(sequence, 2); 
          __pyx_t_10 = PyTuple_GET_ITEM(sequence, 3); 
        } else {
          __pyx_t_4 = PyList_GET_ITEM(sequence, 0); 
          __pyx_t_8 = PyList_GET_ITEM(sequence, 1); 
          __pyx_t_9 = PyList_GET_ITEM(sequence, 2); 
          __pyx_t_10 = PyList_GET_ITEM(sequence, 3); 
        }
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_10);
        #else
        Py_ssize_t i;
        PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_8,&__pyx_t_9,&__pyx_t_10};
        for (i=0; i < 4; i++) {
          PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          __Pyx_GOTREF(item);
          *(temps[i]) = item;
        }
        #endif
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } else
      {
        Py_ssize_t index = -1;
        PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_8,&__pyx_t_9,&__pyx_t_10};
        __pyx_t_11 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext;
        for (index=0; index < 4; index++) {
          PyObject* item = __pyx_t_12(__pyx_t_11); if (unlikely(!item)) goto __pyx_L6_unpacking_failed;
          __Pyx_GOTREF(item);
          *(temps[index]) = item;
        }
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_t_12 = NULL;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L7_unpacking_done;
        __pyx_L6_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_12 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __pyx_L7_unpacking_done:;
      }
      __Pyx_XDECREF(__pyx_v_level);
      __pyx_v_level = __pyx_t_4;
      __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_v_width);
      __pyx_v_width = __pyx_t_8;
      __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_v_height);
      __pyx_v_height = __pyx_t_9;
      __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_v_data);
      __pyx_v_data = __pyx_t_10;
      __pyx_t_10 = 0;

      /* "kivy\graphics\texture.pyx":789
 *             # upload each level
 *             for level, width, height, data in im.iterate_mipmaps():
 *                 blit(data, size=(width, height),             # <<<<<<<<<<<<<<
 *                      colorfmt=im.fmt, pos=pos,
 *                      mipmap_level=level, mipmap_generation=False)
 */
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_v_data);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_data);
      __Pyx_GIVEREF(__pyx_v_data);
      __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_10));
      __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_v_width);
      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_width);
      __Pyx_GIVEREF(__pyx_v_width);
      __Pyx_INCREF(__pyx_v_height);
      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_height);
      __Pyx_GIVEREF(__pyx_v_height);
      if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__size), ((PyObject *)__pyx_t_9)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;

      /* "kivy\graphics\texture.pyx":790
 *             for level, width, height, data in im.iterate_mipmaps():
 *                 blit(data, size=(width, height),
 *                      colorfmt=im.fmt, pos=pos,             # <<<<<<<<<<<<<<
 *                      mipmap_level=level, mipmap_generation=False)
 * 
 */
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_im, __pyx_n_s__fmt); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__colorfmt), __pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__pos), __pyx_v_pos) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "kivy\graphics\texture.pyx":791
 *                 blit(data, size=(width, height),
 *                      colorfmt=im.fmt, pos=pos,
 *                      mipmap_level=level, mipmap_generation=False)             # <<<<<<<<<<<<<<
 * 
 *     def blit_buffer(self, pbuffer, size=None, colorfmt=None,
 */
      if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__mipmap_level), __pyx_v_level) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_9 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__mipmap_generation), __pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = PyObject_Call(__pyx_v_blit, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.blit_data", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_blit);
  __Pyx_XDECREF(__pyx_v_level);
  __Pyx_XDECREF(__pyx_v_width);
  __Pyx_XDECREF(__pyx_v_height);
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_19blit_buffer(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_7Texture_18blit_buffer[] = "Blit a buffer into a texture.\n\n        .. versionadded:: 1.0.7 added mipmap_level + mipmap_generation\n\n        :Parameters:\n            `pbuffer` : str\n                Image data\n            `size` : tuple, default to texture size\n                Size of the image (width, height)\n            `colorfmt` : str, default to 'rgb'\n                Image format, can be one of 'rgb', 'rgba', 'bgr', 'bgra',\n                'luminance', 'luminance_alpha'\n            `pos` : tuple, default to (0, 0)\n                Position to blit in the texture\n            `bufferfmt` : str, default to 'ubyte'\n                Type of the data buffer, can be one of 'ubyte', 'ushort',\n                'uint', 'byte', 'short', 'int', 'float'\n            `mipmap_level`: int, default to 0\n                Indicate which mipmap level we are going to update\n            `mipmap_generation`: bool, default to False\n                Indicate if we need to regenerate mipmap from level 0\n        ";
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_19blit_buffer(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_pbuffer = 0;
  PyObject *__pyx_v_size = 0;
  PyObject *__pyx_v_colorfmt = 0;
  PyObject *__pyx_v_pos = 0;
  PyObject *__pyx_v_bufferfmt = 0;
  PyObject *__pyx_v_mipmap_level = 0;
  PyObject *__pyx_v_mipmap_generation = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("blit_buffer (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__pbuffer,&__pyx_n_s__size,&__pyx_n_s__colorfmt,&__pyx_n_s__pos,&__pyx_n_s__bufferfmt,&__pyx_n_s__mipmap_level,&__pyx_n_s__mipmap_generation,0};
    PyObject* values[7] = {0,0,0,0,0,0,0};

    /* "kivy\graphics\texture.pyx":793
 *                      mipmap_level=level, mipmap_generation=False)
 * 
 *     def blit_buffer(self, pbuffer, size=None, colorfmt=None,             # <<<<<<<<<<<<<<
 *                     pos=None, bufferfmt=None, mipmap_level=0,
 *                     mipmap_generation=True):
 */
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);

    /* "kivy\graphics\texture.pyx":794
 * 
 *     def blit_buffer(self, pbuffer, size=None, colorfmt=None,
 *                     pos=None, bufferfmt=None, mipmap_level=0,             # <<<<<<<<<<<<<<
 *                     mipmap_generation=True):
 *         '''Blit a buffer into a texture.
 */
    values[3] = ((PyObject *)Py_None);
    values[4] = ((PyObject *)Py_None);
    values[5] = ((PyObject *)__pyx_int_0);
    values[6] = __pyx_k_22;
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pbuffer)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__size);
          if (value) { values[1] = value; kw_args--; }
        }
        case  2:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__colorfmt);
          if (value) { values[2] = value; kw_args--; }
        }
        case  3:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pos);
          if (value) { values[3] = value; kw_args--; }
        }
        case  4:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__bufferfmt);
          if (value) { values[4] = value; kw_args--; }
        }
        case  5:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mipmap_level);
          if (value) { values[5] = value; kw_args--; }
        }
        case  6:
        if (kw_args > 0) {
          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mipmap_generation);
          if (value) { values[6] = value; kw_args--; }
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "blit_buffer") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else {
      switch (PyTuple_GET_SIZE(__pyx_args)) {
        case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_pbuffer = values[0];
    __pyx_v_size = values[1];
    __pyx_v_colorfmt = values[2];
    __pyx_v_pos = values[3];
    __pyx_v_bufferfmt = values[4];
    __pyx_v_mipmap_level = values[5];
    __pyx_v_mipmap_generation = values[6];
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("blit_buffer", 0, 1, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.blit_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_18blit_buffer(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), __pyx_v_pbuffer, __pyx_v_size, __pyx_v_colorfmt, __pyx_v_pos, __pyx_v_bufferfmt, __pyx_v_mipmap_level, __pyx_v_mipmap_generation);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":793
 *                      mipmap_level=level, mipmap_generation=False)
 * 
 *     def blit_buffer(self, pbuffer, size=None, colorfmt=None,             # <<<<<<<<<<<<<<
 *                     pos=None, bufferfmt=None, mipmap_level=0,
 *                     mipmap_generation=True):
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_18blit_buffer(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_pbuffer, PyObject *__pyx_v_size, PyObject *__pyx_v_colorfmt, PyObject *__pyx_v_pos, PyObject *__pyx_v_bufferfmt, PyObject *__pyx_v_mipmap_level, PyObject *__pyx_v_mipmap_generation) {
  GLuint __pyx_v_target;
  PyObject *__pyx_v_data = 0;
  int __pyx_v_iglfmt;
  int __pyx_v_glfmt;
  int __pyx_v_datasize;
  int __pyx_v_x;
  int __pyx_v_y;
  int __pyx_v_w;
  int __pyx_v_h;
  char *__pyx_v_cdata;
  int __pyx_v_glbufferfmt;
  int __pyx_v_is_allocated;
  int __pyx_v_is_compressed;
  int __pyx_v__mipmap_generation;
  int __pyx_v__mipmap_level;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  GLuint __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  Py_ssize_t __pyx_t_9;
  int __pyx_t_10;
  char *__pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("blit_buffer", 0);
  __Pyx_INCREF(__pyx_v_size);
  __Pyx_INCREF(__pyx_v_colorfmt);
  __Pyx_INCREF(__pyx_v_pos);
  __Pyx_INCREF(__pyx_v_bufferfmt);

  /* "kivy\graphics\texture.pyx":818
 *                 Indicate if we need to regenerate mipmap from level 0
 *         '''
 *         cdef GLuint target = self._target             # <<<<<<<<<<<<<<
 *         if colorfmt is None:
 *             colorfmt = 'rgb'
 */
  __pyx_t_1 = __pyx_v_self->_target;
  __pyx_v_target = __pyx_t_1;

  /* "kivy\graphics\texture.pyx":819
 *         '''
 *         cdef GLuint target = self._target
 *         if colorfmt is None:             # <<<<<<<<<<<<<<
 *             colorfmt = 'rgb'
 *         if bufferfmt is None:
 */
  __pyx_t_2 = (__pyx_v_colorfmt == Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "kivy\graphics\texture.pyx":820
 *         cdef GLuint target = self._target
 *         if colorfmt is None:
 *             colorfmt = 'rgb'             # <<<<<<<<<<<<<<
 *         if bufferfmt is None:
 *             bufferfmt = 'ubyte'
 */
    __Pyx_INCREF(((PyObject *)__pyx_n_s__rgb));
    __Pyx_DECREF(__pyx_v_colorfmt);
    __pyx_v_colorfmt = ((PyObject *)__pyx_n_s__rgb);
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "kivy\graphics\texture.pyx":821
 *         if colorfmt is None:
 *             colorfmt = 'rgb'
 *         if bufferfmt is None:             # <<<<<<<<<<<<<<
 *             bufferfmt = 'ubyte'
 *         if pos is None:
 */
  __pyx_t_3 = (__pyx_v_bufferfmt == Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "kivy\graphics\texture.pyx":822
 *             colorfmt = 'rgb'
 *         if bufferfmt is None:
 *             bufferfmt = 'ubyte'             # <<<<<<<<<<<<<<
 *         if pos is None:
 *             pos = (0, 0)
 */
    __Pyx_INCREF(((PyObject *)__pyx_n_s__ubyte));
    __Pyx_DECREF(__pyx_v_bufferfmt);
    __pyx_v_bufferfmt = ((PyObject *)__pyx_n_s__ubyte);
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "kivy\graphics\texture.pyx":823
 *         if bufferfmt is None:
 *             bufferfmt = 'ubyte'
 *         if pos is None:             # <<<<<<<<<<<<<<
 *             pos = (0, 0)
 *         if size is None:
 */
  __pyx_t_2 = (__pyx_v_pos == Py_None);
  __pyx_t_3 = (__pyx_t_2 != 0);
  if (__pyx_t_3) {

    /* "kivy\graphics\texture.pyx":824
 *             bufferfmt = 'ubyte'
 *         if pos is None:
 *             pos = (0, 0)             # <<<<<<<<<<<<<<
 *         if size is None:
 *             size = self.size
 */
    __Pyx_INCREF(((PyObject *)__pyx_k_tuple_23));
    __Pyx_DECREF(__pyx_v_pos);
    __pyx_v_pos = ((PyObject *)__pyx_k_tuple_23);
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "kivy\graphics\texture.pyx":825
 *         if pos is None:
 *             pos = (0, 0)
 *         if size is None:             # <<<<<<<<<<<<<<
 *             size = self.size
 *         bufferfmt = _buffer_fmt_to_gl(<bytes>bufferfmt)
 */
  __pyx_t_3 = (__pyx_v_size == Py_None);
  __pyx_t_2 = (__pyx_t_3 != 0);
  if (__pyx_t_2) {

    /* "kivy\graphics\texture.pyx":826
 *             pos = (0, 0)
 *         if size is None:
 *             size = self.size             # <<<<<<<<<<<<<<
 *         bufferfmt = _buffer_fmt_to_gl(<bytes>bufferfmt)
 * 
 */
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_v_size);
    __pyx_v_size = __pyx_t_4;
    __pyx_t_4 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "kivy\graphics\texture.pyx":827
 *         if size is None:
 *             size = self.size
 *         bufferfmt = _buffer_fmt_to_gl(<bytes>bufferfmt)             # <<<<<<<<<<<<<<
 * 
 *         # bind the texture, and create anything that should be created at this
 */
  __pyx_t_4 = PyInt_FromLong(__pyx_f_4kivy_8graphics_7texture__buffer_fmt_to_gl(((PyObject*)__pyx_v_bufferfmt))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_v_bufferfmt);
  __pyx_v_bufferfmt = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":831
 *         # bind the texture, and create anything that should be created at this
 *         # time.
 *         self.bind()             # <<<<<<<<<<<<<<
 * 
 *         # need conversion ?
 */
  __pyx_t_4 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_self->__pyx_vtab)->bind(__pyx_v_self, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":835
 *         # need conversion ?
 *         cdef bytes data
 *         data = pbuffer             # <<<<<<<<<<<<<<
 *         data, colorfmt = _convert_buffer(data, colorfmt)
 * 
 */
  if (!(likely(PyBytes_CheckExact(__pyx_v_pbuffer))||((__pyx_v_pbuffer) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_pbuffer)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(__pyx_v_pbuffer);
  __pyx_v_data = ((PyObject*)__pyx_v_pbuffer);

  /* "kivy\graphics\texture.pyx":836
 *         cdef bytes data
 *         data = pbuffer
 *         data, colorfmt = _convert_buffer(data, colorfmt)             # <<<<<<<<<<<<<<
 * 
 *         # prepare nogil
 */
  if (!(likely(PyString_CheckExact(__pyx_v_colorfmt))||((__pyx_v_colorfmt) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_v_colorfmt)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __pyx_f_4kivy_8graphics_7texture__convert_buffer(__pyx_v_data, ((PyObject*)__pyx_v_colorfmt)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
    PyObject* sequence = __pyx_t_4;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_6);
    #else
    __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    #endif
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else
  {
    Py_ssize_t index = -1;
    __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
    index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L7_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_5);
    index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L7_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_6);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_8 = NULL;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    goto __pyx_L8_unpacking_done;
    __pyx_L7_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L8_unpacking_done:;
  }
  if (!(likely(PyBytes_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_v_data));
  __pyx_v_data = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_v_colorfmt);
  __pyx_v_colorfmt = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "kivy\graphics\texture.pyx":839
 * 
 *         # prepare nogil
 *         cdef int iglfmt = _color_fmt_to_gl(self._colorfmt)             # <<<<<<<<<<<<<<
 *         cdef int glfmt = _color_fmt_to_gl(colorfmt)
 *         cdef int datasize = len(pbuffer)
 */
  __pyx_t_4 = ((PyObject *)__pyx_v_self->_colorfmt);
  __Pyx_INCREF(__pyx_t_4);
  __pyx_v_iglfmt = __pyx_f_4kivy_8graphics_7texture__color_fmt_to_gl(((PyObject*)__pyx_t_4));
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":840
 *         # prepare nogil
 *         cdef int iglfmt = _color_fmt_to_gl(self._colorfmt)
 *         cdef int glfmt = _color_fmt_to_gl(colorfmt)             # <<<<<<<<<<<<<<
 *         cdef int datasize = len(pbuffer)
 *         cdef int x = pos[0]
 */
  if (!(likely(PyBytes_CheckExact(__pyx_v_colorfmt))||((__pyx_v_colorfmt) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_colorfmt)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_glfmt = __pyx_f_4kivy_8graphics_7texture__color_fmt_to_gl(((PyObject*)__pyx_v_colorfmt));

  /* "kivy\graphics\texture.pyx":841
 *         cdef int iglfmt = _color_fmt_to_gl(self._colorfmt)
 *         cdef int glfmt = _color_fmt_to_gl(colorfmt)
 *         cdef int datasize = len(pbuffer)             # <<<<<<<<<<<<<<
 *         cdef int x = pos[0]
 *         cdef int y = pos[1]
 */
  __pyx_t_9 = PyObject_Length(__pyx_v_pbuffer); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_datasize = __pyx_t_9;

  /* "kivy\graphics\texture.pyx":842
 *         cdef int glfmt = _color_fmt_to_gl(colorfmt)
 *         cdef int datasize = len(pbuffer)
 *         cdef int x = pos[0]             # <<<<<<<<<<<<<<
 *         cdef int y = pos[1]
 *         cdef int w = size[0]
 */
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_pos, 0, sizeof(long), PyInt_FromLong, 0, 0, 1); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_4); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_x = __pyx_t_10;

  /* "kivy\graphics\texture.pyx":843
 *         cdef int datasize = len(pbuffer)
 *         cdef int x = pos[0]
 *         cdef int y = pos[1]             # <<<<<<<<<<<<<<
 *         cdef int w = size[0]
 *         cdef int h = size[1]
 */
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_pos, 1, sizeof(long), PyInt_FromLong, 0, 0, 1); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_4); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_y = __pyx_t_10;

  /* "kivy\graphics\texture.pyx":844
 *         cdef int x = pos[0]
 *         cdef int y = pos[1]
 *         cdef int w = size[0]             # <<<<<<<<<<<<<<
 *         cdef int h = size[1]
 *         cdef char *cdata = <char *>data
 */
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_size, 0, sizeof(long), PyInt_FromLong, 0, 0, 1); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_4); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_w = __pyx_t_10;

  /* "kivy\graphics\texture.pyx":845
 *         cdef int y = pos[1]
 *         cdef int w = size[0]
 *         cdef int h = size[1]             # <<<<<<<<<<<<<<
 *         cdef char *cdata = <char *>data
 *         cdef int glbufferfmt = bufferfmt
 */
  __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_size, 1, sizeof(long), PyInt_FromLong, 0, 0, 1); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_4); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_h = __pyx_t_10;

  /* "kivy\graphics\texture.pyx":846
 *         cdef int w = size[0]
 *         cdef int h = size[1]
 *         cdef char *cdata = <char *>data             # <<<<<<<<<<<<<<
 *         cdef int glbufferfmt = bufferfmt
 *         cdef int is_allocated = self._is_allocated
 */
  __pyx_t_11 = __Pyx_PyObject_AsString(((PyObject *)__pyx_v_data)); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_cdata = ((char *)__pyx_t_11);

  /* "kivy\graphics\texture.pyx":847
 *         cdef int h = size[1]
 *         cdef char *cdata = <char *>data
 *         cdef int glbufferfmt = bufferfmt             # <<<<<<<<<<<<<<
 *         cdef int is_allocated = self._is_allocated
 *         cdef int is_compressed = _is_compressed_fmt(colorfmt)
 */
  __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_v_bufferfmt); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_glbufferfmt = __pyx_t_10;

  /* "kivy\graphics\texture.pyx":848
 *         cdef char *cdata = <char *>data
 *         cdef int glbufferfmt = bufferfmt
 *         cdef int is_allocated = self._is_allocated             # <<<<<<<<<<<<<<
 *         cdef int is_compressed = _is_compressed_fmt(colorfmt)
 *         cdef int _mipmap_generation = mipmap_generation and self._mipmap
 */
  __pyx_t_10 = __pyx_v_self->_is_allocated;
  __pyx_v_is_allocated = __pyx_t_10;

  /* "kivy\graphics\texture.pyx":849
 *         cdef int glbufferfmt = bufferfmt
 *         cdef int is_allocated = self._is_allocated
 *         cdef int is_compressed = _is_compressed_fmt(colorfmt)             # <<<<<<<<<<<<<<
 *         cdef int _mipmap_generation = mipmap_generation and self._mipmap
 *         cdef int _mipmap_level = mipmap_level
 */
  if (!(likely(PyString_CheckExact(__pyx_v_colorfmt))||((__pyx_v_colorfmt) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_v_colorfmt)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_is_compressed = __pyx_f_4kivy_8graphics_7texture__is_compressed_fmt(((PyObject*)__pyx_v_colorfmt));

  /* "kivy\graphics\texture.pyx":850
 *         cdef int is_allocated = self._is_allocated
 *         cdef int is_compressed = _is_compressed_fmt(colorfmt)
 *         cdef int _mipmap_generation = mipmap_generation and self._mipmap             # <<<<<<<<<<<<<<
 *         cdef int _mipmap_level = mipmap_level
 * 
 */
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_mipmap_generation); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_2) {
    __pyx_t_4 = PyInt_FromLong(__pyx_v_self->_mipmap); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = __pyx_t_4;
    __pyx_t_4 = 0;
  } else {
    __Pyx_INCREF(__pyx_v_mipmap_generation);
    __pyx_t_6 = __pyx_v_mipmap_generation;
  }
  __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_v__mipmap_generation = __pyx_t_10;

  /* "kivy\graphics\texture.pyx":851
 *         cdef int is_compressed = _is_compressed_fmt(colorfmt)
 *         cdef int _mipmap_generation = mipmap_generation and self._mipmap
 *         cdef int _mipmap_level = mipmap_level             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
  __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_v_mipmap_level); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v__mipmap_level = __pyx_t_10;

  /* "kivy\graphics\texture.pyx":853
 *         cdef int _mipmap_level = mipmap_level
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             if is_compressed:
 *                 glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
 */
  {
      #ifdef WITH_THREAD
      PyThreadState *_save;
      Py_UNBLOCK_THREADS
      #endif
      /*try:*/ {

        /* "kivy\graphics\texture.pyx":854
 * 
 *         with nogil:
 *             if is_compressed:             # <<<<<<<<<<<<<<
 *                 glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
 *                 glCompressedTexImage2D(target, _mipmap_level, glfmt, w, h, 0, datasize, cdata)
 */
        __pyx_t_2 = (__pyx_v_is_compressed != 0);
        if (__pyx_t_2) {

          /* "kivy\graphics\texture.pyx":855
 *         with nogil:
 *             if is_compressed:
 *                 glPixelStorei(GL_UNPACK_ALIGNMENT, 1)             # <<<<<<<<<<<<<<
 *                 glCompressedTexImage2D(target, _mipmap_level, glfmt, w, h, 0, datasize, cdata)
 *             elif is_allocated:
 */
          glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

          /* "kivy\graphics\texture.pyx":856
 *             if is_compressed:
 *                 glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
 *                 glCompressedTexImage2D(target, _mipmap_level, glfmt, w, h, 0, datasize, cdata)             # <<<<<<<<<<<<<<
 *             elif is_allocated:
 *                 _gl_prepare_pixels_upload(w)
 */
          glCompressedTexImage2D(__pyx_v_target, __pyx_v__mipmap_level, __pyx_v_glfmt, __pyx_v_w, __pyx_v_h, 0, __pyx_v_datasize, __pyx_v_cdata);
          goto __pyx_L12;
        }

        /* "kivy\graphics\texture.pyx":857
 *                 glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
 *                 glCompressedTexImage2D(target, _mipmap_level, glfmt, w, h, 0, datasize, cdata)
 *             elif is_allocated:             # <<<<<<<<<<<<<<
 *                 _gl_prepare_pixels_upload(w)
 *                 glTexSubImage2D(target, _mipmap_level, x, y, w, h, glfmt, glbufferfmt, cdata)
 */
        __pyx_t_2 = (__pyx_v_is_allocated != 0);
        if (__pyx_t_2) {

          /* "kivy\graphics\texture.pyx":858
 *                 glCompressedTexImage2D(target, _mipmap_level, glfmt, w, h, 0, datasize, cdata)
 *             elif is_allocated:
 *                 _gl_prepare_pixels_upload(w)             # <<<<<<<<<<<<<<
 *                 glTexSubImage2D(target, _mipmap_level, x, y, w, h, glfmt, glbufferfmt, cdata)
 *             else:
 */
          __pyx_f_4kivy_8graphics_7texture__gl_prepare_pixels_upload(__pyx_v_w);

          /* "kivy\graphics\texture.pyx":859
 *             elif is_allocated:
 *                 _gl_prepare_pixels_upload(w)
 *                 glTexSubImage2D(target, _mipmap_level, x, y, w, h, glfmt, glbufferfmt, cdata)             # <<<<<<<<<<<<<<
 *             else:
 *                 _gl_prepare_pixels_upload(w)
 */
          glTexSubImage2D(__pyx_v_target, __pyx_v__mipmap_level, __pyx_v_x, __pyx_v_y, __pyx_v_w, __pyx_v_h, __pyx_v_glfmt, __pyx_v_glbufferfmt, __pyx_v_cdata);
          goto __pyx_L12;
        }
        /*else*/ {

          /* "kivy\graphics\texture.pyx":861
 *                 glTexSubImage2D(target, _mipmap_level, x, y, w, h, glfmt, glbufferfmt, cdata)
 *             else:
 *                 _gl_prepare_pixels_upload(w)             # <<<<<<<<<<<<<<
 *                 glTexImage2D(target, _mipmap_level, iglfmt, w, h, 0, glfmt, glbufferfmt, cdata)
 *             if _mipmap_generation:
 */
          __pyx_f_4kivy_8graphics_7texture__gl_prepare_pixels_upload(__pyx_v_w);

          /* "kivy\graphics\texture.pyx":862
 *             else:
 *                 _gl_prepare_pixels_upload(w)
 *                 glTexImage2D(target, _mipmap_level, iglfmt, w, h, 0, glfmt, glbufferfmt, cdata)             # <<<<<<<<<<<<<<
 *             if _mipmap_generation:
 *                 glGenerateMipmap(target)
 */
          glTexImage2D(__pyx_v_target, __pyx_v__mipmap_level, __pyx_v_iglfmt, __pyx_v_w, __pyx_v_h, 0, __pyx_v_glfmt, __pyx_v_glbufferfmt, __pyx_v_cdata);
        }
        __pyx_L12:;

        /* "kivy\graphics\texture.pyx":863
 *                 _gl_prepare_pixels_upload(w)
 *                 glTexImage2D(target, _mipmap_level, iglfmt, w, h, 0, glfmt, glbufferfmt, cdata)
 *             if _mipmap_generation:             # <<<<<<<<<<<<<<
 *                 glGenerateMipmap(target)
 * 
 */
        __pyx_t_2 = (__pyx_v__mipmap_generation != 0);
        if (__pyx_t_2) {

          /* "kivy\graphics\texture.pyx":864
 *                 glTexImage2D(target, _mipmap_level, iglfmt, w, h, 0, glfmt, glbufferfmt, cdata)
 *             if _mipmap_generation:
 *                 glGenerateMipmap(target)             # <<<<<<<<<<<<<<
 * 
 *     def _on_proxyimage_loaded(self, image):
 */
          glGenerateMipmap(__pyx_v_target);
          goto __pyx_L13;
        }
        __pyx_L13:;
      }

      /* "kivy\graphics\texture.pyx":853
 *         cdef int _mipmap_level = mipmap_level
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             if is_compressed:
 *                 glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
 */
      /*finally:*/ {
        #ifdef WITH_THREAD
        Py_BLOCK_THREADS
        #endif
      }
  }

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.blit_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_data);
  __Pyx_XDECREF(__pyx_v_size);
  __Pyx_XDECREF(__pyx_v_colorfmt);
  __Pyx_XDECREF(__pyx_v_pos);
  __Pyx_XDECREF(__pyx_v_bufferfmt);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_21_on_proxyimage_loaded(PyObject *__pyx_v_self, PyObject *__pyx_v_image); /*proto*/
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_21_on_proxyimage_loaded(PyObject *__pyx_v_self, PyObject *__pyx_v_image) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_on_proxyimage_loaded (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_20_on_proxyimage_loaded(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), ((PyObject *)__pyx_v_image));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":866
 *                 glGenerateMipmap(target)
 * 
 *     def _on_proxyimage_loaded(self, image):             # <<<<<<<<<<<<<<
 *         if image is not self._proxyimage:
 *             return
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_20_on_proxyimage_loaded(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_image) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_on_proxyimage_loaded", 0);

  /* "kivy\graphics\texture.pyx":867
 * 
 *     def _on_proxyimage_loaded(self, image):
 *         if image is not self._proxyimage:             # <<<<<<<<<<<<<<
 *             return
 *         self._reload_propagate(image.image.texture)
 */
  __pyx_t_1 = (__pyx_v_image != __pyx_v_self->_proxyimage);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "kivy\graphics\texture.pyx":868
 *     def _on_proxyimage_loaded(self, image):
 *         if image is not self._proxyimage:
 *             return             # <<<<<<<<<<<<<<
 *         self._reload_propagate(image.image.texture)
 *         self._proxyimage = None
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "kivy\graphics\texture.pyx":869
 *         if image is not self._proxyimage:
 *             return
 *         self._reload_propagate(image.image.texture)             # <<<<<<<<<<<<<<
 *         self._proxyimage = None
 * 
 */
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s__image); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s__texture); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_4kivy_8graphics_7texture_Texture))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_self->__pyx_vtab)->_reload_propagate(__pyx_v_self, ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_t_4));
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":870
 *             return
 *         self._reload_propagate(image.image.texture)
 *         self._proxyimage = None             # <<<<<<<<<<<<<<
 * 
 *         # the texture might impact something on the drawing, so ask to refresh
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GIVEREF(Py_None);
  __Pyx_GOTREF(__pyx_v_self->_proxyimage);
  __Pyx_DECREF(__pyx_v_self->_proxyimage);
  __pyx_v_self->_proxyimage = Py_None;

  /* "kivy\graphics\texture.pyx":875
 *         # the window.
 *         # FIXME: the texture used in BindTexture should ask for a retrigger
 *         get_context().flag_update_canvas()             # <<<<<<<<<<<<<<
 * 
 *     cdef void reload(self):
 */
  __pyx_t_4 = ((PyObject *)__pyx_f_4kivy_8graphics_7context_get_context(0)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s__flag_update_canvas); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture._on_proxyimage_loaded", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":877
 *         get_context().flag_update_canvas()
 * 
 *     cdef void reload(self):             # <<<<<<<<<<<<<<
 *         cdef Texture texture
 *         if self._id != -1:
 */

static void __pyx_f_4kivy_8graphics_7texture_7Texture_reload(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_texture = 0;
  PyObject *__pyx_v_source = NULL;
  PyObject *__pyx_v_proto = NULL;
  PyObject *__pyx_v_Loader = NULL;
  PyObject *__pyx_v_Image = NULL;
  PyObject *__pyx_v_image = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("reload", 0);

  /* "kivy\graphics\texture.pyx":879
 *     cdef void reload(self):
 *         cdef Texture texture
 *         if self._id != -1:             # <<<<<<<<<<<<<<
 *             return
 *         if self._source is None:
 */
  __pyx_t_1 = ((__pyx_v_self->_id != -1) != 0);
  if (__pyx_t_1) {

    /* "kivy\graphics\texture.pyx":880
 *         cdef Texture texture
 *         if self._id != -1:
 *             return             # <<<<<<<<<<<<<<
 *         if self._source is None:
 *             # manual texture recreation
 */
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "kivy\graphics\texture.pyx":881
 *         if self._id != -1:
 *             return
 *         if self._source is None:             # <<<<<<<<<<<<<<
 *             # manual texture recreation
 *             texture = texture_create(self.size, self.colorfmt, self.bufferfmt,
 */
  __pyx_t_1 = (__pyx_v_self->_source == Py_None);
  __pyx_t_2 = (__pyx_t_1 != 0);
  if (__pyx_t_2) {

    /* "kivy\graphics\texture.pyx":883
 *         if self._source is None:
 *             # manual texture recreation
 *             texture = texture_create(self.size, self.colorfmt, self.bufferfmt,             # <<<<<<<<<<<<<<
 *                     self.mipmap)
 *         else:
 */
    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s__texture_create); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__colorfmt); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__bufferfmt); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);

    /* "kivy\graphics\texture.pyx":884
 *             # manual texture recreation
 *             texture = texture_create(self.size, self.colorfmt, self.bufferfmt,
 *                     self.mipmap)             # <<<<<<<<<<<<<<
 *         else:
 *             source = self._source
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__mipmap); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_7);
    __pyx_t_4 = 0;
    __pyx_t_5 = 0;
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_7 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
    if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_4kivy_8graphics_7texture_Texture))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_texture = ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_t_7);
    __pyx_t_7 = 0;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "kivy\graphics\texture.pyx":886
 *                     self.mipmap)
 *         else:
 *             source = self._source             # <<<<<<<<<<<<<<
 *             proto = source.split(':', 1)[0]
 *             if proto in ('http', 'https', 'ftp', 'smb'):
 */
    __pyx_t_7 = __pyx_v_self->_source;
    __Pyx_INCREF(__pyx_t_7);
    __pyx_v_source = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "kivy\graphics\texture.pyx":887
 *         else:
 *             source = self._source
 *             proto = source.split(':', 1)[0]             # <<<<<<<<<<<<<<
 *             if proto in ('http', 'https', 'ftp', 'smb'):
 *                 from kivy.loader import Loader
 */
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_source, __pyx_n_s__split); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_k_tuple_25), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_8, 0, sizeof(long), PyInt_FromLong, 0, 0, 1); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_v_proto = __pyx_t_7;
    __pyx_t_7 = 0;

    /* "kivy\graphics\texture.pyx":888
 *             source = self._source
 *             proto = source.split(':', 1)[0]
 *             if proto in ('http', 'https', 'ftp', 'smb'):             # <<<<<<<<<<<<<<
 *                 from kivy.loader import Loader
 *                 self._proxyimage = Loader.image(source)
 */
    __Pyx_INCREF(__pyx_v_proto);
    __pyx_t_7 = __pyx_v_proto;
    __pyx_t_8 = PyObject_RichCompare(__pyx_t_7, ((PyObject *)__pyx_n_s__http), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (!((int)__pyx_t_2)) {
      __pyx_t_8 = PyObject_RichCompare(__pyx_t_7, ((PyObject *)__pyx_n_s__https), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_9 = ((int)__pyx_t_1);
    } else {
      __pyx_t_9 = ((int)__pyx_t_2);
    }
    if (!__pyx_t_9) {
      __pyx_t_8 = PyObject_RichCompare(__pyx_t_7, ((PyObject *)__pyx_n_s__ftp), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_1 = ((int)__pyx_t_2);
    } else {
      __pyx_t_1 = __pyx_t_9;
    }
    if (!__pyx_t_1) {
      __pyx_t_8 = PyObject_RichCompare(__pyx_t_7, ((PyObject *)__pyx_n_s__smb), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_2 = ((int)__pyx_t_9);
    } else {
      __pyx_t_2 = __pyx_t_1;
    }
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_1 = (__pyx_t_2 != 0);
    if (__pyx_t_1) {

      /* "kivy\graphics\texture.pyx":889
 *             proto = source.split(':', 1)[0]
 *             if proto in ('http', 'https', 'ftp', 'smb'):
 *                 from kivy.loader import Loader             # <<<<<<<<<<<<<<
 *                 self._proxyimage = Loader.image(source)
 *                 self._id = 0 # FIXME this will point to an invalid texture ...
 */
      __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(((PyObject *)__pyx_n_s__Loader));
      PyList_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_n_s__Loader));
      __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Loader));
      __pyx_t_8 = __Pyx_Import(((PyObject *)__pyx_n_s_26), ((PyObject *)__pyx_t_7), -1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_8, __pyx_n_s__Loader); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_7);
      __pyx_v_Loader = __pyx_t_7;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "kivy\graphics\texture.pyx":890
 *             if proto in ('http', 'https', 'ftp', 'smb'):
 *                 from kivy.loader import Loader
 *                 self._proxyimage = Loader.image(source)             # <<<<<<<<<<<<<<
 *                 self._id = 0 # FIXME this will point to an invalid texture ...
 *                 self._proxyimage.bind(on_load=self._on_proxyimage_loaded)
 */
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_Loader, __pyx_n_s__image); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_v_source);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_source);
      __Pyx_GIVEREF(__pyx_v_source);
      __pyx_t_3 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 890; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
      __Pyx_GIVEREF(__pyx_t_3);
      __Pyx_GOTREF(__pyx_v_self->_proxyimage);
      __Pyx_DECREF(__pyx_v_self->_proxyimage);
      __pyx_v_self->_proxyimage = __pyx_t_3;
      __pyx_t_3 = 0;

      /* "kivy\graphics\texture.pyx":891
 *                 from kivy.loader import Loader
 *                 self._proxyimage = Loader.image(source)
 *                 self._id = 0 # FIXME this will point to an invalid texture ...             # <<<<<<<<<<<<<<
 *                 self._proxyimage.bind(on_load=self._on_proxyimage_loaded)
 *                 if self._proxyimage.loaded:
 */
      __pyx_v_self->_id = 0;

      /* "kivy\graphics\texture.pyx":892
 *                 self._proxyimage = Loader.image(source)
 *                 self._id = 0 # FIXME this will point to an invalid texture ...
 *                 self._proxyimage.bind(on_load=self._on_proxyimage_loaded)             # <<<<<<<<<<<<<<
 *                 if self._proxyimage.loaded:
 *                     self._on_proxyimage_loaded(self._proxyimage)
 */
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_proxyimage, __pyx_n_s__bind); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_7));
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_27); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__on_load), __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

      /* "kivy\graphics\texture.pyx":893
 *                 self._id = 0 # FIXME this will point to an invalid texture ...
 *                 self._proxyimage.bind(on_load=self._on_proxyimage_loaded)
 *                 if self._proxyimage.loaded:             # <<<<<<<<<<<<<<
 *                     self._on_proxyimage_loaded(self._proxyimage)
 *                 return
 */
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_proxyimage, __pyx_n_s__loaded); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (__pyx_t_1) {

        /* "kivy\graphics\texture.pyx":894
 *                 self._proxyimage.bind(on_load=self._on_proxyimage_loaded)
 *                 if self._proxyimage.loaded:
 *                     self._on_proxyimage_loaded(self._proxyimage)             # <<<<<<<<<<<<<<
 *                 return
 *             else:
 */
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_27); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_INCREF(__pyx_v_self->_proxyimage);
        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_self->_proxyimage);
        __Pyx_GIVEREF(__pyx_v_self->_proxyimage);
        __pyx_t_3 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        goto __pyx_L6;
      }
      __pyx_L6:;

      /* "kivy\graphics\texture.pyx":895
 *                 if self._proxyimage.loaded:
 *                     self._on_proxyimage_loaded(self._proxyimage)
 *                 return             # <<<<<<<<<<<<<<
 *             else:
 *                 from kivy.core.image import Image
 */
      goto __pyx_L0;
      goto __pyx_L5;
    }
    /*else*/ {

      /* "kivy\graphics\texture.pyx":897
 *                 return
 *             else:
 *                 from kivy.core.image import Image             # <<<<<<<<<<<<<<
 *                 image = Image(self._source, nocache=True)
 *                 texture = image.texture
 */
      __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(((PyObject *)__pyx_n_s__Image));
      PyList_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__Image));
      __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Image));
      __pyx_t_7 = __Pyx_Import(((PyObject *)__pyx_n_s_28), ((PyObject *)__pyx_t_3), -1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_7, __pyx_n_s__Image); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_3);
      __pyx_v_Image = __pyx_t_3;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "kivy\graphics\texture.pyx":898
 *             else:
 *                 from kivy.core.image import Image
 *                 image = Image(self._source, nocache=True)             # <<<<<<<<<<<<<<
 *                 texture = image.texture
 * 
 */
      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 898; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_v_self->_source);
      PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_self->_source);
      __Pyx_GIVEREF(__pyx_v_self->_source);
      __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 898; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      __pyx_t_8 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 898; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__nocache), __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 898; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyObject_Call(__pyx_v_Image, ((PyObject *)__pyx_t_7), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 898; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __pyx_v_image = __pyx_t_8;
      __pyx_t_8 = 0;

      /* "kivy\graphics\texture.pyx":899
 *                 from kivy.core.image import Image
 *                 image = Image(self._source, nocache=True)
 *                 texture = image.texture             # <<<<<<<<<<<<<<
 * 
 *         self._reload_propagate(texture)
 */
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_image, __pyx_n_s__texture); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_4kivy_8graphics_7texture_Texture))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_v_texture = ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_t_8);
      __pyx_t_8 = 0;
    }
    __pyx_L5:;
  }
  __pyx_L4:;

  /* "kivy\graphics\texture.pyx":901
 *                 texture = image.texture
 * 
 *         self._reload_propagate(texture)             # <<<<<<<<<<<<<<
 * 
 *     cdef void _reload_propagate(self, Texture texture):
 */
  ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_self->__pyx_vtab)->_reload_propagate(__pyx_v_self, __pyx_v_texture);

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_WriteUnraisable("kivy.graphics.texture.Texture.reload", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_texture);
  __Pyx_XDECREF(__pyx_v_source);
  __Pyx_XDECREF(__pyx_v_proto);
  __Pyx_XDECREF(__pyx_v_Loader);
  __Pyx_XDECREF(__pyx_v_Image);
  __Pyx_XDECREF(__pyx_v_image);
  __Pyx_RefNannyFinishContext();
}

/* "kivy\graphics\texture.pyx":903
 *         self._reload_propagate(texture)
 * 
 *     cdef void _reload_propagate(self, Texture texture):             # <<<<<<<<<<<<<<
 * 
 *         # ensure the new opengl ID will not get through GC
 */

static void __pyx_f_4kivy_8graphics_7texture_7Texture__reload_propagate(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_texture) {
  PyObject *__pyx_v_callback = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  GLuint __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_reload_propagate", 0);

  /* "kivy\graphics\texture.pyx":906
 * 
 *         # ensure the new opengl ID will not get through GC
 *         texture.bind()             # <<<<<<<<<<<<<<
 *         self._id = texture.id
 *         texture._nofree = 1
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_texture->__pyx_vtab)->bind(__pyx_v_texture, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "kivy\graphics\texture.pyx":907
 *         # ensure the new opengl ID will not get through GC
 *         texture.bind()
 *         self._id = texture.id             # <<<<<<<<<<<<<<
 *         texture._nofree = 1
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_texture), __pyx_n_s__id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_from_py_GLuint(__pyx_t_1); if (unlikely((__pyx_t_2 == (GLuint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->_id = __pyx_t_2;

  /* "kivy\graphics\texture.pyx":908
 *         texture.bind()
 *         self._id = texture.id
 *         texture._nofree = 1             # <<<<<<<<<<<<<<
 * 
 *         # set the same parameters as our current texture
 */
  __pyx_v_texture->_nofree = 1;

  /* "kivy\graphics\texture.pyx":911
 * 
 *         # set the same parameters as our current texture
 *         texture.set_wrap(self.wrap)             # <<<<<<<<<<<<<<
 *         texture.set_min_filter(self.min_filter)
 *         texture.set_mag_filter(self.mag_filter)
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__wrap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_texture->__pyx_vtab)->set_wrap(__pyx_v_texture, ((PyObject*)__pyx_t_1));
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "kivy\graphics\texture.pyx":912
 *         # set the same parameters as our current texture
 *         texture.set_wrap(self.wrap)
 *         texture.set_min_filter(self.min_filter)             # <<<<<<<<<<<<<<
 *         texture.set_mag_filter(self.mag_filter)
 * 
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__min_filter); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_texture->__pyx_vtab)->set_min_filter(__pyx_v_texture, ((PyObject*)__pyx_t_1));
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "kivy\graphics\texture.pyx":913
 *         texture.set_wrap(self.wrap)
 *         texture.set_min_filter(self.min_filter)
 *         texture.set_mag_filter(self.mag_filter)             # <<<<<<<<<<<<<<
 * 
 *         # then update content again
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__mag_filter); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 913; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 913; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_texture->__pyx_vtab)->set_mag_filter(__pyx_v_texture, ((PyObject*)__pyx_t_1));
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "kivy\graphics\texture.pyx":916
 * 
 *         # then update content again
 *         for callback in self.observers[:]:             # <<<<<<<<<<<<<<
 *             if callback.is_dead():
 *                 self.observers.remove(callback)
 */
  if (unlikely(((PyObject *)__pyx_v_self->observers) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_PyList_GetSlice(((PyObject *)__pyx_v_self->observers), 0, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (unlikely(((PyObject *)__pyx_t_1) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = ((PyObject *)__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  for (;;) {
    if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #endif
    __Pyx_XDECREF(__pyx_v_callback);
    __pyx_v_callback = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "kivy\graphics\texture.pyx":917
 *         # then update content again
 *         for callback in self.observers[:]:
 *             if callback.is_dead():             # <<<<<<<<<<<<<<
 *                 self.observers.remove(callback)
 *                 continue
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_callback, __pyx_n_s__is_dead); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_6) {

      /* "kivy\graphics\texture.pyx":918
 *         for callback in self.observers[:]:
 *             if callback.is_dead():
 *                 self.observers.remove(callback)             # <<<<<<<<<<<<<<
 *                 continue
 *             callback()(self)
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->observers), __pyx_n_s__remove); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_v_callback);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_callback);
      __Pyx_GIVEREF(__pyx_v_callback);
      __pyx_t_7 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "kivy\graphics\texture.pyx":919
 *             if callback.is_dead():
 *                 self.observers.remove(callback)
 *                 continue             # <<<<<<<<<<<<<<
 *             callback()(self)
 * 
 */
      goto __pyx_L3_continue;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "kivy\graphics\texture.pyx":920
 *                 self.observers.remove(callback)
 *                 continue
 *             callback()(self)             # <<<<<<<<<<<<<<
 * 
 *     def save(self, filename):
 */
    __pyx_t_7 = PyObject_Call(__pyx_v_callback, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    __pyx_t_5 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_L3_continue:;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_WriteUnraisable("kivy.graphics.texture.Texture._reload_propagate", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_callback);
  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_23save(PyObject *__pyx_v_self, PyObject *__pyx_v_filename); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_7Texture_22save[] = "Save the texture content into a file. Check\n        :meth:`kivy.core.image.Image.save` for more information about the usage.\n\n        .. versionadded:: 1.7.0\n        ";
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_23save(PyObject *__pyx_v_self, PyObject *__pyx_v_filename) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("save (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_22save(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), ((PyObject *)__pyx_v_filename));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":922
 *             callback()(self)
 * 
 *     def save(self, filename):             # <<<<<<<<<<<<<<
 *         '''Save the texture content into a file. Check
 *         :meth:`kivy.core.image.Image.save` for more information about the usage.
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_22save(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_filename) {
  PyObject *__pyx_v_Image = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("save", 0);

  /* "kivy\graphics\texture.pyx":928
 *         .. versionadded:: 1.7.0
 *         '''
 *         from kivy.core.image import Image             # <<<<<<<<<<<<<<
 *         return Image(self).save(filename)
 * 
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__Image));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__Image));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Image));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s_28), ((PyObject *)__pyx_t_1), -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s__Image); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_Image = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "kivy\graphics\texture.pyx":929
 *         '''
 *         from kivy.core.image import Image
 *         return Image(self).save(filename)             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_1 = PyObject_Call(__pyx_v_Image, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__save); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_filename);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_filename);
  __Pyx_GIVEREF(__pyx_v_filename);
  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.save", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_Image);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_25__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_25__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_24__repr__(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":931
 *         return Image(self).save(filename)
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return '<Texture hash=%r id=%d size=%r colorfmt=%r bufferfmt=%r source=%r observers=%d>' % (
 *             id(self), self._id, self.size, self.colorfmt, self.bufferfmt,
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_24__repr__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "kivy\graphics\texture.pyx":932
 * 
 *     def __repr__(self):
 *         return '<Texture hash=%r id=%d size=%r colorfmt=%r bufferfmt=%r source=%r observers=%d>' % (             # <<<<<<<<<<<<<<
 *             id(self), self._id, self.size, self.colorfmt, self.bufferfmt,
 *             self._source, len(self.observers))
 */
  __Pyx_XDECREF(__pyx_r);

  /* "kivy\graphics\texture.pyx":933
 *     def __repr__(self):
 *         return '<Texture hash=%r id=%d size=%r colorfmt=%r bufferfmt=%r source=%r observers=%d>' % (
 *             id(self), self._id, self.size, self.colorfmt, self.bufferfmt,             # <<<<<<<<<<<<<<
 *             self._source, len(self.observers))
 * 
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = PyObject_Call(__pyx_builtin_id, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_to_py_GLuint(__pyx_v_self->_id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__colorfmt); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__bufferfmt); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "kivy\graphics\texture.pyx":934
 *         return '<Texture hash=%r id=%d size=%r colorfmt=%r bufferfmt=%r source=%r observers=%d>' % (
 *             id(self), self._id, self.size, self.colorfmt, self.bufferfmt,
 *             self._source, len(self.observers))             # <<<<<<<<<<<<<<
 * 
 *     property size:
 */
  __pyx_t_6 = ((PyObject *)__pyx_v_self->observers);
  __Pyx_INCREF(__pyx_t_6);
  if (unlikely(__pyx_t_6 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_7 = PyList_GET_SIZE(__pyx_t_6); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = PyTuple_New(7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_8, 4, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_self->_source);
  PyTuple_SET_ITEM(__pyx_t_8, 5, __pyx_v_self->_source);
  __Pyx_GIVEREF(__pyx_v_self->_source);
  PyTuple_SET_ITEM(__pyx_t_8, 6, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_29), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));
  __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
  __pyx_r = ((PyObject *)__pyx_t_6);
  __pyx_t_6 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_4size_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_4size_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_4size___get__(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":939
 *         '''Return the (width, height) of the texture (readonly)
 *         '''
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return (self.width, self.height)
 * 
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_4size___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "kivy\graphics\texture.pyx":940
 *         '''
 *         def __get__(self):
 *             return (self.width, self.height)             # <<<<<<<<<<<<<<
 * 
 *     property mipmap:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__width); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__height); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_r = ((PyObject *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_6mipmap_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_6mipmap_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_6mipmap___get__(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":945
 *         '''Return True if the texture have mipmap enabled (readonly)
 *         '''
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._mipmap
 * 
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6mipmap___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "kivy\graphics\texture.pyx":946
 *         '''
 *         def __get__(self):
 *             return self._mipmap             # <<<<<<<<<<<<<<
 * 
 *     property id:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->_mipmap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.mipmap.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_2id_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_2id_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_2id___get__(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":951
 *         '''Return the OpenGL ID of the texture (readonly)
 *         '''
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._id
 * 
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_2id___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "kivy\graphics\texture.pyx":952
 *         '''
 *         def __get__(self):
 *             return self._id             # <<<<<<<<<<<<<<
 * 
 *     property target:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_GLuint(__pyx_v_self->_id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.id.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_6target_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_6target_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_6target___get__(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":957
 *         '''Return the OpenGL target of the texture (readonly)
 *         '''
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._target
 * 
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6target___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "kivy\graphics\texture.pyx":958
 *         '''
 *         def __get__(self):
 *             return self._target             # <<<<<<<<<<<<<<
 * 
 *     property width:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_GLuint(__pyx_v_self->_target); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 958; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.target.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_5width_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_5width_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_5width___get__(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":963
 *         '''Return the width of the texture (readonly)
 *         '''
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._width
 * 
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_5width___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "kivy\graphics\texture.pyx":964
 *         '''
 *         def __get__(self):
 *             return self._width             # <<<<<<<<<<<<<<
 * 
 *     property height:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->_width); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.width.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_6height_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_6height_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_6height___get__(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":969
 *         '''Return the height of the texture (readonly)
 *         '''
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._height
 * 
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6height___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "kivy\graphics\texture.pyx":970
 *         '''
 *         def __get__(self):
 *             return self._height             # <<<<<<<<<<<<<<
 * 
 *     property tex_coords:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->_height); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.height.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_10tex_coords_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_10tex_coords_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_10tex_coords___get__(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":975
 *         '''Return the list of tex_coords (opengl)
 *         '''
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return (
 *                 self._tex_coords[0],
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_10tex_coords___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "kivy\graphics\texture.pyx":976
 *         '''
 *         def __get__(self):
 *             return (             # <<<<<<<<<<<<<<
 *                 self._tex_coords[0],
 *                 self._tex_coords[1],
 */
  __Pyx_XDECREF(__pyx_r);

  /* "kivy\graphics\texture.pyx":977
 *         def __get__(self):
 *             return (
 *                 self._tex_coords[0],             # <<<<<<<<<<<<<<
 *                 self._tex_coords[1],
 *                 self._tex_coords[2],
 */
  __pyx_t_1 = PyFloat_FromDouble((__pyx_v_self->_tex_coords[0])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "kivy\graphics\texture.pyx":978
 *             return (
 *                 self._tex_coords[0],
 *                 self._tex_coords[1],             # <<<<<<<<<<<<<<
 *                 self._tex_coords[2],
 *                 self._tex_coords[3],
 */
  __pyx_t_2 = PyFloat_FromDouble((__pyx_v_self->_tex_coords[1])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "kivy\graphics\texture.pyx":979
 *                 self._tex_coords[0],
 *                 self._tex_coords[1],
 *                 self._tex_coords[2],             # <<<<<<<<<<<<<<
 *                 self._tex_coords[3],
 *                 self._tex_coords[4],
 */
  __pyx_t_3 = PyFloat_FromDouble((__pyx_v_self->_tex_coords[2])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "kivy\graphics\texture.pyx":980
 *                 self._tex_coords[1],
 *                 self._tex_coords[2],
 *                 self._tex_coords[3],             # <<<<<<<<<<<<<<
 *                 self._tex_coords[4],
 *                 self._tex_coords[5],
 */
  __pyx_t_4 = PyFloat_FromDouble((__pyx_v_self->_tex_coords[3])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "kivy\graphics\texture.pyx":981
 *                 self._tex_coords[2],
 *                 self._tex_coords[3],
 *                 self._tex_coords[4],             # <<<<<<<<<<<<<<
 *                 self._tex_coords[5],
 *                 self._tex_coords[6],
 */
  __pyx_t_5 = PyFloat_FromDouble((__pyx_v_self->_tex_coords[4])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 981; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "kivy\graphics\texture.pyx":982
 *                 self._tex_coords[3],
 *                 self._tex_coords[4],
 *                 self._tex_coords[5],             # <<<<<<<<<<<<<<
 *                 self._tex_coords[6],
 *                 self._tex_coords[7],
 */
  __pyx_t_6 = PyFloat_FromDouble((__pyx_v_self->_tex_coords[5])); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 982; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);

  /* "kivy\graphics\texture.pyx":983
 *                 self._tex_coords[4],
 *                 self._tex_coords[5],
 *                 self._tex_coords[6],             # <<<<<<<<<<<<<<
 *                 self._tex_coords[7],
 *             )
 */
  __pyx_t_7 = PyFloat_FromDouble((__pyx_v_self->_tex_coords[6])); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);

  /* "kivy\graphics\texture.pyx":984
 *                 self._tex_coords[5],
 *                 self._tex_coords[6],
 *                 self._tex_coords[7],             # <<<<<<<<<<<<<<
 *             )
 * 
 */
  __pyx_t_8 = PyFloat_FromDouble((__pyx_v_self->_tex_coords[7])); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = PyTuple_New(8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_9, 4, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_9, 5, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_9, 6, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_9, 7, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_7 = 0;
  __pyx_t_8 = 0;
  __pyx_r = ((PyObject *)__pyx_t_9);
  __pyx_t_9 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.tex_coords.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_5uvpos_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_5uvpos_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_5uvpos___get__(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":990
 *         '''Get/set the UV position inside texture
 *         '''
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return (self._uvx, self._uvy)
 *         def __set__(self, x):
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_5uvpos___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "kivy\graphics\texture.pyx":991
 *         '''
 *         def __get__(self):
 *             return (self._uvx, self._uvy)             # <<<<<<<<<<<<<<
 *         def __set__(self, x):
 *             self._uvx, self._uvy = x
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->_uvx); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 991; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->_uvy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 991; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 991; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_r = ((PyObject *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.uvpos.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4kivy_8graphics_7texture_7Texture_5uvpos_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_pw_4kivy_8graphics_7texture_7Texture_5uvpos_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_5uvpos_2__set__(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), ((PyObject *)__pyx_v_x));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":992
 *         def __get__(self):
 *             return (self._uvx, self._uvy)
 *         def __set__(self, x):             # <<<<<<<<<<<<<<
 *             self._uvx, self._uvy = x
 *             self.update_tex_coords()
 */

static int __pyx_pf_4kivy_8graphics_7texture_7Texture_5uvpos_2__set__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *(*__pyx_t_4)(PyObject *);
  float __pyx_t_5;
  float __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "kivy\graphics\texture.pyx":993
 *             return (self._uvx, self._uvy)
 *         def __set__(self, x):
 *             self._uvx, self._uvy = x             # <<<<<<<<<<<<<<
 *             self.update_tex_coords()
 * 
 */
  if ((likely(PyTuple_CheckExact(__pyx_v_x))) || (PyList_CheckExact(__pyx_v_x))) {
    PyObject* sequence = __pyx_v_x;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    #endif
  } else
  {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_v_x); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_2 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_4(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __pyx_t_5 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_5 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_6 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_self->_uvx = __pyx_t_5;
  __pyx_v_self->_uvy = __pyx_t_6;

  /* "kivy\graphics\texture.pyx":994
 *         def __set__(self, x):
 *             self._uvx, self._uvy = x
 *             self.update_tex_coords()             # <<<<<<<<<<<<<<
 * 
 *     property uvsize:
 */
  ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_self->__pyx_vtab)->update_tex_coords(__pyx_v_self);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.uvpos.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_6uvsize_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_6uvsize_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_6uvsize___get__(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":1002
 *             The size can be negative is the texture is flipped.
 *         '''
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return (self._uvw, self._uvh)
 *         def __set__(self, x):
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6uvsize___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "kivy\graphics\texture.pyx":1003
 *         '''
 *         def __get__(self):
 *             return (self._uvw, self._uvh)             # <<<<<<<<<<<<<<
 *         def __set__(self, x):
 *             self._uvw, self._uvh = x
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->_uvw); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->_uvh); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1003; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_r = ((PyObject *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.uvsize.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4kivy_8graphics_7texture_7Texture_6uvsize_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_pw_4kivy_8graphics_7texture_7Texture_6uvsize_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_6uvsize_2__set__(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), ((PyObject *)__pyx_v_x));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":1004
 *         def __get__(self):
 *             return (self._uvw, self._uvh)
 *         def __set__(self, x):             # <<<<<<<<<<<<<<
 *             self._uvw, self._uvh = x
 *             self.update_tex_coords()
 */

static int __pyx_pf_4kivy_8graphics_7texture_7Texture_6uvsize_2__set__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *(*__pyx_t_4)(PyObject *);
  float __pyx_t_5;
  float __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "kivy\graphics\texture.pyx":1005
 *             return (self._uvw, self._uvh)
 *         def __set__(self, x):
 *             self._uvw, self._uvh = x             # <<<<<<<<<<<<<<
 *             self.update_tex_coords()
 * 
 */
  if ((likely(PyTuple_CheckExact(__pyx_v_x))) || (PyList_CheckExact(__pyx_v_x))) {
    PyObject* sequence = __pyx_v_x;
    #if CYTHON_COMPILING_IN_CPYTHON
    Py_ssize_t size = Py_SIZE(sequence);
    #else
    Py_ssize_t size = PySequence_Size(sequence);
    #endif
    if (unlikely(size != 2)) {
      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    #if CYTHON_COMPILING_IN_CPYTHON
    if (likely(PyTuple_CheckExact(sequence))) {
      __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); 
    } else {
      __pyx_t_1 = PyList_GET_ITEM(sequence, 0); 
      __pyx_t_2 = PyList_GET_ITEM(sequence, 1); 
    }
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    #else
    __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    #endif
  } else
  {
    Py_ssize_t index = -1;
    __pyx_t_3 = PyObject_GetIter(__pyx_v_x); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext;
    index = 0; __pyx_t_1 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_1);
    index = 1; __pyx_t_2 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed;
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_IternextUnpackEndCheck(__pyx_t_4(__pyx_t_3), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_4 = NULL;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L4_unpacking_done;
    __pyx_L3_unpacking_failed:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_4 = NULL;
    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_L4_unpacking_done:;
  }
  __pyx_t_5 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_5 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __pyx_PyFloat_AsFloat(__pyx_t_2); if (unlikely((__pyx_t_6 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_self->_uvw = __pyx_t_5;
  __pyx_v_self->_uvh = __pyx_t_6;

  /* "kivy\graphics\texture.pyx":1006
 *         def __set__(self, x):
 *             self._uvw, self._uvh = x
 *             self.update_tex_coords()             # <<<<<<<<<<<<<<
 * 
 *     property colorfmt:
 */
  ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_self->__pyx_vtab)->update_tex_coords(__pyx_v_self);

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.uvsize.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_8colorfmt_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_8colorfmt_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_8colorfmt___get__(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":1013
 *         .. versionadded:: 1.0.7
 *         '''
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._colorfmt
 * 
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_8colorfmt___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "kivy\graphics\texture.pyx":1014
 *         '''
 *         def __get__(self):
 *             return self._colorfmt             # <<<<<<<<<<<<<<
 * 
 *     property bufferfmt:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->_colorfmt));
  __pyx_r = ((PyObject *)__pyx_v_self->_colorfmt);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_9bufferfmt_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_9bufferfmt_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_9bufferfmt___get__(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":1021
 *         .. versionadded:: 1.2.0
 *         '''
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._bufferfmt
 * 
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_9bufferfmt___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "kivy\graphics\texture.pyx":1022
 *         '''
 *         def __get__(self):
 *             return self._bufferfmt             # <<<<<<<<<<<<<<
 * 
 *     property min_filter:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->_bufferfmt));
  __pyx_r = ((PyObject *)__pyx_v_self->_bufferfmt);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_10min_filter_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_10min_filter_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_10min_filter___get__(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":1037
 *         theses values : http://www.khronos.org/opengles/sdk/docs/man/xhtml/glTexParameter.xml.
 *         '''
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._min_filter
 *         def __set__(self, str x):
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_10min_filter___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "kivy\graphics\texture.pyx":1038
 *         '''
 *         def __get__(self):
 *             return self._min_filter             # <<<<<<<<<<<<<<
 *         def __set__(self, str x):
 *             self.set_min_filter(x)
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->_min_filter));
  __pyx_r = ((PyObject *)__pyx_v_self->_min_filter);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4kivy_8graphics_7texture_7Texture_10min_filter_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_pw_4kivy_8graphics_7texture_7Texture_10min_filter_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), (&PyString_Type), 1, "x", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1039; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_10min_filter_2__set__(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), ((PyObject*)__pyx_v_x));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":1039
 *         def __get__(self):
 *             return self._min_filter
 *         def __set__(self, str x):             # <<<<<<<<<<<<<<
 *             self.set_min_filter(x)
 * 
 */

static int __pyx_pf_4kivy_8graphics_7texture_7Texture_10min_filter_2__set__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "kivy\graphics\texture.pyx":1040
 *             return self._min_filter
 *         def __set__(self, str x):
 *             self.set_min_filter(x)             # <<<<<<<<<<<<<<
 * 
 *     property mag_filter:
 */
  ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_self->__pyx_vtab)->set_min_filter(__pyx_v_self, __pyx_v_x);

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_10mag_filter_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_10mag_filter_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_10mag_filter___get__(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":1051
 *         theses values : http://www.khronos.org/opengles/sdk/docs/man/xhtml/glTexParameter.xml.
 *         '''
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._mag_filter
 *         def __set__(self, str x):
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_10mag_filter___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "kivy\graphics\texture.pyx":1052
 *         '''
 *         def __get__(self):
 *             return self._mag_filter             # <<<<<<<<<<<<<<
 *         def __set__(self, str x):
 *             self.set_mag_filter(x)
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->_mag_filter));
  __pyx_r = ((PyObject *)__pyx_v_self->_mag_filter);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4kivy_8graphics_7texture_7Texture_10mag_filter_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_pw_4kivy_8graphics_7texture_7Texture_10mag_filter_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), (&PyString_Type), 1, "x", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1053; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_10mag_filter_2__set__(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), ((PyObject*)__pyx_v_x));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":1053
 *         def __get__(self):
 *             return self._mag_filter
 *         def __set__(self, str x):             # <<<<<<<<<<<<<<
 *             self.set_mag_filter(x)
 * 
 */

static int __pyx_pf_4kivy_8graphics_7texture_7Texture_10mag_filter_2__set__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "kivy\graphics\texture.pyx":1054
 *             return self._mag_filter
 *         def __set__(self, str x):
 *             self.set_mag_filter(x)             # <<<<<<<<<<<<<<
 * 
 *     property wrap:
 */
  ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_self->__pyx_vtab)->set_mag_filter(__pyx_v_self, __pyx_v_x);

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_4wrap_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_4wrap_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_4wrap___get__(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":1066
 *         theses values : http://www.khronos.org/opengles/sdk/docs/man/xhtml/glTexParameter.xml.
 *         '''
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._wrap
 *         def __set__(self, str wrap):
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_4wrap___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "kivy\graphics\texture.pyx":1067
 *         '''
 *         def __get__(self):
 *             return self._wrap             # <<<<<<<<<<<<<<
 *         def __set__(self, str wrap):
 *             self.set_wrap(wrap)
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->_wrap));
  __pyx_r = ((PyObject *)__pyx_v_self->_wrap);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4kivy_8graphics_7texture_7Texture_4wrap_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_wrap); /*proto*/
static int __pyx_pw_4kivy_8graphics_7texture_7Texture_4wrap_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_wrap) {
  CYTHON_UNUSED int __pyx_lineno = 0;
  CYTHON_UNUSED const char *__pyx_filename = NULL;
  CYTHON_UNUSED int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_wrap), (&PyString_Type), 1, "wrap", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_4wrap_2__set__(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), ((PyObject*)__pyx_v_wrap));
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":1068
 *         def __get__(self):
 *             return self._wrap
 *         def __set__(self, str wrap):             # <<<<<<<<<<<<<<
 *             self.set_wrap(wrap)
 * 
 */

static int __pyx_pf_4kivy_8graphics_7texture_7Texture_4wrap_2__set__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_wrap) {
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__set__", 0);

  /* "kivy\graphics\texture.pyx":1069
 *             return self._wrap
 *         def __set__(self, str wrap):
 *             self.set_wrap(wrap)             # <<<<<<<<<<<<<<
 * 
 *     property pixels:
 */
  ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_self->__pyx_vtab)->set_wrap(__pyx_v_self, __pyx_v_wrap);

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_6pixels_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4kivy_8graphics_7texture_7Texture_6pixels_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_7Texture_6pixels___get__(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":1076
 *         .. versionadded:: 1.7.0
 *         '''
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             from kivy.graphics.fbo import Fbo
 *             return Fbo(size=self.size, texture=self).pixels
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6pixels___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  PyObject *__pyx_v_Fbo = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "kivy\graphics\texture.pyx":1077
 *         '''
 *         def __get__(self):
 *             from kivy.graphics.fbo import Fbo             # <<<<<<<<<<<<<<
 *             return Fbo(size=self.size, texture=self).pixels
 * 
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1077; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__Fbo));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__Fbo));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Fbo));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s_30), ((PyObject *)__pyx_t_1), -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1077; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s__Fbo); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1077; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_Fbo = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "kivy\graphics\texture.pyx":1078
 *         def __get__(self):
 *             from kivy.graphics.fbo import Fbo
 *             return Fbo(size=self.size, texture=self).pixels             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__size), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__texture), ((PyObject *)__pyx_v_self)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyObject_Call(__pyx_v_Fbo, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s__pixels); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.pixels.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_Fbo);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static int __pyx_pw_4kivy_8graphics_7texture_13TextureRegion_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4kivy_8graphics_7texture_13TextureRegion_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_v_x;
  int __pyx_v_y;
  int __pyx_v_width;
  int __pyx_v_height;
  struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_origin = 0;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__x,&__pyx_n_s__y,&__pyx_n_s__width,&__pyx_n_s__height,&__pyx_n_s__origin,0};
    PyObject* values[5] = {0,0,0,0,0};
    if (unlikely(__pyx_kwds)) {
      Py_ssize_t kw_args;
      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
      switch (pos_args) {
        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      kw_args = PyDict_Size(__pyx_kwds);
      switch (pos_args) {
        case  0:
        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x)) != 0)) kw_args--;
        else goto __pyx_L5_argtuple_error;
        case  1:
        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  2:
        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__width)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  3:
        if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__height)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
        case  4:
        if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__origin)) != 0)) kw_args--;
        else {
          __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
        }
      }
      if (unlikely(kw_args > 0)) {
        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
    }
    __pyx_v_x = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_x == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_y = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_y == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_width = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_width == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_height = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_height == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_origin = ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)values[4]);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("kivy.graphics.texture.TextureRegion.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_origin), __pyx_ptype_4kivy_8graphics_7texture_Texture, 1, "origin", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_13TextureRegion___init__(((struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)__pyx_v_self), __pyx_v_x, __pyx_v_y, __pyx_v_width, __pyx_v_height, __pyx_v_origin);
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":1085
 *     texture handling.'''
 * 
 *     def __init__(self, int x, int y, int width, int height, Texture origin):             # <<<<<<<<<<<<<<
 *         Texture.__init__(self, width, height, origin.target, origin.id)
 *         self._is_allocated = 1
 */

static int __pyx_pf_4kivy_8graphics_7texture_13TextureRegion___init__(struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *__pyx_v_self, int __pyx_v_x, int __pyx_v_y, int __pyx_v_width, int __pyx_v_height, struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_origin) {
  float __pyx_v_origin_u1;
  float __pyx_v_origin_v1;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  float __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "kivy\graphics\texture.pyx":1086
 * 
 *     def __init__(self, int x, int y, int width, int height, Texture origin):
 *         Texture.__init__(self, width, height, origin.target, origin.id)             # <<<<<<<<<<<<<<
 *         self._is_allocated = 1
 *         self._mipmap = origin._mipmap
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)((PyObject*)__pyx_ptype_4kivy_8graphics_7texture_Texture)), __pyx_n_s____init__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyInt_FromLong(__pyx_v_width); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyInt_FromLong(__pyx_v_height); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_origin), __pyx_n_s__target); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_origin), __pyx_n_s__id); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyTuple_New(5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":1087
 *     def __init__(self, int x, int y, int width, int height, Texture origin):
 *         Texture.__init__(self, width, height, origin.target, origin.id)
 *         self._is_allocated = 1             # <<<<<<<<<<<<<<
 *         self._mipmap = origin._mipmap
 *         self.x = x
 */
  __pyx_v_self->__pyx_base._is_allocated = 1;

  /* "kivy\graphics\texture.pyx":1088
 *         Texture.__init__(self, width, height, origin.target, origin.id)
 *         self._is_allocated = 1
 *         self._mipmap = origin._mipmap             # <<<<<<<<<<<<<<
 *         self.x = x
 *         self.y = y
 */
  __pyx_t_7 = __pyx_v_origin->_mipmap;
  __pyx_v_self->__pyx_base._mipmap = __pyx_t_7;

  /* "kivy\graphics\texture.pyx":1089
 *         self._is_allocated = 1
 *         self._mipmap = origin._mipmap
 *         self.x = x             # <<<<<<<<<<<<<<
 *         self.y = y
 *         self.owner = origin
 */
  __pyx_v_self->x = __pyx_v_x;

  /* "kivy\graphics\texture.pyx":1090
 *         self._mipmap = origin._mipmap
 *         self.x = x
 *         self.y = y             # <<<<<<<<<<<<<<
 *         self.owner = origin
 * 
 */
  __pyx_v_self->y = __pyx_v_y;

  /* "kivy\graphics\texture.pyx":1091
 *         self.x = x
 *         self.y = y
 *         self.owner = origin             # <<<<<<<<<<<<<<
 * 
 *         # recalculate texture coordinate
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_origin));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_origin));
  __Pyx_GOTREF(__pyx_v_self->owner);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->owner));
  __pyx_v_self->owner = __pyx_v_origin;

  /* "kivy\graphics\texture.pyx":1095
 *         # recalculate texture coordinate
 *         cdef float origin_u1, origin_v1
 *         origin_u1 = origin._uvx             # <<<<<<<<<<<<<<
 *         origin_v1 = origin._uvy
 *         self._uvx = (x / <float>origin._width) * origin._uvw + origin_u1
 */
  __pyx_t_8 = __pyx_v_origin->_uvx;
  __pyx_v_origin_u1 = __pyx_t_8;

  /* "kivy\graphics\texture.pyx":1096
 *         cdef float origin_u1, origin_v1
 *         origin_u1 = origin._uvx
 *         origin_v1 = origin._uvy             # <<<<<<<<<<<<<<
 *         self._uvx = (x / <float>origin._width) * origin._uvw + origin_u1
 *         self._uvy = (y / <float>origin._height) * origin._uvh + origin_v1
 */
  __pyx_t_8 = __pyx_v_origin->_uvy;
  __pyx_v_origin_v1 = __pyx_t_8;

  /* "kivy\graphics\texture.pyx":1097
 *         origin_u1 = origin._uvx
 *         origin_v1 = origin._uvy
 *         self._uvx = (x / <float>origin._width) * origin._uvw + origin_u1             # <<<<<<<<<<<<<<
 *         self._uvy = (y / <float>origin._height) * origin._uvh + origin_v1
 *         self._uvw = (width / <float>origin._width) * origin._uvw
 */
  if (unlikely(((float)__pyx_v_origin->_width) == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_Format(PyExc_ZeroDivisionError, "float division");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_self->__pyx_base._uvx = (((__pyx_v_x / ((float)__pyx_v_origin->_width)) * __pyx_v_origin->_uvw) + __pyx_v_origin_u1);

  /* "kivy\graphics\texture.pyx":1098
 *         origin_v1 = origin._uvy
 *         self._uvx = (x / <float>origin._width) * origin._uvw + origin_u1
 *         self._uvy = (y / <float>origin._height) * origin._uvh + origin_v1             # <<<<<<<<<<<<<<
 *         self._uvw = (width / <float>origin._width) * origin._uvw
 *         self._uvh = (height / <float>origin._height) * origin._uvh
 */
  if (unlikely(((float)__pyx_v_origin->_height) == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_Format(PyExc_ZeroDivisionError, "float division");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_self->__pyx_base._uvy = (((__pyx_v_y / ((float)__pyx_v_origin->_height)) * __pyx_v_origin->_uvh) + __pyx_v_origin_v1);

  /* "kivy\graphics\texture.pyx":1099
 *         self._uvx = (x / <float>origin._width) * origin._uvw + origin_u1
 *         self._uvy = (y / <float>origin._height) * origin._uvh + origin_v1
 *         self._uvw = (width / <float>origin._width) * origin._uvw             # <<<<<<<<<<<<<<
 *         self._uvh = (height / <float>origin._height) * origin._uvh
 *         self.update_tex_coords()
 */
  if (unlikely(((float)__pyx_v_origin->_width) == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_Format(PyExc_ZeroDivisionError, "float division");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_self->__pyx_base._uvw = ((__pyx_v_width / ((float)__pyx_v_origin->_width)) * __pyx_v_origin->_uvw);

  /* "kivy\graphics\texture.pyx":1100
 *         self._uvy = (y / <float>origin._height) * origin._uvh + origin_v1
 *         self._uvw = (width / <float>origin._width) * origin._uvw
 *         self._uvh = (height / <float>origin._height) * origin._uvh             # <<<<<<<<<<<<<<
 *         self.update_tex_coords()
 * 
 */
  if (unlikely(((float)__pyx_v_origin->_height) == 0)) {
    #ifdef WITH_THREAD
    PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
    #endif
    PyErr_Format(PyExc_ZeroDivisionError, "float division");
    #ifdef WITH_THREAD
    PyGILState_Release(__pyx_gilstate_save);
    #endif
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_v_self->__pyx_base._uvh = ((__pyx_v_height / ((float)__pyx_v_origin->_height)) * __pyx_v_origin->_uvh);

  /* "kivy\graphics\texture.pyx":1101
 *         self._uvw = (width / <float>origin._width) * origin._uvw
 *         self._uvh = (height / <float>origin._height) * origin._uvh
 *         self.update_tex_coords()             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_TextureRegion *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.update_tex_coords(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self));

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("kivy.graphics.texture.TextureRegion.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_13TextureRegion_3__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4kivy_8graphics_7texture_13TextureRegion_3__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_13TextureRegion_2__repr__(((struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":1103
 *         self.update_tex_coords()
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return '<TextureRegion of %r hash=%r id=%d size=%r colorfmt=%r bufferfmt=%r source=%r observers=%d>' % (
 *             self.owner, id(self), self._id, self.size, self.colorfmt,
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_13TextureRegion_2__repr__(struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__repr__", 0);

  /* "kivy\graphics\texture.pyx":1104
 * 
 *     def __repr__(self):
 *         return '<TextureRegion of %r hash=%r id=%d size=%r colorfmt=%r bufferfmt=%r source=%r observers=%d>' % (             # <<<<<<<<<<<<<<
 *             self.owner, id(self), self._id, self.size, self.colorfmt,
 *             self.bufferfmt, self._source, len(self.observers))
 */
  __Pyx_XDECREF(__pyx_r);

  /* "kivy\graphics\texture.pyx":1105
 *     def __repr__(self):
 *         return '<TextureRegion of %r hash=%r id=%d size=%r colorfmt=%r bufferfmt=%r source=%r observers=%d>' % (
 *             self.owner, id(self), self._id, self.size, self.colorfmt,             # <<<<<<<<<<<<<<
 *             self.bufferfmt, self._source, len(self.observers))
 * 
 */
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_2 = PyObject_Call(__pyx_builtin_id, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyInt_to_py_GLuint(__pyx_v_self->__pyx_base._id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__colorfmt); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "kivy\graphics\texture.pyx":1106
 *         return '<TextureRegion of %r hash=%r id=%d size=%r colorfmt=%r bufferfmt=%r source=%r observers=%d>' % (
 *             self.owner, id(self), self._id, self.size, self.colorfmt,
 *             self.bufferfmt, self._source, len(self.observers))             # <<<<<<<<<<<<<<
 * 
 *     cdef void reload(self):
 */
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__bufferfmt); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = ((PyObject *)__pyx_v_self->__pyx_base.observers);
  __Pyx_INCREF(__pyx_t_6);
  if (unlikely(__pyx_t_6 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_7 = PyList_GET_SIZE(__pyx_t_6); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = PyTuple_New(8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_INCREF(((PyObject *)__pyx_v_self->owner));
  PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_v_self->owner));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self->owner));
  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_8, 4, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_8, 5, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __Pyx_INCREF(__pyx_v_self->__pyx_base._source);
  PyTuple_SET_ITEM(__pyx_t_8, 6, __pyx_v_self->__pyx_base._source);
  __Pyx_GIVEREF(__pyx_v_self->__pyx_base._source);
  PyTuple_SET_ITEM(__pyx_t_8, 7, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_t_2 = 0;
  __pyx_t_1 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_6 = 0;
  __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_31), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));
  __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
  __pyx_r = ((PyObject *)__pyx_t_6);
  __pyx_t_6 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("kivy.graphics.texture.TextureRegion.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":1108
 *             self.bufferfmt, self._source, len(self.observers))
 * 
 *     cdef void reload(self):             # <<<<<<<<<<<<<<
 *         # texture region are reloaded _after_ normal texture
 *         # so that could work, except if it's a region of region
 */

static void __pyx_f_4kivy_8graphics_7texture_13TextureRegion_reload(struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *__pyx_v_self) {
  PyObject *__pyx_v_callback = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  GLuint __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("reload", 0);

  /* "kivy\graphics\texture.pyx":1113
 *         # it's safe to retrigger a reload, since the owner texture will be not
 *         # really reloaded if its id is not -1.
 *         self.owner.reload()             # <<<<<<<<<<<<<<
 *         self._id = self.owner.id
 * 
 */
  ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_self->owner->__pyx_vtab)->reload(__pyx_v_self->owner);

  /* "kivy\graphics\texture.pyx":1114
 *         # really reloaded if its id is not -1.
 *         self.owner.reload()
 *         self._id = self.owner.id             # <<<<<<<<<<<<<<
 * 
 *         # then update content again
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->owner), __pyx_n_s__id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_from_py_GLuint(__pyx_t_1); if (unlikely((__pyx_t_2 == (GLuint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->__pyx_base._id = __pyx_t_2;

  /* "kivy\graphics\texture.pyx":1117
 * 
 *         # then update content again
 *         self.bind()             # <<<<<<<<<<<<<<
 *         for callback in self.observers[:]:
 *             if callback.is_dead():
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_TextureRegion *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.bind(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "kivy\graphics\texture.pyx":1118
 *         # then update content again
 *         self.bind()
 *         for callback in self.observers[:]:             # <<<<<<<<<<<<<<
 *             if callback.is_dead():
 *                 self.observers.remove(callback)
 */
  if (unlikely(((PyObject *)__pyx_v_self->__pyx_base.observers) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = __Pyx_PyList_GetSlice(((PyObject *)__pyx_v_self->__pyx_base.observers), 0, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (unlikely(((PyObject *)__pyx_t_1) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_3 = ((PyObject *)__pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  for (;;) {
    if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_3)) break;
    #if CYTHON_COMPILING_IN_CPYTHON
    __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_4); __Pyx_INCREF(__pyx_t_1); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #else
    __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    #endif
    __Pyx_XDECREF(__pyx_v_callback);
    __pyx_v_callback = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "kivy\graphics\texture.pyx":1119
 *         self.bind()
 *         for callback in self.observers[:]:
 *             if callback.is_dead():             # <<<<<<<<<<<<<<
 *                 self.observers.remove(callback)
 *                 continue
 */
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_callback, __pyx_n_s__is_dead); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_6) {

      /* "kivy\graphics\texture.pyx":1120
 *         for callback in self.observers[:]:
 *             if callback.is_dead():
 *                 self.observers.remove(callback)             # <<<<<<<<<<<<<<
 *                 continue
 *             callback()(self)
 */
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->__pyx_base.observers), __pyx_n_s__remove); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_v_callback);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_callback);
      __Pyx_GIVEREF(__pyx_v_callback);
      __pyx_t_7 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "kivy\graphics\texture.pyx":1121
 *             if callback.is_dead():
 *                 self.observers.remove(callback)
 *                 continue             # <<<<<<<<<<<<<<
 *             callback()(self)
 * 
 */
      goto __pyx_L3_continue;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "kivy\graphics\texture.pyx":1122
 *                 self.observers.remove(callback)
 *                 continue
 *             callback()(self)             # <<<<<<<<<<<<<<
 * 
 *     def ask_update(self, callback):
 */
    __pyx_t_7 = PyObject_Call(__pyx_v_callback, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    __pyx_t_5 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_L3_continue:;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_WriteUnraisable("kivy.graphics.texture.TextureRegion.reload", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_callback);
  __Pyx_RefNannyFinishContext();
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_13TextureRegion_5ask_update(PyObject *__pyx_v_self, PyObject *__pyx_v_callback); /*proto*/
static PyObject *__pyx_pw_4kivy_8graphics_7texture_13TextureRegion_5ask_update(PyObject *__pyx_v_self, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ask_update (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_13TextureRegion_4ask_update(((struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)__pyx_v_self), ((PyObject *)__pyx_v_callback));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":1124
 *             callback()(self)
 * 
 *     def ask_update(self, callback):             # <<<<<<<<<<<<<<
 *         # redirect to owner
 *         self.owner.ask_update(callback)
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_13TextureRegion_4ask_update(struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *__pyx_v_self, PyObject *__pyx_v_callback) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("ask_update", 0);

  /* "kivy\graphics\texture.pyx":1126
 *     def ask_update(self, callback):
 *         # redirect to owner
 *         self.owner.ask_update(callback)             # <<<<<<<<<<<<<<
 * 
 *     cpdef bind(self):
 */
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->owner), __pyx_n_s__ask_update); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_v_callback);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_callback);
  __Pyx_GIVEREF(__pyx_v_callback);
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("kivy.graphics.texture.TextureRegion.ask_update", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":1128
 *         self.owner.ask_update(callback)
 * 
 *     cpdef bind(self):             # <<<<<<<<<<<<<<
 *         self.owner.bind()
 * 
 */

static PyObject *__pyx_pw_4kivy_8graphics_7texture_13TextureRegion_7bind(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_f_4kivy_8graphics_7texture_13TextureRegion_bind(struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *__pyx_v_self, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("bind", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overridden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__bind); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_13TextureRegion_7bind)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "kivy\graphics\texture.pyx":1129
 * 
 *     cpdef bind(self):
 *         self.owner.bind()             # <<<<<<<<<<<<<<
 * 
 *     property pixels:
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_self->owner->__pyx_vtab)->bind(__pyx_v_self->owner, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("kivy.graphics.texture.TextureRegion.bind", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_13TextureRegion_7bind(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pw_4kivy_8graphics_7texture_13TextureRegion_7bind(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("bind (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_13TextureRegion_6bind(((struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":1128
 *         self.owner.ask_update(callback)
 * 
 *     cpdef bind(self):             # <<<<<<<<<<<<<<
 *         self.owner.bind()
 * 
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_13TextureRegion_6bind(struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("bind", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_TextureRegion *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.bind(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.texture.TextureRegion.bind", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* Python wrapper */
static PyObject *__pyx_pw_4kivy_8graphics_7texture_13TextureRegion_6pixels_1__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pw_4kivy_8graphics_7texture_13TextureRegion_6pixels_1__get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
  __pyx_r = __pyx_pf_4kivy_8graphics_7texture_13TextureRegion_6pixels___get__(((struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)__pyx_v_self));
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy\graphics\texture.pyx":1132
 * 
 *     property pixels:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             from kivy.graphics.fbo import Fbo
 *             from kivy.graphics import Color, Rectangle
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_13TextureRegion_6pixels___get__(struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *__pyx_v_self) {
  PyObject *__pyx_v_Fbo = NULL;
  PyObject *__pyx_v_Color = NULL;
  PyObject *__pyx_v_Rectangle = NULL;
  PyObject *__pyx_v_fbo = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__get__", 0);

  /* "kivy\graphics\texture.pyx":1133
 *     property pixels:
 *         def __get__(self):
 *             from kivy.graphics.fbo import Fbo             # <<<<<<<<<<<<<<
 *             from kivy.graphics import Color, Rectangle
 *             fbo = Fbo(size=self.size)
 */
  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__Fbo));
  PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__Fbo));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Fbo));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s_30), ((PyObject *)__pyx_t_1), -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s__Fbo); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_Fbo = __pyx_t_1;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "kivy\graphics\texture.pyx":1134
 *         def __get__(self):
 *             from kivy.graphics.fbo import Fbo
 *             from kivy.graphics import Color, Rectangle             # <<<<<<<<<<<<<<
 *             fbo = Fbo(size=self.size)
 *             fbo.clear()
 */
  __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__Color));
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__Color));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Color));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__Rectangle));
  PyList_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_n_s__Rectangle));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Rectangle));
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s_32), ((PyObject *)__pyx_t_2), -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s__Color); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_t_2);
  __pyx_v_Color = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s__Rectangle); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_t_2);
  __pyx_v_Rectangle = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "kivy\graphics\texture.pyx":1135
 *             from kivy.graphics.fbo import Fbo
 *             from kivy.graphics import Color, Rectangle
 *             fbo = Fbo(size=self.size)             # <<<<<<<<<<<<<<
 *             fbo.clear()
 *             self.flip_vertical()
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__size), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_v_Fbo, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_v_fbo = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "kivy\graphics\texture.pyx":1136
 *             from kivy.graphics import Color, Rectangle
 *             fbo = Fbo(size=self.size)
 *             fbo.clear()             # <<<<<<<<<<<<<<
 *             self.flip_vertical()
 *             with fbo:
 */
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_fbo, __pyx_n_s__clear); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "kivy\graphics\texture.pyx":1137
 *             fbo = Fbo(size=self.size)
 *             fbo.clear()
 *             self.flip_vertical()             # <<<<<<<<<<<<<<
 *             with fbo:
 *                 Color(1, 1, 1)
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_TextureRegion *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.flip_vertical(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "kivy\graphics\texture.pyx":1138
 *             fbo.clear()
 *             self.flip_vertical()
 *             with fbo:             # <<<<<<<<<<<<<<
 *                 Color(1, 1, 1)
 *                 Rectangle(size=self.size, texture=self,
 */
  /*with:*/ {
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_fbo, __pyx_n_s____exit__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_fbo, __pyx_n_s____enter__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    /*try:*/ {
      {
        __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
        __Pyx_XGOTREF(__pyx_t_4);
        __Pyx_XGOTREF(__pyx_t_5);
        __Pyx_XGOTREF(__pyx_t_6);
        /*try:*/ {

          /* "kivy\graphics\texture.pyx":1139
 *             self.flip_vertical()
 *             with fbo:
 *                 Color(1, 1, 1)             # <<<<<<<<<<<<<<
 *                 Rectangle(size=self.size, texture=self,
 *                         tex_coords=self.tex_coords)
 */
          __pyx_t_2 = PyObject_Call(__pyx_v_Color, ((PyObject *)__pyx_k_tuple_33), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1139; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "kivy\graphics\texture.pyx":1140
 *             with fbo:
 *                 Color(1, 1, 1)
 *                 Rectangle(size=self.size, texture=self,             # <<<<<<<<<<<<<<
 *                         tex_coords=self.tex_coords)
 *             fbo.draw()
 */
          __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1140; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(((PyObject *)__pyx_t_2));
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1140; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_1);
          if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__size), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1140; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__texture), ((PyObject *)__pyx_v_self)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1140; __pyx_clineno = __LINE__; goto __pyx_L7_error;}

          /* "kivy\graphics\texture.pyx":1141
 *                 Color(1, 1, 1)
 *                 Rectangle(size=self.size, texture=self,
 *                         tex_coords=self.tex_coords)             # <<<<<<<<<<<<<<
 *             fbo.draw()
 *             self.flip_vertical()
 */
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s__tex_coords); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1141; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_1);
          if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__tex_coords), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1140; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = PyObject_Call(__pyx_v_Rectangle, ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1140; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        }
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        goto __pyx_L14_try_end;
        __pyx_L7_error:;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "kivy\graphics\texture.pyx":1138
 *             fbo.clear()
 *             self.flip_vertical()
 *             with fbo:             # <<<<<<<<<<<<<<
 *                 Color(1, 1, 1)
 *                 Rectangle(size=self.size, texture=self,
 */
        /*except:*/ {
          __Pyx_AddTraceback("kivy.graphics.texture.TextureRegion.pixels.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_1);
          PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_2);
          PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_7);
          PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7);
          __Pyx_GIVEREF(__pyx_t_7);
          __pyx_t_10 = PyObject_Call(__pyx_t_3, __pyx_t_8, NULL);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (__pyx_t_9 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
          __pyx_t_11 = ((!(__pyx_t_9 != 0)) != 0);
          if (__pyx_t_11) {
            __Pyx_GIVEREF(__pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_2);
            __Pyx_GIVEREF(__pyx_t_7);
            __Pyx_ErrRestore(__pyx_t_1, __pyx_t_2, __pyx_t_7);
            __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_7 = 0; 
            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
            goto __pyx_L17;
          }
          __pyx_L17:;
          __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          goto __pyx_L8_exception_handled;
        }
        __pyx_L9_except_error:;
        __Pyx_XGIVEREF(__pyx_t_4);
        __Pyx_XGIVEREF(__pyx_t_5);
        __Pyx_XGIVEREF(__pyx_t_6);
        __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
        goto __pyx_L1_error;
        __pyx_L8_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_4);
        __Pyx_XGIVEREF(__pyx_t_5);
        __Pyx_XGIVEREF(__pyx_t_6);
        __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
        __pyx_L14_try_end:;
      }
    }
    /*finally:*/ {
      if (__pyx_t_3) {
        __pyx_t_6 = PyObject_Call(__pyx_t_3, __pyx_k_tuple_34, NULL);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (__pyx_t_11 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
    }
    goto __pyx_L18;
    __pyx_L3_error:;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L1_error;
    __pyx_L18:;
  }

  /* "kivy\graphics\texture.pyx":1142
 *                 Rectangle(size=self.size, texture=self,
 *                         tex_coords=self.tex_coords)
 *             fbo.draw()             # <<<<<<<<<<<<<<
 *             self.flip_vertical()
 *             return fbo.pixels
 */
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_fbo, __pyx_n_s__draw); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_2 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "kivy\graphics\texture.pyx":1143
 *                         tex_coords=self.tex_coords)
 *             fbo.draw()
 *             self.flip_vertical()             # <<<<<<<<<<<<<<
 *             return fbo.pixels
 * 
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_TextureRegion *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.flip_vertical(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "kivy\graphics\texture.pyx":1144
 *             fbo.draw()
 *             self.flip_vertical()
 *             return fbo.pixels             # <<<<<<<<<<<<<<
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_fbo, __pyx_n_s__pixels); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("kivy.graphics.texture.TextureRegion.pixels.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_Fbo);
  __Pyx_XDECREF(__pyx_v_Color);
  __Pyx_XDECREF(__pyx_v_Rectangle);
  __Pyx_XDECREF(__pyx_v_fbo);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture __pyx_vtable_4kivy_8graphics_7texture_Texture;

static PyObject *__pyx_tp_new_4kivy_8graphics_7texture_Texture(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4kivy_8graphics_7texture_Texture *p;
  PyObject *o;
  o = (*t->tp_alloc)(t, 0);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)o);
  p->__pyx_vtab = __pyx_vtabptr_4kivy_8graphics_7texture_Texture;
  p->__weakref__ = 0;
  p->_source = Py_None; Py_INCREF(Py_None);
  p->_wrap = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->_min_filter = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->_mag_filter = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->_colorfmt = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->_bufferfmt = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->observers = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->_proxyimage = Py_None; Py_INCREF(Py_None);
  p->_callback = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4kivy_8graphics_7texture_Texture(PyObject *o) {
  struct __pyx_obj_4kivy_8graphics_7texture_Texture *p = (struct __pyx_obj_4kivy_8graphics_7texture_Texture *)o;
  PyObject_GC_UnTrack(o);
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_4kivy_8graphics_7texture_7Texture_3__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  if (p->__weakref__) PyObject_ClearWeakRefs(o);
  Py_CLEAR(p->_source);
  Py_CLEAR(p->_wrap);
  Py_CLEAR(p->_min_filter);
  Py_CLEAR(p->_mag_filter);
  Py_CLEAR(p->_colorfmt);
  Py_CLEAR(p->_bufferfmt);
  Py_CLEAR(p->observers);
  Py_CLEAR(p->_proxyimage);
  Py_CLEAR(p->_callback);
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_4kivy_8graphics_7texture_Texture(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4kivy_8graphics_7texture_Texture *p = (struct __pyx_obj_4kivy_8graphics_7texture_Texture *)o;
  if (p->_source) {
    e = (*v)(p->_source, a); if (e) return e;
  }
  if (p->_wrap) {
    e = (*v)(p->_wrap, a); if (e) return e;
  }
  if (p->_min_filter) {
    e = (*v)(p->_min_filter, a); if (e) return e;
  }
  if (p->_mag_filter) {
    e = (*v)(p->_mag_filter, a); if (e) return e;
  }
  if (p->_colorfmt) {
    e = (*v)(p->_colorfmt, a); if (e) return e;
  }
  if (p->_bufferfmt) {
    e = (*v)(p->_bufferfmt, a); if (e) return e;
  }
  if (p->observers) {
    e = (*v)(p->observers, a); if (e) return e;
  }
  if (p->_proxyimage) {
    e = (*v)(p->_proxyimage, a); if (e) return e;
  }
  if (p->_callback) {
    e = (*v)(p->_callback, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4kivy_8graphics_7texture_Texture(PyObject *o) {
  struct __pyx_obj_4kivy_8graphics_7texture_Texture *p = (struct __pyx_obj_4kivy_8graphics_7texture_Texture *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_source);
  p->_source = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_wrap);
  p->_wrap = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_min_filter);
  p->_min_filter = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_mag_filter);
  p->_mag_filter = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_colorfmt);
  p->_colorfmt = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_bufferfmt);
  p->_bufferfmt = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->observers);
  p->observers = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_proxyimage);
  p->_proxyimage = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_callback);
  p->_callback = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_size(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4kivy_8graphics_7texture_7Texture_4size_1__get__(o);
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_mipmap(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4kivy_8graphics_7texture_7Texture_6mipmap_1__get__(o);
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_id(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4kivy_8graphics_7texture_7Texture_2id_1__get__(o);
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_target(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4kivy_8graphics_7texture_7Texture_6target_1__get__(o);
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_width(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4kivy_8graphics_7texture_7Texture_5width_1__get__(o);
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_height(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4kivy_8graphics_7texture_7Texture_6height_1__get__(o);
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_tex_coords(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4kivy_8graphics_7texture_7Texture_10tex_coords_1__get__(o);
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_uvpos(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4kivy_8graphics_7texture_7Texture_5uvpos_1__get__(o);
}

static int __pyx_setprop_4kivy_8graphics_7texture_7Texture_uvpos(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4kivy_8graphics_7texture_7Texture_5uvpos_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_uvsize(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4kivy_8graphics_7texture_7Texture_6uvsize_1__get__(o);
}

static int __pyx_setprop_4kivy_8graphics_7texture_7Texture_uvsize(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4kivy_8graphics_7texture_7Texture_6uvsize_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_colorfmt(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4kivy_8graphics_7texture_7Texture_8colorfmt_1__get__(o);
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_bufferfmt(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4kivy_8graphics_7texture_7Texture_9bufferfmt_1__get__(o);
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_min_filter(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4kivy_8graphics_7texture_7Texture_10min_filter_1__get__(o);
}

static int __pyx_setprop_4kivy_8graphics_7texture_7Texture_min_filter(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4kivy_8graphics_7texture_7Texture_10min_filter_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_mag_filter(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4kivy_8graphics_7texture_7Texture_10mag_filter_1__get__(o);
}

static int __pyx_setprop_4kivy_8graphics_7texture_7Texture_mag_filter(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4kivy_8graphics_7texture_7Texture_10mag_filter_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_wrap(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4kivy_8graphics_7texture_7Texture_4wrap_1__get__(o);
}

static int __pyx_setprop_4kivy_8graphics_7texture_7Texture_wrap(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
  if (v) {
    return __pyx_pw_4kivy_8graphics_7texture_7Texture_4wrap_3__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_pixels(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4kivy_8graphics_7texture_7Texture_6pixels_1__get__(o);
}

static PyMethodDef __pyx_methods_4kivy_8graphics_7texture_Texture[] = {
  {__Pyx_NAMESTR("add_reload_observer"), (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_7Texture_5add_reload_observer, METH_O, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_4add_reload_observer)},
  {__Pyx_NAMESTR("remove_reload_observer"), (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_7Texture_7remove_reload_observer, METH_O, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_6remove_reload_observer)},
  {__Pyx_NAMESTR("flip_vertical"), (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_7Texture_9flip_vertical, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_8flip_vertical)},
  {__Pyx_NAMESTR("get_region"), (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_7Texture_11get_region, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_10get_region)},
  {__Pyx_NAMESTR("ask_update"), (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_7Texture_13ask_update, METH_O, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_12ask_update)},
  {__Pyx_NAMESTR("bind"), (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_7Texture_15bind, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_14bind)},
  {__Pyx_NAMESTR("blit_data"), (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_7Texture_17blit_data, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_16blit_data)},
  {__Pyx_NAMESTR("blit_buffer"), (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_7Texture_19blit_buffer, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_18blit_buffer)},
  {__Pyx_NAMESTR("_on_proxyimage_loaded"), (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_7Texture_21_on_proxyimage_loaded, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("save"), (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_7Texture_23save, METH_O, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_22save)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4kivy_8graphics_7texture_Texture[] = {
  {(char *)"size", __pyx_getprop_4kivy_8graphics_7texture_7Texture_size, 0, __Pyx_DOCSTR(__pyx_k_35), 0},
  {(char *)"mipmap", __pyx_getprop_4kivy_8graphics_7texture_7Texture_mipmap, 0, __Pyx_DOCSTR(__pyx_k_36), 0},
  {(char *)"id", __pyx_getprop_4kivy_8graphics_7texture_7Texture_id, 0, __Pyx_DOCSTR(__pyx_k_37), 0},
  {(char *)"target", __pyx_getprop_4kivy_8graphics_7texture_7Texture_target, 0, __Pyx_DOCSTR(__pyx_k_38), 0},
  {(char *)"width", __pyx_getprop_4kivy_8graphics_7texture_7Texture_width, 0, __Pyx_DOCSTR(__pyx_k_39), 0},
  {(char *)"height", __pyx_getprop_4kivy_8graphics_7texture_7Texture_height, 0, __Pyx_DOCSTR(__pyx_k_40), 0},
  {(char *)"tex_coords", __pyx_getprop_4kivy_8graphics_7texture_7Texture_tex_coords, 0, __Pyx_DOCSTR(__pyx_k_41), 0},
  {(char *)"uvpos", __pyx_getprop_4kivy_8graphics_7texture_7Texture_uvpos, __pyx_setprop_4kivy_8graphics_7texture_7Texture_uvpos, __Pyx_DOCSTR(__pyx_k_42), 0},
  {(char *)"uvsize", __pyx_getprop_4kivy_8graphics_7texture_7Texture_uvsize, __pyx_setprop_4kivy_8graphics_7texture_7Texture_uvsize, __Pyx_DOCSTR(__pyx_k_43), 0},
  {(char *)"colorfmt", __pyx_getprop_4kivy_8graphics_7texture_7Texture_colorfmt, 0, __Pyx_DOCSTR(__pyx_k_44), 0},
  {(char *)"bufferfmt", __pyx_getprop_4kivy_8graphics_7texture_7Texture_bufferfmt, 0, __Pyx_DOCSTR(__pyx_k_45), 0},
  {(char *)"min_filter", __pyx_getprop_4kivy_8graphics_7texture_7Texture_min_filter, __pyx_setprop_4kivy_8graphics_7texture_7Texture_min_filter, __Pyx_DOCSTR(__pyx_k_46), 0},
  {(char *)"mag_filter", __pyx_getprop_4kivy_8graphics_7texture_7Texture_mag_filter, __pyx_setprop_4kivy_8graphics_7texture_7Texture_mag_filter, __Pyx_DOCSTR(__pyx_k_47), 0},
  {(char *)"wrap", __pyx_getprop_4kivy_8graphics_7texture_7Texture_wrap, __pyx_setprop_4kivy_8graphics_7texture_7Texture_wrap, __Pyx_DOCSTR(__pyx_k_48), 0},
  {(char *)"pixels", __pyx_getprop_4kivy_8graphics_7texture_7Texture_pixels, 0, __Pyx_DOCSTR(__pyx_k_49), 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4kivy_8graphics_7texture_Texture = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("kivy.graphics.texture.Texture"), /*tp_name*/
  sizeof(struct __pyx_obj_4kivy_8graphics_7texture_Texture), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4kivy_8graphics_7texture_Texture, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_4kivy_8graphics_7texture_7Texture_25__repr__, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("Handle a OpenGL texture. This class can be used to create simple texture\n    or complex texture based on ImageData."), /*tp_doc*/
  __pyx_tp_traverse_4kivy_8graphics_7texture_Texture, /*tp_traverse*/
  __pyx_tp_clear_4kivy_8graphics_7texture_Texture, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4kivy_8graphics_7texture_Texture, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4kivy_8graphics_7texture_Texture, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4kivy_8graphics_7texture_7Texture_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4kivy_8graphics_7texture_Texture, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_4kivy_8graphics_7texture_TextureRegion __pyx_vtable_4kivy_8graphics_7texture_TextureRegion;

static PyObject *__pyx_tp_new_4kivy_8graphics_7texture_TextureRegion(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *p;
  PyObject *o = __pyx_tp_new_4kivy_8graphics_7texture_Texture(t, a, k);
  if (unlikely(!o)) return 0;
  p = ((struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture*)__pyx_vtabptr_4kivy_8graphics_7texture_TextureRegion;
  p->owner = ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4kivy_8graphics_7texture_TextureRegion(PyObject *o) {
  struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *p = (struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)o;
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->owner);
  PyObject_GC_Track(o);
  __pyx_tp_dealloc_4kivy_8graphics_7texture_Texture(o);
}

static int __pyx_tp_traverse_4kivy_8graphics_7texture_TextureRegion(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *p = (struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)o;
  e = __pyx_tp_traverse_4kivy_8graphics_7texture_Texture(o, v, a); if (e) return e;
  if (p->owner) {
    e = (*v)(((PyObject*)p->owner), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4kivy_8graphics_7texture_TextureRegion(PyObject *o) {
  struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *p = (struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)o;
  PyObject* tmp;
  __pyx_tp_clear_4kivy_8graphics_7texture_Texture(o);
  tmp = ((PyObject*)p->owner);
  p->owner = ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_13TextureRegion_pixels(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4kivy_8graphics_7texture_13TextureRegion_6pixels_1__get__(o);
}

static PyMethodDef __pyx_methods_4kivy_8graphics_7texture_TextureRegion[] = {
  {__Pyx_NAMESTR("ask_update"), (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_13TextureRegion_5ask_update, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("bind"), (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_13TextureRegion_7bind, METH_NOARGS, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4kivy_8graphics_7texture_TextureRegion[] = {
  {(char *)"pixels", __pyx_getprop_4kivy_8graphics_7texture_13TextureRegion_pixels, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyTypeObject __pyx_type_4kivy_8graphics_7texture_TextureRegion = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("kivy.graphics.texture.TextureRegion"), /*tp_name*/
  sizeof(struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4kivy_8graphics_7texture_TextureRegion, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_4kivy_8graphics_7texture_13TextureRegion_3__repr__, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("Handle a region of a Texture class. Useful for non power-of-2\n    texture handling."), /*tp_doc*/
  __pyx_tp_traverse_4kivy_8graphics_7texture_TextureRegion, /*tp_traverse*/
  __pyx_tp_clear_4kivy_8graphics_7texture_TextureRegion, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4kivy_8graphics_7texture_TextureRegion, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4kivy_8graphics_7texture_TextureRegion, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4kivy_8graphics_7texture_13TextureRegion_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4kivy_8graphics_7texture_TextureRegion, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
  #if PY_VERSION_HEX < 0x03020000
    { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
  #else
    PyModuleDef_HEAD_INIT,
  #endif
    __Pyx_NAMESTR("texture"),
    __Pyx_DOCSTR(__pyx_k_50), /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
  {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0},
  {&__pyx_n_s_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 0, 1, 1},
  {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
  {&__pyx_kp_s_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 0, 1, 0},
  {&__pyx_kp_s_24, __pyx_k_24, sizeof(__pyx_k_24), 0, 0, 1, 0},
  {&__pyx_n_s_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 0, 1, 1},
  {&__pyx_n_s_27, __pyx_k_27, sizeof(__pyx_k_27), 0, 0, 1, 1},
  {&__pyx_n_s_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 0, 1, 1},
  {&__pyx_kp_s_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 0, 1, 0},
  {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
  {&__pyx_n_s_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 0, 1, 1},
  {&__pyx_kp_s_31, __pyx_k_31, sizeof(__pyx_k_31), 0, 0, 1, 0},
  {&__pyx_n_s_32, __pyx_k_32, sizeof(__pyx_k_32), 0, 0, 1, 1},
  {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
  {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
  {&__pyx_n_s_52, __pyx_k_52, sizeof(__pyx_k_52), 0, 0, 1, 1},
  {&__pyx_n_s_53, __pyx_k_53, sizeof(__pyx_k_53), 0, 0, 1, 1},
  {&__pyx_n_s_54, __pyx_k_54, sizeof(__pyx_k_54), 0, 0, 1, 1},
  {&__pyx_n_s_55, __pyx_k_55, sizeof(__pyx_k_55), 0, 0, 1, 1},
  {&__pyx_kp_s_58, __pyx_k_58, sizeof(__pyx_k_58), 0, 0, 1, 0},
  {&__pyx_n_s_59, __pyx_k_59, sizeof(__pyx_k_59), 0, 0, 1, 1},
  {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
  {&__pyx_n_s_62, __pyx_k_62, sizeof(__pyx_k_62), 0, 0, 1, 1},
  {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
  {&__pyx_n_s__Color, __pyx_k__Color, sizeof(__pyx_k__Color), 0, 0, 1, 1},
  {&__pyx_n_s__Exception, __pyx_k__Exception, sizeof(__pyx_k__Exception), 0, 0, 1, 1},
  {&__pyx_n_s__Fbo, __pyx_k__Fbo, sizeof(__pyx_k__Fbo), 0, 0, 1, 1},
  {&__pyx_n_s__GLCAP_BGRA, __pyx_k__GLCAP_BGRA, sizeof(__pyx_k__GLCAP_BGRA), 0, 0, 1, 1},
  {&__pyx_n_s__GLCAP_DXT1, __pyx_k__GLCAP_DXT1, sizeof(__pyx_k__GLCAP_DXT1), 0, 0, 1, 1},
  {&__pyx_n_s__GLCAP_ETC1, __pyx_k__GLCAP_ETC1, sizeof(__pyx_k__GLCAP_ETC1), 0, 0, 1, 1},
  {&__pyx_n_s__GLCAP_NPOT, __pyx_k__GLCAP_NPOT, sizeof(__pyx_k__GLCAP_NPOT), 0, 0, 1, 1},
  {&__pyx_n_s__GLCAP_PVRTC, __pyx_k__GLCAP_PVRTC, sizeof(__pyx_k__GLCAP_PVRTC), 0, 0, 1, 1},
  {&__pyx_n_s__GLCAP_S3TC, __pyx_k__GLCAP_S3TC, sizeof(__pyx_k__GLCAP_S3TC), 0, 0, 1, 1},
  {&__pyx_n_s__Image, __pyx_k__Image, sizeof(__pyx_k__Image), 0, 0, 1, 1},
  {&__pyx_n_s__KeyError, __pyx_k__KeyError, sizeof(__pyx_k__KeyError), 0, 0, 1, 1},
  {&__pyx_n_s__Loader, __pyx_k__Loader, sizeof(__pyx_k__Loader), 0, 0, 1, 1},
  {&__pyx_n_s__Rectangle, __pyx_k__Rectangle, sizeof(__pyx_k__Rectangle), 0, 0, 1, 1},
  {&__pyx_n_s__Texture, __pyx_k__Texture, sizeof(__pyx_k__Texture), 0, 0, 1, 1},
  {&__pyx_n_s__TextureRegion, __pyx_k__TextureRegion, sizeof(__pyx_k__TextureRegion), 0, 0, 1, 1},
  {&__pyx_n_s__WeakMethod, __pyx_k__WeakMethod, sizeof(__pyx_k__WeakMethod), 0, 0, 1, 1},
  {&__pyx_n_s____all__, __pyx_k____all__, sizeof(__pyx_k____all__), 0, 0, 1, 1},
  {&__pyx_n_s____enter__, __pyx_k____enter__, sizeof(__pyx_k____enter__), 0, 0, 1, 1},
  {&__pyx_n_s____exit__, __pyx_k____exit__, sizeof(__pyx_k____exit__), 0, 0, 1, 1},
  {&__pyx_n_s____import__, __pyx_k____import__, sizeof(__pyx_k____import__), 0, 0, 1, 1},
  {&__pyx_n_s____init__, __pyx_k____init__, sizeof(__pyx_k____init__), 0, 0, 1, 1},
  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
  {&__pyx_n_s____pyx_vtable__, __pyx_k____pyx_vtable__, sizeof(__pyx_k____pyx_vtable__), 0, 0, 1, 1},
  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
  {&__pyx_n_s__allocate, __pyx_k__allocate, sizeof(__pyx_k__allocate), 0, 0, 1, 1},
  {&__pyx_n_s__array, __pyx_k__array, sizeof(__pyx_k__array), 0, 0, 1, 1},
  {&__pyx_n_s__ask_update, __pyx_k__ask_update, sizeof(__pyx_k__ask_update), 0, 0, 1, 1},
  {&__pyx_n_s__b, __pyx_k__b, sizeof(__pyx_k__b), 0, 0, 1, 1},
  {&__pyx_n_s__bgr, __pyx_k__bgr, sizeof(__pyx_k__bgr), 0, 0, 1, 1},
  {&__pyx_n_s__bgra, __pyx_k__bgra, sizeof(__pyx_k__bgra), 0, 0, 1, 1},
  {&__pyx_n_s__bind, __pyx_k__bind, sizeof(__pyx_k__bind), 0, 0, 1, 1},
  {&__pyx_n_s__blit_buffer, __pyx_k__blit_buffer, sizeof(__pyx_k__blit_buffer), 0, 0, 1, 1},
  {&__pyx_n_s__blit_data, __pyx_k__blit_data, sizeof(__pyx_k__blit_data), 0, 0, 1, 1},
  {&__pyx_n_s__bufferfmt, __pyx_k__bufferfmt, sizeof(__pyx_k__bufferfmt), 0, 0, 1, 1},
  {&__pyx_n_s__byte, __pyx_k__byte, sizeof(__pyx_k__byte), 0, 0, 1, 1},
  {&__pyx_n_s__callback, __pyx_k__callback, sizeof(__pyx_k__callback), 0, 0, 1, 1},
  {&__pyx_n_s__clamp_to_edge, __pyx_k__clamp_to_edge, sizeof(__pyx_k__clamp_to_edge), 0, 0, 1, 1},
  {&__pyx_n_s__clear, __pyx_k__clear, sizeof(__pyx_k__clear), 0, 0, 1, 1},
  {&__pyx_n_s__colorfmt, __pyx_k__colorfmt, sizeof(__pyx_k__colorfmt), 0, 0, 1, 1},
  {&__pyx_n_s__create, __pyx_k__create, sizeof(__pyx_k__create), 0, 0, 1, 1},
  {&__pyx_n_s__create_from_data, __pyx_k__create_from_data, sizeof(__pyx_k__create_from_data), 0, 0, 1, 1},
  {&__pyx_n_s__data, __pyx_k__data, sizeof(__pyx_k__data), 0, 0, 1, 1},
  {&__pyx_n_s__draw, __pyx_k__draw, sizeof(__pyx_k__draw), 0, 0, 1, 1},
  {&__pyx_n_s__etc1_, __pyx_k__etc1_, sizeof(__pyx_k__etc1_), 0, 0, 1, 1},
  {&__pyx_n_s__etc1_rgb8, __pyx_k__etc1_rgb8, sizeof(__pyx_k__etc1_rgb8), 0, 0, 1, 1},
  {&__pyx_n_s__flag_update_canvas, __pyx_k__flag_update_canvas, sizeof(__pyx_k__flag_update_canvas), 0, 0, 1, 1},
  {&__pyx_n_s__flip_vertical, __pyx_k__flip_vertical, sizeof(__pyx_k__flip_vertical), 0, 0, 1, 1},
  {&__pyx_n_s__float, __pyx_k__float, sizeof(__pyx_k__float), 0, 0, 1, 1},
  {&__pyx_n_s__fmt, __pyx_k__fmt, sizeof(__pyx_k__fmt), 0, 0, 1, 1},
  {&__pyx_n_s__format, __pyx_k__format, sizeof(__pyx_k__format), 0, 0, 1, 1},
  {&__pyx_n_s__ftp, __pyx_k__ftp, sizeof(__pyx_k__ftp), 0, 0, 1, 1},
  {&__pyx_n_s__get_region, __pyx_k__get_region, sizeof(__pyx_k__get_region), 0, 0, 1, 1},
  {&__pyx_n_s__have_mipmap, __pyx_k__have_mipmap, sizeof(__pyx_k__have_mipmap), 0, 0, 1, 1},
  {&__pyx_n_s__height, __pyx_k__height, sizeof(__pyx_k__height), 0, 0, 1, 1},
  {&__pyx_n_s__http, __pyx_k__http, sizeof(__pyx_k__http), 0, 0, 1, 1},
  {&__pyx_n_s__https, __pyx_k__https, sizeof(__pyx_k__https), 0, 0, 1, 1},
  {&__pyx_n_s__id, __pyx_k__id, sizeof(__pyx_k__id), 0, 0, 1, 1},
  {&__pyx_n_s__im, __pyx_k__im, sizeof(__pyx_k__im), 0, 0, 1, 1},
  {&__pyx_n_s__image, __pyx_k__image, sizeof(__pyx_k__image), 0, 0, 1, 1},
  {&__pyx_n_s__int, __pyx_k__int, sizeof(__pyx_k__int), 0, 0, 1, 1},
  {&__pyx_n_s__is_dead, __pyx_k__is_dead, sizeof(__pyx_k__is_dead), 0, 0, 1, 1},
  {&__pyx_n_s__iterate_mipmaps, __pyx_k__iterate_mipmaps, sizeof(__pyx_k__iterate_mipmaps), 0, 0, 1, 1},
  {&__pyx_n_s__linear, __pyx_k__linear, sizeof(__pyx_k__linear), 0, 0, 1, 1},
  {&__pyx_n_s__loaded, __pyx_k__loaded, sizeof(__pyx_k__loaded), 0, 0, 1, 1},
  {&__pyx_n_s__lower, __pyx_k__lower, sizeof(__pyx_k__lower), 0, 0, 1, 1},
  {&__pyx_n_s__luminance, __pyx_k__luminance, sizeof(__pyx_k__luminance), 0, 0, 1, 1},
  {&__pyx_n_s__luminance_alpha, __pyx_k__luminance_alpha, sizeof(__pyx_k__luminance_alpha), 0, 0, 1, 1},
  {&__pyx_n_s__mag_filter, __pyx_k__mag_filter, sizeof(__pyx_k__mag_filter), 0, 0, 1, 1},
  {&__pyx_n_s__min_filter, __pyx_k__min_filter, sizeof(__pyx_k__min_filter), 0, 0, 1, 1},
  {&__pyx_n_s__mipmap, __pyx_k__mipmap, sizeof(__pyx_k__mipmap), 0, 0, 1, 1},
  {&__pyx_n_s__mipmap_generation, __pyx_k__mipmap_generation, sizeof(__pyx_k__mipmap_generation), 0, 0, 1, 1},
  {&__pyx_n_s__mipmap_level, __pyx_k__mipmap_level, sizeof(__pyx_k__mipmap_level), 0, 0, 1, 1},
  {&__pyx_n_s__mirrored_repeat, __pyx_k__mirrored_repeat, sizeof(__pyx_k__mirrored_repeat), 0, 0, 1, 1},
  {&__pyx_n_s__nearest, __pyx_k__nearest, sizeof(__pyx_k__nearest), 0, 0, 1, 1},
  {&__pyx_n_s__no_blit, __pyx_k__no_blit, sizeof(__pyx_k__no_blit), 0, 0, 1, 1},
  {&__pyx_n_s__nocache, __pyx_k__nocache, sizeof(__pyx_k__nocache), 0, 0, 1, 1},
  {&__pyx_n_s__on_load, __pyx_k__on_load, sizeof(__pyx_k__on_load), 0, 0, 1, 1},
  {&__pyx_n_s__origin, __pyx_k__origin, sizeof(__pyx_k__origin), 0, 0, 1, 1},
  {&__pyx_n_s__palette, __pyx_k__palette, sizeof(__pyx_k__palette), 0, 0, 1, 1},
  {&__pyx_n_s__palette4_r5_g6_b5, __pyx_k__palette4_r5_g6_b5, sizeof(__pyx_k__palette4_r5_g6_b5), 0, 0, 1, 1},
  {&__pyx_n_s__palette4_rgb5_a1, __pyx_k__palette4_rgb5_a1, sizeof(__pyx_k__palette4_rgb5_a1), 0, 0, 1, 1},
  {&__pyx_n_s__palette4_rgb8, __pyx_k__palette4_rgb8, sizeof(__pyx_k__palette4_rgb8), 0, 0, 1, 1},
  {&__pyx_n_s__palette4_rgba4, __pyx_k__palette4_rgba4, sizeof(__pyx_k__palette4_rgba4), 0, 0, 1, 1},
  {&__pyx_n_s__palette4_rgba8, __pyx_k__palette4_rgba8, sizeof(__pyx_k__palette4_rgba8), 0, 0, 1, 1},
  {&__pyx_n_s__palette8_r5_g6_b5, __pyx_k__palette8_r5_g6_b5, sizeof(__pyx_k__palette8_r5_g6_b5), 0, 0, 1, 1},
  {&__pyx_n_s__palette8_rgb5_a1, __pyx_k__palette8_rgb5_a1, sizeof(__pyx_k__palette8_rgb5_a1), 0, 0, 1, 1},
  {&__pyx_n_s__palette8_rgb8, __pyx_k__palette8_rgb8, sizeof(__pyx_k__palette8_rgb8), 0, 0, 1, 1},
  {&__pyx_n_s__palette8_rgba4, __pyx_k__palette8_rgba4, sizeof(__pyx_k__palette8_rgba4), 0, 0, 1, 1},
  {&__pyx_n_s__palette8_rgba8, __pyx_k__palette8_rgba8, sizeof(__pyx_k__palette8_rgba8), 0, 0, 1, 1},
  {&__pyx_n_s__pbuffer, __pyx_k__pbuffer, sizeof(__pyx_k__pbuffer), 0, 0, 1, 1},
  {&__pyx_n_s__pixels, __pyx_k__pixels, sizeof(__pyx_k__pixels), 0, 0, 1, 1},
  {&__pyx_n_s__pos, __pyx_k__pos, sizeof(__pyx_k__pos), 0, 0, 1, 1},
  {&__pyx_n_s__pvrtc_, __pyx_k__pvrtc_, sizeof(__pyx_k__pvrtc_), 0, 0, 1, 1},
  {&__pyx_n_s__pvrtc_rgb2, __pyx_k__pvrtc_rgb2, sizeof(__pyx_k__pvrtc_rgb2), 0, 0, 1, 1},
  {&__pyx_n_s__pvrtc_rgb4, __pyx_k__pvrtc_rgb4, sizeof(__pyx_k__pvrtc_rgb4), 0, 0, 1, 1},
  {&__pyx_n_s__pvrtc_rgba2, __pyx_k__pvrtc_rgba2, sizeof(__pyx_k__pvrtc_rgba2), 0, 0, 1, 1},
  {&__pyx_n_s__pvrtc_rgba4, __pyx_k__pvrtc_rgba4, sizeof(__pyx_k__pvrtc_rgba4), 0, 0, 1, 1},
  {&__pyx_n_s__remove, __pyx_k__remove, sizeof(__pyx_k__remove), 0, 0, 1, 1},
  {&__pyx_n_s__repeat, __pyx_k__repeat, sizeof(__pyx_k__repeat), 0, 0, 1, 1},
  {&__pyx_n_s__rgb, __pyx_k__rgb, sizeof(__pyx_k__rgb), 0, 0, 1, 1},
  {&__pyx_n_s__rgba, __pyx_k__rgba, sizeof(__pyx_k__rgba), 0, 0, 1, 1},
  {&__pyx_n_s__s3tc_dxt, __pyx_k__s3tc_dxt, sizeof(__pyx_k__s3tc_dxt), 0, 0, 1, 1},
  {&__pyx_n_s__s3tc_dxt1, __pyx_k__s3tc_dxt1, sizeof(__pyx_k__s3tc_dxt1), 0, 0, 1, 1},
  {&__pyx_n_s__s3tc_dxt3, __pyx_k__s3tc_dxt3, sizeof(__pyx_k__s3tc_dxt3), 0, 0, 1, 1},
  {&__pyx_n_s__s3tc_dxt5, __pyx_k__s3tc_dxt5, sizeof(__pyx_k__s3tc_dxt5), 0, 0, 1, 1},
  {&__pyx_n_s__save, __pyx_k__save, sizeof(__pyx_k__save), 0, 0, 1, 1},
  {&__pyx_n_s__short, __pyx_k__short, sizeof(__pyx_k__short), 0, 0, 1, 1},
  {&__pyx_n_s__size, __pyx_k__size, sizeof(__pyx_k__size), 0, 0, 1, 1},
  {&__pyx_n_s__smb, __pyx_k__smb, sizeof(__pyx_k__smb), 0, 0, 1, 1},
  {&__pyx_n_s__source, __pyx_k__source, sizeof(__pyx_k__source), 0, 0, 1, 1},
  {&__pyx_n_s__split, __pyx_k__split, sizeof(__pyx_k__split), 0, 0, 1, 1},
  {&__pyx_n_s__staticmethod, __pyx_k__staticmethod, sizeof(__pyx_k__staticmethod), 0, 0, 1, 1},
  {&__pyx_n_s__target, __pyx_k__target, sizeof(__pyx_k__target), 0, 0, 1, 1},
  {&__pyx_n_s__tex_coords, __pyx_k__tex_coords, sizeof(__pyx_k__tex_coords), 0, 0, 1, 1},
  {&__pyx_n_s__texid, __pyx_k__texid, sizeof(__pyx_k__texid), 0, 0, 1, 1},
  {&__pyx_n_s__texture, __pyx_k__texture, sizeof(__pyx_k__texture), 0, 0, 1, 1},
  {&__pyx_n_s__texture_create, __pyx_k__texture_create, sizeof(__pyx_k__texture_create), 0, 0, 1, 1},
  {&__pyx_n_s__tostring, __pyx_k__tostring, sizeof(__pyx_k__tostring), 0, 0, 1, 1},
  {&__pyx_n_s__ubyte, __pyx_k__ubyte, sizeof(__pyx_k__ubyte), 0, 0, 1, 1},
  {&__pyx_n_s__uint, __pyx_k__uint, sizeof(__pyx_k__uint), 0, 0, 1, 1},
  {&__pyx_n_s__ushort, __pyx_k__ushort, sizeof(__pyx_k__ushort), 0, 0, 1, 1},
  {&__pyx_n_s__width, __pyx_k__width, sizeof(__pyx_k__width), 0, 0, 1, 1},
  {&__pyx_n_s__wrap, __pyx_k__wrap, sizeof(__pyx_k__wrap), 0, 0, 1, 1},
  {&__pyx_n_s__x, __pyx_k__x, sizeof(__pyx_k__x), 0, 0, 1, 1},
  {&__pyx_n_s__y, __pyx_k__y, sizeof(__pyx_k__y), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_staticmethod = __Pyx_GetBuiltinName(__pyx_n_s__staticmethod); if (!__pyx_builtin_staticmethod) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_KeyError = __Pyx_GetBuiltinName(__pyx_n_s__KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_Exception = __Pyx_GetBuiltinName(__pyx_n_s__Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_format = __Pyx_GetBuiltinName(__pyx_n_s__format); if (!__pyx_builtin_format) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s__id); if (!__pyx_builtin_id) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "kivy\graphics\texture.pyx":424
 *         ret_format = 'rgb'
 *         a = array('b', data)
 *         a[0::3], a[2::3] = a[2::3], a[0::3]             # <<<<<<<<<<<<<<
 *         ret_buffer = a.tostring()
 * 
 */
  __pyx_k_slice_8 = PySlice_New(__pyx_int_2, Py_None, __pyx_int_3); if (unlikely(!__pyx_k_slice_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_8);
  __Pyx_GIVEREF(__pyx_k_slice_8);
  __pyx_k_slice_9 = PySlice_New(__pyx_int_0, Py_None, __pyx_int_3); if (unlikely(!__pyx_k_slice_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_9);
  __Pyx_GIVEREF(__pyx_k_slice_9);
  __pyx_k_slice_10 = PySlice_New(__pyx_int_0, Py_None, __pyx_int_3); if (unlikely(!__pyx_k_slice_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_10);
  __Pyx_GIVEREF(__pyx_k_slice_10);
  __pyx_k_slice_11 = PySlice_New(__pyx_int_2, Py_None, __pyx_int_3); if (unlikely(!__pyx_k_slice_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_11);
  __Pyx_GIVEREF(__pyx_k_slice_11);

  /* "kivy\graphics\texture.pyx":431
 *         ret_format = 'rgba'
 *         a = array('b', data)
 *         a[0::4], a[2::4] = a[2::4], a[0::4]             # <<<<<<<<<<<<<<
 *         ret_buffer = a.tostring()
 * 
 */
  __pyx_k_slice_12 = PySlice_New(__pyx_int_2, Py_None, __pyx_int_4); if (unlikely(!__pyx_k_slice_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_12);
  __Pyx_GIVEREF(__pyx_k_slice_12);
  __pyx_k_slice_13 = PySlice_New(__pyx_int_0, Py_None, __pyx_int_4); if (unlikely(!__pyx_k_slice_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_13);
  __Pyx_GIVEREF(__pyx_k_slice_13);
  __pyx_k_slice_14 = PySlice_New(__pyx_int_0, Py_None, __pyx_int_4); if (unlikely(!__pyx_k_slice_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_14);
  __Pyx_GIVEREF(__pyx_k_slice_14);
  __pyx_k_slice_15 = PySlice_New(__pyx_int_2, Py_None, __pyx_int_4); if (unlikely(!__pyx_k_slice_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_15);
  __Pyx_GIVEREF(__pyx_k_slice_15);

  /* "kivy\graphics\texture.pyx":824
 *             bufferfmt = 'ubyte'
 *         if pos is None:
 *             pos = (0, 0)             # <<<<<<<<<<<<<<
 *         if size is None:
 *             size = self.size
 */
  __pyx_k_tuple_23 = PyTuple_Pack(2, __pyx_int_0, __pyx_int_0); if (unlikely(!__pyx_k_tuple_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_23);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_23));

  /* "kivy\graphics\texture.pyx":887
 *         else:
 *             source = self._source
 *             proto = source.split(':', 1)[0]             # <<<<<<<<<<<<<<
 *             if proto in ('http', 'https', 'ftp', 'smb'):
 *                 from kivy.loader import Loader
 */
  __pyx_k_tuple_25 = PyTuple_Pack(2, ((PyObject *)__pyx_kp_s_24), __pyx_int_1); if (unlikely(!__pyx_k_tuple_25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_25);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_25));

  /* "kivy\graphics\texture.pyx":1139
 *             self.flip_vertical()
 *             with fbo:
 *                 Color(1, 1, 1)             # <<<<<<<<<<<<<<
 *                 Rectangle(size=self.size, texture=self,
 *                         tex_coords=self.tex_coords)
 */
  __pyx_k_tuple_33 = PyTuple_Pack(3, __pyx_int_1, __pyx_int_1, __pyx_int_1); if (unlikely(!__pyx_k_tuple_33)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_33);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_33));

  /* "kivy\graphics\texture.pyx":1138
 *             fbo.clear()
 *             self.flip_vertical()
 *             with fbo:             # <<<<<<<<<<<<<<
 *                 Color(1, 1, 1)
 *                 Rectangle(size=self.size, texture=self,
 */
  __pyx_k_tuple_34 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_tuple_34)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_34);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_34));

  /* "kivy\graphics\texture.pyx":184
 * '''
 * 
 * __all__ = ('Texture', 'TextureRegion')             # <<<<<<<<<<<<<<
 * 
 * include "config.pxi"
 */
  __pyx_k_tuple_51 = PyTuple_Pack(2, ((PyObject *)__pyx_n_s__Texture), ((PyObject *)__pyx_n_s__TextureRegion)); if (unlikely(!__pyx_k_tuple_51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_51);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_51));

  /* "kivy\graphics\texture.pyx":511
 * 
 * 
 * def texture_create(size=None, colorfmt=None, bufferfmt=None, mipmap=False,             # <<<<<<<<<<<<<<
 *     callback=None):
 *     '''Create a texture based on size.
 */
  __pyx_k_tuple_56 = PyTuple_Pack(8, ((PyObject *)__pyx_n_s__size), ((PyObject *)__pyx_n_s__colorfmt), ((PyObject *)__pyx_n_s__bufferfmt), ((PyObject *)__pyx_n_s__mipmap), ((PyObject *)__pyx_n_s__callback), ((PyObject *)__pyx_n_s__width), ((PyObject *)__pyx_n_s__height), ((PyObject *)__pyx_n_s__allocate)); if (unlikely(!__pyx_k_tuple_56)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_56);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_56));
  __pyx_k_codeobj_57 = (PyObject*)__Pyx_PyCode_New(5, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_56, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_58, __pyx_n_s__texture_create, 511, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_57)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "kivy\graphics\texture.pyx":546
 * 
 * 
 * def texture_create_from_data(im, mipmap=False):             # <<<<<<<<<<<<<<
 *     '''Create a texture from an ImageData class
 *     '''
 */
  __pyx_k_tuple_60 = PyTuple_Pack(7, ((PyObject *)__pyx_n_s__im), ((PyObject *)__pyx_n_s__mipmap), ((PyObject *)__pyx_n_s__width), ((PyObject *)__pyx_n_s__height), ((PyObject *)__pyx_n_s__allocate), ((PyObject *)__pyx_n_s__no_blit), ((PyObject *)__pyx_n_s__texture)); if (unlikely(!__pyx_k_tuple_60)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_60);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_60));
  __pyx_k_codeobj_61 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_60, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_58, __pyx_n_s_62, 546, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_61)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC inittexture(void); /*proto*/
PyMODINIT_FUNC inittexture(void)
#else
PyMODINIT_FUNC PyInit_texture(void); /*proto*/
PyMODINIT_FUNC PyInit_texture(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  #if CYTHON_REFNANNY
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
      PyErr_Clear();
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
      if (!__Pyx_RefNanny)
          Py_FatalError("failed to import 'refnanny' module");
  }
  #endif
  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_texture(void)", 0);
  if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #ifdef __Pyx_CyFunction_USED
  if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("texture"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_50), 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_INCREF(__pyx_d);
  #if PY_MAJOR_VERSION >= 3
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (!PyDict_GetItemString(modules, "kivy.graphics.texture")) {
      if (unlikely(PyDict_SetItemString(modules, "kivy.graphics.texture", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
  }
  #endif
  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if CYTHON_COMPILING_IN_PYPY
  Py_INCREF(__pyx_b);
  #endif
  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Initialize various global constants etc. ---*/
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  if (__pyx_module_is_main_kivy__graphics__texture) {
    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  }
  /*--- Builtin init code ---*/
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Constants init code ---*/
  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  __pyx_v_4kivy_8graphics_7texture__gl_color_fmt = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4kivy_8graphics_7texture__gl_buffer_fmt = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4kivy_8graphics_7texture__gl_buffer_size = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4kivy_8graphics_7texture__gl_texture_min_filter = ((PyObject*)Py_None); Py_INCREF(Py_None);
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  __pyx_vtabptr_4kivy_8graphics_7texture_Texture = &__pyx_vtable_4kivy_8graphics_7texture_Texture;
  __pyx_vtable_4kivy_8graphics_7texture_Texture.update_tex_coords = (void (*)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *))__pyx_f_4kivy_8graphics_7texture_7Texture_update_tex_coords;
  __pyx_vtable_4kivy_8graphics_7texture_Texture.set_min_filter = (void (*)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, PyObject *))__pyx_f_4kivy_8graphics_7texture_7Texture_set_min_filter;
  __pyx_vtable_4kivy_8graphics_7texture_Texture.set_mag_filter = (void (*)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, PyObject *))__pyx_f_4kivy_8graphics_7texture_7Texture_set_mag_filter;
  __pyx_vtable_4kivy_8graphics_7texture_Texture.set_wrap = (void (*)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, PyObject *))__pyx_f_4kivy_8graphics_7texture_7Texture_set_wrap;
  __pyx_vtable_4kivy_8graphics_7texture_Texture.reload = (void (*)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *))__pyx_f_4kivy_8graphics_7texture_7Texture_reload;
  __pyx_vtable_4kivy_8graphics_7texture_Texture._reload_propagate = (void (*)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, struct __pyx_obj_4kivy_8graphics_7texture_Texture *))__pyx_f_4kivy_8graphics_7texture_7Texture__reload_propagate;
  __pyx_vtable_4kivy_8graphics_7texture_Texture.allocate = (void (*)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *))__pyx_f_4kivy_8graphics_7texture_7Texture_allocate;
  __pyx_vtable_4kivy_8graphics_7texture_Texture.flip_vertical = (PyObject *(*)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, int __pyx_skip_dispatch))__pyx_f_4kivy_8graphics_7texture_7Texture_flip_vertical;
  __pyx_vtable_4kivy_8graphics_7texture_Texture.get_region = (PyObject *(*)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4kivy_8graphics_7texture_7Texture_get_region;
  __pyx_vtable_4kivy_8graphics_7texture_Texture.bind = (PyObject *(*)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, int __pyx_skip_dispatch))__pyx_f_4kivy_8graphics_7texture_7Texture_bind;
  if (PyType_Ready(&__pyx_type_4kivy_8graphics_7texture_Texture) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4kivy_8graphics_7texture_Texture.tp_dict, __pyx_vtabptr_4kivy_8graphics_7texture_Texture) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Texture", (PyObject *)&__pyx_type_4kivy_8graphics_7texture_Texture) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 586; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_type_4kivy_8graphics_7texture_Texture.tp_weaklistoffset == 0) __pyx_type_4kivy_8graphics_7texture_Texture.tp_weaklistoffset = offsetof(struct __pyx_obj_4kivy_8graphics_7texture_Texture, __weakref__);
  __pyx_ptype_4kivy_8graphics_7texture_Texture = &__pyx_type_4kivy_8graphics_7texture_Texture;
  __pyx_vtabptr_4kivy_8graphics_7texture_TextureRegion = &__pyx_vtable_4kivy_8graphics_7texture_TextureRegion;
  __pyx_vtable_4kivy_8graphics_7texture_TextureRegion.__pyx_base = *__pyx_vtabptr_4kivy_8graphics_7texture_Texture;
  __pyx_vtable_4kivy_8graphics_7texture_TextureRegion.__pyx_base.reload = (void (*)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *))__pyx_f_4kivy_8graphics_7texture_13TextureRegion_reload;
  __pyx_vtable_4kivy_8graphics_7texture_TextureRegion.__pyx_base.bind = (PyObject *(*)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, int __pyx_skip_dispatch))__pyx_f_4kivy_8graphics_7texture_13TextureRegion_bind;
  __pyx_type_4kivy_8graphics_7texture_TextureRegion.tp_base = __pyx_ptype_4kivy_8graphics_7texture_Texture;
  if (PyType_Ready(&__pyx_type_4kivy_8graphics_7texture_TextureRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_4kivy_8graphics_7texture_TextureRegion.tp_dict, __pyx_vtabptr_4kivy_8graphics_7texture_TextureRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "TextureRegion", (PyObject *)&__pyx_type_4kivy_8graphics_7texture_TextureRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_type_4kivy_8graphics_7texture_TextureRegion.tp_weaklistoffset == 0) __pyx_type_4kivy_8graphics_7texture_TextureRegion.tp_weaklistoffset = offsetof(struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion, __pyx_base.__weakref__);
  __pyx_ptype_4kivy_8graphics_7texture_TextureRegion = &__pyx_type_4kivy_8graphics_7texture_TextureRegion;
  /*--- Type import code ---*/
  __pyx_ptype_4kivy_8graphics_6buffer_Buffer = __Pyx_ImportType("kivy.graphics.buffer", "Buffer", sizeof(struct __pyx_obj_4kivy_8graphics_6buffer_Buffer), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_6buffer_Buffer)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_6buffer_Buffer = (struct __pyx_vtabstruct_4kivy_8graphics_6buffer_Buffer*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_6buffer_Buffer->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_6buffer_Buffer)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_6vertex_VertexFormat = __Pyx_ImportType("kivy.graphics.vertex", "VertexFormat", sizeof(struct __pyx_obj_4kivy_8graphics_6vertex_VertexFormat), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_6vertex_VertexFormat)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_3vbo_VBO = __Pyx_ImportType("kivy.graphics.vbo", "VBO", sizeof(struct __pyx_obj_4kivy_8graphics_3vbo_VBO), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_3vbo_VBO)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_3vbo_VBO = (struct __pyx_vtabstruct_4kivy_8graphics_3vbo_VBO*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_3vbo_VBO->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_3vbo_VBO)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_3vbo_VertexBatch = __Pyx_ImportType("kivy.graphics.vbo", "VertexBatch", sizeof(struct __pyx_obj_4kivy_8graphics_3vbo_VertexBatch), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_3vbo_VertexBatch)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_3vbo_VertexBatch = (struct __pyx_vtabstruct_4kivy_8graphics_3vbo_VertexBatch*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_3vbo_VertexBatch->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_3vbo_VertexBatch)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_14transformation_Matrix = __Pyx_ImportType("kivy.graphics.transformation", "Matrix", sizeof(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_14transformation_Matrix)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_14transformation_Matrix = (struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_14transformation_Matrix->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_14transformation_Matrix)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_LineWidth = __Pyx_ImportType("kivy.graphics.context_instructions", "LineWidth", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_LineWidth), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_LineWidth)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_20context_instructions_LineWidth = (struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_LineWidth*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_20context_instructions_LineWidth->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_20context_instructions_LineWidth)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_Color = __Pyx_ImportType("kivy.graphics.context_instructions", "Color", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_Color), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_Color)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_20context_instructions_Color = (struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Color*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_20context_instructions_Color->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_20context_instructions_Color)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_BindTexture = __Pyx_ImportType("kivy.graphics.context_instructions", "BindTexture", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_BindTexture), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_BindTexture)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_20context_instructions_BindTexture = (struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_BindTexture*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_20context_instructions_BindTexture->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_20context_instructions_BindTexture)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_PushState = __Pyx_ImportType("kivy.graphics.context_instructions", "PushState", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_PushState), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_PushState)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_ChangeState = __Pyx_ImportType("kivy.graphics.context_instructions", "ChangeState", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_ChangeState), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_ChangeState)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_PopState = __Pyx_ImportType("kivy.graphics.context_instructions", "PopState", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_PopState), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_PopState)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_LoadIdentity = __Pyx_ImportType("kivy.graphics.context_instructions", "LoadIdentity", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_LoadIdentity), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_LoadIdentity)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_PushMatrix = __Pyx_ImportType("kivy.graphics.context_instructions", "PushMatrix", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_PushMatrix), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_PushMatrix)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_20context_instructions_PushMatrix = (struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_PushMatrix*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_20context_instructions_PushMatrix->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_20context_instructions_PushMatrix)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_PopMatrix = __Pyx_ImportType("kivy.graphics.context_instructions", "PopMatrix", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_PopMatrix), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_PopMatrix)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_20context_instructions_PopMatrix = (struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_PopMatrix*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_20context_instructions_PopMatrix->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_20context_instructions_PopMatrix)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_ApplyContextMatrix = __Pyx_ImportType("kivy.graphics.context_instructions", "ApplyContextMatrix", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_ApplyContextMatrix), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_ApplyContextMatrix)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_20context_instructions_ApplyContextMatrix = (struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_ApplyContextMatrix*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_20context_instructions_ApplyContextMatrix->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_20context_instructions_ApplyContextMatrix)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_UpdateNormalMatrix = __Pyx_ImportType("kivy.graphics.context_instructions", "UpdateNormalMatrix", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_UpdateNormalMatrix), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_UpdateNormalMatrix)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_20context_instructions_UpdateNormalMatrix = (struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_UpdateNormalMatrix*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_20context_instructions_UpdateNormalMatrix->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_20context_instructions_UpdateNormalMatrix)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_MatrixInstruction = __Pyx_ImportType("kivy.graphics.context_instructions", "MatrixInstruction", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_MatrixInstruction), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_MatrixInstruction)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_20context_instructions_MatrixInstruction = (struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_MatrixInstruction*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_20context_instructions_MatrixInstruction->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_20context_instructions_MatrixInstruction)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_Transform = __Pyx_ImportType("kivy.graphics.context_instructions", "Transform", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_Transform), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_Transform)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_20context_instructions_Transform = (struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Transform*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_20context_instructions_Transform->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_20context_instructions_Transform)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_Rotate = __Pyx_ImportType("kivy.graphics.context_instructions", "Rotate", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_Rotate), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_Rotate)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_20context_instructions_Rotate = (struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Rotate*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_20context_instructions_Rotate->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_20context_instructions_Rotate)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_Scale = __Pyx_ImportType("kivy.graphics.context_instructions", "Scale", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_Scale), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_Scale)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_20context_instructions_Scale = (struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Scale*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_20context_instructions_Scale->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_20context_instructions_Scale)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_Translate = __Pyx_ImportType("kivy.graphics.context_instructions", "Translate", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_Translate), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_Translate)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_20context_instructions_Translate = (struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Translate*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_20context_instructions_Translate->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_20context_instructions_Translate)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_8compiler_GraphicsCompiler = __Pyx_ImportType("kivy.graphics.compiler", "GraphicsCompiler", sizeof(struct __pyx_obj_4kivy_8graphics_8compiler_GraphicsCompiler), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_8compiler_GraphicsCompiler)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_8compiler_GraphicsCompiler = (struct __pyx_vtabstruct_4kivy_8graphics_8compiler_GraphicsCompiler*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_8compiler_GraphicsCompiler->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_8compiler_GraphicsCompiler)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_6shader_ShaderSource = __Pyx_ImportType("kivy.graphics.shader", "ShaderSource", sizeof(struct __pyx_obj_4kivy_8graphics_6shader_ShaderSource), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_6shader_ShaderSource)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_6shader_ShaderSource = (struct __pyx_vtabstruct_4kivy_8graphics_6shader_ShaderSource*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_6shader_ShaderSource->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_6shader_ShaderSource)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_6shader_Shader = __Pyx_ImportType("kivy.graphics.shader", "Shader", sizeof(struct __pyx_obj_4kivy_8graphics_6shader_Shader), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_6shader_Shader)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_6shader_Shader = (struct __pyx_vtabstruct_4kivy_8graphics_6shader_Shader*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_6shader_Shader->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_6shader_Shader)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_6_event_ObjectWithUid = __Pyx_ImportType("kivy._event", "ObjectWithUid", sizeof(struct __pyx_obj_4kivy_6_event_ObjectWithUid), 1); if (unlikely(!__pyx_ptype_4kivy_6_event_ObjectWithUid)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_6_event_EventDispatcher = __Pyx_ImportType("kivy._event", "EventDispatcher", sizeof(struct __pyx_obj_4kivy_6_event_EventDispatcher), 1); if (unlikely(!__pyx_ptype_4kivy_6_event_EventDispatcher)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_6_event_EventDispatcher = (struct __pyx_vtabstruct_4kivy_6_event_EventDispatcher*)__Pyx_GetVtable(__pyx_ptype_4kivy_6_event_EventDispatcher->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_6_event_EventDispatcher)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_12instructions_Instruction = __Pyx_ImportType("kivy.graphics.instructions", "Instruction", sizeof(struct __pyx_obj_4kivy_8graphics_12instructions_Instruction), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_12instructions_Instruction)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_12instructions_Instruction = (struct __pyx_vtabstruct_4kivy_8graphics_12instructions_Instruction*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_12instructions_Instruction->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_12instructions_Instruction)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_12instructions_InstructionGroup = __Pyx_ImportType("kivy.graphics.instructions", "InstructionGroup", sizeof(struct __pyx_obj_4kivy_8graphics_12instructions_InstructionGroup), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_12instructions_InstructionGroup)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_12instructions_InstructionGroup = (struct __pyx_vtabstruct_4kivy_8graphics_12instructions_InstructionGroup*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_12instructions_InstructionGroup->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_12instructions_InstructionGroup)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_12instructions_ContextInstruction = __Pyx_ImportType("kivy.graphics.instructions", "ContextInstruction", sizeof(struct __pyx_obj_4kivy_8graphics_12instructions_ContextInstruction), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_12instructions_ContextInstruction)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_12instructions_ContextInstruction = (struct __pyx_vtabstruct_4kivy_8graphics_12instructions_ContextInstruction*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_12instructions_ContextInstruction->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_12instructions_ContextInstruction)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_12instructions_VertexInstruction = __Pyx_ImportType("kivy.graphics.instructions", "VertexInstruction", sizeof(struct __pyx_obj_4kivy_8graphics_12instructions_VertexInstruction), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_12instructions_VertexInstruction)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_12instructions_VertexInstruction = (struct __pyx_vtabstruct_4kivy_8graphics_12instructions_VertexInstruction*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_12instructions_VertexInstruction->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_12instructions_VertexInstruction)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_12instructions_CanvasBase = __Pyx_ImportType("kivy.graphics.instructions", "CanvasBase", sizeof(struct __pyx_obj_4kivy_8graphics_12instructions_CanvasBase), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_12instructions_CanvasBase)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_12instructions_CanvasBase = (struct __pyx_vtabstruct_4kivy_8graphics_12instructions_CanvasBase*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_12instructions_CanvasBase->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_12instructions_CanvasBase)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_12instructions_Canvas = __Pyx_ImportType("kivy.graphics.instructions", "Canvas", sizeof(struct __pyx_obj_4kivy_8graphics_12instructions_Canvas), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_12instructions_Canvas)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_12instructions_Canvas = (struct __pyx_vtabstruct_4kivy_8graphics_12instructions_Canvas*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_12instructions_Canvas->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_12instructions_Canvas)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_12instructions_RenderContext = __Pyx_ImportType("kivy.graphics.instructions", "RenderContext", sizeof(struct __pyx_obj_4kivy_8graphics_12instructions_RenderContext), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_12instructions_RenderContext)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_12instructions_RenderContext = (struct __pyx_vtabstruct_4kivy_8graphics_12instructions_RenderContext*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_12instructions_RenderContext->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_12instructions_RenderContext)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_12instructions_Callback = __Pyx_ImportType("kivy.graphics.instructions", "Callback", sizeof(struct __pyx_obj_4kivy_8graphics_12instructions_Callback), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_12instructions_Callback)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_12instructions_Callback = (struct __pyx_vtabstruct_4kivy_8graphics_12instructions_Callback*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_12instructions_Callback->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_12instructions_Callback)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_3fbo_Fbo = __Pyx_ImportType("kivy.graphics.fbo", "Fbo", sizeof(struct __pyx_obj_4kivy_8graphics_3fbo_Fbo), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_3fbo_Fbo)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_3fbo_Fbo = (struct __pyx_vtabstruct_4kivy_8graphics_3fbo_Fbo*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_3fbo_Fbo->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_3fbo_Fbo)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_7context_Context = __Pyx_ImportType("kivy.graphics.context", "Context", sizeof(struct __pyx_obj_4kivy_8graphics_7context_Context), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_7context_Context)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_7context_Context = (struct __pyx_vtabstruct_4kivy_8graphics_7context_Context*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_7context_Context->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_7context_Context)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Variable import code ---*/
  __pyx_t_1 = __Pyx_ImportModule("kivy.graphics.vbo"); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportVoidPtr(__pyx_t_1, "default_vertex", (void **)&__pyx_vp_4kivy_8graphics_3vbo_default_vertex, "struct __pyx_obj_4kivy_8graphics_6vertex_VertexFormat *") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  /*--- Function import code ---*/
  __pyx_t_2 = __Pyx_ImportModule("kivy.graphics.context"); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_2, "get_context", (void (**)(void))&__pyx_f_4kivy_8graphics_7context_get_context, "struct __pyx_obj_4kivy_8graphics_7context_Context *(int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_ImportModule("kivy.graphics.opengl_utils"); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_3, "gl_has_capability", (void (**)(void))&__pyx_f_4kivy_8graphics_12opengl_utils_gl_has_capability, "int (int, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_3, "gl_has_texture_native_format", (void (**)(void))&__pyx_f_4kivy_8graphics_12opengl_utils_gl_has_texture_native_format, "int (PyObject *, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_3, "gl_has_texture_conversion", (void (**)(void))&__pyx_f_4kivy_8graphics_12opengl_utils_gl_has_texture_conversion, "int (PyObject *, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  /*--- Execution code ---*/

  /* "kivy\graphics\texture.pyx":184
 * '''
 * 
 * __all__ = ('Texture', 'TextureRegion')             # <<<<<<<<<<<<<<
 * 
 * include "config.pxi"
 */
  if (PyDict_SetItem(__pyx_d, __pyx_n_s____all__, ((PyObject *)__pyx_k_tuple_51)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "c:\Users\tito\Desktop\Kivy-dev\kivy\Kivy-1.7.2-w32\Kivy-1.7.2\kivy\graphics\common.pxi":11
 *     ctypedef char* const_char_ptr "const char*"
 * 
 * cdef double pi = PI             # <<<<<<<<<<<<<<
 * cdef extern from "math.h":
 *     double cos(double) nogil
 */
  __pyx_v_4kivy_8graphics_7texture_pi = 3.141592653589793;

  /* "c:\Users\tito\Desktop\Kivy-dev\kivy\Kivy-1.7.2-w32\Kivy-1.7.2\kivy\graphics\opengl_utils_def.pxi":2
 * # c definition
 * cdef int c_GLCAP_BGRA = 0x0001             # <<<<<<<<<<<<<<
 * cdef int c_GLCAP_NPOT = 0x0002
 * cdef int c_GLCAP_S3TC = 0x0003
 */
  __pyx_v_4kivy_8graphics_7texture_c_GLCAP_BGRA = 0x0001;

  /* "c:\Users\tito\Desktop\Kivy-dev\kivy\Kivy-1.7.2-w32\Kivy-1.7.2\kivy\graphics\opengl_utils_def.pxi":3
 * # c definition
 * cdef int c_GLCAP_BGRA = 0x0001
 * cdef int c_GLCAP_NPOT = 0x0002             # <<<<<<<<<<<<<<
 * cdef int c_GLCAP_S3TC = 0x0003
 * cdef int c_GLCAP_DXT1 = 0x0004
 */
  __pyx_v_4kivy_8graphics_7texture_c_GLCAP_NPOT = 0x0002;

  /* "c:\Users\tito\Desktop\Kivy-dev\kivy\Kivy-1.7.2-w32\Kivy-1.7.2\kivy\graphics\opengl_utils_def.pxi":4
 * cdef int c_GLCAP_BGRA = 0x0001
 * cdef int c_GLCAP_NPOT = 0x0002
 * cdef int c_GLCAP_S3TC = 0x0003             # <<<<<<<<<<<<<<
 * cdef int c_GLCAP_DXT1 = 0x0004
 * cdef int c_GLCAP_PVRTC = 0x0005
 */
  __pyx_v_4kivy_8graphics_7texture_c_GLCAP_S3TC = 0x0003;

  /* "c:\Users\tito\Desktop\Kivy-dev\kivy\Kivy-1.7.2-w32\Kivy-1.7.2\kivy\graphics\opengl_utils_def.pxi":5
 * cdef int c_GLCAP_NPOT = 0x0002
 * cdef int c_GLCAP_S3TC = 0x0003
 * cdef int c_GLCAP_DXT1 = 0x0004             # <<<<<<<<<<<<<<
 * cdef int c_GLCAP_PVRTC = 0x0005
 * cdef int c_GLCAP_ETC1 = 0x0006
 */
  __pyx_v_4kivy_8graphics_7texture_c_GLCAP_DXT1 = 0x0004;

  /* "c:\Users\tito\Desktop\Kivy-dev\kivy\Kivy-1.7.2-w32\Kivy-1.7.2\kivy\graphics\opengl_utils_def.pxi":6
 * cdef int c_GLCAP_S3TC = 0x0003
 * cdef int c_GLCAP_DXT1 = 0x0004
 * cdef int c_GLCAP_PVRTC = 0x0005             # <<<<<<<<<<<<<<
 * cdef int c_GLCAP_ETC1 = 0x0006
 * 
 */
  __pyx_v_4kivy_8graphics_7texture_c_GLCAP_PVRTC = 0x0005;

  /* "c:\Users\tito\Desktop\Kivy-dev\kivy\Kivy-1.7.2-w32\Kivy-1.7.2\kivy\graphics\opengl_utils_def.pxi":7
 * cdef int c_GLCAP_DXT1 = 0x0004
 * cdef int c_GLCAP_PVRTC = 0x0005
 * cdef int c_GLCAP_ETC1 = 0x0006             # <<<<<<<<<<<<<<
 * 
 * # for python export
 */
  __pyx_v_4kivy_8graphics_7texture_c_GLCAP_ETC1 = 0x0006;

  /* "c:\Users\tito\Desktop\Kivy-dev\kivy\Kivy-1.7.2-w32\Kivy-1.7.2\kivy\graphics\opengl_utils_def.pxi":10
 * 
 * # for python export
 * GLCAP_BGRA = c_GLCAP_NPOT             # <<<<<<<<<<<<<<
 * GLCAP_NPOT = c_GLCAP_NPOT
 * GLCAP_S3TC = c_GLCAP_S3TC
 */
  __pyx_t_4 = PyInt_FromLong(__pyx_v_4kivy_8graphics_7texture_c_GLCAP_NPOT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s__GLCAP_BGRA, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "c:\Users\tito\Desktop\Kivy-dev\kivy\Kivy-1.7.2-w32\Kivy-1.7.2\kivy\graphics\opengl_utils_def.pxi":11
 * # for python export
 * GLCAP_BGRA = c_GLCAP_NPOT
 * GLCAP_NPOT = c_GLCAP_NPOT             # <<<<<<<<<<<<<<
 * GLCAP_S3TC = c_GLCAP_S3TC
 * GLCAP_DXT1 = c_GLCAP_DXT1
 */
  __pyx_t_4 = PyInt_FromLong(__pyx_v_4kivy_8graphics_7texture_c_GLCAP_NPOT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s__GLCAP_NPOT, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "c:\Users\tito\Desktop\Kivy-dev\kivy\Kivy-1.7.2-w32\Kivy-1.7.2\kivy\graphics\opengl_utils_def.pxi":12
 * GLCAP_BGRA = c_GLCAP_NPOT
 * GLCAP_NPOT = c_GLCAP_NPOT
 * GLCAP_S3TC = c_GLCAP_S3TC             # <<<<<<<<<<<<<<
 * GLCAP_DXT1 = c_GLCAP_DXT1
 * GLCAP_PVRTC = c_GLCAP_PVRTC
 */
  __pyx_t_4 = PyInt_FromLong(__pyx_v_4kivy_8graphics_7texture_c_GLCAP_S3TC); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s__GLCAP_S3TC, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "c:\Users\tito\Desktop\Kivy-dev\kivy\Kivy-1.7.2-w32\Kivy-1.7.2\kivy\graphics\opengl_utils_def.pxi":13
 * GLCAP_NPOT = c_GLCAP_NPOT
 * GLCAP_S3TC = c_GLCAP_S3TC
 * GLCAP_DXT1 = c_GLCAP_DXT1             # <<<<<<<<<<<<<<
 * GLCAP_PVRTC = c_GLCAP_PVRTC
 * GLCAP_ETC1 = c_GLCAP_ETC1
 */
  __pyx_t_4 = PyInt_FromLong(__pyx_v_4kivy_8graphics_7texture_c_GLCAP_DXT1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s__GLCAP_DXT1, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "c:\Users\tito\Desktop\Kivy-dev\kivy\Kivy-1.7.2-w32\Kivy-1.7.2\kivy\graphics\opengl_utils_def.pxi":14
 * GLCAP_S3TC = c_GLCAP_S3TC
 * GLCAP_DXT1 = c_GLCAP_DXT1
 * GLCAP_PVRTC = c_GLCAP_PVRTC             # <<<<<<<<<<<<<<
 * GLCAP_ETC1 = c_GLCAP_ETC1
 */
  __pyx_t_4 = PyInt_FromLong(__pyx_v_4kivy_8graphics_7texture_c_GLCAP_PVRTC); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s__GLCAP_PVRTC, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "c:\Users\tito\Desktop\Kivy-dev\kivy\Kivy-1.7.2-w32\Kivy-1.7.2\kivy\graphics\opengl_utils_def.pxi":15
 * GLCAP_DXT1 = c_GLCAP_DXT1
 * GLCAP_PVRTC = c_GLCAP_PVRTC
 * GLCAP_ETC1 = c_GLCAP_ETC1             # <<<<<<<<<<<<<<
 */
  __pyx_t_4 = PyInt_FromLong(__pyx_v_4kivy_8graphics_7texture_c_GLCAP_ETC1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s__GLCAP_ETC1, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":190
 * include "opengl_utils_def.pxi"
 * 
 * from array import array             # <<<<<<<<<<<<<<
 * from kivy.weakmethod import WeakMethod
 * from kivy.graphics.context cimport get_context
 */
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__array));
  PyList_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_n_s__array));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__array));
  __pyx_t_5 = __Pyx_Import(((PyObject *)__pyx_n_s__array), ((PyObject *)__pyx_t_4), -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_5, __pyx_n_s__array); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s__array, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":191
 * 
 * from array import array
 * from kivy.weakmethod import WeakMethod             # <<<<<<<<<<<<<<
 * from kivy.graphics.context cimport get_context
 * 
 */
  __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__WeakMethod));
  PyList_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_n_s__WeakMethod));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__WeakMethod));
  __pyx_t_4 = __Pyx_Import(((PyObject *)__pyx_n_s_52), ((PyObject *)__pyx_t_5), -1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s__WeakMethod); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s__WeakMethod, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":200
 * 
 * # update flags
 * cdef int TI_MIN_FILTER      = 1 << 0             # <<<<<<<<<<<<<<
 * cdef int TI_MAG_FILTER      = 1 << 1
 * cdef int TI_WRAP            = 1 << 2
 */
  __pyx_v_4kivy_8graphics_7texture_TI_MIN_FILTER = 1;

  /* "kivy\graphics\texture.pyx":201
 * # update flags
 * cdef int TI_MIN_FILTER      = 1 << 0
 * cdef int TI_MAG_FILTER      = 1 << 1             # <<<<<<<<<<<<<<
 * cdef int TI_WRAP            = 1 << 2
 * cdef int TI_NEED_GEN        = 1 << 3
 */
  __pyx_v_4kivy_8graphics_7texture_TI_MAG_FILTER = 2;

  /* "kivy\graphics\texture.pyx":202
 * cdef int TI_MIN_FILTER      = 1 << 0
 * cdef int TI_MAG_FILTER      = 1 << 1
 * cdef int TI_WRAP            = 1 << 2             # <<<<<<<<<<<<<<
 * cdef int TI_NEED_GEN        = 1 << 3
 * cdef int TI_NEED_ALLOCATE   = 1 << 4
 */
  __pyx_v_4kivy_8graphics_7texture_TI_WRAP = 4;

  /* "kivy\graphics\texture.pyx":203
 * cdef int TI_MAG_FILTER      = 1 << 1
 * cdef int TI_WRAP            = 1 << 2
 * cdef int TI_NEED_GEN        = 1 << 3             # <<<<<<<<<<<<<<
 * cdef int TI_NEED_ALLOCATE   = 1 << 4
 * cdef int TI_NEED_PIXELS     = 1 << 5
 */
  __pyx_v_4kivy_8graphics_7texture_TI_NEED_GEN = 8;

  /* "kivy\graphics\texture.pyx":204
 * cdef int TI_WRAP            = 1 << 2
 * cdef int TI_NEED_GEN        = 1 << 3
 * cdef int TI_NEED_ALLOCATE   = 1 << 4             # <<<<<<<<<<<<<<
 * cdef int TI_NEED_PIXELS     = 1 << 5
 * 
 */
  __pyx_v_4kivy_8graphics_7texture_TI_NEED_ALLOCATE = 16;

  /* "kivy\graphics\texture.pyx":205
 * cdef int TI_NEED_GEN        = 1 << 3
 * cdef int TI_NEED_ALLOCATE   = 1 << 4
 * cdef int TI_NEED_PIXELS     = 1 << 5             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_4kivy_8graphics_7texture_TI_NEED_PIXELS = 32;

  /* "kivy\graphics\texture.pyx":209
 * 
 * # compatibility layer
 * cdef GLuint GL_BGR = 0x80E0             # <<<<<<<<<<<<<<
 * cdef GLuint GL_BGRA = 0x80E1
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1
 */
  __pyx_v_4kivy_8graphics_7texture_GL_BGR = 0x80E0;

  /* "kivy\graphics\texture.pyx":210
 * # compatibility layer
 * cdef GLuint GL_BGR = 0x80E0
 * cdef GLuint GL_BGRA = 0x80E1             # <<<<<<<<<<<<<<
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2
 */
  __pyx_v_4kivy_8graphics_7texture_GL_BGRA = 0x80E1;

  /* "kivy\graphics\texture.pyx":211
 * cdef GLuint GL_BGR = 0x80E0
 * cdef GLuint GL_BGRA = 0x80E1
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1             # <<<<<<<<<<<<<<
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3
 */
  __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1;

  /* "kivy\graphics\texture.pyx":212
 * cdef GLuint GL_BGRA = 0x80E1
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2             # <<<<<<<<<<<<<<
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3
 * cdef GLuint GL_ETC1_RGB8_OES = 0x8D64
 */
  __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2;

  /* "kivy\graphics\texture.pyx":213
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3             # <<<<<<<<<<<<<<
 * cdef GLuint GL_ETC1_RGB8_OES = 0x8D64
 * cdef GLuint GL_PALETTE4_RGB8_OES = 0x8B90
 */
  __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3;

  /* "kivy\graphics\texture.pyx":214
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3
 * cdef GLuint GL_ETC1_RGB8_OES = 0x8D64             # <<<<<<<<<<<<<<
 * cdef GLuint GL_PALETTE4_RGB8_OES = 0x8B90
 * cdef GLuint GL_PALETTE4_RGBA8_OES = 0x8B91
 */
  __pyx_v_4kivy_8graphics_7texture_GL_ETC1_RGB8_OES = 0x8D64;

  /* "kivy\graphics\texture.pyx":215
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3
 * cdef GLuint GL_ETC1_RGB8_OES = 0x8D64
 * cdef GLuint GL_PALETTE4_RGB8_OES = 0x8B90             # <<<<<<<<<<<<<<
 * cdef GLuint GL_PALETTE4_RGBA8_OES = 0x8B91
 * cdef GLuint GL_PALETTE4_R5_G6_B5_OES = 0x8B92
 */
  __pyx_v_4kivy_8graphics_7texture_GL_PALETTE4_RGB8_OES = 0x8B90;

  /* "kivy\graphics\texture.pyx":216
 * cdef GLuint GL_ETC1_RGB8_OES = 0x8D64
 * cdef GLuint GL_PALETTE4_RGB8_OES = 0x8B90
 * cdef GLuint GL_PALETTE4_RGBA8_OES = 0x8B91             # <<<<<<<<<<<<<<
 * cdef GLuint GL_PALETTE4_R5_G6_B5_OES = 0x8B92
 * cdef GLuint GL_PALETTE4_RGBA4_OES = 0x8B93
 */
  __pyx_v_4kivy_8graphics_7texture_GL_PALETTE4_RGBA8_OES = 0x8B91;

  /* "kivy\graphics\texture.pyx":217
 * cdef GLuint GL_PALETTE4_RGB8_OES = 0x8B90
 * cdef GLuint GL_PALETTE4_RGBA8_OES = 0x8B91
 * cdef GLuint GL_PALETTE4_R5_G6_B5_OES = 0x8B92             # <<<<<<<<<<<<<<
 * cdef GLuint GL_PALETTE4_RGBA4_OES = 0x8B93
 * cdef GLuint GL_PALETTE4_RGB5_A1_OES = 0x8B94
 */
  __pyx_v_4kivy_8graphics_7texture_GL_PALETTE4_R5_G6_B5_OES = 0x8B92;

  /* "kivy\graphics\texture.pyx":218
 * cdef GLuint GL_PALETTE4_RGBA8_OES = 0x8B91
 * cdef GLuint GL_PALETTE4_R5_G6_B5_OES = 0x8B92
 * cdef GLuint GL_PALETTE4_RGBA4_OES = 0x8B93             # <<<<<<<<<<<<<<
 * cdef GLuint GL_PALETTE4_RGB5_A1_OES = 0x8B94
 * cdef GLuint GL_PALETTE8_RGB8_OES = 0x8B95
 */
  __pyx_v_4kivy_8graphics_7texture_GL_PALETTE4_RGBA4_OES = 0x8B93;

  /* "kivy\graphics\texture.pyx":219
 * cdef GLuint GL_PALETTE4_R5_G6_B5_OES = 0x8B92
 * cdef GLuint GL_PALETTE4_RGBA4_OES = 0x8B93
 * cdef GLuint GL_PALETTE4_RGB5_A1_OES = 0x8B94             # <<<<<<<<<<<<<<
 * cdef GLuint GL_PALETTE8_RGB8_OES = 0x8B95
 * cdef GLuint GL_PALETTE8_RGBA8_OES = 0x8B96
 */
  __pyx_v_4kivy_8graphics_7texture_GL_PALETTE4_RGB5_A1_OES = 0x8B94;

  /* "kivy\graphics\texture.pyx":220
 * cdef GLuint GL_PALETTE4_RGBA4_OES = 0x8B93
 * cdef GLuint GL_PALETTE4_RGB5_A1_OES = 0x8B94
 * cdef GLuint GL_PALETTE8_RGB8_OES = 0x8B95             # <<<<<<<<<<<<<<
 * cdef GLuint GL_PALETTE8_RGBA8_OES = 0x8B96
 * cdef GLuint GL_PALETTE8_R5_G6_B5_OES = 0x8B97
 */
  __pyx_v_4kivy_8graphics_7texture_GL_PALETTE8_RGB8_OES = 0x8B95;

  /* "kivy\graphics\texture.pyx":221
 * cdef GLuint GL_PALETTE4_RGB5_A1_OES = 0x8B94
 * cdef GLuint GL_PALETTE8_RGB8_OES = 0x8B95
 * cdef GLuint GL_PALETTE8_RGBA8_OES = 0x8B96             # <<<<<<<<<<<<<<
 * cdef GLuint GL_PALETTE8_R5_G6_B5_OES = 0x8B97
 * cdef GLuint GL_PALETTE8_RGBA4_OES = 0x8B98
 */
  __pyx_v_4kivy_8graphics_7texture_GL_PALETTE8_RGBA8_OES = 0x8B96;

  /* "kivy\graphics\texture.pyx":222
 * cdef GLuint GL_PALETTE8_RGB8_OES = 0x8B95
 * cdef GLuint GL_PALETTE8_RGBA8_OES = 0x8B96
 * cdef GLuint GL_PALETTE8_R5_G6_B5_OES = 0x8B97             # <<<<<<<<<<<<<<
 * cdef GLuint GL_PALETTE8_RGBA4_OES = 0x8B98
 * cdef GLuint GL_PALETTE8_RGB5_A1_OES = 0x8B99
 */
  __pyx_v_4kivy_8graphics_7texture_GL_PALETTE8_R5_G6_B5_OES = 0x8B97;

  /* "kivy\graphics\texture.pyx":223
 * cdef GLuint GL_PALETTE8_RGBA8_OES = 0x8B96
 * cdef GLuint GL_PALETTE8_R5_G6_B5_OES = 0x8B97
 * cdef GLuint GL_PALETTE8_RGBA4_OES = 0x8B98             # <<<<<<<<<<<<<<
 * cdef GLuint GL_PALETTE8_RGB5_A1_OES = 0x8B99
 * cdef GLuint GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00
 */
  __pyx_v_4kivy_8graphics_7texture_GL_PALETTE8_RGBA4_OES = 0x8B98;

  /* "kivy\graphics\texture.pyx":224
 * cdef GLuint GL_PALETTE8_R5_G6_B5_OES = 0x8B97
 * cdef GLuint GL_PALETTE8_RGBA4_OES = 0x8B98
 * cdef GLuint GL_PALETTE8_RGB5_A1_OES = 0x8B99             # <<<<<<<<<<<<<<
 * cdef GLuint GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00
 * cdef GLuint GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01
 */
  __pyx_v_4kivy_8graphics_7texture_GL_PALETTE8_RGB5_A1_OES = 0x8B99;

  /* "kivy\graphics\texture.pyx":225
 * cdef GLuint GL_PALETTE8_RGBA4_OES = 0x8B98
 * cdef GLuint GL_PALETTE8_RGB5_A1_OES = 0x8B99
 * cdef GLuint GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00             # <<<<<<<<<<<<<<
 * cdef GLuint GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01
 * cdef GLuint GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02
 */
  __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00;

  /* "kivy\graphics\texture.pyx":226
 * cdef GLuint GL_PALETTE8_RGB5_A1_OES = 0x8B99
 * cdef GLuint GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00
 * cdef GLuint GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01             # <<<<<<<<<<<<<<
 * cdef GLuint GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02
 * cdef GLuint GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03
 */
  __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01;

  /* "kivy\graphics\texture.pyx":227
 * cdef GLuint GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00
 * cdef GLuint GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01
 * cdef GLuint GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02             # <<<<<<<<<<<<<<
 * cdef GLuint GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03
 * 
 */
  __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02;

  /* "kivy\graphics\texture.pyx":228
 * cdef GLuint GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01
 * cdef GLuint GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02
 * cdef GLuint GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03;

  /* "kivy\graphics\texture.pyx":231
 * 
 * 
 * cdef dict _gl_color_fmt = {             # <<<<<<<<<<<<<<
 *     'rgba': GL_RGBA, 'bgra': GL_BGRA, 'rgb': GL_RGB, 'bgr': GL_BGR,
 *     'luminance': GL_LUMINANCE, 'luminance_alpha': GL_LUMINANCE_ALPHA,
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));

  /* "kivy\graphics\texture.pyx":232
 * 
 * cdef dict _gl_color_fmt = {
 *     'rgba': GL_RGBA, 'bgra': GL_BGRA, 'rgb': GL_RGB, 'bgr': GL_BGR,             # <<<<<<<<<<<<<<
 *     'luminance': GL_LUMINANCE, 'luminance_alpha': GL_LUMINANCE_ALPHA,
 *     's3tc_dxt1': GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
 */
  __pyx_t_5 = PyInt_FromLong(GL_RGBA); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__rgba), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_BGRA); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__bgra), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyInt_FromLong(GL_RGB); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__rgb), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_BGR); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__bgr), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":233
 * cdef dict _gl_color_fmt = {
 *     'rgba': GL_RGBA, 'bgra': GL_BGRA, 'rgb': GL_RGB, 'bgr': GL_BGR,
 *     'luminance': GL_LUMINANCE, 'luminance_alpha': GL_LUMINANCE_ALPHA,             # <<<<<<<<<<<<<<
 *     's3tc_dxt1': GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
 *     's3tc_dxt3': GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
 */
  __pyx_t_5 = PyInt_FromLong(GL_LUMINANCE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__luminance), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyInt_FromLong(GL_LUMINANCE_ALPHA); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__luminance_alpha), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":234
 *     'rgba': GL_RGBA, 'bgra': GL_BGRA, 'rgb': GL_RGB, 'bgr': GL_BGR,
 *     'luminance': GL_LUMINANCE, 'luminance_alpha': GL_LUMINANCE_ALPHA,
 *     's3tc_dxt1': GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,             # <<<<<<<<<<<<<<
 *     's3tc_dxt3': GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
 *     's3tc_dxt5': GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
 */
  __pyx_t_5 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__s3tc_dxt1), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":235
 *     'luminance': GL_LUMINANCE, 'luminance_alpha': GL_LUMINANCE_ALPHA,
 *     's3tc_dxt1': GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
 *     's3tc_dxt3': GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,             # <<<<<<<<<<<<<<
 *     's3tc_dxt5': GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
 *     'etc1_rgb8': GL_ETC1_RGB8_OES,
 */
  __pyx_t_5 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__s3tc_dxt3), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":236
 *     's3tc_dxt1': GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
 *     's3tc_dxt3': GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
 *     's3tc_dxt5': GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,             # <<<<<<<<<<<<<<
 *     'etc1_rgb8': GL_ETC1_RGB8_OES,
 *     'palette4_rgb8': GL_PALETTE4_RGB8_OES,
 */
  __pyx_t_5 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__s3tc_dxt5), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":237
 *     's3tc_dxt3': GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
 *     's3tc_dxt5': GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
 *     'etc1_rgb8': GL_ETC1_RGB8_OES,             # <<<<<<<<<<<<<<
 *     'palette4_rgb8': GL_PALETTE4_RGB8_OES,
 *     'palette4_rgba8': GL_PALETTE4_RGBA8_OES,
 */
  __pyx_t_5 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_ETC1_RGB8_OES); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__etc1_rgb8), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":238
 *     's3tc_dxt5': GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
 *     'etc1_rgb8': GL_ETC1_RGB8_OES,
 *     'palette4_rgb8': GL_PALETTE4_RGB8_OES,             # <<<<<<<<<<<<<<
 *     'palette4_rgba8': GL_PALETTE4_RGBA8_OES,
 *     'palette4_r5_g6_b5': GL_PALETTE4_R5_G6_B5_OES,
 */
  __pyx_t_5 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_PALETTE4_RGB8_OES); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__palette4_rgb8), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":239
 *     'etc1_rgb8': GL_ETC1_RGB8_OES,
 *     'palette4_rgb8': GL_PALETTE4_RGB8_OES,
 *     'palette4_rgba8': GL_PALETTE4_RGBA8_OES,             # <<<<<<<<<<<<<<
 *     'palette4_r5_g6_b5': GL_PALETTE4_R5_G6_B5_OES,
 *     'palette4_rgba4': GL_PALETTE4_RGBA4_OES,
 */
  __pyx_t_5 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_PALETTE4_RGBA8_OES); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__palette4_rgba8), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":240
 *     'palette4_rgb8': GL_PALETTE4_RGB8_OES,
 *     'palette4_rgba8': GL_PALETTE4_RGBA8_OES,
 *     'palette4_r5_g6_b5': GL_PALETTE4_R5_G6_B5_OES,             # <<<<<<<<<<<<<<
 *     'palette4_rgba4': GL_PALETTE4_RGBA4_OES,
 *     'palette4_rgb5_a1': GL_PALETTE4_RGB5_A1_OES,
 */
  __pyx_t_5 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_PALETTE4_R5_G6_B5_OES); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__palette4_r5_g6_b5), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":241
 *     'palette4_rgba8': GL_PALETTE4_RGBA8_OES,
 *     'palette4_r5_g6_b5': GL_PALETTE4_R5_G6_B5_OES,
 *     'palette4_rgba4': GL_PALETTE4_RGBA4_OES,             # <<<<<<<<<<<<<<
 *     'palette4_rgb5_a1': GL_PALETTE4_RGB5_A1_OES,
 *     'palette8_rgb8': GL_PALETTE8_RGB8_OES,
 */
  __pyx_t_5 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_PALETTE4_RGBA4_OES); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__palette4_rgba4), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":242
 *     'palette4_r5_g6_b5': GL_PALETTE4_R5_G6_B5_OES,
 *     'palette4_rgba4': GL_PALETTE4_RGBA4_OES,
 *     'palette4_rgb5_a1': GL_PALETTE4_RGB5_A1_OES,             # <<<<<<<<<<<<<<
 *     'palette8_rgb8': GL_PALETTE8_RGB8_OES,
 *     'palette8_rgba8': GL_PALETTE8_RGBA8_OES,
 */
  __pyx_t_5 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_PALETTE4_RGB5_A1_OES); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__palette4_rgb5_a1), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":243
 *     'palette4_rgba4': GL_PALETTE4_RGBA4_OES,
 *     'palette4_rgb5_a1': GL_PALETTE4_RGB5_A1_OES,
 *     'palette8_rgb8': GL_PALETTE8_RGB8_OES,             # <<<<<<<<<<<<<<
 *     'palette8_rgba8': GL_PALETTE8_RGBA8_OES,
 *     'palette8_r5_g6_b5': GL_PALETTE8_R5_G6_B5_OES,
 */
  __pyx_t_5 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_PALETTE8_RGB8_OES); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__palette8_rgb8), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":244
 *     'palette4_rgb5_a1': GL_PALETTE4_RGB5_A1_OES,
 *     'palette8_rgb8': GL_PALETTE8_RGB8_OES,
 *     'palette8_rgba8': GL_PALETTE8_RGBA8_OES,             # <<<<<<<<<<<<<<
 *     'palette8_r5_g6_b5': GL_PALETTE8_R5_G6_B5_OES,
 *     'palette8_rgba4': GL_PALETTE8_RGBA4_OES,
 */
  __pyx_t_5 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_PALETTE8_RGBA8_OES); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__palette8_rgba8), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":245
 *     'palette8_rgb8': GL_PALETTE8_RGB8_OES,
 *     'palette8_rgba8': GL_PALETTE8_RGBA8_OES,
 *     'palette8_r5_g6_b5': GL_PALETTE8_R5_G6_B5_OES,             # <<<<<<<<<<<<<<
 *     'palette8_rgba4': GL_PALETTE8_RGBA4_OES,
 *     'palette8_rgb5_a1': GL_PALETTE8_RGB5_A1_OES,
 */
  __pyx_t_5 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_PALETTE8_R5_G6_B5_OES); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__palette8_r5_g6_b5), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":246
 *     'palette8_rgba8': GL_PALETTE8_RGBA8_OES,
 *     'palette8_r5_g6_b5': GL_PALETTE8_R5_G6_B5_OES,
 *     'palette8_rgba4': GL_PALETTE8_RGBA4_OES,             # <<<<<<<<<<<<<<
 *     'palette8_rgb5_a1': GL_PALETTE8_RGB5_A1_OES,
 *     'pvrtc_rgba2': GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
 */
  __pyx_t_5 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_PALETTE8_RGBA4_OES); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__palette8_rgba4), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":247
 *     'palette8_r5_g6_b5': GL_PALETTE8_R5_G6_B5_OES,
 *     'palette8_rgba4': GL_PALETTE8_RGBA4_OES,
 *     'palette8_rgb5_a1': GL_PALETTE8_RGB5_A1_OES,             # <<<<<<<<<<<<<<
 *     'pvrtc_rgba2': GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
 *     'pvrtc_rgba4': GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
 */
  __pyx_t_5 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_PALETTE8_RGB5_A1_OES); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__palette8_rgb5_a1), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":248
 *     'palette8_rgba4': GL_PALETTE8_RGBA4_OES,
 *     'palette8_rgb5_a1': GL_PALETTE8_RGB5_A1_OES,
 *     'pvrtc_rgba2': GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,             # <<<<<<<<<<<<<<
 *     'pvrtc_rgba4': GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
 *     'pvrtc_rgb2': GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG,
 */
  __pyx_t_5 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__pvrtc_rgba2), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":249
 *     'palette8_rgb5_a1': GL_PALETTE8_RGB5_A1_OES,
 *     'pvrtc_rgba2': GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
 *     'pvrtc_rgba4': GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,             # <<<<<<<<<<<<<<
 *     'pvrtc_rgb2': GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG,
 *     'pvrtc_rgb4': GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG }
 */
  __pyx_t_5 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__pvrtc_rgba4), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":250
 *     'pvrtc_rgba2': GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
 *     'pvrtc_rgba4': GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
 *     'pvrtc_rgb2': GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG,             # <<<<<<<<<<<<<<
 *     'pvrtc_rgb4': GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG }
 * 
 */
  __pyx_t_5 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__pvrtc_rgb2), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":251
 *     'pvrtc_rgba4': GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
 *     'pvrtc_rgb2': GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG,
 *     'pvrtc_rgb4': GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG }             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__pvrtc_rgb4), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_XGOTREF(((PyObject *)__pyx_v_4kivy_8graphics_7texture__gl_color_fmt));
  __Pyx_DECREF(((PyObject *)__pyx_v_4kivy_8graphics_7texture__gl_color_fmt));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
  __pyx_v_4kivy_8graphics_7texture__gl_color_fmt = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":254
 * 
 * 
 * cdef dict _gl_buffer_fmt = {             # <<<<<<<<<<<<<<
 *     'ubyte': GL_UNSIGNED_BYTE, 'ushort': GL_UNSIGNED_SHORT,
 *     'uint': GL_UNSIGNED_INT, 'byte': GL_BYTE,
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));

  /* "kivy\graphics\texture.pyx":255
 * 
 * cdef dict _gl_buffer_fmt = {
 *     'ubyte': GL_UNSIGNED_BYTE, 'ushort': GL_UNSIGNED_SHORT,             # <<<<<<<<<<<<<<
 *     'uint': GL_UNSIGNED_INT, 'byte': GL_BYTE,
 *     'short': GL_SHORT, 'int': GL_INT, 'float': GL_FLOAT }
 */
  __pyx_t_5 = PyInt_FromLong(GL_UNSIGNED_BYTE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__ubyte), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyInt_FromLong(GL_UNSIGNED_SHORT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__ushort), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":256
 * cdef dict _gl_buffer_fmt = {
 *     'ubyte': GL_UNSIGNED_BYTE, 'ushort': GL_UNSIGNED_SHORT,
 *     'uint': GL_UNSIGNED_INT, 'byte': GL_BYTE,             # <<<<<<<<<<<<<<
 *     'short': GL_SHORT, 'int': GL_INT, 'float': GL_FLOAT }
 * 
 */
  __pyx_t_5 = PyInt_FromLong(GL_UNSIGNED_INT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__uint), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyInt_FromLong(GL_BYTE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__byte), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":257
 *     'ubyte': GL_UNSIGNED_BYTE, 'ushort': GL_UNSIGNED_SHORT,
 *     'uint': GL_UNSIGNED_INT, 'byte': GL_BYTE,
 *     'short': GL_SHORT, 'int': GL_INT, 'float': GL_FLOAT }             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = PyInt_FromLong(GL_SHORT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__short), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyInt_FromLong(GL_INT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__int), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyInt_FromLong(GL_FLOAT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__float), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_XGOTREF(((PyObject *)__pyx_v_4kivy_8graphics_7texture__gl_buffer_fmt));
  __Pyx_DECREF(((PyObject *)__pyx_v_4kivy_8graphics_7texture__gl_buffer_fmt));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
  __pyx_v_4kivy_8graphics_7texture__gl_buffer_fmt = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":260
 * 
 * 
 * cdef dict _gl_buffer_size = {             # <<<<<<<<<<<<<<
 *     'ubyte': sizeof(GLubyte), 'ushort': sizeof(GLushort),
 *     'uint': sizeof(GLuint), 'byte': sizeof(GLbyte),
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));

  /* "kivy\graphics\texture.pyx":261
 * 
 * cdef dict _gl_buffer_size = {
 *     'ubyte': sizeof(GLubyte), 'ushort': sizeof(GLushort),             # <<<<<<<<<<<<<<
 *     'uint': sizeof(GLuint), 'byte': sizeof(GLbyte),
 *     'short': sizeof(GLshort), 'int': sizeof(GLint),
 */
  __pyx_t_5 = __Pyx_PyInt_FromSize_t((sizeof(GLubyte))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__ubyte), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyInt_FromSize_t((sizeof(GLushort))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__ushort), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":262
 * cdef dict _gl_buffer_size = {
 *     'ubyte': sizeof(GLubyte), 'ushort': sizeof(GLushort),
 *     'uint': sizeof(GLuint), 'byte': sizeof(GLbyte),             # <<<<<<<<<<<<<<
 *     'short': sizeof(GLshort), 'int': sizeof(GLint),
 *     'float': sizeof(GLfloat) }
 */
  __pyx_t_5 = __Pyx_PyInt_FromSize_t((sizeof(GLuint))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__uint), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyInt_FromSize_t((sizeof(GLbyte))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__byte), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":263
 *     'ubyte': sizeof(GLubyte), 'ushort': sizeof(GLushort),
 *     'uint': sizeof(GLuint), 'byte': sizeof(GLbyte),
 *     'short': sizeof(GLshort), 'int': sizeof(GLint),             # <<<<<<<<<<<<<<
 *     'float': sizeof(GLfloat) }
 * 
 */
  __pyx_t_5 = __Pyx_PyInt_FromSize_t((sizeof(GLshort))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__short), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __Pyx_PyInt_FromSize_t((sizeof(GLint))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__int), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":264
 *     'uint': sizeof(GLuint), 'byte': sizeof(GLbyte),
 *     'short': sizeof(GLshort), 'int': sizeof(GLint),
 *     'float': sizeof(GLfloat) }             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = __Pyx_PyInt_FromSize_t((sizeof(GLfloat))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__float), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_XGOTREF(((PyObject *)__pyx_v_4kivy_8graphics_7texture__gl_buffer_size));
  __Pyx_DECREF(((PyObject *)__pyx_v_4kivy_8graphics_7texture__gl_buffer_size));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
  __pyx_v_4kivy_8graphics_7texture__gl_buffer_size = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":267
 * 
 * 
 * cdef dict _gl_texture_min_filter = {             # <<<<<<<<<<<<<<
 *     'nearest': GL_NEAREST, 'linear': GL_LINEAR,
 *     'nearest_mipmap_nearest': GL_NEAREST_MIPMAP_NEAREST,
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));

  /* "kivy\graphics\texture.pyx":268
 * 
 * cdef dict _gl_texture_min_filter = {
 *     'nearest': GL_NEAREST, 'linear': GL_LINEAR,             # <<<<<<<<<<<<<<
 *     'nearest_mipmap_nearest': GL_NEAREST_MIPMAP_NEAREST,
 *     'nearest_mipmap_linear': GL_NEAREST_MIPMAP_LINEAR,
 */
  __pyx_t_5 = PyInt_FromLong(GL_NEAREST); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__nearest), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = PyInt_FromLong(GL_LINEAR); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__linear), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":269
 * cdef dict _gl_texture_min_filter = {
 *     'nearest': GL_NEAREST, 'linear': GL_LINEAR,
 *     'nearest_mipmap_nearest': GL_NEAREST_MIPMAP_NEAREST,             # <<<<<<<<<<<<<<
 *     'nearest_mipmap_linear': GL_NEAREST_MIPMAP_LINEAR,
 *     'linear_mipmap_nearest': GL_LINEAR_MIPMAP_NEAREST,
 */
  __pyx_t_5 = PyInt_FromLong(GL_NEAREST_MIPMAP_NEAREST); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s_53), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":270
 *     'nearest': GL_NEAREST, 'linear': GL_LINEAR,
 *     'nearest_mipmap_nearest': GL_NEAREST_MIPMAP_NEAREST,
 *     'nearest_mipmap_linear': GL_NEAREST_MIPMAP_LINEAR,             # <<<<<<<<<<<<<<
 *     'linear_mipmap_nearest': GL_LINEAR_MIPMAP_NEAREST,
 *     'linear_mipmap_linear': GL_LINEAR_MIPMAP_LINEAR }
 */
  __pyx_t_5 = PyInt_FromLong(GL_NEAREST_MIPMAP_LINEAR); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s_54), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":271
 *     'nearest_mipmap_nearest': GL_NEAREST_MIPMAP_NEAREST,
 *     'nearest_mipmap_linear': GL_NEAREST_MIPMAP_LINEAR,
 *     'linear_mipmap_nearest': GL_LINEAR_MIPMAP_NEAREST,             # <<<<<<<<<<<<<<
 *     'linear_mipmap_linear': GL_LINEAR_MIPMAP_LINEAR }
 * 
 */
  __pyx_t_5 = PyInt_FromLong(GL_LINEAR_MIPMAP_NEAREST); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s_17), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "kivy\graphics\texture.pyx":272
 *     'nearest_mipmap_linear': GL_NEAREST_MIPMAP_LINEAR,
 *     'linear_mipmap_nearest': GL_LINEAR_MIPMAP_NEAREST,
 *     'linear_mipmap_linear': GL_LINEAR_MIPMAP_LINEAR }             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_5 = PyInt_FromLong(GL_LINEAR_MIPMAP_LINEAR); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s_55), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_XGOTREF(((PyObject *)__pyx_v_4kivy_8graphics_7texture__gl_texture_min_filter));
  __Pyx_DECREF(((PyObject *)__pyx_v_4kivy_8graphics_7texture__gl_texture_min_filter));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
  __pyx_v_4kivy_8graphics_7texture__gl_texture_min_filter = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":511
 * 
 * 
 * def texture_create(size=None, colorfmt=None, bufferfmt=None, mipmap=False,             # <<<<<<<<<<<<<<
 *     callback=None):
 *     '''Create a texture based on size.
 */
  __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k_18 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4kivy_8graphics_7texture_1texture_create, NULL, __pyx_n_s_59); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s__texture_create, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":546
 * 
 * 
 * def texture_create_from_data(im, mipmap=False):             # <<<<<<<<<<<<<<
 *     '''Create a texture from an ImageData class
 *     '''
 */
  __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k_19 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_4kivy_8graphics_7texture_3texture_create_from_data, NULL, __pyx_n_s_59); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s_62, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":590
 *     or complex texture based on ImageData.'''
 * 
 *     create = staticmethod(texture_create)             # <<<<<<<<<<<<<<
 *     create_from_data = staticmethod(texture_create_from_data)
 * 
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s__texture_create); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_builtin_staticmethod, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4kivy_8graphics_7texture_Texture->tp_dict, __pyx_n_s__create, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  PyType_Modified(__pyx_ptype_4kivy_8graphics_7texture_Texture);

  /* "kivy\graphics\texture.pyx":591
 * 
 *     create = staticmethod(texture_create)
 *     create_from_data = staticmethod(texture_create_from_data)             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, width, height, target, texid=0, colorfmt='rgb',
 */
  __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_62); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_Call(__pyx_builtin_staticmethod, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4kivy_8graphics_7texture_Texture->tp_dict, __pyx_n_s__create_from_data, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  PyType_Modified(__pyx_ptype_4kivy_8graphics_7texture_Texture);

  /* "kivy\graphics\texture.pyx":594
 * 
 *     def __init__(self, width, height, target, texid=0, colorfmt='rgb',
 *             bufferfmt='ubyte', mipmap=False, source=None, callback=None):             # <<<<<<<<<<<<<<
 *         self.observers = []
 *         self._width         = width
 */
  __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k_20 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":795
 *     def blit_buffer(self, pbuffer, size=None, colorfmt=None,
 *                     pos=None, bufferfmt=None, mipmap_level=0,
 *                     mipmap_generation=True):             # <<<<<<<<<<<<<<
 *         '''Blit a buffer into a texture.
 * 
 */
  __pyx_t_4 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_k_22 = __pyx_t_4;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":1
 * '''             # <<<<<<<<<<<<<<
 * Texture
 * =======
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  if (PyDict_SetItem(__pyx_d, __pyx_n_s____test__, ((PyObject *)__pyx_t_4)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  if (__pyx_m) {
    __Pyx_AddTraceback("init kivy.graphics.texture", __pyx_clineno, __pyx_lineno, __pyx_filename);
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init kivy.graphics.texture");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

/* Runtime support code */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif /* CYTHON_REFNANNY */

static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
    if (unlikely(!result)) {
        PyErr_Format(PyExc_NameError,
#if PY_MAJOR_VERSION >= 3
            "name '%U' is not defined", name);
#else
            "name '%s' is not defined", PyString_AS_STRING(name));
#endif
    }
    return result;
}

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *local_type, *local_value, *local_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(&local_type, &local_value, &local_tb);
#endif
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
#if CYTHON_COMPILING_IN_CPYTHON
    if (unlikely(tstate->curexc_type))
#else
    if (unlikely(PyErr_Occurred()))
#endif
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
        goto bad;
    #endif
    Py_INCREF(local_type);
    Py_INCREF(local_value);
    Py_INCREF(local_tb);
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    /* Make sure tstate is in a consistent state when we XDECREF
       these objects (DECREF may run arbitrary code). */
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_Restore(type, value, tb);
#endif
}
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(type, value, tb);
#endif
}

#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    Py_XINCREF(type);
    if (!value || value == Py_None)
        value = NULL;
    else
        Py_INCREF(value);
    if (!tb || tb == Py_None)
        tb = NULL;
    else {
        Py_INCREF(tb);
        if (!PyTraceBack_Check(tb)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: arg 3 must be a traceback or None");
            goto raise_error;
        }
    }
    #if PY_VERSION_HEX < 0x02050000
    if (PyClass_Check(type)) {
    #else
    if (PyType_Check(type)) {
    #endif
#if CYTHON_COMPILING_IN_PYPY
        if (!value) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
#endif
        PyErr_NormalizeException(&type, &value, &tb);
    } else {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        value = type;
        #if PY_VERSION_HEX < 0x02050000
        if (PyInstance_Check(type)) {
            type = (PyObject*) ((PyInstanceObject*)type)->in_class;
            Py_INCREF(type);
        } else {
            type = 0;
            PyErr_SetString(PyExc_TypeError,
                "raise: exception must be an old-style class or instance");
            goto raise_error;
        }
        #else
        type = (PyObject*) Py_TYPE(type);
        Py_INCREF(type);
        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
            PyErr_SetString(PyExc_TypeError,
                "raise: exception class must be a subclass of BaseException");
            goto raise_error;
        }
        #endif
    }
    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}
#else /* Python 3+ */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    PyObject* owned_instance = NULL;
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;
    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (PyExceptionClass_Check(type)) {
        PyObject *args;
        if (!value)
            args = PyTuple_New(0);
        else if (PyTuple_Check(value)) {
            Py_INCREF(value);
            args = value;
        } else
            args = PyTuple_Pack(1, value);
        if (!args)
            goto bad;
        owned_instance = PyEval_CallObject(type, args);
        Py_DECREF(args);
        if (!owned_instance)
            goto bad;
        value = owned_instance;
        if (!PyExceptionInstance_Check(value)) {
            PyErr_Format(PyExc_TypeError,
                         "calling %R should have returned an instance of "
                         "BaseException, not %R",
                         type, Py_TYPE(value));
            goto bad;
        }
    } else {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
#if PY_VERSION_HEX >= 0x03030000
    if (cause) {
#else
    if (cause && cause != Py_None) {
#endif
        PyObject *fixed_cause;
        if (cause == Py_None) {
            fixed_cause = NULL;
        } else if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        } else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        } else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        PyException_SetCause(value, fixed_cause);
    }
    PyErr_SetObject(type, value);
    if (tb) {
        PyThreadState *tstate = PyThreadState_GET();
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}
#endif

static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
}

static CYTHON_INLINE int __Pyx_PyStr_Tailmatch(PyObject* self, PyObject* arg, Py_ssize_t start,
                                               Py_ssize_t end, int direction)
{
    if (PY_MAJOR_VERSION < 3)
        return __Pyx_PyBytes_Tailmatch(self, arg, start, end, direction);
    else
        return __Pyx_PyUnicode_Tailmatch(self, arg, start, end, direction);
}

static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
    if (s1 == s2) {
        return (equals == Py_EQ);
    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
        if (PyBytes_GET_SIZE(s1) != PyBytes_GET_SIZE(s2)) {
            return (equals == Py_NE);
        } else if (PyBytes_GET_SIZE(s1) == 1) {
            if (equals == Py_EQ)
                return (PyBytes_AS_STRING(s1)[0] == PyBytes_AS_STRING(s2)[0]);
            else
                return (PyBytes_AS_STRING(s1)[0] != PyBytes_AS_STRING(s2)[0]);
        } else {
            int result = memcmp(PyBytes_AS_STRING(s1), PyBytes_AS_STRING(s2), (size_t)PyBytes_GET_SIZE(s1));
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
#endif
}

static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
    if (s1 == s2) {
        return (equals == Py_EQ);
    } else if (PyUnicode_CheckExact(s1) & PyUnicode_CheckExact(s2)) {
        #if CYTHON_PEP393_ENABLED
        if ((PyUnicode_READY(s1) < 0) || (PyUnicode_READY(s2) < 0))
            return -1;
        if (PyUnicode_GET_LENGTH(s1) != PyUnicode_GET_LENGTH(s2)) {
            return (equals == Py_NE);
        } else if (PyUnicode_GET_LENGTH(s1) == 1) {
            Py_UCS4 ch1 = PyUnicode_READ_CHAR(s1, 0);
            Py_UCS4 ch2 = PyUnicode_READ_CHAR(s2, 0);
            return (equals == Py_EQ) ? (ch1 == ch2) : (ch1 != ch2);
        #else
        if (PyUnicode_GET_SIZE(s1) != PyUnicode_GET_SIZE(s2)) {
            return (equals == Py_NE);
        } else if (PyUnicode_GET_SIZE(s1) == 1) {
            Py_UNICODE ch1 = PyUnicode_AS_UNICODE(s1)[0];
            Py_UNICODE ch2 = PyUnicode_AS_UNICODE(s2)[0];
            return (equals == Py_EQ) ? (ch1 == ch2) : (ch1 != ch2);
        #endif
        } else {
            int result = PyUnicode_Compare(s1, s2);
            if ((result == -1) && unlikely(PyErr_Occurred()))
                return -1;
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyUnicode_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyUnicode_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
#endif
}

static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
    PyObject *result;
#if CYTHON_COMPILING_IN_CPYTHON
    result = PyDict_GetItem(__pyx_d, name);
    if (result) {
        Py_INCREF(result);
    } else {
#else
    result = PyObject_GetItem(__pyx_d, name);
    if (!result) {
        PyErr_Clear();
#endif
        result = __Pyx_GetBuiltinName(name);
    }
    return result;
}

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(PyObject_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AsString(kw_name));
        #endif
}

static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
            continue;
        }
        name = first_kw_arg;
        #if PY_MAJOR_VERSION < 3
        if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
            while (*name) {
                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
                        && _PyString_Eq(**name, key)) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    if ((**argname == key) || (
                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
                             && _PyString_Eq(**argname, key))) {
                        goto arg_passed_twice;
                    }
                    argname++;
                }
            }
        } else
        #endif
        if (likely(PyUnicode_Check(key))) {
            while (*name) {
                int cmp = (**name == key) ? 0 :
                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                    (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
                #endif
                    PyUnicode_Compare(**name, key);
                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                if (cmp == 0) {
                    values[name-argnames] = value;
                    break;
                }
                name++;
            }
            if (*name) continue;
            else {
                PyObject*** argname = argnames;
                while (argname != first_kw_arg) {
                    int cmp = (**argname == key) ? 0 :
                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
                        (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
                    #endif
                        PyUnicode_Compare(**argname, key);
                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
                    if (cmp == 0) goto arg_passed_twice;
                    argname++;
                }
            }
        } else
            goto invalid_keyword_type;
        if (kwds2) {
            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
        } else {
            goto invalid_keyword;
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%s() takes %s %" CYTHON_FORMAT_SSIZE_T "d positional argument%s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
}

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%s to unpack",
                 index, (index == 1) ? "" : "s");
}

static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) {
            PyObject *exc_value, *exc_tb;
            exc_value = tstate->curexc_value;
            exc_tb = tstate->curexc_traceback;
            tstate->curexc_type = 0;
            tstate->curexc_value = 0;
            tstate->curexc_traceback = 0;
            Py_DECREF(exc_type);
            Py_XDECREF(exc_value);
            Py_XDECREF(exc_tb);
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#else
    if (unlikely(PyErr_Occurred())) {
        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
            PyErr_Clear();
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#endif
}

static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
    if (unlikely(retval)) {
        Py_DECREF(retval);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    } else {
        return __Pyx_IterFinish();
    }
    return 0;
}

#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE void __Pyx_crop_slice(Py_ssize_t* _start, Py_ssize_t* _stop, Py_ssize_t* _length) {
    Py_ssize_t start = *_start, stop = *_stop, length = *_length;
    if (start < 0) {
        start += length;
        if (start < 0)
            start = 0;
    }
    if (stop < 0)
        stop += length;
    else if (stop > length)
        stop = length;
    *_length = stop - start;
    *_start = start;
    *_stop = stop;
}
static CYTHON_INLINE void __Pyx_copy_object_array(PyObject** CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) {
    PyObject *v;
    Py_ssize_t i;
    for (i = 0; i < length; i++) {
        v = dest[i] = src[i];
        Py_INCREF(v);
    }
}
static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(
            PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
    PyObject* dest;
    Py_ssize_t length = PyList_GET_SIZE(src);
    __Pyx_crop_slice(&start, &stop, &length);
    if (unlikely(length <= 0))
        return PyList_New(0);
    dest = PyList_New(length);
    if (unlikely(!dest))
        return NULL;
    __Pyx_copy_object_array(
        ((PyListObject*)src)->ob_item + start,
        ((PyListObject*)dest)->ob_item,
        length);
    return dest;
}
static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(
            PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
    PyObject* dest;
    Py_ssize_t length = PyTuple_GET_SIZE(src);
    __Pyx_crop_slice(&start, &stop, &length);
    if (unlikely(length <= 0))
        return PyTuple_New(0);
    dest = PyTuple_New(length);
    if (unlikely(!dest))
        return NULL;
    __Pyx_copy_object_array(
        ((PyTupleObject*)src)->ob_item + start,
        ((PyTupleObject*)dest)->ob_item,
        length);
    return dest;
}
#endif

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        PyObject *r = PyList_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o);
    if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
        PyObject *r = PyTuple_GET_ITEM(o, i);
        Py_INCREF(r);
        return r;
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
    return PySequence_GetItem(o, i);
#endif
}
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (is_list || PyList_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
            PyObject *r = PyList_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (PyTuple_CheckExact(o)) {
        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    } else {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
                Py_ssize_t l = m->sq_length(o);
                if (likely(l >= 0)) {
                    i += l;
                } else {
                    if (PyErr_ExceptionMatches(PyExc_OverflowError))
                        PyErr_Clear();
                    else
                        return NULL;
                }
            }
            return m->sq_item(o, i);
        }
    }
#else
    if (is_list || PySequence_Check(o)) {
        return PySequence_GetItem(o, i);
    }
#endif
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Format(PyExc_ImportError,
        #if PY_MAJOR_VERSION < 3
            "cannot import name %.230s", PyString_AS_STRING(name));
        #else
            "cannot import name %S", name);
        #endif
    }
    return value;
}

static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact)
{
    if (!type) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (none_allowed && obj == Py_None) return 1;
    else if (exact) {
        if (Py_TYPE(obj) == type) return 1;
    }
    else {
        if (PyObject_TypeCheck(obj, type)) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%s' has incorrect type (expected %s, got %s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItem(dict, __pyx_n_s____pyx_vtable__, ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

static void* __Pyx_GetVtable(PyObject *dict) {
    void* ptr;
    PyObject *ob = PyObject_GetItem(dict, __pyx_n_s____pyx_vtable__);
    if (!ob)
        goto bad;
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    ptr = PyCapsule_GetPointer(ob, 0);
#else
    ptr = PyCObject_AsVoidPtr(ob);
#endif
    if (!ptr && !PyErr_Occurred())
        PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
    Py_DECREF(ob);
    return ptr;
bad:
    Py_XDECREF(ob);
    return NULL;
}

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
#else
    PyErr_GetExcInfo(type, value, tb);
#endif
}
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(type, value, tb);
#endif
}

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    #if PY_VERSION_HEX < 0x03030000
    PyObject *py_import;
    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s____import__);
    if (!py_import)
        goto bad;
    #endif
    if (from_list)
        list = from_list;
    else {
        empty_list = PyList_New(0);
        if (!empty_list)
            goto bad;
        list = empty_list;
    }
    global_dict = PyModule_GetDict(__pyx_m);
    if (!global_dict)
        goto bad;
    empty_dict = PyDict_New();
    if (!empty_dict)
        goto bad;
    #if PY_VERSION_HEX >= 0x02050000
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if (strchr(__Pyx_MODULE_NAME, '.')) {
                #if PY_VERSION_HEX < 0x03030000
                PyObject *py_level = PyInt_FromLong(1);
                if (!py_level)
                    goto bad;
                module = PyObject_CallFunctionObjArgs(py_import,
                    name, global_dict, empty_dict, list, py_level, NULL);
                Py_DECREF(py_level);
                #else
                module = PyImport_ImportModuleLevelObject(
                    name, global_dict, empty_dict, list, 1);
                #endif
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0; /* try absolute import on failure */
        }
        #endif
        if (!module) {
            #if PY_VERSION_HEX < 0x03030000
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, NULL);
            Py_DECREF(py_level);
            #else
            module = PyImport_ImportModuleLevelObject(
                name, global_dict, empty_dict, list, level);
            #endif
        }
    }
    #else
    if (level>0) {
        PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4.");
        goto bad;
    }
    module = PyObject_CallFunctionObjArgs(py_import,
        name, global_dict, empty_dict, list, NULL);
    #endif
bad:
    #if PY_VERSION_HEX < 0x03030000
    Py_XDECREF(py_import);
    #endif
    Py_XDECREF(empty_list);
    Py_XDECREF(empty_dict);
    return module;
}

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_GLuint(GLuint val) {
    const GLuint neg_one = (GLuint)-1, const_zero = (GLuint)0;
    const int is_unsigned = const_zero < neg_one;
    if ((sizeof(GLuint) == sizeof(char))  ||
        (sizeof(GLuint) == sizeof(short))) {
        return PyInt_FromLong((long)val);
    } else if ((sizeof(GLuint) == sizeof(int)) ||
               (sizeof(GLuint) == sizeof(long))) {
        if (is_unsigned)
            return PyLong_FromUnsignedLong((unsigned long)val);
        else
            return PyInt_FromLong((long)val);
    } else if (sizeof(GLuint) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
        else
            return PyLong_FromLongLong((PY_LONG_LONG)val);
    } else {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&val;
        return _PyLong_FromByteArray(bytes, sizeof(GLuint),
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE GLuint __Pyx_PyInt_from_py_GLuint(PyObject* x) {
    const GLuint neg_one = (GLuint)-1, const_zero = (GLuint)0;
    const int is_unsigned = const_zero < neg_one;
    if (sizeof(GLuint) == sizeof(char)) {
        if (is_unsigned)
            return (GLuint)__Pyx_PyInt_AsUnsignedChar(x);
        else
            return (GLuint)__Pyx_PyInt_AsSignedChar(x);
    } else if (sizeof(GLuint) == sizeof(short)) {
        if (is_unsigned)
            return (GLuint)__Pyx_PyInt_AsUnsignedShort(x);
        else
            return (GLuint)__Pyx_PyInt_AsSignedShort(x);
    } else if (sizeof(GLuint) == sizeof(int)) {
        if (is_unsigned)
            return (GLuint)__Pyx_PyInt_AsUnsignedInt(x);
        else
            return (GLuint)__Pyx_PyInt_AsSignedInt(x);
    } else if (sizeof(GLuint) == sizeof(long)) {
        if (is_unsigned)
            return (GLuint)__Pyx_PyInt_AsUnsignedLong(x);
        else
            return (GLuint)__Pyx_PyInt_AsSignedLong(x);
    } else if (sizeof(GLuint) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return (GLuint)__Pyx_PyInt_AsUnsignedLongLong(x);
        else
            return (GLuint)__Pyx_PyInt_AsSignedLongLong(x);
    }  else {
        #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
        PyErr_SetString(PyExc_RuntimeError,
                        "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
        #else
        GLuint val;
        PyObject *v = __Pyx_PyNumber_Int(x);
        #if PY_MAJOR_VERSION < 3
        if (likely(v) && !PyLong_Check(v)) {
            PyObject *tmp = v;
            v = PyNumber_Long(tmp);
            Py_DECREF(tmp);
        }
        #endif
        if (likely(v)) {
            int one = 1; int is_little = (int)*(unsigned char *)&one;
            unsigned char *bytes = (unsigned char *)&val;
            int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                          bytes, sizeof(val),
                                          is_little, !is_unsigned);
            Py_DECREF(v);
            if (likely(!ret))
                return val;
        }
        #endif
        return (GLuint)-1;
    }
}

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
    const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned char" :
                    "value too large to convert to unsigned char");
            }
            return (unsigned char)-1;
        }
        return (unsigned char)val;
    }
    return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
    const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned short" :
                    "value too large to convert to unsigned short");
            }
            return (unsigned short)-1;
        }
        return (unsigned short)val;
    }
    return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
    const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned int" :
                    "value too large to convert to unsigned int");
            }
            return (unsigned int)-1;
        }
        return (unsigned int)val;
    }
    return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
    const char neg_one = (char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to char" :
                    "value too large to convert to char");
            }
            return (char)-1;
        }
        return (char)val;
    }
    return (char)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
    const short neg_one = (short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to short" :
                    "value too large to convert to short");
            }
            return (short)-1;
        }
        return (short)val;
    }
    return (short)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
    const signed char neg_one = (signed char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed char" :
                    "value too large to convert to signed char");
            }
            return (signed char)-1;
        }
        return (signed char)val;
    }
    return (signed char)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
    const signed short neg_one = (signed short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed short" :
                    "value too large to convert to signed short");
            }
            return (signed short)-1;
        }
        return (signed short)val;
    }
    return (signed short)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
    const signed int neg_one = (signed int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed int" :
                    "value too large to convert to signed int");
            }
            return (signed int)-1;
        }
        return (signed int)val;
    }
    return (signed int)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#endif
#endif
static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
    const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned long");
            return (unsigned long)-1;
        }
        return (unsigned long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(unsigned long)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return (unsigned long) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned long");
                return (unsigned long)-1;
            }
            return (unsigned long)PyLong_AsUnsignedLong(x);
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(unsigned long)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return +(unsigned long) ((PyLongObject*)x)->ob_digit[0];
                    case -1: return -(unsigned long) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            return (unsigned long)PyLong_AsLong(x);
        }
    } else {
        unsigned long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned long)-1;
        val = __Pyx_PyInt_AsUnsignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#endif
#endif
static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
    const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned PY_LONG_LONG");
            return (unsigned PY_LONG_LONG)-1;
        }
        return (unsigned PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return (unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned PY_LONG_LONG");
                return (unsigned PY_LONG_LONG)-1;
            }
            return (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(unsigned PY_LONG_LONG)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return +(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                    case -1: return -(unsigned PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        unsigned PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#endif
#endif
static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
    const long neg_one = (long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to long");
            return (long)-1;
        }
        return (long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(long)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return (long) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to long");
                return (long)-1;
            }
            return (long)PyLong_AsUnsignedLong(x);
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(long)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return +(long) ((PyLongObject*)x)->ob_digit[0];
                    case -1: return -(long) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            return (long)PyLong_AsLong(x);
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (long)-1;
        val = __Pyx_PyInt_AsLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#endif
#endif
static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
    const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to PY_LONG_LONG");
            return (PY_LONG_LONG)-1;
        }
        return (PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(PY_LONG_LONG)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return (PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to PY_LONG_LONG");
                return (PY_LONG_LONG)-1;
            }
            return (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(PY_LONG_LONG)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return +(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                    case -1: return -(PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            return (PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#endif
#endif
static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
    const signed long neg_one = (signed long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed long");
            return (signed long)-1;
        }
        return (signed long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(signed long)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return (signed long) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed long");
                return (signed long)-1;
            }
            return (signed long)PyLong_AsUnsignedLong(x);
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(signed long)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return +(signed long) ((PyLongObject*)x)->ob_digit[0];
                    case -1: return -(signed long) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            return (signed long)PyLong_AsLong(x);
        }
    } else {
        signed long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed long)-1;
        val = __Pyx_PyInt_AsSignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
#include "longintrepr.h"
#endif
#endif
static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
    const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_MAJOR_VERSION < 3
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed PY_LONG_LONG");
            return (signed PY_LONG_LONG)-1;
        }
        return (signed PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return (signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed PY_LONG_LONG");
                return (signed PY_LONG_LONG)-1;
            }
            return (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
#if CYTHON_USE_PYLONG_INTERNALS
            if (sizeof(digit) <= sizeof(signed PY_LONG_LONG)) {
                switch (Py_SIZE(x)) {
                    case  0: return 0;
                    case  1: return +(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                    case -1: return -(signed PY_LONG_LONG) ((PyLongObject*)x)->ob_digit[0];
                }
            }
#endif
#endif
            return (signed PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        signed PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsSignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static int __Pyx_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        #if PY_VERSION_HEX < 0x02050000
        return PyErr_Warn(NULL, message);
        #else
        return PyErr_WarnEx(NULL, message, 1);
        #endif
    }
    return 0;
}

#ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;
    py_name = __Pyx_PyIdentifier_FromString(name);
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    size_t size, int strict)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;
    char warning[200];
    Py_ssize_t basicsize;
#ifdef Py_LIMITED_API
    PyObject *py_basicsize;
#endif
    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    py_name = __Pyx_PyIdentifier_FromString(class_name);
    if (!py_name)
        goto bad;
    result = PyObject_GetAttr(py_module, py_name);
    Py_DECREF(py_name);
    py_name = 0;
    Py_DECREF(py_module);
    py_module = 0;
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%s.%s is not a type object",
            module_name, class_name);
        goto bad;
    }
#ifndef Py_LIMITED_API
    basicsize = ((PyTypeObject *)result)->tp_basicsize;
#else
    py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
    if (!py_basicsize)
        goto bad;
    basicsize = PyLong_AsSsize_t(py_basicsize);
    Py_DECREF(py_basicsize);
    py_basicsize = 0;
    if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
        goto bad;
#endif
    if (!strict && (size_t)basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility",
            module_name, class_name);
        #if PY_VERSION_HEX < 0x02050000
        if (PyErr_Warn(NULL, warning) < 0) goto bad;
        #else
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
        #endif
    }
    else if ((size_t)basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%s.%s has the wrong size, try recompiling",
            module_name, class_name);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return NULL;
}
#endif

#ifndef __PYX_HAVE_RT_ImportVoidPtr
#define __PYX_HAVE_RT_ImportVoidPtr
static int __Pyx_ImportVoidPtr(PyObject *module, const char *name, void **p, const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, name);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%s does not export expected C variable %s",
                PyModule_GetName(module), name);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3 && PY_MINOR_VERSION==0)
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C variable %s.%s has wrong signature (expected %s, got %s)",
             PyModule_GetName(module), name, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    *p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C variable %s.%s has wrong signature (expected %s, got %s)",
             PyModule_GetName(module), name, sig, desc);
        goto bad;
    }
    *p = PyCObject_AsVoidPtr(cobj);}
#endif
    if (!(*p))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif

#ifndef __PYX_HAVE_RT_ImportFunction
#define __PYX_HAVE_RT_ImportFunction
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, funcname);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%s does not export expected C function %s",
                PyModule_GetName(module), funcname);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3 && PY_MINOR_VERSION==0)
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C function %s.%s has wrong signature (expected %s, got %s)",
             PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    tmp.p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C function %s.%s has wrong signature (expected %s, got %s)",
             PyModule_GetName(module), funcname, sig, desc);
        goto bad;
    }
    tmp.p = PyCObject_AsVoidPtr(cobj);}
#endif
    *f = tmp.fp;
    if (!(*f))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif

static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = (start + end) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, new_max*sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(filename);
    #else
    py_srcfile = PyUnicode_FromString(filename);
    #endif
    if (!py_srcfile) goto bad;
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_code = __Pyx_PyCode_New(
        0,            /*int argcount,*/
        0,            /*int kwonlyargcount,*/
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple, /*PyObject *consts,*/
        __pyx_empty_tuple, /*PyObject *names,*/
        __pyx_empty_tuple, /*PyObject *varnames,*/
        __pyx_empty_tuple, /*PyObject *freevars,*/
        __pyx_empty_tuple, /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        py_line,      /*int firstlineno,*/
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    Py_DECREF(py_funcname);
    return py_code;
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_globals = 0;
    PyFrameObject *py_frame = 0;
    py_code = __pyx_find_code_object(c_line ? c_line : py_line);
    if (!py_code) {
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) goto bad;
        __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
    }
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        py_globals,          /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = py_line;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else  /* Python 3+ has unicode identifiers */
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char* c_str) {
    return __Pyx_PyUnicode_FromStringAndSize(c_str, strlen(c_str));
}
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
    if (
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
            __Pyx_sys_getdefaultencoding_not_ascii &&
#endif
            PyUnicode_Check(o)) {
#if PY_VERSION_HEX < 0x03030000
        char* defenc_c;
        PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
        if (!defenc) return NULL;
        defenc_c = PyBytes_AS_STRING(defenc);
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        {
            char* end = defenc_c + PyBytes_GET_SIZE(defenc);
            char* c;
            for (c = defenc_c; c < end; c++) {
                if ((unsigned char) (*c) >= 128) {
                    PyUnicode_AsASCIIString(o);
                    return NULL;
                }
            }
        }
#endif /*__PYX_DEFAULT_STRING_ENCODING_IS_ASCII*/
        *length = PyBytes_GET_SIZE(defenc);
        return defenc_c;
#else /* PY_VERSION_HEX < 0x03030000 */
        if (PyUnicode_READY(o) == -1) return NULL;
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        if (PyUnicode_IS_ASCII(o)) {
            *length = PyUnicode_GET_DATA_SIZE(o);
            return PyUnicode_AsUTF8(o);
        } else {
            PyUnicode_AsASCIIString(o);
            return NULL;
        }
#else /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */
        return PyUnicode_AsUTF8AndSize(o, length);
#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */
#endif /* PY_VERSION_HEX < 0x03030000 */
    } else
#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII  || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT */
    {
        char* result;
        int r = PyBytes_AsStringAndSize(o, &result, length);
        if (r < 0) {
            return NULL;
        } else {
            return result;
        }
    }
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  PyNumberMethods *m;
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_MAJOR_VERSION < 3
  if (PyInt_Check(x) || PyLong_Check(x))
#else
  if (PyLong_Check(x))
#endif
    return Py_INCREF(x), x;
  m = Py_TYPE(x)->tp_as_number;
#if PY_MAJOR_VERSION < 3
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = PyNumber_Long(x);
  }
#else
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Long(x);
  }
#endif
  if (res) {
#if PY_MAJOR_VERSION < 3
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%s__ returned non-%s (type %.200s)",
                   name, name, Py_TYPE(res)->tp_name);
      Py_DECREF(res);
      return NULL;
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject* x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
#if PY_VERSION_HEX < 0x02050000
   if (ival <= LONG_MAX)
       return PyInt_FromLong((long)ival);
   else {
       unsigned char *bytes = (unsigned char *) &ival;
       int one = 1; int little = (int)*(unsigned char*)&one;
       return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
   }
#else
   return PyInt_FromSize_t(ival);
#endif
}
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
   unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
   if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
       if ((val != (unsigned PY_LONG_LONG)-1) || !PyErr_Occurred())
           PyErr_SetString(PyExc_OverflowError,
                           "value too large to convert to size_t");
       return (size_t)-1;
   }
   return (size_t)val;
}


#endif /* Py_PYTHON_H */
