void ElemTemplate::execute(StylesheetExecutionContext& executionContext) const { ParentType::execute(executionContext); executeChildren(executionContext); }
void ElemOtherwise::execute(StylesheetExecutionContext& executionContext) const { ElemTemplateElement::execute(executionContext); executeChildren(executionContext); }
void ElemElement::doExecuteChildren( StylesheetExecutionContext& executionContext, bool skipAttributeChildren) const { if (skipAttributeChildren == false) { // If we should execute all children, then just call // executeChildren()... executeChildren(executionContext); } else { StylesheetExecutionContext::PushAndPopElementFrame thePushAndPop(executionContext, this); for (ElemTemplateElement* node = getFirstChildElem(); node != 0; node = node->getNextSiblingElem()) { if (node->getXSLToken() != StylesheetConstructionContext::ELEMNAME_ATTRIBUTE) { node->execute(executionContext); } } } }
void ElemLiteralResult::execute(StylesheetExecutionContext& executionContext) const { const XalanDOMString& theElementName = getElementName(); executionContext.startElement(c_wstr(theElementName)); ElemUse::execute(executionContext); const NamespacesHandler& theNamespacesHandler = getNamespacesHandler(); theNamespacesHandler.outputResultNamespaces(executionContext); if (hasPrefix() == false) { // OK, let's check to make sure we don't have to change the default namespace... const XalanDOMString* const theCurrentDefaultNamespace = executionContext.getResultNamespaceForPrefix(s_emptyString); if (theCurrentDefaultNamespace != 0) { const XalanDOMString* const theElementDefaultNamespace = theNamespacesHandler.getNamespace(s_emptyString); if (theElementDefaultNamespace == 0) { // There was no default namespace, so we have to turn the // current one off. executionContext.addResultAttribute(DOMServices::s_XMLNamespace, s_emptyString); } else if (equals(*theCurrentDefaultNamespace, *theElementDefaultNamespace) == false) { executionContext.addResultAttribute(DOMServices::s_XMLNamespace, *theElementDefaultNamespace); } } } if(m_avtsCount > 0) { StylesheetExecutionContext::GetAndReleaseCachedString theGuard(executionContext); XalanDOMString& theStringedValue = theGuard.get(); for(unsigned int i = 0; i < m_avtsCount; ++i) { const AVT* const avt = m_avts[i]; const XalanDOMString& theName = avt->getName(); avt->evaluate(theStringedValue, *this, executionContext); executionContext.addResultAttribute(theName, theStringedValue); theStringedValue.clear(); } } executeChildren(executionContext); executionContext.endElement(c_wstr(theElementName)); }
bool PrimitiveMaterialD3D::execute() { DisplayDeviceD3D * pDeviceD3D = (DisplayDeviceD3D *)m_pDevice; if (! pDeviceD3D ) return false; LPDIRECT3DDEVICE9 pD3DD = pDeviceD3D->m_pD3DD; if (! pD3DD ) return false; // disable culling if doubleSided flag is true, enable CCW culling if false if ( pD3DD->SetRenderState( D3DRS_CULLMODE, m_DoubleSided ? D3DCULL_NONE : D3DCULL_CCW ) != D3D_OK) return false; setupBlending(); if ( m_nPass == DisplayDevice::PRIMARY ) { // write enabled for primary render pass pD3DD->SetRenderState( D3DRS_ZWRITEENABLE, D3DZB_TRUE ); pD3DD->SetRenderState( D3DRS_ZFUNC, D3DCMP_LESSEQUAL ); } else { // no write for secondary and background passes pD3DD->SetRenderState( D3DRS_ZWRITEENABLE, D3DZB_FALSE ); pD3DD->SetRenderState( D3DRS_ZFUNC, D3DCMP_LESSEQUAL ); } DisplayDeviceD3D::LightMap & lights = pDeviceD3D->m_Lights; // we use fixed function if lighting if disabled.. if ( DisplayDevice::sm_bUseFixedFunction || !m_LightEnable || lights.size() == 0 || m_Blending == PrimitiveMaterial::ADDITIVE ) { pDeviceD3D->m_bUsingFixedFunction = true; // enable/disable lighting if ( pD3DD->SetRenderState( D3DRS_LIGHTING, m_LightEnable && lights.size() > 0 ) != D3D_OK ) return false; // enable/disable specular highlighting if ( pD3DD->SetRenderState( D3DRS_SPECULARENABLE, (m_LightEnable && m_SpecularPower > 0.0f && sm_bEnableSpecular) ? TRUE : FALSE ) != D3D_OK) return false; D3DMATERIAL9 d3dm; d3dm.Diffuse = makeD3DCOLORVALUE( m_Diffuse ); d3dm.Ambient = makeD3DCOLORVALUE( m_Ambient ); d3dm.Emissive = makeD3DCOLORVALUE( m_Emissive ); d3dm.Specular = makeD3DCOLORVALUE( m_Specular ); d3dm.Power = m_SpecularPower; // apply shader if one has been set manually, needed for the HDR bloom effects.. if ( m_pShader.valid() && m_pShader != pDeviceD3D->m_pDefaultShader ) m_pShader->apply( pDeviceD3D ); else pDeviceD3D->clearShaders(); // set the material properties if ( pD3DD->SetMaterial( &d3dm ) != D3D_OK ) return false; if (! setupTextureStatges() ) return false; if (! executeChildren() ) return false; } else { // turn off fixed function lighting.. if ( pD3DD->SetRenderState( D3DRS_LIGHTING, FALSE ) != D3D_OK ) return false; // update our pixel/vertex shaders if needed.. if ( m_bUpdateShaders || !m_pShader.valid() || m_pShader->released() ) { m_bUpdateShaders = false; m_pShader = NULL; if ( m_sShader.length() > 0 ) m_pShader = pDeviceD3D->getShader( m_sShader ); if (! m_pShader.valid() ) m_pShader = pDeviceD3D->m_pDefaultShader; } if ( !m_pShader.valid() || m_pShader->released() ) return false; pDeviceD3D->m_bUsingFixedFunction = false; pDeviceD3D->m_pMatShader = m_pShader; // setup shader constants for this material.. m_pShader->setConstant( "vMatAmbient", m_Ambient ); m_pShader->setConstant( "vMatDiffuse", m_Diffuse ); m_pShader->setConstant( "vMatEmissive", m_Emissive ); m_pShader->setConstant( "vMatSpecular", m_Specular ); m_pShader->setConstant( "fMatSpecularPower", m_SpecularPower ); // set global ambient light for the first lighting pass.. m_pShader->setConstant( "vGlobalAmbient", pDeviceD3D->m_cAmbientLight ); m_pShader->setConstant( "bEnableAmbient", true ); m_pShader->setConstant( "szShadowMap", pDeviceD3D->m_szShadowMap ); if (! setupTextureStatges() ) return false; DisplayDeviceD3D::ShadowPassList::iterator iShadowPass = pDeviceD3D->m_ShadowPassList.begin(); // set to alpha blending for the first pass... pD3DD->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE); pD3DD->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA); pD3DD->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA); // we need to make a render pass for each light in the scene int nLightCount = 0; for( DisplayDeviceD3D::LightMap::iterator iLight = lights.begin(); iLight != lights.end(); ++iLight, ++nLightCount ) { if ( nLightCount >= sm_nMaxLights ) break; D3DLIGHT9 & light = iLight->second; m_pShader->setConstant( "nLightType", (int)light.Type ); if ( light.Type != D3DLIGHT_DIRECTIONAL ) m_pShader->setConstant( "vLightPosition", light.Position ); if ( light.Type != D3DLIGHT_POINT ) m_pShader->setConstant( "vLightDirection", light.Direction ); m_pShader->setConstant( "vLightDiffuse", light.Diffuse ); m_pShader->setConstant( "vLightSpecular", light.Specular ); m_pShader->setConstant( "vLightAmbient", light.Ambient ); if ( light.Type == D3DLIGHT_POINT ) { Vector3 vAttenation( light.Attenuation0, light.Attenuation1, light.Attenuation2 ); m_pShader->setConstant( "vAttenuation", vAttenation ); } if ( iShadowPass != pDeviceD3D->m_ShadowPassList.end() ) { DisplayDeviceD3D::ShadowPass & pass = *iShadowPass; // yes we have a shadow map.. m_pShader->setConstant( "bEnableShadowMap", true ); m_pShader->setConstant( "mLightView", pass.m_LightView ); m_pShader->setConstant( "mLightProj", pass.m_LightProj ); // put our shadow map into slot 7, reserved specially for shadow maps.. pD3DD->SetTexture( 7, pass.m_pShadowMap ); pD3DD->SetSamplerState( 7, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP ); pD3DD->SetSamplerState( 7, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP ); pD3DD->SetSamplerState( 7, D3DSAMP_MAGFILTER, D3DTEXF_POINT ); // IMPORTANT: Turn off all filtering on the shadow map, the shader does the filtering.. pD3DD->SetSamplerState( 7, D3DSAMP_MINFILTER, D3DTEXF_POINT ); pD3DD->SetSamplerState( 7, D3DSAMP_MIPFILTER, D3DTEXF_POINT ); ++iShadowPass; } else m_pShader->setConstant( "bEnableShadowMap", false ); // apply the shader and upload all constants for rendering.. if (! m_pShader->apply( pDeviceD3D ) ) return false; // render geometry.. if (! executeChildren() ) return false; if ( nLightCount == 0 ) { // after the first light, switch to additive blending mode.. pD3DD->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA ); pD3DD->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ONE ); // disable ambient in the shader, so the colors don't accumulate per light.. m_pShader->setConstant( "bEnableAmbient", false ); } } } return true; }