Beispiel #1
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)
Beispiel #2
0
 def _blit(self, img, r):
     if self._update_rect:
         self._update_rect = rect.union(r, self._update_rect)
     else:
         self._update_rect = r