/* Generated by Cython 0.14.1 on Fri Jul 15 16:11:20 2011 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#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

#if PY_VERSION_HEX < 0x02040000
  #define METH_COEXIST 0
  #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
  #define PyDict_Contains(d,o)   PySequence_Contains(d,o)
#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 PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)   PyInt_AsLong(o)
  #define PyNumber_Index(o)    PyNumber_Int(o)
  #define PyIndex_Check(o)     PyNumber_Check(o)
  #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
#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)

#endif

#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
#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_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_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_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

#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

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

#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#define __PYX_HAVE_API__kivy__graphics__texture
#include "gl_redirect.h"
#include "math.h"
#include "stdlib.h"
#include "string.h"

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif


/* inline attribute */
#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

/* unused attribute */
#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)
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif

typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/


/* Type Conversion Predeclarations */

#define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
#define __Pyx_PyBytes_AsUString(s)   ((unsigned char*) PyBytes_AsString(s))

#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*);

#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))


#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_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",
};

/* Type declarations */

/* "kivy/graphics/texture.pxd":3
 * from c_opengl cimport GLuint
 * 
 * cdef class Texture:             # <<<<<<<<<<<<<<
 *     cdef float _tex_coords[8]
 *     cdef int _width
 */

struct __pyx_obj_4kivy_8graphics_7texture_Texture {
  PyObject_HEAD
  struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *__pyx_vtab;
  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;
  float _uvx;
  float _uvy;
  float _uvw;
  float _uvh;
  int _is_allocated;
};

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

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


/* "kivy/graphics/texture.pyx":521
 * 
 * 
 * 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 {
  PyObject *(*update_tex_coords)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *);
  PyObject *(*set_min_filter)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, PyObject *);
  PyObject *(*set_mag_filter)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, PyObject *);
  PyObject *(*set_wrap)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, PyObject *);
  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":823
 *             self.set_wrap(wrap)
 * 
 * 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;

#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) {
    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;
  }
  #define __Pyx_RefNannySetupContext(name)           void *__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  #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_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r);} } while(0)
#else
  #define __Pyx_RefNannySetupContext(name)
  #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_XDECREF(r) Py_XDECREF(r)
#endif /* CYTHON_REFNANNY */
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);} } while(0)
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r);} } while(0)

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/

static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void);

#if PY_MAJOR_VERSION >= 3
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
    PyObject *value;
    if (unlikely(d == Py_None)) {
        __Pyx_RaiseNoneIndexingError();
        return NULL;
    }
    value = PyDict_GetItemWithError(d, key);
    if (unlikely(!value)) {
        if (!PyErr_Occurred())
            PyErr_SetObject(PyExc_KeyError, key);
        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); /*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_RaiseNeedMoreValuesError(Py_ssize_t index);

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t index); /*proto*/
static int __Pyx_EndUnpack(PyObject *, Py_ssize_t expected); /*proto*/


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


#define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_List_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
    if (likely(o != Py_None)) {
        if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
            PyObject *r = PyList_GET_ITEM(o, i);
            Py_INCREF(r);
            return r;
        }
        else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
            PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
            Py_INCREF(r);
            return r;
        }
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Tuple_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
    if (likely(o != Py_None)) {
        if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, i);
            Py_INCREF(r);
            return r;
        }
        else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
            PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
            Py_INCREF(r);
            return r;
        }
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}


#define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
    PyObject *r;
    if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        r = PyList_GET_ITEM(o, i);
        Py_INCREF(r);
    }
    else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
        r = PyTuple_GET_ITEM(o, i);
        Py_INCREF(r);
    }
    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0))) {
        r = PySequence_GetItem(o, i);
    }
    else {
        r = __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
    }
    return r;
}

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

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict,
    const char* function_name, int kw_allowed); /*proto*/

static CYTHON_INLINE long __Pyx_NegateNonNeg(long b) { return unlikely(b < 0) ? b : !b; }
static CYTHON_INLINE PyObject* __Pyx_PyBoolOrNull_FromLong(long b) {
    return unlikely(b < 0) ? NULL : __Pyx_PyBool_FromLong(b);
}

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); /*proto*/

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_GLuint(GLuint);

static CYTHON_INLINE GLuint __Pyx_PyInt_from_py_GLuint(PyObject *);

#ifndef __PYX_FORCE_INIT_THREADS
  #if PY_VERSION_HEX < 0x02040200
    #define __PYX_FORCE_INIT_THREADS 1
  #else
    #define __PYX_FORCE_INIT_THREADS 0
  #endif
#endif

static CYTHON_INLINE GLenum __Pyx_PyInt_from_py_GLenum(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 void __Pyx_WriteUnraisable(const char *name); /*proto*/

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

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

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

static void __Pyx_AddTraceback(const char *funcname); /*proto*/

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
/* Module declarations from kivy.graphics.c_opengl */

/* Module declarations from kivy.graphics.opengl_utils */

static PyObject *(*__pyx_f_4kivy_8graphics_12opengl_utils_gl_get_extensions)(int __pyx_skip_dispatch); /*proto*/
static int (*__pyx_f_4kivy_8graphics_12opengl_utils_gl_has_extension)(PyObject *, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4kivy_8graphics_12opengl_utils_gl_register_get_size)(int, int, int __pyx_skip_dispatch); /*proto*/
static int (*__pyx_f_4kivy_8graphics_12opengl_utils_gl_has_capability)(int, int __pyx_skip_dispatch); /*proto*/
static PyObject *(*__pyx_f_4kivy_8graphics_12opengl_utils_gl_get_texture_formats)(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*/
static int (*__pyx_f_4kivy_8graphics_12opengl_utils_gl_has_texture_format)(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_GLCAP_BGRA;
static int __pyx_v_4kivy_8graphics_7texture_GLCAP_NPOT;
static int __pyx_v_4kivy_8graphics_7texture_GLCAP_S3TC;
static int __pyx_v_4kivy_8graphics_7texture_GLCAP_DXT1;
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 PyObject *__pyx_v_4kivy_8graphics_7texture__texture_release_trigger = 0;
static PyObject *__pyx_v_4kivy_8graphics_7texture__texture_release_list = 0;
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 int __pyx_f_4kivy_8graphics_7texture__is_gl_format_supported(PyObject *); /*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 PyObject *__pyx_f_4kivy_8graphics_7texture__texture_create(int, int, PyObject *, PyObject *, int, int); /*proto*/
#define __Pyx_MODULE_NAME "kivy.graphics.texture"
static 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 char __pyx_k_1[] = "Unknown <%s> color format";
static char __pyx_k_3[] = "Unknown <%s> buffer format";
static char __pyx_k_4[] = "Unknown <%s> format";
static char __pyx_k_5[] = "Unknown <%s> texture min filter";
static char __pyx_k_6[] = "Unknown <%s> texture mag filter";
static char __pyx_k_7[] = "Unsupported format size <%s>";
static char __pyx_k_9[] = "Unimplemented texture conversion for %s";
static char __pyx_k_18[] = "Non implemented texture conversion !";
static char __pyx_k_19[] = "linear_mipmap_nearest";
static char __pyx_k_20[] = "Unable to allocate memory for texture (size is %s)";
static char __pyx_k_26[] = "<Texture id=%d size=(%d, %d)>";
static char __pyx_k_27[] = "<TextureRegion id=%d size=(%d, %d)>";
static char __pyx_k_28[] = "Texture: releasing %d textures";
static char __pyx_k_29[] = "Return the (width, height) of the texture (readonly)\n        ";
static char __pyx_k_30[] = "Return True if the texture have mipmap enabled (readonly)\n        ";
static char __pyx_k_31[] = "Return the OpenGL ID of the texture (readonly)\n        ";
static char __pyx_k_32[] = "Return the OpenGL target of the texture (readonly)\n        ";
static char __pyx_k_33[] = "Return the width of the texture (readonly)\n        ";
static char __pyx_k_34[] = "Return the height of the texture (readonly)\n        ";
static char __pyx_k_35[] = "Return the list of tex_coords (opengl)\n        ";
static char __pyx_k_36[] = "Get/set the UV position inside texture\n        ";
static char __pyx_k_37[] = "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_38[] = "Return the color format used in this texture. (readonly)\n\n        .. versionadded:: 1.0.7\n        ";
static char __pyx_k_39[] = "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_40[] = "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_41[] = "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_42[] = "\nTexture\n=======\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` instead.\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\ninformations.\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\n";
static char __pyx_k_44[] = "kivy.logger";
static char __pyx_k_45[] = "nearest_mipmap_nearest";
static char __pyx_k_46[] = "nearest_mipmap_linear";
static char __pyx_k_47[] = "linear_mipmap_linear";
static char __pyx_k_48[] = "kivy.graphics.texture";
static char __pyx_k_49[] = "texture_create_from_data";
static char __pyx_k_50[] = "kivy.clock";
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__os[] = "os";
static char __pyx_k___id[] = "_id";
static char __pyx_k__bgr[] = "bgr";
static char __pyx_k__fmt[] = "fmt";
static char __pyx_k__int[] = "int";
static char __pyx_k__pos[] = "pos";
static char __pyx_k__rgb[] = "rgb";
static char __pyx_k___uvh[] = "_uvh";
static char __pyx_k___uvw[] = "_uvw";
static char __pyx_k___uvx[] = "_uvx";
static char __pyx_k___uvy[] = "_uvy";
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__rgba[] = "rgba";
static char __pyx_k__size[] = "size";
static char __pyx_k__uint[] = "uint";
static char __pyx_k__Clock[] = "Clock";
static char __pyx_k___wrap[] = "_wrap";
static char __pyx_k__array[] = "array";
static char __pyx_k__float[] = "float";
static char __pyx_k__lower[] = "lower";
static char __pyx_k__owner[] = "owner";
static char __pyx_k__short[] = "short";
static char __pyx_k__texid[] = "texid";
static char __pyx_k__trace[] = "trace";
static char __pyx_k__ubyte[] = "ubyte";
static char __pyx_k__width[] = "width";
static char __pyx_k__Logger[] = "Logger";
static char __pyx_k___width[] = "_width";
static char __pyx_k__append[] = "append";
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__mipmap[] = "mipmap";
static char __pyx_k__origin[] = "origin";
static char __pyx_k__repeat[] = "repeat";
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___height[] = "_height";
static char __pyx_k___mipmap[] = "_mipmap";
static char __pyx_k___target[] = "_target";
static char __pyx_k__environ[] = "environ";
static char __pyx_k__nearest[] = "nearest";
static char __pyx_k__pbuffer[] = "pbuffer";
static char __pyx_k__KeyError[] = "KeyError";
static char __pyx_k____init__[] = "__init__";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k__colorfmt[] = "colorfmt";
static char __pyx_k__s3tc_dxt[] = "s3tc_dxt";
static char __pyx_k__set_wrap[] = "set_wrap";
static char __pyx_k__tostring[] = "tostring";
static char __pyx_k__Exception[] = "Exception";
static char __pyx_k___colorfmt[] = "_colorfmt";
static char __pyx_k__blit_data[] = "blit_data";
static char __pyx_k__bufferfmt[] = "bufferfmt";
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__get_region[] = "get_region";
static char __pyx_k__startswith[] = "startswith";
static char __pyx_k___mag_filter[] = "_mag_filter";
static char __pyx_k___min_filter[] = "_min_filter";
static char __pyx_k___tex_coords[] = "_tex_coords";
static char __pyx_k__blit_buffer[] = "blit_buffer";
static char __pyx_k__have_mipmap[] = "have_mipmap";
static char __pyx_k__mipmap_level[] = "mipmap_level";
static char __pyx_k__staticmethod[] = "staticmethod";
static char __pyx_k__TextureRegion[] = "TextureRegion";
static char __pyx_k___is_allocated[] = "_is_allocated";
static char __pyx_k__clamp_to_edge[] = "clamp_to_edge";
static char __pyx_k__flip_vertical[] = "flip_vertical";
static char __pyx_k__create_trigger[] = "create_trigger";
static char __pyx_k__set_mag_filter[] = "set_mag_filter";
static char __pyx_k__set_min_filter[] = "set_min_filter";
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__KIVY_DOC_INCLUDE[] = "KIVY_DOC_INCLUDE";
static char __pyx_k___texture_release[] = "_texture_release";
static char __pyx_k__create_from_data[] = "create_from_data";
static char __pyx_k__mipmap_generation[] = "mipmap_generation";
static char __pyx_k__update_tex_coords[] = "update_tex_coords";
static PyObject *__pyx_kp_s_1;
static PyObject *__pyx_kp_s_18;
static PyObject *__pyx_n_s_19;
static PyObject *__pyx_kp_s_20;
static PyObject *__pyx_kp_s_26;
static PyObject *__pyx_kp_s_27;
static PyObject *__pyx_kp_s_28;
static PyObject *__pyx_kp_s_3;
static PyObject *__pyx_kp_s_4;
static PyObject *__pyx_n_s_44;
static PyObject *__pyx_n_s_45;
static PyObject *__pyx_n_s_46;
static PyObject *__pyx_n_s_47;
static PyObject *__pyx_n_s_48;
static PyObject *__pyx_n_s_49;
static PyObject *__pyx_kp_s_5;
static PyObject *__pyx_n_s_50;
static PyObject *__pyx_kp_s_6;
static PyObject *__pyx_kp_s_7;
static PyObject *__pyx_kp_s_9;
static PyObject *__pyx_n_s__Clock;
static PyObject *__pyx_n_s__Exception;
static PyObject *__pyx_n_s__KIVY_DOC_INCLUDE;
static PyObject *__pyx_n_s__KeyError;
static PyObject *__pyx_n_s__Logger;
static PyObject *__pyx_n_s__Texture;
static PyObject *__pyx_n_s__TextureRegion;
static PyObject *__pyx_n_s____all__;
static PyObject *__pyx_n_s____init__;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s___colorfmt;
static PyObject *__pyx_n_s___height;
static PyObject *__pyx_n_s___id;
static PyObject *__pyx_n_s___is_allocated;
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___target;
static PyObject *__pyx_n_s___tex_coords;
static PyObject *__pyx_n_s___texture_release;
static PyObject *__pyx_n_s___uvh;
static PyObject *__pyx_n_s___uvw;
static PyObject *__pyx_n_s___uvx;
static PyObject *__pyx_n_s___uvy;
static PyObject *__pyx_n_s___width;
static PyObject *__pyx_n_s___wrap;
static PyObject *__pyx_n_s__append;
static PyObject *__pyx_n_s__array;
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__clamp_to_edge;
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__create_trigger;
static PyObject *__pyx_n_s__data;
static PyObject *__pyx_n_s__environ;
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__get_region;
static PyObject *__pyx_n_s__have_mipmap;
static PyObject *__pyx_n_s__height;
static PyObject *__pyx_n_s__id;
static PyObject *__pyx_n_s__im;
static PyObject *__pyx_n_s__int;
static PyObject *__pyx_n_s__iterate_mipmaps;
static PyObject *__pyx_n_s__linear;
static PyObject *__pyx_n_s__lower;
static PyObject *__pyx_n_s__luminance;
static PyObject *__pyx_n_s__luminance_alpha;
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__origin;
static PyObject *__pyx_n_s__os;
static PyObject *__pyx_n_s__owner;
static PyObject *__pyx_n_s__pbuffer;
static PyObject *__pyx_n_s__pos;
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__set_mag_filter;
static PyObject *__pyx_n_s__set_min_filter;
static PyObject *__pyx_n_s__set_wrap;
static PyObject *__pyx_n_s__short;
static PyObject *__pyx_n_s__size;
static PyObject *__pyx_n_s__startswith;
static PyObject *__pyx_n_s__staticmethod;
static PyObject *__pyx_n_s__target;
static PyObject *__pyx_n_s__texid;
static PyObject *__pyx_n_s__texture_create;
static PyObject *__pyx_n_s__tostring;
static PyObject *__pyx_n_s__trace;
static PyObject *__pyx_n_s__ubyte;
static PyObject *__pyx_n_s__uint;
static PyObject *__pyx_n_s__update_tex_coords;
static PyObject *__pyx_n_s__ushort;
static PyObject *__pyx_n_s__width;
static PyObject *__pyx_n_s__x;
static PyObject *__pyx_n_s__y;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_3;
static PyObject *__pyx_int_4;
static PyObject *__pyx_k_21;
static PyObject *__pyx_k_22;
static PyObject *__pyx_k_23;
static PyObject *__pyx_k_24;
static PyObject *__pyx_k_tuple_2;
static PyObject *__pyx_k_tuple_8;
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_slice_16;
static PyObject *__pyx_k_slice_17;
static PyObject *__pyx_k_tuple_25;
static PyObject *__pyx_k_tuple_43;

/* "kivy/graphics/texture.pyx":203
 * 
 * 
 * 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_RefNannySetupContext("_nearest_pow2");

  /* "kivy/graphics/texture.pyx":206
 *     # 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":207
 *     # 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":208
 *     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":209
 *     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":210
 *     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":211
 *     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":212
 *     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":215
 * 
 * 
 * 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_RefNannySetupContext("_is_pow2");

  /* "kivy/graphics/texture.pyx":217
 * 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":220
 * 
 * 
 * cdef inline int _color_fmt_to_gl(str 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;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("_color_fmt_to_gl");
  __Pyx_INCREF(__pyx_v_x);

  /* "kivy/graphics/texture.pyx":223
 *     '''Return the GL numeric value from a color string format
 *     '''
 *     x = x.lower()             # <<<<<<<<<<<<<<
 *     try:
 *         return _gl_color_fmt[x]
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_x), __pyx_n_s__lower); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __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 = 223; __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 = 223; __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":224
 *     '''
 *     x = x.lower()
 *     try:             # <<<<<<<<<<<<<<
 *         return _gl_color_fmt[x]
 *     except KeyError:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "kivy/graphics/texture.pyx":225
 *     x = x.lower()
 *     try:
 *         return _gl_color_fmt[x]             # <<<<<<<<<<<<<<
 *     except KeyError:
 *         raise Exception('Unknown <%s> color format' % x)
 */
      __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 = 225; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_3;
      goto __pyx_L7_try_return;
    }
    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L10_try_end;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    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":226
 *     try:
 *         return _gl_color_fmt[x]
 *     except KeyError:             # <<<<<<<<<<<<<<
 *         raise Exception('Unknown <%s> color format' % x)
 * 
 */
    __pyx_t_3 = PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_3) {
      __Pyx_AddTraceback("kivy.graphics.texture._color_fmt_to_gl");
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_4);

      /* "kivy/graphics/texture.pyx":227
 *         return _gl_color_fmt[x]
 *     except KeyError:
 *         raise Exception('Unknown <%s> color format' % x)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_1), ((PyObject *)__pyx_v_x)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(((PyObject *)__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 = 227; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __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_4); __pyx_t_4 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __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_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("kivy.graphics.texture._color_fmt_to_gl");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_x);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":230
 * 
 * 
 * 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;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("_is_compressed_fmt");

  /* "kivy/graphics/texture.pyx":233
 *     '''Return 1 if the color string format is a compressed one
 *     '''
 *     return x.startswith('s3tc_dxt')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_x), __pyx_n_s__startswith); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_2), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_WriteUnraisable("kivy.graphics.texture._is_compressed_fmt");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":236
 * 
 * 
 * cdef inline int _buffer_fmt_to_gl(str 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;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("_buffer_fmt_to_gl");
  __Pyx_INCREF(__pyx_v_x);

  /* "kivy/graphics/texture.pyx":239
 *     '''Return the GL numeric value from a buffer string format
 *     '''
 *     x = x.lower()             # <<<<<<<<<<<<<<
 *     try:
 *         return _gl_buffer_fmt[x]
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_x), __pyx_n_s__lower); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __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 = 239; __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 = 239; __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":240
 *     '''
 *     x = x.lower()
 *     try:             # <<<<<<<<<<<<<<
 *         return _gl_buffer_fmt[x]
 *     except KeyError:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "kivy/graphics/texture.pyx":241
 *     x = x.lower()
 *     try:
 *         return _gl_buffer_fmt[x]             # <<<<<<<<<<<<<<
 *     except KeyError:
 *         raise Exception('Unknown <%s> buffer format' % x)
 */
      __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 = 241; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_3;
      goto __pyx_L7_try_return;
    }
    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L10_try_end;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    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":242
 *     try:
 *         return _gl_buffer_fmt[x]
 *     except KeyError:             # <<<<<<<<<<<<<<
 *         raise Exception('Unknown <%s> buffer format' % x)
 * 
 */
    __pyx_t_3 = PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_3) {
      __Pyx_AddTraceback("kivy.graphics.texture._buffer_fmt_to_gl");
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 242; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_4);

      /* "kivy/graphics/texture.pyx":243
 *         return _gl_buffer_fmt[x]
 *     except KeyError:
 *         raise Exception('Unknown <%s> buffer format' % x)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_3), ((PyObject *)__pyx_v_x)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(((PyObject *)__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 = 243; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 243; __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_4); __pyx_t_4 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __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_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("kivy.graphics.texture._buffer_fmt_to_gl");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_x);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":246
 * 
 * 
 * cdef inline int _buffer_type_to_gl_size(str 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;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("_buffer_type_to_gl_size");
  __Pyx_INCREF(__pyx_v_x);

  /* "kivy/graphics/texture.pyx":249
 *     '''Return the size of a buffer string format in bytes
 *     '''
 *     x = x.lower()             # <<<<<<<<<<<<<<
 *     try:
 *         return _gl_buffer_size[x]
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_x), __pyx_n_s__lower); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 249; __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 = 249; __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 = 249; __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":250
 *     '''
 *     x = x.lower()
 *     try:             # <<<<<<<<<<<<<<
 *         return _gl_buffer_size[x]
 *     except KeyError:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "kivy/graphics/texture.pyx":251
 *     x = x.lower()
 *     try:
 *         return _gl_buffer_size[x]             # <<<<<<<<<<<<<<
 *     except KeyError:
 *         raise Exception('Unknown <%s> format' % x)
 */
      __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 = 251; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_3;
      goto __pyx_L7_try_return;
    }
    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L10_try_end;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    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":252
 *     try:
 *         return _gl_buffer_size[x]
 *     except KeyError:             # <<<<<<<<<<<<<<
 *         raise Exception('Unknown <%s> format' % x)
 * 
 */
    __pyx_t_3 = PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_3) {
      __Pyx_AddTraceback("kivy.graphics.texture._buffer_type_to_gl_size");
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_4);

      /* "kivy/graphics/texture.pyx":253
 *         return _gl_buffer_size[x]
 *     except KeyError:
 *         raise Exception('Unknown <%s> format' % x)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), ((PyObject *)__pyx_v_x)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_5));
      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(((PyObject *)__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 = 253; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
      __Pyx_Raise(__pyx_t_5, 0, 0);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __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_4); __pyx_t_4 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __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_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("kivy.graphics.texture._buffer_type_to_gl_size");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_x);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":256
 * 
 * 
 * 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;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  GLuint __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_RefNannySetupContext("_str_to_gl_texture_min_filter");
  __Pyx_INCREF(__pyx_v_x);

  /* "kivy/graphics/texture.pyx":259
 *     '''Return the GL numeric value from a texture min filter string
 *     '''
 *     x = x.lower()             # <<<<<<<<<<<<<<
 *     try:
 *         return _gl_texture_min_filter[x]
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_x), __pyx_n_s__lower); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 259; __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 = 259; __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 = 259; __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":260
 *     '''
 *     x = x.lower()
 *     try:             # <<<<<<<<<<<<<<
 *         return _gl_texture_min_filter[x]
 *     except KeyError:
 */
  {
    PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
    __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
    __Pyx_XGOTREF(__pyx_save_exc_type);
    __Pyx_XGOTREF(__pyx_save_exc_value);
    __Pyx_XGOTREF(__pyx_save_exc_tb);
    /*try:*/ {

      /* "kivy/graphics/texture.pyx":261
 *     x = x.lower()
 *     try:
 *         return _gl_texture_min_filter[x]             # <<<<<<<<<<<<<<
 *     except KeyError:
 *         raise Exception('Unknown <%s> texture min filter' % x)
 */
      __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 = 261; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyInt_from_py_GLuint(__pyx_t_2); if (unlikely((__pyx_t_3 == (GLuint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_3;
      goto __pyx_L7_try_return;
    }
    __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
    __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
    __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
    goto __pyx_L10_try_end;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    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":262
 *     try:
 *         return _gl_texture_min_filter[x]
 *     except KeyError:             # <<<<<<<<<<<<<<
 *         raise Exception('Unknown <%s> texture min filter' % x)
 * 
 */
    __pyx_t_4 = PyErr_ExceptionMatches(__pyx_builtin_KeyError);
    if (__pyx_t_4) {
      __Pyx_AddTraceback("kivy.graphics.texture._str_to_gl_texture_min_filter");
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_5);

      /* "kivy/graphics/texture.pyx":263
 *         return _gl_texture_min_filter[x]
 *     except KeyError:
 *         raise Exception('Unknown <%s> texture min filter' % x)             # <<<<<<<<<<<<<<
 * 
 * 
 */
      __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), ((PyObject *)__pyx_v_x)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_6));
      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_7));
      PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_6));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
      __pyx_t_6 = 0;
      __pyx_t_6 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
      __Pyx_Raise(__pyx_t_6, 0, 0);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __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_5); __pyx_t_5 = 0;
      goto __pyx_L4_exception_handled;
    }
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_save_exc_type);
    __Pyx_XGIVEREF(__pyx_save_exc_value);
    __Pyx_XGIVEREF(__pyx_save_exc_tb);
    __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
    __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_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_WriteUnraisable("kivy.graphics.texture._str_to_gl_texture_min_filter");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_x);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":266
 * 
 * 
 * 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;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("_str_to_gl_texture_mag_filter");
  __Pyx_INCREF(__pyx_v_x);

  /* "kivy/graphics/texture.pyx":269
 *     '''Return the GL numeric value from a texture mag filter string
 *     '''
 *     x = x.lower()             # <<<<<<<<<<<<<<
 *     if x == 'nearest':
 *         return GL_NEAREST
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_x), __pyx_n_s__lower); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __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 = 269; __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 = 269; __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":270
 *     '''
 *     x = x.lower()
 *     if x == 'nearest':             # <<<<<<<<<<<<<<
 *         return GL_NEAREST
 *     elif x == 'linear':
 */
  __pyx_t_2 = PyObject_RichCompare(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_n_s__nearest), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "kivy/graphics/texture.pyx":271
 *     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":272
 *     if x == 'nearest':
 *         return GL_NEAREST
 *     elif x == 'linear':             # <<<<<<<<<<<<<<
 *         return GL_LINEAR
 *     raise Exception('Unknown <%s> texture mag filter' % x)
 */
  __pyx_t_2 = PyObject_RichCompare(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_n_s__linear), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "kivy/graphics/texture.pyx":273
 *         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":274
 *     elif x == 'linear':
 *         return GL_LINEAR
 *     raise Exception('Unknown <%s> texture mag filter' % x)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_6), ((PyObject *)__pyx_v_x)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __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 = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__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 = 274; __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);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __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_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_x);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":277
 * 
 * 
 * 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;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("_str_to_gl_texture_wrap");

  /* "kivy/graphics/texture.pyx":280
 *     '''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 = PyObject_RichCompare(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_n_s__clamp_to_edge), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __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 = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "kivy/graphics/texture.pyx":281
 *     '''
 *     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":282
 *     if x == 'clamp_to_edge':
 *         return GL_CLAMP_TO_EDGE
 *     elif x == 'repeat':             # <<<<<<<<<<<<<<
 *         return GL_REPEAT
 *     elif x == 'mirrored_repeat':
 */
  __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_n_s__repeat), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __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 = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "kivy/graphics/texture.pyx":283
 *         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":284
 *     elif x == 'repeat':
 *         return GL_REPEAT
 *     elif x == 'mirrored_repeat':             # <<<<<<<<<<<<<<
 *         return GL_MIRRORED_REPEAT
 * 
 */
  __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_n_s__mirrored_repeat), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __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 = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "kivy/graphics/texture.pyx":285
 *         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_XDECREF(__pyx_t_1);
  __Pyx_WriteUnraisable("kivy.graphics.texture._str_to_gl_texture_wrap");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":288
 * 
 * 
 * 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;
  GLuint __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("_gl_format_size");

  /* "kivy/graphics/texture.pyx":291
 *     '''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;
  if (!(__pyx_t_1 == GL_RGB)) {
    __pyx_t_2 = (__pyx_t_1 == __pyx_v_4kivy_8graphics_7texture_GL_BGR);
  } else {
    __pyx_t_2 = (__pyx_t_1 == GL_RGB);
  }
  __pyx_t_3 = __pyx_t_2;
  if (__pyx_t_3) {

    /* "kivy/graphics/texture.pyx":292
 *     '''
 *     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":293
 *     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;
  if (!(__pyx_t_1 == GL_RGBA)) {
    __pyx_t_3 = (__pyx_t_1 == __pyx_v_4kivy_8graphics_7texture_GL_BGRA);
  } else {
    __pyx_t_3 = (__pyx_t_1 == GL_RGBA);
  }
  __pyx_t_2 = __pyx_t_3;
  if (__pyx_t_2) {

    /* "kivy/graphics/texture.pyx":294
 *         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":295
 *     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);
  if (__pyx_t_2) {

    /* "kivy/graphics/texture.pyx":296
 *         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":297
 *     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);
  if (__pyx_t_2) {

    /* "kivy/graphics/texture.pyx":298
 *         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":299
 *     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;
  if (!(__pyx_t_1 == __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT)) {

    /* "kivy/graphics/texture.pyx":300
 *         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_2 = (__pyx_t_1 == __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT);
  } else {
    __pyx_t_2 = (__pyx_t_1 == __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT);
  }
  if (!__pyx_t_2) {

    /* "kivy/graphics/texture.pyx":301
 *     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_3 = (__pyx_t_1 == __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT);
  } else {
    __pyx_t_3 = __pyx_t_2;
  }
  __pyx_t_2 = __pyx_t_3;
  if (__pyx_t_2) {

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

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("kivy.graphics.texture._gl_format_size");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":306
 * 
 * 
 * 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;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("_is_gl_format_supported");

  /* "kivy/graphics/texture.pyx":307
 * 
 * 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 = PyObject_RichCompare(((PyObject *)__pyx_t_1), ((PyObject *)__pyx_n_s__bgr), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (!__pyx_t_3) {
    __pyx_t_2 = PyObject_RichCompare(((PyObject *)__pyx_t_1), ((PyObject *)__pyx_n_s__bgra), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = __pyx_t_4;
  } else {
    __pyx_t_5 = __pyx_t_3;
  }
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_3 = __pyx_t_5;
  if (__pyx_t_3) {

    /* "kivy/graphics/texture.pyx":308
 * 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_r = __pyx_f_4kivy_8graphics_12opengl_utils_gl_has_capability(__pyx_v_4kivy_8graphics_7texture_GLCAP_BGRA, 0);
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "kivy/graphics/texture.pyx":309
 *     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 = PyObject_RichCompare(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_n_s__s3tc_dxt1), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

    /* "kivy/graphics/texture.pyx":310
 *         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_r = __pyx_f_4kivy_8graphics_12opengl_utils_gl_has_capability(__pyx_v_4kivy_8graphics_7texture_GLCAP_DXT1, 0);
    goto __pyx_L0;
    goto __pyx_L3;
  }

  /* "kivy/graphics/texture.pyx":311
 *     elif x == 's3tc_dxt1':
 *         return gl_has_capability(GLCAP_DXT1)
 *     elif x.startswith('s3tc_dxt'):             # <<<<<<<<<<<<<<
 *         return gl_has_capability(GLCAP_S3TC)
 *     return 1
 */
  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_x), __pyx_n_s__startswith); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_8), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (__pyx_t_3) {

    /* "kivy/graphics/texture.pyx":312
 *         return gl_has_capability(GLCAP_DXT1)
 *     elif x.startswith('s3tc_dxt'):
 *         return gl_has_capability(GLCAP_S3TC)             # <<<<<<<<<<<<<<
 *     return 1
 * 
 */
    __pyx_r = __pyx_f_4kivy_8graphics_12opengl_utils_gl_has_capability(__pyx_v_4kivy_8graphics_7texture_GLCAP_S3TC, 0);
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "kivy/graphics/texture.pyx":313
 *     elif x.startswith('s3tc_dxt'):
 *         return gl_has_capability(GLCAP_S3TC)
 *     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_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_WriteUnraisable("kivy.graphics.texture._is_gl_format_supported");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":316
 * 
 * 
 * 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;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("_convert_gl_format");

  /* "kivy/graphics/texture.pyx":317
 * 
 * cdef inline str _convert_gl_format(str x):
 *     if x == 'bgr':             # <<<<<<<<<<<<<<
 *         return 'rgb'
 *     elif x == 'bgra':
 */
  __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_n_s__bgr), Py_EQ); 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 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "kivy/graphics/texture.pyx":318
 * 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":319
 *     if x == 'bgr':
 *         return 'rgb'
 *     elif x == 'bgra':             # <<<<<<<<<<<<<<
 *         return 'rgba'
 *     return x
 */
  __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_n_s__bgra), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __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 = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "kivy/graphics/texture.pyx":320
 *         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":321
 *     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_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("kivy.graphics.texture._convert_gl_format");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":324
 * 
 * 
 * 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;
  PyObject *__pyx_v_ret_format;
  PyObject *__pyx_v_a;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("_convert_buffer");
  __pyx_v_ret_buffer = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_ret_format = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_a = Py_None; __Pyx_INCREF(Py_None);

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

    /* "kivy/graphics/texture.pyx":330
 *     # 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_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_INCREF(((PyObject *)__pyx_v_data));
    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_data));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_data));
    __Pyx_INCREF(((PyObject *)__pyx_v_fmt));
    PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_fmt));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_fmt));
    __pyx_r = ((PyObject *)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "kivy/graphics/texture.pyx":333
 * 
 *     # 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 = ((PyObject *)__pyx_v_fmt);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_3 = (!__pyx_f_4kivy_8graphics_12opengl_utils_gl_has_texture_conversion(((PyObject*)__pyx_t_1), 0));
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_3) {

    /* "kivy/graphics/texture.pyx":334
 *     # 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_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), ((PyObject *)__pyx_v_fmt)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_1));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
    __pyx_t_1 = 0;
    __pyx_t_1 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_Raise(__pyx_t_1, 0, 0);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

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

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

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

    /* "kivy/graphics/texture.pyx":342
 *     # 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":343
 *     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_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__array); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_INCREF(((PyObject *)__pyx_n_s__b));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_n_s__b));
    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__b));
    __Pyx_INCREF(((PyObject *)__pyx_v_data));
    PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_data));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_data));
    __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __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_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_v_a);
    __pyx_v_a = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "kivy/graphics/texture.pyx":344
 *         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_10); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = PyObject_GetItem(__pyx_v_a, __pyx_k_slice_11); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    if (PyObject_SetItem(__pyx_v_a, __pyx_k_slice_12, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __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_13, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "kivy/graphics/texture.pyx":345
 *         a = array('b', data)
 *         a[0::3], a[2::3] = a[2::3], a[0::3]
 *         ret_buffer = a.tostring()             # <<<<<<<<<<<<<<
 * 
 *     # BGRA -> RGBA
 */
    __pyx_t_4 = PyObject_GetAttr(__pyx_v_a, __pyx_n_s__tostring); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 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 = 345; __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":348
 * 
 *     # BGRA -> RGBA
 *     elif fmt == 'bgra':             # <<<<<<<<<<<<<<
 *         ret_format = 'rgba'
 *         a = array('b', data)
 */
  __pyx_t_5 = PyObject_RichCompare(((PyObject *)__pyx_v_fmt), ((PyObject *)__pyx_n_s__bgra), Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_3) {

    /* "kivy/graphics/texture.pyx":349
 *     # 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":350
 *     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_GetName(__pyx_m, __pyx_n_s__array); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_INCREF(((PyObject *)__pyx_n_s__b));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_n_s__b));
    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__b));
    __Pyx_INCREF(((PyObject *)__pyx_v_data));
    PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_v_data));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_data));
    __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_v_a);
    __pyx_v_a = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "kivy/graphics/texture.pyx":351
 *         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_1 = PyObject_GetItem(__pyx_v_a, __pyx_k_slice_14); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyObject_GetItem(__pyx_v_a, __pyx_k_slice_15); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    if (PyObject_SetItem(__pyx_v_a, __pyx_k_slice_16, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (PyObject_SetItem(__pyx_v_a, __pyx_k_slice_17, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

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

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

  /* "kivy/graphics/texture.pyx":357
 *         assert False, 'Non implemented texture conversion !' % fmt
 * 
 *     return ret_buffer, ret_format             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(((PyObject *)__pyx_v_ret_buffer));
  PyTuple_SET_ITEM(__pyx_t_1, 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_1, 1, ((PyObject *)__pyx_v_ret_format));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_ret_format));
  __pyx_r = ((PyObject *)__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_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("kivy.graphics.texture._convert_buffer");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_ret_buffer);
  __Pyx_DECREF(__pyx_v_ret_format);
  __Pyx_DECREF(__pyx_v_a);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":360
 * 
 * 
 * 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":363
 *     '''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));
  if (__pyx_t_1) {

    /* "kivy/graphics/texture.pyx":364
 *     '''
 *     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":365
 *     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));
  if (__pyx_t_1) {

    /* "kivy/graphics/texture.pyx":366
 *         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":367
 *     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));
  if (__pyx_t_1) {

    /* "kivy/graphics/texture.pyx":368
 *         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":370
 *         glPixelStorei(GL_UNPACK_ALIGNMENT, 2)
 *     else:
 *         glPixelStorei(GL_UNPACK_ALIGNMENT, 1)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  }
  __pyx_L3:;

}

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

static  PyObject *__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) {
  GLuint __pyx_v_target;
  GLuint __pyx_v_texid;
  struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_texture;
  int __pyx_v_texture_width;
  int __pyx_v_texture_height;
  int __pyx_v_glbufferfmt;
  int __pyx_v_make_npot;
  int __pyx_v_glfmt;
  int __pyx_v_iglbufferfmt;
  int __pyx_v_datasize;
  int __pyx_v_dataerr;
  void *__pyx_v_data;
  PyObject *__pyx_r = NULL;
  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;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_RefNannySetupContext("_texture_create");
  __Pyx_INCREF(__pyx_v_colorfmt);
  __pyx_v_texture = ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)Py_None); __Pyx_INCREF(Py_None);

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

  /* "kivy/graphics/texture.pyx":381
 *     cdef Texture texture
 *     cdef int texture_width, texture_height
 *     cdef int glbufferfmt = _buffer_fmt_to_gl(bufferfmt)             # <<<<<<<<<<<<<<
 *     cdef int make_npot = 0
 *     cdef int glfmt, iglbufferfmt, datasize, dataerr = 0
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_bufferfmt);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_glbufferfmt = __pyx_f_4kivy_8graphics_7texture__buffer_fmt_to_gl(((PyObject*)__pyx_t_1));
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "kivy/graphics/texture.pyx":382
 *     cdef int texture_width, texture_height
 *     cdef int glbufferfmt = _buffer_fmt_to_gl(bufferfmt)
 *     cdef int make_npot = 0             # <<<<<<<<<<<<<<
 *     cdef int glfmt, iglbufferfmt, datasize, dataerr = 0
 *     cdef void *data = NULL
 */
  __pyx_v_make_npot = 0;

  /* "kivy/graphics/texture.pyx":383
 *     cdef int glbufferfmt = _buffer_fmt_to_gl(bufferfmt)
 *     cdef int make_npot = 0
 *     cdef int glfmt, iglbufferfmt, datasize, dataerr = 0             # <<<<<<<<<<<<<<
 *     cdef void *data = NULL
 * 
 */
  __pyx_v_dataerr = 0;

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

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

    /* "kivy/graphics/texture.pyx":388
 *     # check if it's a pot or not
 *     if not _is_pow2(width) or not _is_pow2(height):
 *         make_npot = 1             # <<<<<<<<<<<<<<
 * 
 *     # in case of mipmap is asked for npot texture, make it pot compatible
 */
    __pyx_v_make_npot = 1;
    goto __pyx_L3;
  }
  __pyx_L3:;

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

    /* "kivy/graphics/texture.pyx":392
 *     # in case of mipmap is asked for npot texture, make it pot compatible
 *     if mipmap:
 *         make_npot = 0             # <<<<<<<<<<<<<<
 * 
 *     # depending if npot is available, use the real size or pot size
 */
    __pyx_v_make_npot = 0;
    goto __pyx_L4;
  }
  __pyx_L4:;

  /* "kivy/graphics/texture.pyx":395
 * 
 *     # depending if npot is available, use the real size or pot size
 *     if make_npot and gl_has_capability(GLCAP_NPOT):             # <<<<<<<<<<<<<<
 *         texture_width = width
 *         texture_height = height
 */
  if (__pyx_v_make_npot) {
    __pyx_t_5 = __pyx_f_4kivy_8graphics_12opengl_utils_gl_has_capability(__pyx_v_4kivy_8graphics_7texture_GLCAP_NPOT, 0);
    __pyx_t_4 = __pyx_t_5;
  } else {
    __pyx_t_4 = __pyx_v_make_npot;
  }
  if (__pyx_t_4) {

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

    /* "kivy/graphics/texture.pyx":397
 *     if make_npot and gl_has_capability(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":399
 *         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":400
 *     else:
 *         texture_width = _nearest_pow2(width)
 *         texture_height = _nearest_pow2(height)             # <<<<<<<<<<<<<<
 * 
 *     # generate the texture
 */
    __pyx_v_texture_height = __pyx_f_4kivy_8graphics_7texture__nearest_pow2(__pyx_v_height);
  }
  __pyx_L5:;

  /* "kivy/graphics/texture.pyx":403
 * 
 *     # generate the texture
 *     glGenTextures(1, &texid)             # <<<<<<<<<<<<<<
 * 
 *     # if the color format is not supported, create the texture with the future
 */
  glGenTextures(1, (&__pyx_v_texid));

  /* "kivy/graphics/texture.pyx":407
 *     # if the color format is not supported, create the texture with the future
 *     # color format.
 *     if not _is_gl_format_supported(colorfmt):             # <<<<<<<<<<<<<<
 *         colorfmt = _convert_gl_format(colorfmt)
 * 
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_colorfmt);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_4 = (!__pyx_f_4kivy_8graphics_7texture__is_gl_format_supported(((PyObject*)__pyx_t_1)));
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_4) {

    /* "kivy/graphics/texture.pyx":408
 *     # color format.
 *     if not _is_gl_format_supported(colorfmt):
 *         colorfmt = _convert_gl_format(colorfmt)             # <<<<<<<<<<<<<<
 * 
 *     texture = Texture(texture_width, texture_height, target, texid,
 */
    __pyx_t_1 = ((PyObject *)__pyx_v_colorfmt);
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_6 = ((PyObject *)__pyx_f_4kivy_8graphics_7texture__convert_gl_format(((PyObject*)__pyx_t_1))); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_v_colorfmt));
    __pyx_v_colorfmt = ((PyObject*)__pyx_t_6);
    __pyx_t_6 = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "kivy/graphics/texture.pyx":410
 *         colorfmt = _convert_gl_format(colorfmt)
 * 
 *     texture = Texture(texture_width, texture_height, target, texid,             # <<<<<<<<<<<<<<
 *                       colorfmt=colorfmt, mipmap=mipmap)
 * 
 */
  __pyx_t_6 = PyInt_FromLong(__pyx_v_texture_width); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = PyInt_FromLong(__pyx_v_texture_height); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyInt_to_py_GLuint(__pyx_v_target); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyInt_to_py_GLuint(__pyx_v_texid); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = PyTuple_New(4); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_9));
  PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_7);
  PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_8);
  __Pyx_GIVEREF(__pyx_t_8);
  __pyx_t_6 = 0;
  __pyx_t_1 = 0;
  __pyx_t_7 = 0;
  __pyx_t_8 = 0;
  __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_8));

  /* "kivy/graphics/texture.pyx":411
 * 
 *     texture = Texture(texture_width, texture_height, target, texid,
 *                       colorfmt=colorfmt, mipmap=mipmap)             # <<<<<<<<<<<<<<
 * 
 *     # set default parameter for this texture
 */
  if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__colorfmt), ((PyObject *)__pyx_v_colorfmt)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = PyInt_FromLong(__pyx_v_mipmap); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__mipmap), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_7 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_4kivy_8graphics_7texture_Texture)), ((PyObject *)__pyx_t_9), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_v_texture));
  __pyx_v_texture = ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "kivy/graphics/texture.pyx":414
 * 
 *     # set default parameter for this texture
 *     texture.bind()             # <<<<<<<<<<<<<<
 *     texture.set_wrap('clamp_to_edge')
 *     if mipmap:
 */
  __pyx_t_7 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_texture->__pyx_vtab)->bind(__pyx_v_texture, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "kivy/graphics/texture.pyx":415
 *     # set default parameter for this texture
 *     texture.bind()
 *     texture.set_wrap('clamp_to_edge')             # <<<<<<<<<<<<<<
 *     if mipmap:
 *         texture.set_min_filter('linear_mipmap_nearest')
 */
  __pyx_t_7 = ((PyObject *)__pyx_n_s__clamp_to_edge);
  __Pyx_INCREF(__pyx_t_7);
  __pyx_t_8 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_texture->__pyx_vtab)->set_wrap(__pyx_v_texture, ((PyObject*)__pyx_t_7)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "kivy/graphics/texture.pyx":416
 *     texture.bind()
 *     texture.set_wrap('clamp_to_edge')
 *     if mipmap:             # <<<<<<<<<<<<<<
 *         texture.set_min_filter('linear_mipmap_nearest')
 *         texture.set_mag_filter('linear')
 */
  if (__pyx_v_mipmap) {

    /* "kivy/graphics/texture.pyx":417
 *     texture.set_wrap('clamp_to_edge')
 *     if mipmap:
 *         texture.set_min_filter('linear_mipmap_nearest')             # <<<<<<<<<<<<<<
 *         texture.set_mag_filter('linear')
 *     else:
 */
    __pyx_t_8 = ((PyObject *)__pyx_n_s_19);
    __Pyx_INCREF(__pyx_t_8);
    __pyx_t_7 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_texture->__pyx_vtab)->set_min_filter(__pyx_v_texture, ((PyObject*)__pyx_t_8)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "kivy/graphics/texture.pyx":418
 *     if mipmap:
 *         texture.set_min_filter('linear_mipmap_nearest')
 *         texture.set_mag_filter('linear')             # <<<<<<<<<<<<<<
 *     else:
 *         texture.set_min_filter('linear')
 */
    __pyx_t_7 = ((PyObject *)__pyx_n_s__linear);
    __Pyx_INCREF(__pyx_t_7);
    __pyx_t_8 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_texture->__pyx_vtab)->set_mag_filter(__pyx_v_texture, ((PyObject*)__pyx_t_7)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    goto __pyx_L7;
  }
  /*else*/ {

    /* "kivy/graphics/texture.pyx":420
 *         texture.set_mag_filter('linear')
 *     else:
 *         texture.set_min_filter('linear')             # <<<<<<<<<<<<<<
 *         texture.set_mag_filter('linear')
 * 
 */
    __pyx_t_8 = ((PyObject *)__pyx_n_s__linear);
    __Pyx_INCREF(__pyx_t_8);
    __pyx_t_7 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_texture->__pyx_vtab)->set_min_filter(__pyx_v_texture, ((PyObject*)__pyx_t_8)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "kivy/graphics/texture.pyx":421
 *     else:
 *         texture.set_min_filter('linear')
 *         texture.set_mag_filter('linear')             # <<<<<<<<<<<<<<
 * 
 *     # if allocation if wanted, do it now
 */
    __pyx_t_7 = ((PyObject *)__pyx_n_s__linear);
    __Pyx_INCREF(__pyx_t_7);
    __pyx_t_8 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_texture->__pyx_vtab)->set_mag_filter(__pyx_v_texture, ((PyObject*)__pyx_t_7)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  }
  __pyx_L7:;

  /* "kivy/graphics/texture.pyx":424
 * 
 *     # if allocation if wanted, do it now
 *     if allocate:             # <<<<<<<<<<<<<<
 * 
 *         # prepare information needed for nogil
 */
  if (__pyx_v_allocate) {

    /* "kivy/graphics/texture.pyx":427
 * 
 *         # prepare information needed for nogil
 *         glfmt = _color_fmt_to_gl(colorfmt)             # <<<<<<<<<<<<<<
 *         iglbufferfmt = glbufferfmt
 *         datasize = texture_width * texture_height * \
 */
    __pyx_t_8 = ((PyObject *)__pyx_v_colorfmt);
    __Pyx_INCREF(__pyx_t_8);
    __pyx_v_glfmt = __pyx_f_4kivy_8graphics_7texture__color_fmt_to_gl(((PyObject*)__pyx_t_8));
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "kivy/graphics/texture.pyx":428
 *         # prepare information needed for nogil
 *         glfmt = _color_fmt_to_gl(colorfmt)
 *         iglbufferfmt = glbufferfmt             # <<<<<<<<<<<<<<
 *         datasize = texture_width * texture_height * \
 *                 _gl_format_size(glfmt) * _buffer_type_to_gl_size(bufferfmt)
 */
    __pyx_v_iglbufferfmt = __pyx_v_glbufferfmt;

    /* "kivy/graphics/texture.pyx":430
 *         iglbufferfmt = glbufferfmt
 *         datasize = texture_width * texture_height * \
 *                 _gl_format_size(glfmt) * _buffer_type_to_gl_size(bufferfmt)             # <<<<<<<<<<<<<<
 * 
 *         # act as we have been able to allocate the texture
 */
    __pyx_t_8 = ((PyObject *)__pyx_v_bufferfmt);
    __Pyx_INCREF(__pyx_t_8);
    __pyx_v_datasize = (((__pyx_v_texture_width * __pyx_v_texture_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_8)));
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

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

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

        /* "kivy/graphics/texture.pyx":437
 *         # 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":438
 *         with nogil:
 *             data = calloc(1, datasize)
 *             if data != NULL:             # <<<<<<<<<<<<<<
 *                 # ensure pixel upload is correct
 *                 _gl_prepare_pixels_upload(texture_width)
 */
        __pyx_t_4 = (__pyx_v_data != NULL);
        if (__pyx_t_4) {

          /* "kivy/graphics/texture.pyx":440
 *             if data != NULL:
 *                 # ensure pixel upload is correct
 *                 _gl_prepare_pixels_upload(texture_width)             # <<<<<<<<<<<<<<
 * 
 *                 # do the initial upload with fake data
 */
          __pyx_f_4kivy_8graphics_7texture__gl_prepare_pixels_upload(__pyx_v_texture_width);

          /* "kivy/graphics/texture.pyx":444
 *                 # do the initial upload with fake data
 *                 glTexImage2D(target, 0, glfmt, texture_width, texture_height, 0,
 *                              glfmt, iglbufferfmt, data)             # <<<<<<<<<<<<<<
 * 
 *                 # free the data !
 */
          glTexImage2D(__pyx_v_target, 0, __pyx_v_glfmt, __pyx_v_texture_width, __pyx_v_texture_height, 0, __pyx_v_glfmt, __pyx_v_iglbufferfmt, __pyx_v_data);

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

          /* "kivy/graphics/texture.pyx":450
 * 
 *                 # create mipmap if needed
 *                 if mipmap:             # <<<<<<<<<<<<<<
 *                     glGenerateMipmap(target)
 *             else:
 */
          if (__pyx_v_mipmap) {

            /* "kivy/graphics/texture.pyx":451
 *                 # create mipmap if needed
 *                 if mipmap:
 *                     glGenerateMipmap(target)             # <<<<<<<<<<<<<<
 *             else:
 *                 dataerr = 1
 */
            glGenerateMipmap(__pyx_v_target);
            goto __pyx_L13;
          }
          __pyx_L13:;
          goto __pyx_L12;
        }
        /*else*/ {

          /* "kivy/graphics/texture.pyx":453
 *                     glGenerateMipmap(target)
 *             else:
 *                 dataerr = 1             # <<<<<<<<<<<<<<
 * 
 *         if dataerr:
 */
          __pyx_v_dataerr = 1;
        }
        __pyx_L12:;
      }

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

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

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

      /* "kivy/graphics/texture.pyx":458
 *             texture._is_allocated = 0
 *             raise Exception('Unable to allocate memory for texture (size is %s)' %
 *                             datasize)             # <<<<<<<<<<<<<<
 * 
 *     # if the texture size is the same as initial size, return the texture
 */
      __pyx_t_8 = PyInt_FromLong(__pyx_v_datasize); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_20), __pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_7));
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_8));
      PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_7));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
      __pyx_t_7 = 0;
      __pyx_t_7 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
      __Pyx_Raise(__pyx_t_7, 0, 0);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L14;
    }
    __pyx_L14:;
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "kivy/graphics/texture.pyx":462
 *     # 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_4 = (__pyx_v_texture_width == __pyx_v_width);
  if (__pyx_t_4) {
    __pyx_t_2 = (__pyx_v_texture_height == __pyx_v_height);
    __pyx_t_3 = __pyx_t_2;
  } else {
    __pyx_t_3 = __pyx_t_4;
  }
  if (__pyx_t_3) {

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

  /* "kivy/graphics/texture.pyx":466
 * 
 *     # otherwise, return a region of that texture
 *     return texture.get_region(0, 0, width, height)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_7 = __pyx_int_0;
  __Pyx_INCREF(__pyx_t_7);
  __pyx_t_8 = __pyx_int_0;
  __Pyx_INCREF(__pyx_t_8);
  __pyx_t_9 = PyInt_FromLong(__pyx_v_width); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_1 = PyInt_FromLong(__pyx_v_height); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_6 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_texture->__pyx_vtab)->get_region(__pyx_v_texture, __pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_1, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __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_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("kivy.graphics.texture._texture_create");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_texture);
  __Pyx_DECREF(__pyx_v_colorfmt);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

static PyObject *__pyx_pf_4kivy_8graphics_7texture_texture_create(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_texture_create[] = "texture_create(size=None, colorfmt=None, bufferfmt=None, mipmap=False)\nCreate 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\n    ";
static PyMethodDef __pyx_mdef_4kivy_8graphics_7texture_texture_create = {__Pyx_NAMESTR("texture_create"), (PyCFunction)__pyx_pf_4kivy_8graphics_7texture_texture_create, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_texture_create)};
static PyObject *__pyx_pf_4kivy_8graphics_7texture_texture_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;
  int __pyx_v_width;
  int __pyx_v_height;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__size,&__pyx_n_s__colorfmt,&__pyx_n_s__bufferfmt,&__pyx_n_s__mipmap,0};
  __Pyx_RefNannySetupContext("texture_create");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[4] = {0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = __pyx_k_21;
    switch (PyTuple_GET_SIZE(__pyx_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;
    }
    switch (PyTuple_GET_SIZE(__pyx_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--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "texture_create") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_size = values[0];
    __pyx_v_colorfmt = values[1];
    __pyx_v_bufferfmt = values[2];
    __pyx_v_mipmap = values[3];
  } else {
    __pyx_v_size = ((PyObject *)Py_None);
    __pyx_v_colorfmt = ((PyObject *)Py_None);
    __pyx_v_bufferfmt = ((PyObject *)Py_None);
    __pyx_v_mipmap = __pyx_k_21;
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  4: __pyx_v_mipmap = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: __pyx_v_bufferfmt = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: __pyx_v_colorfmt = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_size = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("texture_create", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("kivy.graphics.texture.texture_create");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF(__pyx_v_colorfmt);
  __Pyx_INCREF(__pyx_v_bufferfmt);

  /* "kivy/graphics/texture.pyx":485
 * 
 *     '''
 *     cdef int width = 128, height = 128             # <<<<<<<<<<<<<<
 *     if size is not None:
 *         width, height = size
 */
  __pyx_v_width = 128;
  __pyx_v_height = 128;

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

    /* "kivy/graphics/texture.pyx":487
 *     cdef int width = 128, height = 128
 *     if size is not None:
 *         width, height = size             # <<<<<<<<<<<<<<
 *     if colorfmt is None:
 *         colorfmt = 'rgba'
 */
    if (PyTuple_CheckExact(__pyx_v_size) && likely(PyTuple_GET_SIZE(__pyx_v_size) == 2)) {
      PyObject* tuple = __pyx_v_size;
      __pyx_t_2 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_3 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_3);
      __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_width = __pyx_t_4;
      __pyx_v_height = __pyx_t_5;
    } else {
      __pyx_t_6 = PyObject_GetIter(__pyx_v_size); 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_2 = __Pyx_UnpackItem(__pyx_t_6, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_6, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__Pyx_EndUnpack(__pyx_t_6, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_v_width = __pyx_t_5;
      __pyx_v_height = __pyx_t_4;
    }
    goto __pyx_L6;
  }
  __pyx_L6:;

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

    /* "kivy/graphics/texture.pyx":489
 *         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_L7;
  }
  __pyx_L7:;

  /* "kivy/graphics/texture.pyx":490
 *     if colorfmt is None:
 *         colorfmt = 'rgba'
 *     if bufferfmt is None:             # <<<<<<<<<<<<<<
 *         bufferfmt = 'ubyte'
 *     return _texture_create(width, height, colorfmt, bufferfmt, mipmap, 1)
 */
  __pyx_t_1 = (__pyx_v_bufferfmt == Py_None);
  if (__pyx_t_1) {

    /* "kivy/graphics/texture.pyx":491
 *         colorfmt = 'rgba'
 *     if bufferfmt is None:
 *         bufferfmt = 'ubyte'             # <<<<<<<<<<<<<<
 *     return _texture_create(width, height, colorfmt, bufferfmt, mipmap, 1)
 * 
 */
    __Pyx_INCREF(((PyObject *)__pyx_n_s__ubyte));
    __Pyx_DECREF(__pyx_v_bufferfmt);
    __pyx_v_bufferfmt = ((PyObject *)__pyx_n_s__ubyte);
    goto __pyx_L8;
  }
  __pyx_L8:;

  /* "kivy/graphics/texture.pyx":492
 *     if bufferfmt is None:
 *         bufferfmt = 'ubyte'
 *     return _texture_create(width, height, colorfmt, bufferfmt, mipmap, 1)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __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 = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = __pyx_v_colorfmt;
  __Pyx_INCREF(__pyx_t_3);
  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 = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_2 = __pyx_v_bufferfmt;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_v_mipmap); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = __pyx_f_4kivy_8graphics_7texture__texture_create(__pyx_v_width, __pyx_v_height, ((PyObject*)__pyx_t_3), ((PyObject*)__pyx_t_2), __pyx_t_4, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __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_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("kivy.graphics.texture.texture_create");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_colorfmt);
  __Pyx_DECREF(__pyx_v_bufferfmt);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

static PyObject *__pyx_pf_4kivy_8graphics_7texture_1texture_create_from_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_1texture_create_from_data[] = "texture_create_from_data(im, mipmap=False)\nCreate a texture from an ImageData class\n    ";
static PyMethodDef __pyx_mdef_4kivy_8graphics_7texture_1texture_create_from_data = {__Pyx_NAMESTR("texture_create_from_data"), (PyCFunction)__pyx_pf_4kivy_8graphics_7texture_1texture_create_from_data, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_1texture_create_from_data)};
static PyObject *__pyx_pf_4kivy_8graphics_7texture_1texture_create_from_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_im = 0;
  PyObject *__pyx_v_mipmap = 0;
  int __pyx_v_width;
  int __pyx_v_height;
  int __pyx_v_allocate;
  PyObject *__pyx_v_texture;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__im,&__pyx_n_s__mipmap,0};
  __Pyx_RefNannySetupContext("texture_create_from_data");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    values[1] = __pyx_k_22;
    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);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__im);
      if (likely(values[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, PyTuple_GET_SIZE(__pyx_args), "texture_create_from_data") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_im = values[0];
    __pyx_v_mipmap = values[1];
  } else {
    __pyx_v_mipmap = __pyx_k_22;
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_mipmap = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_im = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  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 = 495; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("kivy.graphics.texture.texture_create_from_data");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF(__pyx_v_mipmap);
  __pyx_v_texture = Py_None; __Pyx_INCREF(Py_None);

  /* "kivy/graphics/texture.pyx":499
 *     '''
 * 
 *     cdef int width = im.width             # <<<<<<<<<<<<<<
 *     cdef int height = im.height
 *     cdef int allocate = 1
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_im, __pyx_n_s__width); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 499; __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 = 499; __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":500
 * 
 *     cdef int width = im.width
 *     cdef int height = im.height             # <<<<<<<<<<<<<<
 *     cdef int allocate = 1
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_im, __pyx_n_s__height); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 500; __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 = 500; __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":501
 *     cdef int width = im.width
 *     cdef int height = im.height
 *     cdef int allocate = 1             # <<<<<<<<<<<<<<
 * 
 *     # optimization, if the texture is power of 2, don't allocate in
 */
  __pyx_v_allocate = 1;

  /* "kivy/graphics/texture.pyx":505
 *     # 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
 * 
 */
  __pyx_t_2 = __pyx_f_4kivy_8graphics_7texture__is_pow2(__pyx_v_width);
  if (__pyx_t_2) {
    __pyx_t_3 = __pyx_f_4kivy_8graphics_7texture__is_pow2(__pyx_v_height);
    __pyx_t_4 = __pyx_t_3;
  } else {
    __pyx_t_4 = __pyx_t_2;
  }
  if (__pyx_t_4) {

    /* "kivy/graphics/texture.pyx":506
 *     # _texture_create, but allocate in blit_data => only 1 upload
 *     if _is_pow2(width) and _is_pow2(height):
 *         allocate = 0             # <<<<<<<<<<<<<<
 * 
 *     # if imagedata have more than one image, activate mipmap
 */
    __pyx_v_allocate = 0;
    goto __pyx_L6;
  }
  __pyx_L6:;

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

    /* "kivy/graphics/texture.pyx":510
 *     # if imagedata have more than one image, activate mipmap
 *     if im.have_mipmap:
 *         mipmap = True             # <<<<<<<<<<<<<<
 * 
 *     texture = _texture_create(width, height, im.fmt, 'ubyte', mipmap, allocate)
 */
    __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __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_L7;
  }
  __pyx_L7:;

  /* "kivy/graphics/texture.pyx":512
 *         mipmap = True
 * 
 *     texture = _texture_create(width, height, im.fmt, 'ubyte', mipmap, allocate)             # <<<<<<<<<<<<<<
 *     if texture is None:
 *         return None
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_im, __pyx_n_s__fmt); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __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 = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = ((PyObject *)__pyx_n_s__ubyte);
  __Pyx_INCREF(__pyx_t_5);
  __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 = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = __pyx_f_4kivy_8graphics_7texture__texture_create(__pyx_v_width, __pyx_v_height, ((PyObject*)__pyx_t_1), ((PyObject*)__pyx_t_5), __pyx_t_2, __pyx_v_allocate); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_DECREF(__pyx_v_texture);
  __pyx_v_texture = __pyx_t_6;
  __pyx_t_6 = 0;

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

    /* "kivy/graphics/texture.pyx":514
 *     texture = _texture_create(width, height, im.fmt, 'ubyte', mipmap, allocate)
 *     if texture is None:
 *         return None             # <<<<<<<<<<<<<<
 * 
 *     texture.blit_data(im)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    goto __pyx_L0;
    goto __pyx_L8;
  }
  __pyx_L8:;

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

  /* "kivy/graphics/texture.pyx":518
 *     texture.blit_data(im)
 * 
 *     return texture             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_texture);
  __pyx_r = __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_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("kivy.graphics.texture.texture_create_from_data");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_texture);
  __Pyx_DECREF(__pyx_v_mipmap);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":528
 *     create_from_data = staticmethod(texture_create_from_data)
 * 
 *     def __init__(self, width, height, target, texid, colorfmt='rgb',             # <<<<<<<<<<<<<<
 *                  mipmap=False):
 *         self._width         = width
 */

static int __pyx_pf_4kivy_8graphics_7texture_7Texture___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4kivy_8graphics_7texture_7Texture___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_mipmap = 0;
  int __pyx_r;
  int __pyx_t_1;
  GLuint __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  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__mipmap,0};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[6] = {0,0,0,0,0,0};
    values[4] = ((PyObject *)__pyx_n_s__rgb);
    values[5] = __pyx_k_23;
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      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;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__width);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__height);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__target);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__texid);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 6, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      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__mipmap);
        if (value) { values[5] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L3_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_mipmap = values[5];
  } else {
    __pyx_v_colorfmt = ((PyObject *)__pyx_n_s__rgb);
    __pyx_v_mipmap = __pyx_k_23;
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  6:
      __pyx_v_mipmap = PyTuple_GET_ITEM(__pyx_args, 5);
      case  5:
      __pyx_v_colorfmt = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4:
      __pyx_v_texid = PyTuple_GET_ITEM(__pyx_args, 3);
      __pyx_v_target = PyTuple_GET_ITEM(__pyx_args, 2);
      __pyx_v_height = PyTuple_GET_ITEM(__pyx_args, 1);
      __pyx_v_width = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.__init__");
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "kivy/graphics/texture.pyx":530
 *     def __init__(self, width, height, target, texid, colorfmt='rgb',
 *                  mipmap=False):
 *         self._width         = width             # <<<<<<<<<<<<<<
 *         self._height        = height
 *         self._target        = target
 */
  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_width); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_width = __pyx_t_1;

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

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

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

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

  /* "kivy/graphics/texture.pyx":535
 *         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(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_wrap);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_wrap));
  ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_wrap = ((PyObject*)Py_None);

  /* "kivy/graphics/texture.pyx":536
 *         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(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_min_filter);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_min_filter));
  ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_min_filter = ((PyObject*)Py_None);

  /* "kivy/graphics/texture.pyx":537
 *         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(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_mag_filter);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_mag_filter));
  ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_mag_filter = ((PyObject*)Py_None);

  /* "kivy/graphics/texture.pyx":538
 *         self._min_filter    = None
 *         self._mag_filter    = None
 *         self._is_allocated  = 0             # <<<<<<<<<<<<<<
 *         self._uvx           = 0.
 *         self._uvy           = 0.
 */
  ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_is_allocated = 0;

  /* "kivy/graphics/texture.pyx":539
 *         self._mag_filter    = None
 *         self._is_allocated  = 0
 *         self._uvx           = 0.             # <<<<<<<<<<<<<<
 *         self._uvy           = 0.
 *         self._uvw           = 1.
 */
  ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_uvx = 0.;

  /* "kivy/graphics/texture.pyx":540
 *         self._is_allocated  = 0
 *         self._uvx           = 0.
 *         self._uvy           = 0.             # <<<<<<<<<<<<<<
 *         self._uvw           = 1.
 *         self._uvh           = 1.
 */
  ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_uvy = 0.;

  /* "kivy/graphics/texture.pyx":541
 *         self._uvx           = 0.
 *         self._uvy           = 0.
 *         self._uvw           = 1.             # <<<<<<<<<<<<<<
 *         self._uvh           = 1.
 *         self._colorfmt      = colorfmt
 */
  ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_uvw = 1.;

  /* "kivy/graphics/texture.pyx":542
 *         self._uvy           = 0.
 *         self._uvw           = 1.
 *         self._uvh           = 1.             # <<<<<<<<<<<<<<
 *         self._colorfmt      = colorfmt
 *         self.update_tex_coords()
 */
  ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_uvh = 1.;

  /* "kivy/graphics/texture.pyx":543
 *         self._uvw           = 1.
 *         self._uvh           = 1.
 *         self._colorfmt      = colorfmt             # <<<<<<<<<<<<<<
 *         self.update_tex_coords()
 * 
 */
  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 = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(__pyx_v_colorfmt);
  __Pyx_GIVEREF(__pyx_v_colorfmt);
  __Pyx_GOTREF(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_colorfmt);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_colorfmt));
  ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_colorfmt = ((PyObject*)__pyx_v_colorfmt);

  /* "kivy/graphics/texture.pyx":544
 *         self._uvh           = 1.
 *         self._colorfmt      = colorfmt
 *         self.update_tex_coords()             # <<<<<<<<<<<<<<
 * 
 *     def __dealloc__(self):
 */
  __pyx_t_3 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->__pyx_vtab)->update_tex_coords(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

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

/* "kivy/graphics/texture.pyx":546
 *         self.update_tex_coords()
 * 
 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
 *         # Add texture deletion outside GC call.
 *         # This case happen if some texture have been not deleted
 */

static void __pyx_pf_4kivy_8graphics_7texture_7Texture_1__dealloc__(PyObject *__pyx_v_self); /*proto*/
static void __pyx_pf_4kivy_8graphics_7texture_7Texture_1__dealloc__(PyObject *__pyx_v_self) {
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("__dealloc__");

  /* "kivy/graphics/texture.pyx":550
 *         # This case happen if some texture have been not deleted
 *         # before application exit...
 *         if _texture_release_list is not None:             # <<<<<<<<<<<<<<
 *             _texture_release_list.append(self._id)
 *             if _texture_release_trigger is not None:
 */
  __pyx_t_1 = (__pyx_v_4kivy_8graphics_7texture__texture_release_list != ((PyObject*)Py_None));
  if (__pyx_t_1) {

    /* "kivy/graphics/texture.pyx":551
 *         # before application exit...
 *         if _texture_release_list is not None:
 *             _texture_release_list.append(self._id)             # <<<<<<<<<<<<<<
 *             if _texture_release_trigger is not None:
 *                 _texture_release_trigger()
 */
    if (unlikely(__pyx_v_4kivy_8graphics_7texture__texture_release_list == Py_None)) {
      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
    }
    __pyx_t_2 = __Pyx_PyInt_to_py_GLuint(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_id); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyList_Append(__pyx_v_4kivy_8graphics_7texture__texture_release_list, __pyx_t_2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "kivy/graphics/texture.pyx":552
 *         if _texture_release_list is not None:
 *             _texture_release_list.append(self._id)
 *             if _texture_release_trigger is not None:             # <<<<<<<<<<<<<<
 *                 _texture_release_trigger()
 * 
 */
    __pyx_t_1 = (__pyx_v_4kivy_8graphics_7texture__texture_release_trigger != Py_None);
    if (__pyx_t_1) {

      /* "kivy/graphics/texture.pyx":553
 *             _texture_release_list.append(self._id)
 *             if _texture_release_trigger is not None:
 *                 _texture_release_trigger()             # <<<<<<<<<<<<<<
 * 
 *     cdef update_tex_coords(self):
 */
      __pyx_t_2 = PyObject_Call(__pyx_v_4kivy_8graphics_7texture__texture_release_trigger, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      goto __pyx_L6;
    }
    __pyx_L6:;
    goto __pyx_L5;
  }
  __pyx_L5:;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.__dealloc__");
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
}

/* "kivy/graphics/texture.pyx":555
 *                 _texture_release_trigger()
 * 
 *     cdef update_tex_coords(self):             # <<<<<<<<<<<<<<
 *         self._tex_coords[0] = self._uvx
 *         self._tex_coords[1] = self._uvy
 */

static  PyObject *__pyx_f_4kivy_8graphics_7texture_7Texture_update_tex_coords(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("update_tex_coords");

  /* "kivy/graphics/texture.pyx":556
 * 
 *     cdef 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_v_self->_tex_coords[0]) = __pyx_v_self->_uvx;

  /* "kivy/graphics/texture.pyx":557
 *     cdef 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_v_self->_tex_coords[1]) = __pyx_v_self->_uvy;

  /* "kivy/graphics/texture.pyx":558
 *         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":559
 *         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_v_self->_tex_coords[3]) = __pyx_v_self->_uvy;

  /* "kivy/graphics/texture.pyx":560
 *         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":561
 *         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":562
 *         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[6]) = __pyx_v_self->_uvx;

  /* "kivy/graphics/texture.pyx":563
 *         self._tex_coords[5] = self._uvy + self._uvh
 *         self._tex_coords[6] = self._uvx
 *         self._tex_coords[7] = self._uvy + self._uvh             # <<<<<<<<<<<<<<
 * 
 *     cpdef flip_vertical(self):
 */
  (__pyx_v_self->_tex_coords[7]) = (__pyx_v_self->_uvy + __pyx_v_self->_uvh);

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

/* "kivy/graphics/texture.pyx":565
 *         self._tex_coords[7] = self._uvy + self._uvh
 * 
 *     cpdef flip_vertical(self):             # <<<<<<<<<<<<<<
 *         '''Flip tex_coords for vertical displaying'''
 *         self._uvy += self._uvh
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_2flip_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;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("flip_vertical");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flip_vertical); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_4kivy_8graphics_7texture_7Texture_2flip_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 = 565; __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":567
 *     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":568
 *         '''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":569
 *         self._uvy += self._uvh
 *         self._uvh = -self._uvh
 *         self.update_tex_coords()             # <<<<<<<<<<<<<<
 * 
 *     cpdef get_region(self, x, y, width, height):
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_self->__pyx_vtab)->update_tex_coords(__pyx_v_self); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __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.Texture.flip_vertical");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":565
 *         self._tex_coords[7] = self._uvy + self._uvh
 * 
 *     cpdef flip_vertical(self):             # <<<<<<<<<<<<<<
 *         '''Flip tex_coords for vertical displaying'''
 *         self._uvy += self._uvh
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_2flip_vertical(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_7Texture_2flip_vertical[] = "Texture.flip_vertical(self)\nFlip tex_coords for vertical displaying";
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_2flip_vertical(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("flip_vertical");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->__pyx_vtab)->flip_vertical(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __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_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":571
 *         self.update_tex_coords()
 * 
 *     cpdef get_region(self, x, y, width, height):             # <<<<<<<<<<<<<<
 *         '''Return a part of the texture, from (x,y) with (width,height)
 *         dimensions'''
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_3get_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;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("get_region");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__get_region); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_4kivy_8graphics_7texture_7Texture_3get_region)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__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 = 571; __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":574
 *         '''Return a part of the texture, from (x,y) with (width,height)
 *         dimensions'''
 *         return TextureRegion(x, y, width, height, self)             # <<<<<<<<<<<<<<
 * 
 *     cpdef bind(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__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 = 574; __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_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":571
 *         self.update_tex_coords()
 * 
 *     cpdef get_region(self, x, y, width, height):             # <<<<<<<<<<<<<<
 *         '''Return a part of the texture, from (x,y) with (width,height)
 *         dimensions'''
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_3get_region(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_7Texture_3get_region[] = "Texture.get_region(self, x, y, width, height)\nReturn a part of the texture, from (x,y) with (width,height)\n        dimensions";
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_3get_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;
  PyObject *__pyx_r = NULL;
  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;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__x,&__pyx_n_s__y,&__pyx_n_s__width,&__pyx_n_s__height,0};
  __Pyx_RefNannySetupContext("get_region");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[4] = {0,0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_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;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("get_region", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__width);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("get_region", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__height);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("get_region", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "get_region") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_x = values[0];
    __pyx_v_y = values[1];
    __pyx_v_width = values[2];
    __pyx_v_height = values[3];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_x = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_y = PyTuple_GET_ITEM(__pyx_args, 1);
    __pyx_v_width = PyTuple_GET_ITEM(__pyx_args, 2);
    __pyx_v_height = PyTuple_GET_ITEM(__pyx_args, 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 = 571; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.get_region");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_v_x;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = __pyx_v_y;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_3 = __pyx_v_width;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_4 = __pyx_v_height;
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_5 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->__pyx_vtab)->get_region(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), __pyx_t_1, __pyx_t_2, __pyx_t_3, __pyx_t_4, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 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_AddTraceback("kivy.graphics.texture.Texture.get_region");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":576
 *         return TextureRegion(x, y, width, height, self)
 * 
 *     cpdef bind(self):             # <<<<<<<<<<<<<<
 *         '''Bind the texture to current opengl state'''
 *         glBindTexture(self._target, self._id)
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_4bind(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) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("bind");
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if overriden in Python */
  else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__bind); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_4kivy_8graphics_7texture_7Texture_4bind)) {
      __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 = 576; __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":578
 *     cpdef bind(self):
 *         '''Bind the texture to current opengl state'''
 *         glBindTexture(self._target, self._id)             # <<<<<<<<<<<<<<
 * 
 *     cdef set_min_filter(self, str x):
 */
  glBindTexture(__pyx_v_self->_target, __pyx_v_self->_id);

  __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_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":576
 *         return TextureRegion(x, y, width, height, self)
 * 
 *     cpdef bind(self):             # <<<<<<<<<<<<<<
 *         '''Bind the texture to current opengl state'''
 *         glBindTexture(self._target, self._id)
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_4bind(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_7Texture_4bind[] = "Texture.bind(self)\nBind the texture to current opengl state";
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_4bind(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("bind");
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->__pyx_vtab)->bind(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; __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_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":580
 *         glBindTexture(self._target, self._id)
 * 
 *     cdef set_min_filter(self, str x):             # <<<<<<<<<<<<<<
 *         cdef GLuint _value = _str_to_gl_texture_min_filter(x)
 *         glTexParameteri(self.target, GL_TEXTURE_MIN_FILTER, _value)
 */

static  PyObject *__pyx_f_4kivy_8graphics_7texture_7Texture_set_min_filter(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x) {
  GLuint __pyx_v__value;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  GLenum __pyx_t_2;
  __Pyx_RefNannySetupContext("set_min_filter");

  /* "kivy/graphics/texture.pyx":581
 * 
 *     cdef set_min_filter(self, str x):
 *         cdef GLuint _value = _str_to_gl_texture_min_filter(x)             # <<<<<<<<<<<<<<
 *         glTexParameteri(self.target, GL_TEXTURE_MIN_FILTER, _value)
 *         self._min_filter = x
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_x);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v__value = __pyx_f_4kivy_8graphics_7texture__str_to_gl_texture_min_filter(((PyObject*)__pyx_t_1));
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "kivy/graphics/texture.pyx":582
 *     cdef set_min_filter(self, str x):
 *         cdef GLuint _value = _str_to_gl_texture_min_filter(x)
 *         glTexParameteri(self.target, GL_TEXTURE_MIN_FILTER, _value)             # <<<<<<<<<<<<<<
 *         self._min_filter = x
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__target); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_from_py_GLenum(__pyx_t_1); if (unlikely((__pyx_t_2 == (GLenum)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  glTexParameteri(__pyx_t_2, GL_TEXTURE_MIN_FILTER, __pyx_v__value);

  /* "kivy/graphics/texture.pyx":583
 *         cdef GLuint _value = _str_to_gl_texture_min_filter(x)
 *         glTexParameteri(self.target, GL_TEXTURE_MIN_FILTER, _value)
 *         self._min_filter = x             # <<<<<<<<<<<<<<
 * 
 *     cdef set_mag_filter(self, str x):
 */
  __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;

  __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.set_min_filter");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":585
 *         self._min_filter = x
 * 
 *     cdef set_mag_filter(self, str x):             # <<<<<<<<<<<<<<
 *         cdef GLuint _value = _str_to_gl_texture_mag_filter(x)
 *         glTexParameteri(self.target, GL_TEXTURE_MAG_FILTER, _value)
 */

static  PyObject *__pyx_f_4kivy_8graphics_7texture_7Texture_set_mag_filter(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x) {
  GLuint __pyx_v__value;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  GLenum __pyx_t_2;
  __Pyx_RefNannySetupContext("set_mag_filter");

  /* "kivy/graphics/texture.pyx":586
 * 
 *     cdef set_mag_filter(self, str x):
 *         cdef GLuint _value = _str_to_gl_texture_mag_filter(x)             # <<<<<<<<<<<<<<
 *         glTexParameteri(self.target, GL_TEXTURE_MAG_FILTER, _value)
 *         self._mag_filter = x
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_x);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v__value = __pyx_f_4kivy_8graphics_7texture__str_to_gl_texture_mag_filter(((PyObject*)__pyx_t_1));
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "kivy/graphics/texture.pyx":587
 *     cdef set_mag_filter(self, str x):
 *         cdef GLuint _value = _str_to_gl_texture_mag_filter(x)
 *         glTexParameteri(self.target, GL_TEXTURE_MAG_FILTER, _value)             # <<<<<<<<<<<<<<
 *         self._mag_filter = x
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__target); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_from_py_GLenum(__pyx_t_1); if (unlikely((__pyx_t_2 == (GLenum)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  glTexParameteri(__pyx_t_2, GL_TEXTURE_MAG_FILTER, __pyx_v__value);

  /* "kivy/graphics/texture.pyx":588
 *         cdef GLuint _value = _str_to_gl_texture_mag_filter(x)
 *         glTexParameteri(self.target, GL_TEXTURE_MAG_FILTER, _value)
 *         self._mag_filter = x             # <<<<<<<<<<<<<<
 * 
 *     cdef set_wrap(self, str x):
 */
  __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;

  __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.set_mag_filter");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":590
 *         self._mag_filter = x
 * 
 *     cdef set_wrap(self, str x):             # <<<<<<<<<<<<<<
 *         cdef GLuint _value = _str_to_gl_texture_wrap(x)
 *         glTexParameteri(self.target, GL_TEXTURE_WRAP_S, _value)
 */

static  PyObject *__pyx_f_4kivy_8graphics_7texture_7Texture_set_wrap(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x) {
  GLuint __pyx_v__value;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  GLenum __pyx_t_2;
  __Pyx_RefNannySetupContext("set_wrap");

  /* "kivy/graphics/texture.pyx":591
 * 
 *     cdef set_wrap(self, str x):
 *         cdef GLuint _value = _str_to_gl_texture_wrap(x)             # <<<<<<<<<<<<<<
 *         glTexParameteri(self.target, GL_TEXTURE_WRAP_S, _value)
 *         glTexParameteri(self.target, GL_TEXTURE_WRAP_T, _value)
 */
  __pyx_t_1 = ((PyObject *)__pyx_v_x);
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v__value = __pyx_f_4kivy_8graphics_7texture__str_to_gl_texture_wrap(((PyObject*)__pyx_t_1));
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "kivy/graphics/texture.pyx":592
 *     cdef set_wrap(self, str x):
 *         cdef GLuint _value = _str_to_gl_texture_wrap(x)
 *         glTexParameteri(self.target, GL_TEXTURE_WRAP_S, _value)             # <<<<<<<<<<<<<<
 *         glTexParameteri(self.target, GL_TEXTURE_WRAP_T, _value)
 *         self._wrap = x
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__target); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_from_py_GLenum(__pyx_t_1); if (unlikely((__pyx_t_2 == (GLenum)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  glTexParameteri(__pyx_t_2, GL_TEXTURE_WRAP_S, __pyx_v__value);

  /* "kivy/graphics/texture.pyx":593
 *         cdef GLuint _value = _str_to_gl_texture_wrap(x)
 *         glTexParameteri(self.target, GL_TEXTURE_WRAP_S, _value)
 *         glTexParameteri(self.target, GL_TEXTURE_WRAP_T, _value)             # <<<<<<<<<<<<<<
 *         self._wrap = x
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__target); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyInt_from_py_GLenum(__pyx_t_1); if (unlikely((__pyx_t_2 == (GLenum)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  glTexParameteri(__pyx_t_2, GL_TEXTURE_WRAP_T, __pyx_v__value);

  /* "kivy/graphics/texture.pyx":594
 *         glTexParameteri(self.target, GL_TEXTURE_WRAP_S, _value)
 *         glTexParameteri(self.target, GL_TEXTURE_WRAP_T, _value)
 *         self._wrap = x             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __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;

  __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.set_wrap");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":597
 * 
 * 
 *     def blit_data(self, im, pos=None):             # <<<<<<<<<<<<<<
 *         '''Replace a whole texture with a image data
 *         '''
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_5blit_data(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_7Texture_5blit_data[] = "Texture.blit_data(self, im, pos=None)\nReplace a whole texture with a image data\n        ";
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_5blit_data(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_im = 0;
  PyObject *__pyx_v_pos = 0;
  PyObject *__pyx_v_blit;
  PyObject *__pyx_v_level;
  PyObject *__pyx_v_width;
  PyObject *__pyx_v_height;
  PyObject *__pyx_v_data;
  PyObject *__pyx_r = NULL;
  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 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__im,&__pyx_n_s__pos,0};
  __Pyx_RefNannySetupContext("blit_data");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    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);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__im);
      if (likely(values[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, PyTuple_GET_SIZE(__pyx_args), "blit_data") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_im = values[0];
    __pyx_v_pos = values[1];
  } else {
    __pyx_v_pos = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_pos = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_im = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  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 = 597; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.blit_data");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_blit = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_level = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_width = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_height = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_data = Py_None; __Pyx_INCREF(Py_None);

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

  /* "kivy/graphics/texture.pyx":603
 * 
 *         # 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 = PyObject_GetAttr(__pyx_v_im, __pyx_n_s__have_mipmap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 603; __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 = 603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (!__pyx_t_2);
  if (__pyx_t_3) {

    /* "kivy/graphics/texture.pyx":604
 *         # 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 = PyObject_GetAttr(__pyx_v_im, __pyx_n_s__data); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __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 = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__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 = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __pyx_t_5 = PyObject_GetAttr(__pyx_v_im, __pyx_n_s__size); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __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 = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_GetAttr(__pyx_v_im, __pyx_n_s__fmt); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __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 = 604; __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 = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = PyEval_CallObjectWithKeywords(__pyx_v_blit, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __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_L6;
  }
  /*else*/ {

    /* "kivy/graphics/texture.pyx":607
 *         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 = PyObject_GetAttr(__pyx_v_im, __pyx_n_s__iterate_mipmaps); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __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 = 607; __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_6 = 0; __pyx_t_5 = __pyx_t_1; __Pyx_INCREF(__pyx_t_5);
    } 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 = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    for (;;) {
      if (likely(PyList_CheckExact(__pyx_t_5))) {
        if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break;
        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++;
      } else if (likely(PyTuple_CheckExact(__pyx_t_5))) {
        if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++;
      } else {
        __pyx_t_1 = PyIter_Next(__pyx_t_5);
        if (!__pyx_t_1) {
          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
          break;
        }
        __Pyx_GOTREF(__pyx_t_1);
      }
      if (PyTuple_CheckExact(__pyx_t_1) && likely(PyTuple_GET_SIZE(__pyx_t_1) == 4)) {
        PyObject* tuple = __pyx_t_1;
        __pyx_t_4 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_4);
        __pyx_t_7 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_7);
        __pyx_t_8 = PyTuple_GET_ITEM(tuple, 2); __Pyx_INCREF(__pyx_t_8);
        __pyx_t_9 = PyTuple_GET_ITEM(tuple, 3); __Pyx_INCREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_v_level);
        __pyx_v_level = __pyx_t_4;
        __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_v_width);
        __pyx_v_width = __pyx_t_7;
        __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_v_height);
        __pyx_v_height = __pyx_t_8;
        __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_v_data);
        __pyx_v_data = __pyx_t_9;
        __pyx_t_9 = 0;
      } else {
        __pyx_t_10 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_4 = __Pyx_UnpackItem(__pyx_t_10, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_10, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_8 = __Pyx_UnpackItem(__pyx_t_10, 2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = __Pyx_UnpackItem(__pyx_t_10, 3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_GOTREF(__pyx_t_9);
        if (__Pyx_EndUnpack(__pyx_t_10, 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_v_level);
        __pyx_v_level = __pyx_t_4;
        __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_v_width);
        __pyx_v_width = __pyx_t_7;
        __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_v_height);
        __pyx_v_height = __pyx_t_8;
        __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_v_data);
        __pyx_v_data = __pyx_t_9;
        __pyx_t_9 = 0;
      }

      /* "kivy/graphics/texture.pyx":608
 *             # 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 = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__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_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_9));
      __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_8));
      __Pyx_INCREF(__pyx_v_width);
      PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_width);
      __Pyx_GIVEREF(__pyx_v_width);
      __Pyx_INCREF(__pyx_v_height);
      PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_height);
      __Pyx_GIVEREF(__pyx_v_height);
      if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__size), ((PyObject *)__pyx_t_8)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;

      /* "kivy/graphics/texture.pyx":609
 *             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_8 = PyObject_GetAttr(__pyx_v_im, __pyx_n_s__fmt); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__colorfmt), __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__pos), __pyx_v_pos) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

      /* "kivy/graphics/texture.pyx":610
 *                 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_9, ((PyObject *)__pyx_n_s__mipmap_level), __pyx_v_level) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __pyx_t_8 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__mipmap_generation), __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = PyEval_CallObjectWithKeywords(__pyx_v_blit, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_9)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __pyx_L6:;

  __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_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.blit_data");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_blit);
  __Pyx_DECREF(__pyx_v_level);
  __Pyx_DECREF(__pyx_v_width);
  __Pyx_DECREF(__pyx_v_height);
  __Pyx_DECREF(__pyx_v_data);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":612
 *                      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_6blit_buffer(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_7Texture_6blit_buffer[] = "Texture.blit_buffer(self, pbuffer, size=None, colorfmt=None, pos=None, bufferfmt=None, mipmap_level=0, mipmap_generation=True)\nBlit a buffer into a texture.\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                .. versionadded:: 1.0.7\n                Indicate which mipmap level we are going to update\n            `mipmap_generation`: bool, default to False\n                .. versionadded:: 1.0.7\n                Indicate if we need to regenerate mipmap from level 0\n        ";
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6blit_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;
  GLuint __pyx_v_target;
  int __pyx_v_tid;
  PyObject *__pyx_v_data;
  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;
  PyObject *__pyx_t_1 = NULL;
  GLuint __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  Py_ssize_t __pyx_t_7;
  int __pyx_t_8;
  char *__pyx_t_9;
  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};
  __Pyx_RefNannySetupContext("blit_buffer");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[7] = {0,0,0,0,0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);

    /* "kivy/graphics/texture.pyx":613
 * 
 *     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_24;
    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);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pbuffer);
      if (likely(values[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, PyTuple_GET_SIZE(__pyx_args), "blit_buffer") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L3_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];
  } else {

    /* "kivy/graphics/texture.pyx":612
 *                      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):
 */
    __pyx_v_size = ((PyObject *)Py_None);
    __pyx_v_colorfmt = ((PyObject *)Py_None);

    /* "kivy/graphics/texture.pyx":613
 * 
 *     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_v_pos = ((PyObject *)Py_None);
    __pyx_v_bufferfmt = ((PyObject *)Py_None);
    __pyx_v_mipmap_level = ((PyObject *)__pyx_int_0);
    __pyx_v_mipmap_generation = __pyx_k_24;
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  7: __pyx_v_mipmap_generation = PyTuple_GET_ITEM(__pyx_args, 6);
      case  6: __pyx_v_mipmap_level = PyTuple_GET_ITEM(__pyx_args, 5);
      case  5: __pyx_v_bufferfmt = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: __pyx_v_pos = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: __pyx_v_colorfmt = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: __pyx_v_size = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_pbuffer = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  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 = 612; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.blit_buffer");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __Pyx_INCREF(__pyx_v_size);
  __Pyx_INCREF(__pyx_v_colorfmt);
  __Pyx_INCREF(__pyx_v_pos);
  __Pyx_INCREF(__pyx_v_bufferfmt);
  __pyx_v_data = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);

  /* "kivy/graphics/texture.pyx":637
 *                 Indicate if we need to regenerate mipmap from level 0
 *         '''
 *         cdef GLuint target = self.target             # <<<<<<<<<<<<<<
 *         cdef int tid = self._id
 *         if colorfmt is None:
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__target); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __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 = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_target = __pyx_t_2;

  /* "kivy/graphics/texture.pyx":638
 *         '''
 *         cdef GLuint target = self.target
 *         cdef int tid = self._id             # <<<<<<<<<<<<<<
 *         if colorfmt is None:
 *             colorfmt = 'rgb'
 */
  __pyx_v_tid = ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_id;

  /* "kivy/graphics/texture.pyx":639
 *         cdef GLuint target = self.target
 *         cdef int tid = self._id
 *         if colorfmt is None:             # <<<<<<<<<<<<<<
 *             colorfmt = 'rgb'
 *         if bufferfmt is None:
 */
  __pyx_t_3 = (__pyx_v_colorfmt == Py_None);
  if (__pyx_t_3) {

    /* "kivy/graphics/texture.pyx":640
 *         cdef int tid = self._id
 *         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_L6;
  }
  __pyx_L6:;

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

    /* "kivy/graphics/texture.pyx":642
 *             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_L7;
  }
  __pyx_L7:;

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

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

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

    /* "kivy/graphics/texture.pyx":646
 *             pos = (0, 0)
 *         if size is None:
 *             size = self.size             # <<<<<<<<<<<<<<
 *         bufferfmt = _buffer_fmt_to_gl(bufferfmt)
 * 
 */
    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__size); 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_DECREF(__pyx_v_size);
    __pyx_v_size = __pyx_t_1;
    __pyx_t_1 = 0;
    goto __pyx_L9;
  }
  __pyx_L9:;

  /* "kivy/graphics/texture.pyx":647
 *         if size is None:
 *             size = self.size
 *         bufferfmt = _buffer_fmt_to_gl(bufferfmt)             # <<<<<<<<<<<<<<
 * 
 *         # need conversion ?
 */
  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 = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_bufferfmt;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_4 = PyInt_FromLong(__pyx_f_4kivy_8graphics_7texture__buffer_fmt_to_gl(((PyObject*)__pyx_t_1))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_v_bufferfmt);
  __pyx_v_bufferfmt = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "kivy/graphics/texture.pyx":651
 *         # 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 = 651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_INCREF(__pyx_v_pbuffer);
  __Pyx_DECREF(((PyObject *)__pyx_v_data));
  __pyx_v_data = ((PyObject*)__pyx_v_pbuffer);

  /* "kivy/graphics/texture.pyx":652
 *         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 = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __pyx_v_colorfmt;
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_1 = __pyx_f_4kivy_8graphics_7texture__convert_buffer(__pyx_v_data, ((PyObject*)__pyx_t_4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (PyTuple_CheckExact(__pyx_t_1) && likely(PyTuple_GET_SIZE(__pyx_t_1) == 2)) {
    PyObject* tuple = __pyx_t_1;
    __pyx_t_4 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_4);
    if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_v_data));
    __pyx_v_data = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_v_colorfmt);
    __pyx_v_colorfmt = __pyx_t_5;
    __pyx_t_5 = 0;
  } else {
    __pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_4 = __Pyx_UnpackItem(__pyx_t_6, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_t_5 = __Pyx_UnpackItem(__pyx_t_6, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    if (__Pyx_EndUnpack(__pyx_t_6, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_v_data));
    __pyx_v_data = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_v_colorfmt);
    __pyx_v_colorfmt = __pyx_t_5;
    __pyx_t_5 = 0;
  }

  /* "kivy/graphics/texture.pyx":655
 * 
 *         # prepare nogil
 *         cdef int glfmt = _color_fmt_to_gl(colorfmt)             # <<<<<<<<<<<<<<
 *         cdef int datasize = len(pbuffer)
 *         cdef int x = pos[0]
 */
  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 = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_colorfmt;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_glfmt = __pyx_f_4kivy_8graphics_7texture__color_fmt_to_gl(((PyObject*)__pyx_t_1));
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "kivy/graphics/texture.pyx":656
 *         # prepare nogil
 *         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_1 = __pyx_v_pbuffer;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_7 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 656; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_datasize = __pyx_t_7;

  /* "kivy/graphics/texture.pyx":657
 *         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_1 = __Pyx_GetItemInt(__pyx_v_pos, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_x = __pyx_t_8;

  /* "kivy/graphics/texture.pyx":658
 *         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_1 = __Pyx_GetItemInt(__pyx_v_pos, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_y = __pyx_t_8;

  /* "kivy/graphics/texture.pyx":659
 *         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_1 = __Pyx_GetItemInt(__pyx_v_size, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_w = __pyx_t_8;

  /* "kivy/graphics/texture.pyx":660
 *         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_1 = __Pyx_GetItemInt(__pyx_v_size, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_h = __pyx_t_8;

  /* "kivy/graphics/texture.pyx":661
 *         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_9 = PyBytes_AsString(((PyObject *)__pyx_v_data)); if (unlikely((!__pyx_t_9) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_cdata = __pyx_t_9;

  /* "kivy/graphics/texture.pyx":662
 *         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_8 = __Pyx_PyInt_AsInt(__pyx_v_bufferfmt); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_glbufferfmt = __pyx_t_8;

  /* "kivy/graphics/texture.pyx":663
 *         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_v_is_allocated = ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_is_allocated;

  /* "kivy/graphics/texture.pyx":664
 *         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 = 664; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_colorfmt;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_v_is_compressed = __pyx_f_4kivy_8graphics_7texture__is_compressed_fmt(((PyObject*)__pyx_t_1));
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "kivy/graphics/texture.pyx":665
 *         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_3 = __Pyx_PyObject_IsTrue(__pyx_v_mipmap_generation); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_3) {
    __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_mipmap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = __pyx_t_1;
    __pyx_t_1 = 0;
  } else {
    __Pyx_INCREF(__pyx_v_mipmap_generation);
    __pyx_t_5 = __pyx_v_mipmap_generation;
  }
  __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_v__mipmap_generation = __pyx_t_8;

  /* "kivy/graphics/texture.pyx":666
 *         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_8 = __Pyx_PyInt_AsInt(__pyx_v_mipmap_level); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v__mipmap_level = __pyx_t_8;

  /* "kivy/graphics/texture.pyx":668
 *         cdef int _mipmap_level = mipmap_level
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             glBindTexture(target, self._id)
 *             if is_compressed:
 */
  {
    #ifdef WITH_THREAD
    PyThreadState *_save;
    #endif
    Py_UNBLOCK_THREADS
    /*try:*/ {

      /* "kivy/graphics/texture.pyx":669
 * 
 *         with nogil:
 *             glBindTexture(target, self._id)             # <<<<<<<<<<<<<<
 *             if is_compressed:
 *                 glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
 */
      glBindTexture(__pyx_v_target, ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_id);

      /* "kivy/graphics/texture.pyx":670
 *         with nogil:
 *             glBindTexture(target, self._id)
 *             if is_compressed:             # <<<<<<<<<<<<<<
 *                 glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
 *                 glCompressedTexImage2D(target, _mipmap_level, glfmt, w, h, 0, datasize, cdata)
 */
      if (__pyx_v_is_compressed) {

        /* "kivy/graphics/texture.pyx":671
 *             glBindTexture(target, self._id)
 *             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":672
 *             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_L13;
      }

      /* "kivy/graphics/texture.pyx":673
 *                 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)
 */
      if (__pyx_v_is_allocated) {

        /* "kivy/graphics/texture.pyx":674
 *                 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":675
 *             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_L13;
      }
      /*else*/ {

        /* "kivy/graphics/texture.pyx":677
 *                 glTexSubImage2D(target, _mipmap_level, x, y, w, h, glfmt, glbufferfmt, cdata)
 *             else:
 *                 _gl_prepare_pixels_upload(w)             # <<<<<<<<<<<<<<
 *                 glTexImage2D(target, _mipmap_level, glfmt, 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":678
 *             else:
 *                 _gl_prepare_pixels_upload(w)
 *                 glTexImage2D(target, _mipmap_level, glfmt, w, h, 0, glfmt, glbufferfmt, cdata)             # <<<<<<<<<<<<<<
 *             if _mipmap_generation:
 *                 glGenerateMipmap(target)
 */
        glTexImage2D(__pyx_v_target, __pyx_v__mipmap_level, __pyx_v_glfmt, __pyx_v_w, __pyx_v_h, 0, __pyx_v_glfmt, __pyx_v_glbufferfmt, __pyx_v_cdata);
      }
      __pyx_L13:;

      /* "kivy/graphics/texture.pyx":679
 *                 _gl_prepare_pixels_upload(w)
 *                 glTexImage2D(target, _mipmap_level, glfmt, w, h, 0, glfmt, glbufferfmt, cdata)
 *             if _mipmap_generation:             # <<<<<<<<<<<<<<
 *                 glGenerateMipmap(target)
 * 
 */
      if (__pyx_v__mipmap_generation) {

        /* "kivy/graphics/texture.pyx":680
 *                 glTexImage2D(target, _mipmap_level, glfmt, w, h, 0, glfmt, glbufferfmt, cdata)
 *             if _mipmap_generation:
 *                 glGenerateMipmap(target)             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
        glGenerateMipmap(__pyx_v_target);
        goto __pyx_L14;
      }
      __pyx_L14:;
    }

    /* "kivy/graphics/texture.pyx":668
 *         cdef int _mipmap_level = mipmap_level
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             glBindTexture(target, self._id)
 *             if is_compressed:
 */
    /*finally:*/ {
      Py_BLOCK_THREADS
    }
  }

  __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_6);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.blit_buffer");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_data);
  __Pyx_DECREF(__pyx_v_size);
  __Pyx_DECREF(__pyx_v_colorfmt);
  __Pyx_DECREF(__pyx_v_pos);
  __Pyx_DECREF(__pyx_v_bufferfmt);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":682
 *                 glGenerateMipmap(target)
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return '<Texture id=%d size=(%d, %d)>' % (
 *             self._id, self.width, self.height)
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_7__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_7__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("__str__");

  /* "kivy/graphics/texture.pyx":683
 * 
 *     def __str__(self):
 *         return '<Texture id=%d size=(%d, %d)>' % (             # <<<<<<<<<<<<<<
 *             self._id, self.width, self.height)
 * 
 */
  __Pyx_XDECREF(__pyx_r);

  /* "kivy/graphics/texture.pyx":684
 *     def __str__(self):
 *         return '<Texture id=%d size=(%d, %d)>' % (
 *             self._id, self.width, self.height)             # <<<<<<<<<<<<<<
 * 
 *     property size:
 */
  __pyx_t_1 = __Pyx_PyInt_to_py_GLuint(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__width); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__height); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_26), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 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_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.__str__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":689
 *         '''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__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_4size___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "kivy/graphics/texture.pyx":690
 *         '''
 *         def __get__(self):
 *             return (self.width, self.height)             # <<<<<<<<<<<<<<
 * 
 *     property mipmap:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__width); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__height); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __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 = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__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_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":695
 *         '''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__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6mipmap___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "kivy/graphics/texture.pyx":696
 *         '''
 *         def __get__(self):
 *             return self._mipmap             # <<<<<<<<<<<<<<
 * 
 *     property id:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_mipmap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __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_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_2id___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_2id___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "kivy/graphics/texture.pyx":702
 *         '''
 *         def __get__(self):
 *             return self._id             # <<<<<<<<<<<<<<
 * 
 *     property target:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_GLuint(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __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_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6target___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6target___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "kivy/graphics/texture.pyx":708
 *         '''
 *         def __get__(self):
 *             return self._target             # <<<<<<<<<<<<<<
 * 
 *     property width:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_GLuint(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_target); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 708; __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_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_5width___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_5width___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "kivy/graphics/texture.pyx":714
 *         '''
 *         def __get__(self):
 *             return self._width             # <<<<<<<<<<<<<<
 * 
 *     property height:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_width); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 714; __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_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6height___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6height___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "kivy/graphics/texture.pyx":720
 *         '''
 *         def __get__(self):
 *             return self._height             # <<<<<<<<<<<<<<
 * 
 *     property tex_coords:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_height); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 720; __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_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":725
 *         '''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__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_10tex_coords___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  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;
  __Pyx_RefNannySetupContext("__get__");

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

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

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

  /* "kivy/graphics/texture.pyx":729
 *                 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((((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_tex_coords[2])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "kivy/graphics/texture.pyx":730
 *                 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((((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_tex_coords[3])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "kivy/graphics/texture.pyx":731
 *                 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((((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_tex_coords[4])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "kivy/graphics/texture.pyx":732
 *                 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((((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_tex_coords[5])); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);

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

  /* "kivy/graphics/texture.pyx":734
 *                 self._tex_coords[5],
 *                 self._tex_coords[6],
 *                 self._tex_coords[7],             # <<<<<<<<<<<<<<
 *             )
 * 
 */
  __pyx_t_8 = PyFloat_FromDouble((((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_tex_coords[7])); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __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 = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__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_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":740
 *         '''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__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_5uvpos___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "kivy/graphics/texture.pyx":741
 *         '''
 *         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(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_uvx); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyFloat_FromDouble(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_uvy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __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 = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__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_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":742
 *         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_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_pf_4kivy_8graphics_7texture_7Texture_5uvpos_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  float __pyx_t_3;
  float __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__set__");

  /* "kivy/graphics/texture.pyx":743
 *             return (self._uvx, self._uvy)
 *         def __set__(self, x):
 *             self._uvx, self._uvy = x             # <<<<<<<<<<<<<<
 *             self.update_tex_coords()
 * 
 */
  if (PyTuple_CheckExact(__pyx_v_x) && likely(PyTuple_GET_SIZE(__pyx_v_x) == 2)) {
    PyObject* tuple = __pyx_v_x;
    __pyx_t_1 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_1);
    __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_2 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_2);
    __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_4 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_uvx = __pyx_t_3;
    ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_uvy = __pyx_t_4;
  } else {
    __pyx_t_5 = PyObject_GetIter(__pyx_v_x); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_5, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_4 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_5, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__Pyx_EndUnpack(__pyx_t_5, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_uvx = __pyx_t_4;
    ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_uvy = __pyx_t_3;
  }

  /* "kivy/graphics/texture.pyx":744
 *         def __set__(self, x):
 *             self._uvx, self._uvy = x
 *             self.update_tex_coords()             # <<<<<<<<<<<<<<
 * 
 *     property uvsize:
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->__pyx_vtab)->update_tex_coords(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)); 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(__pyx_t_2); __pyx_t_2 = 0;

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

/* "kivy/graphics/texture.pyx":752
 *             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__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6uvsize___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "kivy/graphics/texture.pyx":753
 *         '''
 *         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(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_uvw); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyFloat_FromDouble(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_uvh); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __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 = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__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_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":754
 *         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_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_pf_4kivy_8graphics_7texture_7Texture_6uvsize_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  float __pyx_t_3;
  float __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__set__");

  /* "kivy/graphics/texture.pyx":755
 *             return (self._uvw, self._uvh)
 *         def __set__(self, x):
 *             self._uvw, self._uvh = x             # <<<<<<<<<<<<<<
 *             self.update_tex_coords()
 * 
 */
  if (PyTuple_CheckExact(__pyx_v_x) && likely(PyTuple_GET_SIZE(__pyx_v_x) == 2)) {
    PyObject* tuple = __pyx_v_x;
    __pyx_t_1 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_1);
    __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_2 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_2);
    __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_4 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_uvw = __pyx_t_3;
    ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_uvh = __pyx_t_4;
  } else {
    __pyx_t_5 = PyObject_GetIter(__pyx_v_x); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_5, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_4 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_5, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__Pyx_EndUnpack(__pyx_t_5, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_uvw = __pyx_t_4;
    ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_uvh = __pyx_t_3;
  }

  /* "kivy/graphics/texture.pyx":756
 *         def __set__(self, x):
 *             self._uvw, self._uvh = x
 *             self.update_tex_coords()             # <<<<<<<<<<<<<<
 * 
 *     property colorfmt:
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->__pyx_vtab)->update_tex_coords(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

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

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

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_8colorfmt___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_8colorfmt___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "kivy/graphics/texture.pyx":764
 *         '''
 *         def __get__(self):
 *             return self._colorfmt             # <<<<<<<<<<<<<<
 * 
 *     property min_filter:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_colorfmt));
  __pyx_r = ((PyObject *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__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;
}

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

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_10min_filter___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_10min_filter___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "kivy/graphics/texture.pyx":780
 *         '''
 *         def __get__(self):
 *             return self._min_filter             # <<<<<<<<<<<<<<
 *         def __set__(self, x):
 *             cdef GLuint value
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_min_filter));
  __pyx_r = ((PyObject *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__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;
}

/* "kivy/graphics/texture.pyx":781
 *         def __get__(self):
 *             return self._min_filter
 *         def __set__(self, x):             # <<<<<<<<<<<<<<
 *             cdef GLuint value
 *             if x == self._min_filter:
 */

static int __pyx_pf_4kivy_8graphics_7texture_7Texture_10min_filter_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_pf_4kivy_8graphics_7texture_7Texture_10min_filter_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__set__");

  /* "kivy/graphics/texture.pyx":783
 *         def __set__(self, x):
 *             cdef GLuint value
 *             if x == self._min_filter:             # <<<<<<<<<<<<<<
 *                 return
 *             self.bind()
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_x, ((PyObject *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_min_filter), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __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 = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "kivy/graphics/texture.pyx":784
 *             cdef GLuint value
 *             if x == self._min_filter:
 *                 return             # <<<<<<<<<<<<<<
 *             self.bind()
 *             self.set_min_filter(x)
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "kivy/graphics/texture.pyx":785
 *             if x == self._min_filter:
 *                 return
 *             self.bind()             # <<<<<<<<<<<<<<
 *             self.set_min_filter(x)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->__pyx_vtab)->bind(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), 0); 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_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "kivy/graphics/texture.pyx":786
 *                 return
 *             self.bind()
 *             self.set_min_filter(x)             # <<<<<<<<<<<<<<
 * 
 *     property mag_filter:
 */
  if (!(likely(PyString_CheckExact(__pyx_v_x))||((__pyx_v_x) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_v_x)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_x;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_3 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->__pyx_vtab)->set_min_filter(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.min_filter.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_10mag_filter___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_10mag_filter___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "kivy/graphics/texture.pyx":798
 *         '''
 *         def __get__(self):
 *             return self._mag_filter             # <<<<<<<<<<<<<<
 *         def __set__(self, x):
 *             if x == self._mag_filter:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_mag_filter));
  __pyx_r = ((PyObject *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__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;
}

/* "kivy/graphics/texture.pyx":799
 *         def __get__(self):
 *             return self._mag_filter
 *         def __set__(self, x):             # <<<<<<<<<<<<<<
 *             if x == self._mag_filter:
 *                 return
 */

static int __pyx_pf_4kivy_8graphics_7texture_7Texture_10mag_filter_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_pf_4kivy_8graphics_7texture_7Texture_10mag_filter_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__set__");

  /* "kivy/graphics/texture.pyx":800
 *             return self._mag_filter
 *         def __set__(self, x):
 *             if x == self._mag_filter:             # <<<<<<<<<<<<<<
 *                 return
 *             self.bind()
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_x, ((PyObject *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_mag_filter), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __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 = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "kivy/graphics/texture.pyx":801
 *         def __set__(self, x):
 *             if x == self._mag_filter:
 *                 return             # <<<<<<<<<<<<<<
 *             self.bind()
 *             self.set_mag_filter(x)
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "kivy/graphics/texture.pyx":802
 *             if x == self._mag_filter:
 *                 return
 *             self.bind()             # <<<<<<<<<<<<<<
 *             self.set_mag_filter(x)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->__pyx_vtab)->bind(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 802; __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":803
 *                 return
 *             self.bind()
 *             self.set_mag_filter(x)             # <<<<<<<<<<<<<<
 * 
 *     property wrap:
 */
  if (!(likely(PyString_CheckExact(__pyx_v_x))||((__pyx_v_x) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_v_x)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_x;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_3 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->__pyx_vtab)->set_mag_filter(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.mag_filter.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_4wrap___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_4wrap___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "kivy/graphics/texture.pyx":816
 *         '''
 *         def __get__(self):
 *             return self._wrap             # <<<<<<<<<<<<<<
 *         def __set__(self, wrap):
 *             if wrap == self._wrap:
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_wrap));
  __pyx_r = ((PyObject *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__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;
}

/* "kivy/graphics/texture.pyx":817
 *         def __get__(self):
 *             return self._wrap
 *         def __set__(self, wrap):             # <<<<<<<<<<<<<<
 *             if wrap == self._wrap:
 *                 return
 */

static int __pyx_pf_4kivy_8graphics_7texture_7Texture_4wrap_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_wrap); /*proto*/
static int __pyx_pf_4kivy_8graphics_7texture_7Texture_4wrap_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_wrap) {
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__set__");

  /* "kivy/graphics/texture.pyx":818
 *             return self._wrap
 *         def __set__(self, wrap):
 *             if wrap == self._wrap:             # <<<<<<<<<<<<<<
 *                 return
 *             self.bind()
 */
  __pyx_t_1 = PyObject_RichCompare(__pyx_v_wrap, ((PyObject *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_wrap), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __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 = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "kivy/graphics/texture.pyx":819
 *         def __set__(self, wrap):
 *             if wrap == self._wrap:
 *                 return             # <<<<<<<<<<<<<<
 *             self.bind()
 *             self.set_wrap(wrap)
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "kivy/graphics/texture.pyx":820
 *             if wrap == self._wrap:
 *                 return
 *             self.bind()             # <<<<<<<<<<<<<<
 *             self.set_wrap(wrap)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->__pyx_vtab)->bind(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __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":821
 *                 return
 *             self.bind()
 *             self.set_wrap(wrap)             # <<<<<<<<<<<<<<
 * 
 * cdef class TextureRegion(Texture):
 */
  if (!(likely(PyString_CheckExact(__pyx_v_wrap))||((__pyx_v_wrap) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_v_wrap)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_v_wrap;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_3 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->__pyx_vtab)->set_wrap(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.wrap.__set__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":831
 *     cdef Texture owner
 * 
 *     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__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4kivy_8graphics_7texture_13TextureRegion___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;
  float __pyx_v_origin_u1;
  float __pyx_v_origin_v1;
  float __pyx_v_origin_u2;
  float __pyx_v_origin_v2;
  int __pyx_r;
  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;
  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};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[5] = {0,0,0,0,0};
    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;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__width);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__height);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__origin);
      if (likely(values[4])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_x = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_x == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __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 = 831; __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 = 831; __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 = 831; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_origin = ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)values[4]);
  } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_x = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_x == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_y = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_y == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_width = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_width == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_height = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_height == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_origin = ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)PyTuple_GET_ITEM(__pyx_args, 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 = 831; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("kivy.graphics.texture.TextureRegion.__init__");
  __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 = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "kivy/graphics/texture.pyx":832
 * 
 *     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 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_4kivy_8graphics_7texture_Texture)), __pyx_n_s____init__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __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 = 832; __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 = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_origin), __pyx_n_s__target); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_origin), __pyx_n_s__id); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __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 = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_self);
  __Pyx_GIVEREF(__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 = 832; __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":833
 *     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
 */
  ((struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)__pyx_v_self)->__pyx_base._is_allocated = 1;

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

  /* "kivy/graphics/texture.pyx":835
 *         self._is_allocated = 1
 *         self._mipmap = origin._mipmap
 *         self.x = x             # <<<<<<<<<<<<<<
 *         self.y = y
 *         self.owner = origin
 */
  ((struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)__pyx_v_self)->x = __pyx_v_x;

  /* "kivy/graphics/texture.pyx":836
 *         self._mipmap = origin._mipmap
 *         self.x = x
 *         self.y = y             # <<<<<<<<<<<<<<
 *         self.owner = origin
 * 
 */
  ((struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)__pyx_v_self)->y = __pyx_v_y;

  /* "kivy/graphics/texture.pyx":837
 *         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(((struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)__pyx_v_self)->owner);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)__pyx_v_self)->owner));
  ((struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)__pyx_v_self)->owner = __pyx_v_origin;

  /* "kivy/graphics/texture.pyx":841
 *         # recalculate texture coordinate
 *         cdef float origin_u1, origin_v1, origin_u2, origin_v2
 *         origin_u1 = origin._uvx             # <<<<<<<<<<<<<<
 *         origin_v1 = origin._uvy
 *         origin_u2 = origin._uvx + origin._uvw
 */
  __pyx_v_origin_u1 = __pyx_v_origin->_uvx;

  /* "kivy/graphics/texture.pyx":842
 *         cdef float origin_u1, origin_v1, origin_u2, origin_v2
 *         origin_u1 = origin._uvx
 *         origin_v1 = origin._uvy             # <<<<<<<<<<<<<<
 *         origin_u2 = origin._uvx + origin._uvw
 *         origin_v2 = origin._uvy + origin._uvh
 */
  __pyx_v_origin_v1 = __pyx_v_origin->_uvy;

  /* "kivy/graphics/texture.pyx":843
 *         origin_u1 = origin._uvx
 *         origin_v1 = origin._uvy
 *         origin_u2 = origin._uvx + origin._uvw             # <<<<<<<<<<<<<<
 *         origin_v2 = origin._uvy + origin._uvh
 *         self._uvx = (x / <float>origin._width) * origin._uvw + origin_u1
 */
  __pyx_v_origin_u2 = (__pyx_v_origin->_uvx + __pyx_v_origin->_uvw);

  /* "kivy/graphics/texture.pyx":844
 *         origin_v1 = origin._uvy
 *         origin_u2 = origin._uvx + origin._uvw
 *         origin_v2 = origin._uvy + origin._uvh             # <<<<<<<<<<<<<<
 *         self._uvx = (x / <float>origin._width) * origin._uvw + origin_u1
 *         self._uvy = (y / <float>origin._height) * origin._uvh + origin_v1
 */
  __pyx_v_origin_v2 = (__pyx_v_origin->_uvy + __pyx_v_origin->_uvh);

  /* "kivy/graphics/texture.pyx":845
 *         origin_u2 = origin._uvx + origin._uvw
 *         origin_v2 = origin._uvy + origin._uvh
 *         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)) {
    PyErr_Format(PyExc_ZeroDivisionError, "float division");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  ((struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)__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":846
 *         origin_v2 = origin._uvy + origin._uvh
 *         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)) {
    PyErr_Format(PyExc_ZeroDivisionError, "float division");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  ((struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)__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":847
 *         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)) {
    PyErr_Format(PyExc_ZeroDivisionError, "float division");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  ((struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)__pyx_v_self)->__pyx_base._uvw = ((__pyx_v_width / ((float)__pyx_v_origin->_width)) * __pyx_v_origin->_uvw);

  /* "kivy/graphics/texture.pyx":848
 *         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)) {
    PyErr_Format(PyExc_ZeroDivisionError, "float division");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  ((struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)__pyx_v_self)->__pyx_base._uvh = ((__pyx_v_height / ((float)__pyx_v_origin->_height)) * __pyx_v_origin->_uvh);

  /* "kivy/graphics/texture.pyx":849
 *         self._uvw = (width / <float>origin._width) * origin._uvw
 *         self._uvh = (height / <float>origin._height) * origin._uvh
 *         self.update_tex_coords()             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
  __pyx_t_5 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_TextureRegion *)((struct __pyx_obj_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)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  __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_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":851
 *         self.update_tex_coords()
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return '<TextureRegion id=%d size=(%d, %d)>' % (
 *             self._id, self.width, self.height)
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_13TextureRegion_1__str__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4kivy_8graphics_7texture_13TextureRegion_1__str__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("__str__");

  /* "kivy/graphics/texture.pyx":852
 * 
 *     def __str__(self):
 *         return '<TextureRegion id=%d size=(%d, %d)>' % (             # <<<<<<<<<<<<<<
 *             self._id, self.width, self.height)
 * 
 */
  __Pyx_XDECREF(__pyx_r);

  /* "kivy/graphics/texture.pyx":853
 *     def __str__(self):
 *         return '<TextureRegion id=%d size=(%d, %d)>' % (
 *             self._id, self.width, self.height)             # <<<<<<<<<<<<<<
 * 
 * # Releasing texture through GC is problematic
 */
  __pyx_t_1 = __Pyx_PyInt_to_py_GLuint(((struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)__pyx_v_self)->__pyx_base._id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__width); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__height); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_27), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 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_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("kivy.graphics.texture.TextureRegion.__str__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "kivy/graphics/texture.pyx":859
 * # So, to prevent that, call the _texture_release
 * # at flip time.
 * def _texture_release(*largs):             # <<<<<<<<<<<<<<
 *     cdef GLuint texture_id
 *     if not _texture_release_list:
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_2_texture_release(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_2_texture_release[] = "_texture_release(*largs)";
static PyMethodDef __pyx_mdef_4kivy_8graphics_7texture_2_texture_release = {__Pyx_NAMESTR("_texture_release"), (PyCFunction)__pyx_pf_4kivy_8graphics_7texture_2_texture_release, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_2_texture_release)};
static PyObject *__pyx_pf_4kivy_8graphics_7texture_2_texture_release(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_largs = 0;
  GLuint __pyx_v_texture_id;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  Py_ssize_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  GLuint __pyx_t_7;
  __Pyx_RefNannySetupContext("_texture_release");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "_texture_release", 0))) return NULL;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_largs = __pyx_args;

  /* "kivy/graphics/texture.pyx":861
 * def _texture_release(*largs):
 *     cdef GLuint texture_id
 *     if not _texture_release_list:             # <<<<<<<<<<<<<<
 *         return
 *     Logger.trace('Texture: releasing %d textures' % len(_texture_release_list))
 */
  __pyx_t_1 = (((PyObject *)__pyx_v_4kivy_8graphics_7texture__texture_release_list) != Py_None) && (PyList_GET_SIZE(((PyObject *)__pyx_v_4kivy_8graphics_7texture__texture_release_list)) != 0);
  __pyx_t_2 = (!__pyx_t_1);
  if (__pyx_t_2) {

    /* "kivy/graphics/texture.pyx":862
 *     cdef GLuint texture_id
 *     if not _texture_release_list:
 *         return             # <<<<<<<<<<<<<<
 *     Logger.trace('Texture: releasing %d textures' % len(_texture_release_list))
 *     for texture_id in _texture_release_list:
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "kivy/graphics/texture.pyx":863
 *     if not _texture_release_list:
 *         return
 *     Logger.trace('Texture: releasing %d textures' % len(_texture_release_list))             # <<<<<<<<<<<<<<
 *     for texture_id in _texture_release_list:
 *         glDeleteTextures(1, &texture_id)
 */
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__Logger); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 863; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__trace); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 863; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = ((PyObject *)__pyx_v_4kivy_8graphics_7texture__texture_release_list);
  __Pyx_INCREF(__pyx_t_3);
  if (unlikely(__pyx_t_3 == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 863; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_5 = PyList_GET_SIZE(__pyx_t_3); 
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 863; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_28), __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 863; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 863; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_6));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
  __pyx_t_6 = 0;
  __pyx_t_6 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 863; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "kivy/graphics/texture.pyx":864
 *         return
 *     Logger.trace('Texture: releasing %d textures' % len(_texture_release_list))
 *     for texture_id in _texture_release_list:             # <<<<<<<<<<<<<<
 *         glDeleteTextures(1, &texture_id)
 *     del _texture_release_list[:]
 */
  if (unlikely(__pyx_v_4kivy_8graphics_7texture__texture_release_list == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_5 = 0; __pyx_t_6 = ((PyObject *)__pyx_v_4kivy_8graphics_7texture__texture_release_list); __Pyx_INCREF(__pyx_t_6);
  for (;;) {
    if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_6)) break;
    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++;
    __pyx_t_7 = __Pyx_PyInt_from_py_GLuint(__pyx_t_3); if (unlikely((__pyx_t_7 == (GLuint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_texture_id = __pyx_t_7;

    /* "kivy/graphics/texture.pyx":865
 *     Logger.trace('Texture: releasing %d textures' % len(_texture_release_list))
 *     for texture_id in _texture_release_list:
 *         glDeleteTextures(1, &texture_id)             # <<<<<<<<<<<<<<
 *     del _texture_release_list[:]
 * 
 */
    glDeleteTextures(1, (&__pyx_v_texture_id));
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "kivy/graphics/texture.pyx":866
 *     for texture_id in _texture_release_list:
 *         glDeleteTextures(1, &texture_id)
 *     del _texture_release_list[:]             # <<<<<<<<<<<<<<
 * 
 * if 'KIVY_DOC_INCLUDE' not in environ:
 */
  if (__Pyx_PySequence_DelSlice(((PyObject *)__pyx_v_4kivy_8graphics_7texture__texture_release_list), 0, PY_SSIZE_T_MAX) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __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_6);
  __Pyx_AddTraceback("kivy.graphics.texture._texture_release");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_largs);
  __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, PyObject *a, PyObject *k) {
  struct __pyx_obj_4kivy_8graphics_7texture_Texture *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)o);
  p->__pyx_vtab = __pyx_vtabptr_4kivy_8graphics_7texture_Texture;
  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);
  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 *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pf_4kivy_8graphics_7texture_7Texture_1__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  Py_XDECREF(((PyObject *)p->_wrap));
  Py_XDECREF(((PyObject *)p->_min_filter));
  Py_XDECREF(((PyObject *)p->_mag_filter));
  Py_XDECREF(((PyObject *)p->_colorfmt));
  (*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->_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;
  }
  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->_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);
  return 0;
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_size(PyObject *o, void *x) {
  return __pyx_pf_4kivy_8graphics_7texture_7Texture_4size___get__(o);
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_mipmap(PyObject *o, void *x) {
  return __pyx_pf_4kivy_8graphics_7texture_7Texture_6mipmap___get__(o);
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_id(PyObject *o, void *x) {
  return __pyx_pf_4kivy_8graphics_7texture_7Texture_2id___get__(o);
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_target(PyObject *o, void *x) {
  return __pyx_pf_4kivy_8graphics_7texture_7Texture_6target___get__(o);
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_width(PyObject *o, void *x) {
  return __pyx_pf_4kivy_8graphics_7texture_7Texture_5width___get__(o);
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_height(PyObject *o, void *x) {
  return __pyx_pf_4kivy_8graphics_7texture_7Texture_6height___get__(o);
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_tex_coords(PyObject *o, void *x) {
  return __pyx_pf_4kivy_8graphics_7texture_7Texture_10tex_coords___get__(o);
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_uvpos(PyObject *o, void *x) {
  return __pyx_pf_4kivy_8graphics_7texture_7Texture_5uvpos___get__(o);
}

static int __pyx_setprop_4kivy_8graphics_7texture_7Texture_uvpos(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_4kivy_8graphics_7texture_7Texture_5uvpos_1__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_uvsize(PyObject *o, void *x) {
  return __pyx_pf_4kivy_8graphics_7texture_7Texture_6uvsize___get__(o);
}

static int __pyx_setprop_4kivy_8graphics_7texture_7Texture_uvsize(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_4kivy_8graphics_7texture_7Texture_6uvsize_1__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_colorfmt(PyObject *o, void *x) {
  return __pyx_pf_4kivy_8graphics_7texture_7Texture_8colorfmt___get__(o);
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_min_filter(PyObject *o, void *x) {
  return __pyx_pf_4kivy_8graphics_7texture_7Texture_10min_filter___get__(o);
}

static int __pyx_setprop_4kivy_8graphics_7texture_7Texture_min_filter(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_4kivy_8graphics_7texture_7Texture_10min_filter_1__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_mag_filter(PyObject *o, void *x) {
  return __pyx_pf_4kivy_8graphics_7texture_7Texture_10mag_filter___get__(o);
}

static int __pyx_setprop_4kivy_8graphics_7texture_7Texture_mag_filter(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_4kivy_8graphics_7texture_7Texture_10mag_filter_1__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_wrap(PyObject *o, void *x) {
  return __pyx_pf_4kivy_8graphics_7texture_7Texture_4wrap___get__(o);
}

static int __pyx_setprop_4kivy_8graphics_7texture_7Texture_wrap(PyObject *o, PyObject *v, void *x) {
  if (v) {
    return __pyx_pf_4kivy_8graphics_7texture_7Texture_4wrap_1__set__(o, v);
  }
  else {
    PyErr_SetString(PyExc_NotImplementedError, "__del__");
    return -1;
  }
}

static PyMethodDef __pyx_methods_4kivy_8graphics_7texture_Texture[] = {
  {__Pyx_NAMESTR("flip_vertical"), (PyCFunction)__pyx_pf_4kivy_8graphics_7texture_7Texture_2flip_vertical, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_2flip_vertical)},
  {__Pyx_NAMESTR("get_region"), (PyCFunction)__pyx_pf_4kivy_8graphics_7texture_7Texture_3get_region, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_3get_region)},
  {__Pyx_NAMESTR("bind"), (PyCFunction)__pyx_pf_4kivy_8graphics_7texture_7Texture_4bind, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_4bind)},
  {__Pyx_NAMESTR("blit_data"), (PyCFunction)__pyx_pf_4kivy_8graphics_7texture_7Texture_5blit_data, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_5blit_data)},
  {__Pyx_NAMESTR("blit_buffer"), (PyCFunction)__pyx_pf_4kivy_8graphics_7texture_7Texture_6blit_buffer, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_6blit_buffer)},
  {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_29), 0},
  {(char *)"mipmap", __pyx_getprop_4kivy_8graphics_7texture_7Texture_mipmap, 0, __Pyx_DOCSTR(__pyx_k_30), 0},
  {(char *)"id", __pyx_getprop_4kivy_8graphics_7texture_7Texture_id, 0, __Pyx_DOCSTR(__pyx_k_31), 0},
  {(char *)"target", __pyx_getprop_4kivy_8graphics_7texture_7Texture_target, 0, __Pyx_DOCSTR(__pyx_k_32), 0},
  {(char *)"width", __pyx_getprop_4kivy_8graphics_7texture_7Texture_width, 0, __Pyx_DOCSTR(__pyx_k_33), 0},
  {(char *)"height", __pyx_getprop_4kivy_8graphics_7texture_7Texture_height, 0, __Pyx_DOCSTR(__pyx_k_34), 0},
  {(char *)"tex_coords", __pyx_getprop_4kivy_8graphics_7texture_7Texture_tex_coords, 0, __Pyx_DOCSTR(__pyx_k_35), 0},
  {(char *)"uvpos", __pyx_getprop_4kivy_8graphics_7texture_7Texture_uvpos, __pyx_setprop_4kivy_8graphics_7texture_7Texture_uvpos, __Pyx_DOCSTR(__pyx_k_36), 0},
  {(char *)"uvsize", __pyx_getprop_4kivy_8graphics_7texture_7Texture_uvsize, __pyx_setprop_4kivy_8graphics_7texture_7Texture_uvsize, __Pyx_DOCSTR(__pyx_k_37), 0},
  {(char *)"colorfmt", __pyx_getprop_4kivy_8graphics_7texture_7Texture_colorfmt, 0, __Pyx_DOCSTR(__pyx_k_38), 0},
  {(char *)"min_filter", __pyx_getprop_4kivy_8graphics_7texture_7Texture_min_filter, __pyx_setprop_4kivy_8graphics_7texture_7Texture_min_filter, __Pyx_DOCSTR(__pyx_k_39), 0},
  {(char *)"mag_filter", __pyx_getprop_4kivy_8graphics_7texture_7Texture_mag_filter, __pyx_setprop_4kivy_8graphics_7texture_7Texture_mag_filter, __Pyx_DOCSTR(__pyx_k_40), 0},
  {(char *)"wrap", __pyx_getprop_4kivy_8graphics_7texture_7Texture_wrap, __pyx_setprop_4kivy_8graphics_7texture_7Texture_wrap, __Pyx_DOCSTR(__pyx_k_41), 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Texture = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Texture = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Texture = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Texture = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

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
  0, /*tp_repr*/
  &__pyx_tp_as_number_Texture, /*tp_as_number*/
  &__pyx_tp_as_sequence_Texture, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Texture, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pf_4kivy_8graphics_7texture_7Texture_7__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Texture, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("Texture(width, height, target, texid, colorfmt='rgb', mipmap=False)\nHandle 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_pf_4kivy_8graphics_7texture_7Texture___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 (!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;
  Py_XDECREF(((PyObject *)p->owner));
  __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 PyMethodDef __pyx_methods_4kivy_8graphics_7texture_TextureRegion[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_TextureRegion = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_TextureRegion = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_TextureRegion = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_TextureRegion = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

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
  0, /*tp_repr*/
  &__pyx_tp_as_number_TextureRegion, /*tp_as_number*/
  &__pyx_tp_as_sequence_TextureRegion, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_TextureRegion, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  __pyx_pf_4kivy_8graphics_7texture_13TextureRegion_1__str__, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_TextureRegion, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("TextureRegion(int x, int y, int width, int height, Texture origin)\nHandle 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*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_4kivy_8graphics_7texture_13TextureRegion___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 = {
    PyModuleDef_HEAD_INIT,
    __Pyx_NAMESTR("texture"),
    __Pyx_DOCSTR(__pyx_k_42), /* 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_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 0},
  {&__pyx_n_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 1},
  {&__pyx_kp_s_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 1, 0},
  {&__pyx_kp_s_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 0, 1, 0},
  {&__pyx_kp_s_27, __pyx_k_27, sizeof(__pyx_k_27), 0, 0, 1, 0},
  {&__pyx_kp_s_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 0, 1, 0},
  {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
  {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
  {&__pyx_n_s_44, __pyx_k_44, sizeof(__pyx_k_44), 0, 0, 1, 1},
  {&__pyx_n_s_45, __pyx_k_45, sizeof(__pyx_k_45), 0, 0, 1, 1},
  {&__pyx_n_s_46, __pyx_k_46, sizeof(__pyx_k_46), 0, 0, 1, 1},
  {&__pyx_n_s_47, __pyx_k_47, sizeof(__pyx_k_47), 0, 0, 1, 1},
  {&__pyx_n_s_48, __pyx_k_48, sizeof(__pyx_k_48), 0, 0, 1, 1},
  {&__pyx_n_s_49, __pyx_k_49, sizeof(__pyx_k_49), 0, 0, 1, 1},
  {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
  {&__pyx_n_s_50, __pyx_k_50, sizeof(__pyx_k_50), 0, 0, 1, 1},
  {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
  {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
  {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0},
  {&__pyx_n_s__Clock, __pyx_k__Clock, sizeof(__pyx_k__Clock), 0, 0, 1, 1},
  {&__pyx_n_s__Exception, __pyx_k__Exception, sizeof(__pyx_k__Exception), 0, 0, 1, 1},
  {&__pyx_n_s__KIVY_DOC_INCLUDE, __pyx_k__KIVY_DOC_INCLUDE, sizeof(__pyx_k__KIVY_DOC_INCLUDE), 0, 0, 1, 1},
  {&__pyx_n_s__KeyError, __pyx_k__KeyError, sizeof(__pyx_k__KeyError), 0, 0, 1, 1},
  {&__pyx_n_s__Logger, __pyx_k__Logger, sizeof(__pyx_k__Logger), 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____all__, __pyx_k____all__, sizeof(__pyx_k____all__), 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____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
  {&__pyx_n_s___colorfmt, __pyx_k___colorfmt, sizeof(__pyx_k___colorfmt), 0, 0, 1, 1},
  {&__pyx_n_s___height, __pyx_k___height, sizeof(__pyx_k___height), 0, 0, 1, 1},
  {&__pyx_n_s___id, __pyx_k___id, sizeof(__pyx_k___id), 0, 0, 1, 1},
  {&__pyx_n_s___is_allocated, __pyx_k___is_allocated, sizeof(__pyx_k___is_allocated), 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___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___texture_release, __pyx_k___texture_release, sizeof(__pyx_k___texture_release), 0, 0, 1, 1},
  {&__pyx_n_s___uvh, __pyx_k___uvh, sizeof(__pyx_k___uvh), 0, 0, 1, 1},
  {&__pyx_n_s___uvw, __pyx_k___uvw, sizeof(__pyx_k___uvw), 0, 0, 1, 1},
  {&__pyx_n_s___uvx, __pyx_k___uvx, sizeof(__pyx_k___uvx), 0, 0, 1, 1},
  {&__pyx_n_s___uvy, __pyx_k___uvy, sizeof(__pyx_k___uvy), 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__append, __pyx_k__append, sizeof(__pyx_k__append), 0, 0, 1, 1},
  {&__pyx_n_s__array, __pyx_k__array, sizeof(__pyx_k__array), 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__clamp_to_edge, __pyx_k__clamp_to_edge, sizeof(__pyx_k__clamp_to_edge), 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__create_trigger, __pyx_k__create_trigger, sizeof(__pyx_k__create_trigger), 0, 0, 1, 1},
  {&__pyx_n_s__data, __pyx_k__data, sizeof(__pyx_k__data), 0, 0, 1, 1},
  {&__pyx_n_s__environ, __pyx_k__environ, sizeof(__pyx_k__environ), 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__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__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__int, __pyx_k__int, sizeof(__pyx_k__int), 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__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__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__origin, __pyx_k__origin, sizeof(__pyx_k__origin), 0, 0, 1, 1},
  {&__pyx_n_s__os, __pyx_k__os, sizeof(__pyx_k__os), 0, 0, 1, 1},
  {&__pyx_n_s__owner, __pyx_k__owner, sizeof(__pyx_k__owner), 0, 0, 1, 1},
  {&__pyx_n_s__pbuffer, __pyx_k__pbuffer, sizeof(__pyx_k__pbuffer), 0, 0, 1, 1},
  {&__pyx_n_s__pos, __pyx_k__pos, sizeof(__pyx_k__pos), 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__set_mag_filter, __pyx_k__set_mag_filter, sizeof(__pyx_k__set_mag_filter), 0, 0, 1, 1},
  {&__pyx_n_s__set_min_filter, __pyx_k__set_min_filter, sizeof(__pyx_k__set_min_filter), 0, 0, 1, 1},
  {&__pyx_n_s__set_wrap, __pyx_k__set_wrap, sizeof(__pyx_k__set_wrap), 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__startswith, __pyx_k__startswith, sizeof(__pyx_k__startswith), 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__texid, __pyx_k__texid, sizeof(__pyx_k__texid), 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__trace, __pyx_k__trace, sizeof(__pyx_k__trace), 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__update_tex_coords, __pyx_k__update_tex_coords, sizeof(__pyx_k__update_tex_coords), 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__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_GetName(__pyx_b, __pyx_n_s__staticmethod); if (!__pyx_builtin_staticmethod) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_KeyError = __Pyx_GetName(__pyx_b, __pyx_n_s__KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_Exception = __Pyx_GetName(__pyx_b, __pyx_n_s__Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_format = __Pyx_GetName(__pyx_b, __pyx_n_s__format); if (!__pyx_builtin_format) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants");

  /* "kivy/graphics/texture.pyx":233
 *     '''Return 1 if the color string format is a compressed one
 *     '''
 *     return x.startswith('s3tc_dxt')             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_k_tuple_2 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_2));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__s3tc_dxt));
  PyTuple_SET_ITEM(__pyx_k_tuple_2, 0, ((PyObject *)__pyx_n_s__s3tc_dxt));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__s3tc_dxt));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_2));

  /* "kivy/graphics/texture.pyx":311
 *     elif x == 's3tc_dxt1':
 *         return gl_has_capability(GLCAP_DXT1)
 *     elif x.startswith('s3tc_dxt'):             # <<<<<<<<<<<<<<
 *         return gl_has_capability(GLCAP_S3TC)
 *     return 1
 */
  __pyx_k_tuple_8 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_8));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__s3tc_dxt));
  PyTuple_SET_ITEM(__pyx_k_tuple_8, 0, ((PyObject *)__pyx_n_s__s3tc_dxt));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__s3tc_dxt));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_8));

  /* "kivy/graphics/texture.pyx":344
 *         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_10 = PySlice_New(__pyx_int_2, Py_None, __pyx_int_3); if (unlikely(!__pyx_k_slice_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __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_0, Py_None, __pyx_int_3); if (unlikely(!__pyx_k_slice_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_11);
  __Pyx_GIVEREF(__pyx_k_slice_11);
  __pyx_k_slice_12 = PySlice_New(__pyx_int_0, Py_None, __pyx_int_3); if (unlikely(!__pyx_k_slice_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __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_2, Py_None, __pyx_int_3); if (unlikely(!__pyx_k_slice_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_13);
  __Pyx_GIVEREF(__pyx_k_slice_13);

  /* "kivy/graphics/texture.pyx":351
 *         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_14 = PySlice_New(__pyx_int_2, Py_None, __pyx_int_4); if (unlikely(!__pyx_k_slice_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __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_0, Py_None, __pyx_int_4); if (unlikely(!__pyx_k_slice_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_15);
  __Pyx_GIVEREF(__pyx_k_slice_15);
  __pyx_k_slice_16 = PySlice_New(__pyx_int_0, Py_None, __pyx_int_4); if (unlikely(!__pyx_k_slice_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_16);
  __Pyx_GIVEREF(__pyx_k_slice_16);
  __pyx_k_slice_17 = PySlice_New(__pyx_int_2, Py_None, __pyx_int_4); if (unlikely(!__pyx_k_slice_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_17);
  __Pyx_GIVEREF(__pyx_k_slice_17);

  /* "kivy/graphics/texture.pyx":644
 *             bufferfmt = 'ubyte'
 *         if pos is None:
 *             pos = (0, 0)             # <<<<<<<<<<<<<<
 *         if size is None:
 *             size = self.size
 */
  __pyx_k_tuple_25 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_25));
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_k_tuple_25, 0, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __Pyx_INCREF(__pyx_int_0);
  PyTuple_SET_ITEM(__pyx_k_tuple_25, 1, __pyx_int_0);
  __Pyx_GIVEREF(__pyx_int_0);
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_25));

  /* "kivy/graphics/texture.pyx":151
 * '''
 * 
 * __all__ = ('Texture', 'TextureRegion')             # <<<<<<<<<<<<<<
 * 
 * include "config.pxi"
 */
  __pyx_k_tuple_43 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_43)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_43));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__Texture));
  PyTuple_SET_ITEM(__pyx_k_tuple_43, 0, ((PyObject *)__pyx_n_s__Texture));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Texture));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__TextureRegion));
  PyTuple_SET_ITEM(__pyx_k_tuple_43, 1, ((PyObject *)__pyx_n_s__TextureRegion));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__TextureRegion));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_43));
  __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_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;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  #if CYTHON_REFNANNY
  void* __pyx_refnanny = NULL;
  __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");
  }
  __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit_texture(void)", __LINE__, __FILE__);
  #endif
  __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_binding_PyCFunctionType_USED
  if (__pyx_binding_PyCFunctionType_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_42), 0, PYTHON_API_VERSION);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  #if PY_MAJOR_VERSION < 3
  Py_INCREF(__pyx_m);
  #endif
  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  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 (__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__texture_release_trigger = Py_None; Py_INCREF(Py_None);
  __pyx_v_4kivy_8graphics_7texture__texture_release_list = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __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);
  /*--- 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 = (PyObject *(*)(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 = (PyObject *(*)(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 = (PyObject *(*)(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 = (PyObject *(*)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, PyObject *))__pyx_f_4kivy_8graphics_7texture_7Texture_set_wrap;
  __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 = 521; __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 = 521; __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 = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __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_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 = 823; __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 = 823; __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 = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_7texture_TextureRegion = &__pyx_type_4kivy_8graphics_7texture_TextureRegion;
  /*--- Type import code ---*/
  /*--- Function import code ---*/
  __pyx_t_1 = __Pyx_ImportModule("kivy.graphics.opengl_utils"); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_1, "gl_get_extensions", (void (**)(void))&__pyx_f_4kivy_8graphics_12opengl_utils_gl_get_extensions, "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_1, "gl_has_extension", (void (**)(void))&__pyx_f_4kivy_8graphics_12opengl_utils_gl_has_extension, "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_1, "gl_register_get_size", (void (**)(void))&__pyx_f_4kivy_8graphics_12opengl_utils_gl_register_get_size, "PyObject *(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_1, "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_1, "gl_get_texture_formats", (void (**)(void))&__pyx_f_4kivy_8graphics_12opengl_utils_gl_get_texture_formats, "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_1, "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_1, "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;}
  if (__Pyx_ImportFunction(__pyx_t_1, "gl_has_texture_format", (void (**)(void))&__pyx_f_4kivy_8graphics_12opengl_utils_gl_has_texture_format, "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_1); __pyx_t_1 = 0;
  /*--- Execution code ---*/

  /* "kivy/graphics/texture.pyx":151
 * '''
 * 
 * __all__ = ('Texture', 'TextureRegion')             # <<<<<<<<<<<<<<
 * 
 * include "config.pxi"
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____all__, ((PyObject *)__pyx_k_tuple_43)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/tito/code/kivy/kivy/graphics/common.pxi":5
 * #
 * 
 * cdef double pi = 3.1415926535897931             # <<<<<<<<<<<<<<
 * cdef extern from "math.h":
 *     double cos(double) nogil
 */
  __pyx_v_4kivy_8graphics_7texture_pi = 3.1415926535897931;

  /* "/home/tito/code/kivy/kivy/graphics/opengl_utils_def.pxi":1
 * cdef int GLCAP_BGRA = 0x0001             # <<<<<<<<<<<<<<
 * cdef int GLCAP_NPOT = 0x0002
 * cdef int GLCAP_S3TC = 0x0003
 */
  __pyx_v_4kivy_8graphics_7texture_GLCAP_BGRA = 0x0001;

  /* "/home/tito/code/kivy/kivy/graphics/opengl_utils_def.pxi":2
 * cdef int GLCAP_BGRA = 0x0001
 * cdef int GLCAP_NPOT = 0x0002             # <<<<<<<<<<<<<<
 * cdef int GLCAP_S3TC = 0x0003
 * cdef int GLCAP_DXT1 = 0x0004
 */
  __pyx_v_4kivy_8graphics_7texture_GLCAP_NPOT = 0x0002;

  /* "/home/tito/code/kivy/kivy/graphics/opengl_utils_def.pxi":3
 * cdef int GLCAP_BGRA = 0x0001
 * cdef int GLCAP_NPOT = 0x0002
 * cdef int GLCAP_S3TC = 0x0003             # <<<<<<<<<<<<<<
 * cdef int GLCAP_DXT1 = 0x0004
 */
  __pyx_v_4kivy_8graphics_7texture_GLCAP_S3TC = 0x0003;

  /* "/home/tito/code/kivy/kivy/graphics/opengl_utils_def.pxi":4
 * cdef int GLCAP_NPOT = 0x0002
 * cdef int GLCAP_S3TC = 0x0003
 * cdef int GLCAP_DXT1 = 0x0004             # <<<<<<<<<<<<<<
 */
  __pyx_v_4kivy_8graphics_7texture_GLCAP_DXT1 = 0x0004;

  /* "kivy/graphics/texture.pyx":157
 * include "opengl_utils_def.pxi"
 * 
 * from os import environ             # <<<<<<<<<<<<<<
 * from array import array
 * from kivy.logger import Logger
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__environ));
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__environ));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__environ));
  __pyx_t_3 = __Pyx_Import(((PyObject *)__pyx_n_s__os), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__environ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__environ, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "kivy/graphics/texture.pyx":158
 * 
 * from os import environ
 * from array import array             # <<<<<<<<<<<<<<
 * from kivy.logger import Logger
 * 
 */
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__array));
  PyList_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__array));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__array));
  __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__array), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__array); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__array, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "kivy/graphics/texture.pyx":159
 * from os import environ
 * from array import array
 * from kivy.logger import Logger             # <<<<<<<<<<<<<<
 * 
 * from c_opengl cimport *
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__Logger));
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__Logger));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Logger));
  __pyx_t_3 = __Pyx_Import(((PyObject *)__pyx_n_s_44), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__Logger); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__Logger, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "kivy/graphics/texture.pyx":167
 * 
 * # 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":168
 * # 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":169
 * 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":170
 * 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_DXT3_EXT = 0x83F2;

  /* "kivy/graphics/texture.pyx":171
 * 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 object _texture_release_trigger = None
 */
  __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3;

  /* "kivy/graphics/texture.pyx":173
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3
 * 
 * cdef object _texture_release_trigger = None             # <<<<<<<<<<<<<<
 * cdef list _texture_release_list = []
 * 
 */
  __Pyx_INCREF(Py_None);
  __Pyx_GOTREF(__pyx_v_4kivy_8graphics_7texture__texture_release_trigger);
  __Pyx_DECREF(__pyx_v_4kivy_8graphics_7texture__texture_release_trigger);
  __Pyx_GIVEREF(Py_None);
  __pyx_v_4kivy_8graphics_7texture__texture_release_trigger = Py_None;

  /* "kivy/graphics/texture.pyx":174
 * 
 * cdef object _texture_release_trigger = None
 * cdef list _texture_release_list = []             # <<<<<<<<<<<<<<
 * 
 * cdef dict _gl_color_fmt = {
 */
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_GOTREF(((PyObject *)__pyx_v_4kivy_8graphics_7texture__texture_release_list));
  __Pyx_DECREF(((PyObject *)__pyx_v_4kivy_8graphics_7texture__texture_release_list));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
  __pyx_v_4kivy_8graphics_7texture__texture_release_list = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "kivy/graphics/texture.pyx":176
 * cdef list _texture_release_list = []
 * 
 * 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_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));

  /* "kivy/graphics/texture.pyx":177
 * 
 * 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_2 = PyInt_FromLong(GL_RGBA); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__rgba), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_BGRA); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__bgra), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromLong(GL_RGB); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__rgb), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_BGR); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__bgr), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "kivy/graphics/texture.pyx":178
 * 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_2 = PyInt_FromLong(GL_LUMINANCE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__luminance), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromLong(GL_LUMINANCE_ALPHA); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__luminance_alpha), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "kivy/graphics/texture.pyx":179
 *     '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_2 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__s3tc_dxt1), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "kivy/graphics/texture.pyx":180
 *     '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_2 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__s3tc_dxt3), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "kivy/graphics/texture.pyx":181
 *     's3tc_dxt1': GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
 *     's3tc_dxt3': GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
 *     's3tc_dxt5': GL_COMPRESSED_RGBA_S3TC_DXT5_EXT }             # <<<<<<<<<<<<<<
 * 
 * cdef dict _gl_buffer_fmt = {
 */
  __pyx_t_2 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__s3tc_dxt5), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GOTREF(((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_3));
  __pyx_v_4kivy_8graphics_7texture__gl_color_fmt = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "kivy/graphics/texture.pyx":183
 *     's3tc_dxt5': GL_COMPRESSED_RGBA_S3TC_DXT5_EXT }
 * 
 * cdef dict _gl_buffer_fmt = {             # <<<<<<<<<<<<<<
 *     'ubyte': GL_UNSIGNED_BYTE, 'ushort': GL_UNSIGNED_SHORT,
 *     'uint': GL_UNSIGNED_INT, 'byte': GL_BYTE,
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));

  /* "kivy/graphics/texture.pyx":184
 * 
 * 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_2 = PyInt_FromLong(GL_UNSIGNED_BYTE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__ubyte), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromLong(GL_UNSIGNED_SHORT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__ushort), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "kivy/graphics/texture.pyx":185
 * 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_2 = PyInt_FromLong(GL_UNSIGNED_INT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__uint), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromLong(GL_BYTE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__byte), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "kivy/graphics/texture.pyx":186
 *     'ubyte': GL_UNSIGNED_BYTE, 'ushort': GL_UNSIGNED_SHORT,
 *     'uint': GL_UNSIGNED_INT, 'byte': GL_BYTE,
 *     'short': GL_SHORT, 'int': GL_INT, 'float': GL_FLOAT }             # <<<<<<<<<<<<<<
 * 
 * cdef dict _gl_buffer_size = {
 */
  __pyx_t_2 = PyInt_FromLong(GL_SHORT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__short), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromLong(GL_INT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__int), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromLong(GL_FLOAT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__float), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GOTREF(((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_3));
  __pyx_v_4kivy_8graphics_7texture__gl_buffer_fmt = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "kivy/graphics/texture.pyx":188
 *     'short': GL_SHORT, 'int': GL_INT, 'float': GL_FLOAT }
 * 
 * cdef dict _gl_buffer_size = {             # <<<<<<<<<<<<<<
 *     'ubyte': sizeof(GLubyte), 'ushort': sizeof(GLushort),
 *     'uint': sizeof(GLuint), 'byte': sizeof(GLbyte),
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));

  /* "kivy/graphics/texture.pyx":189
 * 
 * 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_2 = __Pyx_PyInt_FromSize_t((sizeof(GLubyte))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__ubyte), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_FromSize_t((sizeof(GLushort))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__ushort), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "kivy/graphics/texture.pyx":190
 * 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_2 = __Pyx_PyInt_FromSize_t((sizeof(GLuint))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__uint), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_FromSize_t((sizeof(GLbyte))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__byte), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "kivy/graphics/texture.pyx":191
 *     'ubyte': sizeof(GLubyte), 'ushort': sizeof(GLushort),
 *     'uint': sizeof(GLuint), 'byte': sizeof(GLbyte),
 *     'short': sizeof(GLshort), 'int': sizeof(GLint),             # <<<<<<<<<<<<<<
 *     'float': sizeof(GLfloat) }
 * 
 */
  __pyx_t_2 = __Pyx_PyInt_FromSize_t((sizeof(GLshort))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__short), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyInt_FromSize_t((sizeof(GLint))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__int), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "kivy/graphics/texture.pyx":192
 *     'uint': sizeof(GLuint), 'byte': sizeof(GLbyte),
 *     'short': sizeof(GLshort), 'int': sizeof(GLint),
 *     'float': sizeof(GLfloat) }             # <<<<<<<<<<<<<<
 * 
 * cdef dict _gl_texture_min_filter = {
 */
  __pyx_t_2 = __Pyx_PyInt_FromSize_t((sizeof(GLfloat))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__float), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GOTREF(((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_3));
  __pyx_v_4kivy_8graphics_7texture__gl_buffer_size = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "kivy/graphics/texture.pyx":194
 *     'float': sizeof(GLfloat) }
 * 
 * cdef dict _gl_texture_min_filter = {             # <<<<<<<<<<<<<<
 *     'nearest': GL_NEAREST, 'linear': GL_LINEAR,
 *     'nearest_mipmap_nearest': GL_NEAREST_MIPMAP_NEAREST,
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));

  /* "kivy/graphics/texture.pyx":195
 * 
 * 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_2 = PyInt_FromLong(GL_NEAREST); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__nearest), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyInt_FromLong(GL_LINEAR); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__linear), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "kivy/graphics/texture.pyx":196
 * 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_2 = PyInt_FromLong(GL_NEAREST_MIPMAP_NEAREST); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s_45), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "kivy/graphics/texture.pyx":197
 *     '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_2 = PyInt_FromLong(GL_NEAREST_MIPMAP_LINEAR); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s_46), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "kivy/graphics/texture.pyx":198
 *     '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_2 = PyInt_FromLong(GL_LINEAR_MIPMAP_NEAREST); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s_19), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "kivy/graphics/texture.pyx":199
 *     'nearest_mipmap_linear': GL_NEAREST_MIPMAP_LINEAR,
 *     'linear_mipmap_nearest': GL_LINEAR_MIPMAP_NEAREST,
 *     'linear_mipmap_linear': GL_LINEAR_MIPMAP_LINEAR }             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = PyInt_FromLong(GL_LINEAR_MIPMAP_LINEAR); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s_47), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GOTREF(((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_3));
  __pyx_v_4kivy_8graphics_7texture__gl_texture_min_filter = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "kivy/graphics/texture.pyx":469
 * 
 * 
 * def texture_create(size=None, colorfmt=None, bufferfmt=None, mipmap=False):             # <<<<<<<<<<<<<<
 *     '''Create a texture based on size.
 * 
 */
  __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_k_21 = __pyx_t_3;
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_4kivy_8graphics_7texture_texture_create, NULL, __pyx_n_s_48); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__texture_create, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "kivy/graphics/texture.pyx":495
 * 
 * 
 * def texture_create_from_data(im, mipmap=False):             # <<<<<<<<<<<<<<
 *     '''Create a texture from an ImageData class
 *     '''
 */
  __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_k_22 = __pyx_t_3;
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_4kivy_8graphics_7texture_1texture_create_from_data, NULL, __pyx_n_s_48); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_49, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "kivy/graphics/texture.pyx":525
 *     or complex texture based on ImageData.'''
 * 
 *     create = staticmethod(texture_create)             # <<<<<<<<<<<<<<
 *     create_from_data = staticmethod(texture_create_from_data)
 * 
 */
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__texture_create); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_builtin_staticmethod, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4kivy_8graphics_7texture_Texture->tp_dict, __pyx_n_s__create, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_4kivy_8graphics_7texture_Texture);

  /* "kivy/graphics/texture.pyx":526
 * 
 *     create = staticmethod(texture_create)
 *     create_from_data = staticmethod(texture_create_from_data)             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, width, height, target, texid, colorfmt='rgb',
 */
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s_49); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_Call(__pyx_builtin_staticmethod, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4kivy_8graphics_7texture_Texture->tp_dict, __pyx_n_s__create_from_data, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  PyType_Modified(__pyx_ptype_4kivy_8graphics_7texture_Texture);

  /* "kivy/graphics/texture.pyx":529
 * 
 *     def __init__(self, width, height, target, texid, colorfmt='rgb',
 *                  mipmap=False):             # <<<<<<<<<<<<<<
 *         self._width         = width
 *         self._height        = height
 */
  __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_k_23 = __pyx_t_3;
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;

  /* "kivy/graphics/texture.pyx":614
 *     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_3 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_k_24 = __pyx_t_3;
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;

  /* "kivy/graphics/texture.pyx":859
 * # So, to prevent that, call the _texture_release
 * # at flip time.
 * def _texture_release(*largs):             # <<<<<<<<<<<<<<
 *     cdef GLuint texture_id
 *     if not _texture_release_list:
 */
  __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_4kivy_8graphics_7texture_2_texture_release, NULL, __pyx_n_s_48); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s___texture_release, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "kivy/graphics/texture.pyx":868
 *     del _texture_release_list[:]
 * 
 * if 'KIVY_DOC_INCLUDE' not in environ:             # <<<<<<<<<<<<<<
 *     # install tick to release texture every 200ms
 *     from kivy.clock import Clock
 */
  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__environ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = (__Pyx_NegateNonNeg(PySequence_Contains(__pyx_t_3, ((PyObject *)__pyx_n_s__KIVY_DOC_INCLUDE)))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {

    /* "kivy/graphics/texture.pyx":870
 * if 'KIVY_DOC_INCLUDE' not in environ:
 *     # install tick to release texture every 200ms
 *     from kivy.clock import Clock             # <<<<<<<<<<<<<<
 *     _texture_release_trigger = Clock.create_trigger(_texture_release)
 * 
 */
    __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_INCREF(((PyObject *)__pyx_n_s__Clock));
    PyList_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__Clock));
    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Clock));
    __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s_50), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__Clock); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    if (PyObject_SetAttr(__pyx_m, __pyx_n_s__Clock, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "kivy/graphics/texture.pyx":871
 *     # install tick to release texture every 200ms
 *     from kivy.clock import Clock
 *     _texture_release_trigger = Clock.create_trigger(_texture_release)             # <<<<<<<<<<<<<<
 * 
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__Clock); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__create_trigger); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s___texture_release); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_GOTREF(__pyx_v_4kivy_8graphics_7texture__texture_release_trigger);
    __Pyx_DECREF(__pyx_v_4kivy_8graphics_7texture__texture_release_trigger);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_v_4kivy_8graphics_7texture__texture_release_trigger = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "kivy/graphics/texture.pyx":1
 * #cython: embedsignature=True             # <<<<<<<<<<<<<<
 * 
 * '''
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 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_5);
  if (__pyx_m) {
    __Pyx_AddTraceback("init kivy.graphics.texture");
    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 */

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
    PyObject *result;
    result = PyObject_GetAttr(dict, name);
    if (!result)
        PyErr_SetObject(PyExc_NameError, name);
    return result;
}

static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is unsubscriptable");
}

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *local_type, *local_value, *local_tb;
    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;
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
    if (unlikely(tstate->curexc_type))
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
        goto bad;
    #endif
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
    Py_INCREF(local_type);
    Py_INCREF(local_value);
    Py_INCREF(local_tb);
    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 (XDECREF may run arbitrary code). */
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
    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) {
    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);
}

static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
    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;
}


#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
    Py_XINCREF(type);
    Py_XINCREF(value);
    Py_XINCREF(tb);
    /* First, check the traceback argument, replacing None with NULL. */
    if (tb == Py_None) {
        Py_DECREF(tb);
        tb = 0;
    }
    else if (tb != NULL && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto raise_error;
    }
    /* Next, replace a missing value with None */
    if (value == NULL) {
        value = Py_None;
        Py_INCREF(value);
    }
    #if PY_VERSION_HEX < 0x02050000
    if (!PyClass_Check(type))
    #else
    if (!PyType_Check(type))
    #endif
    {
        /* Raising an instance.  The value should be a dummy. */
        if (value != Py_None) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        /* Normalize to raise <class>, <instance> */
        Py_DECREF(value);
        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) {
    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)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }

    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:
    return;
}
#endif

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_AS_STRING(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;
        } else {
            #if PY_MAJOR_VERSION < 3
            if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
            #else
            if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) {
            #endif
                goto invalid_keyword_type;
            } else {
                for (name = first_kw_arg; *name; name++) {
                    #if PY_MAJOR_VERSION >= 3
                    if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                        PyUnicode_Compare(**name, key) == 0) break;
                    #else
                    if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                        _PyString_Eq(**name, key)) break;
                    #endif
                }
                if (*name) {
                    values[name-argnames] = value;
                } else {
                    /* unexpected keyword found */
                    for (name=argnames; name != first_kw_arg; name++) {
                        if (**name == key) goto arg_passed_twice;
                        #if PY_MAJOR_VERSION >= 3
                        if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                            PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
                        #else
                        if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                            _PyString_Eq(**name, key)) goto arg_passed_twice;
                        #endif
                    }
                    if (kwds2) {
                        if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
                    } else {
                        goto invalid_keyword;
                    }
                }
            }
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, **name);
    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 *number, *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";
    }
    number = (num_expected == 1) ? "" : "s";
    PyErr_Format(PyExc_TypeError,
        #if PY_VERSION_HEX < 0x02050000
            "%s() takes %s %d positional argument%s (%d given)",
        #else
            "%s() takes %s %zd positional argument%s (%zd given)",
        #endif
        func_name, more_or_less, num_expected, number, num_found);
}

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
        #if PY_VERSION_HEX < 0x02050000
                 "need more than %d value%s to unpack", (int)index,
        #else
                 "need more than %zd value%s to unpack", index,
        #endif
                 (index == 1) ? "" : "s");
}

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
        #if PY_VERSION_HEX < 0x02050000
            "too many values to unpack (expected %d)", (int)expected);
        #else
            "too many values to unpack (expected %zd)", expected);
        #endif
}

static PyObject *__Pyx_UnpackItem(PyObject *iter, Py_ssize_t index) {
    PyObject *item;
    if (!(item = PyIter_Next(iter))) {
        if (!PyErr_Occurred()) {
            __Pyx_RaiseNeedMoreValuesError(index);
        }
    }
    return item;
}

static int __Pyx_EndUnpack(PyObject *iter, Py_ssize_t expected) {
    PyObject *item;
    if ((item = PyIter_Next(iter))) {
        Py_DECREF(item);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    }
    else if (!PyErr_Occurred())
        return 0;
    else
        return -1;
}


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 CYTHON_INLINE int __Pyx_CheckKeywordStrings(
    PyObject *kwdict,
    const char* function_name,
    int kw_allowed)
{
    PyObject* key = 0;
    Py_ssize_t pos = 0;
    while (PyDict_Next(kwdict, &pos, &key, 0)) {
        #if PY_MAJOR_VERSION < 3
        if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key)))
        #else
        if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key)))
        #endif
            goto invalid_keyword_type;
    }
    if ((!kw_allowed) && unlikely(key))
        goto invalid_keyword;
    return 1;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    return 0;
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
    return 0;
}

static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
    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);
}

static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
    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);
}

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
    PyObject *py_import = 0;
    PyObject *empty_list = 0;
    PyObject *module = 0;
    PyObject *global_dict = 0;
    PyObject *empty_dict = 0;
    PyObject *list;
    py_import = __Pyx_GetAttrString(__pyx_b, "__import__");
    if (!py_import)
        goto bad;
    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;
    module = PyObject_CallFunctionObjArgs(py_import,
        name, global_dict, empty_dict, list, NULL);
bad:
    Py_XDECREF(empty_list);
    Py_XDECREF(py_import);
    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 {
        GLuint val;
        PyObject *v = __Pyx_PyNumber_Int(x);
        #if PY_VERSION_HEX < 0x03000000
        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;
        }
        return (GLuint)-1;
    }
}

static CYTHON_INLINE GLenum __Pyx_PyInt_from_py_GLenum(PyObject* x) {
    const GLenum neg_one = (GLenum)-1, const_zero = (GLenum)0;
    const int is_unsigned = const_zero < neg_one;
    if (sizeof(GLenum) == sizeof(char)) {
        if (is_unsigned)
            return (GLenum)__Pyx_PyInt_AsUnsignedChar(x);
        else
            return (GLenum)__Pyx_PyInt_AsSignedChar(x);
    } else if (sizeof(GLenum) == sizeof(short)) {
        if (is_unsigned)
            return (GLenum)__Pyx_PyInt_AsUnsignedShort(x);
        else
            return (GLenum)__Pyx_PyInt_AsSignedShort(x);
    } else if (sizeof(GLenum) == sizeof(int)) {
        if (is_unsigned)
            return (GLenum)__Pyx_PyInt_AsUnsignedInt(x);
        else
            return (GLenum)__Pyx_PyInt_AsSignedInt(x);
    } else if (sizeof(GLenum) == sizeof(long)) {
        if (is_unsigned)
            return (GLenum)__Pyx_PyInt_AsUnsignedLong(x);
        else
            return (GLenum)__Pyx_PyInt_AsSignedLong(x);
    } else if (sizeof(GLenum) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return (GLenum)__Pyx_PyInt_AsUnsignedLongLong(x);
        else
            return (GLenum)__Pyx_PyInt_AsSignedLongLong(x);
    }  else {
        GLenum val;
        PyObject *v = __Pyx_PyNumber_Int(x);
        #if PY_VERSION_HEX < 0x03000000
        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;
        }
        return (GLenum)-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);
}

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_VERSION_HEX < 0x03000000
    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 (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned long");
                return (unsigned long)-1;
            }
            return PyLong_AsUnsignedLong(x);
        } else {
            return 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;
    }
}

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_VERSION_HEX < 0x03000000
    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 (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 PyLong_AsUnsignedLongLong(x);
        } else {
            return 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;
    }
}

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_VERSION_HEX < 0x03000000
    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 (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to long");
                return (long)-1;
            }
            return PyLong_AsUnsignedLong(x);
        } else {
            return 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;
    }
}

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_VERSION_HEX < 0x03000000
    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 (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to PY_LONG_LONG");
                return (PY_LONG_LONG)-1;
            }
            return PyLong_AsUnsignedLongLong(x);
        } else {
            return 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;
    }
}

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_VERSION_HEX < 0x03000000
    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 (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed long");
                return (signed long)-1;
            }
            return PyLong_AsUnsignedLong(x);
        } else {
            return 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;
    }
}

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_VERSION_HEX < 0x03000000
    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 (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 PyLong_AsUnsignedLongLong(x);
        } else {
            return 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 void __Pyx_WriteUnraisable(const char *name) {
    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 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_SetItemString(dict, "__pyx_vtable__", ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

#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;

    #if PY_MAJOR_VERSION < 3
    py_name = PyString_FromString(name);
    #else
    py_name = PyUnicode_FromString(name);
    #endif
    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_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

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"

static void __Pyx_AddTraceback(const char *funcname) {
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    PyObject *py_globals = 0;
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;

    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(__pyx_filename);
    #else
    py_srcfile = PyUnicode_FromString(__pyx_filename);
    #endif
    if (!py_srcfile) goto bad;
    if (__pyx_clineno) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #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_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    py_code = PyCode_New(
        0,            /*int argcount,*/
        #if PY_MAJOR_VERSION >= 3
        0,            /*int kwonlyargcount,*/
        #endif
        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,*/
        __pyx_lineno,   /*int firstlineno,*/
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    if (!py_code) 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 = __pyx_lineno;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    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;
}

/* Type Conversion Functions */

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_VERSION_HEX < 0x03000000
  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_VERSION_HEX < 0x03000000
  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_VERSION_HEX < 0x03000000
    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)-1 && PyErr_Occurred())) {
       return (size_t)-1;
   } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
       PyErr_SetString(PyExc_OverflowError,
                       "value too large to convert to size_t");
       return (size_t)-1;
   }
   return (size_t)val;
}


#endif /* Py_PYTHON_H */
