Skip to content

Commit 7499dd8

Browse files
authored
Merge pull request #1 from DisDis/clang_fixes
implement make_resource_current
2 parents 189aeab + 2b222b9 commit 7499dd8

File tree

6 files changed

+40
-2
lines changed

6 files changed

+40
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
out/
22
sdk/
3+
.vscode

flutter/flutter_application.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ FlutterApplication::FlutterApplication(
7070
return reinterpret_cast<FlutterApplication *>(userdata)
7171
->render_delegate_.GetProcAddress(name);
7272
};
73+
config.open_gl.make_resource_current =
74+
[](void *userdata) -> bool {
75+
return reinterpret_cast<FlutterApplication *>(userdata)
76+
->render_delegate_.OnApplicationMakeResourceCurrent();
77+
};
7378

7479
auto icu_data_path = GetICUDataPath();
7580

@@ -94,7 +99,7 @@ FlutterApplication::FlutterApplication(
9499
.command_line_argv = command_line_args_c.data(),
95100
};
96101

97-
auto result = FlutterEngineRun(FLUTTER_ENGINE_VERSION, &config, &args,
102+
auto result = FlutterEngineRun(FLUTTER_ENGINE_VERSION, &config, &args,
98103
this /* userdata */, &engine_);
99104

100105
if (result != kSuccess) {

flutter/flutter_application.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class FlutterApplication {
2626
virtual uint32_t OnApplicationGetOnscreenFBO() = 0;
2727

2828
virtual void *GetProcAddress(const char *) = 0;
29+
30+
virtual bool OnApplicationMakeResourceCurrent() = 0;
2931
};
3032

3133
FlutterApplication(std::string bundle_path,

flutter/main.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include "flutter_application.h"
1212
#include "pi_display.h"
1313
#include "utils.h"
14+
#define GLFW_INCLUDE_ES2
15+
#include <glfw3.h>
1416

1517
namespace flutter {
1618

flutter/pi_display.cc

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,11 @@ bool PiDisplay::OnApplicationContextMakeCurrent() {
180180
}
181181
if (::eglMakeCurrent(display_, surface_, surface_, context_) != EGL_TRUE) {
182182
FLWAY_ERROR << "Could not make the context current." << std::endl;
183-
184183
return false;
184+
} else {
185+
FLWAY_LOG << "call OnApplicationContextMakeCurrent" << std::endl;
185186
}
187+
186188
return true;
187189
}
188190

@@ -196,6 +198,8 @@ bool PiDisplay::OnApplicationContextClearCurrent() {
196198
EGL_NO_CONTEXT) != EGL_TRUE) {
197199
FLWAY_ERROR << "Could not clear the current context." << std::endl;
198200
return false;
201+
} else {
202+
FLWAY_LOG << "call OnApplicationContextClearCurrent" << std::endl;
199203
}
200204
return true;
201205
}
@@ -210,11 +214,30 @@ bool PiDisplay::OnApplicationPresent() {
210214
if (::eglSwapBuffers(display_, surface_) != EGL_TRUE) {
211215
FLWAY_ERROR << "Could not swap buffers to present the screen." << std::endl;
212216
return false;
217+
} else {
218+
FLWAY_LOG << "call OnApplicationPresent" << std::endl;
213219
}
214220

215221
return true;
216222
}
217223

224+
// |FlutterApplication::RenderDelegate|
225+
bool PiDisplay::OnApplicationMakeResourceCurrent(){
226+
if (!valid_) {
227+
FLWAY_ERROR << "Cannot make resource current an invalid display." << std::endl;
228+
return false;
229+
}
230+
231+
if (::eglMakeCurrent(display_, surface_, surface_, context_) != EGL_TRUE) {
232+
FLWAY_ERROR << "Could not make resource current." << std::endl;
233+
return false;
234+
} else {
235+
FLWAY_LOG << "call OnApplicationMakeResourceCurrent" << std::endl;
236+
}
237+
238+
return true;
239+
}
240+
218241
// |FlutterApplication::RenderDelegate|
219242
uint32_t PiDisplay::OnApplicationGetOnscreenFBO() {
220243
// Just FBO0.
@@ -228,6 +251,7 @@ void *PiDisplay::GetProcAddress(const char *name) {
228251
}
229252

230253
if (auto address = dlsym(RTLD_DEFAULT, name)) {
254+
FLWAY_LOG << "call GetProcAddress:" << name << std::endl;
231255
return address;
232256
}
233257

flutter/pi_display.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ class PiDisplay : public FlutterApplication::RenderDelegate {
5353
// |FlutterApplication::RenderDelegate|
5454
void *GetProcAddress(const char *) override;
5555

56+
// |FlutterApplication::RenderDelegate|
57+
bool OnApplicationMakeResourceCurrent() override;
58+
59+
5660
FLWAY_DISALLOW_COPY_AND_ASSIGN(PiDisplay);
5761
};
5862

0 commit comments

Comments
 (0)