2019-07-16 22:09:04 +02:00
|
|
|
#ifndef CEF_LIBCEF_BROWSER_OSR_SOFTWARE_OUTPUT_DEVICE_PROXY_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_OSR_SOFTWARE_OUTPUT_DEVICE_PROXY_H_
|
|
|
|
|
|
|
|
#include "base/memory/shared_memory_mapping.h"
|
|
|
|
#include "base/threading/thread_checker.h"
|
|
|
|
#include "components/viz/service/display/software_output_device.h"
|
|
|
|
#include "components/viz/service/viz_service_export.h"
|
2022-03-26 02:12:30 +01:00
|
|
|
#include "mojo/public/cpp/bindings/remote.h"
|
2019-10-01 15:55:16 +02:00
|
|
|
#include "services/viz/privileged/mojom/compositing/layered_window_updater.mojom.h"
|
2019-07-16 22:09:04 +02:00
|
|
|
|
|
|
|
namespace viz {
|
|
|
|
|
|
|
|
// SoftwareOutputDevice implementation that draws indirectly. An
|
|
|
|
// implementation of mojom::LayeredWindowUpdater in the browser process
|
|
|
|
// handles the actual drawing. Pixel backing is in SharedMemory so no copying
|
|
|
|
// between processes is required.
|
|
|
|
class VIZ_SERVICE_EXPORT SoftwareOutputDeviceProxy
|
|
|
|
: public SoftwareOutputDevice {
|
|
|
|
public:
|
|
|
|
explicit SoftwareOutputDeviceProxy(
|
2022-03-26 02:12:30 +01:00
|
|
|
mojo::PendingRemote<mojom::LayeredWindowUpdater> layered_window_updater);
|
2021-12-06 21:40:25 +01:00
|
|
|
|
|
|
|
SoftwareOutputDeviceProxy(const SoftwareOutputDeviceProxy&) = delete;
|
|
|
|
SoftwareOutputDeviceProxy& operator=(const SoftwareOutputDeviceProxy&) =
|
|
|
|
delete;
|
|
|
|
|
2019-07-16 22:09:04 +02:00
|
|
|
~SoftwareOutputDeviceProxy() override;
|
|
|
|
|
|
|
|
// SoftwareOutputDevice implementation.
|
2023-01-03 00:34:43 +01:00
|
|
|
void OnSwapBuffers(SwapBuffersCallback swap_ack_callback,
|
|
|
|
gl::FrameData data) override;
|
2019-07-16 22:09:04 +02:00
|
|
|
|
|
|
|
// SoftwareOutputDeviceBase implementation.
|
|
|
|
void Resize(const gfx::Size& viewport_pixel_size,
|
|
|
|
float scale_factor) override;
|
|
|
|
SkCanvas* BeginPaint(const gfx::Rect& damage_rect) override;
|
|
|
|
void EndPaint() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Runs |swap_ack_callback_| after draw has happened.
|
|
|
|
void DrawAck();
|
|
|
|
|
2022-03-26 02:12:30 +01:00
|
|
|
mojo::Remote<mojom::LayeredWindowUpdater> layered_window_updater_;
|
2019-07-16 22:09:04 +02:00
|
|
|
|
|
|
|
std::unique_ptr<SkCanvas> canvas_;
|
|
|
|
bool waiting_on_draw_ack_ = false;
|
|
|
|
bool in_paint_ = false;
|
|
|
|
base::OnceClosure swap_ack_callback_;
|
|
|
|
base::WritableSharedMemoryMapping shm_;
|
|
|
|
|
|
|
|
THREAD_CHECKER(thread_checker_);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace viz
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_OSR_SOFTWARE_OUTPUT_DEVICE_PROXY_H_
|