X-Git-Url: https://git.sesse.net/?p=nageru;a=blobdiff_plain;f=cef_capture.cpp;fp=cef_capture.cpp;h=c52e3a45ddccf92f18b6fb489a80d26b66f05ebc;hp=76c5c7f753c8630ff6a796de58ac660daff65bf1;hb=82e392b0e444d9b4043b78ef3413343b092e4537;hpb=a1fac4049d79171dc40f0cd416c1358fd4dc2d3c diff --git a/cef_capture.cpp b/cef_capture.cpp index 76c5c7f..c52e3a4 100644 --- a/cef_capture.cpp +++ b/cef_capture.cpp @@ -99,16 +99,25 @@ void CEFCapture::OnPaint(const void *buffer, int width, int height) video_format.is_connected = true; FrameAllocator::Frame video_frame = video_frame_allocator->alloc_frame(); - if (video_frame.data != nullptr) { + if (video_frame.data == nullptr) { + // We lost a frame, so we need to invalidate the entire thing. + // (CEF only sends OnPaint when there are actual changes, + // so we need to do this explicitly, or we could be stuck on an + // old frame forever if the image doesn't change.) + post_to_cef_ui_thread([this] { + browser->GetHost()->Invalidate(PET_VIEW); + }); + ++timecode; + } else { assert(video_frame.size >= unsigned(width * height * 4)); assert(!video_frame.interleaved); memcpy(video_frame.data, buffer, width * height * 4); video_frame.len = video_format.stride * height; video_frame.received_timestamp = timestamp; + frame_callback(timecode++, + video_frame, 0, video_format, + FrameAllocator::Frame(), 0, AudioFormat()); } - frame_callback(timecode++, - video_frame, 0, video_format, - FrameAllocator::Frame(), 0, AudioFormat()); } void CEFCapture::OnLoadEnd()