1 #ifndef CEF_LIBCEF_BROWSER_OSR_SOFTWARE_OUTPUT_DEVICE_PROXY_H_ 2 #define CEF_LIBCEF_BROWSER_OSR_SOFTWARE_OUTPUT_DEVICE_PROXY_H_ 3 4 #include "base/memory/shared_memory_mapping.h" 5 #include "base/threading/thread_checker.h" 6 #include "components/viz/service/display/software_output_device.h" 7 #include "components/viz/service/viz_service_export.h" 8 #include "services/viz/privileged/mojom/compositing/display_private.mojom.h" 9 #include "services/viz/privileged/mojom/compositing/layered_window_updater.mojom.h" 10 11 namespace viz { 12 13 // SoftwareOutputDevice implementation that draws indirectly. An 14 // implementation of mojom::LayeredWindowUpdater in the browser process 15 // handles the actual drawing. Pixel backing is in SharedMemory so no copying 16 // between processes is required. 17 class VIZ_SERVICE_EXPORT SoftwareOutputDeviceProxy 18 : public SoftwareOutputDevice { 19 public: 20 explicit SoftwareOutputDeviceProxy( 21 mojom::LayeredWindowUpdaterPtr layered_window_updater); 22 ~SoftwareOutputDeviceProxy() override; 23 24 // SoftwareOutputDevice implementation. 25 void OnSwapBuffers(SwapBuffersCallback swap_ack_callback) override; 26 27 // SoftwareOutputDeviceBase implementation. 28 void Resize(const gfx::Size& viewport_pixel_size, 29 float scale_factor) override; 30 SkCanvas* BeginPaint(const gfx::Rect& damage_rect) override; 31 void EndPaint() override; 32 33 private: 34 // Runs |swap_ack_callback_| after draw has happened. 35 void DrawAck(); 36 37 mojom::LayeredWindowUpdaterPtr layered_window_updater_; 38 39 std::unique_ptr<SkCanvas> canvas_; 40 bool waiting_on_draw_ack_ = false; 41 bool in_paint_ = false; 42 base::OnceClosure swap_ack_callback_; 43 base::WritableSharedMemoryMapping shm_; 44 45 THREAD_CHECKER(thread_checker_); 46 47 DISALLOW_COPY_AND_ASSIGN(SoftwareOutputDeviceProxy); 48 }; 49 50 } // namespace viz 51 52 #endif // CEF_LIBCEF_BROWSER_OSR_SOFTWARE_OUTPUT_DEVICE_PROXY_H_