chromium/ui/gl/gl_surface_egl.cc

// 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.

#include "ui/gl/gl_surface_egl.h"

#include <stddef.h>
#include <stdint.h>

#include <map>
#include <memory>
#include <sstream>
#include <utility>
#include <vector>

#include "base/compiler_specific.h"
#include "base/containers/heap_array.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ref.h"
#include "base/scoped_environment_variable_override.h"
#include "base/system/sys_info.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "ui/events/platform/platform_event_dispatcher.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/gpu_fence.h"
#include "ui/gl/egl_util.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_display_egl_util.h"
#include "ui/gl/gl_display_manager.h"
#include "ui/gl/gl_surface_presentation_helper.h"
#include "ui/gl/gl_surface_stub.h"
#include "ui/gl/gl_utils.h"
#include "ui/gl/scoped_make_current.h"
#include "ui/gl/sync_control_vsync_provider.h"

#if !defined(EGL_FIXED_SIZE_ANGLE)
#define EGL_FIXED_SIZE_ANGLE
#endif

#if !defined(EGL_OPENGL_ES3_BIT)
#define EGL_OPENGL_ES3_BIT
#endif

// Not present egl/eglext.h yet.

#ifndef EGL_EXT_gl_colorspace_display_p3
#define EGL_EXT_gl_colorspace_display_p3
#define EGL_GL_COLORSPACE_DISPLAY_P3_EXT
#endif /* EGL_EXT_gl_colorspace_display_p3 */

#ifndef EGL_EXT_gl_colorspace_display_p3_passthrough
#define EGL_EXT_gl_colorspace_display_p3_passthrough
#define EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT
#endif /* EGL_EXT_gl_colorspace_display_p3_passthrough */

// From ANGLE's egl/eglext.h.

#ifndef EGL_ANGLE_robust_resource_initialization
#define EGL_ANGLE_robust_resource_initialization
#define EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE
#endif /* EGL_ANGLE_display_robust_resource_initialization */

#ifndef EGL_ANGLE_surface_orientation
#define EGL_ANGLE_surface_orientation
#define EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE
#define EGL_SURFACE_ORIENTATION_ANGLE
#define EGL_SURFACE_ORIENTATION_INVERT_X_ANGLE
#define EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE
#endif /* EGL_ANGLE_surface_orientation */

GetLastEGLErrorString;

namespace gl {

namespace {

constexpr const char kSwapEventTraceCategories[] =;

constexpr size_t kMaxTimestampsSupportable =;

struct TraceSwapEventsInitializer {};

static base::LazyInstance<TraceSwapEventsInitializer>::Leaky
    g_trace_swap_enabled =;

class EGLSyncControlVSyncProvider : public SyncControlVSyncProvider {};

bool ValidateEglConfig(EGLDisplay display,
                       const EGLint* config_attribs,
                       EGLint* num_configs) {}

EGLConfig ChooseConfig(EGLDisplay display,
                       GLSurfaceFormat format,
                       bool surfaceless,
                       bool offscreen,
                       EGLint visual_id) {}

}  // namespace

GLSurfaceEGL::GLSurfaceEGL(GLDisplayEGL* display) :{}

GLSurfaceFormat GLSurfaceEGL::GetFormat() {}

GLDisplay* GLSurfaceEGL::GetGLDisplay() {}

EGLConfig GLSurfaceEGL::GetConfig() {}

EGLint GLSurfaceEGL::GetNativeVisualID() const {}

EGLDisplay GLSurfaceEGL::GetEGLDisplay() {}

// static
GLDisplayEGL* GLSurfaceEGL::GetGLDisplayEGL() {}

GLSurfaceEGL::~GLSurfaceEGL() {}

#if BUILDFLAG(IS_ANDROID)
NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(
    GLDisplayEGL* display,
    ScopedANativeWindow scoped_window,
    std::unique_ptr<gfx::VSyncProvider> vsync_provider)
    : GLSurfaceEGL(display),
      scoped_window_(std::move(scoped_window)),
      window_(scoped_window_.a_native_window()),
      vsync_provider_external_(std::move(vsync_provider)) {}
#else
NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(
    GLDisplayEGL* display,
    EGLNativeWindowType window,
    std::unique_ptr<gfx::VSyncProvider> vsync_provider)
    :{}
#endif  // BUILDFLAG(IS_ANDROID)

bool NativeViewGLSurfaceEGL::Initialize(GLSurfaceFormat format) {}

bool NativeViewGLSurfaceEGL::SupportsSwapTimestamps() const {}

void NativeViewGLSurfaceEGL::SetEnableSwapTimestamps() {}

bool NativeViewGLSurfaceEGL::InitializeNativeWindow() {}

void NativeViewGLSurfaceEGL::Destroy() {}

bool NativeViewGLSurfaceEGL::IsOffscreen() {}

gfx::SwapResult NativeViewGLSurfaceEGL::SwapBuffers(
    PresentationCallback callback,
    gfx::FrameData data) {}

void NativeViewGLSurfaceEGL::UpdateSwapEvents(EGLuint64KHR newFrameId,
                                              bool newFrameIdIsValid) {}

void NativeViewGLSurfaceEGL::TraceSwapEvents(EGLuint64KHR oldFrameId) {}

std::unique_ptr<gfx::VSyncProvider>
NativeViewGLSurfaceEGL::CreateVsyncProviderInternal() {}

gfx::Size NativeViewGLSurfaceEGL::GetSize() {}

bool NativeViewGLSurfaceEGL::Resize(const gfx::Size& size,
                                    float scale_factor,
                                    const gfx::ColorSpace& color_space,
                                    bool has_alpha) {}

bool NativeViewGLSurfaceEGL::Recreate() {}

EGLSurface NativeViewGLSurfaceEGL::GetHandle() {}

bool NativeViewGLSurfaceEGL::SupportsPostSubBuffer() {}

gfx::SurfaceOrigin NativeViewGLSurfaceEGL::GetOrigin() const {}

EGLTimestampClient* NativeViewGLSurfaceEGL::GetEGLTimestampClient() {}

bool NativeViewGLSurfaceEGL::IsEGLTimestampSupported() const {}

bool NativeViewGLSurfaceEGL::GetFrameTimestampInfoIfAvailable(
    base::TimeTicks* presentation_time,
    base::TimeDelta* composite_interval,
    base::TimeTicks* writes_done_time,
    uint32_t* presentation_flags,
    int frame_id) {}

gfx::SwapResult NativeViewGLSurfaceEGL::SwapBuffersWithDamage(
    const std::vector<int>& rects,
    PresentationCallback callback,
    gfx::FrameData data) {}

gfx::SwapResult NativeViewGLSurfaceEGL::PostSubBuffer(
    int x,
    int y,
    int width,
    int height,
    PresentationCallback callback,
    gfx::FrameData data) {}

bool NativeViewGLSurfaceEGL::OnMakeCurrent(GLContext* context) {}

gfx::VSyncProvider* NativeViewGLSurfaceEGL::GetVSyncProvider() {}

void NativeViewGLSurfaceEGL::SetVSyncEnabled(bool enabled) {}

NativeViewGLSurfaceEGL::~NativeViewGLSurfaceEGL() {}

PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(GLDisplayEGL* display,
                                         const gfx::Size& size)
    :{}

bool PbufferGLSurfaceEGL::Initialize(GLSurfaceFormat format) {}

void PbufferGLSurfaceEGL::Destroy() {}

bool PbufferGLSurfaceEGL::IsOffscreen() {}

gfx::SwapResult PbufferGLSurfaceEGL::SwapBuffers(PresentationCallback callback,
                                                 gfx::FrameData data) {}

gfx::Size PbufferGLSurfaceEGL::GetSize() {}

bool PbufferGLSurfaceEGL::Resize(const gfx::Size& size,
                                 float scale_factor,
                                 const gfx::ColorSpace& color_space,
                                 bool has_alpha) {}

EGLSurface PbufferGLSurfaceEGL::GetHandle() {}

void* PbufferGLSurfaceEGL::GetShareHandle() {}

PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() {}

SurfacelessEGL::SurfacelessEGL(GLDisplayEGL* display, const gfx::Size& size)
    :{}

bool SurfacelessEGL::Initialize(GLSurfaceFormat format) {}

void SurfacelessEGL::Destroy() {}

bool SurfacelessEGL::IsOffscreen() {}

bool SurfacelessEGL::IsSurfaceless() const {}

gfx::SwapResult SurfacelessEGL::SwapBuffers(PresentationCallback callback,
                                            gfx::FrameData data) {}

gfx::Size SurfacelessEGL::GetSize() {}

bool SurfacelessEGL::Resize(const gfx::Size& size,
                            float scale_factor,
                            const gfx::ColorSpace& color_space,
                            bool has_alpha) {}

EGLSurface SurfacelessEGL::GetHandle() {}

void* SurfacelessEGL::GetShareHandle() {}

SurfacelessEGL::~SurfacelessEGL() {}

}  // namespace gl