• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
23   SoftwareOutputDeviceProxy(const SoftwareOutputDeviceProxy&) = delete;
24   SoftwareOutputDeviceProxy& operator=(const SoftwareOutputDeviceProxy&) =
25       delete;
26 
27   ~SoftwareOutputDeviceProxy() override;
28 
29   // SoftwareOutputDevice implementation.
30   void OnSwapBuffers(SwapBuffersCallback swap_ack_callback) override;
31 
32   // SoftwareOutputDeviceBase implementation.
33   void Resize(const gfx::Size& viewport_pixel_size,
34               float scale_factor) override;
35   SkCanvas* BeginPaint(const gfx::Rect& damage_rect) override;
36   void EndPaint() override;
37 
38  private:
39   // Runs |swap_ack_callback_| after draw has happened.
40   void DrawAck();
41 
42   mojom::LayeredWindowUpdaterPtr layered_window_updater_;
43 
44   std::unique_ptr<SkCanvas> canvas_;
45   bool waiting_on_draw_ack_ = false;
46   bool in_paint_ = false;
47   base::OnceClosure swap_ack_callback_;
48   base::WritableSharedMemoryMapping shm_;
49 
50   THREAD_CHECKER(thread_checker_);
51 };
52 
53 }  // namespace viz
54 
55 #endif  // CEF_LIBCEF_BROWSER_OSR_SOFTWARE_OUTPUT_DEVICE_PROXY_H_