| 1791 | } |
| 1792 | |
| 1793 | void PMTraceConsumer::HandleDWMEvent(EVENT_RECORD* pEventRecord) |
| 1794 | { |
| 1795 | auto const& hdr = pEventRecord->EventHeader; |
| 1796 | switch (hdr.EventDescriptor.Id) { |
| 1797 | case Microsoft_Windows_Dwm_Core::MILEVENT_MEDIA_UCE_PROCESSPRESENTHISTORY_GetPresentHistory_Info::Id: |
| 1798 | // Move all the latest in-progress Composed_Copy from each window into |
| 1799 | // mPresentsWaitingForDWM, to be attached to the next DWM present's |
| 1800 | // DependentPresents. |
| 1801 | for (auto& hWndPair : mLastPresentByWindow) { |
| 1802 | auto& present = hWndPair.second; |
| 1803 | if (present->PresentMode == PresentMode::Composed_Copy_GPU_GDI || |
| 1804 | present->PresentMode == PresentMode::Composed_Copy_CPU_GDI) { |
| 1805 | VerboseTraceBeforeModifyingPresent(present.get()); |
| 1806 | mPresentsWaitingForDWM.emplace_back(present); |
| 1807 | present->PresentInDwmWaitingStruct = true; |
| 1808 | } |
| 1809 | } |
| 1810 | mLastPresentByWindow.clear(); |
| 1811 | break; |
| 1812 | |
| 1813 | case Microsoft_Windows_Dwm_Core::SCHEDULE_PRESENT_Start::Id: |
| 1814 | DwmProcessId = hdr.ProcessId; |
| 1815 | DwmPresentThreadId = hdr.ThreadId; |
| 1816 | break; |
| 1817 | |
| 1818 | // These events are only used for Composed_Copy_CPU_GDI presents. They are |
| 1819 | // used to identify when such presents are handed off to DWM. |
| 1820 | case Microsoft_Windows_Dwm_Core::FlipChain_Pending::Id: |
| 1821 | case Microsoft_Windows_Dwm_Core::FlipChain_Complete::Id: |
| 1822 | case Microsoft_Windows_Dwm_Core::FlipChain_Dirty::Id: |
| 1823 | { |
| 1824 | if (InlineIsEqualGUID(hdr.ProviderId, Microsoft_Windows_Dwm_Core::Win7::GUID)) { |
| 1825 | break; |
| 1826 | } |
| 1827 | |
| 1828 | // ulFlipChain and ulSerialNumber are expected to be uint32_t data, but |
| 1829 | // on Windows 8.1 the event properties are specified as uint64_t. |
| 1830 | auto GetU32FromU32OrU64 = [](EventDataDesc const& desc) { |
| 1831 | if (desc.size_ == 4) { |
| 1832 | return desc.GetData<uint32_t>(); |
| 1833 | } else { |
| 1834 | auto u64 = desc.GetData<uint64_t>(); |
| 1835 | DebugAssert(u64 <= UINT32_MAX); |
| 1836 | return (uint32_t) u64; |
| 1837 | } |
| 1838 | }; |
| 1839 | |
| 1840 | EventDataDesc desc[] = { |
| 1841 | { L"ulFlipChain" }, |
| 1842 | { L"ulSerialNumber" }, |
| 1843 | { L"hwnd" }, |
| 1844 | }; |
| 1845 | mMetadata.GetEventData(pEventRecord, desc, _countof(desc)); |
| 1846 | auto ulFlipChain = GetU32FromU32OrU64(desc[0]); |
| 1847 | auto ulSerialNumber = GetU32FromU32OrU64(desc[1]); |
| 1848 | auto hwnd = desc[2].GetData<uint64_t>(); |
| 1849 | |
| 1850 | // Lookup the present using the 64-bit token data from the PHT |
no test coverage detected