Esempio n. 1
0
static int relayFillPoly(XFlash *Xf,FILE *fc,FILE *ts,int len){
	IOStr iob,*io = &iob;
	IStr(buf,32*1024);
	int rcc;
	int wcc;
	int rv;
	int nl;
	int d,g,s,m,x,y;
	IStr(poly,1024);
	refQStr(pp,poly);

	rcc = fread(buf,1,(len-1)*4,fc);
	IOinit(io,Xf," cs FP",buf,rcc);
	fprintf(stderr," ----\n");
	d = rv = getInt4(io,"DRAWABLE/drawable");
	g = rv = getInt4(io,"GCONTEXT/gc");
	s = rv = getInt1(io,"shape");
	m = rv = getInt1(io,"coordinate-mode");
	    rv = getInt2(io,"unused");
	while( 4 <= remLeng(io) ){
		x = rv = getInt2(io,"INT16/x");
		y = rv = getInt2(io,"INT16/y");
		if( poly < pp ){
			setVStrPtrInc(pp,',');
		}
		sprintf(pp,"%d/%d",x,y);
		pp += strlen(pp);
	}
	toFlash(Xf,"FillPoly gc=%d poly={%s}",g,poly);
	wcc = fwrite(buf,1,rcc,ts);
	return 0;
}
Esempio n. 2
0
/* X11R6.7DRAFT p.122 */
static int scanVISUALTYPE(IOStr *io,const char *what){
	int rv;
	rv = getInt4(io,"VISUALID/visual-id");
	rv = getInt1(io,"class");
	rv = getInt1(io,"CARD8/bits-per-rgb-value");
	rv = getInt2(io,"CARD16/colormap-entries");
	rv = getInt4(io,"CARD32/red-mask");
	rv = getInt4(io,"CARD32/green-mask");
	rv = getInt4(io,"CARD32/blue-mask");
	rv = getPadN(io,"unused",4);
	return 0;
}
Esempio n. 3
0
static int scanFORMAT(IOStr *io,const char *what){
	int rv;
	rv = getInt1(io,"CARD8/depth");
	rv = getInt1(io,"CARD8/bits-per-pixel");
	rv = getInt1(io,"CARD8/scanline-pad");
	rv = getInt1(io,"Pad");
	rv = getInt4(io,"Pad");
	return 0;
}
Esempio n. 4
0
static int relayPolyFillArc(XFlash *Xf,OpQue *qop,FILE *fc,FILE *ts,int len){
	IOStr iob,*io = &iob;
	IStr(buf,32*1024);
	int rcc;
	int wcc;
	int rv;
	int nl;

	rcc = fread(buf,1,(len-1)*4,fc);
	IOinit(io,Xf," cs PF",buf,rcc);
	fprintf(stderr," ----\n");
	rv = getInt4(io,"DRAWABLE/drawable");
	rv = getInt4(io,"GCONTEXT/gc");
	while( 12 <= remLeng(io) ){
		scanARC(io,"ARC",rv);
	}
	wcc = fwrite(buf,1,rcc,ts);
	return 0;
}
Esempio n. 5
0
static int relayImageText8(XFlash *Xf,FILE *fc,FILE *ts,int len,int slen){
	IOStr iob,*io = &iob;
	IStr(buf,32*1024);
	int rcc;
	int wcc;
	int rv;
	int d,g,x,y;

	rcc = fread(buf,1,(len-1)*4,fc);
	IOinit(io,Xf," cs IT",buf,rcc);
	fprintf(stderr," -\n");
	d = rv = getInt4(io,"DRAWABLE/drawable");
	g = rv = getInt4(io,"GCONTEXT/gc");
	x = rv = getInt2(io,"INT16/x");
	y = rv = getInt2(io,"INT16/y");
	    rv = getSTRING8(io,"STRING8/string",slen);
	toFlash(Xf,"X %d\n",x);
	toFlash(Xf,"TEXT8 gc=%d x=%d y=%d str=\"%s\"",g,x,y,Xf->xf_string8);
	wcc = fwrite(buf,1,rcc,ts);
	return 0;
}
Esempio n. 6
0
static int scanSCREEN(IOStr *io,const char *what,int sn){
	int rv;
	int nl;
	int di;

	rv = getInt4(io,"WINDOW/root");
	rv = getInt4(io,"COLORMAP/default-colormap");
	rv = getInt4(io,"CARD32/white-pixel");
	rv = getInt4(io,"CARD32/black-pixel");
	rv = getInt4(io,"SETofEVENT/corrent-input-masks");
	rv = getInt2(io,"CARD16/width-in-pixels");
	rv = getInt2(io,"CARD16/height-in-pixels");
	rv = getInt2(io,"CARD16/width-in-millimeters");
	rv = getInt2(io,"CARD16/height-in-millimeters");
	rv = getInt2(io,"CARD16/min-installed-maps");
	rv = getInt2(io,"CARD16/max-installed-maps");
	rv = getInt4(io,"VISUALID/root-visual");
	rv = getInt1(io,"VISUALID/backing-stores");
	rv = getInt1(io,"VISUALID/save-unders");
	rv = getInt1(io,"VISUALID/root-depth");
	nl = getInt1(io,"VISUALID/number-of-DEPTHs-in-allowed-depth");
	for( di = 0; di < nl; di++ ){
		if( remLeng(io) <= 0 ){
			return EOF;
		}
		rv = scanDEPTH(io,"LISTofDEPTH/allowed-depath");
	}
	return 0;
}
Esempio n. 7
0
static int relayCopyArea(XFlash *Xf,FILE *fc,FILE *ts,int len,int slen){
	IOStr iob,*io = &iob;
	IStr(buf,32*1024);
	int rcc;
	int wcc;
	int rv;
	int d,D,g,X,x,Y,y,w,h;

	rcc = fread(buf,1,(len-1)*4,fc);
	IOinit(io,Xf," cs CA",buf,rcc);
	D = rv = getInt4(io,"DRAWABLE/src-drawable");
	d = rv = getInt4(io,"DRAWABLE/dst-drawable");
	g = rv = getInt4(io,"GCONTEXT/gc");
	X = rv = getInt2(io,"INT16/src-x");
	Y = rv = getInt2(io,"INT16/src-y");
	x = rv = getInt2(io,"INT16/dst-x");
	y = rv = getInt2(io,"INT16/dst-y");
	w = rv = getInt2(io,"CARD16/width");
	h = rv = getInt2(io,"CARD16/height");
	toFlash(Xf,"CopyArea gc=%d x=%d y=%d w=%d h=%d ",g,x,y,w,h);
	wcc = fwrite(buf,1,rcc,ts);
	return 0;
}
Esempio n. 8
0
static int relayInitialResp(IOStr *io,int op){
	int rv;
	int vl;
	int sl;
	int nl;
	int fi;

	rv = getInt1(io,"Sucess");
	rv = getPadN(io,"unused",1);
	rv = getInt2(io,"major_version");
	rv = getInt2(io,"minor_version");
	rv = getInt2(io,"length/4");
	rv = getInt4(io,"release-number");
	rv = getInt4(io,"resource-id-base");
	rv = getInt4(io,"resource-id-mask");
	rv = getInt4(io,"motion-bufffer-size");
	vl = getInt2(io,"length-of-vendor");
	rv = getInt2(io,"maximum-request-length");
	sl = getInt1(io,"number-of-SCREENs-in-roots");
	nl = getInt1(io,"number-for-FORMATs-in-pixmap-formats");
	rv = getInt1(io,"image-byte-order");
	rv = getInt1(io,"bitmap-format-bit-order");
	rv = getInt1(io,"bitmap-format-scanline-unit");
	rv = getInt1(io,"bitmap-format-scanline-pad");
	rv = getInt1(io,"min-keycode");
	rv = getInt1(io,"max-keycode");
	rv = getPadN(io,"unused",4);
	rv = getSTRING8(io,"Vendor",vl);
rv = skipPad(io,"unused-Padding",4);
	for( fi = 0; fi < nl; fi++ ){
		rv = scanFORMAT(io,"Format");
	}
	rv = scanSCREEN(io,"Screen",sl);
rv = skipPad(io,"Pad",8);
	return 0;
}
Esempio n. 9
0
static int relayClearArea(XFlash *Xf,FILE *fc,FILE *ts,int len,int slen){
	IOStr iob,*io = &iob;
	IStr(buf,32*1024);
	int rcc;
	int wcc;
	int rv;
	int W,g,x,y,w,h;

	rcc = fread(buf,1,(len-1)*4,fc);
	IOinit(io,Xf," cs CA",buf,rcc);
	W = rv = getInt4(io,"WINDOW/window");
	x = rv = getInt2(io,"INT16/x");
	y = rv = getInt2(io,"INT16/y");
	w = rv = getInt2(io,"CARD16/width");
	h = rv = getInt2(io,"CARD16/height");
	toFlash(Xf,"ClearArea W=%u x=%d y=%d w=%d h=%d ",W,x,y,w,h);
	wcc = fwrite(buf,1,rcc,ts);
	return 0;
}
Esempio n. 10
0
static int scanresp(IOStr *io,int op,int seq,OpQue *qop,const char *resp,int rcc){
	int rv;
	int nl;

	if( op == OP_InitialResp ){
		relayInitialResp(io,op);
	}else
	if( resp[0] == EV_KeyPress ){
		fprintf(stderr," seq=%d\n",seq);
		rv = getInt1(io,"evcode");
		rv = getInt1(io,"KEYCODE");
			toFlash(io->in_Xf,"KeyPress code=%d",rv);
		rv = getInt2(io,"CARD16/Seq#");
		/*
		if( resp[0] == EV_KeyPress ){
			rv = getInt4(io,"TIMESTAMP/time");
			rv = getInt4(io,"WINDOW/root");
			rv = getInt4(io,"WINDOW/event");
			rv = getInt4(io,"WINDOW/child");
			rv = getInt2(io,"INT16/root-x");
			rv = getInt2(io,"INT16/root-y");
			rv = getInt2(io,"INT16/event-x");
			rv = getInt2(io,"INT16/event-y");
			rv = getInt2(io,"SETofKEYBUTMASK/state");
			rv = getInt1(io,"BOOL/same-screen");
		}
		*/
	}else{
		fprintf(stderr," seq=%d\n",seq);
		rv = getInt1(io,"Reply");
		rv = getInt1(io,"opt");
		rv = getInt2(io,"CARD16/Seq#");
		if( op == OP_QueryExtension ){
			rv = getInt4(io,"CARD32/length");
			rv = getInt1(io,"BOOL/present");
			rv = getInt1(io,"CARD8/major-opcode");
fprintf(stderr,"------------- #%d got opcode=%d, put it into Op Table\n",qop?qop->oq_seq:0,rv);
//addop(rv);
			rv = getInt1(io,"CARD8/first-event");
			rv = getInt1(io,"CARD8/first-error");
		}else
		if( op == OP_InternAtom ){
			rv = getInt4(io,"CARD32/length");
			rv = getInt4(io,"ATOM/atom");
		}else
		if( op == OP_GetProperty ){
			rv = getInt4(io,"CARD32/length");
			rv = getInt4(io,"ATOM/atom");
			rv = getInt4(io,"CARD32/bytes-after");
			rv = getInt4(io,"CARD32/length-of-value-in-format-units");
			rv = getPadN(io,"unused",12);
		}else
		if( op == OP_QueryPointer ){
			rv = getInt4(io,"CARD32/length");
			rv = getInt4(io,"WINDOW/root");
			rv = getInt4(io,"WINDOW/child");
			rv = getInt2(io,"INT16/root-x");
			rv = getInt2(io,"INT16/root-y");
			rv = getInt2(io,"INT16/win-x");
			rv = getInt2(io,"INT16/win-y");
			rv = getInt2(io,"SETofKEYBUTMASK/mask");
		}
	}
	return 0;
}
Esempio n. 11
0
RenderPass RenderStage::createRenderPassFromJson(const JSONValue& renderPassJSON)
{
    GraphicSystem& graphicSystem = renderer.getGraphicSystem();

    RenderPass renderPass;
    auto clearColorJSON = renderPassJSON.getJSONValue("clearColor");
    auto colorWriteJSON = renderPassJSON.getJSONValue("colorWrite");
    auto depthWriteJSON = renderPassJSON.getJSONValue("depthWrite");
    auto renderTargetLayerJSON = renderPassJSON.getJSONValue("renderTargetLayer");
    auto flagsJSON = renderPassJSON.getJSONValue("flags");

    if(!clearColorJSON.isNull())
        renderPass.clearColor = clearColorJSON.getVector4();
    if(!colorWriteJSON.isNull())
        renderPass.colorWrite = colorWriteJSON.getBool();
    if(!depthWriteJSON.isNull())
        renderPass.depthWrite = depthWriteJSON.getBool();
    if(!renderTargetLayerJSON.isNull())
        renderPass.renderTargetLayer = renderTargetLayerJSON.getInt();
    if(!flagsJSON.isNull())
    {
        unsigned int flags = 0;
        for(unsigned int i = 0; i < flagsJSON.getSize(); ++i)
        {
            if(flagsJSON.getJSONArrayItem(i).getString().compare("CLEAR_COLOR") == 0)
                flags |= CLEAR_COLOR;
            if(flagsJSON.getJSONArrayItem(i).getString().compare("CLEAR_DEPTH") == 0)
                flags |= CLEAR_DEPTH;
        }
        renderPass.flags = flags;
    }

    auto viewPortJSON = renderPassJSON.getJSONValue("viewPort");
    if(!viewPortJSON.isNull())
    {
        FixedArray<int, 4> viewPort = viewPortJSON.getInt4();
        renderPass.viewPort.set(viewPort[0], viewPort[1], viewPort[2], viewPort[3]);
    }
    else
        renderPass.viewPort = renderer.getScreenViewPort();

    auto renderTargetJSON = renderPassJSON.getJSONValue("renderTarget");
    renderPass.renderTarget = graphicSystem.createRenderTarget(renderTargetJSON);

    auto shaderPasses = renderPassJSON.getJSONValue("shaderPasses");

    if(!shaderPasses.isNull())
    {
        for(unsigned int i = 0; i < shaderPasses.getSize(); ++i)
        {
            auto shaderPassJSON = shaderPasses.getJSONArrayItem(i);
            auto programJSON = shaderPassJSON.getJSONValue("shaderProgram");
            auto vertexDataJSON = shaderPassJSON.getJSONValue("vertexData");
            auto rasterStateJSON = shaderPassJSON.getJSONValue("rasterState");
            auto shaderParameterBlocksJSON = shaderPassJSON.getJSONValue("shaderParameterBlocks");
            auto texturesJSON = shaderPassJSON.getJSONValue("textures");
            ShaderPass shaderPass;

            if(!vertexDataJSON.isNull())
            {
                if(vertexDataJSON.getString().compare("fullScreenQuad") == 0)
                    shaderPass.vertexData = renderer.getFullScreenQuad();
            }
            if(!rasterStateJSON.isNull())
            {
                auto blendFunctionJSON = rasterStateJSON.getJSONValue("blendFunction");
                auto compareFunctionJSON = rasterStateJSON.getJSONValue("compareFunction");
                auto cullFaceJSON = rasterStateJSON.getJSONValue("cullFace");
                auto blendState = !blendFunctionJSON.isNull() ? BlendState(true, enumFromString<BlendFunction>(blendFunctionJSON.getString())) : BlendState(false, BlendFunction::Replace);
                auto compareState = !compareFunctionJSON.isNull() ? CompareState(true, enumFromString<CompareFunction>(compareFunctionJSON.getString())) : CompareState(false, CompareFunction::Never);
                auto cullState = !cullFaceJSON.isNull() ? CullState(true, enumFromString<CullFace>(cullFaceJSON.getString())) : CullState(false, CullFace::Back);
                shaderPass.rasterState = RasterState(blendState, compareState, cullState);
            }

            if(!shaderParameterBlocksJSON.isNull())
            {
                for(unsigned int j = 0; j < shaderParameterBlocksJSON.getSize(); ++j)
                {
                    ShaderParameterBlock* block = graphicSystem.createShaderParameterBlock(shaderParameterBlocksJSON.getJSONArrayItem(j));
                    if(block)
                        shaderPass.shaderParameterBlocks.pushBack(block);
                }
            }
            if(!texturesJSON.isNull())
            {
                for(unsigned int j = 0; j < texturesJSON.getSize(); ++j)
                {
                    Texture* texture = graphicSystem.createTexture(texturesJSON.getJSONArrayItem(j));
                    if(texture)
                        shaderPass.textures.pushBack(texture);
                }
            }

            if(!programJSON.isNull())
                shaderPass.program = graphicSystem.createShaderProgram(programJSON);

            renderPass.shaderPasses.pushBack(shaderPass);
        }
    }
    return renderPass;
}