void UIWidget::setBlendFunc(BlendFunc blendFunc) { BlendProtocol * blendNode = DYNAMIC_CAST_CCBLENDPROTOCOL; if (blendNode) { blendNode->setBlendFunc(blendFunc); } }
void TDDHelper::setAlphaPremultiplied(Node *node) { if(node == NULL) { return; } BlendProtocol *ptr = dynamic_cast<BlendProtocol *>(node); if(ptr == NULL) { return; } ptr->setBlendFunc(BlendFunc::ALPHA_PREMULTIPLIED); }
bool LWFRendererFactory::Render(class LWF *lwf, Node *node, BlendEquationProtocol *be, int renderingIndex, bool visible, BlendFunc *baseBlendFunc) { m_renderingIndex = renderingIndex; node->setVisible(visible); if (!visible) return false; Node *target; switch (m_maskMode) { case Format::BLEND_MODE_ERASE: case Format::BLEND_MODE_MASK: case Format::BLEND_MODE_LAYER: { LWFMask *mask; if (m_lastMaskMode != m_maskMode) { ++m_maskNo; if (m_masks.size() > m_maskNo) { mask = m_masks[m_maskNo]; } else { mask = LWFMask::create(); m_masks.push_back(mask); } PlaceNode(m_node, mask); LWFMask *layer = nullptr; if (m_lastMaskMode == Format::BLEND_MODE_LAYER && (m_maskMode == Format::BLEND_MODE_ERASE || m_maskMode == Format::BLEND_MODE_MASK) && m_maskNo > 0) { layer = m_masks[m_maskNo - 1]; if (layer) layer->setLocalZOrder(INT_MAX); PlaceNode(mask, layer); } if (layer && mask) { switch (m_maskMode) { case Format::BLEND_MODE_ERASE: case Format::BLEND_MODE_MASK: switch (m_maskMode) { case Format::BLEND_MODE_ERASE: layer->setBlendFunc( {GL_ONE_MINUS_DST_ALPHA, GL_ZERO}); break; case Format::BLEND_MODE_MASK: layer->setBlendFunc( {GL_DST_ALPHA, GL_ZERO}); break; } BlendFunc blendFunc = {GL_ONE, GL_ZERO}; GetBlendFunc(blendFunc, m_blendMode); mask->setBlendFunc(blendFunc); break; } } m_lastMaskMode = m_maskMode; } else { mask = m_masks[m_maskNo]; } if (mask) mask->setLocalZOrder(m_renderingIndex + 1); target = mask; } break; default: target = m_node; break; } PlaceNode(target, node); node->setLocalZOrder(renderingIndex); BlendProtocol *p = dynamic_cast<BlendProtocol *>(node); if (p) { BlendFunc blendFunc = baseBlendFunc ? *baseBlendFunc : p->getBlendFunc(); GetBlendFunc(blendFunc, m_blendMode); p->setBlendFunc(blendFunc); } BlendEquationProtocol *ep = dynamic_cast<BlendEquationProtocol *>(node); if (ep) ep->setBlendEquation(m_blendMode); return true; }