Repository: kivy/kivy

Issue:
textinput render issue
i don't know if it's driver specific or something, but i get some weird behaviour when i enter text in a textinput, demonstrated here :

http://pub.tshirtman.fr/out-6.ogv

this happens in the examples/demo/showcase/main.py example as well, both in single and multiline textinput, getting near of the border and then erasing is a good way to trigger it, in fact, the more what you write makes the textinput scroll, the bigger trail/artifact you get when erasing.



Discussion:
The video is not available, and the referenced issue has been fixed and closed. I'll assume this one doesn't exist anymore :)

Still present, open a single line TextInput inter text such that textinput scrolls  now delete text.

I created a gltrace of it, and when replaying it, i get these errors in the terminal, i guess that could be a good hint

```
174: glDebugOutputCallback: High severity API error 1, GL_INVALID_OPERATION in glUniformMatrix(program not linked)
174 glUniformMatrix4fv(location = 1, count = 1, transpose = GL_FALSE, value = {0.001392758, 0, 0, 0, 0, 0.002333722, 0, 0, 0, 0, 1, 0, -1, -1, -0, 1})
174: warning: glGetError(glUniformMatrix4fv) = GL_INVALID_OPERATION
175: glDebugOutputCallback: High severity API error 1, GL_INVALID_OPERATION in glUniformMatrix(program not linked)
175 glUniformMatrix4fv(location = 0, count = 1, transpose = GL_FALSE, value = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1})
175: warning: glGetError(glUniformMatrix4fv) = GL_INVALID_OPERATION
213: glDebugOutputCallback: High severity API error 1, GL_INVALID_OPERATION in glUniformMatrix(program not linked)
213 glUniformMatrix4fv(location = 1, count = 1, transpose = GL_FALSE, value = {0.001392758, 0, 0, 0, 0, 0.002333722, 0, 0, 0, 0, 1, 0, -1, -1, -0, 1})
213: warning: glGetError(glUniformMatrix4fv) = GL_INVALID_OPERATION
214: glDebugOutputCallback: High severity API error 1, GL_INVALID_OPERATION in glUniformMatrix(program not linked)
214 glUniformMatrix4fv(location = 0, count = 1, transpose = GL_FALSE, value = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1})
214: warning: glGetError(glUniformMatrix4fv) = GL_INVALID_OPERATION
216: glDebugOutputCallback: High severity API error 1, GL_INVALID_OPERATION in glUniformMatrix(program not linked)
216 glUniformMatrix4fv(location = 1, count = 1, transpose = GL_FALSE, value = {0.001392758, 0, 0, 0, 0, 0.002333722, 0, 0, 0, 0, 1, 0, -1, -1, -0, 1})
216: warning: glGetError(glUniformMatrix4fv) = GL_INVALID_OPERATION
217: glDebugOutputCallback: High severity API error 1, GL_INVALID_OPERATION in glUniformMatrix(program not linked)
217 glUniformMatrix4fv(location = 0, count = 1, transpose = GL_FALSE, value = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1})
217: warning: glGetError(glUniformMatrix4fv) = GL_INVALID_OPERATION
293: glDebugOutputCallback: High severity API error 1, GL_INVALID_OPERATION in glUniformMatrix(program not linked)
293 glUniformMatrix4fv(location = 1, count = 1, transpose = GL_FALSE, value = {0.001392758, 0, 0, 0, 0, 0.002333722, 0, 0, 0, 0, 1, 0, -1, -1, -0, 1})
293: warning: glGetError(glUniformMatrix4fv) = GL_INVALID_OPERATION
294: glDebugOutputCallback: High severity API error 1, GL_INVALID_OPERATION in glUniformMatrix(program not linked)
294 glUniformMatrix4fv(location = 0, count = 1, transpose = GL_FALSE, value = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1})
294: warning: glGetError(glUniformMatrix4fv) = GL_INVALID_OPERATION
```

the trace can be found here http://pub.tshirtman.fr/kivy_issue_508.trace (600k)


Resolving patch:
diff --git a/kivy/uix/textinput.py b/kivy/uix/textinput.py
--- a/kivy/uix/textinput.py
+++ b/kivy/uix/textinput.py
@@ -141,7 +141,6 @@ def insert_text(self, substring, from_undo=False):
 from functools import partial
 from os import environ
 from weakref import ref
-import string
 
 from kivy.animation import Animation
 from kivy.base import EventLoop
@@ -1643,16 +1642,19 @@ def _update_graphics(self, *largs):
                 tcx, tcy = 0, 0
 
                 # adjust size/texcoord according to viewport
-                if vw < tw:
+                if viewport_pos:
+                    tcx, tcy = viewport_pos
+                    tcx = tcx / tw * (ow)
+                    tcy = tcy / th * oh
+                if tw - viewport_pos[0] < vw:
+                    tcw = tcw - tcx
+                    size[0] = tcw * size[0]
+                elif vw < tw:
                     tcw = (vw / tw) * tcw
                     size[0] = vw
                 if vh < th:
                     tch = (vh / th) * tch
                     size[1] = vh
-                if viewport_pos:
-                    tcx, tcy = viewport_pos
-                    tcx = tcx / tw * (ow)
-                    tcy = tcy / th * oh
 
                 # cropping
                 mlh = lh


Test patch: