SharedMemoryRenderHandler.h 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. #pragma once
  2. #include "WallpaperEngine/WebBrowser/IPC/WebHostSharedMemory.h"
  3. #include "include/cef_browser.h"
  4. #include "include/cef_render_handler.h"
  5. namespace WallpaperEngine::WebBrowser::CEF {
  6. // Used only inside the disposable web-host child process (see WallpaperApplication::runWebHost()).
  7. // Has no GL context and no CWeb to talk to directly - it writes CEF's off-screen-rendered pixels
  8. // straight into the shared memory segment the main process reads frames from. GetViewRect reports
  9. // whatever size the main process last asked for via shm - the caller (runWebHost()) is responsible
  10. // for calling CefBrowserHost::WasResized() when that changes.
  11. class SharedMemoryRenderHandler : public CefRenderHandler {
  12. public:
  13. explicit SharedMemoryRenderHandler (WallpaperEngine::WebBrowser::IPC::WebHostSharedMemory* shm);
  14. ~SharedMemoryRenderHandler () override = default;
  15. void GetViewRect (CefRefPtr<CefBrowser> browser, CefRect& rect) override;
  16. void OnPaint (
  17. CefRefPtr<CefBrowser> browser, PaintElementType type, const RectList& dirtyRects, const void* buffer,
  18. int width, int height
  19. ) override;
  20. IMPLEMENT_REFCOUNTING (SharedMemoryRenderHandler);
  21. private:
  22. WallpaperEngine::WebBrowser::IPC::WebHostSharedMemory* m_shm;
  23. };
  24. } // namespace WallpaperEngine::WebBrowser::CEF