use pixelRatio properly
This commit is contained in:
@@ -11,7 +11,9 @@ enum ToneMapper { ACES, FILMIC, LINEAR }
|
||||
|
||||
class TextureDetails {
|
||||
final int textureId;
|
||||
final int width;
|
||||
|
||||
// both width and height are in physical, not logical pixels
|
||||
final int width;
|
||||
final int height;
|
||||
|
||||
TextureDetails(
|
||||
|
||||
@@ -148,8 +148,7 @@ class FilamentControllerFFI extends FilamentController {
|
||||
///
|
||||
@override
|
||||
Future createViewer(Rect rect) async {
|
||||
double width = rect.width;
|
||||
double height = rect.height;
|
||||
|
||||
if (_viewer != null) {
|
||||
throw Exception(
|
||||
"Viewer already exists, make sure you call destroyViewer first");
|
||||
@@ -165,9 +164,7 @@ class FilamentControllerFFI extends FilamentController {
|
||||
throw Exception("Failed to get resource loader");
|
||||
}
|
||||
|
||||
var size = ui.Size(width * _pixelRatio, height * _pixelRatio);
|
||||
|
||||
print("Creating viewer with size $size");
|
||||
rect = rect.inflate(_pixelRatio);
|
||||
|
||||
if (Platform.isWindows && requiresTextureWidget) {
|
||||
_driver = Pointer<Void>.fromAddress(
|
||||
@@ -220,7 +217,7 @@ class FilamentControllerFFI extends FilamentController {
|
||||
Future<RenderingSurface> _createRenderingSurface(Rect rect) async {
|
||||
return RenderingSurface.from(await _channel.invokeMethod(
|
||||
"createTexture",
|
||||
[rect.width, rect.height, _pixelRatio, rect.left, rect.top]));
|
||||
[rect.width, rect.height, rect.left, rect.top]));
|
||||
}
|
||||
|
||||
///
|
||||
@@ -299,6 +296,8 @@ class FilamentControllerFFI extends FilamentController {
|
||||
throw Exception("Resize currently underway, ignoring");
|
||||
}
|
||||
|
||||
rect = rect.inflate(_pixelRatio);
|
||||
|
||||
_resizing = true;
|
||||
|
||||
_lib.set_rendering_ffi(_viewer!, false);
|
||||
@@ -315,7 +314,7 @@ class FilamentControllerFFI extends FilamentController {
|
||||
} else if(Platform.isWindows) {
|
||||
print("Resizing window with rect $rect");
|
||||
await _channel.invokeMethod(
|
||||
"resizeWindow", [rect.width, rect.height, _pixelRatio, rect.left, rect.top]);
|
||||
"resizeWindow", [rect.width, rect.height, rect.left, rect.top]);
|
||||
}
|
||||
|
||||
var renderingSurface = await _createRenderingSurface(rect);
|
||||
@@ -330,7 +329,7 @@ class FilamentControllerFFI extends FilamentController {
|
||||
_lib.create_swap_chain_ffi(_viewer!, renderingSurface.surface,
|
||||
rect.width.toInt(), rect.height.toInt());
|
||||
}
|
||||
|
||||
|
||||
if (renderingSurface.textureHandle != 0) {
|
||||
print(
|
||||
"Creating render target from native texture ${renderingSurface.textureHandle}");
|
||||
|
||||
@@ -169,15 +169,14 @@ void PolyvoxFilamentPlugin::CreateTexture(
|
||||
|
||||
double dWidth = *(std::get_if<double>(&(args->at(0))));
|
||||
double dHeight = *(std::get_if<double>(&(args->at(1))));
|
||||
double pixelRatio = *(std::get_if<double>(&(args->at(2))));
|
||||
double dLeft = *(std::get_if<double>(&(args->at(3))));
|
||||
double dTop = *(std::get_if<double>(&(args->at(4))));
|
||||
auto width = (uint32_t)round(dWidth * pixelRatio);
|
||||
auto height = (uint32_t)round(dHeight * pixelRatio);
|
||||
auto left = (uint32_t)round(dLeft * pixelRatio);
|
||||
auto top = (uint32_t)round(dTop * pixelRatio);
|
||||
double dLeft = *(std::get_if<double>(&(args->at(2))));
|
||||
double dTop = *(std::get_if<double>(&(args->at(3))));
|
||||
auto width = (uint32_t)round(dWidth );
|
||||
auto height = (uint32_t)round(dHeight );
|
||||
auto left = (uint32_t)round(dLeft );
|
||||
auto top = (uint32_t)round(dTop );
|
||||
|
||||
std::cout << "Using " << width << "x" << height << " (pixel ratio " << pixelRatio << ")" << std::endl;
|
||||
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
|
||||
@@ -234,13 +233,12 @@ void PolyvoxFilamentPlugin::HandleMethodCall(
|
||||
std::get_if<flutter::EncodableList>(methodCall.arguments());
|
||||
double dWidth = *(std::get_if<double>(&(args->at(0))));
|
||||
double dHeight = *(std::get_if<double>(&(args->at(1))));
|
||||
double pixelRatio = *(std::get_if<double>(&(args->at(2))));
|
||||
double dLeft = *(std::get_if<double>(&(args->at(3))));
|
||||
double dTop = *(std::get_if<double>(&(args->at(4))));
|
||||
auto width = (uint32_t)round(dWidth * pixelRatio);
|
||||
auto height = (uint32_t)round(dHeight * pixelRatio);
|
||||
auto left = (uint32_t)round(dLeft * pixelRatio);
|
||||
auto top = (uint32_t)round(dTop * pixelRatio);
|
||||
double dLeft = *(std::get_if<double>(&(args->at(2))));
|
||||
double dTop = *(std::get_if<double>(&(args->at(3))));
|
||||
auto width = (uint32_t)round(dWidth );
|
||||
auto height = (uint32_t)round(dHeight );
|
||||
auto left = (uint32_t)round(dLeft );
|
||||
auto top = (uint32_t)round(dTop );
|
||||
_context->ResizeRenderingSurface(width, height, left, top);
|
||||
result->Success();
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user