MCPcopy Create free account
hub / github.com/Nevcairiel/LAVFilters / PreparePalette

Method PreparePalette

common/baseclasses/winutil.cpp:1803–1869  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1801// for a specific monitor on a multi monitor system
1802
1803HRESULT CImagePalette::PreparePalette(const CMediaType *pmtNew, const CMediaType *pmtOld, __in LPSTR szDevice)
1804{
1805 const VIDEOINFOHEADER *pNewInfo = (VIDEOINFOHEADER *)pmtNew->Format();
1806 const VIDEOINFOHEADER *pOldInfo = (VIDEOINFOHEADER *)pmtOld->Format();
1807 ASSERT(pNewInfo);
1808
1809 // This is an performance optimisation, when we get a media type we check
1810 // to see if the format requires a palette change. If either we need one
1811 // when previously we didn't or vica versa then this returns TRUE, if we
1812 // previously needed a palette and we do now it compares their colours
1813
1814 if (ShouldUpdate(pNewInfo, pOldInfo) == FALSE)
1815 {
1816 NOTE("No update needed");
1817 return S_FALSE;
1818 }
1819
1820 // We must notify the filter graph that the application may have changed
1821 // the palette although in practice we don't bother checking to see if it
1822 // is really different. If it tries to get the palette either the window
1823 // or renderer lock will ensure it doesn't get in until we are finished
1824
1825 RemovePalette();
1826 m_pFilter->NotifyEvent(EC_PALETTE_CHANGED, 0, 0);
1827
1828 // Do we need a palette for the new format
1829
1830 if (ContainsPalette(pNewInfo) == FALSE)
1831 {
1832 NOTE("New has no palette");
1833 return S_FALSE;
1834 }
1835
1836 if (m_pBaseWindow)
1837 {
1838 m_pBaseWindow->LockPaletteLock();
1839 }
1840
1841 // If we're changing the palette on the fly then we increment our palette
1842 // cookie which is compared against the cookie also stored in all of our
1843 // DIBSECTION media samples. If they don't match when we come to draw it
1844 // then we know the sample is out of date and we'll update it's palette
1845
1846 NOTE("Making new colour palette");
1847 m_hPalette = MakePalette(pNewInfo, szDevice);
1848 ASSERT(m_hPalette != NULL);
1849
1850 if (m_pBaseWindow)
1851 {
1852 m_pBaseWindow->UnlockPaletteLock();
1853 }
1854
1855 // The window in which the new palette is to be realised may be a NULL
1856 // pointer to signal that no window is in use, if so we don't call it
1857 // Some filters just want to use this object to create/manage palettes
1858
1859 if (m_pBaseWindow)
1860 m_pBaseWindow->SetPalette(m_hPalette);

Callers

nothing calls this directly

Calls 7

ContainsPaletteFunction · 0.85
FormatMethod · 0.80
NotifyEventMethod · 0.80
LockPaletteLockMethod · 0.80
UnlockPaletteLockMethod · 0.80
SetPaletteMethod · 0.45

Tested by

no test coverage detected