/* Generated by Cython 0.14 on Wed Feb  9 18:35: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
  #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

#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 "stdlib.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 */

/* "/home/tito/code/kivy/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;
  GLuint _gl_wrap;
  GLuint _gl_min_filter;
  GLuint _gl_mag_filter;
  int _rectangle;
  PyObject *_colorfmt;
  float _uvx;
  float _uvy;
  float _uvw;
  float _uvh;
};

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":550
 *         return '<Texture size=(%d, %d)>' % self.size
 * 
 * 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;
};


/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":317
 *     return texture
 * 
 * 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 *(*release)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *);
  PyObject *(*flip_vertical)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, int __pyx_skip_dispatch);
  PyObject *(*get_region)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch);
  PyObject *(*bind)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, int __pyx_skip_dispatch);
  PyObject *(*enable)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, int __pyx_skip_dispatch);
  PyObject *(*disable)(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;


/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":550
 *         return '<Texture size=(%d, %d)>' % self.size
 * 
 * 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 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_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 void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name, PyObject* kw_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 int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*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 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 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*/

#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 GLuint __Pyx_PyInt_from_py_GLuint(PyObject *);

static CYTHON_INLINE GLenum __Pyx_PyInt_from_py_GLenum(PyObject *);

static CYTHON_INLINE GLint __Pyx_PyInt_from_py_GLint(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 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.texture */

static PyTypeObject *__pyx_ptype_4kivy_8graphics_7texture_Texture = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_7texture_TextureRegion = 0;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_BGR;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_BGRA;
static PyObject *__pyx_v_4kivy_8graphics_7texture__texture_release_list = 0;
static int __pyx_v_4kivy_8graphics_7texture__has_bgr;
static int __pyx_v_4kivy_8graphics_7texture__has_texture_nv;
static int __pyx_v_4kivy_8graphics_7texture__has_texture_arb;
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 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__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 int __pyx_f_4kivy_8graphics_7texture__gl_format_size(GLuint); /*proto*/
static CYTHON_INLINE int __pyx_f_4kivy_8graphics_7texture_has_bgr(void); /*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 PyObject *__pyx_f_4kivy_8graphics_7texture__texture_create(int, int, PyObject *, PyObject *, int, int); /*proto*/
#define __Pyx_MODULE_NAME "kivy.graphics.texture"
int __pyx_module_is_main_kivy__graphics__texture = 0;

/* Implementation of kivy.graphics.texture */
static PyObject *__pyx_builtin_staticmethod;
static PyObject *__pyx_builtin_KeyError;
static PyObject *__pyx_builtin_Exception;
static PyObject *__pyx_builtin_format;
static char __pyx_k_1[] = "AVAILABLE_GL_EXTENSIONS";
static char __pyx_k_2[] = "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[] = "Unsupported format size <%s>";
static char __pyx_k_6[] = "Texture: BGR/BGRA format is not supported byyour graphic card";
static char __pyx_k_8[] = "Texture: Software conversion will be done toRGB/RGBA";
static char __pyx_k_11[] = "Texture: non implemented%s texture conversion";
static char __pyx_k_12[] = "Unimplemented texture conversion for %s";
static char __pyx_k_13[] = "Unable to allocate memory for texture (size is %s)";
static char __pyx_k_21[] = "<Texture size=(%d, %d)>";
static char __pyx_k_22[] = "Texture: releasing %d textures";
static char __pyx_k_23[] = "Return True if the texture have mipmap enabled (readonly)";
static char __pyx_k_24[] = "Return True if the texture is a rectangle texture (readonly)";
static char __pyx_k_25[] = "Return the OpenGL ID of the texture (readonly)";
static char __pyx_k_26[] = "Return the OpenGL target of the texture (readonly)";
static char __pyx_k_27[] = "Return the width of the texture (readonly)";
static char __pyx_k_28[] = "Return the height of the texture (readonly)";
static char __pyx_k_29[] = "Return the list of tex_coords (opengl)";
static char __pyx_k_30[] = "Get/set the UV position inside texture\n        ";
static char __pyx_k_31[] = "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_32[] = "Get/set the GL_TEXTURE_MIN_FILTER property\n        ";
static char __pyx_k_33[] = "Get/set the GL_TEXTURE_MAG_FILTER property\n        ";
static char __pyx_k_34[] = "Get/set the GL_TEXTURE_WRAP_S,T property\n        ";
static char __pyx_k_35[] = "\nTexture management\n==================\n\nOpenGL texture can be a pain to manage ourself, except if you know perfectly all\nthe OpenGL API :).\n";
static char __pyx_k_37[] = "kivy.logger";
static char __pyx_k_38[] = "";
static char __pyx_k_39[] = "kivy.graphics.texture";
static char __pyx_k_40[] = "texture_create_from_data";
static char __pyx_k_41[] = "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__wrap[] = "wrap";
static char __pyx_k__Clock[] = "Clock";
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__split[] = "split";
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__enable[] = "enable";
static char __pyx_k__format[] = "format";
static char __pyx_k__height[] = "height";
static char __pyx_k__mipmap[] = "mipmap";
static char __pyx_k__origin[] = "origin";
static char __pyx_k__target[] = "target";
static char __pyx_k__ushort[] = "ushort";
static char __pyx_k__uvsize[] = "uvsize";
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__disable[] = "disable";
static char __pyx_k__environ[] = "environ";
static char __pyx_k__pbuffer[] = "pbuffer";
static char __pyx_k__release[] = "release";
static char __pyx_k__warning[] = "warning";
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___gl_wrap[] = "_gl_wrap";
static char __pyx_k__colorfmt[] = "colorfmt";
static char __pyx_k__critical[] = "critical";
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__rectangle[] = "rectangle";
static char __pyx_k___rectangle[] = "_rectangle";
static char __pyx_k__get_region[] = "get_region";
static char __pyx_k__mag_filter[] = "mag_filter";
static char __pyx_k__min_filter[] = "min_filter";
static char __pyx_k__GL_EXT_bgra[] = "GL_EXT_bgra";
static char __pyx_k___tex_coords[] = "_tex_coords";
static char __pyx_k__blit_buffer[] = "blit_buffer";
static char __pyx_k__staticmethod[] = "staticmethod";
static char __pyx_k__TextureRegion[] = "TextureRegion";
static char __pyx_k__flip_vertical[] = "flip_vertical";
static char __pyx_k___gl_mag_filter[] = "_gl_mag_filter";
static char __pyx_k___gl_min_filter[] = "_gl_min_filter";
static char __pyx_k__hasGLExtension[] = "hasGLExtension";
static char __pyx_k__texture_create[] = "texture_create";
static char __pyx_k__luminance_alpha[] = "luminance_alpha";
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__schedule_interval[] = "schedule_interval";
static char __pyx_k__update_tex_coords[] = "update_tex_coords";
static PyObject *__pyx_n_s_1;
static PyObject *__pyx_kp_s_11;
static PyObject *__pyx_kp_s_12;
static PyObject *__pyx_kp_s_13;
static PyObject *__pyx_kp_s_2;
static PyObject *__pyx_kp_s_21;
static PyObject *__pyx_kp_s_22;
static PyObject *__pyx_kp_s_3;
static PyObject *__pyx_n_s_37;
static PyObject *__pyx_kp_s_38;
static PyObject *__pyx_n_s_39;
static PyObject *__pyx_kp_s_4;
static PyObject *__pyx_n_s_40;
static PyObject *__pyx_n_s_41;
static PyObject *__pyx_kp_s_5;
static PyObject *__pyx_kp_s_6;
static PyObject *__pyx_kp_s_8;
static PyObject *__pyx_n_s__Clock;
static PyObject *__pyx_n_s__Exception;
static PyObject *__pyx_n_s__GL_EXT_bgra;
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___gl_mag_filter;
static PyObject *__pyx_n_s___gl_min_filter;
static PyObject *__pyx_n_s___gl_wrap;
static PyObject *__pyx_n_s___height;
static PyObject *__pyx_n_s___id;
static PyObject *__pyx_n_s___mipmap;
static PyObject *__pyx_n_s___rectangle;
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__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__colorfmt;
static PyObject *__pyx_n_s__create;
static PyObject *__pyx_n_s__create_from_data;
static PyObject *__pyx_n_s__critical;
static PyObject *__pyx_n_s__data;
static PyObject *__pyx_n_s__disable;
static PyObject *__pyx_n_s__enable;
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__hasGLExtension;
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__lower;
static PyObject *__pyx_n_s__luminance;
static PyObject *__pyx_n_s__luminance_alpha;
static PyObject *__pyx_n_s__mag_filter;
static PyObject *__pyx_n_s__min_filter;
static PyObject *__pyx_n_s__mipmap;
static PyObject *__pyx_n_s__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__rectangle;
static PyObject *__pyx_n_s__release;
static PyObject *__pyx_n_s__rgb;
static PyObject *__pyx_n_s__rgba;
static PyObject *__pyx_n_s__schedule_interval;
static PyObject *__pyx_n_s__short;
static PyObject *__pyx_n_s__size;
static PyObject *__pyx_n_s__split;
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__uvsize;
static PyObject *__pyx_n_s__warning;
static PyObject *__pyx_n_s__width;
static PyObject *__pyx_n_s__wrap;
static PyObject *__pyx_n_s__x;
static PyObject *__pyx_n_s__y;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_3;
static PyObject *__pyx_int_4;
static PyObject *__pyx_k_14;
static PyObject *__pyx_k_15;
static PyObject *__pyx_k_16;
static PyObject *__pyx_k_17;
static PyObject *__pyx_k_18;
static PyObject *__pyx_k_19;
static PyObject *__pyx_k_tuple_7;
static PyObject *__pyx_k_tuple_9;
static PyObject *__pyx_k_tuple_10;
static PyObject *__pyx_k_tuple_20;
static PyObject *__pyx_k_tuple_36;

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":32
 * # utilities
 * AVAILABLE_GL_EXTENSIONS = ''
 * def hasGLExtension( specifier ):             # <<<<<<<<<<<<<<
 *     '''Given a string specifier, check for extension being available
 *     '''
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_0hasGLExtension(PyObject *__pyx_self, PyObject *__pyx_v_specifier); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_0hasGLExtension[] = "hasGLExtension(specifier)\nGiven a string specifier, check for extension being available\n    ";
static PyMethodDef __pyx_mdef_4kivy_8graphics_7texture_0hasGLExtension = {__Pyx_NAMESTR("hasGLExtension"), (PyCFunction)__pyx_pf_4kivy_8graphics_7texture_0hasGLExtension, METH_O, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_0hasGLExtension)};
static PyObject *__pyx_pf_4kivy_8graphics_7texture_0hasGLExtension(PyObject *__pyx_self, PyObject *__pyx_v_specifier) {
  PyObject *__pyx_v_extensions;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("hasGLExtension");
  __pyx_self = __pyx_self;
  __pyx_v_extensions = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":37
 *     global AVAILABLE_GL_EXTENSIONS
 *     cdef bytes extensions
 *     if not AVAILABLE_GL_EXTENSIONS:             # <<<<<<<<<<<<<<
 *         extensions = <char *>glGetString( GL_EXTENSIONS )
 *         AVAILABLE_GL_EXTENSIONS[:] = extensions.split()
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __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 = 37; __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) {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":38
 *     cdef bytes extensions
 *     if not AVAILABLE_GL_EXTENSIONS:
 *         extensions = <char *>glGetString( GL_EXTENSIONS )             # <<<<<<<<<<<<<<
 *         AVAILABLE_GL_EXTENSIONS[:] = extensions.split()
 *     return specifier in AVAILABLE_GL_EXTENSIONS
 */
    __pyx_t_1 = PyBytes_FromString(((char *)glGetString(GL_EXTENSIONS))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
    __Pyx_DECREF(((PyObject *)__pyx_v_extensions));
    __pyx_v_extensions = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":39
 *     if not AVAILABLE_GL_EXTENSIONS:
 *         extensions = <char *>glGetString( GL_EXTENSIONS )
 *         AVAILABLE_GL_EXTENSIONS[:] = extensions.split()             # <<<<<<<<<<<<<<
 *     return specifier in AVAILABLE_GL_EXTENSIONS
 * 
 */
    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_extensions), __pyx_n_s__split); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (__Pyx_PySequence_SetSlice(__pyx_t_1, 0, PY_SSIZE_T_MAX, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":40
 *         extensions = <char *>glGetString( GL_EXTENSIONS )
 *         AVAILABLE_GL_EXTENSIONS[:] = extensions.split()
 *     return specifier in AVAILABLE_GL_EXTENSIONS             # <<<<<<<<<<<<<<
 * 
 * # compatibility layer
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = ((PySequence_Contains(__pyx_t_4, __pyx_v_specifier))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("kivy.graphics.texture.hasGLExtension");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_extensions);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":51
 * cdef int _has_texture_arb = -1
 * 
 * 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");

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":54
 *     # 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);

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

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

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":57
 *     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));

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":58
 *     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));

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

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":60
 *     v |= v >> 8
 *     v |= v >> 16
 *     return v + 1             # <<<<<<<<<<<<<<
 * 
 * cdef inline int _is_pow2(int v):
 */
  __pyx_r = (__pyx_v_v + 1);
  goto __pyx_L0;

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

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":62
 *     return v + 1
 * 
 * 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");

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

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

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":75
 * }
 * 
 * cdef inline int _color_fmt_to_gl(str x):             # <<<<<<<<<<<<<<
 *     x = x.lower()
 *     try:
 */

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

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":76
 * 
 * cdef inline int _color_fmt_to_gl(str x):
 *     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 = 76; __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 = 76; __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 = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_v_x));
  __pyx_v_x = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":77
 * cdef inline int _color_fmt_to_gl(str x):
 *     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:*/ {

      /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":78
 *     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 = 78; __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 = 78; __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;

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":79
 *     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 = 79; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_4);

      /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":80
 *         return _gl_color_fmt[x]
 *     except KeyError:
 *         raise Exception('Unknown <%s> color format' % x)             # <<<<<<<<<<<<<<
 * 
 * cdef dict _gl_buffer_fmt = {
 */
      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_2), ((PyObject *)__pyx_v_x)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __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 = 80; __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 = 80; __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 = 80; __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;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":92
 * }
 * 
 * cdef inline int _buffer_fmt_to_gl(str x):             # <<<<<<<<<<<<<<
 *     x = x.lower()
 *     try:
 */

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

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":93
 * 
 * cdef inline int _buffer_fmt_to_gl(str x):
 *     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 = 93; __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 = 93; __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 = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_v_x));
  __pyx_v_x = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":94
 * cdef inline int _buffer_fmt_to_gl(str x):
 *     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:*/ {

      /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":95
 *     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 = 95; __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 = 95; __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;

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":96
 *     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 = 96; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_4);

      /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":97
 *         return _gl_buffer_fmt[x]
 *     except KeyError:
 *         raise Exception('Unknown <%s> buffer format' % x)             # <<<<<<<<<<<<<<
 * 
 * cdef dict _gl_buffer_size = {
 */
      __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 = 97; __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 = 97; __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 = 97; __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 = 97; __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;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":109
 * }
 * 
 * cdef inline int _buffer_type_to_gl_size(str x):             # <<<<<<<<<<<<<<
 *     x = x.lower()
 *     try:
 */

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

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":110
 * 
 * cdef inline int _buffer_type_to_gl_size(str x):
 *     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 = 110; __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 = 110; __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 = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_v_x));
  __pyx_v_x = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":111
 * cdef inline int _buffer_type_to_gl_size(str x):
 *     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:*/ {

      /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":112
 *     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 = 112; __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 = 112; __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;

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":113
 *     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 = 113; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GOTREF(__pyx_t_4);

      /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":114
 *         return _gl_buffer_size[x]
 *     except KeyError:
 *         raise Exception('Unknown <%s> format' % x)             # <<<<<<<<<<<<<<
 * 
 * cdef inline int _gl_format_size(GLuint 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 = 114; __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 = 114; __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 = 114; __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 = 114; __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;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":116
 *         raise Exception('Unknown <%s> format' % x)
 * 
 * cdef inline int _gl_format_size(GLuint x):             # <<<<<<<<<<<<<<
 *     if x in (GL_RGB, GL_BGR):
 *         return 3
 */

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;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("_gl_format_size");

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":117
 * 
 * cdef inline int _gl_format_size(GLuint x):
 *     if x in (GL_RGB, GL_BGR):             # <<<<<<<<<<<<<<
 *         return 3
 *     elif x in (GL_RGBA, GL_BGRA):
 */
  __pyx_t_1 = __pyx_v_x;
  __pyx_t_2 = (__pyx_t_1 == GL_RGB);
  if (!__pyx_t_2) {
    __pyx_t_3 = (__pyx_t_1 == __pyx_v_4kivy_8graphics_7texture_GL_BGR);
    __pyx_t_4 = __pyx_t_3;
  } else {
    __pyx_t_4 = __pyx_t_2;
  }
  __pyx_t_2 = __pyx_t_4;
  if (__pyx_t_2) {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":118
 * cdef inline int _gl_format_size(GLuint x):
 *     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;
  }

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

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":120
 *         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;
  }

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":121
 *     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) {

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

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":123
 *     elif x == GL_LUMINANCE_ALPHA:
 *         return 2
 *     elif x == GL_LUMINANCE:             # <<<<<<<<<<<<<<
 *         return 1
 *     raise Exception('Unsupported format size <%s>' % str(format))
 */
  __pyx_t_2 = (__pyx_v_x == GL_LUMINANCE);
  if (__pyx_t_2) {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":124
 *         return 2
 *     elif x == GL_LUMINANCE:
 *         return 1             # <<<<<<<<<<<<<<
 *     raise Exception('Unsupported format size <%s>' % str(format))
 * 
 */
    __pyx_r = 1;
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":125
 *     elif x == GL_LUMINANCE:
 *         return 1
 *     raise Exception('Unsupported format size <%s>' % str(format))             # <<<<<<<<<<<<<<
 * 
 * cdef inline int has_bgr():
 */
  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  __Pyx_INCREF(__pyx_builtin_format);
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_builtin_format);
  __Pyx_GIVEREF(__pyx_builtin_format);
  __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_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 = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  __Pyx_Raise(__pyx_t_5, 0, 0);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

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

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":127
 *     raise Exception('Unsupported format size <%s>' % str(format))
 * 
 * cdef inline int has_bgr():             # <<<<<<<<<<<<<<
 *     global _has_bgr
 *     if _has_bgr == -1:
 */

static CYTHON_INLINE int __pyx_f_4kivy_8graphics_7texture_has_bgr(void) {
  int __pyx_r;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  __Pyx_RefNannySetupContext("has_bgr");

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":129
 * cdef inline int has_bgr():
 *     global _has_bgr
 *     if _has_bgr == -1:             # <<<<<<<<<<<<<<
 *         Logger.warning('Texture: BGR/BGRA format is not supported by'
 *                        'your graphic card')
 */
  __pyx_t_1 = (__pyx_v_4kivy_8graphics_7texture__has_bgr == -1);
  if (__pyx_t_1) {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":130
 *     global _has_bgr
 *     if _has_bgr == -1:
 *         Logger.warning('Texture: BGR/BGRA format is not supported by'             # <<<<<<<<<<<<<<
 *                        'your graphic card')
 *         Logger.warning('Texture: Software conversion will be done to'
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__Logger); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__warning); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_7), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":132
 *         Logger.warning('Texture: BGR/BGRA format is not supported by'
 *                        'your graphic card')
 *         Logger.warning('Texture: Software conversion will be done to'             # <<<<<<<<<<<<<<
 *                        'RGB/RGBA')
 *         _has_bgr = int(hasGLExtension('GL_EXT_bgra'))
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__Logger); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__warning); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_9), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":134
 *         Logger.warning('Texture: Software conversion will be done to'
 *                        'RGB/RGBA')
 *         _has_bgr = int(hasGLExtension('GL_EXT_bgra'))             # <<<<<<<<<<<<<<
 *     return _has_bgr
 * 
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__hasGLExtension); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_10), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __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(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __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 = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_4kivy_8graphics_7texture__has_bgr = __pyx_t_4;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":135
 *                        'RGB/RGBA')
 *         _has_bgr = int(hasGLExtension('GL_EXT_bgra'))
 *     return _has_bgr             # <<<<<<<<<<<<<<
 * 
 * cdef inline int _is_gl_format_supported(str x):
 */
  __pyx_r = __pyx_v_4kivy_8graphics_7texture__has_bgr;
  goto __pyx_L0;

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

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":137
 *     return _has_bgr
 * 
 * cdef inline int _is_gl_format_supported(str x):             # <<<<<<<<<<<<<<
 *     if x in ('bgr', 'bgra'):
 *         return not has_bgr()
 */

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;
  __Pyx_RefNannySetupContext("_is_gl_format_supported");

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":138
 * 
 * cdef inline int _is_gl_format_supported(str x):
 *     if x in ('bgr', 'bgra'):             # <<<<<<<<<<<<<<
 *         return not has_bgr()
 *     return 1
 */
  __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 = 138; __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 = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __pyx_t_3;
  if (!__pyx_t_4) {
    __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 = 138; __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 = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = __pyx_t_3;
    __pyx_t_3 = __pyx_t_5;
  } else {
    __pyx_t_3 = __pyx_t_4;
  }
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_t_4 = __pyx_t_3;
  if (__pyx_t_4) {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":139
 * cdef inline int _is_gl_format_supported(str x):
 *     if x in ('bgr', 'bgra'):
 *         return not has_bgr()             # <<<<<<<<<<<<<<
 *     return 1
 * 
 */
    __pyx_r = (!__pyx_f_4kivy_8graphics_7texture_has_bgr());
    goto __pyx_L0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":140
 *     if x in ('bgr', 'bgra'):
 *         return not has_bgr()
 *     return 1             # <<<<<<<<<<<<<<
 * 
 * cdef inline str _convert_gl_format(str x):
 */
  __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_WriteUnraisable("kivy.graphics.texture._is_gl_format_supported");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":142
 *     return 1
 * 
 * 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");

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":143
 * 
 * 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 = 143; __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 = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":144
 * 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;
  }

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":145
 *     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 = 145; __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 = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":146
 *         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:;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":147
 *     elif x == 'bgra':
 *         return 'rgba'
 *     return x             # <<<<<<<<<<<<<<
 * 
 * cdef inline _convert_buffer(bytes data, str fmt):
 */
  __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;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":149
 *     return x
 * 
 * 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;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = 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);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":154
 * 
 *     # check if format is supported by user
 *     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;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":155
 *     # check if format is supported by user
 *     ret_format = fmt
 *     ret_buffer = data             # <<<<<<<<<<<<<<
 * 
 *     # BGR / BGRA conversion not supported by hardware ?
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_data));
  __Pyx_DECREF(((PyObject *)__pyx_v_ret_buffer));
  __pyx_v_ret_buffer = __pyx_v_data;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":158
 * 
 *     # BGR / BGRA conversion not supported by hardware ?
 *     if not _is_gl_format_supported(fmt):             # <<<<<<<<<<<<<<
 *         if fmt == 'bgr':
 *             ret_format = 'rgb'
 */
  __pyx_t_1 = (!__pyx_f_4kivy_8graphics_7texture__is_gl_format_supported(__pyx_v_fmt));
  if (__pyx_t_1) {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":159
 *     # BGR / BGRA conversion not supported by hardware ?
 *     if not _is_gl_format_supported(fmt):
 *         if fmt == 'bgr':             # <<<<<<<<<<<<<<
 *             ret_format = 'rgb'
 *             a = array('b', data)
 */
    __pyx_t_2 = PyObject_RichCompare(((PyObject *)__pyx_v_fmt), ((PyObject *)__pyx_n_s__bgr), Py_EQ); 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);
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 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;
    if (__pyx_t_1) {

      /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":160
 *     if not _is_gl_format_supported(fmt):
 *         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;

      /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":161
 *         if fmt == 'bgr':
 *             ret_format = 'rgb'
 *             a = array('b', data)             # <<<<<<<<<<<<<<
 *             a[0::3], a[2::3] = a[2::3], a[0::3]
 *             ret_buffer = a.tostring()
 */
      __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__array); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __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 = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      __Pyx_INCREF(((PyObject *)__pyx_n_s__b));
      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__b));
      __Pyx_GIVEREF(((PyObject *)__pyx_n_s__b));
      __Pyx_INCREF(((PyObject *)__pyx_v_data));
      PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_data));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_data));
      __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_v_a);
      __pyx_v_a = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":162
 *             ret_format = 'rgb'
 *             a = array('b', data)
 *             a[0::3], a[2::3] = a[2::3], a[0::3]             # <<<<<<<<<<<<<<
 *             ret_buffer = a.tostring()
 *         elif fmt == 'bgra':
 */
      __pyx_t_4 = PySlice_New(__pyx_int_2, Py_None, __pyx_int_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_GetItem(__pyx_v_a, __pyx_t_4); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PySlice_New(__pyx_int_0, Py_None, __pyx_int_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_2 = PyObject_GetItem(__pyx_v_a, __pyx_t_4); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PySlice_New(__pyx_int_0, Py_None, __pyx_int_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      if (PyObject_SetItem(__pyx_v_a, __pyx_t_4, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PySlice_New(__pyx_int_2, Py_None, __pyx_int_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      if (PyObject_SetItem(__pyx_v_a, __pyx_t_3, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __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;

      /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":163
 *             a = array('b', data)
 *             a[0::3], a[2::3] = a[2::3], a[0::3]
 *             ret_buffer = a.tostring()             # <<<<<<<<<<<<<<
 *         elif fmt == 'bgra':
 *             ret_format = 'rgba'
 */
      __pyx_t_2 = PyObject_GetAttr(__pyx_v_a, __pyx_n_s__tostring); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!(likely(PyBytes_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(((PyObject *)__pyx_v_ret_buffer));
      __pyx_v_ret_buffer = ((PyObject*)__pyx_t_3);
      __pyx_t_3 = 0;
      goto __pyx_L4;
    }

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":164
 *             a[0::3], a[2::3] = a[2::3], a[0::3]
 *             ret_buffer = a.tostring()
 *         elif fmt == 'bgra':             # <<<<<<<<<<<<<<
 *             ret_format = 'rgba'
 *             a = array('b', data)
 */
    __pyx_t_3 = PyObject_RichCompare(((PyObject *)__pyx_v_fmt), ((PyObject *)__pyx_n_s__bgra), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_1) {

      /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":165
 *             ret_buffer = a.tostring()
 *         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;

      /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":166
 *         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_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__array); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(((PyObject *)__pyx_n_s__b));
      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__b));
      __Pyx_GIVEREF(((PyObject *)__pyx_n_s__b));
      __Pyx_INCREF(((PyObject *)__pyx_v_data));
      PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_data));
      __Pyx_GIVEREF(((PyObject *)__pyx_v_data));
      __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_v_a);
      __pyx_v_a = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":167
 *             ret_format = 'rgba'
 *             a = array('b', data)
 *             a[0::4], a[2::4] = a[2::4], a[0::4]             # <<<<<<<<<<<<<<
 *             ret_buffer = a.tostring()
 *         else:
 */
      __pyx_t_4 = PySlice_New(__pyx_int_2, Py_None, __pyx_int_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_2 = PyObject_GetItem(__pyx_v_a, __pyx_t_4); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PySlice_New(__pyx_int_0, Py_None, __pyx_int_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyObject_GetItem(__pyx_v_a, __pyx_t_4); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PySlice_New(__pyx_int_0, Py_None, __pyx_int_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      if (PyObject_SetItem(__pyx_v_a, __pyx_t_4, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PySlice_New(__pyx_int_2, Py_None, __pyx_int_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      if (PyObject_SetItem(__pyx_v_a, __pyx_t_2, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __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;

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

      /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":170
 *             ret_buffer = a.tostring()
 *         else:
 *             Logger.critical('Texture: non implemented'             # <<<<<<<<<<<<<<
 *                             '%s texture conversion' % fmt)
 *             raise Exception('Unimplemented texture conversion for %s' %
 */
      __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__Logger); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__critical); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":171
 *         else:
 *             Logger.critical('Texture: non implemented'
 *                             '%s texture conversion' % fmt)             # <<<<<<<<<<<<<<
 *             raise Exception('Unimplemented texture conversion for %s' %
 *                             str(format))
 */
      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_11), ((PyObject *)__pyx_v_fmt)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_2));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
      __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __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_4)); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":173
 *                             '%s texture conversion' % fmt)
 *             raise Exception('Unimplemented texture conversion for %s' %
 *                             str(format))             # <<<<<<<<<<<<<<
 *     return ret_buffer, ret_format
 * 
 */
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_INCREF(__pyx_builtin_format);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_builtin_format);
      __Pyx_GIVEREF(__pyx_builtin_format);
      __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_12), __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
      PyTuple_SET_ITEM(__pyx_t_4, 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_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
      __Pyx_Raise(__pyx_t_2, 0, 0);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":174
 *             raise Exception('Unimplemented texture conversion for %s' %
 *                             str(format))
 *     return ret_buffer, ret_format             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(((PyObject *)__pyx_v_ret_buffer));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_ret_buffer));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_ret_buffer));
  __Pyx_INCREF(((PyObject *)__pyx_v_ret_format));
  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_ret_format));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_ret_format));
  __pyx_r = ((PyObject *)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __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;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":177
 * 
 * 
 * cdef _texture_create(int width, int height, str colorfmt, str bufferfmt, int             # <<<<<<<<<<<<<<
 *                      rectangle, int mipmap):
 *     cdef GLuint target = GL_TEXTURE_2D
 */

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_rectangle, int __pyx_v_mipmap) {
  GLuint __pyx_v_target;
  int __pyx_v_texture_width;
  int __pyx_v_texture_height;
  int __pyx_v_glbufferfmt;
  GLuint __pyx_v_texid;
  struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_texture = 0;
  int __pyx_v_glfmt;
  int __pyx_v_datasize;
  void *__pyx_v_data;
  int __pyx_v_dataerr;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  __Pyx_RefNannySetupContext("_texture_create");
  __Pyx_INCREF(__pyx_v_colorfmt);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":179
 * cdef _texture_create(int width, int height, str colorfmt, str bufferfmt, int
 *                      rectangle, int mipmap):
 *     cdef GLuint target = GL_TEXTURE_2D             # <<<<<<<<<<<<<<
 *     cdef int texture_width, texture_height
 *     cdef int glbufferfmt = _buffer_fmt_to_gl(bufferfmt)
 */
  __pyx_v_target = GL_TEXTURE_2D;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":181
 *     cdef GLuint target = GL_TEXTURE_2D
 *     cdef int texture_width, texture_height
 *     cdef int glbufferfmt = _buffer_fmt_to_gl(bufferfmt)             # <<<<<<<<<<<<<<
 * 
 *     if rectangle:
 */
  __pyx_v_glbufferfmt = __pyx_f_4kivy_8graphics_7texture__buffer_fmt_to_gl(__pyx_v_bufferfmt);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":183
 *     cdef int glbufferfmt = _buffer_fmt_to_gl(bufferfmt)
 * 
 *     if rectangle:             # <<<<<<<<<<<<<<
 *         rectangle = 0
 *         if not _is_pow2(width) or not _is_pow2(height):
 */
  if (__pyx_v_rectangle) {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":184
 * 
 *     if rectangle:
 *         rectangle = 0             # <<<<<<<<<<<<<<
 *         if not _is_pow2(width) or not _is_pow2(height):
 *             # Adapt this part to make it work.
 */
    __pyx_v_rectangle = 0;

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":185
 *     if rectangle:
 *         rectangle = 0
 *         if not _is_pow2(width) or not _is_pow2(height):             # <<<<<<<<<<<<<<
 *             # Adapt this part to make it work.
 *             # It cannot work for OpenGL ES 2.0,
 */
    __pyx_t_1 = (!__pyx_f_4kivy_8graphics_7texture__is_pow2(__pyx_v_width));
    if (!__pyx_t_1) {
      __pyx_t_2 = (!__pyx_f_4kivy_8graphics_7texture__is_pow2(__pyx_v_height));
      __pyx_t_3 = __pyx_t_2;
    } else {
      __pyx_t_3 = __pyx_t_1;
    }
    if (__pyx_t_3) {

      /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":210
 * 
 *             # Can't do mipmap with rectangle texture
 *             if rectangle:             # <<<<<<<<<<<<<<
 *                 mipmap = 0
 * 
 */
      if (__pyx_v_rectangle) {

        /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":211
 *             # Can't do mipmap with rectangle texture
 *             if rectangle:
 *                 mipmap = 0             # <<<<<<<<<<<<<<
 * 
 *     if rectangle:
 */
        __pyx_v_mipmap = 0;
        goto __pyx_L5;
      }
      __pyx_L5:;
      goto __pyx_L4;
    }
    __pyx_L4:;
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":213
 *                 mipmap = 0
 * 
 *     if rectangle:             # <<<<<<<<<<<<<<
 *         texture_width = width
 *         texture_height = height
 */
  if (__pyx_v_rectangle) {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":214
 * 
 *     if rectangle:
 *         texture_width = width             # <<<<<<<<<<<<<<
 *         texture_height = height
 *     else:
 */
    __pyx_v_texture_width = __pyx_v_width;

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":215
 *     if rectangle:
 *         texture_width = width
 *         texture_height = height             # <<<<<<<<<<<<<<
 *     else:
 *         texture_width = _nearest_pow2(width)
 */
    __pyx_v_texture_height = __pyx_v_height;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":217
 *         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);

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":218
 *     else:
 *         texture_width = _nearest_pow2(width)
 *         texture_height = _nearest_pow2(height)             # <<<<<<<<<<<<<<
 * 
 *     cdef GLuint texid
 */
    __pyx_v_texture_height = __pyx_f_4kivy_8graphics_7texture__nearest_pow2(__pyx_v_height);
  }
  __pyx_L6:;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":221
 * 
 *     cdef GLuint texid
 *     glGenTextures(1, &texid)             # <<<<<<<<<<<<<<
 * 
 *     if not _is_gl_format_supported(colorfmt):
 */
  glGenTextures(1, (&__pyx_v_texid));

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":223
 *     glGenTextures(1, &texid)
 * 
 *     if not _is_gl_format_supported(colorfmt):             # <<<<<<<<<<<<<<
 *         colorfmt = _convert_gl_format(colorfmt)
 * 
 */
  __pyx_t_3 = (!__pyx_f_4kivy_8graphics_7texture__is_gl_format_supported(__pyx_v_colorfmt));
  if (__pyx_t_3) {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":224
 * 
 *     if not _is_gl_format_supported(colorfmt):
 *         colorfmt = _convert_gl_format(colorfmt)             # <<<<<<<<<<<<<<
 * 
 *     cdef Texture texture = Texture(texture_width, texture_height, target, texid,
 */
    __pyx_t_4 = ((PyObject *)__pyx_f_4kivy_8graphics_7texture__convert_gl_format(__pyx_v_colorfmt)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(((PyObject *)__pyx_v_colorfmt));
    __pyx_v_colorfmt = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
    goto __pyx_L7;
  }
  __pyx_L7:;

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

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":227
 * 
 *     cdef Texture texture = Texture(texture_width, texture_height, target, texid,
 *                       colorfmt=colorfmt, mipmap=mipmap)             # <<<<<<<<<<<<<<
 * 
 *     texture.bind()
 */
  if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__colorfmt), ((PyObject *)__pyx_v_colorfmt)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = PyInt_FromLong(__pyx_v_mipmap); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__mipmap), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_6 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_4kivy_8graphics_7texture_Texture)), ((PyObject *)__pyx_t_8), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
  __pyx_v_texture = ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":229
 *                       colorfmt=colorfmt, mipmap=mipmap)
 * 
 *     texture.bind()             # <<<<<<<<<<<<<<
 *     texture.wrap = GL_CLAMP_TO_EDGE
 *     if mipmap:
 */
  __pyx_t_6 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_texture->__pyx_vtab)->bind(__pyx_v_texture, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":230
 * 
 *     texture.bind()
 *     texture.wrap = GL_CLAMP_TO_EDGE             # <<<<<<<<<<<<<<
 *     if mipmap:
 *         texture.min_filter  = GL_LINEAR_MIPMAP_NEAREST
 */
  __pyx_t_6 = PyInt_FromLong(GL_CLAMP_TO_EDGE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyObject_SetAttr(((PyObject *)__pyx_v_texture), __pyx_n_s__wrap, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":231
 *     texture.bind()
 *     texture.wrap = GL_CLAMP_TO_EDGE
 *     if mipmap:             # <<<<<<<<<<<<<<
 *         texture.min_filter  = GL_LINEAR_MIPMAP_NEAREST
 *         texture.mag_filter  = GL_LINEAR
 */
  if (__pyx_v_mipmap) {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":232
 *     texture.wrap = GL_CLAMP_TO_EDGE
 *     if mipmap:
 *         texture.min_filter  = GL_LINEAR_MIPMAP_NEAREST             # <<<<<<<<<<<<<<
 *         texture.mag_filter  = GL_LINEAR
 *     else:
 */
    __pyx_t_6 = PyInt_FromLong(GL_LINEAR_MIPMAP_NEAREST); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    if (PyObject_SetAttr(((PyObject *)__pyx_v_texture), __pyx_n_s__min_filter, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":233
 *     if mipmap:
 *         texture.min_filter  = GL_LINEAR_MIPMAP_NEAREST
 *         texture.mag_filter  = GL_LINEAR             # <<<<<<<<<<<<<<
 *     else:
 *         texture.min_filter  = GL_LINEAR
 */
    __pyx_t_6 = PyInt_FromLong(GL_LINEAR); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    if (PyObject_SetAttr(((PyObject *)__pyx_v_texture), __pyx_n_s__mag_filter, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L8;
  }
  /*else*/ {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":235
 *         texture.mag_filter  = GL_LINEAR
 *     else:
 *         texture.min_filter  = GL_LINEAR             # <<<<<<<<<<<<<<
 *         texture.mag_filter  = GL_LINEAR
 * 
 */
    __pyx_t_6 = PyInt_FromLong(GL_LINEAR); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    if (PyObject_SetAttr(((PyObject *)__pyx_v_texture), __pyx_n_s__min_filter, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":236
 *     else:
 *         texture.min_filter  = GL_LINEAR
 *         texture.mag_filter  = GL_LINEAR             # <<<<<<<<<<<<<<
 * 
 *     # ok, allocate memory for initial texture
 */
    __pyx_t_6 = PyInt_FromLong(GL_LINEAR); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    if (PyObject_SetAttr(((PyObject *)__pyx_v_texture), __pyx_n_s__mag_filter, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __pyx_L8:;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":239
 * 
 *     # ok, allocate memory for initial texture
 *     cdef int glfmt = _color_fmt_to_gl(colorfmt)             # <<<<<<<<<<<<<<
 *     cdef int datasize = texture_width * texture_height * \
 *             _gl_format_size(glfmt) * _buffer_type_to_gl_size(bufferfmt)
 */
  __pyx_v_glfmt = __pyx_f_4kivy_8graphics_7texture__color_fmt_to_gl(__pyx_v_colorfmt);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":241
 *     cdef int glfmt = _color_fmt_to_gl(colorfmt)
 *     cdef int datasize = texture_width * texture_height * \
 *             _gl_format_size(glfmt) * _buffer_type_to_gl_size(bufferfmt)             # <<<<<<<<<<<<<<
 *     cdef void *data = NULL
 *     cdef int dataerr = 0
 */
  __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(__pyx_v_bufferfmt));

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":242
 *     cdef int datasize = texture_width * texture_height * \
 *             _gl_format_size(glfmt) * _buffer_type_to_gl_size(bufferfmt)
 *     cdef void *data = NULL             # <<<<<<<<<<<<<<
 *     cdef int dataerr = 0
 * 
 */
  __pyx_v_data = NULL;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":243
 *             _gl_format_size(glfmt) * _buffer_type_to_gl_size(bufferfmt)
 *     cdef void *data = NULL
 *     cdef int dataerr = 0             # <<<<<<<<<<<<<<
 * 
 *     with nogil:
 */
  __pyx_v_dataerr = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":245
 *     cdef int dataerr = 0
 * 
 *     with nogil:             # <<<<<<<<<<<<<<
 *         data = calloc(1, datasize)
 *         if data != NULL:
 */
  {
    #ifdef WITH_THREAD
    PyThreadState *_save;
    #endif
    Py_UNBLOCK_THREADS
    /*try:*/ {

      /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":246
 * 
 *     with nogil:
 *         data = calloc(1, datasize)             # <<<<<<<<<<<<<<
 *         if data != NULL:
 *             glTexImage2D(target, 0, glfmt, texture_width, texture_height, 0,
 */
      __pyx_v_data = calloc(1, __pyx_v_datasize);

      /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":247
 *     with nogil:
 *         data = calloc(1, datasize)
 *         if data != NULL:             # <<<<<<<<<<<<<<
 *             glTexImage2D(target, 0, glfmt, texture_width, texture_height, 0,
 *                          glfmt, glbufferfmt, data)
 */
      __pyx_t_3 = (__pyx_v_data != NULL);
      if (__pyx_t_3) {

        /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":249
 *         if data != NULL:
 *             glTexImage2D(target, 0, glfmt, texture_width, texture_height, 0,
 *                          glfmt, glbufferfmt, data)             # <<<<<<<<<<<<<<
 *             glFlush()
 *             free(data)
 */
        glTexImage2D(__pyx_v_target, 0, __pyx_v_glfmt, __pyx_v_texture_width, __pyx_v_texture_height, 0, __pyx_v_glfmt, __pyx_v_glbufferfmt, __pyx_v_data);

        /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":250
 *             glTexImage2D(target, 0, glfmt, texture_width, texture_height, 0,
 *                          glfmt, glbufferfmt, data)
 *             glFlush()             # <<<<<<<<<<<<<<
 *             free(data)
 *             data = NULL
 */
        glFlush();

        /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":251
 *                          glfmt, glbufferfmt, data)
 *             glFlush()
 *             free(data)             # <<<<<<<<<<<<<<
 *             data = NULL
 *             if mipmap:
 */
        free(__pyx_v_data);

        /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":252
 *             glFlush()
 *             free(data)
 *             data = NULL             # <<<<<<<<<<<<<<
 *             if mipmap:
 *                 glEnable(target)
 */
        __pyx_v_data = NULL;

        /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":253
 *             free(data)
 *             data = NULL
 *             if mipmap:             # <<<<<<<<<<<<<<
 *                 glEnable(target)
 *                 glGenerateMipmap(target)
 */
        if (__pyx_v_mipmap) {

          /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":254
 *             data = NULL
 *             if mipmap:
 *                 glEnable(target)             # <<<<<<<<<<<<<<
 *                 glGenerateMipmap(target)
 *                 glDisable(target)
 */
          glEnable(__pyx_v_target);

          /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":255
 *             if mipmap:
 *                 glEnable(target)
 *                 glGenerateMipmap(target)             # <<<<<<<<<<<<<<
 *                 glDisable(target)
 *         else:
 */
          glGenerateMipmap(__pyx_v_target);

          /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":256
 *                 glEnable(target)
 *                 glGenerateMipmap(target)
 *                 glDisable(target)             # <<<<<<<<<<<<<<
 *         else:
 *             dataerr = 1
 */
          glDisable(__pyx_v_target);
          goto __pyx_L13;
        }
        __pyx_L13:;
        goto __pyx_L12;
      }
      /*else*/ {

        /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":258
 *                 glDisable(target)
 *         else:
 *             dataerr = 1             # <<<<<<<<<<<<<<
 * 
 *     if dataerr:
 */
        __pyx_v_dataerr = 1;
      }
      __pyx_L12:;
    }

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":245
 *     cdef int dataerr = 0
 * 
 *     with nogil:             # <<<<<<<<<<<<<<
 *         data = calloc(1, datasize)
 *         if data != NULL:
 */
    /*finally:*/ {
      Py_BLOCK_THREADS
    }
  }

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":260
 *             dataerr = 1
 * 
 *     if dataerr:             # <<<<<<<<<<<<<<
 *         raise Exception('Unable to allocate memory for texture (size is %s)' %
 *                         datasize)
 */
  if (__pyx_v_dataerr) {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":262
 *     if dataerr:
 *         raise Exception('Unable to allocate memory for texture (size is %s)' %
 *                         datasize)             # <<<<<<<<<<<<<<
 * 
 *     if rectangle:
 */
    __pyx_t_6 = PyInt_FromLong(__pyx_v_datasize); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_13), __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_7));
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_6));
    PyTuple_SET_ITEM(__pyx_t_6, 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_6), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __Pyx_Raise(__pyx_t_7, 0, 0);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L14;
  }
  __pyx_L14:;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":264
 *                         datasize)
 * 
 *     if rectangle:             # <<<<<<<<<<<<<<
 *         texture.uvsize = (width, height)
 * 
 */
  if (__pyx_v_rectangle) {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":265
 * 
 *     if rectangle:
 *         texture.uvsize = (width, height)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_7 = PyInt_FromLong(__pyx_v_width); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = PyInt_FromLong(__pyx_v_height); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_8));
    PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_7);
    PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_7 = 0;
    __pyx_t_6 = 0;
    if (PyObject_SetAttr(((PyObject *)__pyx_v_texture), __pyx_n_s__uvsize, ((PyObject *)__pyx_t_8)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
    goto __pyx_L15;
  }
  __pyx_L15:;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":268
 * 
 * 
 *     if texture_width == width and texture_height == height:             # <<<<<<<<<<<<<<
 *         return texture
 * 
 */
  __pyx_t_3 = (__pyx_v_texture_width == __pyx_v_width);
  if (__pyx_t_3) {
    __pyx_t_1 = (__pyx_v_texture_height == __pyx_v_height);
    __pyx_t_2 = __pyx_t_1;
  } else {
    __pyx_t_2 = __pyx_t_3;
  }
  if (__pyx_t_2) {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":269
 * 
 *     if texture_width == width and texture_height == height:
 *         return texture             # <<<<<<<<<<<<<<
 * 
 *     return texture.get_region(0, 0, width, height)
 */
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(((PyObject *)__pyx_v_texture));
    __pyx_r = ((PyObject *)__pyx_v_texture);
    goto __pyx_L0;
    goto __pyx_L16;
  }
  __pyx_L16:;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":271
 *         return texture
 * 
 *     return texture.get_region(0, 0, width, height)             # <<<<<<<<<<<<<<
 * 
 * def texture_create(size=None, colorfmt=None, bufferfmt=None, rectangle=False, mipmap=False):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_8 = PyInt_FromLong(__pyx_v_width); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_6 = PyInt_FromLong(__pyx_v_height); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_texture->__pyx_vtab)->get_region(__pyx_v_texture, __pyx_int_0, __pyx_int_0, __pyx_t_8, __pyx_t_6, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __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_6); __pyx_t_6 = 0;
  __pyx_r = __pyx_t_7;
  __pyx_t_7 = 0;
  goto __pyx_L0;

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

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":273
 *     return texture.get_region(0, 0, width, height)
 * 
 * def texture_create(size=None, colorfmt=None, bufferfmt=None, rectangle=False, mipmap=False):             # <<<<<<<<<<<<<<
 *     '''Create a texture based on size.
 * 
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_1texture_create(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_1texture_create[] = "texture_create(size=None, colorfmt=None, bufferfmt=None, rectangle=False, 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        `rectangle`: bool, default to False\n            If True, it will use special opengl command for creating a rectangle\n            texture. It's not available on OpenGL ES, but can be used for\n            desktop. If we are on OpenGL ES platform, this parameter will be\n            ignored.\n        `mipmap`: bool, default to False\n            If True, it will automatically generate mipmap texture.\n    ";
static PyMethodDef __pyx_mdef_4kivy_8graphics_7texture_1texture_create = {__Pyx_NAMESTR("texture_create"), (PyCFunction)__pyx_pf_4kivy_8graphics_7texture_1texture_create, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_1texture_create)};
static PyObject *__pyx_pf_4kivy_8graphics_7texture_1texture_create(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_size = 0;
  PyObject *__pyx_v_colorfmt = 0;
  PyObject *__pyx_v_bufferfmt = 0;
  PyObject *__pyx_v_rectangle = 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__rectangle,&__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[5] = {0,0,0,0,0};
    values[0] = ((PyObject *)Py_None);
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);
    values[3] = __pyx_k_14;
    values[4] = __pyx_k_15;
    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:
      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__rectangle);
        if (value) { values[3] = value; kw_args--; }
      }
      case  4:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mipmap);
        if (value) { values[4] = 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 = 273; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_size = values[0];
    __pyx_v_colorfmt = values[1];
    __pyx_v_bufferfmt = values[2];
    __pyx_v_rectangle = values[3];
    __pyx_v_mipmap = values[4];
  } else {
    __pyx_v_size = ((PyObject *)Py_None);
    __pyx_v_colorfmt = ((PyObject *)Py_None);
    __pyx_v_bufferfmt = ((PyObject *)Py_None);
    __pyx_v_rectangle = __pyx_k_14;
    __pyx_v_mipmap = __pyx_k_15;
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  5: __pyx_v_mipmap = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: __pyx_v_rectangle = 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, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __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);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":294
 *     '''
 *     cdef int width, height
 *     if size is None:             # <<<<<<<<<<<<<<
 *         width = height = 128
 *     else:
 */
  __pyx_t_1 = (__pyx_v_size == Py_None);
  if (__pyx_t_1) {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":295
 *     cdef int width, height
 *     if size is None:
 *         width = height = 128             # <<<<<<<<<<<<<<
 *     else:
 *         width, height = size
 */
    __pyx_v_width = 128;
    __pyx_v_height = 128;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":297
 *         width = height = 128
 *     else:
 *         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 = 297; __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 = 297; __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 = 297; __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 = 297; __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 = 297; __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 = 297; __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 = 297; __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 = 297; __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;
    }
  }
  __pyx_L6:;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":298
 *     else:
 *         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) {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":299
 *         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:;

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

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":301
 *         colorfmt = 'rgba'
 *     if bufferfmt is None:
 *         bufferfmt = 'ubyte'             # <<<<<<<<<<<<<<
 *     return _texture_create(width, height, colorfmt, bufferfmt, rectangle, mipmap)
 * 
 */
    __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:;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":302
 *     if bufferfmt is None:
 *         bufferfmt = 'ubyte'
 *     return _texture_create(width, height, colorfmt, bufferfmt, rectangle, mipmap)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __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 = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (!(likely(PyString_CheckExact(__pyx_v_bufferfmt))||((__pyx_v_bufferfmt) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected str, got %.200s", Py_TYPE(__pyx_v_bufferfmt)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_v_rectangle); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_v_mipmap); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_3 = __pyx_f_4kivy_8graphics_7texture__texture_create(__pyx_v_width, __pyx_v_height, ((PyObject*)__pyx_v_colorfmt), ((PyObject*)__pyx_v_bufferfmt), __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __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_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;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":305
 * 
 * 
 * def texture_create_from_data(im, rectangle=True, mipmap=False):             # <<<<<<<<<<<<<<
 *     '''Create a texture from an ImageData class'''
 * 
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_2texture_create_from_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_2texture_create_from_data[] = "texture_create_from_data(im, rectangle=True, mipmap=False)\nCreate a texture from an ImageData class";
static PyMethodDef __pyx_mdef_4kivy_8graphics_7texture_2texture_create_from_data = {__Pyx_NAMESTR("texture_create_from_data"), (PyCFunction)__pyx_pf_4kivy_8graphics_7texture_2texture_create_from_data, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_2texture_create_from_data)};
static PyObject *__pyx_pf_4kivy_8graphics_7texture_2texture_create_from_data(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_im = 0;
  PyObject *__pyx_v_rectangle = 0;
  PyObject *__pyx_v_mipmap = 0;
  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;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__im,&__pyx_n_s__rectangle,&__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[3] = {0,0,0};
    values[1] = __pyx_k_16;
    values[2] = __pyx_k_17;
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      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__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__rectangle);
        if (value) { values[1] = value; kw_args--; }
      }
      case  2:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mipmap);
        if (value) { values[2] = 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 = 305; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_im = values[0];
    __pyx_v_rectangle = values[1];
    __pyx_v_mipmap = values[2];
  } else {
    __pyx_v_rectangle = __pyx_k_16;
    __pyx_v_mipmap = __pyx_k_17;
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: __pyx_v_mipmap = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: __pyx_v_rectangle = 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, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __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_v_texture = Py_None; __Pyx_INCREF(Py_None);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":308
 *     '''Create a texture from an ImageData class'''
 * 
 *     texture = _texture_create(im.width, im.height, im.fmt, 'ubyte',             # <<<<<<<<<<<<<<
 *                              rectangle, mipmap)
 *     if texture is None:
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_im, __pyx_n_s__width); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __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 = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_im, __pyx_n_s__height); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_im, __pyx_n_s__fmt); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __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 = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":309
 * 
 *     texture = _texture_create(im.width, im.height, im.fmt, 'ubyte',
 *                              rectangle, mipmap)             # <<<<<<<<<<<<<<
 *     if texture is None:
 *         return None
 */
  __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_v_rectangle); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_v_mipmap); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = __pyx_f_4kivy_8graphics_7texture__texture_create(__pyx_t_2, __pyx_t_3, ((PyObject*)__pyx_t_1), __pyx_n_s__ubyte, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_v_texture);
  __pyx_v_texture = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":310
 *     texture = _texture_create(im.width, im.height, im.fmt, 'ubyte',
 *                              rectangle, mipmap)
 *     if texture is None:             # <<<<<<<<<<<<<<
 *         return None
 * 
 */
  __pyx_t_7 = (__pyx_v_texture == Py_None);
  if (__pyx_t_7) {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":311
 *                              rectangle, mipmap)
 *     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_L6;
  }
  __pyx_L6:;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":313
 *         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 = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(__pyx_v_im);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_im);
  __Pyx_GIVEREF(__pyx_v_im);
  __pyx_t_8 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":315
 *     texture.blit_data(im)
 * 
 *     return texture             # <<<<<<<<<<<<<<
 * 
 * cdef class 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_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("kivy.graphics.texture.texture_create_from_data");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_texture);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":325
 * 
 * 
 *     def __init__(self, width, height, target, texid, colorfmt='rgb', mipmap=False, rectangle=False):             # <<<<<<<<<<<<<<
 *         self._width         = width
 *         self._height        = height
 */

static int __pyx_pf_4kivy_8graphics_7texture_7Texture_0__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4kivy_8graphics_7texture_7Texture_0__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;
  PyObject *__pyx_v_rectangle = 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,&__pyx_n_s__rectangle,0};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[7] = {0,0,0,0,0,0,0};
    values[4] = ((PyObject *)__pyx_n_s__rgb);
    values[5] = __pyx_k_18;
    values[6] = __pyx_k_19;
    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__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, 7, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __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, 7, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __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, 7, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __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--; }
      }
      case  6:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__rectangle);
        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), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __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];
    __pyx_v_rectangle = values[6];
  } else {
    __pyx_v_colorfmt = ((PyObject *)__pyx_n_s__rgb);
    __pyx_v_mipmap = __pyx_k_18;
    __pyx_v_rectangle = __pyx_k_19;
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  7:
      __pyx_v_rectangle = PyTuple_GET_ITEM(__pyx_args, 6);
      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, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __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:;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":326
 * 
 *     def __init__(self, width, height, target, texid, colorfmt='rgb', mipmap=False, rectangle=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 = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_width = __pyx_t_1;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":327
 *     def __init__(self, width, height, target, texid, colorfmt='rgb', mipmap=False, rectangle=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 = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_height = __pyx_t_1;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":328
 *         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 = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_target = __pyx_t_2;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":329
 *         self._height        = height
 *         self._target        = target
 *         self._id            = texid             # <<<<<<<<<<<<<<
 *         self._mipmap        = mipmap
 *         self._gl_wrap       = 0
 */
  __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 = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_id = __pyx_t_2;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":330
 *         self._target        = target
 *         self._id            = texid
 *         self._mipmap        = mipmap             # <<<<<<<<<<<<<<
 *         self._gl_wrap       = 0
 *         self._gl_min_filter = 0
 */
  __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 = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_mipmap = __pyx_t_1;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":331
 *         self._id            = texid
 *         self._mipmap        = mipmap
 *         self._gl_wrap       = 0             # <<<<<<<<<<<<<<
 *         self._gl_min_filter = 0
 *         self._gl_mag_filter = 0
 */
  ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_gl_wrap = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":332
 *         self._mipmap        = mipmap
 *         self._gl_wrap       = 0
 *         self._gl_min_filter = 0             # <<<<<<<<<<<<<<
 *         self._gl_mag_filter = 0
 *         self._uvx           = 0.
 */
  ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_gl_min_filter = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":333
 *         self._gl_wrap       = 0
 *         self._gl_min_filter = 0
 *         self._gl_mag_filter = 0             # <<<<<<<<<<<<<<
 *         self._uvx           = 0.
 *         self._uvy           = 0.
 */
  ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_gl_mag_filter = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":334
 *         self._gl_min_filter = 0
 *         self._gl_mag_filter = 0
 *         self._uvx           = 0.             # <<<<<<<<<<<<<<
 *         self._uvy           = 0.
 *         self._uvw           = 1.
 */
  ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_uvx = 0.;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":335
 *         self._gl_mag_filter = 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.;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":336
 *         self._uvx           = 0.
 *         self._uvy           = 0.
 *         self._uvw           = 1.             # <<<<<<<<<<<<<<
 *         self._uvh           = 1.
 *         self._rectangle     = rectangle
 */
  ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_uvw = 1.;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":337
 *         self._uvy           = 0.
 *         self._uvw           = 1.
 *         self._uvh           = 1.             # <<<<<<<<<<<<<<
 *         self._rectangle     = rectangle
 *         self._colorfmt      = colorfmt
 */
  ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_uvh = 1.;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":338
 *         self._uvw           = 1.
 *         self._uvh           = 1.
 *         self._rectangle     = rectangle             # <<<<<<<<<<<<<<
 *         self._colorfmt      = colorfmt
 *         self.update_tex_coords()
 */
  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_rectangle); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_rectangle = __pyx_t_1;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":339
 *         self._uvh           = 1.
 *         self._rectangle     = rectangle
 *         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 = 339; __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);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":340
 *         self._rectangle     = rectangle
 *         self._colorfmt      = colorfmt
 *         self.update_tex_coords()             # <<<<<<<<<<<<<<
 * 
 *     def __del__(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 = 340; __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;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":342
 *         self.update_tex_coords()
 * 
 *     def __del__(self):             # <<<<<<<<<<<<<<
 *         self.release()
 * 
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_1__del__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_7Texture_1__del__[] = "Texture.__del__(self)";
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_1__del__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__del__");

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":343
 * 
 *     def __del__(self):
 *         self.release()             # <<<<<<<<<<<<<<
 * 
 *     cdef release(self):
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->__pyx_vtab)->release(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)); 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_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_AddTraceback("kivy.graphics.texture.Texture.__del__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":345
 *         self.release()
 * 
 *     cdef release(self):             # <<<<<<<<<<<<<<
 *         # Add texture deletion outside GC call.
 *         # This case happen if some texture have been not deleted
 */

static  PyObject *__pyx_f_4kivy_8graphics_7texture_7Texture_release(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("release");

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":349
 *         # 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)
 * 
 */
  __pyx_t_1 = (__pyx_v_4kivy_8graphics_7texture__texture_release_list != ((PyObject*)Py_None));
  if (__pyx_t_1) {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":350
 *         # before application exit...
 *         if _texture_release_list is not None:
 *             _texture_release_list.append(self._id)             # <<<<<<<<<<<<<<
 * 
 *     property mipmap:
 */
    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 = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
    }
    __pyx_t_2 = __Pyx_PyInt_to_py_GLuint(__pyx_v_self->_id); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 350; __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 = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L3;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.release");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":354
 *     property mipmap:
 *         '''Return True if the texture have mipmap enabled (readonly)'''
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._mipmap
 * 
 */

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

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":355
 *         '''Return True if the texture have mipmap enabled (readonly)'''
 *         def __get__(self):
 *             return self._mipmap             # <<<<<<<<<<<<<<
 * 
 *     property rectangle:
 */
  __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 = 355; __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;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":359
 *     property rectangle:
 *         '''Return True if the texture is a rectangle texture (readonly)'''
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._rectangle
 * 
 */

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

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":360
 *         '''Return True if the texture is a rectangle texture (readonly)'''
 *         def __get__(self):
 *             return self._rectangle             # <<<<<<<<<<<<<<
 * 
 *     property id:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_rectangle); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __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.rectangle.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":364
 *     property id:
 *         '''Return the OpenGL ID of the texture (readonly)'''
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._id
 * 
 */

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

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":365
 *         '''Return the OpenGL ID of the texture (readonly)'''
 *         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 = 365; __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;
}

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

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

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":370
 *         '''Return the OpenGL target of the texture (readonly)'''
 *         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 = 370; __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;
}

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

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

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":375
 *         '''Return the width of the texture (readonly)'''
 *         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 = 375; __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;
}

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

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

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":380
 *         '''Return the height of the texture (readonly)'''
 *         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 = 380; __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;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":384
 *     property tex_coords:
 *         '''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_0__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_10tex_coords_0__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__");

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":385
 *         '''Return the list of tex_coords (opengl)'''
 *         def __get__(self):
 *             return (             # <<<<<<<<<<<<<<
 *                 self._tex_coords[0],
 *                 self._tex_coords[1],
 */
  __Pyx_XDECREF(__pyx_r);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":386
 *         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 = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":387
 *             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 = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":388
 *                 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 = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":389
 *                 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 = 389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":390
 *                 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 = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":391
 *                 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 = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":392
 *                 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 = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_7);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":393
 *                 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 = 393; __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 = 386; __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;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":399
 *         '''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_0__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_5uvpos_0__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__");

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":400
 *         '''
 *         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 = 400; __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 = 400; __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 = 400; __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;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":401
 *         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__");

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":402
 *             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 = 402; __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 = 402; __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 = 402; __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 = 402; __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 = 402; __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 = 402; __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 = 402; __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 = 402; __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;
  }

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":403
 *         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 = 403; __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;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":411
 *             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_0__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6uvsize_0__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__");

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":412
 *         '''
 *         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 = 412; __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 = 412; __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 = 412; __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;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":413
 *         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__");

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":414
 *             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 = 414; __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 = 414; __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 = 414; __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 = 414; __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 = 414; __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 = 414; __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 = 414; __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 = 414; __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;
  }

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":415
 *         def __set__(self, x):
 *             self._uvw, self._uvh = x
 *             self.update_tex_coords()             # <<<<<<<<<<<<<<
 * 
 *     cdef update_tex_coords(self):
 */
  __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 = 415; __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;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":417
 *             self.update_tex_coords()
 * 
 *     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");

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":418
 * 
 *     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;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":419
 *     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;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":420
 *         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);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":421
 *         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;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":422
 *         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);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":423
 *         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);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":424
 *         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;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":425
 *         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;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":427
 *         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 = 427; __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 = 427; __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;
  }

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":429
 *     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);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":430
 *         '''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);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":431
 *         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 = 431; __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;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":427
 *         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 = 427; __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;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":433
 *         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 = 433; __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 = 433; __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 = 433; __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;
  }

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":436
 *         '''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 = 436; __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 = 436; __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;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":433
 *         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;
  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 = 433; __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 = 433; __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 = 433; __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 = 433; __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 = 433; __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 = ((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_v_x, __pyx_v_y, __pyx_v_width, __pyx_v_height, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":438
 *         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 = 438; __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 = 438; __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;
  }

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":440
 *     cpdef bind(self):
 *         '''Bind the texture to current opengl state'''
 *         glBindTexture(self._target, self._id)             # <<<<<<<<<<<<<<
 * 
 *     cpdef enable(self):
 */
  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;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":438
 *         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 = 438; __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;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":442
 *         glBindTexture(self._target, self._id)
 * 
 *     cpdef enable(self):             # <<<<<<<<<<<<<<
 *         '''Do the appropriate glEnable()'''
 *         glEnable(self._target)
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_5enable(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static  PyObject *__pyx_f_4kivy_8graphics_7texture_7Texture_enable(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("enable");
  /* 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__enable); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __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_5enable)) {
      __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 = 442; __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;
  }

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":444
 *     cpdef enable(self):
 *         '''Do the appropriate glEnable()'''
 *         glEnable(self._target)             # <<<<<<<<<<<<<<
 * 
 *     cpdef disable(self):
 */
  glEnable(__pyx_v_self->_target);

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

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":442
 *         glBindTexture(self._target, self._id)
 * 
 *     cpdef enable(self):             # <<<<<<<<<<<<<<
 *         '''Do the appropriate glEnable()'''
 *         glEnable(self._target)
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_5enable(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_7Texture_5enable[] = "Texture.enable(self)\nDo the appropriate glEnable()";
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_5enable(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("enable");
  __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)->enable(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __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.enable");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":446
 *         glEnable(self._target)
 * 
 *     cpdef disable(self):             # <<<<<<<<<<<<<<
 *         '''Do the appropriate glDisable()'''
 *         glDisable(self._target)
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6disable(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static  PyObject *__pyx_f_4kivy_8graphics_7texture_7Texture_disable(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("disable");
  /* 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__disable); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __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_6disable)) {
      __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 = 446; __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;
  }

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":448
 *     cpdef disable(self):
 *         '''Do the appropriate glDisable()'''
 *         glDisable(self._target)             # <<<<<<<<<<<<<<
 * 
 *     property min_filter:
 */
  glDisable(__pyx_v_self->_target);

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

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":446
 *         glEnable(self._target)
 * 
 *     cpdef disable(self):             # <<<<<<<<<<<<<<
 *         '''Do the appropriate glDisable()'''
 *         glDisable(self._target)
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6disable(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_7Texture_6disable[] = "Texture.disable(self)\nDo the appropriate glDisable()";
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6disable(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("disable");
  __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)->disable(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __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.disable");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":453
 *         '''Get/set the GL_TEXTURE_MIN_FILTER property
 *         '''
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._gl_min_filter
 *         def __set__(self, x):
 */

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

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":454
 *         '''
 *         def __get__(self):
 *             return self._gl_min_filter             # <<<<<<<<<<<<<<
 *         def __set__(self, x):
 *             if x == self._gl_min_filter:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_GLuint(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_gl_min_filter); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __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.min_filter.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":455
 *         def __get__(self):
 *             return self._gl_min_filter
 *         def __set__(self, x):             # <<<<<<<<<<<<<<
 *             if x == self._gl_min_filter:
 *                 return
 */

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;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  GLenum __pyx_t_4;
  GLint __pyx_t_5;
  GLuint __pyx_t_6;
  __Pyx_RefNannySetupContext("__set__");

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

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":457
 *         def __set__(self, x):
 *             if x == self._gl_min_filter:
 *                 return             # <<<<<<<<<<<<<<
 *             self.bind()
 *             glTexParameteri(self.target, GL_TEXTURE_MIN_FILTER, x)
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":458
 *             if x == self._gl_min_filter:
 *                 return
 *             self.bind()             # <<<<<<<<<<<<<<
 *             glTexParameteri(self.target, GL_TEXTURE_MIN_FILTER, x)
 *             self._gl_min_filter = x
 */
  __pyx_t_2 = ((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_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":459
 *                 return
 *             self.bind()
 *             glTexParameteri(self.target, GL_TEXTURE_MIN_FILTER, x)             # <<<<<<<<<<<<<<
 *             self._gl_min_filter = x
 * 
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__target); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyInt_from_py_GLenum(__pyx_t_2); if (unlikely((__pyx_t_4 == (GLenum)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = __Pyx_PyInt_from_py_GLint(__pyx_v_x); if (unlikely((__pyx_t_5 == (GLint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  glTexParameteri(__pyx_t_4, GL_TEXTURE_MIN_FILTER, __pyx_t_5);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":460
 *             self.bind()
 *             glTexParameteri(self.target, GL_TEXTURE_MIN_FILTER, x)
 *             self._gl_min_filter = x             # <<<<<<<<<<<<<<
 * 
 *     property mag_filter:
 */
  __pyx_t_6 = __Pyx_PyInt_from_py_GLuint(__pyx_v_x); if (unlikely((__pyx_t_6 == (GLuint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_gl_min_filter = __pyx_t_6;

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

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":465
 *         '''Get/set the GL_TEXTURE_MAG_FILTER property
 *         '''
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._gl_mag_filter
 *         def __set__(self, x):
 */

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

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":466
 *         '''
 *         def __get__(self):
 *             return self._gl_mag_filter             # <<<<<<<<<<<<<<
 *         def __set__(self, x):
 *             if x == self._gl_mag_filter:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_GLuint(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_gl_mag_filter); 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_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.mag_filter.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":467
 *         def __get__(self):
 *             return self._gl_mag_filter
 *         def __set__(self, x):             # <<<<<<<<<<<<<<
 *             if x == self._gl_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;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  GLenum __pyx_t_4;
  GLint __pyx_t_5;
  GLuint __pyx_t_6;
  __Pyx_RefNannySetupContext("__set__");

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

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":469
 *         def __set__(self, x):
 *             if x == self._gl_mag_filter:
 *                 return             # <<<<<<<<<<<<<<
 *             self.bind()
 *             glTexParameteri(self.target, GL_TEXTURE_MAG_FILTER, x)
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":470
 *             if x == self._gl_mag_filter:
 *                 return
 *             self.bind()             # <<<<<<<<<<<<<<
 *             glTexParameteri(self.target, GL_TEXTURE_MAG_FILTER, x)
 *             self._gl_mag_filter = x
 */
  __pyx_t_2 = ((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_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":471
 *                 return
 *             self.bind()
 *             glTexParameteri(self.target, GL_TEXTURE_MAG_FILTER, x)             # <<<<<<<<<<<<<<
 *             self._gl_mag_filter = x
 * 
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__target); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyInt_from_py_GLenum(__pyx_t_2); if (unlikely((__pyx_t_4 == (GLenum)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = __Pyx_PyInt_from_py_GLint(__pyx_v_x); if (unlikely((__pyx_t_5 == (GLint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  glTexParameteri(__pyx_t_4, GL_TEXTURE_MAG_FILTER, __pyx_t_5);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":472
 *             self.bind()
 *             glTexParameteri(self.target, GL_TEXTURE_MAG_FILTER, x)
 *             self._gl_mag_filter = x             # <<<<<<<<<<<<<<
 * 
 *     property wrap:
 */
  __pyx_t_6 = __Pyx_PyInt_from_py_GLuint(__pyx_v_x); if (unlikely((__pyx_t_6 == (GLuint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_gl_mag_filter = __pyx_t_6;

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

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":477
 *         '''Get/set the GL_TEXTURE_WRAP_S,T property
 *         '''
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self._gl_wrap
 *         def __set__(self, wrap):
 */

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

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":478
 *         '''
 *         def __get__(self):
 *             return self._gl_wrap             # <<<<<<<<<<<<<<
 *         def __set__(self, wrap):
 *             if wrap == self._gl_wrap:
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_GLuint(((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_gl_wrap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __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.wrap.__get__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":479
 *         def __get__(self):
 *             return self._gl_wrap
 *         def __set__(self, wrap):             # <<<<<<<<<<<<<<
 *             if wrap == self._gl_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;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  GLenum __pyx_t_4;
  GLint __pyx_t_5;
  __Pyx_RefNannySetupContext("__set__");

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

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":481
 *         def __set__(self, wrap):
 *             if wrap == self._gl_wrap:
 *                 return             # <<<<<<<<<<<<<<
 *             self.bind()
 *             glTexParameteri(self.target, GL_TEXTURE_WRAP_S, wrap)
 */
    __pyx_r = 0;
    goto __pyx_L0;
    goto __pyx_L5;
  }
  __pyx_L5:;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":482
 *             if wrap == self._gl_wrap:
 *                 return
 *             self.bind()             # <<<<<<<<<<<<<<
 *             glTexParameteri(self.target, GL_TEXTURE_WRAP_S, wrap)
 *             glTexParameteri(self.target, GL_TEXTURE_WRAP_T, wrap)
 */
  __pyx_t_2 = ((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_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":483
 *                 return
 *             self.bind()
 *             glTexParameteri(self.target, GL_TEXTURE_WRAP_S, wrap)             # <<<<<<<<<<<<<<
 *             glTexParameteri(self.target, GL_TEXTURE_WRAP_T, wrap)
 * 
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__target); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyInt_from_py_GLenum(__pyx_t_2); if (unlikely((__pyx_t_4 == (GLenum)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = __Pyx_PyInt_from_py_GLint(__pyx_v_wrap); if (unlikely((__pyx_t_5 == (GLint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  glTexParameteri(__pyx_t_4, GL_TEXTURE_WRAP_S, __pyx_t_5);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":484
 *             self.bind()
 *             glTexParameteri(self.target, GL_TEXTURE_WRAP_S, wrap)
 *             glTexParameteri(self.target, GL_TEXTURE_WRAP_T, wrap)             # <<<<<<<<<<<<<<
 * 
 *     def blit_data(self, im, pos=None):
 */
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__target); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyInt_from_py_GLenum(__pyx_t_2); if (unlikely((__pyx_t_4 == (GLenum)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = __Pyx_PyInt_from_py_GLint(__pyx_v_wrap); if (unlikely((__pyx_t_5 == (GLint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  glTexParameteri(__pyx_t_4, GL_TEXTURE_WRAP_T, __pyx_t_5);

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

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":486
 *             glTexParameteri(self.target, GL_TEXTURE_WRAP_T, wrap)
 * 
 *     def blit_data(self, im, pos=None):             # <<<<<<<<<<<<<<
 *         '''Replace a whole texture with a image data'''
 *         self.blit_buffer(im.data, size=(im.width, im.height),
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_7blit_data(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_7Texture_7blit_data[] = "Texture.blit_data(self, im, pos=None)\nReplace a whole texture with a image data";
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_7blit_data(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_im = 0;
  PyObject *__pyx_v_pos = 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;
  PyObject *__pyx_t_6 = 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 = 486; __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 = 486; __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:;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":488
 *     def blit_data(self, im, pos=None):
 *         '''Replace a whole texture with a image data'''
 *         self.blit_buffer(im.data, size=(im.width, im.height),             # <<<<<<<<<<<<<<
 *                          colorfmt=im.fmt, pos=pos)
 * 
 */
  __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 = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_GetAttr(__pyx_v_im, __pyx_n_s__data); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __pyx_t_4 = PyObject_GetAttr(__pyx_v_im, __pyx_n_s__width); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyObject_GetAttr(__pyx_v_im, __pyx_n_s__height); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_6));
  PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__size), ((PyObject *)__pyx_t_6)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":489
 *         '''Replace a whole texture with a image data'''
 *         self.blit_buffer(im.data, size=(im.width, im.height),
 *                          colorfmt=im.fmt, pos=pos)             # <<<<<<<<<<<<<<
 * 
 *     def blit_buffer(self, pbuffer, size=None, colorfmt=None,
 */
  __pyx_t_6 = PyObject_GetAttr(__pyx_v_im, __pyx_n_s__fmt); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__colorfmt), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__pos), __pyx_v_pos) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_6 = PyEval_CallObjectWithKeywords(__pyx_t_1, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __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_t_3)); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

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

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":491
 *                          colorfmt=im.fmt, pos=pos)
 * 
 *     def blit_buffer(self, pbuffer, size=None, colorfmt=None,             # <<<<<<<<<<<<<<
 *                     pos=None, bufferfmt=None):
 *         '''Blit a buffer into a texture.
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_8blit_buffer(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_7Texture_8blit_buffer[] = "Texture.blit_buffer(self, pbuffer, size=None, colorfmt=None, pos=None, bufferfmt=None)\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        ";
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_8blit_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;
  GLuint __pyx_v_target;
  int __pyx_v_tid;
  PyObject *__pyx_v_data;
  PyObject *__pyx_v_pdata;
  int __pyx_v_glfmt;
  int __pyx_v_x;
  int __pyx_v_y;
  int __pyx_v_w;
  int __pyx_v_h;
  char *__pyx_v_cdata;
  int __pyx_v_glbufferfmt;
  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;
  int __pyx_t_7;
  char *__pyx_t_8;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__pbuffer,&__pyx_n_s__size,&__pyx_n_s__colorfmt,&__pyx_n_s__pos,&__pyx_n_s__bufferfmt,0};
  __Pyx_RefNannySetupContext("blit_buffer");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[5] = {0,0,0,0,0};
    values[1] = ((PyObject *)Py_None);
    values[2] = ((PyObject *)Py_None);

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":492
 * 
 *     def blit_buffer(self, pbuffer, size=None, colorfmt=None,
 *                     pos=None, bufferfmt=None):             # <<<<<<<<<<<<<<
 *         '''Blit a buffer into a texture.
 * 
 */
    values[3] = ((PyObject *)Py_None);
    values[4] = ((PyObject *)Py_None);
    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__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--; }
      }
    }
    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 = 491; __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];
  } else {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":491
 *                          colorfmt=im.fmt, pos=pos)
 * 
 *     def blit_buffer(self, pbuffer, size=None, colorfmt=None,             # <<<<<<<<<<<<<<
 *                     pos=None, bufferfmt=None):
 *         '''Blit a buffer into a texture.
 */
    __pyx_v_size = ((PyObject *)Py_None);
    __pyx_v_colorfmt = ((PyObject *)Py_None);

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":492
 * 
 *     def blit_buffer(self, pbuffer, size=None, colorfmt=None,
 *                     pos=None, bufferfmt=None):             # <<<<<<<<<<<<<<
 *         '''Blit a buffer into a texture.
 * 
 */
    __pyx_v_pos = ((PyObject *)Py_None);
    __pyx_v_bufferfmt = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      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, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __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);
  __pyx_v_pdata = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":509
 *                 'uint', 'byte', 'short', 'int', 'float'
 *         '''
 *         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 = 509; __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 = 509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_target = __pyx_t_2;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":510
 *         '''
 *         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;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":511
 *         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) {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":512
 *         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:;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":513
 *         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) {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":514
 *             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:;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":515
 *         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) {

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

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":517
 *         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) {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":518
 *             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 = 518; __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:;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":519
 *         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 = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = PyInt_FromLong(__pyx_f_4kivy_8graphics_7texture__buffer_fmt_to_gl(((PyObject*)__pyx_v_bufferfmt))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_v_bufferfmt);
  __pyx_v_bufferfmt = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":523
 *         # need conversion ?
 *         cdef bytes data, pdata
 *         data = pbuffer             # <<<<<<<<<<<<<<
 *         pdata, 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 = 523; __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);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":524
 *         cdef bytes data, pdata
 *         data = pbuffer
 *         pdata, 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 = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_1 = __pyx_f_4kivy_8graphics_7texture__convert_buffer(__pyx_v_data, ((PyObject*)__pyx_v_colorfmt)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  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 = 524; __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_pdata));
    __pyx_v_pdata = ((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 = 524; __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 = 524; __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 = 524; __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 = 524; __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 = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_v_pdata));
    __pyx_v_pdata = ((PyObject*)__pyx_t_4);
    __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_v_colorfmt);
    __pyx_v_colorfmt = __pyx_t_5;
    __pyx_t_5 = 0;
  }

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":527
 * 
 *         # prepare nogil
 *         cdef int glfmt = _color_fmt_to_gl(colorfmt)             # <<<<<<<<<<<<<<
 *         cdef int x = pos[0]
 *         cdef int y = pos[1]
 */
  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 = 527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_glfmt = __pyx_f_4kivy_8graphics_7texture__color_fmt_to_gl(((PyObject*)__pyx_v_colorfmt));

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":528
 *         # prepare nogil
 *         cdef int glfmt = _color_fmt_to_gl(colorfmt)
 *         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 = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_x = __pyx_t_7;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":529
 *         cdef int glfmt = _color_fmt_to_gl(colorfmt)
 *         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 = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_y = __pyx_t_7;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":530
 *         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 = 530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_w = __pyx_t_7;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":531
 *         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 = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_h = __pyx_t_7;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":532
 *         cdef int w = size[0]
 *         cdef int h = size[1]
 *         cdef char *cdata = <char *>data             # <<<<<<<<<<<<<<
 *         cdef int glbufferfmt = bufferfmt
 * 
 */
  __pyx_t_8 = PyBytes_AsString(((PyObject *)__pyx_v_data)); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_cdata = __pyx_t_8;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":533
 *         cdef int h = size[1]
 *         cdef char *cdata = <char *>data
 *         cdef int glbufferfmt = bufferfmt             # <<<<<<<<<<<<<<
 * 
 *         with nogil:
 */
  __pyx_t_7 = __Pyx_PyInt_AsInt(__pyx_v_bufferfmt); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_v_glbufferfmt = __pyx_t_7;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":535
 *         cdef int glbufferfmt = bufferfmt
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             glBindTexture(target, self._id)
 *             glEnable(target)
 */
  {
    #ifdef WITH_THREAD
    PyThreadState *_save;
    #endif
    Py_UNBLOCK_THREADS
    /*try:*/ {

      /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":536
 * 
 *         with nogil:
 *             glBindTexture(target, self._id)             # <<<<<<<<<<<<<<
 *             glEnable(target)
 *             glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
 */
      glBindTexture(__pyx_v_target, ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_v_self)->_id);

      /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":537
 *         with nogil:
 *             glBindTexture(target, self._id)
 *             glEnable(target)             # <<<<<<<<<<<<<<
 *             glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
 *             glTexSubImage2D(target, 0, x, y, w, h, glfmt, glbufferfmt, cdata)
 */
      glEnable(__pyx_v_target);

      /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":538
 *             glBindTexture(target, self._id)
 *             glEnable(target)
 *             glPixelStorei(GL_UNPACK_ALIGNMENT, 1)             # <<<<<<<<<<<<<<
 *             glTexSubImage2D(target, 0, x, y, w, h, glfmt, glbufferfmt, cdata)
 *             glFlush()
 */
      glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

      /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":539
 *             glEnable(target)
 *             glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
 *             glTexSubImage2D(target, 0, x, y, w, h, glfmt, glbufferfmt, cdata)             # <<<<<<<<<<<<<<
 *             glFlush()
 *             glDisable(target)
 */
      glTexSubImage2D(__pyx_v_target, 0, __pyx_v_x, __pyx_v_y, __pyx_v_w, __pyx_v_h, __pyx_v_glfmt, __pyx_v_glbufferfmt, __pyx_v_cdata);

      /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":540
 *             glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
 *             glTexSubImage2D(target, 0, x, y, w, h, glfmt, glbufferfmt, cdata)
 *             glFlush()             # <<<<<<<<<<<<<<
 *             glDisable(target)
 * 
 */
      glFlush();

      /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":541
 *             glTexSubImage2D(target, 0, x, y, w, h, glfmt, glbufferfmt, cdata)
 *             glFlush()
 *             glDisable(target)             # <<<<<<<<<<<<<<
 * 
 *     property size:
 */
      glDisable(__pyx_v_target);
    }

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":535
 *         cdef int glbufferfmt = bufferfmt
 * 
 *         with nogil:             # <<<<<<<<<<<<<<
 *             glBindTexture(target, self._id)
 *             glEnable(target)
 */
    /*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_pdata);
  __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;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":544
 * 
 *     property size:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return (self.width, self.height)
 * 
 */

static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_4size_0__get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_4size_0__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__");

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":545
 *     property size:
 *         def __get__(self):
 *             return (self.width, self.height)             # <<<<<<<<<<<<<<
 * 
 *     def __str__(self):
 */
  __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 = 545; __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 = 545; __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 = 545; __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;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":547
 *             return (self.width, self.height)
 * 
 *     def __str__(self):             # <<<<<<<<<<<<<<
 *         return '<Texture size=(%d, %d)>' % self.size
 * 
 */

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

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":548
 * 
 *     def __str__(self):
 *         return '<Texture size=(%d, %d)>' % self.size             # <<<<<<<<<<<<<<
 * 
 * cdef class TextureRegion(Texture):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_21), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = ((PyObject *)__pyx_t_2);
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("kivy.graphics.texture.Texture.__str__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":558
 *     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.x = x
 */

static int __pyx_pf_4kivy_8graphics_7texture_13TextureRegion_0__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_4kivy_8graphics_7texture_13TextureRegion_0__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;
  float __pyx_t_7;
  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 = 558; __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 = 558; __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 = 558; __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 = 558; __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 = 558; __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 = 558; __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 = 558; __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 = 558; __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 = 558; __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 = 558; __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 = 558; __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 = 558; __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 = 558; __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 = 558; __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 = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":559
 * 
 *     def __init__(self, int x, int y, int width, int height, Texture origin):
 *         Texture.__init__(self, width, height, origin.target, origin.id)             # <<<<<<<<<<<<<<
 *         self.x = x
 *         self.y = y
 */
  __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 = 559; __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 = 559; __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 = 559; __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 = 559; __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 = 559; __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 = 559; __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 = 559; __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;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":560
 *     def __init__(self, int x, int y, int width, int height, Texture origin):
 *         Texture.__init__(self, width, height, origin.target, origin.id)
 *         self.x = x             # <<<<<<<<<<<<<<
 *         self.y = y
 *         self.owner = origin
 */
  ((struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)__pyx_v_self)->x = __pyx_v_x;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":561
 *         Texture.__init__(self, width, height, origin.target, origin.id)
 *         self.x = x
 *         self.y = y             # <<<<<<<<<<<<<<
 *         self.owner = origin
 * 
 */
  ((struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)__pyx_v_self)->y = __pyx_v_y;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":562
 *         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;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":566
 *         # 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;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":567
 *         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;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":568
 *         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);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":569
 *         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);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":570
 *         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
 */
  __pyx_t_7 = ((float)__pyx_v_origin->_width);
  if (unlikely(__pyx_t_7 == 0)) {
    PyErr_Format(PyExc_ZeroDivisionError, "float division");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  ((struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)__pyx_v_self)->__pyx_base._uvx = (((__pyx_v_x / __pyx_t_7) * __pyx_v_origin->_uvw) + __pyx_v_origin_u1);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":571
 *         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
 */
  __pyx_t_7 = ((float)__pyx_v_origin->_height);
  if (unlikely(__pyx_t_7 == 0)) {
    PyErr_Format(PyExc_ZeroDivisionError, "float division");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  ((struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)__pyx_v_self)->__pyx_base._uvy = (((__pyx_v_y / __pyx_t_7) * __pyx_v_origin->_uvh) + __pyx_v_origin_v1);

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":572
 *         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()
 */
  __pyx_t_7 = ((float)__pyx_v_origin->_width);
  if (unlikely(__pyx_t_7 == 0)) {
    PyErr_Format(PyExc_ZeroDivisionError, "float division");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  ((struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)__pyx_v_self)->__pyx_base._uvw = ((__pyx_v_width / __pyx_t_7) * __pyx_v_origin->_uvw);

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

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":574
 *         self._uvw = (width / <float>origin._width) * origin._uvw
 *         self._uvh = (height / <float>origin._height) * origin._uvh
 *         self.update_tex_coords()             # <<<<<<<<<<<<<<
 * 
 * # Releasing texture through GC is problematic
 */
  __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 = 574; __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;
}

/* "/home/tito/code/kivy/kivy/graphics/texture.pyx":580
 * # 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_3_texture_release(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_4kivy_8graphics_7texture_3_texture_release[] = "_texture_release(*largs)";
static PyMethodDef __pyx_mdef_4kivy_8graphics_7texture_3_texture_release = {__Pyx_NAMESTR("_texture_release"), (PyCFunction)__pyx_pf_4kivy_8graphics_7texture_3_texture_release, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_3_texture_release)};
static PyObject *__pyx_pf_4kivy_8graphics_7texture_3_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;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":582
 * 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) {

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":583
 *     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:;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":584
 *     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 = 584; __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 = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (unlikely(__pyx_v_4kivy_8graphics_7texture__texture_release_list == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
  }
  __pyx_t_5 = PyList_GET_SIZE(((PyObject *)__pyx_v_4kivy_8graphics_7texture__texture_release_list)); 
  __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_22), __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __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 = 584; __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 = 584; __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;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":585
 *         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 = 585; __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 = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_v_texture_id = __pyx_t_7;

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":586
 *     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;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":587
 *     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 = 587; __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->_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;
  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->_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->_colorfmt);
  p->_colorfmt = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

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

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_rectangle(PyObject *o, void *x) {
  return __pyx_pf_4kivy_8graphics_7texture_7Texture_9rectangle_0__get__(o);
}

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

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

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

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_height(PyObject *o, void *x) {
  return __pyx_pf_4kivy_8graphics_7texture_7Texture_6height_0__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_0__get__(o);
}

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_uvpos(PyObject *o, void *x) {
  return __pyx_pf_4kivy_8graphics_7texture_7Texture_5uvpos_0__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_0__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_min_filter(PyObject *o, void *x) {
  return __pyx_pf_4kivy_8graphics_7texture_7Texture_10min_filter_0__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_0__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_0__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 PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_size(PyObject *o, void *x) {
  return __pyx_pf_4kivy_8graphics_7texture_7Texture_4size_0__get__(o);
}

static PyMethodDef __pyx_methods_4kivy_8graphics_7texture_Texture[] = {
  {__Pyx_NAMESTR("__del__"), (PyCFunction)__pyx_pf_4kivy_8graphics_7texture_7Texture_1__del__, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_1__del__)},
  {__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("enable"), (PyCFunction)__pyx_pf_4kivy_8graphics_7texture_7Texture_5enable, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_5enable)},
  {__Pyx_NAMESTR("disable"), (PyCFunction)__pyx_pf_4kivy_8graphics_7texture_7Texture_6disable, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_6disable)},
  {__Pyx_NAMESTR("blit_data"), (PyCFunction)__pyx_pf_4kivy_8graphics_7texture_7Texture_7blit_data, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_7blit_data)},
  {__Pyx_NAMESTR("blit_buffer"), (PyCFunction)__pyx_pf_4kivy_8graphics_7texture_7Texture_8blit_buffer, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_8blit_buffer)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4kivy_8graphics_7texture_Texture[] = {
  {(char *)"mipmap", __pyx_getprop_4kivy_8graphics_7texture_7Texture_mipmap, 0, __Pyx_DOCSTR(__pyx_k_23), 0},
  {(char *)"rectangle", __pyx_getprop_4kivy_8graphics_7texture_7Texture_rectangle, 0, __Pyx_DOCSTR(__pyx_k_24), 0},
  {(char *)"id", __pyx_getprop_4kivy_8graphics_7texture_7Texture_id, 0, __Pyx_DOCSTR(__pyx_k_25), 0},
  {(char *)"target", __pyx_getprop_4kivy_8graphics_7texture_7Texture_target, 0, __Pyx_DOCSTR(__pyx_k_26), 0},
  {(char *)"width", __pyx_getprop_4kivy_8graphics_7texture_7Texture_width, 0, __Pyx_DOCSTR(__pyx_k_27), 0},
  {(char *)"height", __pyx_getprop_4kivy_8graphics_7texture_7Texture_height, 0, __Pyx_DOCSTR(__pyx_k_28), 0},
  {(char *)"tex_coords", __pyx_getprop_4kivy_8graphics_7texture_7Texture_tex_coords, 0, __Pyx_DOCSTR(__pyx_k_29), 0},
  {(char *)"uvpos", __pyx_getprop_4kivy_8graphics_7texture_7Texture_uvpos, __pyx_setprop_4kivy_8graphics_7texture_7Texture_uvpos, __Pyx_DOCSTR(__pyx_k_30), 0},
  {(char *)"uvsize", __pyx_getprop_4kivy_8graphics_7texture_7Texture_uvsize, __pyx_setprop_4kivy_8graphics_7texture_7Texture_uvsize, __Pyx_DOCSTR(__pyx_k_31), 0},
  {(char *)"min_filter", __pyx_getprop_4kivy_8graphics_7texture_7Texture_min_filter, __pyx_setprop_4kivy_8graphics_7texture_7Texture_min_filter, __Pyx_DOCSTR(__pyx_k_32), 0},
  {(char *)"mag_filter", __pyx_getprop_4kivy_8graphics_7texture_7Texture_mag_filter, __pyx_setprop_4kivy_8graphics_7texture_7Texture_mag_filter, __Pyx_DOCSTR(__pyx_k_33), 0},
  {(char *)"wrap", __pyx_getprop_4kivy_8graphics_7texture_7Texture_wrap, __pyx_setprop_4kivy_8graphics_7texture_7Texture_wrap, __Pyx_DOCSTR(__pyx_k_34), 0},
  {(char *)"size", __pyx_getprop_4kivy_8graphics_7texture_7Texture_size, 0, 0, 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
};

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_9__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, rectangle=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_0__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
};

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*/
  0, /*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_0__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_35), /* 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_n_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 1},
  {&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0},
  {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
  {&__pyx_kp_s_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 0, 1, 0},
  {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
  {&__pyx_kp_s_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 0, 1, 0},
  {&__pyx_kp_s_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 0, 1, 0},
  {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
  {&__pyx_n_s_37, __pyx_k_37, sizeof(__pyx_k_37), 0, 0, 1, 1},
  {&__pyx_kp_s_38, __pyx_k_38, sizeof(__pyx_k_38), 0, 0, 1, 0},
  {&__pyx_n_s_39, __pyx_k_39, sizeof(__pyx_k_39), 0, 0, 1, 1},
  {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
  {&__pyx_n_s_40, __pyx_k_40, sizeof(__pyx_k_40), 0, 0, 1, 1},
  {&__pyx_n_s_41, __pyx_k_41, sizeof(__pyx_k_41), 0, 0, 1, 1},
  {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
  {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
  {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 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__GL_EXT_bgra, __pyx_k__GL_EXT_bgra, sizeof(__pyx_k__GL_EXT_bgra), 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___gl_mag_filter, __pyx_k___gl_mag_filter, sizeof(__pyx_k___gl_mag_filter), 0, 0, 1, 1},
  {&__pyx_n_s___gl_min_filter, __pyx_k___gl_min_filter, sizeof(__pyx_k___gl_min_filter), 0, 0, 1, 1},
  {&__pyx_n_s___gl_wrap, __pyx_k___gl_wrap, sizeof(__pyx_k___gl_wrap), 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___mipmap, __pyx_k___mipmap, sizeof(__pyx_k___mipmap), 0, 0, 1, 1},
  {&__pyx_n_s___rectangle, __pyx_k___rectangle, sizeof(__pyx_k___rectangle), 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__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__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__critical, __pyx_k__critical, sizeof(__pyx_k__critical), 0, 0, 1, 1},
  {&__pyx_n_s__data, __pyx_k__data, sizeof(__pyx_k__data), 0, 0, 1, 1},
  {&__pyx_n_s__disable, __pyx_k__disable, sizeof(__pyx_k__disable), 0, 0, 1, 1},
  {&__pyx_n_s__enable, __pyx_k__enable, sizeof(__pyx_k__enable), 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__hasGLExtension, __pyx_k__hasGLExtension, sizeof(__pyx_k__hasGLExtension), 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__lower, __pyx_k__lower, sizeof(__pyx_k__lower), 0, 0, 1, 1},
  {&__pyx_n_s__luminance, __pyx_k__luminance, sizeof(__pyx_k__luminance), 0, 0, 1, 1},
  {&__pyx_n_s__luminance_alpha, __pyx_k__luminance_alpha, sizeof(__pyx_k__luminance_alpha), 0, 0, 1, 1},
  {&__pyx_n_s__mag_filter, __pyx_k__mag_filter, sizeof(__pyx_k__mag_filter), 0, 0, 1, 1},
  {&__pyx_n_s__min_filter, __pyx_k__min_filter, sizeof(__pyx_k__min_filter), 0, 0, 1, 1},
  {&__pyx_n_s__mipmap, __pyx_k__mipmap, sizeof(__pyx_k__mipmap), 0, 0, 1, 1},
  {&__pyx_n_s__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__rectangle, __pyx_k__rectangle, sizeof(__pyx_k__rectangle), 0, 0, 1, 1},
  {&__pyx_n_s__release, __pyx_k__release, sizeof(__pyx_k__release), 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__schedule_interval, __pyx_k__schedule_interval, sizeof(__pyx_k__schedule_interval), 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__split, __pyx_k__split, sizeof(__pyx_k__split), 0, 0, 1, 1},
  {&__pyx_n_s__staticmethod, __pyx_k__staticmethod, sizeof(__pyx_k__staticmethod), 0, 0, 1, 1},
  {&__pyx_n_s__target, __pyx_k__target, sizeof(__pyx_k__target), 0, 0, 1, 1},
  {&__pyx_n_s__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__uvsize, __pyx_k__uvsize, sizeof(__pyx_k__uvsize), 0, 0, 1, 1},
  {&__pyx_n_s__warning, __pyx_k__warning, sizeof(__pyx_k__warning), 0, 0, 1, 1},
  {&__pyx_n_s__width, __pyx_k__width, sizeof(__pyx_k__width), 0, 0, 1, 1},
  {&__pyx_n_s__wrap, __pyx_k__wrap, sizeof(__pyx_k__wrap), 0, 0, 1, 1},
  {&__pyx_n_s__x, __pyx_k__x, sizeof(__pyx_k__x), 0, 0, 1, 1},
  {&__pyx_n_s__y, __pyx_k__y, sizeof(__pyx_k__y), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_staticmethod = __Pyx_GetName(__pyx_b, __pyx_n_s__staticmethod); if (!__pyx_builtin_staticmethod) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __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 = 79; __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 = 80; __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 = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

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

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":130
 *     global _has_bgr
 *     if _has_bgr == -1:
 *         Logger.warning('Texture: BGR/BGRA format is not supported by'             # <<<<<<<<<<<<<<
 *                        'your graphic card')
 *         Logger.warning('Texture: Software conversion will be done to'
 */
  __pyx_k_tuple_7 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_7));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
  PyTuple_SET_ITEM(__pyx_k_tuple_7, 0, ((PyObject *)__pyx_kp_s_6));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_7));

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":132
 *         Logger.warning('Texture: BGR/BGRA format is not supported by'
 *                        'your graphic card')
 *         Logger.warning('Texture: Software conversion will be done to'             # <<<<<<<<<<<<<<
 *                        'RGB/RGBA')
 *         _has_bgr = int(hasGLExtension('GL_EXT_bgra'))
 */
  __pyx_k_tuple_9 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_9));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
  PyTuple_SET_ITEM(__pyx_k_tuple_9, 0, ((PyObject *)__pyx_kp_s_8));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_9));

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":134
 *         Logger.warning('Texture: Software conversion will be done to'
 *                        'RGB/RGBA')
 *         _has_bgr = int(hasGLExtension('GL_EXT_bgra'))             # <<<<<<<<<<<<<<
 *     return _has_bgr
 * 
 */
  __pyx_k_tuple_10 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_10));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__GL_EXT_bgra));
  PyTuple_SET_ITEM(__pyx_k_tuple_10, 0, ((PyObject *)__pyx_n_s__GL_EXT_bgra));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__GL_EXT_bgra));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_10));

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

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":11
 * '''
 * 
 * __all__ = ('Texture', 'TextureRegion')             # <<<<<<<<<<<<<<
 * 
 * include "config.pxi"
 */
  __pyx_k_tuple_36 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_36));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__Texture));
  PyTuple_SET_ITEM(__pyx_k_tuple_36, 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_36, 1, ((PyObject *)__pyx_n_s__TextureRegion));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__TextureRegion));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_36));
  __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;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  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_35), 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_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);
  /*--- 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.release = (PyObject *(*)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *))__pyx_f_4kivy_8graphics_7texture_7Texture_release;
  __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;
  __pyx_vtable_4kivy_8graphics_7texture_Texture.enable = (PyObject *(*)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, int __pyx_skip_dispatch))__pyx_f_4kivy_8graphics_7texture_7Texture_enable;
  __pyx_vtable_4kivy_8graphics_7texture_Texture.disable = (PyObject *(*)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, int __pyx_skip_dispatch))__pyx_f_4kivy_8graphics_7texture_7Texture_disable;
  if (PyType_Ready(&__pyx_type_4kivy_8graphics_7texture_Texture) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __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 = 317; __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 = 317; __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 = 550; __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 = 550; __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 = 550; __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 ---*/
  /*--- Execution code ---*/

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

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

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":16
 * 
 * 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 = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__array));
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__array));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__array));
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__array), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__array); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__array, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

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

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":31
 * # XXX move missing symbol in c_opengl
 * # utilities
 * AVAILABLE_GL_EXTENSIONS = ''             # <<<<<<<<<<<<<<
 * def hasGLExtension( specifier ):
 *     '''Given a string specifier, check for extension being available
 */
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_1, ((PyObject *)__pyx_kp_s_38)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":32
 * # utilities
 * AVAILABLE_GL_EXTENSIONS = ''
 * def hasGLExtension( specifier ):             # <<<<<<<<<<<<<<
 *     '''Given a string specifier, check for extension being available
 *     '''
 */
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4kivy_8graphics_7texture_0hasGLExtension, NULL, __pyx_n_s_39); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__hasGLExtension, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":43
 * 
 * # compatibility layer
 * cdef GLuint GL_BGR = 0x80E0             # <<<<<<<<<<<<<<
 * cdef GLuint GL_BGRA = 0x80E1
 * 
 */
  __pyx_v_4kivy_8graphics_7texture_GL_BGR = 0x80E0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":44
 * # compatibility layer
 * cdef GLuint GL_BGR = 0x80E0
 * cdef GLuint GL_BGRA = 0x80E1             # <<<<<<<<<<<<<<
 * 
 * cdef list _texture_release_list = []
 */
  __pyx_v_4kivy_8graphics_7texture_GL_BGRA = 0x80E1;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":46
 * cdef GLuint GL_BGRA = 0x80E1
 * 
 * cdef list _texture_release_list = []             # <<<<<<<<<<<<<<
 * cdef int _has_bgr = -1
 * cdef int _has_texture_nv = -1
 */
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __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_2));
  __pyx_v_4kivy_8graphics_7texture__texture_release_list = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":47
 * 
 * cdef list _texture_release_list = []
 * cdef int _has_bgr = -1             # <<<<<<<<<<<<<<
 * cdef int _has_texture_nv = -1
 * cdef int _has_texture_arb = -1
 */
  __pyx_v_4kivy_8graphics_7texture__has_bgr = -1;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":48
 * cdef list _texture_release_list = []
 * cdef int _has_bgr = -1
 * cdef int _has_texture_nv = -1             # <<<<<<<<<<<<<<
 * cdef int _has_texture_arb = -1
 * 
 */
  __pyx_v_4kivy_8graphics_7texture__has_texture_nv = -1;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":49
 * cdef int _has_bgr = -1
 * cdef int _has_texture_nv = -1
 * cdef int _has_texture_arb = -1             # <<<<<<<<<<<<<<
 * 
 * cdef inline int _nearest_pow2(int v):
 */
  __pyx_v_4kivy_8graphics_7texture__has_texture_arb = -1;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":66
 *     return (v & (v - 1)) == 0
 * 
 * cdef dict _gl_color_fmt = {             # <<<<<<<<<<<<<<
 *     'rgba': GL_RGBA,
 *     'bgra': GL_BGRA,
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":67
 * 
 * cdef dict _gl_color_fmt = {
 *     'rgba': GL_RGBA,             # <<<<<<<<<<<<<<
 *     'bgra': GL_BGRA,
 *     'rgb': GL_RGB,
 */
  __pyx_t_1 = PyInt_FromLong(GL_RGBA); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__rgba), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":68
 * cdef dict _gl_color_fmt = {
 *     'rgba': GL_RGBA,
 *     'bgra': GL_BGRA,             # <<<<<<<<<<<<<<
 *     'rgb': GL_RGB,
 *     'bgr': GL_BGR,
 */
  __pyx_t_1 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_BGRA); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__bgra), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":69
 *     'rgba': GL_RGBA,
 *     'bgra': GL_BGRA,
 *     'rgb': GL_RGB,             # <<<<<<<<<<<<<<
 *     'bgr': GL_BGR,
 *     'luminance': GL_LUMINANCE,
 */
  __pyx_t_1 = PyInt_FromLong(GL_RGB); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__rgb), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":70
 *     'bgra': GL_BGRA,
 *     'rgb': GL_RGB,
 *     'bgr': GL_BGR,             # <<<<<<<<<<<<<<
 *     'luminance': GL_LUMINANCE,
 *     'luminance_alpha': GL_LUMINANCE_ALPHA,
 */
  __pyx_t_1 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_BGR); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__bgr), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":71
 *     'rgb': GL_RGB,
 *     'bgr': GL_BGR,
 *     'luminance': GL_LUMINANCE,             # <<<<<<<<<<<<<<
 *     'luminance_alpha': GL_LUMINANCE_ALPHA,
 * }
 */
  __pyx_t_1 = PyInt_FromLong(GL_LUMINANCE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__luminance), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":72
 *     'bgr': GL_BGR,
 *     'luminance': GL_LUMINANCE,
 *     'luminance_alpha': GL_LUMINANCE_ALPHA,             # <<<<<<<<<<<<<<
 * }
 * 
 */
  __pyx_t_1 = PyInt_FromLong(GL_LUMINANCE_ALPHA); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__luminance_alpha), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 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_2));
  __pyx_v_4kivy_8graphics_7texture__gl_color_fmt = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":82
 *         raise Exception('Unknown <%s> color format' % x)
 * 
 * cdef dict _gl_buffer_fmt = {             # <<<<<<<<<<<<<<
 *     'ubyte': GL_UNSIGNED_BYTE,
 *     'ushort': GL_UNSIGNED_SHORT,
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":83
 * 
 * cdef dict _gl_buffer_fmt = {
 *     'ubyte': GL_UNSIGNED_BYTE,             # <<<<<<<<<<<<<<
 *     'ushort': GL_UNSIGNED_SHORT,
 *     'uint': GL_UNSIGNED_INT,
 */
  __pyx_t_1 = PyInt_FromLong(GL_UNSIGNED_BYTE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__ubyte), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":84
 * cdef dict _gl_buffer_fmt = {
 *     'ubyte': GL_UNSIGNED_BYTE,
 *     'ushort': GL_UNSIGNED_SHORT,             # <<<<<<<<<<<<<<
 *     'uint': GL_UNSIGNED_INT,
 *     'byte': GL_BYTE,
 */
  __pyx_t_1 = PyInt_FromLong(GL_UNSIGNED_SHORT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__ushort), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":85
 *     'ubyte': GL_UNSIGNED_BYTE,
 *     'ushort': GL_UNSIGNED_SHORT,
 *     'uint': GL_UNSIGNED_INT,             # <<<<<<<<<<<<<<
 *     'byte': GL_BYTE,
 *     'short': GL_SHORT,
 */
  __pyx_t_1 = PyInt_FromLong(GL_UNSIGNED_INT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__uint), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":86
 *     'ushort': GL_UNSIGNED_SHORT,
 *     'uint': GL_UNSIGNED_INT,
 *     'byte': GL_BYTE,             # <<<<<<<<<<<<<<
 *     'short': GL_SHORT,
 *     'int': GL_INT,
 */
  __pyx_t_1 = PyInt_FromLong(GL_BYTE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__byte), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":87
 *     'uint': GL_UNSIGNED_INT,
 *     'byte': GL_BYTE,
 *     'short': GL_SHORT,             # <<<<<<<<<<<<<<
 *     'int': GL_INT,
 *     'float': GL_FLOAT
 */
  __pyx_t_1 = PyInt_FromLong(GL_SHORT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__short), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":88
 *     'byte': GL_BYTE,
 *     'short': GL_SHORT,
 *     'int': GL_INT,             # <<<<<<<<<<<<<<
 *     'float': GL_FLOAT
 * }
 */
  __pyx_t_1 = PyInt_FromLong(GL_INT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__int), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":90
 *     'int': GL_INT,
 *     'float': GL_FLOAT
 * }             # <<<<<<<<<<<<<<
 * 
 * cdef inline int _buffer_fmt_to_gl(str x):
 */
  __pyx_t_1 = PyInt_FromLong(GL_FLOAT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__float), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 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_2));
  __pyx_v_4kivy_8graphics_7texture__gl_buffer_fmt = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":99
 *         raise Exception('Unknown <%s> buffer format' % x)
 * 
 * cdef dict _gl_buffer_size = {             # <<<<<<<<<<<<<<
 *     'ubyte': sizeof(GLubyte),
 *     'ushort': sizeof(GLushort),
 */
  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":100
 * 
 * cdef dict _gl_buffer_size = {
 *     'ubyte': sizeof(GLubyte),             # <<<<<<<<<<<<<<
 *     'ushort': sizeof(GLushort),
 *     'uint': sizeof(GLuint),
 */
  __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(GLubyte))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__ubyte), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":101
 * cdef dict _gl_buffer_size = {
 *     'ubyte': sizeof(GLubyte),
 *     'ushort': sizeof(GLushort),             # <<<<<<<<<<<<<<
 *     'uint': sizeof(GLuint),
 *     'byte': sizeof(GLbyte),
 */
  __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(GLushort))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__ushort), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":102
 *     'ubyte': sizeof(GLubyte),
 *     'ushort': sizeof(GLushort),
 *     'uint': sizeof(GLuint),             # <<<<<<<<<<<<<<
 *     'byte': sizeof(GLbyte),
 *     'short': sizeof(GLshort),
 */
  __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(GLuint))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__uint), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":103
 *     'ushort': sizeof(GLushort),
 *     'uint': sizeof(GLuint),
 *     'byte': sizeof(GLbyte),             # <<<<<<<<<<<<<<
 *     'short': sizeof(GLshort),
 *     'int': sizeof(GLint),
 */
  __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(GLbyte))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__byte), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":104
 *     'uint': sizeof(GLuint),
 *     'byte': sizeof(GLbyte),
 *     'short': sizeof(GLshort),             # <<<<<<<<<<<<<<
 *     'int': sizeof(GLint),
 *     'float': sizeof(GLfloat)
 */
  __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(GLshort))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__short), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":105
 *     'byte': sizeof(GLbyte),
 *     'short': sizeof(GLshort),
 *     'int': sizeof(GLint),             # <<<<<<<<<<<<<<
 *     'float': sizeof(GLfloat)
 * }
 */
  __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(GLint))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__int), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":106
 *     'short': sizeof(GLshort),
 *     'int': sizeof(GLint),
 *     'float': sizeof(GLfloat)             # <<<<<<<<<<<<<<
 * }
 * 
 */
  __pyx_t_1 = __Pyx_PyInt_FromSize_t((sizeof(GLfloat))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__float), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 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_2));
  __pyx_v_4kivy_8graphics_7texture__gl_buffer_size = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":273
 *     return texture.get_region(0, 0, width, height)
 * 
 * def texture_create(size=None, colorfmt=None, bufferfmt=None, rectangle=False, mipmap=False):             # <<<<<<<<<<<<<<
 *     '''Create a texture based on size.
 * 
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_14 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_15 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4kivy_8graphics_7texture_1texture_create, NULL, __pyx_n_s_39); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__texture_create, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":305
 * 
 * 
 * def texture_create_from_data(im, rectangle=True, mipmap=False):             # <<<<<<<<<<<<<<
 *     '''Create a texture from an ImageData class'''
 * 
 */
  __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_16 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_k_17 = __pyx_t_2;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_4kivy_8graphics_7texture_2texture_create_from_data, NULL, __pyx_n_s_39); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_40, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

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

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":322
 * 
 *     create = staticmethod(texture_create)
 *     create_from_data = staticmethod(texture_create_from_data)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s_40); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(__pyx_builtin_staticmethod, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  if (PyDict_SetItem((PyObject *)__pyx_ptype_4kivy_8graphics_7texture_Texture->tp_dict, __pyx_n_s__create_from_data, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  PyType_Modified(__pyx_ptype_4kivy_8graphics_7texture_Texture);

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

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":580
 * # 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_2 = PyCFunction_NewEx(&__pyx_mdef_4kivy_8graphics_7texture_3_texture_release, NULL, __pyx_n_s_39); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s___texture_release, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":589
 *     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_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__environ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = (__Pyx_NegateNonNeg(PySequence_Contains(__pyx_t_2, ((PyObject *)__pyx_n_s__KIVY_DOC_INCLUDE)))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_3) {

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

    /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":592
 *     # install tick to release texture every 200ms
 *     from kivy.clock import Clock
 *     Clock.schedule_interval(_texture_release, 0.2)             # <<<<<<<<<<<<<<
 * 
 */
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__Clock); 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 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__schedule_interval); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s___texture_release); 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_4 = PyFloat_FromDouble(0.2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_1 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/home/tito/code/kivy/kivy/graphics/texture.pyx":1
 * #cython: embedsignature=True             # <<<<<<<<<<<<<<
 * 
 * '''
 */
  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_4)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __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 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 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 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 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 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 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 GLint __Pyx_PyInt_from_py_GLint(PyObject* x) {
    const GLint neg_one = (GLint)-1, const_zero = (GLint)0;
    const int is_unsigned = const_zero < neg_one;
    if (sizeof(GLint) == sizeof(char)) {
        if (is_unsigned)
            return (GLint)__Pyx_PyInt_AsUnsignedChar(x);
        else
            return (GLint)__Pyx_PyInt_AsSignedChar(x);
    } else if (sizeof(GLint) == sizeof(short)) {
        if (is_unsigned)
            return (GLint)__Pyx_PyInt_AsUnsignedShort(x);
        else
            return (GLint)__Pyx_PyInt_AsSignedShort(x);
    } else if (sizeof(GLint) == sizeof(int)) {
        if (is_unsigned)
            return (GLint)__Pyx_PyInt_AsUnsignedInt(x);
        else
            return (GLint)__Pyx_PyInt_AsSignedInt(x);
    } else if (sizeof(GLint) == sizeof(long)) {
        if (is_unsigned)
            return (GLint)__Pyx_PyInt_AsUnsignedLong(x);
        else
            return (GLint)__Pyx_PyInt_AsSignedLong(x);
    } else if (sizeof(GLint) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return (GLint)__Pyx_PyInt_AsUnsignedLongLong(x);
        else
            return (GLint)__Pyx_PyInt_AsSignedLongLong(x);
    }  else {
        GLint 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 (GLint)-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;
}

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