| 88 | } |
| 89 | |
| 90 | void RenderState::StateBlock::apply(PipelineDescriptor* pipelineDescriptor) |
| 91 | { |
| 92 | // AX_ASSERT(_globalState); |
| 93 | |
| 94 | auto renderer = Director::getInstance()->getRenderer(); |
| 95 | auto& blend = pipelineDescriptor->blendDescriptor; |
| 96 | |
| 97 | // Update any state that differs from _globalState and flip _globalState bits |
| 98 | if ((_modifiedBits & RS_BLEND)) |
| 99 | { |
| 100 | blend.blendEnabled = _blendEnabled; |
| 101 | } |
| 102 | |
| 103 | if ((_modifiedBits & RS_BLEND_FUNC)) |
| 104 | { |
| 105 | blend.sourceAlphaBlendFactor = blend.sourceRGBBlendFactor = _blendSrc; |
| 106 | blend.destinationAlphaBlendFactor = blend.destinationRGBBlendFactor = _blendDst; |
| 107 | } |
| 108 | |
| 109 | if ((_modifiedBits & RS_CULL_FACE)) |
| 110 | { |
| 111 | if (!_cullFaceEnabled) |
| 112 | renderer->setCullMode(CullMode::NONE); |
| 113 | } |
| 114 | |
| 115 | if ((_modifiedBits & RS_CULL_FACE_SIDE)) |
| 116 | { |
| 117 | renderer->setCullMode(_cullFaceSide); |
| 118 | } |
| 119 | |
| 120 | if ((_modifiedBits & RS_FRONT_FACE)) |
| 121 | { |
| 122 | renderer->setWinding(_frontFace); |
| 123 | } |
| 124 | if ((_modifiedBits & RS_DEPTH_TEST)) |
| 125 | { |
| 126 | renderer->setDepthTest(_depthTestEnabled); |
| 127 | } |
| 128 | |
| 129 | if ((_modifiedBits & RS_DEPTH_WRITE)) |
| 130 | { |
| 131 | renderer->setDepthWrite(_depthWriteEnabled); |
| 132 | } |
| 133 | |
| 134 | if ((_modifiedBits & RS_DEPTH_FUNC)) |
| 135 | { |
| 136 | renderer->setDepthCompareFunction(_depthFunction); |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | void RenderState::StateBlock::restoreUnmodifiedStates(int32_t overrideBits, PipelineDescriptor* programState) |
| 141 | { |
no test coverage detected