mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This is part of a larger effort to expose the difference between GrDirectContext, which runs on the GPU thread and can directly perform operations like uploading textures, and GrRecordingContext, which can only queue up work to be delivered to the GrDirectContext later.
82 lines
2.6 KiB
C++
82 lines
2.6 KiB
C++
// 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_SHELL_PLATFORM_EMBEDDER_EMBEDDER_SURFACE_GL_H_
|
|
#define FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_SURFACE_GL_H_
|
|
|
|
#include "flutter/fml/macros.h"
|
|
#include "flutter/shell/gpu/gpu_surface_gl.h"
|
|
#include "flutter/shell/platform/embedder/embedder_external_view_embedder.h"
|
|
#include "flutter/shell/platform/embedder/embedder_surface.h"
|
|
|
|
namespace flutter {
|
|
|
|
class EmbedderSurfaceGL final : public EmbedderSurface,
|
|
public GPUSurfaceGLDelegate {
|
|
public:
|
|
struct GLDispatchTable {
|
|
std::function<bool(void)> gl_make_current_callback; // required
|
|
std::function<bool(void)> gl_clear_current_callback; // required
|
|
std::function<bool(void)> gl_present_callback; // required
|
|
std::function<intptr_t(void)> gl_fbo_callback; // required
|
|
std::function<bool(void)> gl_make_resource_current_callback; // optional
|
|
std::function<SkMatrix(void)>
|
|
gl_surface_transformation_callback; // optional
|
|
std::function<void*(const char*)> gl_proc_resolver; // optional
|
|
};
|
|
|
|
EmbedderSurfaceGL(
|
|
GLDispatchTable gl_dispatch_table,
|
|
bool fbo_reset_after_present,
|
|
std::unique_ptr<EmbedderExternalViewEmbedder> external_view_embedder);
|
|
|
|
~EmbedderSurfaceGL() override;
|
|
|
|
private:
|
|
bool valid_ = false;
|
|
GLDispatchTable gl_dispatch_table_;
|
|
bool fbo_reset_after_present_;
|
|
|
|
std::unique_ptr<EmbedderExternalViewEmbedder> external_view_embedder_;
|
|
|
|
// |EmbedderSurface|
|
|
bool IsValid() const override;
|
|
|
|
// |EmbedderSurface|
|
|
std::unique_ptr<Surface> CreateGPUSurface() override;
|
|
|
|
// |EmbedderSurface|
|
|
sk_sp<GrDirectContext> CreateResourceContext() const override;
|
|
|
|
// |GPUSurfaceGLDelegate|
|
|
std::unique_ptr<GLContextResult> GLContextMakeCurrent() override;
|
|
|
|
// |GPUSurfaceGLDelegate|
|
|
bool GLContextClearCurrent() override;
|
|
|
|
// |GPUSurfaceGLDelegate|
|
|
bool GLContextPresent() override;
|
|
|
|
// |GPUSurfaceGLDelegate|
|
|
intptr_t GLContextFBO() const override;
|
|
|
|
// |GPUSurfaceGLDelegate|
|
|
bool GLContextFBOResetAfterPresent() const override;
|
|
|
|
// |GPUSurfaceGLDelegate|
|
|
SkMatrix GLContextSurfaceTransformation() const override;
|
|
|
|
// |GPUSurfaceGLDelegate|
|
|
ExternalViewEmbedder* GetExternalViewEmbedder() override;
|
|
|
|
// |GPUSurfaceGLDelegate|
|
|
GLProcResolver GetGLProcResolver() const override;
|
|
|
|
FML_DISALLOW_COPY_AND_ASSIGN(EmbedderSurfaceGL);
|
|
};
|
|
|
|
} // namespace flutter
|
|
|
|
#endif // FLUTTER_SHELL_PLATFORM_EMBEDDER_EMBEDDER_SURFACE_GL_H_
|