Exemple #1
0
    def tile_is_visible(self, tx, ty, transformation, clip_region, sparse,
                        translation_only):
        if not sparse:
            return True

        # it is worth checking whether this tile really will be visible
        # (to speed up the L-shaped expose event during scrolling)
        # (speedup clearly visible; slowdown measurable when always executing this code)
        N = tiledsurface.N
        if translation_only:
            x, y = transformation.transform_point(tx * N, ty * N)
            bbox = (int(x), int(y), N, N)
        else:
            corners = [(tx * N, ty * N), ((tx + 1) * N, ty * N),
                       (tx * N, (ty + 1) * N), ((tx + 1) * N, (ty + 1) * N)]
            corners = [
                transformation.transform_point(x_, y_) for (x_, y_) in corners
            ]
            bbox = helpers.rotated_rectangle_bbox(corners)

        c_r = gdk.Rectangle()
        c_r.x, c_r.y, c_r.width, c_r.height = clip_region
        bb_r = gdk.Rectangle()
        bb_r.x, bb_r.y, bb_r.width, bb_r.height = bbox
        intersects, isect_r = gdk.rectangle_intersect(bb_r, c_r)
        return intersects
Exemple #2
0
def tile_is_visible(cr, tx, ty, clip_region, sparse, translation_only):
    if not sparse:
        return True

    # it is worth checking whether this tile really will be visible
    # (to speed up the L-shaped expose event during scrolling)
    # (speedup clearly visible; slowdown measurable when always executing this code)
    N = tiledsurface.N
    if translation_only:
        x, y = cr.user_to_device(tx*N, ty*N)
        bbox = (int(x), int(y), N, N)
    else:
        corners = [(tx*N, ty*N), ((tx+1)*N, ty*N), (tx*N, (ty+1)*N), ((tx+1)*N, (ty+1)*N)]
        corners = [cr.user_to_device(x_, y_) for (x_, y_) in corners]
        bbox = helpers.rotated_rectangle_bbox(corners)

    if pygtkcompat.USE_GTK3:
        c_r = gdk.Rectangle()
        c_r.x, c_r.y, c_r.width, c_r.height = clip_region
        bb_r = gdk.Rectangle()
        bb_r.x, bb_r.y, bb_r.width, bb_r.height = bbox
        intersects, isect_r = gdk.rectangle_intersect(bb_r, c_r)
        if not intersects:
            return False
    else:
        if clip_region.rect_in(bbox) == gdk.OVERLAP_RECTANGLE_OUT:
            return False

    return True
Exemple #3
0
    def _tile_is_visible(self, tx, ty, transformation, clip_region,
                         translation_only):
        """Tests whether an individual tile is visible.

        This is sometimes worth doing during rendering, but not always.
        Currently we use _render_get_clip_region()'s sparse flag to
        determine whether this is necessary. The original logic for
        this function was documented as...

        > it is worth checking whether this tile really will be visible
        > (to speed up the L-shaped expose event during scrolling)
        > (speedup clearly visible; slowdown measurable when always
        > executing this code)

        but I'm not 100% certain that GTK3 does panning redraws this
        way. So perhaps this method is uneccessary?

        """
        N = tiledsurface.N
        if translation_only:
            x, y = transformation.transform_point(tx * N, ty * N)
            bbox = (int(x), int(y), N, N)
        else:
            corners = [
                (tx * N, ty * N),
                ((tx + 1) * N, ty * N),
                (tx * N, (ty + 1) * N),
                ((tx + 1) * N, (ty + 1) * N),
            ]
            corners = [
                transformation.transform_point(x_, y_) for (x_, y_) in corners
            ]
            bbox = helpers.rotated_rectangle_bbox(corners)

        c_r = gdk.Rectangle()
        c_r.x, c_r.y, c_r.width, c_r.height = clip_region
        bb_r = gdk.Rectangle()
        bb_r.x, bb_r.y, bb_r.width, bb_r.height = bbox
        intersects, isect_r = gdk.rectangle_intersect(bb_r, c_r)
        return intersects
Exemple #4
0
    def tile_is_visible(self, tx, ty, transformation, clip_region, sparse, translation_only):
        if not sparse:
            return True

        # it is worth checking whether this tile really will be visible
        # (to speed up the L-shaped expose event during scrolling)
        # (speedup clearly visible; slowdown measurable when always executing this code)
        N = tiledsurface.N
        if translation_only:
            x, y = transformation.transform_point(tx*N, ty*N)
            bbox = (int(x), int(y), N, N)
        else:
            corners = [(tx*N, ty*N), ((tx+1)*N, ty*N), (tx*N, (ty+1)*N), ((tx+1)*N, (ty+1)*N)]
            corners = [transformation.transform_point(x_, y_) for (x_, y_) in corners]
            bbox = helpers.rotated_rectangle_bbox(corners)

        c_r = gdk.Rectangle()
        c_r.x, c_r.y, c_r.width, c_r.height = clip_region
        bb_r = gdk.Rectangle()
        bb_r.x, bb_r.y, bb_r.width, bb_r.height = bbox
        intersects, isect_r = gdk.rectangle_intersect(bb_r, c_r)
        return intersects
Exemple #5
0
    def _tile_is_visible(self, tx, ty, transformation, clip_region,
                         translation_only):
        """Tests whether an individual tile is visible.

        This is sometimes worth doing during rendering, but not always.
        Currently we use _render_get_clip_region()'s sparse flag to
        determine whether this is necessary. The original logic for
        this function was documented as...

        > it is worth checking whether this tile really will be visible
        > (to speed up the L-shaped expose event during scrolling)
        > (speedup clearly visible; slowdown measurable when always
        > executing this code)

        but I'm not 100% certain that GTK3 does panning redraws this
        way. So perhaps this method is uneccessary?

        """
        N = tiledsurface.N
        if translation_only:
            x, y = transformation.transform_point(tx*N, ty*N)
            bbox = (int(x), int(y), N, N)
        else:
            corners = [
                (tx*N, ty*N), ((tx+1)*N, ty*N),
                (tx*N, (ty+1)*N), ((tx+1)*N, (ty+1)*N),
            ]
            corners = [
                transformation.transform_point(x_, y_)
                for (x_, y_) in corners
            ]
            bbox = helpers.rotated_rectangle_bbox(corners)

        c_r = gdk.Rectangle()
        c_r.x, c_r.y, c_r.width, c_r.height = clip_region
        bb_r = gdk.Rectangle()
        bb_r.x, bb_r.y, bb_r.width, bb_r.height = bbox
        intersects, isect_r = gdk.rectangle_intersect(bb_r, c_r)
        return intersects