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