AcademySoftwareFoundation / AcademySoftwareFoundation/OpenColorIO
Add helper methods to ViewingRules class
- Lingua principale
- C++
- Stelle
- 2.1k
- Fork
- 503
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Here are some helper functions that contain useful functionality to add to the ViewingRules class. The API of the functions below should be altered, as appropriate. As always, unit tests must be added.
```
bool viewingRulesAreEqual(const ConstViewingRulesRcPtr & r1,
size_t r1Idx,
const ConstViewingRulesRcPtr & r2,
size_t r2Idx)
{
// NB: No need to compare the name of the rules, that should be done in the caller.
// Compare color space tokens, handling the case where they may be in a different order.
if (r1->getNumColorSpaces(r1Idx) != r2->getNumColorSpaces(r2Idx))
{
return false;
}
TokensManager r1ColorSpaces;
for (size_t m = 0; m < r1->getNumColorSpaces(r1Idx); m++)
{
r1ColorSpaces.addToken(r1->getColorSpace(r1Idx, m));
}
for (size_t m = 0; m < r2->getNumColorSpaces(r2Idx); m++)
{
if (!r1ColorSpaces.hasToken(r2->getColorSpace(r2Idx, m)))
{
return false;
}
}
// Compare encoding tokens, handling the case where they may be in a different order.
if (r1->getNumEncodings(r1Idx) != r2->getNumEncodings(r2Idx))
{
return false;
}
TokensManager r1Encodings;
for (size_t m = 0; m < r1->getNumEncodings(r1Idx); m++)
{
r1Encodings.addToken(r1->getEncoding(r1Idx, m));
}
for (size_t m = 0; m < r2->getNumEncodings(r2Idx); m++)
{
if(!r1Encodings.hasToken(r2->getEncoding(r2Idx, m)))
{
return false;
}
}
// Compare the custom keys, handling the case where they may be in a different order.
if (r1->getNumCustomKeys(r1Idx) != r2->getNumCustomKeys(r2Idx))
{
return false;
}
CustomKeysContainer r1CustomKeys;
for (size_t m = 0; m < r1->getNumCustomKeys(r1Idx); m++)
{
r1CustomKeys.set(r1->getCustomKeyName(r1Idx, m), r1->getCustomKeyValue(r1Idx, m));
}
for (size_t m = 0; m < r2->getNumCustomKeys(r2Idx); m++)
{
if (!r1CustomKeys.hasKey(r2->getCustomKeyName(r2Idx, m)))
{
return false;
}
else
{
if (Platform::Strcasecmp(r1CustomKeys.getValueForKey(r2->getCustomKeyName(r2Idx, m)),
r2->getCustomKeyValue(r2Idx, m)) != 0)
{
return false;
}
}
}
return true;
}
```
```
void copyViewingRule(const ConstViewingRulesRcPtr & src,
size_t srcIdx,
size_t dstIdx,
ViewingRulesRcPtr & rules)
{
rules->insertRule(dstIdx, src->getName(srcIdx));
for (int j = 0; j < static_cast(src->getNumColorSpaces(srcIdx)); j++)
{
rules->addColorSpace(dstIdx, src->getColorSpace(srcIdx, j));
}
for (int k = 0; k < static_cast(src->getNumEncodings(srcIdx)); k++)
{
rules->addEncoding(dstIdx, src->getEncoding(srcIdx, k));
}
for (int l = 0; l < static_cast(src->getNumCustomKeys(srcIdx)); l++)
{
rules->setCustomKey(dstIdx, src->getCustomKeyName(srcIdx, l), src->getCustomKeyValue(srcIdx, l));
}
}
```
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia individuando la classe ViewingRules e i relativi test unitari esistenti. Esamina il comportamento fornito di viewingRulesAreEqual e copyViewingRule, quindi determina l’API pubblica appropriata. Il lavoro è completato quando i metodi di supporto sono disponibili su ViewingRules e i test unitari coprono i confronti indipendenti dall’ordine e la copia di spazi colore, codifiche e chiavi personalizzate.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- cpp
- Ambito
- computer-graphics
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100