Esempio n. 1
0
 def _expose( self, regions ):
     """
     Callback for expose events from X11
     """
     if self.alpha < 255:
         bs = self._backing_store_with_alpha
     else:
         bs = self._backing_store
     for pos, size in optimize_for_rendering(regions):
         self.__render( bs._image, pos, pos, size )
Esempio n. 2
0
    def _blit(self, img, r):
        pos, size = r

        self._rect = rect.optimize_for_rendering(self._rect)
        # get the raw data from the imlib2 image as buffer
        data = img._image.get_raw_data()
        # create a new surface
        # XXX: Does overlay() handle buffer objects for data?  If not,
        # pass str(data).
        self._surface.overlay(DSPF_ARGB, data)
        self._surface.flip(DSFLIP_WAIT)
        return
Esempio n. 3
0
    def _blit_regions(self, img, regions):
        # Merge the regions into one big union of blit_once is True
        if self._slices:
            new_regions = []
            for ((x, y), (w, h)) in regions:
                new_regions.append( ((0, y), (img.width, h)), )
            regions = new_regions

        if self._blit_once:
            region = regions.pop()
            while regions:
                region = rect.union(region, regions.pop())
            regions = [region]

        # It's the container's responsibility to apply children's alpha
        # values.  But there is no parent of the canvas to do that, so we
        # do that here if it's necessary.
        if self.alpha < 255:
            if self._preserve_alpha:
                self._backing_store_with_alpha.clear()
                self._backing_store_with_alpha.blend(img, alpha = self.alpha)
            else:
                self._backing_store_with_alpha.draw_rectangle( (0, 0),
							       img.size,
							       (0, 0, 0, 255),
							       fill = True)
                self._backing_store_with_alpha.blend(img, alpha = self.alpha,
						     merge_alpha = False)
            img = self._backing_store_with_alpha

        regions = rect.optimize_for_rendering(regions)
        for r in regions:
            # Clip rectangle to screen.
            r = rect.intersect( r, ((0, 0), self.get_size()) )
            if r == rect.empty:
                continue
            self._blit(img, r)