Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ci/licenses_golden/excluded_files
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@
../../../flutter/impeller/tessellator/tessellator_unittests.cc
../../../flutter/impeller/toolkit/android/README.md
../../../flutter/impeller/toolkit/android/toolkit_android_unittests.cc
../../../flutter/impeller/toolkit/glvk/README.md
../../../flutter/impeller/tools/malioc_cores.py
../../../flutter/impeller/tools/malioc_diff.py
../../../flutter/impeller/tools/metal_library.py
Expand Down
12 changes: 12 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -42612,6 +42612,10 @@ ORIGIN: ../../../flutter/impeller/toolkit/egl/surface.cc + ../../../flutter/LICE
ORIGIN: ../../../flutter/impeller/toolkit/egl/surface.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/toolkit/gles/gles.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/toolkit/gles/texture.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/toolkit/glvk/proc_table.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/toolkit/glvk/proc_table.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/toolkit/glvk/trampoline.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/toolkit/glvk/trampoline.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/typographer/backends/skia/text_frame_skia.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/typographer/backends/skia/text_frame_skia.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/impeller/typographer/backends/skia/typeface_skia.cc + ../../../flutter/LICENSE
Expand Down Expand Up @@ -43502,6 +43506,8 @@ ORIGIN: ../../../flutter/shell/platform/android/surface_texture_external_texture
ORIGIN: ../../../flutter/shell/platform/android/surface_texture_external_texture_gl_impeller.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/surface_texture_external_texture_gl_skia.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/surface_texture_external_texture_gl_skia.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/surface_texture_external_texture_vk_impeller.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/surface_texture_external_texture_vk_impeller.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/vsync_waiter_android.cc + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/android/vsync_waiter_android.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/common/accessibility_bridge.cc + ../../../flutter/LICENSE
Expand Down Expand Up @@ -45488,6 +45494,10 @@ FILE: ../../../flutter/impeller/toolkit/egl/surface.h
FILE: ../../../flutter/impeller/toolkit/gles/gles.h
FILE: ../../../flutter/impeller/toolkit/gles/texture.cc
FILE: ../../../flutter/impeller/toolkit/gles/texture.h
FILE: ../../../flutter/impeller/toolkit/glvk/proc_table.cc
FILE: ../../../flutter/impeller/toolkit/glvk/proc_table.h
FILE: ../../../flutter/impeller/toolkit/glvk/trampoline.cc
FILE: ../../../flutter/impeller/toolkit/glvk/trampoline.h
FILE: ../../../flutter/impeller/tools/malioc.json
FILE: ../../../flutter/impeller/typographer/backends/skia/text_frame_skia.cc
FILE: ../../../flutter/impeller/typographer/backends/skia/text_frame_skia.h
Expand Down Expand Up @@ -46392,6 +46402,8 @@ FILE: ../../../flutter/shell/platform/android/surface_texture_external_texture_g
FILE: ../../../flutter/shell/platform/android/surface_texture_external_texture_gl_impeller.h
FILE: ../../../flutter/shell/platform/android/surface_texture_external_texture_gl_skia.cc
FILE: ../../../flutter/shell/platform/android/surface_texture_external_texture_gl_skia.h
FILE: ../../../flutter/shell/platform/android/surface_texture_external_texture_vk_impeller.cc
FILE: ../../../flutter/shell/platform/android/surface_texture_external_texture_vk_impeller.h
FILE: ../../../flutter/shell/platform/android/vsync_waiter_android.cc
FILE: ../../../flutter/shell/platform/android/vsync_waiter_android.h
FILE: ../../../flutter/shell/platform/common/accessibility_bridge.cc
Expand Down
4 changes: 4 additions & 0 deletions impeller/toolkit/egl/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,9 @@ void Context::DispatchLifecyleEvent(LifecycleEvent event) const {
}
}

bool Context::IsCurrent() const {
return ::eglGetCurrentContext() == context_;
}

} // namespace egl
} // namespace impeller
6 changes: 6 additions & 0 deletions impeller/toolkit/egl/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ class Context {
///
bool RemoveLifecycleListener(UniqueID id);

//----------------------------------------------------------------------------
/// @return True if the context is current and attached to any surface,
/// False otherwise.
///
bool IsCurrent() const;

private:
friend class Display;

Expand Down
4 changes: 4 additions & 0 deletions impeller/toolkit/egl/display.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,9 @@ std::unique_ptr<Surface> Display::CreatePixelBufferSurface(const Config& config,
return std::unique_ptr<Surface>(new Surface(display_, surface));
}

const EGLDisplay& Display::GetHandle() const {
return display_;
}

} // namespace egl
} // namespace impeller
2 changes: 2 additions & 0 deletions impeller/toolkit/egl/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class Display {
virtual std::unique_ptr<Surface>
CreatePixelBufferSurface(const Config& config, size_t width, size_t height);

const EGLDisplay& GetHandle() const;

private:
EGLDisplay display_ = EGL_NO_DISPLAY;

Expand Down
23 changes: 23 additions & 0 deletions impeller/toolkit/glvk/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("../../tools/impeller.gni")

impeller_component("glvk") {
sources = [
"proc_table.cc",
"proc_table.h",
"trampoline.cc",
"trampoline.h",
]

public_deps = [
"../../renderer",
"../../renderer/backend/gles",
"../../renderer/backend/vulkan",
"../../toolkit/egl",
"../../toolkit/gles",
"//flutter/fml",
]
}
3 changes: 3 additions & 0 deletions impeller/toolkit/glvk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# GLVK Toolkit

A toolkit for inter-operating between OpenGL and Vulkan.
45 changes: 45 additions & 0 deletions impeller/toolkit/glvk/proc_table.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "impeller/toolkit/glvk/proc_table.h"

#include "impeller/base/validation.h"

namespace impeller::glvk {

ProcTable::ProcTable(const Resolver& resolver) {
if (!resolver) {
return;
}

auto error_fn = reinterpret_cast<PFNGLGETERRORPROC>(resolver("glGetError"));
if (!error_fn) {
VALIDATION_LOG << "Could not resolve " << "glGetError";
return;
}

#define GLVK_PROC(proc_ivar) \
if (auto fn_ptr = resolver(proc_ivar.name)) { \
proc_ivar.function = \
reinterpret_cast<decltype(proc_ivar.function)>(fn_ptr); \
proc_ivar.error_fn = error_fn; \
} else { \
VALIDATION_LOG << "Could not resolve " << proc_ivar.name; \
return; \
}

FOR_EACH_GLVK_PROC(GLVK_PROC);

#undef GLVK_PROC

is_valid_ = true;
}

ProcTable::~ProcTable() = default;

bool ProcTable::IsValid() const {
return is_valid_;
}

} // namespace impeller::glvk
102 changes: 102 additions & 0 deletions impeller/toolkit/glvk/proc_table.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef FLUTTER_IMPELLER_TOOLKIT_GLVK_PROC_TABLE_H_
#define FLUTTER_IMPELLER_TOOLKIT_GLVK_PROC_TABLE_H_

#include "impeller/renderer/backend/gles/proc_table_gles.h"
#include "impeller/toolkit/gles/gles.h"

namespace impeller::glvk {

#define FOR_EACH_GLVK_PROC(PROC) \
PROC(ActiveTexture) \
PROC(AttachShader) \
PROC(BindAttribLocation) \
PROC(BindBuffer) \
PROC(BindFramebuffer) \
PROC(BindTexture) \
PROC(BufferData) \
PROC(CheckFramebufferStatus) \
PROC(Clear) \
PROC(ClearColor) \
PROC(ColorMask) \
PROC(CompileShader) \
PROC(CreateProgram) \
PROC(CreateShader) \
PROC(DeleteBuffers) \
PROC(DeleteFramebuffers) \
PROC(DeleteProgram) \
PROC(DeleteShader) \
PROC(DeleteTextures) \
PROC(Disable) \
PROC(DrawArrays) \
PROC(EGLImageTargetTexture2DOES) \
PROC(Enable) \
PROC(EnableVertexAttribArray) \
PROC(Flush) \
PROC(FramebufferTexture2D) \
PROC(GenBuffers) \
PROC(GenFramebuffers) \
PROC(GenTextures) \
PROC(GetProgramiv) \
PROC(GetShaderiv) \
PROC(GetUniformLocation) \
PROC(LinkProgram) \
PROC(ShaderSource) \
PROC(TexParameteri) \
PROC(Uniform1i) \
PROC(UniformMatrix4fv) \
PROC(UseProgram) \
PROC(VertexAttribPointer) \
PROC(Viewport)

//------------------------------------------------------------------------------
/// @brief A proc. table consisting of methods that are useful when
/// interoperating between OpenGL and Vulkan. This is different from
/// the OpenGL proc. table since it may contain more interop
/// extension related methods.
///
class ProcTable {
public:
using Resolver = std::function<void*(const char* function_name)>;

//----------------------------------------------------------------------------
/// @brief Create a proc table using a resolver to resolve OpenGL
/// methods.
///
/// @param[in] resolver The resolver
///
explicit ProcTable(const Resolver& resolver);

~ProcTable();

ProcTable(const ProcTable&) = delete;

ProcTable& operator=(const ProcTable&) = delete;

//----------------------------------------------------------------------------
/// @brief Determines if a proc. table is suitable for interop purposes.
/// The absence of optional extension methods that have fallbacks
/// don't result in an invalid proc. table. But an invalid proc
/// table must always be discarded as there can be no error
/// recovery.
///
/// @return True if valid, False otherwise.
///
bool IsValid() const;

#define GLVK_PROC(name) GLProc<decltype(gl##name)> name = {"gl" #name, nullptr};

FOR_EACH_GLVK_PROC(GLVK_PROC);

#undef GLVK_PROC

private:
bool is_valid_ = false;
};

} // namespace impeller::glvk

#endif // FLUTTER_IMPELLER_TOOLKIT_GLVK_PROC_TABLE_H_
Loading