Web: Remove the device pixel ratio workaround for Android tablets.
Afetr the `GetDevicePixelRatio` function was fixed to return `double` `useWorkaround_devicePixelRatio` is not needed any more so remove it. See the discussion in #1310 pull request for details.
This commit is contained in:
parent
c53c592dbe
commit
6fc84ae2ce
@ -579,9 +579,6 @@ public:
|
|||||||
std::function<void()> editingDoneFunc;
|
std::function<void()> editingDoneFunc;
|
||||||
std::shared_ptr<MenuBarImplHtml> menuBar;
|
std::shared_ptr<MenuBarImplHtml> menuBar;
|
||||||
|
|
||||||
bool useWorkaround_devicePixelRatio = false;
|
|
||||||
|
|
||||||
|
|
||||||
WindowImplHtml(val htmlContainer, std::string emCanvasSel) :
|
WindowImplHtml(val htmlContainer, std::string emCanvasSel) :
|
||||||
emCanvasSel(emCanvasSel),
|
emCanvasSel(emCanvasSel),
|
||||||
htmlContainer(htmlContainer),
|
htmlContainer(htmlContainer),
|
||||||
@ -618,12 +615,6 @@ public:
|
|||||||
this->scrollbarHelper.set("onScrollCallback", Wrap(&onScrollCallback));
|
this->scrollbarHelper.set("onScrollCallback", Wrap(&onScrollCallback));
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME(emscripten): In Chrome for Android on tablet device, devicePixelRatio should not be multiplied.
|
|
||||||
std::string userAgent = val::global("navigator")["userAgent"].as<std::string>();
|
|
||||||
bool is_smartphone = userAgent.find("Mobile") != std::string::npos;
|
|
||||||
bool is_android_device = userAgent.find("Android") != std::string::npos;
|
|
||||||
this->useWorkaround_devicePixelRatio = is_android_device && !is_smartphone;
|
|
||||||
|
|
||||||
sscheck(emscripten_set_resize_callback(
|
sscheck(emscripten_set_resize_callback(
|
||||||
EMSCRIPTEN_EVENT_TARGET_WINDOW, this, /*useCapture=*/false,
|
EMSCRIPTEN_EVENT_TARGET_WINDOW, this, /*useCapture=*/false,
|
||||||
WindowImplHtml::ResizeCallback));
|
WindowImplHtml::ResizeCallback));
|
||||||
@ -933,14 +924,9 @@ public:
|
|||||||
sscheck(emscripten_get_element_css_size(htmlContainerSel.c_str(), &width, &height));
|
sscheck(emscripten_get_element_css_size(htmlContainerSel.c_str(), &width, &height));
|
||||||
// sscheck(emscripten_get_element_css_size(emCanvasSel.c_str(), &width, &height));
|
// sscheck(emscripten_get_element_css_size(emCanvasSel.c_str(), &width, &height));
|
||||||
|
|
||||||
if (this->useWorkaround_devicePixelRatio) {
|
double devicePixelRatio = GetDevicePixelRatio();
|
||||||
// Workaround is to skip applying devicePixelRatio.
|
width *= devicePixelRatio;
|
||||||
// So NOP here.
|
height *= devicePixelRatio;
|
||||||
} else {
|
|
||||||
double devicePixelRatio = emscripten_get_device_pixel_ratio();
|
|
||||||
width *= devicePixelRatio;
|
|
||||||
height *= devicePixelRatio;
|
|
||||||
}
|
|
||||||
|
|
||||||
int currentWidth = 0, currentHeight = 0;
|
int currentWidth = 0, currentHeight = 0;
|
||||||
sscheck(emscripten_get_canvas_element_size(emCanvasSel.c_str(), ¤tWidth, ¤tHeight));
|
sscheck(emscripten_get_canvas_element_size(emCanvasSel.c_str(), ¤tWidth, ¤tHeight));
|
||||||
@ -967,7 +953,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
double GetPixelDensity() override {
|
double GetPixelDensity() override {
|
||||||
return 96.0 * emscripten_get_device_pixel_ratio();
|
return 96.0 * GetDevicePixelRatio();
|
||||||
}
|
}
|
||||||
|
|
||||||
double GetDevicePixelRatio() override {
|
double GetDevicePixelRatio() override {
|
||||||
|
Loading…
Reference in New Issue
Block a user