mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Move the args for GLContextPresent into a struct (flutter/engine#33758)
This refactor enables easier additions to the method for fields that can be optionally consumed by various platforms.
This commit is contained in:
parent
a4a4b3e733
commit
af6bbe756d
@ -64,8 +64,7 @@ bool ShellTestPlatformViewGL::GLContextClearCurrent() {
|
||||
|
||||
// |GPUSurfaceGLDelegate|
|
||||
bool ShellTestPlatformViewGL::GLContextPresent(
|
||||
uint32_t fbo_id,
|
||||
const std::optional<SkIRect>& damage) {
|
||||
const GLPresentInfo& present_info) {
|
||||
return gl_surface_.Present();
|
||||
}
|
||||
|
||||
|
||||
@ -58,8 +58,7 @@ class ShellTestPlatformViewGL : public ShellTestPlatformView,
|
||||
bool GLContextClearCurrent() override;
|
||||
|
||||
// |GPUSurfaceGLDelegate|
|
||||
bool GLContextPresent(uint32_t fbo_id,
|
||||
const std::optional<SkIRect>& damage) override;
|
||||
bool GLContextPresent(const GLPresentInfo& present_info) override;
|
||||
|
||||
// |GPUSurfaceGLDelegate|
|
||||
intptr_t GLContextFBO(GLFrameInfo frame_info) const override;
|
||||
|
||||
@ -22,6 +22,15 @@ struct GLFrameInfo {
|
||||
uint32_t height;
|
||||
};
|
||||
|
||||
// Information passed during presentation of a frame.
|
||||
struct GLPresentInfo {
|
||||
uint32_t fbo_id;
|
||||
|
||||
// Damage is a hint to compositor telling it which parts of front buffer
|
||||
// need to be updated
|
||||
const std::optional<SkIRect>& damage;
|
||||
};
|
||||
|
||||
class GPUSurfaceGLDelegate {
|
||||
public:
|
||||
~GPUSurfaceGLDelegate();
|
||||
@ -39,11 +48,7 @@ class GPUSurfaceGLDelegate {
|
||||
|
||||
// Called to present the main GL surface. This is only called for the main GL
|
||||
// context and not any of the contexts dedicated for IO.
|
||||
//
|
||||
// Damage is a hint to compositor telling it which parts of front buffer
|
||||
// need to be updated
|
||||
virtual bool GLContextPresent(uint32_t fbo_id,
|
||||
const std::optional<SkIRect>& damage) = 0;
|
||||
virtual bool GLContextPresent(const GLPresentInfo& present_info) = 0;
|
||||
|
||||
// The ID of the main window bound framebuffer. Typically FBO0.
|
||||
virtual intptr_t GLContextFBO(GLFrameInfo frame_info) const = 0;
|
||||
|
||||
@ -60,7 +60,11 @@ std::unique_ptr<SurfaceFrame> GPUSurfaceGLImpeller::AcquireFrame(
|
||||
auto swap_callback = [weak = weak_factory_.GetWeakPtr(),
|
||||
delegate = delegate_]() -> bool {
|
||||
if (weak) {
|
||||
delegate->GLContextPresent(0u, std::nullopt);
|
||||
GLPresentInfo present_info = {
|
||||
.fbo_id = 0,
|
||||
.damage = std::nullopt,
|
||||
};
|
||||
delegate->GLContextPresent(present_info);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
#include "flutter/fml/size.h"
|
||||
#include "flutter/fml/trace_event.h"
|
||||
#include "flutter/shell/common/context_options.h"
|
||||
#include "flutter/shell/gpu/gpu_surface_gl_delegate.h"
|
||||
#include "third_party/skia/include/core/SkAlphaType.h"
|
||||
#include "third_party/skia/include/core/SkColorFilter.h"
|
||||
#include "third_party/skia/include/core/SkColorSpace.h"
|
||||
@ -265,7 +266,8 @@ bool GPUSurfaceGLSkia::PresentSurface(const SurfaceFrame& frame,
|
||||
onscreen_surface_->getCanvas()->flush();
|
||||
}
|
||||
|
||||
if (!delegate_->GLContextPresent(fbo_id_, frame.submit_info().frame_damage)) {
|
||||
GLPresentInfo present_info = {fbo_id_, frame.submit_info().frame_damage};
|
||||
if (!delegate_->GLContextPresent(present_info)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -285,8 +285,7 @@ void AndroidSurfaceGLImpeller::GLContextSetDamageRegion(
|
||||
|
||||
// |GPUSurfaceGLDelegate|
|
||||
bool AndroidSurfaceGLImpeller::GLContextPresent(
|
||||
uint32_t fbo_id,
|
||||
const std::optional<SkIRect>& damage) {
|
||||
const GLPresentInfo& present_info) {
|
||||
// The FBO ID is superfluous and was introduced for iOS where the default
|
||||
// framebuffer was not FBO0.
|
||||
if (!onscreen_surface_) {
|
||||
|
||||
@ -65,8 +65,7 @@ class AndroidSurfaceGLImpeller final : public GPUSurfaceGLDelegate,
|
||||
void GLContextSetDamageRegion(const std::optional<SkIRect>& region) override;
|
||||
|
||||
// |GPUSurfaceGLDelegate|
|
||||
bool GLContextPresent(uint32_t fbo_id,
|
||||
const std::optional<SkIRect>& damage) override;
|
||||
bool GLContextPresent(const GLPresentInfo& present_info) override;
|
||||
|
||||
// |GPUSurfaceGLDelegate|
|
||||
intptr_t GLContextFBO(GLFrameInfo frame_info) const override;
|
||||
|
||||
@ -153,12 +153,10 @@ void AndroidSurfaceGLSkia::GLContextSetDamageRegion(
|
||||
onscreen_surface_->SetDamageRegion(region);
|
||||
}
|
||||
|
||||
bool AndroidSurfaceGLSkia::GLContextPresent(
|
||||
uint32_t fbo_id,
|
||||
const std::optional<SkIRect>& damage) {
|
||||
bool AndroidSurfaceGLSkia::GLContextPresent(const GLPresentInfo& present_info) {
|
||||
FML_DCHECK(IsValid());
|
||||
FML_DCHECK(onscreen_surface_);
|
||||
return onscreen_surface_->SwapBuffers(damage);
|
||||
return onscreen_surface_->SwapBuffers(present_info.damage);
|
||||
}
|
||||
|
||||
intptr_t AndroidSurfaceGLSkia::GLContextFBO(GLFrameInfo frame_info) const {
|
||||
|
||||
@ -64,8 +64,7 @@ class AndroidSurfaceGLSkia final : public GPUSurfaceGLDelegate,
|
||||
void GLContextSetDamageRegion(const std::optional<SkIRect>& region) override;
|
||||
|
||||
// |GPUSurfaceGLDelegate|
|
||||
bool GLContextPresent(uint32_t fbo_id,
|
||||
const std::optional<SkIRect>& damage) override;
|
||||
bool GLContextPresent(const GLPresentInfo& present_info) override;
|
||||
|
||||
// |GPUSurfaceGLDelegate|
|
||||
intptr_t GLContextFBO(GLFrameInfo frame_info) const override;
|
||||
|
||||
@ -18,9 +18,7 @@ bool AndroidSurfaceMock::GLContextClearCurrent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AndroidSurfaceMock::GLContextPresent(
|
||||
uint32_t fbo_id,
|
||||
const std::optional<SkIRect>& damage) {
|
||||
bool AndroidSurfaceMock::GLContextPresent(const GLPresentInfo& present_info) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -48,8 +48,7 @@ class AndroidSurfaceMock final : public GPUSurfaceGLDelegate,
|
||||
bool GLContextClearCurrent() override;
|
||||
|
||||
// |GPUSurfaceGLDelegate|
|
||||
bool GLContextPresent(uint32_t fbo_id,
|
||||
const std::optional<SkIRect>& damage) override;
|
||||
bool GLContextPresent(const GLPresentInfo& present_info) override;
|
||||
|
||||
// |GPUSurfaceGLDelegate|
|
||||
intptr_t GLContextFBO(GLFrameInfo frame_info) const override;
|
||||
|
||||
@ -38,7 +38,7 @@ class IOSSurfaceGL final : public IOSSurface, public GPUSurfaceGLDelegate {
|
||||
bool GLContextClearCurrent() override;
|
||||
|
||||
// |GPUSurfaceGLDelegate|
|
||||
bool GLContextPresent(uint32_t fbo_id, const std::optional<SkIRect>& damage) override;
|
||||
bool GLContextPresent(const GLPresentInfo& present_info) override;
|
||||
|
||||
// |GPUSurfaceGLDelegate|
|
||||
intptr_t GLContextFBO(GLFrameInfo frame_info) const override;
|
||||
|
||||
@ -86,7 +86,7 @@ bool IOSSurfaceGL::GLContextClearCurrent() {
|
||||
}
|
||||
|
||||
// |GPUSurfaceGLDelegate|
|
||||
bool IOSSurfaceGL::GLContextPresent(uint32_t fbo_id, const std::optional<SkIRect>& damage) {
|
||||
bool IOSSurfaceGL::GLContextPresent(const GLPresentInfo& present_info) {
|
||||
TRACE_EVENT0("flutter", "IOSSurfaceGL::GLContextPresent");
|
||||
return IsValid() && render_target_->PresentRenderBuffer();
|
||||
}
|
||||
|
||||
@ -45,9 +45,8 @@ bool EmbedderSurfaceGL::GLContextClearCurrent() {
|
||||
}
|
||||
|
||||
// |GPUSurfaceGLDelegate|
|
||||
bool EmbedderSurfaceGL::GLContextPresent(uint32_t fbo_id,
|
||||
const std::optional<SkIRect>& damage) {
|
||||
return gl_dispatch_table_.gl_present_callback(fbo_id);
|
||||
bool EmbedderSurfaceGL::GLContextPresent(const GLPresentInfo& present_info) {
|
||||
return gl_dispatch_table_.gl_present_callback(present_info.fbo_id);
|
||||
}
|
||||
|
||||
// |GPUSurfaceGLDelegate|
|
||||
|
||||
@ -56,8 +56,7 @@ class EmbedderSurfaceGL final : public EmbedderSurface,
|
||||
bool GLContextClearCurrent() override;
|
||||
|
||||
// |GPUSurfaceGLDelegate|
|
||||
bool GLContextPresent(uint32_t fbo_id,
|
||||
const std::optional<SkIRect>& damage) override;
|
||||
bool GLContextPresent(const GLPresentInfo& present_info) override;
|
||||
|
||||
// |GPUSurfaceGLDelegate|
|
||||
intptr_t GLContextFBO(GLFrameInfo frame_info) const override;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user