static void drawgroup(int UNUSED(x), int UNUSED(y), int UNUSED(w), int UNUSED(height)) { GROUPCHAT *g = sitem->data; drawalpha(BM_GROUP, LIST_RIGHT + SCALE * 5, SCALE * 5, BM_CONTACT_WIDTH, BM_CONTACT_WIDTH, LIST_MAIN); setcolor(C_TITLE); setfont(FONT_TITLE); drawtext(LIST_RIGHT + 30 * SCALE, 1 * SCALE, g->name, g->name_length); setcolor(LIST_MAIN); setfont(FONT_STATUS); drawtext(LIST_RIGHT + 30 * SCALE, 8 * SCALE, g->topic, g->topic_length); setcolor(GRAY(150)); uint32_t i = 0; int k = LIST_RIGHT + 30 * SCALE; uint64_t time = get_time(); unsigned int pos_y = 15; while(i < g->peers) { uint8_t *name = g->peername[i]; if(name) { uint8_t buf[134]; memcpy(buf, name + 1, name[0]); memcpy(buf + name[0], ", ", 2); int w = textwidth(buf, name[0] + 2); if (i == g->our_peer_number) { setcolor(C_GREEN); } else if (time - g->last_recv_audio[i] <= (uint64_t)1 * 1000 * 1000 * 1000) { setcolor(C_RED); } else { setcolor(GRAY(150)); } if(k + w >= (utox_window_width - 32 * SCALE)) { if (pos_y == 15) { pos_y += 6; k = LIST_RIGHT + 30 * SCALE; } else { drawtext(k, pos_y * SCALE, (uint8_t*)"...", 3); break; } } drawtext(k, pos_y * SCALE, buf, name[0] + 2); k += w; } i++; } }
static void gc_start(void) { scm_val v = NIL, *p ; STACK_INIT() ; for (p = stack_start; p != (scm_val *)&p; p += stack_dir) if (IN_RANGE(*p)) GRAY(*p) ; FOREACH(v, roots) { scm_val r = *(scm_val *)(CAR(v).p) ; v.c->flags = FL_GC_BLACK ; if (PTR_AND_NO_FLAG(r, FL_GC_GRAY)) GRAY(r) ; }
static void set_palette(uint32_t *pal) { int r, g, b; memcpy(pal, ff_cga_palette, 16 * 4); pal += 16; #define COLOR(x) ((x) * 40 + 55) for (r = 0; r < 6; r++) for (g = 0; g < 6; g++) for (b = 0; b < 6; b++) *pal++ = 0xFF000000 | (COLOR(r) << 16) | (COLOR(g) << 8) | COLOR(b); #define GRAY(x) ((x) * 10 + 8) for (g = 0; g < 24; g++) *pal++ = 0xFF000000 | (GRAY(g) << 16) | (GRAY(g) << 8) | GRAY(g); }
void Line(int mv) { int y = ToPixel(mv); int color = GRAY(0xC0); Graphics.Rectangle(0,y,Graphics.Width(),1,color); DrawVoltage(mv,4,y-10,color); }
void SetPalette(u8 p) { if (p == _currentPalette) return; _currentPalette = p; for (u8 i = 0; i < 16; i++) { u8 c = i | (i << 4); u16 color = GRAY(c); // Lookup if (p == P_BLACK) ; else if (p == P_RED) color |= 0xF800; else if (p == P_BLUE) color |= 0x001F; else if (p == P_GREY) { c = 0x80 + (c >> 1); color = GRAY(c); } else {
void vibrance(unsigned char *image, int width, int height, int depth, int stride, float scale) { int i, j; unsigned char *pBuf; float Vib = scale / 100.f; float mVibranceTab[512] = {0}; int r, g, b, gray; int maxgb, red; float gs, sx, S; int dr,dg,db; for(i = -255; i < 256; i++) { mVibranceTab[i + 255] = Vib / (1+exp(-(i / 256.0f)*3)); } for(j = 0; j < height; j++) { pBuf = image + j * stride; for(i = 0; i < width; i++, pBuf += depth, pBuf += depth) { r = PR(pBuf); g = PG(pBuf); b = PB(pBuf); gray = GRAY(r, g, b); if(g > b) { maxgb = g; } else { maxgb = b; } red = r - maxgb + 255; sx = mVibranceTab[red]; dr = (int)(r + (r - gray) * sx); dg = (int)(g + (g - gray) * sx); db = (int)(b + (b - gray) * sx); PR(pBuf) = CLAMP(dr); PG(pBuf) = CLAMP(dg); PB(pBuf) = CLAMP(db); } } }
ViRatingItem::ViRatingItem(QWidget *parent, bool grayScale) : ViWidget(parent) { //mImage.load(ViThemeManager::image("star.png", ViThemeImage::Normal, ViThemeManager::Icon).path()); if(grayScale) { int value; QRgb rgb; for(int i = 0; i < mImage.width(); ++i) { for(int j = 0; j < mImage.height(); ++j) { rgb = mImage.pixel(i, j); value = GRAY(rgb); mImage.setPixel(i, j, qRgba(value, value, value, qAlpha(rgb))); } } } mOffset = 0; }
static void drawgroup(int UNUSED(x), int UNUSED(y), int UNUSED(w), int UNUSED(height)) { GROUPCHAT *g = sitem->data; drawalpha(BM_GROUP, LIST_RIGHT + SCALE * 5, SCALE * 5, BM_CONTACT_WIDTH, BM_CONTACT_WIDTH, LIST_MAIN); setcolor(C_TITLE); setfont(FONT_TITLE); drawtext(LIST_RIGHT + 30 * SCALE, 5 * SCALE, g->name, g->name_length); setcolor(LIST_MAIN); setfont(FONT_STATUS); drawtext(LIST_RIGHT + 30 * SCALE, 12 * SCALE, g->topic, g->topic_length); setcolor(GRAY(150)); uint32_t i = 0, j = 0; int k = LIST_RIGHT + 30 * SCALE; while(i < g->peers) { uint8_t *name = g->peername[j]; if(name) { uint8_t buf[134]; memcpy(buf, name + 1, name[0]); memcpy(buf + name[0], ", ", 2); int w = textwidth(buf, name[0] + 2); if(k + w >= width) { drawtext(k, 18 * SCALE, (uint8_t*)"...", 3); break; } drawtext(k, 18 * SCALE, buf, name[0] + 2); k += w; i++; } j++; } }
u8 c = i | (i << 4); u16 color = GRAY(c); // Lookup if (p == P_BLACK) ; else if (p == P_RED) color |= 0xF800; else if (p == P_BLUE) color |= 0x001F; else if (p == P_GREY) { c = 0x80 + (c >> 1); color = GRAY(c); } else { c = 0xFF - c; color = GRAY(c); color |= 0x001F; } u8* pp = _ppalette + i + i; pp[1] = color; pp[0] = color>>8; } } File* _diskFile; typedef struct { u8 format;
const struct token token = tokens[i]; if (token.tk == TK_FBEG || token.tk == TK_FEND) { continue; } if (token.tk != TK_WSPC && token.tk != TK_LCOM && token.tk != TK_BCOM) { alternate++; } const int len = token.end - token.beg; if (i == ntokens - 1 && error == LEX_UNKNOWN_TOKEN) { printf(RED("%.*s") CYAN("< Unknown token\n"), len ?: 1, token.beg); } else if (token.tk == TK_LCOM || token.tk == TK_BCOM) { printf(GRAY("%.*s"), len, token.beg); } else if (alternate % 2) { printf(GREEN("%.*s"), len, token.beg); } else { printf(YELLOW("%.*s"), len, token.beg); } } } int main(int argc, char **argv) { int fd; size_t size; struct stat statbuf; int exit_status = EXIT_FAILURE;
jit_host_reg jit_get_mapped_host_reg(struct jit_state *s, jit_reg reg, jit_reg_access a) { int n; jit_host_reg hostreg = JIT_HOST_REG_INVALID; jit_reg *regmap = s->p_emitter->host_regmap; jit_reg_age *agemap = s->p_emitter->host_agemap; jit_reg evicted = JIT_REG_INVALID; int64_t *spill = s->p_emitter->spill_vreg; if(reg == JIT_REG_INVALID) { goto l_exit; } // First, check if virtual register is already mapped to a host reg. for(n = 0; n < NUM_HOST_REGS; n++) { if(regmap[n] == reg) { hostreg = n; goto l_exit; } } // Virtual register not yet mapped; try to find a spare host register if(hostreg == JIT_HOST_REG_INVALID) { for(n = 0; n < NUM_HOST_REGS; n++) { if(regmap[n] == JIT_REG_INVALID) { regmap[n] = reg; hostreg = n; printf(GRAY(" vreg %d not mapped, using %s (host reg %d)\n"), reg, g_hostregsz[n], n); goto l_spillcheck; } } } // All the slots are taken: evict the oldest one, if they are not all // mapped to specific slots, and spill it so its value is saved if(hostreg == JIT_HOST_REG_INVALID) { int oldest = -1; int maxage = -1; for(n = 0; n < NUM_HOST_REGS; n++) { if(agemap[n] > maxage && !(s->p_emitter->host_busy & (1 << n))) { oldest = n; maxage = agemap[n]; } } if(oldest != -1) { evicted = regmap[oldest]; s->p_bufcur = jit_emit__mov_reg32_to_m(s->p_bufcur, oldest, (int32_t *)&spill[evicted]); s->p_emitter->spill_busy |= (1 << evicted); regmap[oldest] = reg; hostreg = oldest; printf(GRAY(" vreg %d in %s (host reg %d): need evict/spill vreg %d\n"), reg, g_hostregsz[hostreg], hostreg, evicted); } } l_spillcheck: if(a == JIT_ACCESS_W) { goto l_exit; } if(reg < NUM_SPILL_SLOTS && s->p_emitter->spill_busy & (1 << reg)) { printf(GRAY(" vreg %d was spilled, restoring\n"), reg); s->p_bufcur = jit_emit__mov_m32_to_reg(s->p_bufcur, (int32_t *)&spill[reg], hostreg); s->p_emitter->spill_busy &= ~(1 << reg); s->p_emitter->host_agemap[hostreg] = 0; } else if(reg >= NUM_SPILL_SLOTS) { printf("error: could not check spill, too many vregs\n"); } l_exit: return hostreg; }
inline int GRAY(QRgb rgb) { return GRAY(qRed(rgb), qGreen(rgb), qBlue(rgb)); }