Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions src/lime/_internal/backend/html5/HTML5Window.hx
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ class HTML5Window

if (canvas != null)
{
canvas.width = Math.round(parent.__width * scale);
canvas.height = Math.round(parent.__height * scale);
canvas.width = Math.floor(parent.__width * scale);
canvas.height = Math.floor(parent.__height * scale);

canvas.style.width = parent.__width + "px";
canvas.style.height = parent.__height + "px";
Expand Down Expand Up @@ -1015,8 +1015,8 @@ class HTML5Window
if (rect.width > 0 && rect.height > 0)
{
var canvas2:CanvasElement = cast Browser.document.createElement("canvas");
canvas2.width = Std.int(rect.width);
canvas2.height = Std.int(rect.height);
canvas2.width = Math.floor(rect.width);
canvas2.height = Math.floor(rect.height);

var context = canvas2.getContext("2d");
context.drawImage(canvas, -rect.x, -rect.y);
Expand Down Expand Up @@ -1346,6 +1346,24 @@ class HTML5Window
{
if (!parent.__resizable) return;

var attributes = parent.__attributes;
var newScale: Float = scale;
if (Reflect.hasField(attributes, "allowHighDPI") && attributes.allowHighDPI && renderType != DOM)
{
newScale = Browser.window.devicePixelRatio;
}
if (scale != newScale) {
scale = newScale;
parent.__scale = scale;
if (canvas != null)
{
canvas.width = Math.floor(parent.__width * scale);
canvas.height = Math.floor(parent.__height * scale);
canvas.style.width = parent.__width + "px";
canvas.style.height = parent.__height + "px";
}
}

var elementWidth:Float;
var elementHeight:Float;

Expand Down Expand Up @@ -1380,8 +1398,8 @@ class HTML5Window
{
if (parent.element != cast canvas)
{
canvas.width = Math.round(elementWidth * scale);
canvas.height = Math.round(elementHeight * scale);
canvas.width = Math.floor(elementWidth * scale);
canvas.height = Math.floor(elementHeight * scale);

canvas.style.width = elementWidth + "px";
canvas.style.height = elementHeight + "px";
Expand All @@ -1408,13 +1426,13 @@ class HTML5Window

if (scaleX < scaleY)
{
targetHeight = Math.floor(setHeight * scaleX);
marginTop = Math.floor((elementHeight - targetHeight) / 2);
targetHeight = Math.ceil(setHeight * scaleX);
marginTop = Math.ceil((elementHeight - targetHeight) / 2);
}
else
{
targetWidth = Math.floor(setWidth * scaleY);
marginLeft = Math.floor((elementWidth - targetWidth) / 2);
targetWidth = Math.ceil(setWidth * scaleY);
marginLeft = Math.ceil((elementWidth - targetWidth) / 2);
}

if (canvas != null)
Expand Down