LCOV - code coverage report
Current view: top level - gdraw - gwidgets.c (source / functions) Hit Total Coverage
Test: FontForge coverage report 2017-08-04 01:21:11+02:00 (commit d35f7e4107a9e1db65cce47c468fcc914cecb8fd) Lines: 0 42 0.0 %
Date: 2017-08-04 Functions: 0 2 0.0 %

          Line data    Source code
       1             : /* Copyright (C) 2000-2012 by George Williams */
       2             : /*
       3             :  * Redistribution and use in source and binary forms, with or without
       4             :  * modification, are permitted provided that the following conditions are met:
       5             : 
       6             :  * Redistributions of source code must retain the above copyright notice, this
       7             :  * list of conditions and the following disclaimer.
       8             : 
       9             :  * Redistributions in binary form must reproduce the above copyright notice,
      10             :  * this list of conditions and the following disclaimer in the documentation
      11             :  * and/or other materials provided with the distribution.
      12             : 
      13             :  * The name of the author may not be used to endorse or promote products
      14             :  * derived from this software without specific prior written permission.
      15             : 
      16             :  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
      17             :  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
      18             :  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
      19             :  * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
      20             :  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
      21             :  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
      22             :  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
      23             :  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      24             :  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
      25             :  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
      26             :  */
      27             : #include "gwidgetP.h"
      28             : #include "../gdraw/gdrawP.h"
      29             : #include <ggadget.h>
      30             : 
      31             : /* Temporarily do all drawing in this widget to a pixmap rather than the window */
      32             : /*  if events are orderly then we can share one pixmap for all windows */
      33             : static GWindow pixmap, cairo_pixmap;
      34             : /*  otherwise we create and destroy pixmaps */
      35             : 
      36           0 : GWindow _GWidget_GetPixmap(GWindow gw,GRect *rect) {
      37             :     GWindow ours;
      38             : 
      39           0 :     if ( gw->display!=screen_display )
      40           0 : return( gw );
      41           0 :     if ( gw->is_pixmap )
      42           0 : return( gw );
      43             : #ifdef UsingPThreads
      44             :     this is a critical section if there are multiple pthreads
      45             : #endif
      46           0 :     if ( GDrawHasCairo(gw)&gc_alpha ) {
      47           0 :         if ( cairo_pixmap==NULL || cairo_pixmap->pos.width<rect->x+rect->width ||
      48           0 :                              cairo_pixmap->pos.height<rect->y+rect->height ) {
      49           0 :             if ( cairo_pixmap!=NULL )
      50           0 :                 GDrawDestroyWindow(cairo_pixmap);
      51             :             /* The 0x8000 on width is a hack to tell create pixmap to use*/
      52             :             /*  cairo convas */
      53           0 :             cairo_pixmap = GDrawCreatePixmap(gw->display,0x8000|gw->pos.width,gw->pos.height);
      54             :         }
      55           0 :         ours = cairo_pixmap;
      56           0 :         cairo_pixmap = NULL;
      57             :     } else {
      58           0 :         if ( pixmap==NULL || pixmap->pos.width<rect->x+rect->width ||
      59           0 :                              pixmap->pos.height<rect->y+rect->height ) {
      60           0 :             if ( pixmap!=NULL )
      61           0 :                 GDrawDestroyWindow(pixmap);
      62           0 :             pixmap = GDrawCreatePixmap(gw->display,gw->pos.width,gw->pos.height);
      63             :         }
      64           0 :         ours = pixmap;
      65           0 :         pixmap = NULL;
      66             :     }
      67             : #ifdef UsingPThreads
      68             :     End critical section
      69             : #endif
      70           0 :     if ( ours==NULL )
      71           0 :         ours = gw;
      72             :     else {
      73           0 :         GWidgetD *gd = (GWidgetD *) (gw->widget_data);
      74           0 :         ours->widget_data = gd;
      75           0 :         gd->w = ours;
      76           0 :         GDrawFillRect(ours,rect,gw->ggc->bg);
      77             :     }
      78           0 : return( ours );
      79             : }
      80             : 
      81           0 : void _GWidget_RestorePixmap(GWindow gw, GWindow ours, GRect *rect) {
      82           0 :     GWidgetD *gd = (GWidgetD *) (gw->widget_data);
      83             : 
      84           0 :     if ( gw==ours )
      85           0 : return;                         /* it wasn't a pixmap, all drawing was to real window */
      86           0 :     GDrawDrawPixmap(gw, ours, rect, rect->x, rect->y);
      87             :     
      88             : #ifdef UsingPThreads
      89             :     this is a critical section if there are multiple pthreads
      90             : #endif
      91           0 :     if ( GDrawHasCairo(gw)&gc_alpha ) {
      92           0 :         if ( cairo_pixmap!=NULL )
      93           0 :             GDrawDestroyWindow(ours);
      94             :         else {
      95           0 :             cairo_pixmap = ours;
      96           0 :             ours->widget_data = NULL;
      97             :         }
      98             :     } else {
      99           0 :         if ( pixmap!=NULL )
     100           0 :             GDrawDestroyWindow(ours);
     101             :         else {
     102           0 :             pixmap = ours;
     103           0 :             ours->widget_data = NULL;
     104             :         }
     105             :     }
     106           0 :     gd->w = gw;
     107             : #ifdef UsingPThreads
     108             :     End critical section
     109             : #endif
     110             : }

Generated by: LCOV version 1.10