| 1504 | } |
| 1505 | |
| 1506 | bool |
| 1507 | Node::computeHashInternal() |
| 1508 | { |
| 1509 | if (!_imp->effect) { |
| 1510 | return false; |
| 1511 | } |
| 1512 | ///Always called in the main thread |
| 1513 | assert( QThread::currentThread() == qApp->thread() ); |
| 1514 | if (!_imp->inputsInitialized) { |
| 1515 | qDebug() << "Node::computeHash(): inputs not initialized"; |
| 1516 | } |
| 1517 | |
| 1518 | U64 oldHash, newHash; |
| 1519 | { |
| 1520 | QWriteLocker l(&_imp->knobsAgeMutex); |
| 1521 | |
| 1522 | oldHash = _imp->hash.value(); |
| 1523 | |
| 1524 | ///reset the hash value |
| 1525 | _imp->hash.reset(); |
| 1526 | |
| 1527 | ///append the effect's own age |
| 1528 | _imp->hash.append(_imp->knobsAge); |
| 1529 | |
| 1530 | ///append all inputs hash |
| 1531 | boost::shared_ptr<RotoDrawableItem> attachedStroke = _imp->paintStroke.lock(); |
| 1532 | NodePtr attachedStrokeContextNode; |
| 1533 | if (attachedStroke) { |
| 1534 | attachedStrokeContextNode = attachedStroke->getContext()->getNode(); |
| 1535 | } |
| 1536 | { |
| 1537 | ViewerInstance* isViewer = dynamic_cast<ViewerInstance*>( _imp->effect.get() ); |
| 1538 | |
| 1539 | if (isViewer) { |
| 1540 | int activeInput[2]; |
| 1541 | isViewer->getActiveInputs(activeInput[0], activeInput[1]); |
| 1542 | |
| 1543 | for (int i = 0; i < 2; ++i) { |
| 1544 | NodePtr input = getInput(activeInput[i]); |
| 1545 | if (input) { |
| 1546 | _imp->hash.append( input->getHashValue() ); |
| 1547 | } |
| 1548 | } |
| 1549 | } else { |
| 1550 | for (U32 i = 0; i < _imp->inputs.size(); ++i) { |
| 1551 | NodePtr input = getInput(i); |
| 1552 | if (input) { |
| 1553 | //Since the rotopaint node is connected to the internal nodes of the tree, don't change their hash |
| 1554 | if ( attachedStroke && (input == attachedStrokeContextNode) ) { |
| 1555 | continue; |
| 1556 | } |
| 1557 | ///Add the index of the input to its hash. |
| 1558 | ///Explanation: if we didn't add this, just switching inputs would produce a similar |
| 1559 | ///hash. |
| 1560 | _imp->hash.append(input->getHashValue() + i); |
| 1561 | } |
| 1562 | } |
| 1563 | } |
nothing calls this directly
no test coverage detected