[pypy-commit] lang-smalltalk rbitblt: automatically round fractions to ints directly in our bitblt
timfel
noreply at buildbot.pypy.org
Thu Jan 9 19:19:53 CET 2014
Author: Tim Felgentreff <timfelgentreff at gmail.com>
Branch: rbitblt
Changeset: r563:c22d170b585b
Date: 2014-01-09 16:55 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/c22d170b585b/
Log: automatically round fractions to ints directly in our bitblt
diff --git a/spyvm/plugins/bitblt.py b/spyvm/plugins/bitblt.py
--- a/spyvm/plugins/bitblt.py
+++ b/spyvm/plugins/bitblt.py
@@ -37,6 +37,15 @@
return w_rcvr
+def intOrIfNil(space, w_int, i):
+ if w_int is space.w_nil:
+ return i
+ elif isinstance(w_int, model.W_Float):
+ return intmask(int(space.unwrap_float(w_int)))
+ else:
+ return space.unwrap_int(w_int)
+
+
class BitBltShadow(AbstractCachingShadow):
WordSize = 32
MaskTable = [r_uint(0)]
@@ -48,10 +57,7 @@
pass
def intOrIfNil(self, w_int, i):
- if w_int is self.space.w_nil:
- return i
- else:
- return self.space.unwrap_int(w_int)
+ return intOrIfNil(self.space, w_int, i)
def loadForm(self, w_form):
if not isinstance(w_form, model.W_PointersObject):
@@ -716,6 +722,9 @@
AbstractCachingShadow.__init__(self, space, w_self)
self.invalid = False
+ def intOrIfNil(self, w_int, i):
+ return intOrIfNil(self.space, w_int, i)
+
def sync_cache(self):
self.invalid = True
if self.size() < 5:
@@ -725,9 +734,9 @@
return
if not (isinstance(self.w_bits, model.W_WordsObject) or isinstance(self.w_bits, model.W_DisplayBitmap)):
return
- self.width = self.space.unwrap_int(self.fetch(1))
- self.height = self.space.unwrap_int(self.fetch(2))
- self.depth = self.space.unwrap_int(self.fetch(3))
+ self.width = self.intOrIfNil(self.fetch(1), 0)
+ self.height = self.intOrIfNil(self.fetch(2), 0)
+ self.depth = self.intOrIfNil(self.fetch(3), 0)
if self.width < 0 or self.height < 0:
return
self.msb = self.depth > 0
@@ -738,8 +747,8 @@
w_offset = self.fetch(4)
assert isinstance(w_offset, model.W_PointersObject)
if not w_offset is self.space.w_nil:
- self.offsetX = self.space.unwrap_int(w_offset._fetch(0))
- self.offsetY = self.space.unwrap_int(w_offset._fetch(1))
+ self.offsetX = self.intOrIfNil(w_offset._fetch(0), 0)
+ self.offsetY = self.intOrIfNil(w_offset._fetch(1), 0)
self.pixPerWord = 32 / self.depth
self.pitch = (self.width + (self.pixPerWord - 1)) / self.pixPerWord | 0
if self.w_bits.size() != (self.pitch * self.height):
More information about the pypy-commit
mailing list