[pypy-commit] lang-smalltalk bitblt: Fix translation errors, store the sdldisplay on the DisplayBitmap object

timfel noreply at buildbot.pypy.org
Sat Mar 16 13:35:41 CET 2013


Author: Tim Felgentreff <timfelgentreff at gmail.com>
Branch: bitblt
Changeset: r188:25ccd461619c
Date: 2013-03-16 13:11 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/25ccd461619c/

Log:	Fix translation errors, store the sdldisplay on the DisplayBitmap
	object

diff --git a/spyvm/model.py b/spyvm/model.py
--- a/spyvm/model.py
+++ b/spyvm/model.py
@@ -530,16 +530,16 @@
 
 NATIVE_DEPTH = 32
 class W_DisplayBitmap(W_AbstractObjectWithClassReference):
+    _attrs_ = ['pixelbuffer', '_depth', '_realsize', 'display', 'version']
 
-    _attrs_ = ['pixelbuffer', '_depth', '_size']
-
-    def __init__(self, w_class, size, depth):
+    def __init__(self, w_class, size, depth, display):
         W_AbstractObjectWithClassReference.__init__(self, w_class)
         assert depth == 1 # XXX: Only support B/W for now
         bytelen = NATIVE_DEPTH / depth * size * 4
         self.pixelbuffer = lltype.malloc(rffi.VOIDP.TO, bytelen, flavor='raw')
         self._depth = depth
-        self._size = size
+        self._realsize = size
+        self.display = display
         self.mutate()
 
     def __del__(self):
@@ -599,15 +599,15 @@
             pos += 4
 
     def size(self):
-        return self._size
+        return self._realsize
 
     def invariant(self):
         return False
 
     def clone(self, space):
-        w_result = W_WordsObject(self.w_class, self._size)
+        w_result = W_WordsObject(self.w_class, self._realsize)
         n = 0
-        while n < self._size:
+        while n < self._realsize:
             w_result.words[n] = self.getword(n)
             n += 1
         return w_result
diff --git a/spyvm/objspace.py b/spyvm/objspace.py
--- a/spyvm/objspace.py
+++ b/spyvm/objspace.py
@@ -4,13 +4,10 @@
 from rpython.rlib.rarithmetic import intmask, r_uint, int_between
 
 class ObjSpace(object):
-    _attrs_ = ["_display", "w_simulateCopyBits"]
-
     def __init__(self):
         self.classtable = {}
         self.make_bootstrap_classes()
         self.make_bootstrap_objects()
-        self._display = [None]
 
     def make_bootstrap_classes(self):
         def define_core_cls(name, w_superclass, w_metaclass):
@@ -288,12 +285,6 @@
             closure.atput0(i0, copiedValues[i0])
         return w_closure
 
-    def set_display(self, interp, obj):
-        self._display[0] = obj
-
-    def display(self):
-        return self._display[0]
-        
 
 def bootstrap_class(space, instsize, w_superclass=None, w_metaclass=None,
                     name='?', format=shadow.POINTERS, varsized=False):
diff --git a/spyvm/primitives.py b/spyvm/primitives.py
--- a/spyvm/primitives.py
+++ b/spyvm/primitives.py
@@ -557,8 +557,9 @@
 
     w_dest_form = w_rcvr.fetch(interp.space, 0)
     if w_dest_form.is_same_object(interp.space.objtable['w_display']):
-        import pdb; pdb.set_trace()
-        interp.space.display().blit()
+        w_bitmap = w_dest_form.fetch(interp.space, 0)
+        assert isinstance(w_bitmap, model.W_DisplayBitmap)
+        w_bitmap.display.blit()
 
     print "blitting finshed after %d ms" % int((time.time() - start) * 1000)
     return w_rcvr
@@ -578,20 +579,31 @@
     # XXX: TODO get the initial image TODO: figure out whether we
     # should decide the width an report it in the other SCREEN_SIZE
     w_bitmap = w_rcvr.fetch(interp.space, 0)
-    assert isinstance(w_bitmap, model.W_WordsObject) or isinstance(w_bitmap, model.W_DisplayBitmap)
     width = interp.space.unwrap_int(w_rcvr.fetch(interp.space, 1))
     height = interp.space.unwrap_int(w_rcvr.fetch(interp.space, 2))
     depth = interp.space.unwrap_int(w_rcvr.fetch(interp.space, 3))
 
-    w_display_bitmap = model.W_DisplayBitmap(w_bitmap.getclass(interp.space), w_bitmap.size(), depth)
-    for idx, word in enumerate(w_bitmap.words):
-        w_display_bitmap.setword(idx, word)
-    w_rcvr.store(interp.space, 0, w_display_bitmap)
+    w_prev_display = interp.space.objtable['w_display']
+    w_prev_bitmap = None
+    if w_prev_display:
+        w_prev_bitmap = w_prev_display.fetch(interp.space, 0)
+    if isinstance(w_prev_bitmap, model.W_DisplayBitmap):
+        sdldisplay = w_prev_bitmap.display
+    else:
+        sdldisplay = display.SDLDisplay()
+    sdldisplay.set_video_mode(width, height, depth)
 
-    sdldisplay = display.SDLDisplay(width, height, depth)
+    if isinstance(w_bitmap, model.W_WordsObject):
+        w_display_bitmap = model.W_DisplayBitmap(w_bitmap.getclass(interp.space), w_bitmap.size(), depth, display)
+        for idx, word in enumerate(w_bitmap.words):
+            w_display_bitmap.setword(idx, word)
+        w_rcvr.store(interp.space, 0, w_display_bitmap)
+    else:
+        assert isinstance(w_bitmap, model.W_DisplayBitmap)
+        w_display_bitmap = w_bitmap
+
     sdldisplay.set_pixelbuffer(w_display_bitmap.pixelbuffer)
     sdldisplay.blit()
-    interp.space.set_display(interp, display)
 
     interp.space.objtable['w_display'] = w_rcvr
     return w_rcvr
@@ -722,10 +734,7 @@
 
 @expose_primitive(DEFER_UPDATES, unwrap_spec=[object, object])
 def func(interp, s_frame, w_receiver, w_bool):
-    if w_bool.is_same_object(interp.space.w_true):
-        interp.space.display().set_defer_updates()
-    else:
-        interp.space.display().set_defer_updates()
+    raise PrimitiveNotYetWrittenError()
 
 @expose_primitive(DRAW_RECTANGLE, unwrap_spec=[object, int, int, int, int])
 def func(interp, s_frame, w_rcvr, left, right, top, bottom):


More information about the pypy-commit mailing list