Evince
Evince is a document viewer capable of displaying multiple and single page document formats like PDF and Postscript.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
color.h File Reference
#include "common.h"
+ Include dependency graph for color.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

Ulongget_color_table (DviDevice *dev, int nlevels, Ulong fg, Ulong bg, double gamma, int density)
 
void mdvi_set_color __PROTO ((DviContext *, Ulong, Ulong))
 
void mdvi_pop_color __PROTO ((DviContext *))
 

Function Documentation

void mdvi_set_color __PROTO ( (DviContext *, Ulong, Ulong )
void mdvi_pop_color __PROTO ( (DviContext *)  )
Ulong* get_color_table ( DviDevice dev,
int  nlevels,
Ulong  fg,
Ulong  bg,
double  gamma,
int  density 
)

Definition at line 84 of file color.c.

86 {
87  ColorCache *cc, *tofree;
88  int lohits;
89  Ulong *pixels;
90  int status;
91 
92  lohits = color_cache[0].hits;
93  tofree = &color_cache[0];
94  /* look in the cache and see if we have one that matches this request */
95  for(cc = &color_cache[0]; cc < &color_cache[cc_entries]; cc++) {
96  if(cc->hits < lohits) {
97  lohits = cc->hits;
98  tofree = cc;
99  }
100  if(cc->fg == fg && cc->bg == bg && cc->density == density &&
101  cc->nlevels == nlevels && fabs(cc->gamma - gamma) <= GAMMA_DIFF)
102  break;
103  }
104 
105  if(cc < &color_cache[cc_entries]) {
106  cc->hits++;
107  return cc->pixels;
108  }
109 
110  DEBUG((DBG_DEVICE, "Adding color table to cache (fg=%lu, bg=%lu, n=%d)\n",
111  fg, bg, nlevels));
112 
113  /* no entry was found in the cache, create a new one */
114  if(cc_entries < CCSIZE) {
115  cc = &color_cache[cc_entries++];
116  cc->pixels = NULL;
117  } else {
118  cc = tofree;
119  mdvi_free(cc->pixels);
120  }
121  pixels = xnalloc(Ulong, nlevels);
122  status = dev->alloc_colors(dev->device_data,
123  pixels, nlevels, fg, bg, gamma, density);
124  if(status < 0) {
125  mdvi_free(pixels);
126  return NULL;
127  }
128  cc->fg = fg;
129  cc->bg = bg;
130  cc->gamma = gamma;
131  cc->density = density;
132  cc->nlevels = nlevels;
133  cc->pixels = pixels;
134  cc->hits = 1;
135  return pixels;
136 }

+ Here is the caller graph for this function: