RealFde CFormulaNode::getAscent( const SizeFde &sz ) { RealFde vc = sz.height() / 2.0; switch( getAlignmentType() ) { case FBtnChildPos::TableCenter2Baseline: if( (getAlignmentValue() - 1) >= 0 && (getAlignmentValue() - 1) < GetChildCount() ) { CNode *pNode = GetChild( getAlignmentValue() - 1 ); if( pNode != NULL ) vc = pNode->GetPosition().y() + pNode->GetSize().height() / 2.0; } break; case FBtnChildPos::TableTop2Baseline: if( (getAlignmentValue() - 1) >= 0 && (getAlignmentValue() - 1) < GetChildCount() ) { CNode *pNode = GetChild( getAlignmentValue() - 1 ); if( pNode != NULL ) vc = pNode->GetPosition().y(); else vc = 0.0; } else vc = 0.0; break; case FBtnChildPos::TableBottom2Baseline: if( (getAlignmentValue() - 1) >= 0 && (getAlignmentValue() - 1) < GetChildCount() ) { CNode *pNode = GetChild( getAlignmentValue() - 1 ); if( pNode != NULL ) vc = pNode->GetPosition().y() + pNode->GetSize().height(); else vc = sz.height(); } else vc = sz.height(); break; default: vc = sz.height() - ::calculateCurrentTextDescent( GetLevel() ); break; } return vc; }
void CFormulaNode::Recalculate_VerticalCenter( const SizeFde &sz ) { RealFde vc = sz.height() / 2.0; switch( getAlignmentType() ) { case FBtnChildPos::Child: if( getAlignmentValue() >= 1 && (getAlignmentValue() - 1) < getGraphPrimNumber() ) { const RectFde& _t = getGraphPrimitivePositionRect( getAlignmentValue() - 1 ); vc = (_t.top() + _t.bottom()) / 2.0; } break; case FBtnChildPos::Child_Average: if( getAlignmentValue() >= 1 && (getAlignmentValue() - 1) < getGraphPrimNumber() ) { vc = 0.0; for( long i = 0; i <= getAlignmentValue() - 1; i++ ) { const RectFde& _t = getGraphPrimitivePositionRect( i ); vc += _t.top() + _t.bottom(); } vc = vc / (getAlignmentValue() * 2.0); } break; case FBtnChildPos::MSPACE_Exact_HeightDepth: case FBtnChildPos::Frame: if( (getAlignmentValue() - 1) >= 0 && (getAlignmentValue() - 1) < GetChildCount() ) { CNode *pNode = GetChild( getAlignmentValue() - 1 ); if( pNode ) vc = pNode->GetPosition().y() + pNode->GetVerticalCenter(); } break; case FBtnChildPos::Frame_Blank_Average: { CNode *pNodeFirst = GetFirstChild(); CNode *pNodeLast = GetLastChild(); if( pNodeFirst != NULL && pNodeLast != NULL ) { vc = (pNodeFirst->GetPosition().y() + pNodeFirst->GetSize().height() + pNodeLast->GetPosition().y()) / 2.0; } } break; case FBtnChildPos::Half: break; case FBtnChildPos::TableAxis: if( (getAlignmentValue() - 1) >= 0 && (getAlignmentValue() - 1) < GetChildCount() ) { CNode *pNode = GetChild( getAlignmentValue() - 1 ); if( pNode ) vc = pNode->GetPosition().y() + pNode->GetSize().height() / 2.0; } break; case FBtnChildPos::TableCenter2Baseline: case FBtnChildPos::TableTop2Baseline: case FBtnChildPos::TableBottom2Baseline: { RealFde asc = ::getCurrentDefaultAscent( GetLevel() ); RealFde h = ::getCurrentDefaultSize( GetLevel() ).height(); vc = getAscent( sz ) - asc + h - asc / 2.0; } break; default: break; } SetVerticalCenter( vc ); }
void GFXD3D9Shader::_getShaderConstants( ID3DXConstantTable *table, GenericConstBufferLayout *bufferLayoutF, GenericConstBufferLayout* bufferLayoutI, Vector<GFXShaderConstDesc> &samplerDescriptions ) { PROFILE_SCOPE( GFXD3D9Shader_GetShaderConstants ); AssertFatal(table, "NULL constant table not allowed, is this an assembly shader?"); D3DXCONSTANTTABLE_DESC tableDesc; D3D9Assert(table->GetDesc(&tableDesc), "Unable to get constant table info."); for (U32 i = 0; i < tableDesc.Constants; i++) { D3DXHANDLE handle = table->GetConstant(0, i); const U32 descSize=16; D3DXCONSTANT_DESC constantDescArray[descSize]; U32 size = descSize; if (table->GetConstantDesc(handle, constantDescArray, &size) == S_OK) { D3DXCONSTANT_DESC& constantDesc = constantDescArray[0]; GFXShaderConstDesc desc; desc.name = String(constantDesc.Name); // Prepend a "$" if it doesn't exist. Just to make things consistent. if (desc.name.find("$") != 0) desc.name = String::ToString("$%s", desc.name.c_str()); //Con::printf("name %s: , offset: %d, size: %d, constantDesc.Elements: %d", desc.name.c_str(), constantDesc.RegisterIndex, constantDesc.Bytes, constantDesc.Elements); desc.arraySize = constantDesc.Elements; GenericConstBufferLayout* bufferLayout = NULL; switch (constantDesc.RegisterSet) { case D3DXRS_INT4 : { bufferLayout = bufferLayoutI; switch (constantDesc.Class) { case D3DXPC_SCALAR : desc.constType = GFXSCT_Int; break; case D3DXPC_VECTOR : { switch (constantDesc.Columns) { case 1 : desc.constType = GFXSCT_Int; break; case 2 : desc.constType = GFXSCT_Int2; break; case 3 : desc.constType = GFXSCT_Int3; break; case 4 : desc.constType = GFXSCT_Int4; break; default: AssertFatal(false, "Unknown int vector type!"); break; } } break; } desc.constType = GFXSCT_Int4; break; } case D3DXRS_FLOAT4 : { bufferLayout = bufferLayoutF; switch (constantDesc.Class) { case D3DXPC_SCALAR: desc.constType = GFXSCT_Float; break; case D3DXPC_VECTOR : { switch (constantDesc.Columns) { case 1 : desc.constType = GFXSCT_Float; break; case 2 : desc.constType = GFXSCT_Float2; break; case 3 : desc.constType = GFXSCT_Float3; break; case 4 : desc.constType = GFXSCT_Float4; break; default: AssertFatal(false, "Unknown float vector type!"); break; } } break; case D3DXPC_MATRIX_ROWS : case D3DXPC_MATRIX_COLUMNS : { switch (constantDesc.RegisterCount) { case 3 : desc.constType = GFXSCT_Float3x3; break; case 4 : desc.constType = GFXSCT_Float4x4; break; } } break; case D3DXPC_OBJECT : case D3DXPC_STRUCT : bufferLayout = NULL; break; } } break; case D3DXRS_SAMPLER : { AssertFatal( constantDesc.Elements == 1, "Sampler Arrays not yet supported!" ); switch (constantDesc.Type) { case D3DXPT_SAMPLER : case D3DXPT_SAMPLER1D : case D3DXPT_SAMPLER2D : case D3DXPT_SAMPLER3D : // Hi-jack the desc's arraySize to store the registerIndex. desc.constType = GFXSCT_Sampler; desc.arraySize = constantDesc.RegisterIndex; samplerDescriptions.push_back( desc ); break; case D3DXPT_SAMPLERCUBE : desc.constType = GFXSCT_SamplerCube; desc.arraySize = constantDesc.RegisterIndex; samplerDescriptions.push_back( desc ); break; } } break; default: AssertFatal(false, "Unknown shader constant class enum"); break; } if (bufferLayout) { mShaderConsts.push_back(desc); U32 alignBytes = getAlignmentValue(desc.constType); U32 paramSize = alignBytes * desc.arraySize; bufferLayout->addParameter( desc.name, desc.constType, constantDesc.RegisterIndex * sizeof(Point4F), paramSize, desc.arraySize, alignBytes ); } } else AssertFatal(false, "Unable to get shader constant description! (may need more elements of constantDesc"); } }