fix Windows build.dart to avoid native_assets fork; add implementations for ThermionFlutterWindows
This commit is contained in:
@@ -152,8 +152,20 @@ LRESULT CALLBACK FilamentWindowProc(HWND const window, UINT const message,
|
||||
break;
|
||||
}
|
||||
case WM_ERASEBKGND: {
|
||||
// Prevent erasing of |window| when it is unfocused and minimized or
|
||||
// moved out of screen etc.
|
||||
HDC hdc = (HDC)wparam;
|
||||
RECT rect;
|
||||
GetClientRect(window, &rect);
|
||||
|
||||
// Get the BackingWindow instance associated with this window
|
||||
BackingWindow* backing_window = reinterpret_cast<BackingWindow*>(
|
||||
GetWindowLongPtr(window, GWLP_USERDATA));
|
||||
|
||||
if (backing_window) {
|
||||
HBRUSH brush = CreateSolidBrush(RGB(0, 255, 0));
|
||||
FillRect(hdc, &rect, brush);
|
||||
DeleteObject(brush);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case WM_SIZE:
|
||||
@@ -346,8 +358,6 @@ void BackingWindow::Resize(int width, int height, int left, int top) {
|
||||
_top = top;
|
||||
RECT flutterViewRect;
|
||||
::GetWindowRect(_flutterViewWindow, &flutterViewRect);
|
||||
std::cout << "Resizing to " << _width << " x " << _height << " with LT" << _left << " " << _top << " flutter view rect" << flutterViewRect.left << " " << flutterViewRect.top << " " << flutterViewRect.right << " " << flutterViewRect.bottom << std::endl;
|
||||
|
||||
::SetWindowPos(_windowHandle, _flutterRootWindow, flutterViewRect.left + _left,
|
||||
flutterViewRect.top + _top, _width, _height,
|
||||
SWP_NOACTIVATE);
|
||||
|
||||
@@ -172,8 +172,6 @@ void ThermionFlutterPlugin::CreateTexture(
|
||||
auto height = (uint32_t)round(dHeight );
|
||||
auto left = (uint32_t)round(dLeft );
|
||||
auto top = (uint32_t)round(dTop );
|
||||
|
||||
std::cout << "Using " << width << "x" << height << std::endl;
|
||||
|
||||
// create a single shared context for the life of the application
|
||||
// this will be used to create a backing texture and passed to Filament
|
||||
@@ -182,8 +180,10 @@ void ThermionFlutterPlugin::CreateTexture(
|
||||
_context = std::make_unique<FlutterEGLContext>(_pluginRegistrar, _textureRegistrar);
|
||||
#else
|
||||
_context = std::make_unique<WGLContext>(_pluginRegistrar, _textureRegistrar);
|
||||
std::cout << "Created WGL context" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
_context->CreateRenderingSurface(width, height, std::move(result), left, top);
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ void ThermionFlutterPlugin::DestroyTexture(
|
||||
void ThermionFlutterPlugin::HandleMethodCall(
|
||||
const flutter::MethodCall<flutter::EncodableValue> &methodCall,
|
||||
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result) {
|
||||
|
||||
std::cout << methodCall.method_name().c_str() << std::endl;
|
||||
if (methodCall.method_name() == "usesBackingWindow") {
|
||||
result->Success(flutter::EncodableValue(
|
||||
#ifdef WGL_USE_BACKING_WINDOW
|
||||
@@ -243,14 +243,16 @@ void ThermionFlutterPlugin::HandleMethodCall(
|
||||
auto height = (uint32_t)round(dHeight );
|
||||
auto left = (uint32_t)round(dLeft );
|
||||
auto top = (uint32_t)round(dTop );
|
||||
|
||||
_context->ResizeRenderingSurface(width, height, left, top);
|
||||
std::cout << "resized window to " << width << "x" << height << " at " << left << "," << top << std::endl;
|
||||
result->Success();
|
||||
#else
|
||||
result->Error("ERROR", "resizeWindow is only available when using a backing window");
|
||||
#endif
|
||||
} else if (methodCall.method_name() == "createTexture") {
|
||||
} else if (methodCall.method_name() == "createWindow") {
|
||||
CreateTexture(methodCall, std::move(result));
|
||||
} else if (methodCall.method_name() == "destroyTexture") {
|
||||
} else if (methodCall.method_name() == "destroyWindow") {
|
||||
DestroyTexture(methodCall, std::move(result));
|
||||
} else if (methodCall.method_name() == "getRenderCallback") {
|
||||
flutter::EncodableList resultList;
|
||||
|
||||
@@ -45,7 +45,7 @@ WGLContext::WGLContext(flutter::PluginRegistrarWindows *pluginRegistrar,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
16, // Number of bits for the depthbuffer
|
||||
24, // Number of bits for the depthbuffer
|
||||
0, // Number of bits for the stencilbuffer
|
||||
0, // Number of Aux buffers in the framebuffer.
|
||||
PFD_MAIN_PLANE,
|
||||
@@ -117,6 +117,8 @@ void WGLContext::CreateRenderingSurface(
|
||||
} else {
|
||||
ResizeRenderingSurface(width, height, left, top);
|
||||
}
|
||||
|
||||
std::cout << "created window size " << width << "x" << height << " at " << left << "," << top << " with backing handle" << _backingWindow->GetHandle() << std::endl;
|
||||
std::vector<flutter::EncodableValue> resultList;
|
||||
resultList.push_back(flutter::EncodableValue()); // return null for Flutter texture ID
|
||||
resultList.push_back(flutter::EncodableValue()); // return null for hardware texture ID
|
||||
|
||||
Reference in New Issue
Block a user