// Copyright 2012 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_GL_GL_CONTEXT_H_ #define UI_GL_GL_CONTEXT_H_ #include <map> #include <memory> #include <string> #include "base/atomicops.h" #include "base/cancelable_callback.h" #include "base/memory/raw_ptr.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" #include "base/synchronization/atomic_flag.h" #include "build/build_config.h" #include "ui/gfx/extension_set.h" #include "ui/gl/gl_export.h" #include "ui/gl/gl_implementation_wrapper.h" #include "ui/gl/gl_share_group.h" #include "ui/gl/gl_state_restorer.h" #include "ui/gl/gpu_preference.h" namespace gl { class GLContextEGL; class GLDisplayEGL; } // namespace gl namespace gpu { class GLContextVirtual; #if BUILDFLAG(IS_APPLE) class GL_EXPORT BackpressureMetalSharedEvent { public: virtual ~BackpressureMetalSharedEvent() = default; virtual bool HasCompleted() const = 0; }; #endif // #if BUILDFLAG(IS_APPLE) } // namespace gpu namespace gl { struct CurrentGL; class LogGLApi; struct DriverGL; class GLApi; class GLFence; class GLSurface; class GPUTiming; class GPUTimingClient; struct GLVersionInfo; class RealGLApi; class TraceGLApi; // Where available, choose a GL context priority for devices that support it. // Currently this requires the EGL_IMG_context_priority extension that is // present on Daydream ready Android devices. Default is Medium, and the // attribute is ignored if the extension is missing. // // "High" priority must only be used for special cases with strong realtime // requirements, it is incompatible with other critical system GL work such as // the GVR library's asynchronous reprojection for VR viewing. Please avoid // using it for any GL contexts that may be used during VR presentation, // see crbug.com/727800. // // Instead, consider using "Low" priority for possibly-slow GL work such as // user WebGL content. enum ContextPriority { … }; // Angle allows selecting context virtualization group at context creation time. // This enum is used to specify the group number to use for a given context. // Currently all contexts which do not specify any group number are part of // default angle context virtualization group. The below use cases in Chrome use // become part of different virtualization groups via this enum. enum class AngleContextVirtualizationGroup { … }; struct GL_EXPORT GLContextAttribs { … }; // Encapsulates an OpenGL context, hiding platform specific management. // TODO(344606399): Consider folding GLContextEGL into this class. class GL_EXPORT GLContext : public base::RefCounted<GLContext> { … }; class GL_EXPORT GLContextReal : public GLContext { … }; // Wraps GLContext in scoped_refptr and tries to initializes it. Returns a // scoped_refptr containing the initialized GLContext or nullptr if // initialization fails. GL_EXPORT scoped_refptr<GLContext> InitializeGLContext( scoped_refptr<GLContext> context, GLSurface* compatible_surface, const GLContextAttribs& attribs); } // namespace gl #endif // UI_GL_GL_CONTEXT_H_