third_party/cairo/src/cairo-os2-surface.c
void
cairo_os2_surface_refresh_window (cairo_surface_t *surface,
                                  HPS              hps_begin_paint,
                                  PRECTL           prcl_begin_paint_rect)
{
    cairo_os2_surface_t *local_os2_surface;
    RECTL rclTemp;
    HPS hpsTemp = 0;

    local_os2_surface = (cairo_os2_surface_t *) surface;
    if ((!local_os2_surface) ||
        (local_os2_surface->base.backend != &cairo_os2_surface_backend))
    {
        /* Invalid parameter (wrong surface)! */
        return;
    }

    /* If an HPS wasn't provided, see if we can get one. */
    if (!hps_begin_paint) {
        hps_begin_paint = local_os2_surface->hps_client_window;
        if (!hps_begin_paint) {
            if (local_os2_surface->hwnd_client_window) {
                hpsTemp = WinGetPS(local_os2_surface->hwnd_client_window);
                hps_begin_paint = hpsTemp;
            }
            /* No HPS & no way to get one, so exit */
            if (!hps_begin_paint)
                return;
        }
    }

    if (prcl_begin_paint_rect == NULL) {
        /* Update the whole window! */
        rclTemp.xLeft = 0;
        rclTemp.xRight = local_os2_surface->bitmap_info.cx;
        rclTemp.yTop = local_os2_surface->bitmap_info.cy;
        rclTemp.yBottom = 0;
    } else {
        /* Use the rectangle we got passed as parameter! */
        rclTemp.xLeft = prcl_begin_paint_rect->xLeft;
        rclTemp.xRight = prcl_begin_paint_rect->xRight;
        rclTemp.yTop = local_os2_surface->bitmap_info.cy - prcl_begin_paint_rect->yBottom;
        rclTemp.yBottom = local_os2_surface->bitmap_info.cy - prcl_begin_paint_rect->yTop ;
    }

    /* Get mutex, we'll work with the pixel array! */
    if (DosRequestMutexSem (local_os2_surface->hmtx_use_private_fields, SEM_INDEFINITE_WAIT)
        != NO_ERROR)
    {
        /* Could not get mutex! */
        if (hpsTemp)
            WinReleasePS(hpsTemp);
        return;
    }

    if ((local_os2_surface->dirty_area_present) &&
        (local_os2_surface->rcl_dirty_area.xLeft == rclTemp.xLeft) &&
        (local_os2_surface->rcl_dirty_area.xRight == rclTemp.xRight) &&
        (local_os2_surface->rcl_dirty_area.yTop == rclTemp.yTop) &&
        (local_os2_surface->rcl_dirty_area.yBottom == rclTemp.yBottom))
    {
        /* Aha, this call was because of a dirty area, so in this case we
         * have to blit the pixels from the screen to the surface!
         */
        local_os2_surface->dirty_area_present = FALSE;
        _cairo_os2_surface_get_pixels_from_screen (local_os2_surface,
                                                   hps_begin_paint,
                                                   &rclTemp);
    } else {
        /* Okay, we have the surface, have the HPS
         * (might be from WinBeginPaint () or from WinGetPS () )
         * Now blit there the stuffs!
         */
        _cairo_os2_surface_blit_pixels (local_os2_surface,
                                        hps_begin_paint,
                                        &rclTemp);
    }

    DosReleaseMutexSem (local_os2_surface->hmtx_use_private_fields);

    if (hpsTemp)
        WinReleasePS(hpsTemp);
}
/**
 * cairo_os2_surface_refresh_window:
 * @surface: the cairo surface to refresh
 * @hps_begin_paint: the presentation handle of the window to refresh
 * @prcl_begin_paint_rect: the rectangle to redraw
 *
 * This function can be used to force a repaint of a given area of the client
 * window. It should usually be called from the WM_PAINT processing of the
 * window procedure. However, it can be called any time a given part of the
 * window has to be updated.
 *
 * The HPS and RECTL to be passed can be taken from the usual WinBeginPaint call
 * of the window procedure, but you can also get the HPS using WinGetPS, and you
 * can assemble your own update rectangle by hand.
 * If hps_begin_paint is %NULL, the function will use the HPS passed into
 * cairo_os2_surface_create(). If @prcl_begin_paint_rect is %NULL, the function
 * will query the current window size and repaint the whole window.
 *
 * Cairo assumes that if you set the HWND to the surface using
 * cairo_os2_surface_set_hwnd(), this function will be called by the application
 * every time it gets a WM_PAINT for that HWND. If the HWND is set in the
 * surface, Cairo uses this function to handle dirty areas too.
 *
 * Since: 1.4
 **/
@surface: the cairo surface to refresh
@hps_begin_paint: the presentation handle of the window to refresh
@prcl_begin_paint_rect: the rectangle to redraw

This function can be used to force a repaint of a given area of the client
window. It should usually be called from the WM_PAINT processing of the
window procedure. However, it can be called any time a given part of the
window has to be updated.

The HPS and RECTL to be passed can be taken from the usual WinBeginPaint call
of the window procedure, but you can also get the HPS using WinGetPS, and you
can assemble your own update rectangle by hand.
If hps_begin_paint is %NULL, the function will use the HPS passed into
cairo_os2_surface_create(). If @prcl_begin_paint_rect is %NULL, the function
will query the current window size and repaint the whole window.

Cairo assumes that if you set the HWND to the surface using
cairo_os2_surface_set_hwnd(), this function will be called by the application
every time it gets a WM_PAINT for that HWND. If the HWND is set in the
surface, Cairo uses this function to handle dirty areas too.


@surface : the cairo surface to refresh @hps_begin_paint : the presentation handle of the window to refresh @prcl_begin_paint_rect : the rectangle to redraw This function can be used to force a repaint of a given area of the client window . It should usually be called from the WM_PAINT processing of the window procedure . However it can be called any time a given part of the window has to be updated . The HPS and RECTL to be passed can be taken from the usual WinBeginPaint call of the window procedure but you can also get the HPS using WinGetPS and you can assemble your own update rectangle by hand . If hps_begin_paint is %NULL the function will use the HPS passed into cairo_os2_surface_create () . If @prcl_begin_paint_rect is %NULL the function will query the current window size and repaint the whole window . Cairo assumes that if you set the HWND to the surface using cairo_os2_surface_set_hwnd () this function will be called by the application every time it gets a WM_PAINT for that HWND . If the HWND is set in the surface Cairo uses this function to handle dirty areas too .
void
cairo_os2_surface_refresh_window (cairo_surface_t *surface,
                                  HPS              hps_begin_paint,
                                  PRECTL           prcl_begin_paint_rect)
{
    cairo_os2_surface_t *local_os2_surface;
    RECTL rclTemp;
    HPS hpsTemp = 0;
    local_os2_surface = (cairo_os2_surface_t *) surface;
    if ((!local_os2_surface) ||
        (local_os2_surface->base.backend != &cairo_os2_surface_backend))
    {
        return;
    }
    if (!hps_begin_paint) {
        hps_begin_paint = local_os2_surface->hps_client_window;
        if (!hps_begin_paint) {
            if (local_os2_surface->hwnd_client_window) {
                hpsTemp = WinGetPS(local_os2_surface->hwnd_client_window);
                hps_begin_paint = hpsTemp;
            }
            if (!hps_begin_paint)
                return;
        }
    }
    if (prcl_begin_paint_rect == NULL) {
        rclTemp.xLeft = 0;
        rclTemp.xRight = local_os2_surface->bitmap_info.cx;
        rclTemp.yTop = local_os2_surface->bitmap_info.cy;
        rclTemp.yBottom = 0;
    } else {
        rclTemp.xLeft = prcl_begin_paint_rect->xLeft;
        rclTemp.xRight = prcl_begin_paint_rect->xRight;
        rclTemp.yTop = local_os2_surface->bitmap_info.cy - prcl_begin_paint_rect->yBottom;
        rclTemp.yBottom = local_os2_surface->bitmap_info.cy - prcl_begin_paint_rect->yTop ;
    }
    if (DosRequestMutexSem (local_os2_surface->hmtx_use_private_fields, SEM_INDEFINITE_WAIT)
        != NO_ERROR)
    {
        if (hpsTemp)
            WinReleasePS(hpsTemp);
        return;
    }
    if ((local_os2_surface->dirty_area_present) &&
        (local_os2_surface->rcl_dirty_area.xLeft == rclTemp.xLeft) &&
        (local_os2_surface->rcl_dirty_area.xRight == rclTemp.xRight) &&
        (local_os2_surface->rcl_dirty_area.yTop == rclTemp.yTop) &&
        (local_os2_surface->rcl_dirty_area.yBottom == rclTemp.yBottom))
    {
        local_os2_surface->dirty_area_present = FALSE;
        _cairo_os2_surface_get_pixels_from_screen (local_os2_surface,
                                                   hps_begin_paint,
                                                   &rclTemp);
    } else {
        _cairo_os2_surface_blit_pixels (local_os2_surface,
                                        hps_begin_paint,
                                        &rclTemp);
    }
    DosReleaseMutexSem (local_os2_surface->hmtx_use_private_fields);
    if (hpsTemp)
        WinReleasePS(hpsTemp);
}
void cairo_os2_surface_refresh_window ( cairo_surface_t * surface , HPS hps_begin_paint , PRECTL prcl_begin_paint_rect ) { cairo_os2_surface_t * local_os2_surface ; RECTL rclTemp ; HPS hpsTemp = 0 ; local_os2_surface = ( cairo_os2_surface_t * ) surface ; if ( ( ! local_os2_surface ) || ( local_os2_surface -> base . backend != & cairo_os2_surface_backend ) ) { return ; } if ( ! hps_begin_paint ) { hps_begin_paint = local_os2_surface -> hps_client_window ; if ( ! hps_begin_paint ) { if ( local_os2_surface -> hwnd_client_window ) { hpsTemp = WinGetPS ( local_os2_surface -> hwnd_client_window ) ; hps_begin_paint = hpsTemp ; } if ( ! hps_begin_paint ) return ; } } if ( prcl_begin_paint_rect == NULL ) { rclTemp . xLeft = 0 ; rclTemp . xRight = local_os2_surface -> bitmap_info . cx ; rclTemp . yTop = local_os2_surface -> bitmap_info . cy ; rclTemp . yBottom = 0 ; } else { rclTemp . xLeft = prcl_begin_paint_rect -> xLeft ; rclTemp . xRight = prcl_begin_paint_rect -> xRight ; rclTemp . yTop = local_os2_surface -> bitmap_info . cy - prcl_begin_paint_rect -> yBottom ; rclTemp . yBottom = local_os2_surface -> bitmap_info . cy - prcl_begin_paint_rect -> yTop ; } if ( DosRequestMutexSem ( local_os2_surface -> hmtx_use_private_fields , SEM_INDEFINITE_WAIT ) != NO_ERROR ) { if ( hpsTemp ) WinReleasePS ( hpsTemp ) ; return ; } if ( ( local_os2_surface -> dirty_area_present ) && ( local_os2_surface -> rcl_dirty_area . xLeft == rclTemp . xLeft ) && ( local_os2_surface -> rcl_dirty_area . xRight == rclTemp . xRight ) && ( local_os2_surface -> rcl_dirty_area . yTop == rclTemp . yTop ) && ( local_os2_surface -> rcl_dirty_area . yBottom == rclTemp . yBottom ) ) { local_os2_surface -> dirty_area_present = FALSE ; _cairo_os2_surface_get_pixels_from_screen ( local_os2_surface , hps_begin_paint , & rclTemp ) ; } else { _cairo_os2_surface_blit_pixels ( local_os2_surface , hps_begin_paint , & rclTemp ) ; } DosReleaseMutexSem ( local_os2_surface -> hmtx_use_private_fields ) ; if ( hpsTemp ) WinReleasePS ( hpsTemp ) ; }
cairo_os2_surface_refresh_window:
 @surface: the cairo surface to refresh
 @hps_begin_paint: the presentation handle of the window to refresh
 @prcl_begin_paint_rect: the rectangle to redraw
cairo_os2_surface_refresh_window : @surface : the cairo surface to refresh @hps_begin_paint : the presentation handle of the window to refresh @prcl_begin_paint_rect : the rectangle to redraw
/* Invalid parameter (wrong surface)! */ /* If an HPS wasn't provided, see if we can get one. */ /* No HPS & no way to get one, so exit */ /* Update the whole window! */ /* Use the rectangle we got passed as parameter! */ /* Get mutex, we'll work with the pixel array! */ /* Could not get mutex! */ /* Aha, this call was because of a dirty area, so in this case we
         * have to blit the pixels from the screen to the surface!
         */ /* Okay, we have the surface, have the HPS
         * (might be from WinBeginPaint () or from WinGetPS () )
         * Now blit there the stuffs!
         */