Пример #1
0
void LDL_dsolve(
	int n,		/* D is n-by-n, where n >= 0 */
	double X[],	/* size n.	right-hand-side on input, soln. on output */
	double D[]	/* input of size n, not modified */
){
	int j;
	for (j = 0; j < n; j++){
		//X[j] *= D[j]; // D is actually inv(D)
		double s[2], t[2];
		CMUL(&D[8*j+0], &X[4*j+0], s);
		CADDPROD(s, &D[8*j+4], &X[4*j+2]);
		CMUL(&D[8*j+2], &X[4*j+0], t);
		CADDPROD(t, &D[8*j+6], &X[4*j+2]);
		CSET(&X[4*j+0], s);
		CSET(&X[4*j+2], t);
	}
}
Пример #2
0
// z[0],z[1] is (1,1) entry of matrix
// z[2],z[3] is (2,1) entry of matrix, etc.
static void invert_c2x2(double z[]){
	// [a c]
	// [b d]
	// ad-bc
	double idet[2], tmp[2];
	CMUL(&z[2*0], &z[2*3], idet);
	CMUL(&z[2*1], &z[2*2], tmp);
	CSUB(idet,tmp);
	CINV(idet);
	CSWP(&z[2*0], &z[2*3]);
	CNEG(&z[2*1]);
	CNEG(&z[2*2]);
	CMUL(&z[2*0], idet, tmp); CSET(&z[2*0], tmp);
	CMUL(&z[2*1], idet, tmp); CSET(&z[2*1], tmp);
	CMUL(&z[2*2], idet, tmp); CSET(&z[2*2], tmp);
	CMUL(&z[2*3], idet, tmp); CSET(&z[2*3], tmp);
}
uint8_t	ADMVideoAnimated::getCoupledConf( CONFcouple **couples)
{
   
      ADM_assert(_param);
      *couples=new CONFcouple(10);
#define CSET(x)  (*couples)->setCouple((char *)#x,(_param->x))
       CSET(isNTSC);
       CSET(backgroundImg);
        CSET(vignetteW);
        CSET(vignetteH);
#undef CSET
#define CSET(x)  (*couples)->setCouple((char *)"tc"#x,(_param->timecode[x]))
        CSET(0);
        CSET(1);
        CSET(2);
        CSET(3);
        CSET(4);
        CSET(5);

      return 1;
}
Пример #4
0
uint8_t ADMVideoEq2::getCoupledConf( CONFcouple **couples)
{
  ADM_assert(_param);
  *couples=new CONFcouple(8);


                CSET(contrast);
                CSET(brightness);
                CSET(saturation);
                CSET(gamma); 
                CSET(gamma_weight); 
                CSET(rgamma); 
                CSET(ggamma); 
                CSET(bgamma); 
                return 1;
}
Пример #5
0
void SHPaint_ctor(SHPaint *p)
{
  int i;
  
  p->type = VG_PAINT_TYPE_COLOR;
  CSET(p->color, 0,0,0,1);
  SH_INITOBJ(SHStopArray, p->instops);
  SH_INITOBJ(SHStopArray, p->stops);
  p->premultiplied = VG_FALSE;
  p->spreadMode = VG_COLOR_RAMP_SPREAD_PAD;
  p->tilingMode = VG_TILE_FILL;
  for (i=0; i<4; ++i) p->linearGradient[i] = 0.0f;
  for (i=0; i<5; ++i) p->radialGradient[i] = 0.0f;
  p->pattern = VG_INVALID_HANDLE;
  
  glGenTextures(1, &p->texture);
  glBindTexture(GL_TEXTURE_1D, p->texture);
  glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA, SH_GRADIENT_TEX_SIZE, 0,
               GL_RGBA, GL_FLOAT, NULL);
}
uint8_t ADMVideoMPdelogo::getCoupledConf( CONFcouple **couples)
{

                        ADM_assert(_param);
                        *couples=new CONFcouple(6);

#define CSET(x)  (*couples)->setCouple((char *)#x,(_param->x))
                CSET(xoff);
                CSET(yoff);
                CSET(lw);
                CSET(lh);
                CSET(show);
                CSET(band);
                return 1;

}
uint8_t	ADMVideoPartial::getCoupledConf( CONFcouple **couples)
{
			uint32_t nbParam=0;

			ADM_assert(_param);

			// first we ask the child its config
			CONFcouple *child;
			if(!_son->getCoupledConf(&child))
			{
				// no param for child
#define CSET(x)  (*couples)->setCouple((char *)#x,(_param->x))
				*couples=new CONFcouple(3);
				CSET(_start);
				CSET(_end);
				CSET(_tag);
				return 1;
			}

			// grab child param
			nbParam=child->getNumber();

			*couples=new CONFcouple(3+nbParam);
			CSET(_start);
			CSET(_end);
			CSET(_tag);

	// then set the child ones
	char *nm,*vl;

	for(uint32_t i=0;i<nbParam;i++)
	{
		child->getEntry(i,&nm, &vl);
		  (*couples)->setCouple(nm,vl);
	}
	// delete child
	delete child;

	return 1;

}
void VGContext_ctor(VGContext *c)
{
    /* Surface info */
    c->surfaceWidth = 0;
    c->surfaceHeight = 0;

    /* GetString info */
    strncpy(c->vendor, "Ivan Leben", sizeof(c->vendor));
    strncpy(c->renderer, "ShivaVG 0.1.0", sizeof(c->renderer));
    strncpy(c->version, "1.0", sizeof(c->version));
    strncpy(c->extensions, "", sizeof(c->extensions));

    /* Mode settings */
    c->matrixMode = VG_MATRIX_PATH_USER_TO_SURFACE;
    c->fillRule = VG_EVEN_ODD;
    c->imageQuality = VG_IMAGE_QUALITY_FASTER;
    c->renderingQuality = VG_RENDERING_QUALITY_BETTER;
    c->blendMode = VG_BLEND_SRC_OVER;
    c->imageMode = VG_DRAW_IMAGE_NORMAL;

    /* Scissor rectangles */
    SH_INITOBJ(SHRectArray, c->scissor);
    c->scissoring = VG_FALSE;
    c->masking = VG_FALSE;

    /* Stroke parameters */
    c->strokeLineWidth = 1.0f;
    c->strokeCapStyle = VG_CAP_BUTT;
    c->strokeJoinStyle = VG_JOIN_MITER;
    c->strokeMiterLimit = 4.0f;
    c->strokeDashPhase = 0.0f;
    c->strokeDashPhaseReset = VG_FALSE;
    SH_INITOBJ(SHFloatArray, c->strokeDashPattern);

    /* Edge fill color for vgConvolve and pattern paint */
    CSET(c->tileFillColor, 0,0,0,0);

    /* Color for vgClear */
    CSET(c->clearColor, 0,0,0,0);

    /* Color components layout inside pixel */
    c->pixelLayout = VG_PIXEL_LAYOUT_UNKNOWN;

    /* Source format for image filters */
    c->filterFormatLinear = VG_FALSE;
    c->filterFormatPremultiplied = VG_FALSE;
    c->filterChannelMask = VG_RED|VG_GREEN|VG_BLUE|VG_ALPHA;

    /* Matrices */
    SH_INITOBJ(SHMatrix3x3, c->pathTransform);
    SH_INITOBJ(SHMatrix3x3, c->imageTransform);
    SH_INITOBJ(SHMatrix3x3, c->fillTransform);
    SH_INITOBJ(SHMatrix3x3, c->strokeTransform);

    /* Paints */
    c->fillPaint = NULL;
    c->strokePaint = NULL;
    SH_INITOBJ(SHPaint, c->defaultPaint);

    /* Error */
    c->error = VG_NO_ERROR;

    /* Resources */
    SH_INITOBJ(SHPathArray, c->paths);
    SH_INITOBJ(SHPaintArray, c->paints);
    SH_INITOBJ(SHImageArray, c->images);

    shLoadExtensions(c);
}
Пример #9
0
    Nanometer
   @item in
    Inch (1in = 0.0254m)
   @item mil
    Mil (1000mil = 1in)
   @item cmil
    Centimil (1/100 mil)
@end table

@ftable @code
@item --via-thickness <num>
Default diameter of vias. Default value is @code{60mil}.
@end ftable
%end-doc
*/
  CSET (ViaThickness, MIL_TO_COORD(60), "via-thickness",
  "default diameter of vias in 1/100 mil"),

/* %start-doc options "5 Sizes"
@ftable @code
@item --via-drilling-hole <num>
Default diameter of holes. Default value is @code{28mil}.
@end ftable
%end-doc
*/
  CSET (ViaDrillingHole, MIL_TO_COORD(28), "via-drilling-hole",
  "default diameter of holes"),

/* %start-doc options "5 Sizes"
@ftable @code
@item --line-thickness <num>
Default thickness of new lines. Default value is @code{10mil}.
Пример #10
0
void GetTriforce::update()
{
    if(counter==40)
    {
        actiontype oldaction = (actiontype)link.getAction();
        ALLOFF(true, false);
        link.setAction(oldaction); // have to reset this
    }
    
    if(counter>=40 && counter<88)
    {
        if(get_bit(quest_rules,qr_FADE))
        {
            if((counter&3)==0)
            {
                fade_interpolate(RAMpal,flash_pal,RAMpal,42,0,CSET(6)-1);
                refreshpal=true;
            }
            
            if((counter&3)==2)
            {
                loadpalset(0,0);
                loadpalset(1,1);
                loadpalset(5,5);
                
                if(currscr<128) loadlvlpal(DMaps[currdmap].color);
                else loadlvlpal(0xB); // TODO: Cave/Item Cellar distinction?
            }
        }
        else
        {
            if((counter&7)==0)
            {
                for(int cs2=2; cs2<5; cs2++)
                {
                    for(int i=1; i<16; i++)
                    {
                        RAMpal[CSET(cs2)+i]=flash_pal[CSET(cs2)+i];
                    }
                }
                
                refreshpal=true;
            }
            
            if((counter&7)==4)
            {
                if(currscr<128) loadlvlpal(DMaps[currdmap].color);
                else loadlvlpal(0xB);
                
                loadpalset(5,5);
            }
        }
    }
    
    if(itemsbuf[triforceID].flags & ITEM_GAMEDATA)
    {
        if(counter==88)
        {
            refill_what=REFILL_ALL;
            refill_why=triforceID;
            link.StartRefill(REFILL_ALL);
            link.refill();
        }
        
        if(counter==89)
        {
            if(link.refill())
                counter--;
        }
    }
    
    if(itemsbuf[triforceID].flags & ITEM_FLAG1) // Warp out flag
    {
        if(counter>=208 && counter<288)
        {
            x2++;
            counter2++;
            switch(counter2)
            {
            case 5:
                counter2=0;
                
            case 0:
            case 2:
            case 3:
                x2++;
                break;
            }
        }
        
        do_dcounters();
        
        if(counter<288)
        {
            int curtain_x=x2&0xF8;
            draw_screen_clip_rect_x1=curtain_x;
            draw_screen_clip_rect_x2=255-curtain_x;
        }
    }
    
    counter++;
    if(counter<408)
        return;
    if(midi_pos > 0 || (zcmusic && zcmusic->position<800))   // 800 may not be just right, but it works
        return;
    
    finish();
    draw_screen_clip_rect_x1=0;
    draw_screen_clip_rect_x2=255;
    show_subscreen_items=true;
    
    if(itemsbuf[triforceID].flags & ITEM_FLAG1 && currscr < 128)
    {
        link.setScrollDir(link.dir);
        link.dowarp(1,0); //side warp
    }
    else
        playLevelMusic();
}
Пример #11
0
uint8_t	ADMVideoSubtitle::getCoupledConf( CONFcouple **couples)
{
SUBCONF *_param;

			_param=_conf; // keep macro happy
			ADM_assert(_param);
			*couples=new CONFcouple(15);

			CSET(_fontsize);
			CSET(_subname);
			CSET(_fontname);
			CSET(_charset);
			CSET(_baseLine);
			CSET(_Y_percent);
			CSET(_U_percent);
			CSET(_V_percent);
			CSET(_selfAdjustable);
			CSET(_delay);
			CSET(_useBackgroundColor);
			CSET(_bg_Y_percent);
			CSET(_bg_U_percent);
			CSET(_bg_V_percent);
                        (*couples)->setCouple("_blend",(uint32_t)_param->_blend);

		return 1;

}
Пример #12
0
void Message::executeControlCode(char code)
{
    int arg1, arg2, arg3;
    int numArgs=getNumControlCodeArgs(code);
    
    if(numArgs>=1)
        arg1=stream.getControlCodeArgument();
    if(numArgs>=2)
        arg2=stream.getControlCodeArgument();
    if(numArgs==3)
        arg3=stream.getControlCodeArgument();
    
    switch(code)
    {
        // Message property change codes
    case MSGC_SPEED:
        textSpeed=arg1;
        break;
        
    case MSGC_COLOUR:
        renderer.setColor(CSET(arg1)+arg2);
        break;
        
        // Message switch codes
    case MSGC_GOTOIFRAND:
        if(arg1<=1 || rand()%arg1==0)
            manager.switchTo(arg2);
        break;
        
    case MSGC_GOTOIFGLOBAL: // Screen->D[], not global. Should be renamed.
        {
            arg1=vbound(arg1, 0, 7);
            int scr=(get_currdmap()<<7)+get_currscr();
            if(DMaps[get_currdmap()].type!=dmOVERW)
                scr-=DMaps[get_currdmap()].xoff;
            
            if(game->screen_d[scr][arg1]>=arg2)
                manager.switchTo(arg3);
            break;
        }
        
    case MSGC_GOTOIF: // If item. Rename this one, too.
        if(arg1>=0 && arg1<MAXITEMS && game->item[arg1])
            manager.switchTo(arg2);
        break;
        
    case MSGC_GOTOIFCTR:
        if(game->get_counter(arg1)>=arg2)
            manager.switchTo(arg3);
        break;
        
    case MSGC_GOTOIFCTRPC:
        {
            int amount=(arg2*game->get_maxcounter(arg1))/100;
            if(game->get_counter(arg1)>=amount)
                manager.switchTo(arg3);
            break;
        }
        
    case MSGC_GOTOIFTRICOUNT:
        if(TriforceCount()>=arg1)
            manager.switchTo(arg2);
        break;
        
    case MSGC_GOTOIFTRI:
        if(arg1>=0 && arg1<MAXLEVELS && (game->lvlitems[arg1]&liTRIFORCE)!=0)
            manager.switchTo(arg2);
        break;
        
        // Item and counter codes
    case MSGC_CTRUP:
        game->change_counter(arg2, arg1);
        break;
    
    case MSGC_CTRDN:
        game->change_counter(-arg2, arg1);
        break;
    
    case MSGC_CTRSET:
        game->set_counter(vbound(arg2, 0, game->get_maxcounter(arg1)), arg1);
        break;
    
    case MSGC_CTRUPPC:
        {
            int amount=(arg2*game->get_maxcounter(arg1))/100;
            game->change_counter(arg2, amount);
            break;
        }
        
    case MSGC_CTRDNPC:
        {
            int amount=(arg2*game->get_maxcounter(arg1))/100;
            game->change_counter(-arg2, amount);
            break;
        }
        
    case MSGC_CTRSETPC:
        {
            int amount=vbound((arg2*game->get_maxcounter(arg1))/100,
              0, game->get_maxcounter(arg1));
            game->set_counter(amount, arg1);
            break;
        }
        
    case MSGC_GIVEITEM:
        getitem(arg1);
        break;
        
    case MSGC_TAKEITEM:
        takeitem(arg1);
        break;
        
        // Other codes
    case MSGC_MIDI:
        if(arg1==0)
            music_stop();
        else
            jukebox(arg1+(ZC_MIDI_COUNT-1));
        break;
        
    case MSGC_SFX:
        sfx(arg1);
        break;
    }
}
Пример #13
0
void GameOver::update()
{
    if(counter<254)
    {
        if(counter<=32)
            link.setHitTimer(32-counter);
        
        if(counter>=62 && counter<138)
        {
            switch((counter-62)%20)
            {
            case 0:
                link.dir=right;
                break;
                
            case 5:
                link.dir=up;
                break;
                
            case 10:
                link.dir=left;
                break;
                
            case 15:
                link.dir=down;
                break;
            }
            
            link.linkstep();
        }
        
        if(counter>=194 && counter<208)
        {
            if(counter==194)
                link.setAction(dying);
                
            link.extend = 0;
            link.cs = wpnsbuf[iwDeath].csets&15;
            link.tile = wpnsbuf[iwDeath].tile;
            
            if(BSZ)
                link.tile+=(counter-194)/3;
            else if(counter>=204)
                link.tile++;
        }
        
        if(counter==208)
            link.setDontDraw(true);
            
        if(get_bit(quest_rules,qr_FADE))
        {
            if(counter < 170)
            {
                if(counter<60)
                {
                    draw_screen(tmpscr);
                    //reuse our static subscreen
                    set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
                    blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
                }
                
                if(counter==60)
                {
                    red_shift();
                    create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
                    create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
                    memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
                    
                    for(int q=0; q<PAL_SIZE; q++)
                    {
                        trans_table2.data[0][q] = q;
                        trans_table2.data[q][q] = q;
                    }
                }
                
                if(counter>=60 && counter<=169)
                {
                    draw_screen(tmpscr);
                    //reuse our static subscreen
                    blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
                    red_shift();
                    
                }
                
                if(counter>=139 && counter<=169)//fade from red to black
                {
                    fade_interpolate(RAMpal,black_palette,RAMpal, (counter-138)<<1, 224, 255);
                    create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
                    create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
                    memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
                    
                    for(int q=0; q<PAL_SIZE; q++)
                    {
                        trans_table2.data[0][q] = q;
                        trans_table2.data[q][q] = q;
                    }
                    
                    refreshpal=true;
                }
            }
            else //counter>=170
            {
                if(counter==170)//make Link grayish
                {
                    fade_interpolate(RAMpal,black_palette,RAMpal,64, 224, 255);
                    
                    for(int i=CSET(6); i < CSET(7); i++)
                    {
                        int g = (RAMpal[i].r + RAMpal[i].g + RAMpal[i].b)/3;
                        RAMpal[i] = _RGB(g,g,g);
                    }
                    
                    refreshpal = true;
                }
                
                //draw only link. otherwise black layers might cover him.
                rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
                link.draw(framebuf);
                blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
            }
        }
        else //!qr_FADE
        {
            if(counter==58)
            {
                for(int i = 0; i < 96; i++)
                    tmpscr->cset[i] = 3;
                    
                for(int j=0; j<6; j++)
                    if(tmpscr->layermap[j]>0)
                        for(int i=0; i<96; i++)
                            tmpscr2[j].cset[i] = 3;
            }
            
            if(counter==59)
            {
                for(int i = 96; i < 176; i++)
                    tmpscr->cset[i] = 3;
                    
                for(int j=0; j<6; j++)
                    if(tmpscr->layermap[j]>0)
                        for(int i=96; i<176; i++)
                            tmpscr2[j].cset[i] = 3;
            }
            
            if(counter==60)
            {
                for(int i=0; i<176; i++)
                {
                    tmpscr->cset[i] = 2;
                }
                
                for(int j=0; j<6; j++)
                    if(tmpscr->layermap[j]>0)
                        for(int i=0; i<176; i++)
                            tmpscr2[j].cset[i] = 2;
                            
                for(int i=1; i<16; i+=3)
                {
                    RAMpal[CSET(2)+i]   = NESpal(0x17);
                    RAMpal[CSET(2)+i+1] = NESpal(0x16);
                    RAMpal[CSET(2)+i+2] = NESpal(0x26);
                }
                
                refreshpal=true;
            }
            
            if(counter==139)
                slide_in_color(0x06);
                
            if(counter==149)
                slide_in_color(0x07);
                
            if(counter==159)
                slide_in_color(0x0F);
                
            if(counter==169)
            {
                slide_in_color(0x0F);
                slide_in_color(0x0F);
            }
            
            if(counter==170)
            {
                for(int i=1; i<16; i+=3)
                {
                    RAMpal[CSET(6)+i]   = NESpal(0x10);
                    RAMpal[CSET(6)+i+1] = NESpal(0x30);
                    RAMpal[CSET(6)+i+2] = NESpal(0x00);
                    refreshpal = true;
                }
            }
            
            if(counter < 169)
            {
                draw_screen(tmpscr);
                //reuse our static subscreen
                blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
            }
            else
            {
                //draw only link. otherwise black layers might cover him.
                rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
                link.draw(framebuf);
                blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
            }
        }
    }
    else if(counter<350)//draw 'GAME OVER' text
    {
        clear_bitmap(framebuf);
        blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
        textout_ex(framebuf,zfont,"GAME OVER",96,playing_field_offset+80,1,-1);
    }
    else
    {
        clear_bitmap(framebuf);
    }
    
    //SFX... put them all here
    switch(counter)
    {
    case   0:
        sfx(WAV_OUCH,pan(int(link.x)));
        break;
        
    case  60:
        sfx(WAV_SPIRAL);
        break;
        
    case 194:
        sfx(WAV_MSG);
        break;
    }
    
    //advanceframe(true);
    counter++;
    if(counter<353)
        return;
    
    finish();
    destroy_bitmap(subscrbmp);
    link.setAction(none);
    link.setDontDraw(false);
}
Пример #14
0
void PrepareCrosshair(int num, byte tab[10][10])
{
    int i, j;
    for (i=0; i < 10; i++)
        for (j=0; j < 10; j++)
            tab[i][j] = 0;

    switch (num)
    {
    case 3:
        CSET(0-2,0-2);
        CSET(0-3,0-3);
        CSET(0-4,0-4);
        CSET(0+2,0+2);
        CSET(0+3,0+3);
        CSET(0+4,0+4);
        CSET(0+2,0-2);
        CSET(0+3,0-3);
        CSET(0+4,0-4);
        CSET(0-2,0+2);
        CSET(0-3,0+3);
        CSET(0-4,0+4);
        break;
    case 4:
        CSET(0 - 2, 0 - 2);
        CSET(0 - 3, 0 - 3);
        CSET(0 + 2, 0 + 2);
        CSET(0 + 3, 0 + 3);
        CSET(0 + 2, 0 - 2);
        CSET(0 + 3, 0 - 3);
        CSET(0 - 2, 0 + 2);
        CSET(0 - 3, 0 + 3);
        break;
    case 5:
        CSET(0, 0 - 2);
        CSET(0, 0 - 3);
        CSET(0, 0 - 4);
        CSET(0 + 2, 0 + 2);
        CSET(0 + 3, 0 + 3);
        CSET(0 + 4, 0 + 4);
        CSET(0 - 2, 0 + 2);
        CSET(0 - 3, 0 + 3);
        CSET(0 - 4, 0 + 4);
        break;
    case 6:
        CSET(0    , 0 - 1);
        CSET(0 - 1, 0    );
        CSET(0    , 0    );
        CSET(0 + 1, 0    );
        CSET(0    , 0 + 1);
        break;
    case 7:
        CSET(0 - 1, 0 - 1);
        CSET(0    , 0 - 1);
        CSET(0 + 1, 0 - 1);
        CSET(0 - 1, 0    );
        CSET(0    , 0    );
        CSET(0 + 1, 0    );
        CSET(0 - 1, 0 + 1);
        CSET(0    , 0 + 1);
        CSET(0 + 1, 0 + 1);
        break;
    case 8:
        CSET(0 + 1, 0 + 1);
        CSET(0    , 0 + 1);
        CSET(0 + 1, 0    );
        CSET(0    , 0    );
        break;
    case 9:
        CSET(0, 0);
        break;
    case 10:
        CSET(-2, -2);
        CSET(-2, -1);
        CSET(-1, -2);
        CSET(2, -2);
        CSET(2, -1);
        CSET(1, -2);
        CSET(-2, 2);
        CSET(-2, 1);
        CSET(-1, 2);

        CSET(2, 2);
        CSET(2, 1);
        CSET(1, 2);
        break;
    case 11:
        CSET(0, -1);
        CSET(1, -1);
        CSET(-1, 0);
        CSET(2, 0);
        CSET(-1, 1);
        CSET(2, 1);
        CSET(0, 2);
        CSET(1, 2);
        break;
    case 12:
        CSET(0, -1);
        CSET(1, -1);
        CSET(-1, 0);
        CSET(2, 0);
        CSET(-1, 1);
        CSET(2, 1);
        CSET(0, 2);
        CSET(1, 2);

        CSET(0, 0);
        CSET(1, 0);
        CSET(0, 1);
        CSET(1, 1);
        break;
    case 13:
        CSET(0, -2);
        CSET(1, -2);
        CSET(-1, -1);
        CSET(0, -1);
        CSET(1, -1);
        CSET(2, -1);
        CSET(-2, 0);
        CSET(-1, 0);
        CSET(2, 0);
        CSET(3, 0);
        CSET(-2, 1);
        CSET(-1, 1);
        CSET(2, 1);
        CSET(3, 1);
        CSET(-1, 2);
        CSET(0, 2);
        CSET(1, 2);
        CSET(2, 2);
        CSET(0, 3);
        CSET(1, 3);
        break;
    case 14:
        CSET(0, -2);
        CSET(1, -2);
        CSET(-1, -1);
        CSET(0, -1);
        CSET(1, -1);
        CSET(2, -1);
        CSET(-2, 0);
        CSET(-1, 0);
        CSET(2, 0);
        CSET(3, 0);
        CSET(-2, 1);
        CSET(-1, 1);
        CSET(2, 1);
        CSET(3, 1);
        CSET(-1, 2);
        CSET(0, 2);
        CSET(1, 2);
        CSET(2, 2);
        CSET(0, 3);
        CSET(1, 3);

        CSET(0, 0);
        CSET(1, 0);
        CSET(0, 1);
        CSET(1, 1);
        break;
    case 15:
        CSET(-1, -3);
        CSET( 0, -3);
        CSET( 1, -3);

        CSET(-2, -2);
        CSET(-1, -2);
        CSET( 0, -2);
        CSET( 1, -2);
        CSET( 2, -2);

        CSET(-3, -1);
        CSET(-2, -1);
        CSET(-1, -1);
        CSET( 1, -1);
        CSET( 2, -1);
        CSET( 3, -1);

        CSET(-3, 0);
        CSET(-2, 0);
        CSET( 2, 0);
        CSET( 3, 0);

        CSET(-3, 1);
        CSET(-2, 1);
        CSET(-1, 1);
        CSET( 1, 1);
        CSET( 2, 1);
        CSET( 3, 1);

        CSET(-2, 2);
        CSET(-1, 2);
        CSET( 0, 2);
        CSET( 1, 2);
        CSET( 2, 2);

        CSET(-1, 3);
        CSET( 0, 3);
        CSET( 1, 3);
        break;
    case 16:
        CSET(-1, -3);
        CSET( 0, -3);
        CSET( 1, -3);

        CSET(-2, -2);
        CSET(-1, -2);
        CSET( 0, -2);
        CSET( 1, -2);
        CSET( 2, -2);

        CSET(-3, -1);
        CSET(-2, -1);
        CSET(-1, -1);
        CSET( 1, -1);
        CSET( 2, -1);
        CSET( 3, -1);

        CSET(-3, 0);
        CSET(-2, 0);
        CSET( 2, 0);
        CSET( 3, 0);

        CSET(-3, 1);
        CSET(-2, 1);
        CSET(-1, 1);
        CSET( 1, 1);
        CSET( 2, 1);
        CSET( 3, 1);

        CSET(-2, 2);
        CSET(-1, 2);
        CSET( 0, 2);
        CSET( 1, 2);
        CSET( 2, 2);

        CSET(-1, 3);
        CSET( 0, 3);
        CSET( 1, 3);

        CSET(-1,  0);
        CSET( 1,  0);
        CSET( 0, -1);
        CSET( 0,  1);
        CSET( 0,  0);
        break;
    default:
        CSET(0 - 1, 0);
        CSET(0 - 3, 0);
        CSET(0 + 1, 0);
        CSET(0 + 3, 0);
        CSET(0, 0 - 1);
        CSET(0, 0 - 3);
        CSET(0, 0 + 1);
        CSET(0, 0 + 3);
        break;
    }
}
Пример #15
0
static void shSet(VGContext *context, VGParamType type, SHint count,
                  const void* values, SHint floats)
{
  SHfloat fvalue = 0.0f;
  SHint ivalue = 0;
  VGboolean bvalue = VG_FALSE;
  int i = 0;
  
  /* Check for negative count */
  SH_RETURN_ERR_IF(count<0, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
  
  /* Check for empty vector */
  SH_RETURN_ERR_IF(!values && count!=0, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
  
  /* Pre-convert first value for non-vector params */
  if (count == 1) {
    fvalue = shParamToFloat(values, floats, 0);
    ivalue = shParamToInt(values, floats, 0);
    bvalue = (ivalue ? VG_TRUE : VG_FALSE);
  }
  
  switch (type)
  {
  case VG_MATRIX_MODE:
    SH_RETURN_ERR_IF(count!=1, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    SH_RETURN_ERR_IF(!shIsEnumValid(type,ivalue), VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    context->matrixMode = (VGMatrixMode)ivalue;
    break;
    
  case VG_FILL_RULE:
    SH_RETURN_ERR_IF(count!=1, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    SH_RETURN_ERR_IF(!shIsEnumValid(type,ivalue), VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    context->fillRule = (VGFillRule)ivalue;
    break;
    
  case VG_IMAGE_QUALITY:
    SH_RETURN_ERR_IF(count!=1, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    SH_RETURN_ERR_IF(!shIsEnumValid(type,ivalue), VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    context->imageQuality = (VGImageQuality)ivalue;
    break;
    
  case VG_RENDERING_QUALITY:
    SH_RETURN_ERR_IF(count!=1, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    SH_RETURN_ERR_IF(!shIsEnumValid(type,ivalue), VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    context->renderingQuality = (VGRenderingQuality)ivalue;
    break;
    
  case VG_BLEND_MODE:
    SH_RETURN_ERR_IF(count!=1, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    SH_RETURN_ERR_IF(!shIsEnumValid(type,ivalue), VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    context->blendMode = (VGBlendMode)ivalue;
    break;
    
  case VG_IMAGE_MODE:
    SH_RETURN_ERR_IF(count!=1, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    SH_RETURN_ERR_IF(!shIsEnumValid(type,ivalue), VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    context->imageMode = (VGImageMode)ivalue;
    break;
    
  case VG_STROKE_CAP_STYLE:
    SH_RETURN_ERR_IF(count!=1, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    SH_RETURN_ERR_IF(!shIsEnumValid(type,ivalue), VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    context->strokeCapStyle = (VGCapStyle)ivalue;
    break;
    
  case VG_STROKE_JOIN_STYLE:
    SH_RETURN_ERR_IF(count!=1, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    SH_RETURN_ERR_IF(!shIsEnumValid(type,ivalue), VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    context->strokeJoinStyle = (VGJoinStyle)ivalue;
    break;
    
  case VG_PIXEL_LAYOUT:
    SH_RETURN_ERR_IF(count!=1, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    SH_RETURN_ERR_IF(!shIsEnumValid(type,ivalue), VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    context->pixelLayout = (VGPixelLayout)ivalue;
    break;
    
  case VG_FILTER_CHANNEL_MASK:
    SH_RETURN_ERR_IF(count!=1, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    context->filterChannelMask = (VGbitfield)ivalue;
    break;
    
  case VG_FILTER_FORMAT_LINEAR:
    SH_RETURN_ERR_IF(count!=1, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    context->filterFormatLinear = bvalue;
    break;
    
  case VG_FILTER_FORMAT_PREMULTIPLIED:
    SH_RETURN_ERR_IF(count!=1, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    context->filterFormatPremultiplied = bvalue;
    break;
    
  case VG_STROKE_DASH_PHASE_RESET:
    SH_RETURN_ERR_IF(count!=1, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    context->strokeDashPhaseReset = bvalue;
    break;
    
  case VG_MASKING:
    SH_RETURN_ERR_IF(count!=1, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    context->masking = bvalue;
    break;
    
  case VG_SCISSORING:
    SH_RETURN_ERR_IF(count!=1, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    context->scissoring = bvalue;
    if (bvalue)
      shEnableScissoring(context);
    else
      shDisableScissoring(context);
    break;
    
  case VG_STROKE_LINE_WIDTH:
    SH_RETURN_ERR_IF(count!=1, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    context->strokeLineWidth = fvalue;
    break;
    
  case VG_STROKE_MITER_LIMIT:
    SH_RETURN_ERR_IF(count!=1, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    context->strokeMiterLimit = SH_MAX(fvalue, 1.0f);
    break;
    
  case VG_STROKE_DASH_PHASE:
    SH_RETURN_ERR_IF(count!=1, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    context->strokeDashPhase = fvalue;
    break;
    
  case VG_STROKE_DASH_PATTERN:
    
    /* TODO: limit by the VG_MAX_DASH_COUNT value */
    shFloatArrayClear(&context->strokeDashPattern);
    for (i=0; i<count; ++i)
      shFloatArrayPushBack(&context->strokeDashPattern,
                           shParamToFloat(values, floats, i));
    break;
  case VG_TILE_FILL_COLOR:
    
    SH_RETURN_ERR_IF(count!=4, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    CSET(context->tileFillColor,
         shParamToFloat(values, floats, 0),
         shParamToFloat(values, floats, 1),
         shParamToFloat(values, floats, 2),
         shParamToFloat(values, floats, 3));
    
    break;
  case VG_CLEAR_COLOR:
    
    SH_RETURN_ERR_IF(count!=4, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    CSET(context->clearColor,
         shParamToFloat(values, floats, 0),
         shParamToFloat(values, floats, 1),
         shParamToFloat(values, floats, 2),
         shParamToFloat(values, floats, 3));
    
    break;
  case VG_SCISSOR_RECTS:
    
    SH_RETURN_ERR_IF(count % 4, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    shBuildScissorContext(context, count, values, floats);
    
    break;
    
  case VG_MAX_SCISSOR_RECTS:
  case VG_MAX_DASH_COUNT:
  case VG_MAX_KERNEL_SIZE:
  case VG_MAX_SEPARABLE_KERNEL_SIZE:
  case VG_MAX_COLOR_RAMP_STOPS:
  case VG_MAX_IMAGE_WIDTH:
  case VG_MAX_IMAGE_HEIGHT:
  case VG_MAX_IMAGE_PIXELS:
  case VG_MAX_IMAGE_BYTES:
  case VG_MAX_FLOAT:
  case VG_MAX_GAUSSIAN_STD_DEVIATION:
    /* Read-only */ break;
    
  default:
    /* Invalid VGParamType */
    SH_RETURN_ERR(VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
  }
  
  SH_RETURN(SH_NO_RETVAL);
}
Пример #16
0
static void shSetParameter(VGContext *context, VGHandle object,
                           SHResourceType rtype, VGint ptype,
                           SHint count, const void *values, SHint floats)
{
  SHfloat fvalue = 0.0f;
  SHint ivalue = 0;
  VGboolean bvalue = VG_FALSE;
  int i;
  
  /* Check for negative count */
  SH_RETURN_ERR_IF(count<0, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
  
  /* Check for empty vector */
  SH_RETURN_ERR_IF(!values && count!=0, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
  
  /* Pre-convert first value for non-vector params */
  if (count == 1) {
    fvalue = shParamToFloat(values, floats, 0);
    ivalue = shParamToInt(values, floats, 0);
    bvalue = (ivalue ? VG_TRUE : VG_FALSE);
  }
  
  switch (rtype)
  {
  case SH_RESOURCE_PATH: switch (ptype) { /* Path parameters */
      
    case VG_PATH_FORMAT:
    case VG_PATH_DATATYPE:
    case VG_PATH_SCALE:
    case VG_PATH_BIAS:
    case VG_PATH_NUM_SEGMENTS:
    case VG_PATH_NUM_COORDS:
      /* Read-only */ break;
      
    default:
      /* Invalid VGParamType */
      SH_RETURN_ERR(VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
      
    } break;
  case SH_RESOURCE_PAINT: switch (ptype) { /* Paint parameters */
      
    case VG_PAINT_TYPE:
      SH_RETURN_ERR_IF(count != 1, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
      SH_RETURN_ERR_IF(!shIsEnumValid(ptype,ivalue), VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
      ((SHPaint*)object)->type = (VGPaintType)ivalue;
      break;
      
    case VG_PAINT_COLOR:
      SH_RETURN_ERR_IF(count != 4, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
      ((SHPaint*)object)->color.r = shParamToFloat(values, floats, 0);
      ((SHPaint*)object)->color.g = shParamToFloat(values, floats, 1);
      ((SHPaint*)object)->color.b = shParamToFloat(values, floats, 2);
      ((SHPaint*)object)->color.a = shParamToFloat(values, floats, 3);
      break;
      
    case VG_PAINT_COLOR_RAMP_SPREAD_MODE:
      SH_RETURN_ERR_IF(count != 1, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
      SH_RETURN_ERR_IF(!shIsEnumValid(ptype,ivalue), VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
      ((SHPaint*)object)->spreadMode = (VGColorRampSpreadMode)ivalue;
      break;
      
    case VG_PAINT_COLOR_RAMP_PREMULTIPLIED:
      SH_RETURN_ERR_IF(count != 1, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
      SH_RETURN_ERR_IF(!shIsEnumValid(ptype,ivalue), VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
      ((SHPaint*)object)->premultiplied = (VGboolean)ivalue;
      break;
      
    case VG_PAINT_COLOR_RAMP_STOPS: {
        
        int max; SHPaint *paint; SHStop stop;
        SH_RETURN_ERR_IF(count % 5, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
        max  = SH_MIN(count, SH_MAX_COLOR_RAMP_STOPS * 5);
        paint = (SHPaint*)object;
        shStopArrayClear(&paint->instops);
        
        for (i=0; i<max; i+=5) {
          stop.offset = shParamToFloat(values, floats, i+0);
          CSET(stop.color,
               shParamToFloat(values, floats, i+1),
               shParamToFloat(values, floats, i+2),
               shParamToFloat(values, floats, i+3),
               shParamToFloat(values, floats, i+4));
          shStopArrayPushBackP(&paint->instops, &stop); }
        
        shValidateInputStops(paint);
        break;}
      
    case VG_PAINT_LINEAR_GRADIENT:
      SH_RETURN_ERR_IF(count != 4, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
      for (i=0; i<4; ++i)
        ((SHPaint*)object)->linearGradient[i] = shParamToFloat(values, floats, i);
      break;
      
    case VG_PAINT_RADIAL_GRADIENT:
      SH_RETURN_ERR_IF(count != 5, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
      for (i=0; i<5; ++i)
        ((SHPaint*)object)->radialGradient[i] = shParamToFloat(values, floats, i);
      break;
      
    case VG_PAINT_PATTERN_TILING_MODE:
      SH_RETURN_ERR_IF(count != 1, VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
      SH_RETURN_ERR_IF(!shIsEnumValid(ptype,ivalue), VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
      ((SHPaint*)object)->tilingMode = (VGTilingMode)ivalue;
      break;
      
    default:
      /* Invalid VGParamType */
      SH_RETURN_ERR(VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
    
    } break;
  case SH_RESOURCE_IMAGE: switch (ptype) {/* Image parameters */
      
    case VG_IMAGE_FORMAT:
    case VG_IMAGE_WIDTH:
    case VG_IMAGE_HEIGHT:
      /* Read-only */ break;
      
    default:
      /* Invalid VGParamType */
      SH_RETURN_ERR(VG_ILLEGAL_ARGUMENT_ERROR, SH_NO_RETVAL);
      
    } break;
    
  default:
    /* Invalid resource handle */
    SH_ASSERT(rtype!=SH_RESOURCE_INVALID);
    break;
  }
  
  SH_RETURN(SH_NO_RETVAL);
}
Пример #17
0
public void DecodeISO2022( state_t *state, byte codingSystem )
{
  int region;
  byte charset, ch, rch;
  byte c[ ICHAR_WIDTH ];

  for( ; ; ){
    GetChar( ch );
    if( ch < SP ){
      if( ESC == ch ){
	if( FALSE == DecodeEscape( state ) )
	  break;
      } else if( HT == ch )
	DecodeAddTab( state->attr );
      else if( SO == ch )	/* LS1 for 8bit */
	state->gset[ GL ] = G1;
      else if( SI == ch )	/* LS0 for 8bit */
	state->gset[ GL ] = G0;
      else if( BS == ch )
	DecodeAddBs();
      else if( EM == ch )
	state->sset = G2;
      else
	DecodeAddControl( ch );
    } else {
      if( '~' == ch && TRUE == hz_detection ){
	switch( STR[ SIDX ] ){
	case '~':
	  if( ASCII == state->cset[ G0 ] )
	    IncStringIndex();
	  break;	/* break for '~' itself.*/
	case '{':
	  if( ASCII == state->cset[ G0 ] ){
	    IncStringIndex();
	    state->cset[ G0 ] = GB2312;
	    continue;
	  }
	  break;
	case '}':
	  if( GB2312 == state->cset[ G0 ] ){
	    IncStringIndex();
	    state->cset[ G0 ] = ASCII;
	    continue;
	  }
	  break;
	}
      }
      rch = ch;
      if( 0 != state->sset ){
	/*
	 * single shifted character
	 */
	if( EUC_TAIWAN == codingSystem && G2 == state->sset ){
	  charset = CNS_1 + ( ch - 0xa1 );
	  if( charset < CNS_1 || charset > CNS_7 ){
	    state->sset = 0;
	    continue;
	  }
	  GetChar( ch );
	} else {
	  charset = SSET;
	}
	state->sset = 0;
	ch &= 0x7f;	/* for EUC */
	if( !IsGraphicChar( charset, ch ) ){
	  if( SP == ch ){
	    DecodeAddSpace( state->attr );
	  } else {
	    DecodeAddControl( rch );
	  }
	  continue;
	}
	c[ 0 ] = ch;
	if( TRUE == iTable[ (int)charset ].multi ){
	  GetChar( ch );
	  if( !IsGraphicChar( charset, ch & 0x7f ) ){
	    DecodeAddControl( rch );
	    DecodeAddControl( ch );
	    continue;
	  }
	  c[ 1 ] = ch & 0x7f;	/* for EUC */
	}
      } else {
	if( 0x80 & ch ){
	  if( SS2 == ch ){
	    state->sset = G2;
	    continue;
	  } else if( SS3 == ch ){
	    state->sset = G3;
	    continue;
	  }
	  region = GR;
	  ch &= 0x7f;
	} else {
	  region = GL;
	}
	charset = CSET( region );
	if( !IsGraphicChar( charset, ch ) ){
	  if( SP == ch ){
	    DecodeAddSpace( state->attr );
	  } else {
	    DecodeAddControl( rch );
	  }
	  continue;
	}
	c[ 0 ] = ch;
	if( TRUE == iTable[ (int)charset ].multi ){
	  GetChar( ch );
	  ch &= 0x7f;
	  if( !IsGraphicChar( charset, ch ) )
	    continue;
	  c[ 1 ] = ch;
	}
      }
      DecodeAddChar( charset, c, state->attr );
    }
  }
}