#include "gpu/ipc/service/gles2_command_buffer_stub.h"
#include <memory>
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/hash/hash.h"
#include "base/json/json_writer.h"
#include "base/memory/memory_pressure_listener.h"
#include "base/memory/unsafe_shared_memory_region.h"
#include "base/memory/weak_ptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "gpu/command_buffer/common/constants.h"
#include "gpu/command_buffer/common/mailbox.h"
#include "gpu/command_buffer/common/presentation_feedback_utils.h"
#include "gpu/command_buffer/common/swap_buffers_flags.h"
#include "gpu/command_buffer/service/gl_context_virtual.h"
#include "gpu/command_buffer/service/gl_state_restorer_impl.h"
#include "gpu/command_buffer/service/gpu_fence_manager.h"
#include "gpu/command_buffer/service/logger.h"
#include "gpu/command_buffer/service/memory_tracking.h"
#include "gpu/command_buffer/service/scheduler.h"
#include "gpu/command_buffer/service/service_utils.h"
#include "gpu/command_buffer/service/sync_point_manager.h"
#include "gpu/command_buffer/service/transfer_buffer_manager.h"
#include "gpu/config/gpu_crash_keys.h"
#include "gpu/ipc/service/gpu_channel.h"
#include "gpu/ipc/service/gpu_channel_manager.h"
#include "gpu/ipc/service/gpu_channel_manager_delegate.h"
#include "gpu/ipc/service/gpu_memory_buffer_factory.h"
#include "gpu/ipc/service/gpu_watchdog_thread.h"
#include "gpu/ipc/service/image_transport_surface.h"
#include "ui/gfx/buffer_format_util.h"
#include "ui/gfx/gpu_fence.h"
#include "ui/gfx/gpu_fence_handle.h"
#include "ui/gfx/switches.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_features.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface_egl.h"
#include "ui/gl/gl_switches.h"
#include "ui/gl/gl_utils.h"
#include "ui/gl/init/gl_factory.h"
#if BUILDFLAG(IS_WIN)
#include "base/win/win_util.h"
#endif
namespace gpu {
GLES2CommandBufferStub::GLES2CommandBufferStub(
GpuChannel* channel,
const mojom::CreateCommandBufferParams& init_params,
CommandBufferId command_buffer_id,
SequenceId sequence_id,
int32_t stream_id,
int32_t route_id)
: … { … }
GLES2CommandBufferStub::~GLES2CommandBufferStub() = default;
gpu::ContextResult GLES2CommandBufferStub::Initialize(
CommandBufferStub* share_command_buffer_stub,
const mojom::CreateCommandBufferParams& init_params,
base::UnsafeSharedMemoryRegion shared_state_shm) { … }
MemoryTracker* GLES2CommandBufferStub::GetContextGroupMemoryTracker() const { … }
base::WeakPtr<CommandBufferStub> GLES2CommandBufferStub::AsWeakPtr() { … }
void GLES2CommandBufferStub::OnGpuSwitched(
gl::GpuPreference active_gpu_heuristic) { … }
void GLES2CommandBufferStub::OnSetDefaultFramebufferSharedImage(
const Mailbox& mailbox,
int samples_count,
bool preserve,
bool needs_depth,
bool needs_stencil) { … }
void GLES2CommandBufferStub::CreateGpuFenceFromHandle(
uint32_t gpu_fence_id,
gfx::GpuFenceHandle handle) { … }
void GLES2CommandBufferStub::GetGpuFenceHandle(
uint32_t gpu_fence_id,
GetGpuFenceHandleCallback callback) { … }
void GLES2CommandBufferStub::OnSwapBuffers(uint64_t swap_id, uint32_t flags) { … }
}