Skip to content
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 .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
out/
sdk/
.vscode
7 changes: 6 additions & 1 deletion flutter/flutter_application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ FlutterApplication::FlutterApplication(
return reinterpret_cast<FlutterApplication *>(userdata)
->render_delegate_.GetProcAddress(name);
};
config.open_gl.make_resource_current =
[](void *userdata) -> bool {
return reinterpret_cast<FlutterApplication *>(userdata)
->render_delegate_.OnApplicationMakeResourceCurrent();
};

auto icu_data_path = GetICUDataPath();

Expand All @@ -94,7 +99,7 @@ FlutterApplication::FlutterApplication(
.command_line_argv = command_line_args_c.data(),
};

auto result = FlutterEngineRun(FLUTTER_ENGINE_VERSION, &config, &args,
auto result = FlutterEngineRun(FLUTTER_ENGINE_VERSION, &config, &args,
this /* userdata */, &engine_);

if (result != kSuccess) {
Expand Down
2 changes: 2 additions & 0 deletions flutter/flutter_application.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class FlutterApplication {
virtual uint32_t OnApplicationGetOnscreenFBO() = 0;

virtual void *GetProcAddress(const char *) = 0;

virtual bool OnApplicationMakeResourceCurrent() = 0;
};

FlutterApplication(std::string bundle_path,
Expand Down
2 changes: 2 additions & 0 deletions flutter/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "flutter_application.h"
#include "pi_display.h"
#include "utils.h"
#define GLFW_INCLUDE_ES2
#include <glfw3.h>

namespace flutter {

Expand Down
26 changes: 25 additions & 1 deletion flutter/pi_display.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,11 @@ bool PiDisplay::OnApplicationContextMakeCurrent() {
}
if (::eglMakeCurrent(display_, surface_, surface_, context_) != EGL_TRUE) {
FLWAY_ERROR << "Could not make the context current." << std::endl;

return false;
} else {
FLWAY_LOG << "call OnApplicationContextMakeCurrent" << std::endl;
}

return true;
}

Expand All @@ -196,6 +198,8 @@ bool PiDisplay::OnApplicationContextClearCurrent() {
EGL_NO_CONTEXT) != EGL_TRUE) {
FLWAY_ERROR << "Could not clear the current context." << std::endl;
return false;
} else {
FLWAY_LOG << "call OnApplicationContextClearCurrent" << std::endl;
}
return true;
}
Expand All @@ -210,11 +214,30 @@ bool PiDisplay::OnApplicationPresent() {
if (::eglSwapBuffers(display_, surface_) != EGL_TRUE) {
FLWAY_ERROR << "Could not swap buffers to present the screen." << std::endl;
return false;
} else {
FLWAY_LOG << "call OnApplicationPresent" << std::endl;
}

return true;
}

// |FlutterApplication::RenderDelegate|
bool PiDisplay::OnApplicationMakeResourceCurrent(){
if (!valid_) {
FLWAY_ERROR << "Cannot make resource current an invalid display." << std::endl;
return false;
}

if (::eglMakeCurrent(display_, surface_, surface_, context_) != EGL_TRUE) {
FLWAY_ERROR << "Could not make resource current." << std::endl;
return false;
} else {
FLWAY_LOG << "call OnApplicationMakeResourceCurrent" << std::endl;
}

return true;
}

// |FlutterApplication::RenderDelegate|
uint32_t PiDisplay::OnApplicationGetOnscreenFBO() {
// Just FBO0.
Expand All @@ -228,6 +251,7 @@ void *PiDisplay::GetProcAddress(const char *name) {
}

if (auto address = dlsym(RTLD_DEFAULT, name)) {
FLWAY_LOG << "call GetProcAddress:" << name << std::endl;
return address;
}

Expand Down
4 changes: 4 additions & 0 deletions flutter/pi_display.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ class PiDisplay : public FlutterApplication::RenderDelegate {
// |FlutterApplication::RenderDelegate|
void *GetProcAddress(const char *) override;

// |FlutterApplication::RenderDelegate|
bool OnApplicationMakeResourceCurrent() override;


FLWAY_DISALLOW_COPY_AND_ASSIGN(PiDisplay);
};

Expand Down