/* Generated by Cython 0.17pre on Sun Sep 30 02:52:45 2012 */

#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.
#elif PY_VERSION_HEX < 0x02040000
    #error Cython requires Python 2.4+.
#else
#include <stddef.h> /* For offsetof */
#ifndef offsetof
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif

#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif

#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif

#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif

#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif

#ifdef PYPY_VERSION
#define CYTHON_COMPILING_IN_PYPY 1
#define CYTHON_COMPILING_IN_CPYTHON 0
#else
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_CPYTHON 1
#endif

#if PY_VERSION_HEX < 0x02050000
  typedef int Py_ssize_t;
  #define PY_SSIZE_T_MAX INT_MAX
  #define PY_SSIZE_T_MIN INT_MIN
  #define PY_FORMAT_SIZE_T ""
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)   __Pyx_PyInt_AsInt(o)
  #define PyNumber_Index(o)    ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \
                                (PyErr_Format(PyExc_TypeError, \
                                              "expected index value, got %.200s", Py_TYPE(o)->tp_name), \
                                 (PyObject*)0))
  #define PyIndex_Check(o)     (PyNumber_Check(o) && !PyFloat_Check(o) && !PyComplex_Check(o))
  #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
  #define __PYX_BUILD_PY_SSIZE_T "i"
#else
  #define __PYX_BUILD_PY_SSIZE_T "n"
#endif

#if PY_VERSION_HEX < 0x02060000
  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
  #define PyVarObject_HEAD_INIT(type, size) \
          PyObject_HEAD_INIT(type) size,
  #define PyType_Modified(t)

  typedef struct {
     void *buf;
     PyObject *obj;
     Py_ssize_t len;
     Py_ssize_t itemsize;
     int readonly;
     int ndim;
     char *format;
     Py_ssize_t *shape;
     Py_ssize_t *strides;
     Py_ssize_t *suboffsets;
     void *internal;
  } Py_buffer;

  #define PyBUF_SIMPLE 0
  #define PyBUF_WRITABLE 0x0001
  #define PyBUF_FORMAT 0x0004
  #define PyBUF_ND 0x0008
  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
  #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE)
  #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE)

  typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
  typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
#endif

#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
          PyCode_New(a, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#endif

#if PY_MAJOR_VERSION < 3 && PY_MINOR_VERSION < 6
  #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict")
#endif

#if PY_MAJOR_VERSION >= 3
  #define Py_TPFLAGS_CHECKTYPES 0
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif

#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif


#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  #define CYTHON_PEP393_ENABLED 1
  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ? \
                                              0 : _PyUnicode_Ready((PyObject *)(op)))
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
#else
  #define CYTHON_PEP393_ENABLED 0
  #define __Pyx_PyUnicode_READY(op)       (0)
  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))

  #define __Pyx_PyUnicode_READ(k, d, i)   ((k=k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#endif

#if PY_VERSION_HEX < 0x02060000
  #define PyBytesObject                PyStringObject
  #define PyBytes_Type                 PyString_Type
  #define PyBytes_Check                PyString_Check
  #define PyBytes_CheckExact           PyString_CheckExact
  #define PyBytes_FromString           PyString_FromString
  #define PyBytes_FromStringAndSize    PyString_FromStringAndSize
  #define PyBytes_FromFormat           PyString_FromFormat
  #define PyBytes_DecodeEscape         PyString_DecodeEscape
  #define PyBytes_AsString             PyString_AsString
  #define PyBytes_AsStringAndSize      PyString_AsStringAndSize
  #define PyBytes_Size                 PyString_Size
  #define PyBytes_AS_STRING            PyString_AS_STRING
  #define PyBytes_GET_SIZE             PyString_GET_SIZE
  #define PyBytes_Repr                 PyString_Repr
  #define PyBytes_Concat               PyString_Concat
  #define PyBytes_ConcatAndDel         PyString_ConcatAndDel
#endif

#if PY_VERSION_HEX < 0x02060000
  #define PySet_Check(obj)             PyObject_TypeCheck(obj, &PySet_Type)
  #define PyFrozenSet_Check(obj)       PyObject_TypeCheck(obj, &PyFrozenSet_Type)
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif

#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)

#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif

#if PY_VERSION_HEX < 0x03020000
  typedef long Py_hash_t;
  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
#else
  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
#endif

#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
  #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
  #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
#else
  #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
  #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#endif

#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
#else
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
#endif

#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_NAMESTR(n) ((char *)(n))
  #define __Pyx_DOCSTR(n)  ((char *)(n))
#else
  #define __Pyx_NAMESTR(n) (n)
  #define __Pyx_DOCSTR(n)  (n)
#endif

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

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

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

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif


/* 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) && !defined(_MSC_VER))
#   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_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);

#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_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",
  "buffer.pxd",
  "vbo.pxd",
  "transformation.pxd",
  "context_instructions.pxd",
  "compiler.pxd",
  "shader.pxd",
  "instructions.pxd",
  "fbo.pxd",
  "context.pxd",
  "opengl_utils_def.pxi",
};

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

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

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

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

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

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

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


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


/* "kivy\graphics\instructions.pxd":1
 * cdef class Instruction             # <<<<<<<<<<<<<<
 * cdef class InstructionGroup
 * cdef class ContextInstruction
 */
struct __pyx_obj_4kivy_8graphics_12instructions_Instruction {
  PyObject_HEAD
  struct __pyx_vtabstruct_4kivy_8graphics_12instructions_Instruction *__pyx_vtab;
  int flags;
  PyObject *group;
  struct __pyx_obj_4kivy_8graphics_12instructions_InstructionGroup *parent;
};


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


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


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


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


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


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


/* "context_instructions.pxd":44
 *     cdef void apply(self)
 * 
 * cdef class Scale(Transform):             # <<<<<<<<<<<<<<
 *     cdef float s
 *     cdef void apply(self)
 */
struct __pyx_obj_4kivy_8graphics_20context_instructions_Scale {
  struct __pyx_obj_4kivy_8graphics_20context_instructions_Transform __pyx_base;
  float s;
};


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


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


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

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


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


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


/* "vbo.pxd":8
 * cdef vertex_attr_t *vbo_vertex_attr_list()
 * 
 * cdef class VBO:             # <<<<<<<<<<<<<<
 *     cdef object __weakref__
 * 
 */
struct __pyx_obj_4kivy_8graphics_3vbo_VBO {
  PyObject_HEAD
  struct __pyx_vtabstruct_4kivy_8graphics_3vbo_VBO *__pyx_vtab;
  PyObject *__weakref__;
  GLuint id;
  int usage;
  int target;
  __pyx_t_4kivy_8graphics_6vertex_vertex_attr_t *format;
  int format_count;
  struct __pyx_obj_4kivy_8graphics_6buffer_Buffer *data;
  short flags;
  int vbo_size;
};


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


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


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


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


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


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


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


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


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


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


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


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



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


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

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


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

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


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

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


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

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


/* "context_instructions.pxd":48
 *     cdef void apply(self)
 * 
 * cdef class Translate(Transform):             # <<<<<<<<<<<<<<
 *     cdef double _x, _y, _z
 *     cdef void apply(self)
 */

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


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

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


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

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


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

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


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

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


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

struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix {
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*identity)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, int __pyx_skip_dispatch);
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*inverse)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, int __pyx_skip_dispatch);
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*multiply)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, int __pyx_skip_dispatch);
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*rotate)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, double, int __pyx_skip_dispatch);
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*scale)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, int __pyx_skip_dispatch);
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*translate)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, int __pyx_skip_dispatch);
  struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *(*view_clip)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, double, double, double, int, int __pyx_skip_dispatch);
  PyObject *(*transform_point)(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix *, double, double, double, int __pyx_skip_dispatch);
};
static struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix *__pyx_vtabptr_4kivy_8graphics_14transformation_Matrix;


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


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

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


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

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


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

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


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

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


/* "vbo.pxd":8
 * cdef vertex_attr_t *vbo_vertex_attr_list()
 * 
 * cdef class VBO:             # <<<<<<<<<<<<<<
 *     cdef object __weakref__
 * 
 */

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


/* "context_instructions.pxd":39
 *     cdef void apply(self)
 * 
 * cdef class Rotate(Transform):             # <<<<<<<<<<<<<<
 *     cdef float _angle
 *     cdef tuple _axis
 */

struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Rotate {
  struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Transform __pyx_base;
};
static struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Rotate *__pyx_vtabptr_4kivy_8graphics_20context_instructions_Rotate;


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


/* "context_instructions.pxd":44
 *     cdef void apply(self)
 * 
 * cdef class Scale(Transform):             # <<<<<<<<<<<<<<
 *     cdef float s
 *     cdef void apply(self)
 */

struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Scale {
  struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Transform __pyx_base;
};
static struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Scale *__pyx_vtabptr_4kivy_8graphics_20context_instructions_Scale;


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

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


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

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

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

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

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

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

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

static int __Pyx_PyUnicode_Tailmatch(PyObject* s, PyObject* substr,
                                     Py_ssize_t start, Py_ssize_t end, int direction) {
    if (unlikely(PyTuple_Check(substr))) {
        int result;
        Py_ssize_t i;
        for (i = 0; i < PyTuple_GET_SIZE(substr); i++) {
            result = PyUnicode_Tailmatch(s, PyTuple_GET_ITEM(substr, i),
                                         start, end, direction);
            if (result) {
                return result;
            }
        }
        return 0;
    }
    return PyUnicode_Tailmatch(s, substr, start, end, direction);
}

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

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

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

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

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

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

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

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

static int __Pyx_IternextUnpackEndCheck(PyObject *retval, 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 CYTHON_COMPILING_IN_CPYTHON
    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));
#else
    return PySequence_GetItem(o, i);
#endif
}
#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 CYTHON_COMPILING_IN_CPYTHON
    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));
#else
    return PySequence_GetItem(o, i);
#endif
}
#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) {
#if CYTHON_COMPILING_IN_CPYTHON
    if (PyList_CheckExact(o)) {
        Py_ssize_t n = (likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
        if (likely((n >= 0) & (n < PyList_GET_SIZE(o)))) {
            PyObject *r = PyList_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (PyTuple_CheckExact(o)) {
        Py_ssize_t n = (likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
        if (likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, n);
            Py_INCREF(r);
            return r;
        }
    }
    else if (likely(i >= 0)) {
        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
        if (likely(m && m->sq_item)) {
            return m->sq_item(o, i);
        }
    }
#else
    if (PySequence_Check(o)) {
        return PySequence_GetItem(o, i);
    }
#endif
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact); /*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, long level); /*proto*/

static CYTHON_INLINE void __Pyx_RaiseImportError(PyObject *name);

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_GLuint(GLuint);

static CYTHON_INLINE GLuint __Pyx_PyInt_from_py_GLuint(PyObject *);

#include <string.h>

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

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

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

#ifndef __PYX_FORCE_INIT_THREADS
  #define __PYX_FORCE_INIT_THREADS 0
#endif

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, int clineno,
                                  int lineno, const char *filename); /*proto*/

static int __Pyx_check_binary_version(void);

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

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

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

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

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

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

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

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

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


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

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

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

/* Module declarations from 'kivy.graphics.vbo' */
static PyTypeObject *__pyx_ptype_4kivy_8graphics_3vbo_VBO = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_3vbo_VertexBatch = 0;

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

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

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

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

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

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

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

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

/* Module declarations from 'kivy.graphics.texture' */
static PyTypeObject *__pyx_ptype_4kivy_8graphics_7texture_Texture = 0;
static PyTypeObject *__pyx_ptype_4kivy_8graphics_7texture_TextureRegion = 0;
static double __pyx_v_4kivy_8graphics_7texture_pi;
static int __pyx_v_4kivy_8graphics_7texture_c_GLCAP_BGRA;
static int __pyx_v_4kivy_8graphics_7texture_c_GLCAP_NPOT;
static int __pyx_v_4kivy_8graphics_7texture_c_GLCAP_S3TC;
static int __pyx_v_4kivy_8graphics_7texture_c_GLCAP_DXT1;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_BGR;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_BGRA;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
static GLuint __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
static PyObject *__pyx_v_4kivy_8graphics_7texture__gl_color_fmt = 0;
static PyObject *__pyx_v_4kivy_8graphics_7texture__gl_buffer_fmt = 0;
static PyObject *__pyx_v_4kivy_8graphics_7texture__gl_buffer_size = 0;
static PyObject *__pyx_v_4kivy_8graphics_7texture__gl_texture_min_filter = 0;
static CYTHON_INLINE int __pyx_f_4kivy_8graphics_7texture__nearest_pow2(int); /*proto*/
static CYTHON_INLINE int __pyx_f_4kivy_8graphics_7texture__is_pow2(int); /*proto*/
static CYTHON_INLINE int __pyx_f_4kivy_8graphics_7texture__color_fmt_to_gl(PyObject *); /*proto*/
static CYTHON_INLINE int __pyx_f_4kivy_8graphics_7texture__is_compressed_fmt(PyObject *); /*proto*/
static CYTHON_INLINE int __pyx_f_4kivy_8graphics_7texture__buffer_fmt_to_gl(PyObject *); /*proto*/
static CYTHON_INLINE int __pyx_f_4kivy_8graphics_7texture__buffer_type_to_gl_size(PyObject *); /*proto*/
static CYTHON_INLINE GLuint __pyx_f_4kivy_8graphics_7texture__str_to_gl_texture_min_filter(PyObject *); /*proto*/
static CYTHON_INLINE GLuint __pyx_f_4kivy_8graphics_7texture__str_to_gl_texture_mag_filter(PyObject *); /*proto*/
static CYTHON_INLINE GLuint __pyx_f_4kivy_8graphics_7texture__str_to_gl_texture_wrap(PyObject *); /*proto*/
static CYTHON_INLINE int __pyx_f_4kivy_8graphics_7texture__gl_format_size(GLuint); /*proto*/
static CYTHON_INLINE int __pyx_f_4kivy_8graphics_7texture__is_gl_format_supported(PyObject *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_4kivy_8graphics_7texture__convert_gl_format(PyObject *); /*proto*/
static CYTHON_INLINE PyObject *__pyx_f_4kivy_8graphics_7texture__convert_buffer(PyObject *, PyObject *); /*proto*/
static CYTHON_INLINE void __pyx_f_4kivy_8graphics_7texture__gl_prepare_pixels_upload(int); /*proto*/
static struct __pyx_obj_4kivy_8graphics_7texture_Texture *__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 PyObject *__pyx_builtin_id;
static PyObject *__pyx_pf_4kivy_8graphics_7texture_texture_create(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_size, PyObject *__pyx_v_colorfmt, PyObject *__pyx_v_bufferfmt, PyObject *__pyx_v_mipmap); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_2texture_create_from_data(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_im, PyObject *__pyx_v_mipmap); /* proto */
static int __pyx_pf_4kivy_8graphics_7texture_7Texture___init__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_width, PyObject *__pyx_v_height, PyObject *__pyx_v_target, PyObject *__pyx_v_texid, PyObject *__pyx_v_colorfmt, PyObject *__pyx_v_bufferfmt, PyObject *__pyx_v_mipmap, PyObject *__pyx_v_source); /* proto */
static void __pyx_pf_4kivy_8graphics_7texture_7Texture_2__dealloc__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_4add_reload_observer(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6remove_reload_observer(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_callback); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_8flip_vertical(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_10get_region(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x, PyObject *__pyx_v_y, PyObject *__pyx_v_width, PyObject *__pyx_v_height); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_12bind(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_14blit_data(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_im, PyObject *__pyx_v_pos); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_16blit_buffer(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_pbuffer, PyObject *__pyx_v_size, PyObject *__pyx_v_colorfmt, PyObject *__pyx_v_pos, PyObject *__pyx_v_bufferfmt, PyObject *__pyx_v_mipmap_level, PyObject *__pyx_v_mipmap_generation); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_18__repr__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_4size___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6mipmap___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_2id___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6target___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_5width___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6height___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_10tex_coords___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_5uvpos___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static int __pyx_pf_4kivy_8graphics_7texture_7Texture_5uvpos_2__set__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_6uvsize___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static int __pyx_pf_4kivy_8graphics_7texture_7Texture_6uvsize_2__set__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_8colorfmt___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_9bufferfmt___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_10min_filter___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static int __pyx_pf_4kivy_8graphics_7texture_7Texture_10min_filter_2__set__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_10mag_filter___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static int __pyx_pf_4kivy_8graphics_7texture_7Texture_10mag_filter_2__set__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_7Texture_4wrap___get__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self); /* proto */
static int __pyx_pf_4kivy_8graphics_7texture_7Texture_4wrap_2__set__(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_wrap); /* proto */
static int __pyx_pf_4kivy_8graphics_7texture_13TextureRegion___init__(struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *__pyx_v_self, int __pyx_v_x, int __pyx_v_y, int __pyx_v_width, int __pyx_v_height, struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_origin); /* proto */
static PyObject *__pyx_pf_4kivy_8graphics_7texture_13TextureRegion_2__repr__(struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *__pyx_v_self); /* proto */
static char __pyx_k_1[] = "Unknown <%s> color format";
static char __pyx_k_2[] = "Unknown <%s> buffer format";
static char __pyx_k_3[] = "Unknown <%s> format";
static char __pyx_k_4[] = "Unknown <%s> texture min filter";
static char __pyx_k_5[] = "Unknown <%s> texture mag filter";
static char __pyx_k_6[] = "Unsupported format size <%s>";
static char __pyx_k_7[] = "Unimplemented texture conversion for %s";
static char __pyx_k_16[] = "Non implemented texture conversion !";
static char __pyx_k_17[] = "linear_mipmap_nearest";
static char __pyx_k_18[] = "Unable to allocate memory for texture (size is %s)";
static char __pyx_k_24[] = "kivy.core.image";
static char __pyx_k_25[] = "<Texture hash=%r id=%d size=%r colorfmt=%r bufferfmt=%r source=%r observers=%d>";
static char __pyx_k_26[] = "<TextureRegion of %r hash=%r id=%d size=%r colorfmt=%r bufferfmt=%r source=%r observers=%d>";
static char __pyx_k_27[] = "Return the (width, height) of the texture (readonly)\n        ";
static char __pyx_k_28[] = "Return True if the texture have mipmap enabled (readonly)\n        ";
static char __pyx_k_29[] = "Return the OpenGL ID of the texture (readonly)\n        ";
static char __pyx_k_30[] = "Return the OpenGL target of the texture (readonly)\n        ";
static char __pyx_k_31[] = "Return the width of the texture (readonly)\n        ";
static char __pyx_k_32[] = "Return the height of the texture (readonly)\n        ";
static char __pyx_k_33[] = "Return the list of tex_coords (opengl)\n        ";
static char __pyx_k_34[] = "Get/set the UV position inside texture\n        ";
static char __pyx_k_35[] = "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_36[] = "Return the color format used in this texture. (readonly)\n\n        .. versionadded:: 1.0.7\n        ";
static char __pyx_k_37[] = "Return the buffer format used in this texture. (readonly)\n\n        .. versionadded:: 1.2.0\n        ";
static char __pyx_k_38[] = "Get/set the min filter texture. Available values:\n\n        - linear\n        - nearest\n        - linear_mipmap_linear\n        - linear_mipmap_nearest\n        - nearest_mipmap_nearest\n        - nearest_mipmap_linear\n\n        Check opengl documentation for more information about the behavior of\n        theses values : http://www.khronos.org/opengles/sdk/docs/man/xhtml/glTexParameter.xml.\n        ";
static char __pyx_k_39[] = "Get/set the mag filter texture. Available values:\n\n        - linear\n        - nearest\n\n        Check opengl documentation for more information about the behavior of\n        theses values : http://www.khronos.org/opengles/sdk/docs/man/xhtml/glTexParameter.xml.\n        ";
static char __pyx_k_40[] = "Get/set the wrap texture. Available values:\n\n        - repeat\n        - mirrored_repeat\n        - clamp_to_edge\n\n        Check opengl documentation for more information about the behavior of\n        theses values : http://www.khronos.org/opengles/sdk/docs/man/xhtml/glTexParameter.xml.\n        ";
static char __pyx_k_41[] = "\nTexture\n=======\n\n:class:`Texture` is a class to handle OpenGL texture. Depending of the hardware,\nsome OpenGL capabilities might not be available (BGRA support, NPOT support,\netc.)\n\nYou cannot instanciate the class yourself. You must use the function\n:func:`Texture.create` to create a new texture::\n\n    texture = Texture.create(size=(640, 480))\n\nWhen you are creating a texture, you must be aware of the default color format\nand buffer format:\n\n    - the color/pixel format (:data:`Texture.colorfmt`), that can be one of\n      'rgb', 'rgba', 'luminance', 'luminance_alpha', 'bgr', 'bgra'. The default\n      value is 'rgb'\n    - the buffer format is how a color component is stored into memory. This can\n      be one of 'ubyte', 'ushort', 'uint', 'byte', 'short', 'int', 'float'. The\n      default value and the most commonly used is 'ubyte'.\n\nSo, if you want to create an RGBA texture::\n\n    texture = Texture.create(size=(640, 480), colorfmt='rgba')\n\nYou can use your texture in almost all vertex instructions with the\n:data:`kivy.graphics.VertexIntruction.texture` parameter. If you want to use\nyour texture in kv lang, you can save it in an\n:class:`~kivy.properties.ObjectProperty` inside your widget.\n\n\nBlitting custom data\n--------------------\n\nYou can create your own data and blit it on the texture using\n:func:`Texture.blit_data`::\n\n    # create a 64x64 texture, default to rgb / ubyte\n    texture = Texture.create(size=(64, 64))\n\n    # create 64x64 rgb tab, and fill with value from 0 to 255\n    # we'll have a gradient from black to white\n    size = 64 * 64 * 3\n    buf = [int(x * 255 / size) for x in xrange(size)]\n\n    # then, convert the array to a ubyte string\n    buf = ''.join(map(chr, buf))\n\n    # then blit the buffer\n    texture.blit_buffer(buf, colorfmt='rgb', bufferfmt='ubyte')\n\n    # that's all ! you can use it in your graphics now :)\n    # if self is a widget, you can do that\n    with self.canvas:\n        Rectangle""(texture=texture, pos=self.pos, size=(64, 64))\n\n\nBGR/BGRA support\n----------------\n\nThe first time you'll try to create a BGR or BGRA texture, we are checking if\nyour hardware support BGR / BGRA texture by checking the extension\n'GL_EXT_bgra'.\n\nIf the extension is not found, a conversion to RGB / RGBA will be done in\nsoftware.\n\n\nNPOT texture\n------------\n\n.. versionadded:: 1.0.7\n\n    If hardware can support NPOT, no POT are created.\n\nAs OpenGL documentation said, a texture must be power-of-two sized. That's mean\nyour width and height can be one of 64, 32, 256... but not 3, 68, 42. NPOT mean\nnon-power-of-two. OpenGL ES 2 support NPOT texture natively, but with some\ndrawbacks. Another type of NPOT texture are also called rectangle texture.\nPOT, NPOT and texture have their own pro/cons.\n\n================= ============= ============= =================================\n    Features           POT           NPOT                Rectangle\n----------------- ------------- ------------- ---------------------------------\nOpenGL Target     GL_TEXTURE_2D GL_TEXTURE_2D GL_TEXTURE_RECTANGLE_(NV|ARB|EXT)\nTexture coords    0-1 range     0-1 range     width-height range\nMipmapping        Supported     Partially     No\nWrap mode         Supported     Supported     No\n================= ============= ============= =================================\n\nIf you are creating a NPOT texture, we first are checking if your hardware is\ncapable of it by checking the extensions GL_ARB_texture_non_power_of_two or\nOES_texture_npot. If none of theses are availables, we are creating the nearest\nPOT texture that can contain your NPOT texture. The :func:`Texture.create` will\nreturn a :class:`TextureRegion` instead.\n\n\nTexture atlas\n-------------\n\nWe are calling texture atlas a texture that contain many images in it.\nIf you want to seperate the original texture into many single one, you don't\nneed to. You can get a region of the original texture. That will return"" you the\noriginal texture with custom texture coordinates::\n\n    # for example, load a 128x128 image that contain 4 64x64 images\n    from kivy.core.image import Image\n    texture = Image('mycombinedimage.png').texture\n\n    bottomleft = texture.get_region(0, 0, 64, 64)\n    bottomright = texture.get_region(0, 64, 64, 64)\n    topleft = texture.get_region(0, 64, 64, 64)\n    topright = texture.get_region(64, 64, 64, 64)\n\n\n.. _mipmap:\n\nMipmapping\n----------\n\n.. versionadded:: 1.0.7\n\nMipmapping is an OpenGL technique for enhancing the rendering of large texture\nto small surface. Without mipmapping, you might seen pixels when you are\nrendering to small surface.\nThe idea is to precalculate subtexture and apply some image filter, as linear\nfilter. Then, when you rendering a small surface, instead of using the biggest\ntexture, it will use a lower filtered texture. The result can look better with\nthat way.\n\nTo make that happen, you need to specify mipmap=True when you're creating a\ntexture. Some widget already give you the possibility to create mipmapped\ntexture like :class:`~kivy.uix.label.Label` or :class:`~kivy.uix.image.Image`.\n\nFrom the OpenGL Wiki : \"So a 64x16 2D texture can have 5 mip-maps: 32x8, 16x4,\n8x2, 4x1, 2x1, and 1x1\". Check http://www.opengl.org/wiki/Texture for more\ninformation.\n\n.. note::\n\n    As the table in previous section said, if your texture is NPOT, we are\n    actually creating the nearest POT texture and generate mipmap on it. This\n    might change in the future.\n\nReloading the Texture\n---------------------\n\n.. versionadded:: 1.2.0\n\nIf the OpenGL context is lost, the Texture must be reloaded. Texture having a\nsource are automatically reloaded without any help. But generated textures must\nbe reloaded by the user.\n\nUse the :func:`Texture.add_reload_observer` to add a reloading function that will be\nautomatically called when needed::\n\n    def __init__(self, **kwargs):\n        super(...).__init__(**""kwargs)\n        self.texture = Texture.create(size=(512, 512), colorfmt='RGB',\n            bufferfmt='ubyte')\n        self.texture.add_reload_observer(self.populate_texture)\n\n        # and load the data now.\n        self.cbuffer = '\000\303\260\303\277' * 512 * 512\n        self.populate_texture(self.texture)\n\n    def populate_texture(self, texture):\n        texture.blit_buffer(self.cbuffer)\n\nThis way, you could use the same method for initialization and for reloading.\n\n.. note::\n\n    For all text rendering with our core text renderer, texture is generated,\n    but we are binding already a method to redo the text rendering and reupload\n    the text to the texture. You have nothing to do on that case.\n";
static char __pyx_k_43[] = "kivy.weakmethod";
static char __pyx_k_44[] = "nearest_mipmap_nearest";
static char __pyx_k_45[] = "nearest_mipmap_linear";
static char __pyx_k_46[] = "linear_mipmap_linear";
static char __pyx_k_49[] = "c:\\Users\\tito\\Desktop\\Kivy-1.4.0-w32\\kivy\\Kivy-1.4.1-w32\\Kivy-1.4.1\\kivy\\graphics\\texture.pyx";
static char __pyx_k_50[] = "kivy.graphics.texture";
static char __pyx_k_53[] = "texture_create_from_data";
static char __pyx_k__b[] = "b";
static char __pyx_k__x[] = "x";
static char __pyx_k__y[] = "y";
static char __pyx_k__id[] = "id";
static char __pyx_k__im[] = "im";
static char __pyx_k__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__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__Image[] = "Image";
static char __pyx_k__array[] = "array";
static char __pyx_k__float[] = "float";
static char __pyx_k__lower[] = "lower";
static char __pyx_k__short[] = "short";
static char __pyx_k__texid[] = "texid";
static char __pyx_k__ubyte[] = "ubyte";
static char __pyx_k__width[] = "width";
static char __pyx_k__create[] = "create";
static char __pyx_k__format[] = "format";
static char __pyx_k__height[] = "height";
static char __pyx_k__linear[] = "linear";
static char __pyx_k__mipmap[] = "mipmap";
static char __pyx_k__origin[] = "origin";
static char __pyx_k__remove[] = "remove";
static char __pyx_k__repeat[] = "repeat";
static char __pyx_k__source[] = "source";
static char __pyx_k__target[] = "target";
static char __pyx_k__ushort[] = "ushort";
static char __pyx_k__Texture[] = "Texture";
static char __pyx_k____all__[] = "__all__";
static char __pyx_k__is_dead[] = "is_dead";
static char __pyx_k__nearest[] = "nearest";
static char __pyx_k__no_blit[] = "no_blit";
static char __pyx_k__nocache[] = "nocache";
static char __pyx_k__pbuffer[] = "pbuffer";
static char __pyx_k__texture[] = "texture";
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__allocate[] = "allocate";
static char __pyx_k__colorfmt[] = "colorfmt";
static char __pyx_k__s3tc_dxt[] = "s3tc_dxt";
static char __pyx_k__tostring[] = "tostring";
static char __pyx_k__Exception[] = "Exception";
static char __pyx_k__blit_data[] = "blit_data";
static char __pyx_k__bufferfmt[] = "bufferfmt";
static char __pyx_k__luminance[] = "luminance";
static char __pyx_k__s3tc_dxt1[] = "s3tc_dxt1";
static char __pyx_k__s3tc_dxt3[] = "s3tc_dxt3";
static char __pyx_k__s3tc_dxt5[] = "s3tc_dxt5";
static char __pyx_k__GLCAP_BGRA[] = "GLCAP_BGRA";
static char __pyx_k__GLCAP_DXT1[] = "GLCAP_DXT1";
static char __pyx_k__GLCAP_NPOT[] = "GLCAP_NPOT";
static char __pyx_k__GLCAP_S3TC[] = "GLCAP_S3TC";
static char __pyx_k__WeakMethod[] = "WeakMethod";
static char __pyx_k__get_region[] = "get_region";
static char __pyx_k__mag_filter[] = "mag_filter";
static char __pyx_k__min_filter[] = "min_filter";
static char __pyx_k__blit_buffer[] = "blit_buffer";
static char __pyx_k__have_mipmap[] = "have_mipmap";
static char __pyx_k__mipmap_level[] = "mipmap_level";
static char __pyx_k__staticmethod[] = "staticmethod";
static char __pyx_k__TextureRegion[] = "TextureRegion";
static char __pyx_k__clamp_to_edge[] = "clamp_to_edge";
static char __pyx_k__flip_vertical[] = "flip_vertical";
static char __pyx_k__texture_create[] = "texture_create";
static char __pyx_k__iterate_mipmaps[] = "iterate_mipmaps";
static char __pyx_k__luminance_alpha[] = "luminance_alpha";
static char __pyx_k__mirrored_repeat[] = "mirrored_repeat";
static char __pyx_k__create_from_data[] = "create_from_data";
static char __pyx_k__mipmap_generation[] = "mipmap_generation";
static PyObject *__pyx_kp_s_1;
static PyObject *__pyx_kp_s_16;
static PyObject *__pyx_n_s_17;
static PyObject *__pyx_kp_s_18;
static PyObject *__pyx_kp_s_2;
static PyObject *__pyx_n_s_24;
static PyObject *__pyx_kp_s_25;
static PyObject *__pyx_kp_s_26;
static PyObject *__pyx_kp_s_3;
static PyObject *__pyx_kp_s_4;
static PyObject *__pyx_n_s_43;
static PyObject *__pyx_n_s_44;
static PyObject *__pyx_n_s_45;
static PyObject *__pyx_n_s_46;
static PyObject *__pyx_kp_s_49;
static PyObject *__pyx_kp_s_5;
static PyObject *__pyx_n_s_50;
static PyObject *__pyx_n_s_53;
static PyObject *__pyx_kp_s_6;
static PyObject *__pyx_kp_s_7;
static PyObject *__pyx_n_s__Exception;
static PyObject *__pyx_n_s__GLCAP_BGRA;
static PyObject *__pyx_n_s__GLCAP_DXT1;
static PyObject *__pyx_n_s__GLCAP_NPOT;
static PyObject *__pyx_n_s__GLCAP_S3TC;
static PyObject *__pyx_n_s__Image;
static PyObject *__pyx_n_s__KeyError;
static PyObject *__pyx_n_s__Texture;
static PyObject *__pyx_n_s__TextureRegion;
static PyObject *__pyx_n_s__WeakMethod;
static PyObject *__pyx_n_s____all__;
static PyObject *__pyx_n_s____init__;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s__allocate;
static PyObject *__pyx_n_s__array;
static PyObject *__pyx_n_s__b;
static PyObject *__pyx_n_s__bgr;
static PyObject *__pyx_n_s__bgra;
static PyObject *__pyx_n_s__bind;
static PyObject *__pyx_n_s__blit_buffer;
static PyObject *__pyx_n_s__blit_data;
static PyObject *__pyx_n_s__bufferfmt;
static PyObject *__pyx_n_s__byte;
static PyObject *__pyx_n_s__clamp_to_edge;
static PyObject *__pyx_n_s__colorfmt;
static PyObject *__pyx_n_s__create;
static PyObject *__pyx_n_s__create_from_data;
static PyObject *__pyx_n_s__data;
static PyObject *__pyx_n_s__flip_vertical;
static PyObject *__pyx_n_s__float;
static PyObject *__pyx_n_s__fmt;
static PyObject *__pyx_n_s__format;
static PyObject *__pyx_n_s__get_region;
static PyObject *__pyx_n_s__have_mipmap;
static PyObject *__pyx_n_s__height;
static PyObject *__pyx_n_s__id;
static PyObject *__pyx_n_s__im;
static PyObject *__pyx_n_s__int;
static PyObject *__pyx_n_s__is_dead;
static PyObject *__pyx_n_s__iterate_mipmaps;
static PyObject *__pyx_n_s__linear;
static PyObject *__pyx_n_s__lower;
static PyObject *__pyx_n_s__luminance;
static PyObject *__pyx_n_s__luminance_alpha;
static PyObject *__pyx_n_s__mag_filter;
static PyObject *__pyx_n_s__min_filter;
static PyObject *__pyx_n_s__mipmap;
static PyObject *__pyx_n_s__mipmap_generation;
static PyObject *__pyx_n_s__mipmap_level;
static PyObject *__pyx_n_s__mirrored_repeat;
static PyObject *__pyx_n_s__nearest;
static PyObject *__pyx_n_s__no_blit;
static PyObject *__pyx_n_s__nocache;
static PyObject *__pyx_n_s__origin;
static PyObject *__pyx_n_s__pbuffer;
static PyObject *__pyx_n_s__pos;
static PyObject *__pyx_n_s__remove;
static PyObject *__pyx_n_s__repeat;
static PyObject *__pyx_n_s__rgb;
static PyObject *__pyx_n_s__rgba;
static PyObject *__pyx_n_s__s3tc_dxt;
static PyObject *__pyx_n_s__s3tc_dxt1;
static PyObject *__pyx_n_s__s3tc_dxt3;
static PyObject *__pyx_n_s__s3tc_dxt5;
static PyObject *__pyx_n_s__short;
static PyObject *__pyx_n_s__size;
static PyObject *__pyx_n_s__source;
static PyObject *__pyx_n_s__staticmethod;
static PyObject *__pyx_n_s__target;
static PyObject *__pyx_n_s__texid;
static PyObject *__pyx_n_s__texture;
static PyObject *__pyx_n_s__texture_create;
static PyObject *__pyx_n_s__tostring;
static PyObject *__pyx_n_s__ubyte;
static PyObject *__pyx_n_s__uint;
static PyObject *__pyx_n_s__ushort;
static PyObject *__pyx_n_s__width;
static PyObject *__pyx_n_s__wrap;
static PyObject *__pyx_n_s__x;
static PyObject *__pyx_n_s__y;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_2;
static PyObject *__pyx_int_3;
static PyObject *__pyx_int_4;
static PyObject *__pyx_k_19;
static PyObject *__pyx_k_20;
static PyObject *__pyx_k_21;
static PyObject *__pyx_k_22;
static PyObject *__pyx_k_slice_8;
static PyObject *__pyx_k_slice_9;
static PyObject *__pyx_k_slice_10;
static PyObject *__pyx_k_slice_11;
static PyObject *__pyx_k_slice_12;
static PyObject *__pyx_k_slice_13;
static PyObject *__pyx_k_slice_14;
static PyObject *__pyx_k_slice_15;
static PyObject *__pyx_k_tuple_23;
static PyObject *__pyx_k_tuple_42;
static PyObject *__pyx_k_tuple_47;
static PyObject *__pyx_k_tuple_51;
static PyObject *__pyx_k_codeobj_48;
static PyObject *__pyx_k_codeobj_52;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  /* "kivy\graphics\texture.pyx":252
 *     '''Return the GL numeric value from a color string format
 *     '''
 *     x = x.lower()             # <<<<<<<<<<<<<<
 *     try:
 *         return _gl_color_fmt[x]
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_x), __pyx_n_s__lower); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __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 = 252; __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 = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_v_x));
  __pyx_v_x = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

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

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

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

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

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

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

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

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

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

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

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

  /* "kivy\graphics\texture.pyx":268
 *     '''Return the GL numeric value from a buffer string format
 *     '''
 *     x = x.lower()             # <<<<<<<<<<<<<<
 *     try:
 *         return _gl_buffer_fmt[x]
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_x), __pyx_n_s__lower); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __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 = 268; __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 = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_v_x));
  __pyx_v_x = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

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

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

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

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

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

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

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

  /* "kivy\graphics\texture.pyx":278
 *     '''Return the size of a buffer string format in bytes
 *     '''
 *     x = x.lower()             # <<<<<<<<<<<<<<
 *     try:
 *         return _gl_buffer_size[x]
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_x), __pyx_n_s__lower); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 278; __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 = 278; __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 = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_v_x));
  __pyx_v_x = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

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

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

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

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

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

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

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

  /* "kivy\graphics\texture.pyx":288
 *     '''Return the GL numeric value from a texture min filter string
 *     '''
 *     x = x.lower()             # <<<<<<<<<<<<<<
 *     try:
 *         return _gl_texture_min_filter[x]
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_x), __pyx_n_s__lower); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __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 = 288; __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 = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_v_x));
  __pyx_v_x = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    /* "kivy\graphics\texture.pyx":363
 *     # no native support, can we at least convert it ?
 *     if not gl_has_texture_conversion(fmt):
 *         raise Exception('Unimplemented texture conversion for %s' % fmt)             # <<<<<<<<<<<<<<
 * 
 *     # do appropriate conversion, since we accepted it
 */
    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_7), ((PyObject *)__pyx_v_fmt)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __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 = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__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 = 363; __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, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L4;
  }
  __pyx_L4:;

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

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

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

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

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

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

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

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

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

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

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

    /* "kivy\graphics\texture.pyx":381
 *         a = array('b', data)
 *         a[0::4], a[2::4] = a[2::4], a[0::4]
 *         ret_buffer = a.tostring()             # <<<<<<<<<<<<<<
 * 
 *     else:
 */
    __pyx_t_4 = PyObject_GetAttr(__pyx_v_a, __pyx_n_s__tostring); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 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 = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(((PyObject *)__pyx_v_ret_buffer));
    __pyx_v_ret_buffer = ((PyObject*)__pyx_t_2);
    __pyx_t_2 = 0;
    goto __pyx_L5;
  }
  /*else*/ {

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

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

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

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

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

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

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

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

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

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

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

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

}

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

static struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_f_4kivy_8graphics_7texture__texture_create(int __pyx_v_width, int __pyx_v_height, PyObject *__pyx_v_colorfmt, PyObject *__pyx_v_bufferfmt, int __pyx_v_mipmap, int __pyx_v_allocate) {
  GLuint __pyx_v_target;
  GLuint __pyx_v_texid;
  struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_texture = 0;
  int __pyx_v_texture_width;
  int __pyx_v_texture_height;
  int __pyx_v_glbufferfmt;
  int __pyx_v_make_npot;
  int __pyx_v_glfmt;
  int __pyx_v_iglbufferfmt;
  int __pyx_v_datasize;
  int __pyx_v_dataerr;
  void *__pyx_v_data;
  struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __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;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_texture_create", 0);
  __Pyx_INCREF(__pyx_v_colorfmt);

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

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

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

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

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

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

  /* "kivy\graphics\texture.pyx":416
 * 
 *     # check if it's a pot or not
 *     if not _is_pow2(width) or not _is_pow2(height):             # <<<<<<<<<<<<<<
 *         make_npot = 1
 * 
 */
  __pyx_t_1 = (!__pyx_f_4kivy_8graphics_7texture__is_pow2(__pyx_v_width));
  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) {

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

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

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

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

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

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

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

    /* "kivy\graphics\texture.pyx":433
 *     else:
 *         texture_width = _nearest_pow2(width)
 *         texture_height = _nearest_pow2(height)             # <<<<<<<<<<<<<<
 * 
 *     # generate the texture
 */
    __pyx_v_texture_height = __pyx_f_4kivy_8graphics_7texture__nearest_pow2(__pyx_v_height);
  }
  __pyx_L5:;

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

  /* "kivy\graphics\texture.pyx":440
 *     # if the color format is not supported, create the texture with the future
 *     # color format.
 *     if not _is_gl_format_supported(colorfmt):             # <<<<<<<<<<<<<<
 *         colorfmt = _convert_gl_format(colorfmt)
 * 
 */
  __pyx_t_3 = (!__pyx_f_4kivy_8graphics_7texture__is_gl_format_supported(__pyx_v_colorfmt));
  if (__pyx_t_3) {

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

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

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

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

  /* "kivy\graphics\texture.pyx":448
 *     # set default parameter for this texture
 *     texture.bind()
 *     texture.set_wrap('clamp_to_edge')             # <<<<<<<<<<<<<<
 *     if mipmap:
 *         texture.set_min_filter('linear_mipmap_nearest')
 */
  __pyx_t_7 = ((PyObject *)__pyx_n_s__clamp_to_edge);
  __Pyx_INCREF(__pyx_t_7);
  ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_texture->__pyx_vtab)->set_wrap(__pyx_v_texture, ((PyObject*)__pyx_t_7));
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

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

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

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

    /* "kivy\graphics\texture.pyx":453
 *         texture.set_mag_filter('linear')
 *     else:
 *         texture.set_min_filter('linear')             # <<<<<<<<<<<<<<
 *         texture.set_mag_filter('linear')
 * 
 */
    __pyx_t_7 = ((PyObject *)__pyx_n_s__linear);
    __Pyx_INCREF(__pyx_t_7);
    ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_texture->__pyx_vtab)->set_min_filter(__pyx_v_texture, ((PyObject*)__pyx_t_7));
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "kivy\graphics\texture.pyx":454
 *     else:
 *         texture.set_min_filter('linear')
 *         texture.set_mag_filter('linear')             # <<<<<<<<<<<<<<
 * 
 *     # if allocation if wanted, do it now
 */
    __pyx_t_7 = ((PyObject *)__pyx_n_s__linear);
    __Pyx_INCREF(__pyx_t_7);
    ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_texture->__pyx_vtab)->set_mag_filter(__pyx_v_texture, ((PyObject*)__pyx_t_7));
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  }
  __pyx_L7:;

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

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

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

    /* "kivy\graphics\texture.pyx":463
 *         iglbufferfmt = glbufferfmt
 *         datasize = texture_width * texture_height * \
 *                 _gl_format_size(glfmt) * _buffer_type_to_gl_size(bufferfmt)             # <<<<<<<<<<<<<<
 * 
 *         # act as we have been able to allocate the texture
 */
    __pyx_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));

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  /* "kivy\graphics\texture.pyx":495
 *     # if the texture size is the same as initial size, return the texture
 *     # unmodified
 *     if texture_width == width and texture_height == height:             # <<<<<<<<<<<<<<
 *         return texture
 * 
 */
  __pyx_t_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) {

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

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

  __pyx_r = ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_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_create", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_texture);
  __Pyx_XDECREF(__pyx_v_colorfmt);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  /* "kivy\graphics\texture.pyx":531
 *     '''Create a texture from an ImageData class
 *     '''
 *     cdef int width = im.width             # <<<<<<<<<<<<<<
 *     cdef int height = im.height
 *     cdef int allocate = 1
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_im, __pyx_n_s__width); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 531; __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 = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_width = __pyx_t_2;

  /* "kivy\graphics\texture.pyx":532
 *     '''
 *     cdef int width = im.width
 *     cdef int height = im.height             # <<<<<<<<<<<<<<
 *     cdef int allocate = 1
 *     cdef int no_blit = 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 = 532; __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 = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_height = __pyx_t_2;

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

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

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

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

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

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

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

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

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

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

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

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

  /* "kivy\graphics\texture.pyx":556
 *         allocate = 1
 *         no_blit = 1
 *     texture = _texture_create(width, height, im.fmt, 'ubyte', mipmap, allocate)             # <<<<<<<<<<<<<<
 *     if texture is None:
 *         return None
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_im, __pyx_n_s__fmt); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __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 = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_7 = ((PyObject *)__pyx_n_s__ubyte);
  __Pyx_INCREF(__pyx_t_7);
  __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_v_mipmap); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_t_8 = ((PyObject *)__pyx_f_4kivy_8graphics_7texture__texture_create(__pyx_v_width, __pyx_v_height, ((PyObject*)__pyx_t_1), ((PyObject*)__pyx_t_7), __pyx_t_2, __pyx_v_allocate)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_v_texture = ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_t_8);
  __pyx_t_8 = 0;

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

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

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

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

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

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

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

/* Python wrapper */
static int __pyx_pw_4kivy_8graphics_7texture_7Texture_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pw_4kivy_8graphics_7texture_7Texture_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_width = 0;
  PyObject *__pyx_v_height = 0;
  PyObject *__pyx_v_target = 0;
  PyObject *__pyx_v_texid = 0;
  PyObject *__pyx_v_colorfmt = 0;
  PyObject *__pyx_v_bufferfmt = 0;
  PyObject *__pyx_v_mipmap = 0;
  PyObject *__pyx_v_source = 0;
  int __pyx_r;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  {
    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__width,&__pyx_n_s__height,&__pyx_n_s__target,&__pyx_n_s__texid,&__pyx_n_s__colorfmt,&__pyx_n_s__bufferfmt,&__pyx_n_s__mipmap,&__pyx_n_s__source,0};
    PyObject* values[8] = {0,0,0,0,0,0,0,0};
    values[4] = ((PyObject *)__pyx_n_s__rgb);
    values[5] = ((PyObject *)__pyx_n_s__ubyte);
    values[6] = __pyx_k_21;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  /* "kivy\graphics\texture.pyx":593
 *         self._bufferfmt     = bufferfmt
 *         self._source        = source
 *         self._nofree        = 0             # <<<<<<<<<<<<<<
 *         self.update_tex_coords()
 *         get_context().register_texture(self)
 */
  __pyx_v_self->_nofree = 0;

  /* "kivy\graphics\texture.pyx":594
 *         self._source        = source
 *         self._nofree        = 0
 *         self.update_tex_coords()             # <<<<<<<<<<<<<<
 *         get_context().register_texture(self)
 * 
 */
  ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_self->__pyx_vtab)->update_tex_coords(__pyx_v_self);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  __Pyx_RefNannyFinishContext();
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/* "kivy\graphics\texture.pyx":640
 *         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_pw_4kivy_8graphics_7texture_7Texture_11get_region(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_4kivy_8graphics_7texture_7Texture_get_region(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x, PyObject *__pyx_v_y, PyObject *__pyx_v_width, PyObject *__pyx_v_height, int __pyx_skip_dispatch) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_region", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if 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 = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_7Texture_11get_region)) {
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      __Pyx_INCREF(__pyx_v_y);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_y);
      __Pyx_GIVEREF(__pyx_v_y);
      __Pyx_INCREF(__pyx_v_width);
      PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_width);
      __Pyx_GIVEREF(__pyx_v_width);
      __Pyx_INCREF(__pyx_v_height);
      PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_height);
      __Pyx_GIVEREF(__pyx_v_height);
      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "kivy\graphics\texture.pyx":643
 *         '''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 = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_x);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_x);
  __Pyx_GIVEREF(__pyx_v_x);
  __Pyx_INCREF(__pyx_v_y);
  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_y);
  __Pyx_GIVEREF(__pyx_v_y);
  __Pyx_INCREF(__pyx_v_width);
  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_width);
  __Pyx_GIVEREF(__pyx_v_width);
  __Pyx_INCREF(__pyx_v_height);
  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_height);
  __Pyx_GIVEREF(__pyx_v_height);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_4kivy_8graphics_7texture_TextureRegion)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

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

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

/* "kivy\graphics\texture.pyx":640
 *         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_10get_region(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x, PyObject *__pyx_v_y, PyObject *__pyx_v_width, PyObject *__pyx_v_height) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_region", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_self->__pyx_vtab)->get_region(__pyx_v_self, __pyx_v_x, __pyx_v_y, __pyx_v_width, __pyx_v_height, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

/* "kivy\graphics\texture.pyx":645
 *         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_pw_4kivy_8graphics_7texture_7Texture_13bind(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;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("bind", 0);
  /* Check if called by wrapper */
  if (unlikely(__pyx_skip_dispatch)) ;
  /* Check if 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 = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_1);
    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_7Texture_13bind)) {
      __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 = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_r = __pyx_t_2;
      __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }

  /* "kivy\graphics\texture.pyx":647
 *     cpdef bind(self):
 *         '''Bind the texture to current opengl state'''
 *         glBindTexture(self._target, self._id)             # <<<<<<<<<<<<<<
 * 
 *     cdef void set_min_filter(self, str x):
 */
  glBindTexture(__pyx_v_self->_target, __pyx_v_self->_id);

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

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

/* "kivy\graphics\texture.pyx":645
 *         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_12bind(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("bind", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_self->__pyx_vtab)->bind(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

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

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

static void __pyx_f_4kivy_8graphics_7texture_7Texture_set_min_filter(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x) {
  GLuint __pyx_v__value;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_min_filter", 0);

  /* "kivy\graphics\texture.pyx":650
 * 
 *     cdef void set_min_filter(self, str x):
 *         cdef GLuint _value = _str_to_gl_texture_min_filter(x)             # <<<<<<<<<<<<<<
 *         glTexParameteri(self._target, GL_TEXTURE_MIN_FILTER, _value)
 *         self._min_filter = x
 */
  __pyx_v__value = __pyx_f_4kivy_8graphics_7texture__str_to_gl_texture_min_filter(__pyx_v_x);

  /* "kivy\graphics\texture.pyx":651
 *     cdef void set_min_filter(self, str x):
 *         cdef GLuint _value = _str_to_gl_texture_min_filter(x)
 *         glTexParameteri(self._target, GL_TEXTURE_MIN_FILTER, _value)             # <<<<<<<<<<<<<<
 *         self._min_filter = x
 * 
 */
  glTexParameteri(__pyx_v_self->_target, GL_TEXTURE_MIN_FILTER, __pyx_v__value);

  /* "kivy\graphics\texture.pyx":652
 *         cdef GLuint _value = _str_to_gl_texture_min_filter(x)
 *         glTexParameteri(self._target, GL_TEXTURE_MIN_FILTER, _value)
 *         self._min_filter = x             # <<<<<<<<<<<<<<
 * 
 *     cdef void set_mag_filter(self, str x):
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_x));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_x));
  __Pyx_GOTREF(__pyx_v_self->_min_filter);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->_min_filter));
  __pyx_v_self->_min_filter = __pyx_v_x;

  __Pyx_RefNannyFinishContext();
}

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

static void __pyx_f_4kivy_8graphics_7texture_7Texture_set_mag_filter(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x) {
  GLuint __pyx_v__value;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_mag_filter", 0);

  /* "kivy\graphics\texture.pyx":655
 * 
 *     cdef void set_mag_filter(self, str x):
 *         cdef GLuint _value = _str_to_gl_texture_mag_filter(x)             # <<<<<<<<<<<<<<
 *         glTexParameteri(self._target, GL_TEXTURE_MAG_FILTER, _value)
 *         self._mag_filter = x
 */
  __pyx_v__value = __pyx_f_4kivy_8graphics_7texture__str_to_gl_texture_mag_filter(__pyx_v_x);

  /* "kivy\graphics\texture.pyx":656
 *     cdef void set_mag_filter(self, str x):
 *         cdef GLuint _value = _str_to_gl_texture_mag_filter(x)
 *         glTexParameteri(self._target, GL_TEXTURE_MAG_FILTER, _value)             # <<<<<<<<<<<<<<
 *         self._mag_filter = x
 * 
 */
  glTexParameteri(__pyx_v_self->_target, GL_TEXTURE_MAG_FILTER, __pyx_v__value);

  /* "kivy\graphics\texture.pyx":657
 *         cdef GLuint _value = _str_to_gl_texture_mag_filter(x)
 *         glTexParameteri(self._target, GL_TEXTURE_MAG_FILTER, _value)
 *         self._mag_filter = x             # <<<<<<<<<<<<<<
 * 
 *     cdef void set_wrap(self, str x):
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_x));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_x));
  __Pyx_GOTREF(__pyx_v_self->_mag_filter);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->_mag_filter));
  __pyx_v_self->_mag_filter = __pyx_v_x;

  __Pyx_RefNannyFinishContext();
}

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

static void __pyx_f_4kivy_8graphics_7texture_7Texture_set_wrap(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self, PyObject *__pyx_v_x) {
  GLuint __pyx_v__value;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_wrap", 0);

  /* "kivy\graphics\texture.pyx":660
 * 
 *     cdef void set_wrap(self, str x):
 *         cdef GLuint _value = _str_to_gl_texture_wrap(x)             # <<<<<<<<<<<<<<
 *         glTexParameteri(self._target, GL_TEXTURE_WRAP_S, _value)
 *         glTexParameteri(self._target, GL_TEXTURE_WRAP_T, _value)
 */
  __pyx_v__value = __pyx_f_4kivy_8graphics_7texture__str_to_gl_texture_wrap(__pyx_v_x);

  /* "kivy\graphics\texture.pyx":661
 *     cdef void set_wrap(self, str x):
 *         cdef GLuint _value = _str_to_gl_texture_wrap(x)
 *         glTexParameteri(self._target, GL_TEXTURE_WRAP_S, _value)             # <<<<<<<<<<<<<<
 *         glTexParameteri(self._target, GL_TEXTURE_WRAP_T, _value)
 *         self._wrap = x
 */
  glTexParameteri(__pyx_v_self->_target, GL_TEXTURE_WRAP_S, __pyx_v__value);

  /* "kivy\graphics\texture.pyx":662
 *         cdef GLuint _value = _str_to_gl_texture_wrap(x)
 *         glTexParameteri(self._target, GL_TEXTURE_WRAP_S, _value)
 *         glTexParameteri(self._target, GL_TEXTURE_WRAP_T, _value)             # <<<<<<<<<<<<<<
 *         self._wrap = x
 * 
 */
  glTexParameteri(__pyx_v_self->_target, GL_TEXTURE_WRAP_T, __pyx_v__value);

  /* "kivy\graphics\texture.pyx":663
 *         glTexParameteri(self._target, GL_TEXTURE_WRAP_S, _value)
 *         glTexParameteri(self._target, GL_TEXTURE_WRAP_T, _value)
 *         self._wrap = x             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_x));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_x));
  __Pyx_GOTREF(__pyx_v_self->_wrap);
  __Pyx_DECREF(((PyObject *)__pyx_v_self->_wrap));
  __pyx_v_self->_wrap = __pyx_v_x;

  __Pyx_RefNannyFinishContext();
}

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

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

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

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

  /* "kivy\graphics\texture.pyx":672
 * 
 *         # depending if imagedata have mipmap, think different.
 *         if not im.have_mipmap:             # <<<<<<<<<<<<<<
 *             blit(im.data, size=im.size, colorfmt=im.fmt, pos=pos)
 *         else:
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_im, __pyx_n_s__have_mipmap); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; __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 = 672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = (!__pyx_t_2);
  if (__pyx_t_3) {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          /* "kivy\graphics\texture.pyx":748
 *                 glTexImage2D(target, _mipmap_level, glfmt, w, h, 0, glfmt, glbufferfmt, cdata)
 *             if _mipmap_generation:
 *                 glGenerateMipmap(target)             # <<<<<<<<<<<<<<
 * 
 *     cdef void reload(self):
 */
          glGenerateMipmap(__pyx_v_target);
          goto __pyx_L13;
        }
        __pyx_L13:;
      }

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

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

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

static void __pyx_f_4kivy_8graphics_7texture_7Texture_reload(struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_self) {
  struct __pyx_obj_4kivy_8graphics_7texture_Texture *__pyx_v_texture = 0;
  PyObject *__pyx_v_Image = NULL;
  PyObject *__pyx_v_image = NULL;
  PyObject *__pyx_v_callback = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  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;
  GLuint __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("reload", 0);

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

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

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

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

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

    /* "kivy\graphics\texture.pyx":758
 *             texture = texture_create(self.size, self.colorfmt, self.bufferfmt,
 *                     self.mipmap)
 *             self._id = texture.id             # <<<<<<<<<<<<<<
 *         else:
 *             from kivy.core.image import Image
 */
    __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_texture), __pyx_n_s__id); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = __Pyx_PyInt_from_py_GLuint(__pyx_t_6); if (unlikely((__pyx_t_8 == (GLuint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_self->_id = __pyx_t_8;
    goto __pyx_L4;
  }
  /*else*/ {

    /* "kivy\graphics\texture.pyx":760
 *             self._id = texture.id
 *         else:
 *             from kivy.core.image import Image             # <<<<<<<<<<<<<<
 *             image = Image(self._source, nocache=True)
 *             self._id = image.texture.id
 */
    __pyx_t_6 = PyList_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(((PyObject *)__pyx_n_s__Image));
    PyList_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_n_s__Image));
    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Image));
    __pyx_t_7 = __Pyx_Import(((PyObject *)__pyx_n_s_24), ((PyObject *)__pyx_t_6), -1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__Image);
    if (__pyx_t_6 == NULL) {
      if (PyErr_ExceptionMatches(PyExc_AttributeError)) __Pyx_RaiseImportError(__pyx_n_s__Image);
      if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_6);
    __pyx_v_Image = __pyx_t_6;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

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

    /* "kivy\graphics\texture.pyx":762
 *             from kivy.core.image import Image
 *             image = Image(self._source, nocache=True)
 *             self._id = image.texture.id             # <<<<<<<<<<<<<<
 *             texture = image.texture
 *             texture._nofree = 1
 */
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_image, __pyx_n_s__texture); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__id); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_8 = __Pyx_PyInt_from_py_GLuint(__pyx_t_6); if (unlikely((__pyx_t_8 == (GLuint)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_v_self->_id = __pyx_t_8;

    /* "kivy\graphics\texture.pyx":763
 *             image = Image(self._source, nocache=True)
 *             self._id = image.texture.id
 *             texture = image.texture             # <<<<<<<<<<<<<<
 *             texture._nofree = 1
 * 
 */
    __pyx_t_6 = PyObject_GetAttr(__pyx_v_image, __pyx_n_s__texture); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_6);
    if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_4kivy_8graphics_7texture_Texture))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __pyx_v_texture = ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)__pyx_t_6);
    __pyx_t_6 = 0;

    /* "kivy\graphics\texture.pyx":764
 *             self._id = image.texture.id
 *             texture = image.texture
 *             texture._nofree = 1             # <<<<<<<<<<<<<<
 * 
 *         # ensure the new opengl ID will not get through GC
 */
    __pyx_v_texture->_nofree = 1;
  }
  __pyx_L4:;

  /* "kivy\graphics\texture.pyx":767
 * 
 *         # ensure the new opengl ID will not get through GC
 *         texture._nofree = 1             # <<<<<<<<<<<<<<
 * 
 *         # set the same parameters as our current texture
 */
  __pyx_v_texture->_nofree = 1;

  /* "kivy\graphics\texture.pyx":770
 * 
 *         # set the same parameters as our current texture
 *         texture.bind()             # <<<<<<<<<<<<<<
 *         texture.set_wrap(self.wrap)
 *         texture.set_min_filter(self.min_filter)
 */
  __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 = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

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

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

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

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

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

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

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

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

  goto __pyx_L0;
  __pyx_L1_error:;
  __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_WriteUnraisable("kivy.graphics.texture.Texture.reload", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF((PyObject *)__pyx_v_texture);
  __Pyx_XDECREF(__pyx_v_Image);
  __Pyx_XDECREF(__pyx_v_image);
  __Pyx_XDECREF(__pyx_v_callback);
  __Pyx_RefNannyFinishContext();
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  /* "kivy\graphics\texture.pyx":892
 *         def __set__(self, str x):
 *             cdef GLuint value
 *             if x == self._min_filter:             # <<<<<<<<<<<<<<
 *                 return
 *             self.bind()
 */
  __pyx_t_1 = __Pyx_PyString_Equals(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_self->_min_filter), Py_EQ); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

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

  /* "kivy\graphics\texture.pyx":894
 *             if x == self._min_filter:
 *                 return
 *             self.bind()             # <<<<<<<<<<<<<<
 *             self.set_min_filter(x)
 * 
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_self->__pyx_vtab)->bind(__pyx_v_self, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

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

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

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

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

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

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

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

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

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

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

  /* "kivy\graphics\texture.pyx":909
 *             return self._mag_filter
 *         def __set__(self, str x):
 *             if x == self._mag_filter:             # <<<<<<<<<<<<<<
 *                 return
 *             self.bind()
 */
  __pyx_t_1 = __Pyx_PyString_Equals(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_self->_mag_filter), Py_EQ); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

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

  /* "kivy\graphics\texture.pyx":911
 *             if x == self._mag_filter:
 *                 return
 *             self.bind()             # <<<<<<<<<<<<<<
 *             self.set_mag_filter(x)
 * 
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_self->__pyx_vtab)->bind(__pyx_v_self, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

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

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

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

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

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

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

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

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

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

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

  /* "kivy\graphics\texture.pyx":927
 *             return self._wrap
 *         def __set__(self, str wrap):
 *             if wrap == self._wrap:             # <<<<<<<<<<<<<<
 *                 return
 *             self.bind()
 */
  __pyx_t_1 = __Pyx_PyString_Equals(((PyObject *)__pyx_v_wrap), ((PyObject *)__pyx_v_self->_wrap), Py_EQ); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

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

  /* "kivy\graphics\texture.pyx":929
 *             if wrap == self._wrap:
 *                 return
 *             self.bind()             # <<<<<<<<<<<<<<
 *             self.set_wrap(wrap)
 * 
 */
  __pyx_t_2 = ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_self->__pyx_vtab)->bind(__pyx_v_self, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "kivy\graphics\texture.pyx":930
 *                 return
 *             self.bind()
 *             self.set_wrap(wrap)             # <<<<<<<<<<<<<<
 * 
 * cdef class TextureRegion(Texture):
 */
  ((struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture *)__pyx_v_self->__pyx_vtab)->set_wrap(__pyx_v_self, __pyx_v_wrap);

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

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

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

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

  /* "kivy\graphics\texture.pyx":937
 * 
 *     def __init__(self, int x, int y, int width, int height, Texture origin):
 *         Texture.__init__(self, width, height, origin.target, origin.id)             # <<<<<<<<<<<<<<
 *         self._is_allocated = 1
 *         self._mipmap = origin._mipmap
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_4kivy_8graphics_7texture_Texture)), __pyx_n_s____init__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; __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 = 937; __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 = 937; __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 = 937; __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 = 937; __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 = 937; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_INCREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_self));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
  PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_5);
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_5 = 0;
  __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  /* "kivy\graphics\texture.pyx":965
 *         # really reloaded if its id is not -1.
 *         self.owner.reload()
 *         self._id = self.owner.id             # <<<<<<<<<<<<<<
 * 
 *         # then update content again
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->owner), __pyx_n_s__id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __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 = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_self->__pyx_base._id = __pyx_t_2;

  /* "kivy\graphics\texture.pyx":968
 * 
 *         # then update content again
 *         for cb in self.observers:             # <<<<<<<<<<<<<<
 *             cb(self)
 * 
 */
  if (unlikely(((PyObject *)__pyx_v_self->__pyx_base.observers) == Py_None)) {
    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_t_1 = ((PyObject *)__pyx_v_self->__pyx_base.observers); __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
  for (;;) {
    if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
    __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++;
    __Pyx_XDECREF(__pyx_v_cb);
    __pyx_v_cb = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "kivy\graphics\texture.pyx":969
 *         # then update content again
 *         for cb in self.observers:
 *             cb(self)             # <<<<<<<<<<<<<<
 * 
 */
    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_INCREF(((PyObject *)__pyx_v_self));
    PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_self));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
    __pyx_t_5 = PyObject_Call(__pyx_v_cb, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_WriteUnraisable("kivy.graphics.texture.TextureRegion.reload", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_cb);
  __Pyx_RefNannyFinishContext();
}
static struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture __pyx_vtable_4kivy_8graphics_7texture_Texture;

static PyObject *__pyx_tp_new_4kivy_8graphics_7texture_Texture(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  struct __pyx_obj_4kivy_8graphics_7texture_Texture *p;
  PyObject *o = (*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->__weakref__ = 0;
  p->_source = Py_None; Py_INCREF(Py_None);
  p->_wrap = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->_min_filter = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->_mag_filter = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->_colorfmt = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->_bufferfmt = ((PyObject*)Py_None); Py_INCREF(Py_None);
  p->observers = ((PyObject*)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4kivy_8graphics_7texture_Texture(PyObject *o) {
  struct __pyx_obj_4kivy_8graphics_7texture_Texture *p = (struct __pyx_obj_4kivy_8graphics_7texture_Texture *)o;
  {
    PyObject *etype, *eval, *etb;
    PyErr_Fetch(&etype, &eval, &etb);
    ++Py_REFCNT(o);
    __pyx_pw_4kivy_8graphics_7texture_7Texture_3__dealloc__(o);
    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
    --Py_REFCNT(o);
    PyErr_Restore(etype, eval, etb);
  }
  if (p->__weakref__) PyObject_ClearWeakRefs(o);
  Py_XDECREF(p->__weakref__);
  Py_XDECREF(p->_source);
  Py_XDECREF(((PyObject *)p->_wrap));
  Py_XDECREF(((PyObject *)p->_min_filter));
  Py_XDECREF(((PyObject *)p->_mag_filter));
  Py_XDECREF(((PyObject *)p->_colorfmt));
  Py_XDECREF(((PyObject *)p->_bufferfmt));
  Py_XDECREF(((PyObject *)p->observers));
  (*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->__weakref__) {
    e = (*v)(p->__weakref__, a); if (e) return e;
  }
  if (p->_source) {
    e = (*v)(p->_source, a); if (e) return e;
  }
  if (p->_wrap) {
    e = (*v)(p->_wrap, a); if (e) return e;
  }
  if (p->_min_filter) {
    e = (*v)(p->_min_filter, a); if (e) return e;
  }
  if (p->_mag_filter) {
    e = (*v)(p->_mag_filter, a); if (e) return e;
  }
  if (p->_colorfmt) {
    e = (*v)(p->_colorfmt, a); if (e) return e;
  }
  if (p->_bufferfmt) {
    e = (*v)(p->_bufferfmt, a); if (e) return e;
  }
  if (p->observers) {
    e = (*v)(p->observers, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4kivy_8graphics_7texture_Texture(PyObject *o) {
  struct __pyx_obj_4kivy_8graphics_7texture_Texture *p = (struct __pyx_obj_4kivy_8graphics_7texture_Texture *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->_source);
  p->_source = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_wrap);
  p->_wrap = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_min_filter);
  p->_min_filter = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_mag_filter);
  p->_mag_filter = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_colorfmt);
  p->_colorfmt = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->_bufferfmt);
  p->_bufferfmt = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->observers);
  p->observers = ((PyObject*)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

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

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

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

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

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

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

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

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

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

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

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

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

static PyObject *__pyx_getprop_4kivy_8graphics_7texture_7Texture_bufferfmt(PyObject *o, CYTHON_UNUSED void *x) {
  return __pyx_pw_4kivy_8graphics_7texture_7Texture_9bufferfmt_1__get__(o);
}

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

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

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

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

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

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

static PyMethodDef __pyx_methods_4kivy_8graphics_7texture_Texture[] = {
  {__Pyx_NAMESTR("add_reload_observer"), (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_7Texture_5add_reload_observer, METH_O, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_4add_reload_observer)},
  {__Pyx_NAMESTR("remove_reload_observer"), (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_7Texture_7remove_reload_observer, METH_O, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_6remove_reload_observer)},
  {__Pyx_NAMESTR("flip_vertical"), (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_7Texture_9flip_vertical, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_8flip_vertical)},
  {__Pyx_NAMESTR("get_region"), (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_7Texture_11get_region, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_10get_region)},
  {__Pyx_NAMESTR("bind"), (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_7Texture_13bind, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_12bind)},
  {__Pyx_NAMESTR("blit_data"), (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_7Texture_15blit_data, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_14blit_data)},
  {__Pyx_NAMESTR("blit_buffer"), (PyCFunction)__pyx_pw_4kivy_8graphics_7texture_7Texture_17blit_buffer, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_4kivy_8graphics_7texture_7Texture_16blit_buffer)},
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_4kivy_8graphics_7texture_Texture[] = {
  {(char *)"size", __pyx_getprop_4kivy_8graphics_7texture_7Texture_size, 0, __Pyx_DOCSTR(__pyx_k_27), 0},
  {(char *)"mipmap", __pyx_getprop_4kivy_8graphics_7texture_7Texture_mipmap, 0, __Pyx_DOCSTR(__pyx_k_28), 0},
  {(char *)"id", __pyx_getprop_4kivy_8graphics_7texture_7Texture_id, 0, __Pyx_DOCSTR(__pyx_k_29), 0},
  {(char *)"target", __pyx_getprop_4kivy_8graphics_7texture_7Texture_target, 0, __Pyx_DOCSTR(__pyx_k_30), 0},
  {(char *)"width", __pyx_getprop_4kivy_8graphics_7texture_7Texture_width, 0, __Pyx_DOCSTR(__pyx_k_31), 0},
  {(char *)"height", __pyx_getprop_4kivy_8graphics_7texture_7Texture_height, 0, __Pyx_DOCSTR(__pyx_k_32), 0},
  {(char *)"tex_coords", __pyx_getprop_4kivy_8graphics_7texture_7Texture_tex_coords, 0, __Pyx_DOCSTR(__pyx_k_33), 0},
  {(char *)"uvpos", __pyx_getprop_4kivy_8graphics_7texture_7Texture_uvpos, __pyx_setprop_4kivy_8graphics_7texture_7Texture_uvpos, __Pyx_DOCSTR(__pyx_k_34), 0},
  {(char *)"uvsize", __pyx_getprop_4kivy_8graphics_7texture_7Texture_uvsize, __pyx_setprop_4kivy_8graphics_7texture_7Texture_uvsize, __Pyx_DOCSTR(__pyx_k_35), 0},
  {(char *)"colorfmt", __pyx_getprop_4kivy_8graphics_7texture_7Texture_colorfmt, 0, __Pyx_DOCSTR(__pyx_k_36), 0},
  {(char *)"bufferfmt", __pyx_getprop_4kivy_8graphics_7texture_7Texture_bufferfmt, 0, __Pyx_DOCSTR(__pyx_k_37), 0},
  {(char *)"min_filter", __pyx_getprop_4kivy_8graphics_7texture_7Texture_min_filter, __pyx_setprop_4kivy_8graphics_7texture_7Texture_min_filter, __Pyx_DOCSTR(__pyx_k_38), 0},
  {(char *)"mag_filter", __pyx_getprop_4kivy_8graphics_7texture_7Texture_mag_filter, __pyx_setprop_4kivy_8graphics_7texture_7Texture_mag_filter, __Pyx_DOCSTR(__pyx_k_39), 0},
  {(char *)"wrap", __pyx_getprop_4kivy_8graphics_7texture_7Texture_wrap, __pyx_setprop_4kivy_8graphics_7texture_7Texture_wrap, __Pyx_DOCSTR(__pyx_k_40), 0},
  {0, 0, 0, 0, 0}
};

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

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

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

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

static PyTypeObject __pyx_type_4kivy_8graphics_7texture_Texture = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("kivy.graphics.texture.Texture"), /*tp_name*/
  sizeof(struct __pyx_obj_4kivy_8graphics_7texture_Texture), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4kivy_8graphics_7texture_Texture, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_4kivy_8graphics_7texture_7Texture_19__repr__, /*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*/
  0, /*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("Handle a OpenGL texture. This class can be used to create simple texture\n    or complex texture based on ImageData."), /*tp_doc*/
  __pyx_tp_traverse_4kivy_8graphics_7texture_Texture, /*tp_traverse*/
  __pyx_tp_clear_4kivy_8graphics_7texture_Texture, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4kivy_8graphics_7texture_Texture, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_4kivy_8graphics_7texture_Texture, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4kivy_8graphics_7texture_7Texture_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4kivy_8graphics_7texture_Texture, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_4kivy_8graphics_7texture_TextureRegion __pyx_vtable_4kivy_8graphics_7texture_TextureRegion;

static PyObject *__pyx_tp_new_4kivy_8graphics_7texture_TextureRegion(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *p;
  PyObject *o = __pyx_tp_new_4kivy_8graphics_7texture_Texture(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_4kivy_8graphics_7texture_Texture*)__pyx_vtabptr_4kivy_8graphics_7texture_TextureRegion;
  p->owner = ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_4kivy_8graphics_7texture_TextureRegion(PyObject *o) {
  struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *p = (struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)o;
  Py_XDECREF(((PyObject *)p->owner));
  __pyx_tp_dealloc_4kivy_8graphics_7texture_Texture(o);
}

static int __pyx_tp_traverse_4kivy_8graphics_7texture_TextureRegion(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *p = (struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)o;
  e = __pyx_tp_traverse_4kivy_8graphics_7texture_Texture(o, v, a); if (e) return e;
  if (p->owner) {
    e = (*v)(((PyObject*)p->owner), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_4kivy_8graphics_7texture_TextureRegion(PyObject *o) {
  struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *p = (struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion *)o;
  PyObject* tmp;
  __pyx_tp_clear_4kivy_8graphics_7texture_Texture(o);
  tmp = ((PyObject*)p->owner);
  p->owner = ((struct __pyx_obj_4kivy_8graphics_7texture_Texture *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_4kivy_8graphics_7texture_TextureRegion[] = {
  {0, 0, 0, 0}
};

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

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

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

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

static PyTypeObject __pyx_type_4kivy_8graphics_7texture_TextureRegion = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("kivy.graphics.texture.TextureRegion"), /*tp_name*/
  sizeof(struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_4kivy_8graphics_7texture_TextureRegion, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pw_4kivy_8graphics_7texture_13TextureRegion_3__repr__, /*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("Handle a region of a Texture class. Useful for non power-of-2\n    texture handling."), /*tp_doc*/
  __pyx_tp_traverse_4kivy_8graphics_7texture_TextureRegion, /*tp_traverse*/
  __pyx_tp_clear_4kivy_8graphics_7texture_TextureRegion, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_4kivy_8graphics_7texture_TextureRegion, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pw_4kivy_8graphics_7texture_13TextureRegion_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_4kivy_8graphics_7texture_TextureRegion, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    __Pyx_NAMESTR("texture"),
    __Pyx_DOCSTR(__pyx_k_41), /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
  {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0},
  {&__pyx_n_s_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 0, 1, 1},
  {&__pyx_kp_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 0},
  {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
  {&__pyx_n_s_24, __pyx_k_24, sizeof(__pyx_k_24), 0, 0, 1, 1},
  {&__pyx_kp_s_25, __pyx_k_25, sizeof(__pyx_k_25), 0, 0, 1, 0},
  {&__pyx_kp_s_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 0, 1, 0},
  {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
  {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
  {&__pyx_n_s_43, __pyx_k_43, sizeof(__pyx_k_43), 0, 0, 1, 1},
  {&__pyx_n_s_44, __pyx_k_44, sizeof(__pyx_k_44), 0, 0, 1, 1},
  {&__pyx_n_s_45, __pyx_k_45, sizeof(__pyx_k_45), 0, 0, 1, 1},
  {&__pyx_n_s_46, __pyx_k_46, sizeof(__pyx_k_46), 0, 0, 1, 1},
  {&__pyx_kp_s_49, __pyx_k_49, sizeof(__pyx_k_49), 0, 0, 1, 0},
  {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
  {&__pyx_n_s_50, __pyx_k_50, sizeof(__pyx_k_50), 0, 0, 1, 1},
  {&__pyx_n_s_53, __pyx_k_53, sizeof(__pyx_k_53), 0, 0, 1, 1},
  {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
  {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
  {&__pyx_n_s__Exception, __pyx_k__Exception, sizeof(__pyx_k__Exception), 0, 0, 1, 1},
  {&__pyx_n_s__GLCAP_BGRA, __pyx_k__GLCAP_BGRA, sizeof(__pyx_k__GLCAP_BGRA), 0, 0, 1, 1},
  {&__pyx_n_s__GLCAP_DXT1, __pyx_k__GLCAP_DXT1, sizeof(__pyx_k__GLCAP_DXT1), 0, 0, 1, 1},
  {&__pyx_n_s__GLCAP_NPOT, __pyx_k__GLCAP_NPOT, sizeof(__pyx_k__GLCAP_NPOT), 0, 0, 1, 1},
  {&__pyx_n_s__GLCAP_S3TC, __pyx_k__GLCAP_S3TC, sizeof(__pyx_k__GLCAP_S3TC), 0, 0, 1, 1},
  {&__pyx_n_s__Image, __pyx_k__Image, sizeof(__pyx_k__Image), 0, 0, 1, 1},
  {&__pyx_n_s__KeyError, __pyx_k__KeyError, sizeof(__pyx_k__KeyError), 0, 0, 1, 1},
  {&__pyx_n_s__Texture, __pyx_k__Texture, sizeof(__pyx_k__Texture), 0, 0, 1, 1},
  {&__pyx_n_s__TextureRegion, __pyx_k__TextureRegion, sizeof(__pyx_k__TextureRegion), 0, 0, 1, 1},
  {&__pyx_n_s__WeakMethod, __pyx_k__WeakMethod, sizeof(__pyx_k__WeakMethod), 0, 0, 1, 1},
  {&__pyx_n_s____all__, __pyx_k____all__, sizeof(__pyx_k____all__), 0, 0, 1, 1},
  {&__pyx_n_s____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__allocate, __pyx_k__allocate, sizeof(__pyx_k__allocate), 0, 0, 1, 1},
  {&__pyx_n_s__array, __pyx_k__array, sizeof(__pyx_k__array), 0, 0, 1, 1},
  {&__pyx_n_s__b, __pyx_k__b, sizeof(__pyx_k__b), 0, 0, 1, 1},
  {&__pyx_n_s__bgr, __pyx_k__bgr, sizeof(__pyx_k__bgr), 0, 0, 1, 1},
  {&__pyx_n_s__bgra, __pyx_k__bgra, sizeof(__pyx_k__bgra), 0, 0, 1, 1},
  {&__pyx_n_s__bind, __pyx_k__bind, sizeof(__pyx_k__bind), 0, 0, 1, 1},
  {&__pyx_n_s__blit_buffer, __pyx_k__blit_buffer, sizeof(__pyx_k__blit_buffer), 0, 0, 1, 1},
  {&__pyx_n_s__blit_data, __pyx_k__blit_data, sizeof(__pyx_k__blit_data), 0, 0, 1, 1},
  {&__pyx_n_s__bufferfmt, __pyx_k__bufferfmt, sizeof(__pyx_k__bufferfmt), 0, 0, 1, 1},
  {&__pyx_n_s__byte, __pyx_k__byte, sizeof(__pyx_k__byte), 0, 0, 1, 1},
  {&__pyx_n_s__clamp_to_edge, __pyx_k__clamp_to_edge, sizeof(__pyx_k__clamp_to_edge), 0, 0, 1, 1},
  {&__pyx_n_s__colorfmt, __pyx_k__colorfmt, sizeof(__pyx_k__colorfmt), 0, 0, 1, 1},
  {&__pyx_n_s__create, __pyx_k__create, sizeof(__pyx_k__create), 0, 0, 1, 1},
  {&__pyx_n_s__create_from_data, __pyx_k__create_from_data, sizeof(__pyx_k__create_from_data), 0, 0, 1, 1},
  {&__pyx_n_s__data, __pyx_k__data, sizeof(__pyx_k__data), 0, 0, 1, 1},
  {&__pyx_n_s__flip_vertical, __pyx_k__flip_vertical, sizeof(__pyx_k__flip_vertical), 0, 0, 1, 1},
  {&__pyx_n_s__float, __pyx_k__float, sizeof(__pyx_k__float), 0, 0, 1, 1},
  {&__pyx_n_s__fmt, __pyx_k__fmt, sizeof(__pyx_k__fmt), 0, 0, 1, 1},
  {&__pyx_n_s__format, __pyx_k__format, sizeof(__pyx_k__format), 0, 0, 1, 1},
  {&__pyx_n_s__get_region, __pyx_k__get_region, sizeof(__pyx_k__get_region), 0, 0, 1, 1},
  {&__pyx_n_s__have_mipmap, __pyx_k__have_mipmap, sizeof(__pyx_k__have_mipmap), 0, 0, 1, 1},
  {&__pyx_n_s__height, __pyx_k__height, sizeof(__pyx_k__height), 0, 0, 1, 1},
  {&__pyx_n_s__id, __pyx_k__id, sizeof(__pyx_k__id), 0, 0, 1, 1},
  {&__pyx_n_s__im, __pyx_k__im, sizeof(__pyx_k__im), 0, 0, 1, 1},
  {&__pyx_n_s__int, __pyx_k__int, sizeof(__pyx_k__int), 0, 0, 1, 1},
  {&__pyx_n_s__is_dead, __pyx_k__is_dead, sizeof(__pyx_k__is_dead), 0, 0, 1, 1},
  {&__pyx_n_s__iterate_mipmaps, __pyx_k__iterate_mipmaps, sizeof(__pyx_k__iterate_mipmaps), 0, 0, 1, 1},
  {&__pyx_n_s__linear, __pyx_k__linear, sizeof(__pyx_k__linear), 0, 0, 1, 1},
  {&__pyx_n_s__lower, __pyx_k__lower, sizeof(__pyx_k__lower), 0, 0, 1, 1},
  {&__pyx_n_s__luminance, __pyx_k__luminance, sizeof(__pyx_k__luminance), 0, 0, 1, 1},
  {&__pyx_n_s__luminance_alpha, __pyx_k__luminance_alpha, sizeof(__pyx_k__luminance_alpha), 0, 0, 1, 1},
  {&__pyx_n_s__mag_filter, __pyx_k__mag_filter, sizeof(__pyx_k__mag_filter), 0, 0, 1, 1},
  {&__pyx_n_s__min_filter, __pyx_k__min_filter, sizeof(__pyx_k__min_filter), 0, 0, 1, 1},
  {&__pyx_n_s__mipmap, __pyx_k__mipmap, sizeof(__pyx_k__mipmap), 0, 0, 1, 1},
  {&__pyx_n_s__mipmap_generation, __pyx_k__mipmap_generation, sizeof(__pyx_k__mipmap_generation), 0, 0, 1, 1},
  {&__pyx_n_s__mipmap_level, __pyx_k__mipmap_level, sizeof(__pyx_k__mipmap_level), 0, 0, 1, 1},
  {&__pyx_n_s__mirrored_repeat, __pyx_k__mirrored_repeat, sizeof(__pyx_k__mirrored_repeat), 0, 0, 1, 1},
  {&__pyx_n_s__nearest, __pyx_k__nearest, sizeof(__pyx_k__nearest), 0, 0, 1, 1},
  {&__pyx_n_s__no_blit, __pyx_k__no_blit, sizeof(__pyx_k__no_blit), 0, 0, 1, 1},
  {&__pyx_n_s__nocache, __pyx_k__nocache, sizeof(__pyx_k__nocache), 0, 0, 1, 1},
  {&__pyx_n_s__origin, __pyx_k__origin, sizeof(__pyx_k__origin), 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__remove, __pyx_k__remove, sizeof(__pyx_k__remove), 0, 0, 1, 1},
  {&__pyx_n_s__repeat, __pyx_k__repeat, sizeof(__pyx_k__repeat), 0, 0, 1, 1},
  {&__pyx_n_s__rgb, __pyx_k__rgb, sizeof(__pyx_k__rgb), 0, 0, 1, 1},
  {&__pyx_n_s__rgba, __pyx_k__rgba, sizeof(__pyx_k__rgba), 0, 0, 1, 1},
  {&__pyx_n_s__s3tc_dxt, __pyx_k__s3tc_dxt, sizeof(__pyx_k__s3tc_dxt), 0, 0, 1, 1},
  {&__pyx_n_s__s3tc_dxt1, __pyx_k__s3tc_dxt1, sizeof(__pyx_k__s3tc_dxt1), 0, 0, 1, 1},
  {&__pyx_n_s__s3tc_dxt3, __pyx_k__s3tc_dxt3, sizeof(__pyx_k__s3tc_dxt3), 0, 0, 1, 1},
  {&__pyx_n_s__s3tc_dxt5, __pyx_k__s3tc_dxt5, sizeof(__pyx_k__s3tc_dxt5), 0, 0, 1, 1},
  {&__pyx_n_s__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__source, __pyx_k__source, sizeof(__pyx_k__source), 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, __pyx_k__texture, sizeof(__pyx_k__texture), 0, 0, 1, 1},
  {&__pyx_n_s__texture_create, __pyx_k__texture_create, sizeof(__pyx_k__texture_create), 0, 0, 1, 1},
  {&__pyx_n_s__tostring, __pyx_k__tostring, sizeof(__pyx_k__tostring), 0, 0, 1, 1},
  {&__pyx_n_s__ubyte, __pyx_k__ubyte, sizeof(__pyx_k__ubyte), 0, 0, 1, 1},
  {&__pyx_n_s__uint, __pyx_k__uint, sizeof(__pyx_k__uint), 0, 0, 1, 1},
  {&__pyx_n_s__ushort, __pyx_k__ushort, sizeof(__pyx_k__ushort), 0, 0, 1, 1},
  {&__pyx_n_s__width, __pyx_k__width, sizeof(__pyx_k__width), 0, 0, 1, 1},
  {&__pyx_n_s__wrap, __pyx_k__wrap, sizeof(__pyx_k__wrap), 0, 0, 1, 1},
  {&__pyx_n_s__x, __pyx_k__x, sizeof(__pyx_k__x), 0, 0, 1, 1},
  {&__pyx_n_s__y, __pyx_k__y, sizeof(__pyx_k__y), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_staticmethod = __Pyx_GetName(__pyx_b, __pyx_n_s__staticmethod); if (!__pyx_builtin_staticmethod) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __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 = 255; __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 = 256; __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 = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_id = __Pyx_GetName(__pyx_b, __pyx_n_s__id); if (!__pyx_builtin_id) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "kivy\graphics\texture.pyx":373
 *         ret_format = 'rgb'
 *         a = array('b', data)
 *         a[0::3], a[2::3] = a[2::3], a[0::3]             # <<<<<<<<<<<<<<
 *         ret_buffer = a.tostring()
 * 
 */
  __pyx_k_slice_8 = PySlice_New(__pyx_int_2, Py_None, __pyx_int_3); if (unlikely(!__pyx_k_slice_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_8);
  __Pyx_GIVEREF(__pyx_k_slice_8);
  __pyx_k_slice_9 = PySlice_New(__pyx_int_0, Py_None, __pyx_int_3); if (unlikely(!__pyx_k_slice_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_9);
  __Pyx_GIVEREF(__pyx_k_slice_9);
  __pyx_k_slice_10 = PySlice_New(__pyx_int_0, Py_None, __pyx_int_3); if (unlikely(!__pyx_k_slice_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_10);
  __Pyx_GIVEREF(__pyx_k_slice_10);
  __pyx_k_slice_11 = PySlice_New(__pyx_int_2, Py_None, __pyx_int_3); if (unlikely(!__pyx_k_slice_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_11);
  __Pyx_GIVEREF(__pyx_k_slice_11);

  /* "kivy\graphics\texture.pyx":380
 *         ret_format = 'rgba'
 *         a = array('b', data)
 *         a[0::4], a[2::4] = a[2::4], a[0::4]             # <<<<<<<<<<<<<<
 *         ret_buffer = a.tostring()
 * 
 */
  __pyx_k_slice_12 = PySlice_New(__pyx_int_2, Py_None, __pyx_int_4); if (unlikely(!__pyx_k_slice_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_12);
  __Pyx_GIVEREF(__pyx_k_slice_12);
  __pyx_k_slice_13 = PySlice_New(__pyx_int_0, Py_None, __pyx_int_4); if (unlikely(!__pyx_k_slice_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_13);
  __Pyx_GIVEREF(__pyx_k_slice_13);
  __pyx_k_slice_14 = PySlice_New(__pyx_int_0, Py_None, __pyx_int_4); if (unlikely(!__pyx_k_slice_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_14);
  __Pyx_GIVEREF(__pyx_k_slice_14);
  __pyx_k_slice_15 = PySlice_New(__pyx_int_2, Py_None, __pyx_int_4); if (unlikely(!__pyx_k_slice_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_slice_15);
  __Pyx_GIVEREF(__pyx_k_slice_15);

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

  /* "kivy\graphics\texture.pyx":181
 * '''
 * 
 * __all__ = ('Texture', 'TextureRegion')             # <<<<<<<<<<<<<<
 * 
 * include "config.pxi"
 */
  __pyx_k_tuple_42 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_42)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_42);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__Texture));
  PyTuple_SET_ITEM(__pyx_k_tuple_42, 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_42, 1, ((PyObject *)__pyx_n_s__TextureRegion));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__TextureRegion));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_42));

  /* "kivy\graphics\texture.pyx":502
 * 
 * 
 * def texture_create(size=None, colorfmt=None, bufferfmt=None, mipmap=False):             # <<<<<<<<<<<<<<
 *     '''Create a texture based on size.
 * 
 */
  __pyx_k_tuple_47 = PyTuple_New(6); if (unlikely(!__pyx_k_tuple_47)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_47);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__size));
  PyTuple_SET_ITEM(__pyx_k_tuple_47, 0, ((PyObject *)__pyx_n_s__size));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__size));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__colorfmt));
  PyTuple_SET_ITEM(__pyx_k_tuple_47, 1, ((PyObject *)__pyx_n_s__colorfmt));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__colorfmt));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__bufferfmt));
  PyTuple_SET_ITEM(__pyx_k_tuple_47, 2, ((PyObject *)__pyx_n_s__bufferfmt));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__bufferfmt));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__mipmap));
  PyTuple_SET_ITEM(__pyx_k_tuple_47, 3, ((PyObject *)__pyx_n_s__mipmap));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__mipmap));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__width));
  PyTuple_SET_ITEM(__pyx_k_tuple_47, 4, ((PyObject *)__pyx_n_s__width));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__width));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__height));
  PyTuple_SET_ITEM(__pyx_k_tuple_47, 5, ((PyObject *)__pyx_n_s__height));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__height));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_47));
  __pyx_k_codeobj_48 = (PyObject*)__Pyx_PyCode_New(4, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_47, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_49, __pyx_n_s__texture_create, 502, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_48)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "kivy\graphics\texture.pyx":528
 * 
 * 
 * def texture_create_from_data(im, mipmap=False):             # <<<<<<<<<<<<<<
 *     '''Create a texture from an ImageData class
 *     '''
 */
  __pyx_k_tuple_51 = PyTuple_New(7); if (unlikely(!__pyx_k_tuple_51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_k_tuple_51);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__im));
  PyTuple_SET_ITEM(__pyx_k_tuple_51, 0, ((PyObject *)__pyx_n_s__im));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__im));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__mipmap));
  PyTuple_SET_ITEM(__pyx_k_tuple_51, 1, ((PyObject *)__pyx_n_s__mipmap));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__mipmap));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__width));
  PyTuple_SET_ITEM(__pyx_k_tuple_51, 2, ((PyObject *)__pyx_n_s__width));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__width));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__height));
  PyTuple_SET_ITEM(__pyx_k_tuple_51, 3, ((PyObject *)__pyx_n_s__height));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__height));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__allocate));
  PyTuple_SET_ITEM(__pyx_k_tuple_51, 4, ((PyObject *)__pyx_n_s__allocate));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__allocate));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__no_blit));
  PyTuple_SET_ITEM(__pyx_k_tuple_51, 5, ((PyObject *)__pyx_n_s__no_blit));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__no_blit));
  __Pyx_INCREF(((PyObject *)__pyx_n_s__texture));
  PyTuple_SET_ITEM(__pyx_k_tuple_51, 6, ((PyObject *)__pyx_n_s__texture));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__texture));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_51));
  __pyx_k_codeobj_52 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_51, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_49, __pyx_n_s_53, 528, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC inittexture(void); /*proto*/
PyMODINIT_FUNC inittexture(void)
#else
PyMODINIT_FUNC PyInit_texture(void); /*proto*/
PyMODINIT_FUNC PyInit_texture(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannyDeclarations
  #if CYTHON_REFNANNY
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
      PyErr_Clear();
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
      if (!__Pyx_RefNanny)
          Py_FatalError("failed to import 'refnanny' module");
  }
  #endif
  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_texture(void)", 0);
  if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #ifdef __Pyx_CyFunction_USED
  if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_FusedFunction_USED
  if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  #ifdef __Pyx_Generator_USED
  if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("texture"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_41), 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 CYTHON_COMPILING_IN_PYPY
  Py_INCREF(__pyx_b);
  #endif
  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Initialize various global constants etc. ---*/
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_module_is_main_kivy__graphics__texture) {
    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  }
  /*--- Builtin init code ---*/
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Constants init code ---*/
  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  __pyx_v_4kivy_8graphics_7texture__gl_color_fmt = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4kivy_8graphics_7texture__gl_buffer_fmt = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4kivy_8graphics_7texture__gl_buffer_size = ((PyObject*)Py_None); Py_INCREF(Py_None);
  __pyx_v_4kivy_8graphics_7texture__gl_texture_min_filter = ((PyObject*)Py_None); Py_INCREF(Py_None);
  /*--- Variable export code ---*/
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  __pyx_vtabptr_4kivy_8graphics_7texture_Texture = &__pyx_vtable_4kivy_8graphics_7texture_Texture;
  __pyx_vtable_4kivy_8graphics_7texture_Texture.update_tex_coords = (void (*)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *))__pyx_f_4kivy_8graphics_7texture_7Texture_update_tex_coords;
  __pyx_vtable_4kivy_8graphics_7texture_Texture.set_min_filter = (void (*)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, PyObject *))__pyx_f_4kivy_8graphics_7texture_7Texture_set_min_filter;
  __pyx_vtable_4kivy_8graphics_7texture_Texture.set_mag_filter = (void (*)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, PyObject *))__pyx_f_4kivy_8graphics_7texture_7Texture_set_mag_filter;
  __pyx_vtable_4kivy_8graphics_7texture_Texture.set_wrap = (void (*)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, PyObject *))__pyx_f_4kivy_8graphics_7texture_7Texture_set_wrap;
  __pyx_vtable_4kivy_8graphics_7texture_Texture.reload = (void (*)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *))__pyx_f_4kivy_8graphics_7texture_7Texture_reload;
  __pyx_vtable_4kivy_8graphics_7texture_Texture.flip_vertical = (PyObject *(*)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, int __pyx_skip_dispatch))__pyx_f_4kivy_8graphics_7texture_7Texture_flip_vertical;
  __pyx_vtable_4kivy_8graphics_7texture_Texture.get_region = (PyObject *(*)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, PyObject *, PyObject *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_4kivy_8graphics_7texture_7Texture_get_region;
  __pyx_vtable_4kivy_8graphics_7texture_Texture.bind = (PyObject *(*)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *, int __pyx_skip_dispatch))__pyx_f_4kivy_8graphics_7texture_7Texture_bind;
  if (PyType_Ready(&__pyx_type_4kivy_8graphics_7texture_Texture) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __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 = 567; __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 = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_type_4kivy_8graphics_7texture_Texture.tp_weaklistoffset == 0) __pyx_type_4kivy_8graphics_7texture_Texture.tp_weaklistoffset = offsetof(struct __pyx_obj_4kivy_8graphics_7texture_Texture, __weakref__);
  __pyx_ptype_4kivy_8graphics_7texture_Texture = &__pyx_type_4kivy_8graphics_7texture_Texture;
  __pyx_vtabptr_4kivy_8graphics_7texture_TextureRegion = &__pyx_vtable_4kivy_8graphics_7texture_TextureRegion;
  __pyx_vtable_4kivy_8graphics_7texture_TextureRegion.__pyx_base = *__pyx_vtabptr_4kivy_8graphics_7texture_Texture;
  __pyx_vtable_4kivy_8graphics_7texture_TextureRegion.__pyx_base.reload = (void (*)(struct __pyx_obj_4kivy_8graphics_7texture_Texture *))__pyx_f_4kivy_8graphics_7texture_13TextureRegion_reload;
  __pyx_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 = 932; __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 = 932; __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 = 932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_type_4kivy_8graphics_7texture_TextureRegion.tp_weaklistoffset == 0) __pyx_type_4kivy_8graphics_7texture_TextureRegion.tp_weaklistoffset = offsetof(struct __pyx_obj_4kivy_8graphics_7texture_TextureRegion, __pyx_base.__weakref__);
  __pyx_ptype_4kivy_8graphics_7texture_TextureRegion = &__pyx_type_4kivy_8graphics_7texture_TextureRegion;
  /*--- Type import code ---*/
  __pyx_ptype_4kivy_8graphics_6buffer_Buffer = __Pyx_ImportType("kivy.graphics.buffer", "Buffer", sizeof(struct __pyx_obj_4kivy_8graphics_6buffer_Buffer), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_6buffer_Buffer)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_6buffer_Buffer = (struct __pyx_vtabstruct_4kivy_8graphics_6buffer_Buffer*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_6buffer_Buffer->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_6buffer_Buffer)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_3vbo_VBO = __Pyx_ImportType("kivy.graphics.vbo", "VBO", sizeof(struct __pyx_obj_4kivy_8graphics_3vbo_VBO), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_3vbo_VBO)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_3vbo_VBO = (struct __pyx_vtabstruct_4kivy_8graphics_3vbo_VBO*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_3vbo_VBO->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_3vbo_VBO)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_3vbo_VertexBatch = __Pyx_ImportType("kivy.graphics.vbo", "VertexBatch", sizeof(struct __pyx_obj_4kivy_8graphics_3vbo_VertexBatch), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_3vbo_VertexBatch)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_3vbo_VertexBatch = (struct __pyx_vtabstruct_4kivy_8graphics_3vbo_VertexBatch*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_3vbo_VertexBatch->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_3vbo_VertexBatch)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_14transformation_Matrix = __Pyx_ImportType("kivy.graphics.transformation", "Matrix", sizeof(struct __pyx_obj_4kivy_8graphics_14transformation_Matrix), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_14transformation_Matrix)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_14transformation_Matrix = (struct __pyx_vtabstruct_4kivy_8graphics_14transformation_Matrix*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_14transformation_Matrix->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_14transformation_Matrix)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_LineWidth = __Pyx_ImportType("kivy.graphics.context_instructions", "LineWidth", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_LineWidth), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_LineWidth)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_20context_instructions_LineWidth = (struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_LineWidth*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_20context_instructions_LineWidth->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_20context_instructions_LineWidth)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_Color = __Pyx_ImportType("kivy.graphics.context_instructions", "Color", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_Color), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_Color)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_20context_instructions_Color = (struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Color*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_20context_instructions_Color->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_20context_instructions_Color)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_BindTexture = __Pyx_ImportType("kivy.graphics.context_instructions", "BindTexture", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_BindTexture), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_BindTexture)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_20context_instructions_BindTexture = (struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_BindTexture*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_20context_instructions_BindTexture->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_20context_instructions_BindTexture)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_PushMatrix = __Pyx_ImportType("kivy.graphics.context_instructions", "PushMatrix", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_PushMatrix), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_PushMatrix)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_20context_instructions_PushMatrix = (struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_PushMatrix*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_20context_instructions_PushMatrix->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_20context_instructions_PushMatrix)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_PopMatrix = __Pyx_ImportType("kivy.graphics.context_instructions", "PopMatrix", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_PopMatrix), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_PopMatrix)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_20context_instructions_PopMatrix = (struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_PopMatrix*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_20context_instructions_PopMatrix->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_20context_instructions_PopMatrix)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_MatrixInstruction = __Pyx_ImportType("kivy.graphics.context_instructions", "MatrixInstruction", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_MatrixInstruction), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_MatrixInstruction)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_20context_instructions_MatrixInstruction = (struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_MatrixInstruction*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_20context_instructions_MatrixInstruction->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_20context_instructions_MatrixInstruction)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_Transform = __Pyx_ImportType("kivy.graphics.context_instructions", "Transform", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_Transform), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_Transform)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_20context_instructions_Transform = (struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Transform*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_20context_instructions_Transform->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_20context_instructions_Transform)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_Rotate = __Pyx_ImportType("kivy.graphics.context_instructions", "Rotate", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_Rotate), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_Rotate)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_20context_instructions_Rotate = (struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Rotate*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_20context_instructions_Rotate->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_20context_instructions_Rotate)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_Scale = __Pyx_ImportType("kivy.graphics.context_instructions", "Scale", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_Scale), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_Scale)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_20context_instructions_Scale = (struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Scale*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_20context_instructions_Scale->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_20context_instructions_Scale)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_20context_instructions_Translate = __Pyx_ImportType("kivy.graphics.context_instructions", "Translate", sizeof(struct __pyx_obj_4kivy_8graphics_20context_instructions_Translate), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_20context_instructions_Translate)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_20context_instructions_Translate = (struct __pyx_vtabstruct_4kivy_8graphics_20context_instructions_Translate*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_20context_instructions_Translate->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_20context_instructions_Translate)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_8compiler_GraphicsCompiler = __Pyx_ImportType("kivy.graphics.compiler", "GraphicsCompiler", sizeof(struct __pyx_obj_4kivy_8graphics_8compiler_GraphicsCompiler), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_8compiler_GraphicsCompiler)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_8compiler_GraphicsCompiler = (struct __pyx_vtabstruct_4kivy_8graphics_8compiler_GraphicsCompiler*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_8compiler_GraphicsCompiler->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_8compiler_GraphicsCompiler)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_6shader_ShaderSource = __Pyx_ImportType("kivy.graphics.shader", "ShaderSource", sizeof(struct __pyx_obj_4kivy_8graphics_6shader_ShaderSource), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_6shader_ShaderSource)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_6shader_ShaderSource = (struct __pyx_vtabstruct_4kivy_8graphics_6shader_ShaderSource*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_6shader_ShaderSource->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_6shader_ShaderSource)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_6shader_Shader = __Pyx_ImportType("kivy.graphics.shader", "Shader", sizeof(struct __pyx_obj_4kivy_8graphics_6shader_Shader), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_6shader_Shader)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_6shader_Shader = (struct __pyx_vtabstruct_4kivy_8graphics_6shader_Shader*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_6shader_Shader->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_6shader_Shader)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_12instructions_Instruction = __Pyx_ImportType("kivy.graphics.instructions", "Instruction", sizeof(struct __pyx_obj_4kivy_8graphics_12instructions_Instruction), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_12instructions_Instruction)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_12instructions_Instruction = (struct __pyx_vtabstruct_4kivy_8graphics_12instructions_Instruction*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_12instructions_Instruction->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_12instructions_Instruction)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_12instructions_InstructionGroup = __Pyx_ImportType("kivy.graphics.instructions", "InstructionGroup", sizeof(struct __pyx_obj_4kivy_8graphics_12instructions_InstructionGroup), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_12instructions_InstructionGroup)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_12instructions_InstructionGroup = (struct __pyx_vtabstruct_4kivy_8graphics_12instructions_InstructionGroup*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_12instructions_InstructionGroup->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_12instructions_InstructionGroup)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_12instructions_ContextInstruction = __Pyx_ImportType("kivy.graphics.instructions", "ContextInstruction", sizeof(struct __pyx_obj_4kivy_8graphics_12instructions_ContextInstruction), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_12instructions_ContextInstruction)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_12instructions_ContextInstruction = (struct __pyx_vtabstruct_4kivy_8graphics_12instructions_ContextInstruction*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_12instructions_ContextInstruction->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_12instructions_ContextInstruction)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_12instructions_VertexInstruction = __Pyx_ImportType("kivy.graphics.instructions", "VertexInstruction", sizeof(struct __pyx_obj_4kivy_8graphics_12instructions_VertexInstruction), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_12instructions_VertexInstruction)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_12instructions_VertexInstruction = (struct __pyx_vtabstruct_4kivy_8graphics_12instructions_VertexInstruction*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_12instructions_VertexInstruction->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_12instructions_VertexInstruction)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_12instructions_CanvasBase = __Pyx_ImportType("kivy.graphics.instructions", "CanvasBase", sizeof(struct __pyx_obj_4kivy_8graphics_12instructions_CanvasBase), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_12instructions_CanvasBase)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_12instructions_CanvasBase = (struct __pyx_vtabstruct_4kivy_8graphics_12instructions_CanvasBase*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_12instructions_CanvasBase->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_12instructions_CanvasBase)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_12instructions_Canvas = __Pyx_ImportType("kivy.graphics.instructions", "Canvas", sizeof(struct __pyx_obj_4kivy_8graphics_12instructions_Canvas), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_12instructions_Canvas)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_12instructions_Canvas = (struct __pyx_vtabstruct_4kivy_8graphics_12instructions_Canvas*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_12instructions_Canvas->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_12instructions_Canvas)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_12instructions_RenderContext = __Pyx_ImportType("kivy.graphics.instructions", "RenderContext", sizeof(struct __pyx_obj_4kivy_8graphics_12instructions_RenderContext), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_12instructions_RenderContext)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_12instructions_RenderContext = (struct __pyx_vtabstruct_4kivy_8graphics_12instructions_RenderContext*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_12instructions_RenderContext->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_12instructions_RenderContext)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_12instructions_Callback = __Pyx_ImportType("kivy.graphics.instructions", "Callback", sizeof(struct __pyx_obj_4kivy_8graphics_12instructions_Callback), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_12instructions_Callback)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_12instructions_Callback = (struct __pyx_vtabstruct_4kivy_8graphics_12instructions_Callback*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_12instructions_Callback->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_12instructions_Callback)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_3fbo_Fbo = __Pyx_ImportType("kivy.graphics.fbo", "Fbo", sizeof(struct __pyx_obj_4kivy_8graphics_3fbo_Fbo), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_3fbo_Fbo)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_3fbo_Fbo = (struct __pyx_vtabstruct_4kivy_8graphics_3fbo_Fbo*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_3fbo_Fbo->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_3fbo_Fbo)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_4kivy_8graphics_7context_Context = __Pyx_ImportType("kivy.graphics.context", "Context", sizeof(struct __pyx_obj_4kivy_8graphics_7context_Context), 1); if (unlikely(!__pyx_ptype_4kivy_8graphics_7context_Context)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_vtabptr_4kivy_8graphics_7context_Context = (struct __pyx_vtabstruct_4kivy_8graphics_7context_Context*)__Pyx_GetVtable(__pyx_ptype_4kivy_8graphics_7context_Context->tp_dict); if (unlikely(!__pyx_vtabptr_4kivy_8graphics_7context_Context)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Variable import code ---*/
  /*--- Function import code ---*/
  __pyx_t_1 = __Pyx_ImportModule("kivy.graphics.context"); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_1, "get_context", (void (**)(void))&__pyx_f_4kivy_8graphics_7context_get_context, "struct __pyx_obj_4kivy_8graphics_7context_Context *(int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_2 = __Pyx_ImportModule("kivy.graphics.opengl_utils"); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_2, "gl_has_capability", (void (**)(void))&__pyx_f_4kivy_8graphics_12opengl_utils_gl_has_capability, "int (int, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_2, "gl_has_texture_native_format", (void (**)(void))&__pyx_f_4kivy_8graphics_12opengl_utils_gl_has_texture_native_format, "int (PyObject *, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_ImportFunction(__pyx_t_2, "gl_has_texture_conversion", (void (**)(void))&__pyx_f_4kivy_8graphics_12opengl_utils_gl_has_texture_conversion, "int (PyObject *, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  Py_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  /*--- Execution code ---*/

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

  /* "c:\Users\tito\Desktop\Kivy-1.4.0-w32\kivy\Kivy-1.4.1-w32\Kivy-1.4.1\kivy\graphics\common.pxi":11
 *     ctypedef char* const_char_ptr "const char*"
 * 
 * cdef double pi = PI             # <<<<<<<<<<<<<<
 * cdef extern from "math.h":
 *     double cos(double) nogil
 */
  __pyx_v_4kivy_8graphics_7texture_pi = 3.141592653589793;

  /* "c:\Users\tito\Desktop\Kivy-1.4.0-w32\kivy\Kivy-1.4.1-w32\Kivy-1.4.1\kivy\graphics\opengl_utils_def.pxi":2
 * # c definition
 * cdef int c_GLCAP_BGRA = 0x0001             # <<<<<<<<<<<<<<
 * cdef int c_GLCAP_NPOT = 0x0002
 * cdef int c_GLCAP_S3TC = 0x0003
 */
  __pyx_v_4kivy_8graphics_7texture_c_GLCAP_BGRA = 0x0001;

  /* "c:\Users\tito\Desktop\Kivy-1.4.0-w32\kivy\Kivy-1.4.1-w32\Kivy-1.4.1\kivy\graphics\opengl_utils_def.pxi":3
 * # c definition
 * cdef int c_GLCAP_BGRA = 0x0001
 * cdef int c_GLCAP_NPOT = 0x0002             # <<<<<<<<<<<<<<
 * cdef int c_GLCAP_S3TC = 0x0003
 * cdef int c_GLCAP_DXT1 = 0x0004
 */
  __pyx_v_4kivy_8graphics_7texture_c_GLCAP_NPOT = 0x0002;

  /* "c:\Users\tito\Desktop\Kivy-1.4.0-w32\kivy\Kivy-1.4.1-w32\Kivy-1.4.1\kivy\graphics\opengl_utils_def.pxi":4
 * cdef int c_GLCAP_BGRA = 0x0001
 * cdef int c_GLCAP_NPOT = 0x0002
 * cdef int c_GLCAP_S3TC = 0x0003             # <<<<<<<<<<<<<<
 * cdef int c_GLCAP_DXT1 = 0x0004
 * 
 */
  __pyx_v_4kivy_8graphics_7texture_c_GLCAP_S3TC = 0x0003;

  /* "c:\Users\tito\Desktop\Kivy-1.4.0-w32\kivy\Kivy-1.4.1-w32\Kivy-1.4.1\kivy\graphics\opengl_utils_def.pxi":5
 * cdef int c_GLCAP_NPOT = 0x0002
 * cdef int c_GLCAP_S3TC = 0x0003
 * cdef int c_GLCAP_DXT1 = 0x0004             # <<<<<<<<<<<<<<
 * 
 * # for python export
 */
  __pyx_v_4kivy_8graphics_7texture_c_GLCAP_DXT1 = 0x0004;

  /* "c:\Users\tito\Desktop\Kivy-1.4.0-w32\kivy\Kivy-1.4.1-w32\Kivy-1.4.1\kivy\graphics\opengl_utils_def.pxi":8
 * 
 * # for python export
 * GLCAP_BGRA = c_GLCAP_NPOT             # <<<<<<<<<<<<<<
 * GLCAP_NPOT = c_GLCAP_NPOT
 * GLCAP_S3TC = c_GLCAP_S3TC
 */
  __pyx_t_3 = PyInt_FromLong(__pyx_v_4kivy_8graphics_7texture_c_GLCAP_NPOT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__GLCAP_BGRA, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "c:\Users\tito\Desktop\Kivy-1.4.0-w32\kivy\Kivy-1.4.1-w32\Kivy-1.4.1\kivy\graphics\opengl_utils_def.pxi":9
 * # for python export
 * GLCAP_BGRA = c_GLCAP_NPOT
 * GLCAP_NPOT = c_GLCAP_NPOT             # <<<<<<<<<<<<<<
 * GLCAP_S3TC = c_GLCAP_S3TC
 * GLCAP_DXT1 = c_GLCAP_DXT1
 */
  __pyx_t_3 = PyInt_FromLong(__pyx_v_4kivy_8graphics_7texture_c_GLCAP_NPOT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__GLCAP_NPOT, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "c:\Users\tito\Desktop\Kivy-1.4.0-w32\kivy\Kivy-1.4.1-w32\Kivy-1.4.1\kivy\graphics\opengl_utils_def.pxi":10
 * GLCAP_BGRA = c_GLCAP_NPOT
 * GLCAP_NPOT = c_GLCAP_NPOT
 * GLCAP_S3TC = c_GLCAP_S3TC             # <<<<<<<<<<<<<<
 * GLCAP_DXT1 = c_GLCAP_DXT1
 */
  __pyx_t_3 = PyInt_FromLong(__pyx_v_4kivy_8graphics_7texture_c_GLCAP_S3TC); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__GLCAP_S3TC, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "c:\Users\tito\Desktop\Kivy-1.4.0-w32\kivy\Kivy-1.4.1-w32\Kivy-1.4.1\kivy\graphics\opengl_utils_def.pxi":11
 * GLCAP_NPOT = c_GLCAP_NPOT
 * GLCAP_S3TC = c_GLCAP_S3TC
 * GLCAP_DXT1 = c_GLCAP_DXT1             # <<<<<<<<<<<<<<
 */
  __pyx_t_3 = PyInt_FromLong(__pyx_v_4kivy_8graphics_7texture_c_GLCAP_DXT1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__GLCAP_DXT1, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "kivy\graphics\texture.pyx":187
 * include "opengl_utils_def.pxi"
 * 
 * from array import array             # <<<<<<<<<<<<<<
 * from kivy.weakmethod import WeakMethod
 * from kivy.graphics.context cimport get_context
 */
  __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__array));
  PyList_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__array));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__array));
  __pyx_t_4 = __Pyx_Import(((PyObject *)__pyx_n_s__array), ((PyObject *)__pyx_t_3), -1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__array);
  if (__pyx_t_3 == NULL) {
    if (PyErr_ExceptionMatches(PyExc_AttributeError)) __Pyx_RaiseImportError(__pyx_n_s__array);
    if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_3);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__array, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":188
 * 
 * from array import array
 * from kivy.weakmethod import WeakMethod             # <<<<<<<<<<<<<<
 * from kivy.graphics.context cimport get_context
 * 
 */
  __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__WeakMethod));
  PyList_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_n_s__WeakMethod));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__WeakMethod));
  __pyx_t_3 = __Pyx_Import(((PyObject *)__pyx_n_s_43), ((PyObject *)__pyx_t_4), -1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__WeakMethod);
  if (__pyx_t_4 == NULL) {
    if (PyErr_ExceptionMatches(PyExc_AttributeError)) __Pyx_RaiseImportError(__pyx_n_s__WeakMethod);
    if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __Pyx_GOTREF(__pyx_t_4);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__WeakMethod, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __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;

  /* "kivy\graphics\texture.pyx":197
 * 
 * # compatibility layer
 * cdef GLuint GL_BGR = 0x80E0             # <<<<<<<<<<<<<<
 * cdef GLuint GL_BGRA = 0x80E1
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1
 */
  __pyx_v_4kivy_8graphics_7texture_GL_BGR = 0x80E0;

  /* "kivy\graphics\texture.pyx":198
 * # compatibility layer
 * cdef GLuint GL_BGR = 0x80E0
 * cdef GLuint GL_BGRA = 0x80E1             # <<<<<<<<<<<<<<
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2
 */
  __pyx_v_4kivy_8graphics_7texture_GL_BGRA = 0x80E1;

  /* "kivy\graphics\texture.pyx":199
 * cdef GLuint GL_BGR = 0x80E0
 * cdef GLuint GL_BGRA = 0x80E1
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1             # <<<<<<<<<<<<<<
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3
 */
  __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1;

  /* "kivy\graphics\texture.pyx":200
 * cdef GLuint GL_BGRA = 0x80E1
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2             # <<<<<<<<<<<<<<
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3
 * 
 */
  __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2;

  /* "kivy\graphics\texture.pyx":201
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3             # <<<<<<<<<<<<<<
 * 
 * cdef dict _gl_color_fmt = {
 */
  __pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3;

  /* "kivy\graphics\texture.pyx":203
 * cdef GLuint GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3
 * 
 * cdef dict _gl_color_fmt = {             # <<<<<<<<<<<<<<
 *     'rgba': GL_RGBA, 'bgra': GL_BGRA, 'rgb': GL_RGB, 'bgr': GL_BGR,
 *     'luminance': GL_LUMINANCE, 'luminance_alpha': GL_LUMINANCE_ALPHA,
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));

  /* "kivy\graphics\texture.pyx":204
 * 
 * cdef dict _gl_color_fmt = {
 *     'rgba': GL_RGBA, 'bgra': GL_BGRA, 'rgb': GL_RGB, 'bgr': GL_BGR,             # <<<<<<<<<<<<<<
 *     'luminance': GL_LUMINANCE, 'luminance_alpha': GL_LUMINANCE_ALPHA,
 *     's3tc_dxt1': GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
 */
  __pyx_t_4 = PyInt_FromLong(GL_RGBA); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__rgba), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_BGRA); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__bgra), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyInt_FromLong(GL_RGB); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__rgb), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_BGR); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__bgr), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":205
 * cdef dict _gl_color_fmt = {
 *     'rgba': GL_RGBA, 'bgra': GL_BGRA, 'rgb': GL_RGB, 'bgr': GL_BGR,
 *     'luminance': GL_LUMINANCE, 'luminance_alpha': GL_LUMINANCE_ALPHA,             # <<<<<<<<<<<<<<
 *     's3tc_dxt1': GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
 *     's3tc_dxt3': GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
 */
  __pyx_t_4 = PyInt_FromLong(GL_LUMINANCE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__luminance), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyInt_FromLong(GL_LUMINANCE_ALPHA); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__luminance_alpha), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":206
 *     'rgba': GL_RGBA, 'bgra': GL_BGRA, 'rgb': GL_RGB, 'bgr': GL_BGR,
 *     'luminance': GL_LUMINANCE, 'luminance_alpha': GL_LUMINANCE_ALPHA,
 *     's3tc_dxt1': GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,             # <<<<<<<<<<<<<<
 *     's3tc_dxt3': GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
 *     's3tc_dxt5': GL_COMPRESSED_RGBA_S3TC_DXT5_EXT }
 */
  __pyx_t_4 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__s3tc_dxt1), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":207
 *     'luminance': GL_LUMINANCE, 'luminance_alpha': GL_LUMINANCE_ALPHA,
 *     's3tc_dxt1': GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
 *     's3tc_dxt3': GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,             # <<<<<<<<<<<<<<
 *     's3tc_dxt5': GL_COMPRESSED_RGBA_S3TC_DXT5_EXT }
 * 
 */
  __pyx_t_4 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__s3tc_dxt3), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":208
 *     's3tc_dxt1': GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
 *     's3tc_dxt3': GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
 *     's3tc_dxt5': GL_COMPRESSED_RGBA_S3TC_DXT5_EXT }             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = __Pyx_PyInt_to_py_GLuint(__pyx_v_4kivy_8graphics_7texture_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__s3tc_dxt5), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_XGOTREF(((PyObject *)__pyx_v_4kivy_8graphics_7texture__gl_color_fmt));
  __Pyx_DECREF(((PyObject *)__pyx_v_4kivy_8graphics_7texture__gl_color_fmt));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
  __pyx_v_4kivy_8graphics_7texture__gl_color_fmt = __pyx_t_3;
  __pyx_t_3 = 0;

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

  /* "kivy\graphics\texture.pyx":212
 * 
 * cdef dict _gl_buffer_fmt = {
 *     'ubyte': GL_UNSIGNED_BYTE, 'ushort': GL_UNSIGNED_SHORT,             # <<<<<<<<<<<<<<
 *     'uint': GL_UNSIGNED_INT, 'byte': GL_BYTE,
 *     'short': GL_SHORT, 'int': GL_INT, 'float': GL_FLOAT }
 */
  __pyx_t_4 = PyInt_FromLong(GL_UNSIGNED_BYTE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__ubyte), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyInt_FromLong(GL_UNSIGNED_SHORT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__ushort), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":213
 * cdef dict _gl_buffer_fmt = {
 *     'ubyte': GL_UNSIGNED_BYTE, 'ushort': GL_UNSIGNED_SHORT,
 *     'uint': GL_UNSIGNED_INT, 'byte': GL_BYTE,             # <<<<<<<<<<<<<<
 *     'short': GL_SHORT, 'int': GL_INT, 'float': GL_FLOAT }
 * 
 */
  __pyx_t_4 = PyInt_FromLong(GL_UNSIGNED_INT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__uint), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyInt_FromLong(GL_BYTE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__byte), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":214
 *     'ubyte': GL_UNSIGNED_BYTE, 'ushort': GL_UNSIGNED_SHORT,
 *     'uint': GL_UNSIGNED_INT, 'byte': GL_BYTE,
 *     'short': GL_SHORT, 'int': GL_INT, 'float': GL_FLOAT }             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = PyInt_FromLong(GL_SHORT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__short), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyInt_FromLong(GL_INT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__int), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyInt_FromLong(GL_FLOAT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__float), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_XGOTREF(((PyObject *)__pyx_v_4kivy_8graphics_7texture__gl_buffer_fmt));
  __Pyx_DECREF(((PyObject *)__pyx_v_4kivy_8graphics_7texture__gl_buffer_fmt));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
  __pyx_v_4kivy_8graphics_7texture__gl_buffer_fmt = __pyx_t_3;
  __pyx_t_3 = 0;

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

  /* "kivy\graphics\texture.pyx":218
 * 
 * cdef dict _gl_buffer_size = {
 *     'ubyte': sizeof(GLubyte), 'ushort': sizeof(GLushort),             # <<<<<<<<<<<<<<
 *     'uint': sizeof(GLuint), 'byte': sizeof(GLbyte),
 *     'short': sizeof(GLshort), 'int': sizeof(GLint),
 */
  __pyx_t_4 = __Pyx_PyInt_FromSize_t((sizeof(GLubyte))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__ubyte), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_FromSize_t((sizeof(GLushort))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__ushort), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":219
 * cdef dict _gl_buffer_size = {
 *     'ubyte': sizeof(GLubyte), 'ushort': sizeof(GLushort),
 *     'uint': sizeof(GLuint), 'byte': sizeof(GLbyte),             # <<<<<<<<<<<<<<
 *     'short': sizeof(GLshort), 'int': sizeof(GLint),
 *     'float': sizeof(GLfloat) }
 */
  __pyx_t_4 = __Pyx_PyInt_FromSize_t((sizeof(GLuint))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__uint), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyInt_FromSize_t((sizeof(GLbyte))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__byte), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

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

  /* "kivy\graphics\texture.pyx":221
 *     'uint': sizeof(GLuint), 'byte': sizeof(GLbyte),
 *     'short': sizeof(GLshort), 'int': sizeof(GLint),
 *     'float': sizeof(GLfloat) }             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = __Pyx_PyInt_FromSize_t((sizeof(GLfloat))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__float), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_XGOTREF(((PyObject *)__pyx_v_4kivy_8graphics_7texture__gl_buffer_size));
  __Pyx_DECREF(((PyObject *)__pyx_v_4kivy_8graphics_7texture__gl_buffer_size));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
  __pyx_v_4kivy_8graphics_7texture__gl_buffer_size = __pyx_t_3;
  __pyx_t_3 = 0;

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

  /* "kivy\graphics\texture.pyx":225
 * 
 * cdef dict _gl_texture_min_filter = {
 *     'nearest': GL_NEAREST, 'linear': GL_LINEAR,             # <<<<<<<<<<<<<<
 *     'nearest_mipmap_nearest': GL_NEAREST_MIPMAP_NEAREST,
 *     'nearest_mipmap_linear': GL_NEAREST_MIPMAP_LINEAR,
 */
  __pyx_t_4 = PyInt_FromLong(GL_NEAREST); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__nearest), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyInt_FromLong(GL_LINEAR); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__linear), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":226
 * cdef dict _gl_texture_min_filter = {
 *     'nearest': GL_NEAREST, 'linear': GL_LINEAR,
 *     'nearest_mipmap_nearest': GL_NEAREST_MIPMAP_NEAREST,             # <<<<<<<<<<<<<<
 *     'nearest_mipmap_linear': GL_NEAREST_MIPMAP_LINEAR,
 *     'linear_mipmap_nearest': GL_LINEAR_MIPMAP_NEAREST,
 */
  __pyx_t_4 = PyInt_FromLong(GL_NEAREST_MIPMAP_NEAREST); 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);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s_44), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":227
 *     'nearest': GL_NEAREST, 'linear': GL_LINEAR,
 *     'nearest_mipmap_nearest': GL_NEAREST_MIPMAP_NEAREST,
 *     'nearest_mipmap_linear': GL_NEAREST_MIPMAP_LINEAR,             # <<<<<<<<<<<<<<
 *     'linear_mipmap_nearest': GL_LINEAR_MIPMAP_NEAREST,
 *     'linear_mipmap_linear': GL_LINEAR_MIPMAP_LINEAR }
 */
  __pyx_t_4 = PyInt_FromLong(GL_NEAREST_MIPMAP_LINEAR); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s_45), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":228
 *     'nearest_mipmap_nearest': GL_NEAREST_MIPMAP_NEAREST,
 *     'nearest_mipmap_linear': GL_NEAREST_MIPMAP_LINEAR,
 *     'linear_mipmap_nearest': GL_LINEAR_MIPMAP_NEAREST,             # <<<<<<<<<<<<<<
 *     'linear_mipmap_linear': GL_LINEAR_MIPMAP_LINEAR }
 * 
 */
  __pyx_t_4 = PyInt_FromLong(GL_LINEAR_MIPMAP_NEAREST); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s_17), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "kivy\graphics\texture.pyx":229
 *     'nearest_mipmap_linear': GL_NEAREST_MIPMAP_LINEAR,
 *     'linear_mipmap_nearest': GL_LINEAR_MIPMAP_NEAREST,
 *     'linear_mipmap_linear': GL_LINEAR_MIPMAP_LINEAR }             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_4 = PyInt_FromLong(GL_LINEAR_MIPMAP_LINEAR); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s_46), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_XGOTREF(((PyObject *)__pyx_v_4kivy_8graphics_7texture__gl_texture_min_filter));
  __Pyx_DECREF(((PyObject *)__pyx_v_4kivy_8graphics_7texture__gl_texture_min_filter));
  __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
  __pyx_v_4kivy_8graphics_7texture__gl_texture_min_filter = __pyx_t_3;
  __pyx_t_3 = 0;

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

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

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

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

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

  /* "kivy\graphics\texture.pyx":683
 *     def blit_buffer(self, pbuffer, size=None, colorfmt=None,
 *                     pos=None, bufferfmt=None, mipmap_level=0,
 *                     mipmap_generation=True):             # <<<<<<<<<<<<<<
 *         '''Blit a buffer into a texture.
 * 
 */
  __pyx_t_3 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_k_22 = __pyx_t_3;
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_3 = 0;

  /* "kivy\graphics\texture.pyx":1
 * '''             # <<<<<<<<<<<<<<
 * Texture
 * =======
 */
  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 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);
  if (__pyx_m) {
    __Pyx_AddTraceback("init kivy.graphics.texture", __pyx_clineno, __pyx_lineno, __pyx_filename);
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init kivy.graphics.texture");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

/* Runtime support code */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif /* CYTHON_REFNANNY */

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

static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *local_type, *local_value, *local_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(&local_type, &local_value, &local_tb);
#endif
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
#if CYTHON_COMPILING_IN_CPYTHON
    if (unlikely(tstate->curexc_type))
#else
    if (unlikely(PyErr_Occurred()))
#endif
        goto bad;
    #if PY_MAJOR_VERSION >= 3
    if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
        goto bad;
    #endif
    Py_INCREF(local_type);
    Py_INCREF(local_value);
    Py_INCREF(local_tb);
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
#if CYTHON_COMPILING_IN_CPYTHON
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    /* Make sure tstate is in a consistent state when we XDECREF
       these objects (DECREF may run arbitrary code). */
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
    return 0;
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
}

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_Restore(type, value, tb);
#endif
}
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#else
    PyErr_Fetch(type, value, tb);
#endif
}

#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
                        CYTHON_UNUSED PyObject *cause) {
    Py_XINCREF(type);
    Py_XINCREF(value);
    Py_XINCREF(tb);
    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;
    }
    if (value == NULL) {
        value = Py_None;
        Py_INCREF(value);
    }
    #if PY_VERSION_HEX < 0x02050000
    if (!PyClass_Check(type))
    #else
    if (!PyType_Check(type))
    #endif
    {
        if (value != Py_None) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        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, PyObject *cause) {
    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;
    }
    if (cause) {
        PyObject *fixed_cause;
        if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        }
        else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        }
        else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        if (!value) {
            value = PyObject_CallObject(type, NULL);
        }
        PyException_SetCause(value, fixed_cause);
    }
    PyErr_SetObject(type, value);
    if (tb) {
        PyThreadState *tstate = PyThreadState_GET();
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
    }
bad:
    return;
}
#endif

static CYTHON_INLINE int __Pyx_PyStr_Tailmatch(PyObject* self, PyObject* arg, Py_ssize_t start,
                                               Py_ssize_t end, int direction)
{
    if (PY_MAJOR_VERSION < 3)
        return __Pyx_PyBytes_Tailmatch(self, arg, start, end, direction);
    else
        return __Pyx_PyUnicode_Tailmatch(self, arg, start, end, direction);
}

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(PyObject_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AS_STRING(kw_name));
        #endif
}

static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;
    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
        } else {
            #if PY_MAJOR_VERSION < 3
            if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
            #else
            if (unlikely(!PyUnicode_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 {
                    for (name=argnames; name != first_kw_arg; name++) {
                        if (**name == key) goto arg_passed_twice;
                        #if PY_MAJOR_VERSION >= 3
                        if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                            PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
                        #else
                        if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                            _PyString_Eq(**name, key)) goto arg_passed_twice;
                        #endif
                    }
                    if (kwds2) {
                        if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
                    } else {
                        goto invalid_keyword;
                    }
                }
            }
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, **name);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}

static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%s() takes %s %" PY_FORMAT_SIZE_T "d positional argument%s (%" PY_FORMAT_SIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
    PyErr_Format(PyExc_ValueError,
                 "need more than %" PY_FORMAT_SIZE_T "d value%s to unpack",
                 index, (index == 1) ? "" : "s");
}

static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
    PyErr_Format(PyExc_ValueError,
                 "too many values to unpack (expected %" PY_FORMAT_SIZE_T "d)", expected);
}

static CYTHON_INLINE int __Pyx_IterFinish(void) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    PyObject* exc_type = tstate->curexc_type;
    if (unlikely(exc_type)) {
        if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) {
            PyObject *exc_value, *exc_tb;
            exc_value = tstate->curexc_value;
            exc_tb = tstate->curexc_traceback;
            tstate->curexc_type = 0;
            tstate->curexc_value = 0;
            tstate->curexc_traceback = 0;
            Py_DECREF(exc_type);
            Py_XDECREF(exc_value);
            Py_XDECREF(exc_tb);
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#else
    if (unlikely(PyErr_Occurred())) {
        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
            PyErr_Clear();
            return 0;
        } else {
            return -1;
        }
    }
    return 0;
#endif
}

static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
    if (unlikely(retval)) {
        Py_DECREF(retval);
        __Pyx_RaiseTooManyValuesError(expected);
        return -1;
    } else {
        return __Pyx_IterFinish();
    }
    return 0;
}

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 void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
#else
    PyErr_GetExcInfo(type, value, tb);
#endif
}
static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
#if CYTHON_COMPILING_IN_CPYTHON
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#else
    PyErr_SetExcInfo(type, value, tb);
#endif
}

static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) {
    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;
    #if PY_VERSION_HEX >= 0x02050000
    {
        #if PY_MAJOR_VERSION >= 3
        if (level == -1) {
            if (strchr(__Pyx_MODULE_NAME, '.')) {
                /* try package relative import first */
                PyObject *py_level = PyInt_FromLong(1);
                if (!py_level)
                    goto bad;
                module = PyObject_CallFunctionObjArgs(py_import,
                    name, global_dict, empty_dict, list, py_level, NULL);
                Py_DECREF(py_level);
                if (!module) {
                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
                        goto bad;
                    PyErr_Clear();
                }
            }
            level = 0; /* try absolute import on failure */
        }
        #endif
        if (!module) {
            PyObject *py_level = PyInt_FromLong(level);
            if (!py_level)
                goto bad;
            module = PyObject_CallFunctionObjArgs(py_import,
                name, global_dict, empty_dict, list, py_level, NULL);
            Py_DECREF(py_level);
        }
    }
    #else
    if (level>0) {
        PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4.");
        goto bad;
    }
    module = PyObject_CallFunctionObjArgs(py_import,
        name, global_dict, empty_dict, list, NULL);
    #endif
bad:
    Py_XDECREF(empty_list);
    Py_XDECREF(py_import);
    Py_XDECREF(empty_dict);
    return module;
}

static CYTHON_INLINE void __Pyx_RaiseImportError(PyObject *name) {
#if PY_MAJOR_VERSION < 3
    PyErr_Format(PyExc_ImportError, "cannot import name %.230s",
                 PyString_AsString(name));
#else
    PyErr_Format(PyExc_ImportError, "cannot import name %S", name);
#endif
}

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_GLuint(GLuint val) {
    const GLuint neg_one = (GLuint)-1, const_zero = (GLuint)0;
    const int is_unsigned = const_zero < neg_one;
    if ((sizeof(GLuint) == sizeof(char))  ||
        (sizeof(GLuint) == sizeof(short))) {
        return PyInt_FromLong((long)val);
    } else if ((sizeof(GLuint) == sizeof(int)) ||
               (sizeof(GLuint) == sizeof(long))) {
        if (is_unsigned)
            return PyLong_FromUnsignedLong((unsigned long)val);
        else
            return PyInt_FromLong((long)val);
    } else if (sizeof(GLuint) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
        else
            return PyLong_FromLongLong((PY_LONG_LONG)val);
    } else {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&val;
        return _PyLong_FromByteArray(bytes, sizeof(GLuint),
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE GLuint __Pyx_PyInt_from_py_GLuint(PyObject* x) {
    const GLuint neg_one = (GLuint)-1, const_zero = (GLuint)0;
    const int is_unsigned = const_zero < neg_one;
    if (sizeof(GLuint) == sizeof(char)) {
        if (is_unsigned)
            return (GLuint)__Pyx_PyInt_AsUnsignedChar(x);
        else
            return (GLuint)__Pyx_PyInt_AsSignedChar(x);
    } else if (sizeof(GLuint) == sizeof(short)) {
        if (is_unsigned)
            return (GLuint)__Pyx_PyInt_AsUnsignedShort(x);
        else
            return (GLuint)__Pyx_PyInt_AsSignedShort(x);
    } else if (sizeof(GLuint) == sizeof(int)) {
        if (is_unsigned)
            return (GLuint)__Pyx_PyInt_AsUnsignedInt(x);
        else
            return (GLuint)__Pyx_PyInt_AsSignedInt(x);
    } else if (sizeof(GLuint) == sizeof(long)) {
        if (is_unsigned)
            return (GLuint)__Pyx_PyInt_AsUnsignedLong(x);
        else
            return (GLuint)__Pyx_PyInt_AsSignedLong(x);
    } else if (sizeof(GLuint) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return (GLuint)__Pyx_PyInt_AsUnsignedLongLong(x);
        else
            return (GLuint)__Pyx_PyInt_AsSignedLongLong(x);
    }  else {
        GLuint val;
        PyObject *v = __Pyx_PyNumber_Int(x);
        #if PY_VERSION_HEX < 0x03000000
        if (likely(v) && !PyLong_Check(v)) {
            PyObject *tmp = v;
            v = PyNumber_Long(tmp);
            Py_DECREF(tmp);
        }
        #endif
        if (likely(v)) {
            int one = 1; int is_little = (int)*(unsigned char *)&one;
            unsigned char *bytes = (unsigned char *)&val;
            int ret = _PyLong_AsByteArray((PyLongObject *)v,
                                          bytes, sizeof(val),
                                          is_little, !is_unsigned);
            Py_DECREF(v);
            if (likely(!ret))
                return val;
        }
        return (GLuint)-1;
    }
}

static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
    if (s1 == s2) {
        return (equals == Py_EQ);
    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
        if (PyBytes_GET_SIZE(s1) != PyBytes_GET_SIZE(s2)) {
            return (equals == Py_NE);
        } else if (PyBytes_GET_SIZE(s1) == 1) {
            if (equals == Py_EQ)
                return (PyBytes_AS_STRING(s1)[0] == PyBytes_AS_STRING(s2)[0]);
            else
                return (PyBytes_AS_STRING(s1)[0] != PyBytes_AS_STRING(s2)[0]);
        } else {
            int result = memcmp(PyBytes_AS_STRING(s1), PyBytes_AS_STRING(s2), (size_t)PyBytes_GET_SIZE(s1));
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
#endif
}

static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY
    return PyObject_RichCompareBool(s1, s2, equals);
#else
    if (s1 == s2) {
        return (equals == Py_EQ);
    } else if (PyUnicode_CheckExact(s1) & PyUnicode_CheckExact(s2)) {
        #if CYTHON_PEP393_ENABLED
        if ((PyUnicode_READY(s1) < 0) || (PyUnicode_READY(s2) < 0))
            return -1;
        if (PyUnicode_GET_LENGTH(s1) != PyUnicode_GET_LENGTH(s2)) {
            return (equals == Py_NE);
        } else if (PyUnicode_GET_LENGTH(s1) == 1) {
            Py_UCS4 ch1 = PyUnicode_READ_CHAR(s1, 0);
            Py_UCS4 ch2 = PyUnicode_READ_CHAR(s2, 0);
            return (equals == Py_EQ) ? (ch1 == ch2) : (ch1 != ch2);
        #else
        if (PyUnicode_GET_SIZE(s1) != PyUnicode_GET_SIZE(s2)) {
            return (equals == Py_NE);
        } else if (PyUnicode_GET_SIZE(s1) == 1) {
            Py_UNICODE ch1 = PyUnicode_AS_UNICODE(s1)[0];
            Py_UNICODE ch2 = PyUnicode_AS_UNICODE(s2)[0];
            return (equals == Py_EQ) ? (ch1 == ch2) : (ch1 != ch2);
        #endif
        } else {
            int result = PyUnicode_Compare(s1, s2);
            if ((result == -1) && unlikely(PyErr_Occurred()))
                return -1;
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyUnicode_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyUnicode_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
#endif
}

static CYTHON_INLINE 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 (unsigned long)PyLong_AsUnsignedLong(x);
        } else {
            return (unsigned long)PyLong_AsLong(x);
        }
    } else {
        unsigned long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned long)-1;
        val = __Pyx_PyInt_AsUnsignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

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 (unsigned PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
            return (unsigned PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        unsigned PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

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 (long)PyLong_AsUnsignedLong(x);
        } else {
            return (long)PyLong_AsLong(x);
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (long)-1;
        val = __Pyx_PyInt_AsLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

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 (PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
            return (PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

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 (signed long)PyLong_AsUnsignedLong(x);
        } else {
            return (signed long)PyLong_AsLong(x);
        }
    } else {
        signed long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed long)-1;
        val = __Pyx_PyInt_AsSignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

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 (signed PY_LONG_LONG)PyLong_AsUnsignedLongLong(x);
        } else {
            return (signed PY_LONG_LONG)PyLong_AsLongLong(x);
        }
    } else {
        signed PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsSignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
                                  CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
}

static int __Pyx_check_binary_version(void) {
    char ctversion[4], rtversion[4];
    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
        char message[200];
        PyOS_snprintf(message, sizeof(message),
                      "compiletime version %s of module '%.100s' "
                      "does not match runtime version %s",
                      ctversion, __Pyx_MODULE_NAME, rtversion);
        #if PY_VERSION_HEX < 0x02050000
        return PyErr_Warn(NULL, message);
        #else
        return PyErr_WarnEx(NULL, message, 1);
        #endif
    }
    return 0;
}

static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    size_t size, int strict)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;
    char warning[200];
    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    py_name = __Pyx_PyIdentifier_FromString(class_name);
    if (!py_name)
        goto bad;
    result = PyObject_GetAttr(py_module, py_name);
    Py_DECREF(py_name);
    py_name = 0;
    Py_DECREF(py_module);
    py_module = 0;
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%s.%s is not a type object",
            module_name, class_name);
        goto bad;
    }
    if (!strict && (size_t)((PyTypeObject *)result)->tp_basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility",
            module_name, class_name);
        #if PY_VERSION_HEX < 0x02050000
        if (PyErr_Warn(NULL, warning) < 0) goto bad;
        #else
        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
        #endif
    }
    else if ((size_t)((PyTypeObject *)result)->tp_basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%s.%s has the wrong size, try recompiling",
            module_name, class_name);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return NULL;
}
#endif

#ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;
    py_name = __Pyx_PyIdentifier_FromString(name);
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

static void* __Pyx_GetVtable(PyObject *dict) {
    void* ptr;
    PyObject *ob = PyMapping_GetItemString(dict, (char *)"__pyx_vtable__");
    if (!ob)
        goto bad;
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    ptr = PyCapsule_GetPointer(ob, 0);
#else
    ptr = PyCObject_AsVoidPtr(ob);
#endif
    if (!ptr && !PyErr_Occurred())
        PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
    Py_DECREF(ob);
    return ptr;
bad:
    Py_XDECREF(ob);
    return NULL;
}

#ifndef __PYX_HAVE_RT_ImportFunction
#define __PYX_HAVE_RT_ImportFunction
static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig) {
    PyObject *d = 0;
    PyObject *cobj = 0;
    union {
        void (*fp)(void);
        void *p;
    } tmp;
    d = PyObject_GetAttrString(module, (char *)"__pyx_capi__");
    if (!d)
        goto bad;
    cobj = PyDict_GetItemString(d, funcname);
    if (!cobj) {
        PyErr_Format(PyExc_ImportError,
            "%s does not export expected C function %s",
                PyModule_GetName(module), funcname);
        goto bad;
    }
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    if (!PyCapsule_IsValid(cobj, sig)) {
        PyErr_Format(PyExc_TypeError,
            "C function %s.%s has wrong signature (expected %s, got %s)",
             PyModule_GetName(module), funcname, sig, PyCapsule_GetName(cobj));
        goto bad;
    }
    tmp.p = PyCapsule_GetPointer(cobj, sig);
#else
    {const char *desc, *s1, *s2;
    desc = (const char *)PyCObject_GetDesc(cobj);
    if (!desc)
        goto bad;
    s1 = desc; s2 = sig;
    while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; }
    if (*s1 != *s2) {
        PyErr_Format(PyExc_TypeError,
            "C function %s.%s has wrong signature (expected %s, got %s)",
             PyModule_GetName(module), funcname, sig, desc);
        goto bad;
    }
    tmp.p = PyCObject_AsVoidPtr(cobj);}
#endif
    *f = tmp.fp;
    if (!(*f))
        goto bad;
    Py_DECREF(d);
    return 0;
bad:
    Py_XDECREF(d);
    return -1;
}
#endif

static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
    int start = 0, mid = 0, end = count - 1;
    if (end >= 0 && code_line > entries[end].code_line) {
        return count;
    }
    while (start < end) {
        mid = (start + end) / 2;
        if (code_line < entries[mid].code_line) {
            end = mid;
        } else if (code_line > entries[mid].code_line) {
             start = mid + 1;
        } else {
            return mid;
        }
    }
    if (code_line <= entries[mid].code_line) {
        return mid;
    } else {
        return mid + 1;
    }
}
static PyCodeObject *__pyx_find_code_object(int code_line) {
    PyCodeObject* code_object;
    int pos;
    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
        return NULL;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
        return NULL;
    }
    code_object = __pyx_code_cache.entries[pos].code_object;
    Py_INCREF(code_object);
    return code_object;
}
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
    int pos, i;
    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
    if (unlikely(!code_line)) {
        return;
    }
    if (unlikely(!entries)) {
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
        if (likely(entries)) {
            __pyx_code_cache.entries = entries;
            __pyx_code_cache.max_count = 64;
            __pyx_code_cache.count = 1;
            entries[0].code_line = code_line;
            entries[0].code_object = code_object;
            Py_INCREF(code_object);
        }
        return;
    }
    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
        PyCodeObject* tmp = entries[pos].code_object;
        entries[pos].code_object = code_object;
        Py_DECREF(tmp);
        return;
    }
    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
        int new_max = __pyx_code_cache.max_count + 64;
        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
            __pyx_code_cache.entries, new_max*sizeof(__Pyx_CodeObjectCacheEntry));
        if (unlikely(!entries)) {
            return;
        }
        __pyx_code_cache.entries = entries;
        __pyx_code_cache.max_count = new_max;
    }
    for (i=__pyx_code_cache.count; i>pos; i--) {
        entries[i] = entries[i-1];
    }
    entries[pos].code_line = code_line;
    entries[pos].code_object = code_object;
    __pyx_code_cache.count++;
    Py_INCREF(code_object);
}

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"
static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
            const char *funcname, int c_line,
            int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(filename);
    #else
    py_srcfile = PyUnicode_FromString(filename);
    #endif
    if (!py_srcfile) goto bad;
    if (c_line) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_code = __Pyx_PyCode_New(
        0,            /*int argcount,*/
        0,            /*int kwonlyargcount,*/
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple, /*PyObject *consts,*/
        __pyx_empty_tuple, /*PyObject *names,*/
        __pyx_empty_tuple, /*PyObject *varnames,*/
        __pyx_empty_tuple, /*PyObject *freevars,*/
        __pyx_empty_tuple, /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        py_line,      /*int firstlineno,*/
        __pyx_empty_bytes  /*PyObject *lnotab*/
    );
    Py_DECREF(py_srcfile);
    Py_DECREF(py_funcname);
    return py_code;
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    return NULL;
}
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename) {
    PyCodeObject *py_code = 0;
    PyObject *py_globals = 0;
    PyFrameObject *py_frame = 0;
    py_code = __pyx_find_code_object(c_line ? c_line : py_line);
    if (!py_code) {
        py_code = __Pyx_CreateCodeObjectForTraceback(
            funcname, c_line, py_line, filename);
        if (!py_code) goto bad;
        __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
    }
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        py_globals,          /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = py_line;
    PyTraceBack_Here(py_frame);
bad:
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else  /* Python 3+ has unicode identifiers */
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}


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