Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

core/graphics: fix missing attributes not copied when reloaded (min_f…

…ilter, mag_filter and wrap)

+ fix vbo crash (invalid flags set while reloading.)
  • Loading branch information...
commit ca7714281b304dcf7ea8ec50a2d1bd6719d25887 1 parent 7fd74fa
Mathieu Virbel tito authored
1  kivy/core/text/__init__.py
View
@@ -434,7 +434,6 @@ def render(self, real=False):
texture.blit_data(data)
def _texture_refresh(self, *l):
- print 'context reloaded, reupload texture'
self.refresh()
def refresh(self):
15 kivy/graphics/context.pyx
View
@@ -119,6 +119,7 @@ cdef class Context:
cdef Shader shader
cdef Canvas canvas
+ Cache.remove('kv.atlas')
Cache.remove('kv.image')
Cache.remove('kv.texture')
Cache.remove('kv.shader')
@@ -158,25 +159,25 @@ cdef class Context:
for item in self.l_vbo[:]:
vbo = item()
if vbo is not None:
- Logger.debug('Context: reloaded %r' % item())
+ Logger.trace('Context: reloaded %r' % item())
vbo.reload()
Logger.debug('Context: Reload vertex batchs')
for item in self.l_vertexbatch[:]:
batch = item()
if batch is not None:
- Logger.debug('Context: reloaded %r' % item())
+ Logger.trace('Context: reloaded %r' % item())
batch.reload()
Logger.debug('Context: Reload shaders')
for item in self.l_shader[:]:
shader = item()
if shader is not None:
- Logger.debug('Context: reloaded %r' % item())
+ Logger.trace('Context: reloaded %r' % item())
shader.reload()
Logger.debug('Context: Reload canvas')
for item in self.l_canvas[:]:
canvas = item()
if canvas is not None:
- Logger.debug('Context: reloaded %r' % item())
+ Logger.trace('Context: reloaded %r' % item())
canvas.reload()
# call reload observers that want to do something after a whole gpu
@@ -202,18 +203,18 @@ cdef class Context:
# dealloc all gl resources asynchronously
cdef GLuint i, j
if len(self.lr_vbo):
- Logger.debug('Context: releasing %d vbos' % len(self.lr_vbo))
+ Logger.trace('Context: releasing %d vbos' % len(self.lr_vbo))
while len(self.lr_vbo):
i = self.lr_vbo.pop()
glDeleteBuffers(1, &i)
if len(self.lr_texture):
- Logger.debug('Context: releasing %d textures: %r' % (
+ Logger.trace('Context: releasing %d textures: %r' % (
len(self.lr_texture), self.lr_texture))
while len(self.lr_texture):
i = self.lr_texture.pop()
glDeleteTextures(1, &i)
if len(self.lr_fbo):
- Logger.debug('Context: releasing %d fbos' % len(self.lr_fbo))
+ Logger.trace('Context: releasing %d fbos' % len(self.lr_fbo))
while len(self.lr_fbo):
i, j = self.lr_fbo.pop()
if i != -1:
33 kivy/graphics/texture.pyx
View
@@ -711,23 +711,28 @@ cdef class Texture:
texture = texture_create(self.size, self.colorfmt, self.bufferfmt,
self.mipmap)
self._id = texture.id
+ else:
+ from kivy.core.image import Image
+ image = Image(self._source)
+ self._id = image.texture.id
+ texture = image.texture
texture._nofree = 1
- # then update content again
- for callback in self.observers[:]:
- if callback.is_dead():
- self.observers.remove(callback)
- continue
- callback()(self)
- return
- from kivy.core.image import Image
- image = Image(self._source)
- self._id = image.texture.id
- texture = image.texture
+ # ensure the new opengl ID will not get through GC
texture._nofree = 1
+
+ # 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)
+
# then update content again
- for cb in self.observers:
- cb(self)
+ for callback in self.observers[:]:
+ if callback.is_dead():
+ self.observers.remove(callback)
+ continue
+ callback()(self)
def __repr__(self):
return '<Texture hash=%r id=%d size=%r colorfmt=%r bufferfmt=%r source=%r observers=%d>' % (
@@ -901,7 +906,7 @@ cdef class TextureRegion(Texture):
self._uvh = (height / <float>origin._height) * origin._uvh
self.update_tex_coords()
- def __str__(self):
+ 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))
2  kivy/graphics/vbo.pyx
View
@@ -110,7 +110,7 @@ cdef class VBO:
self.data.remove(indices, count)
cdef void reload(self):
- self.flags = V_NEEDUPLOAD & V_NEEDGEN
+ self.flags = V_NEEDUPLOAD | V_NEEDGEN
self.vbo_size = 0
def __repr__(self):
Please sign in to comment.
Something went wrong with that request. Please try again.