// Copyright 2020 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef UI_OZONE_PLATFORM_WAYLAND_GPU_GL_SURFACE_EGL_READBACK_WAYLAND_H_ #define UI_OZONE_PLATFORM_WAYLAND_GPU_GL_SURFACE_EGL_READBACK_WAYLAND_H_ #include "base/containers/circular_deque.h" #include "base/memory/raw_ptr.h" #include "base/memory/shared_memory_mapping.h" #include "ui/ozone/common/gl_surface_egl_readback.h" #include "ui/ozone/platform/wayland/gpu/wayland_surface_gpu.h" namespace ui { class WaylandBufferManagerGpu; // This is a GLSurface implementation that uses glReadPixels to populate a // shared memory region with the contents of the surface, and then passes the // shared memory region to Wayland for presentation. // // Basic control flow: // 1. Resize() creates kMaxBuffers shared memory regions. These are added to // available_buffers_ and registered with Wayland via CreateShmBasedBuffer(). // 2. SwapBuffersAsync() calls glReadPixels() to read the contents of the // active GL context into the next available shared memory region. The shared // memory region is immediately sent to Wayland via CommitBuffer(). // 3. The buffer is not available for reuse until OnSubmission() is called. // // Note: This class relies on the assumption that kMaxBuffers is necessary and // sufficient. The behavior is undefined if SwapBuffersAsync() is called and no // buffers are available. class GLSurfaceEglReadbackWayland : public GLSurfaceEglReadback, public WaylandSurfaceGpu { … }; } // namespace ui #endif // UI_OZONE_PLATFORM_WAYLAND_GPU_GL_SURFACE_EGL_READBACK_WAYLAND_H_