Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix display corruption when using the Metal backend #410

Merged
merged 1 commit into from Jun 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 12 additions & 4 deletions platforms/iOS/vm/OSX/sqSqueakOSXMetalView.m
Expand Up @@ -338,7 +338,8 @@ -(void)drawRect:(NSRect)rect
currentRenderEncoder = [currentCommandBuffer renderCommandEncoderWithDescriptor: renderPassDescriptor];

// Set the viewport.
[currentRenderEncoder setViewport: (MTLViewport){0.0, 0.0, lastFrameSize.width, lastFrameSize.height}];
CGSize drawableSize = self.drawableSize;
[currentRenderEncoder setViewport: (MTLViewport){0.0, 0.0, drawableSize.width, drawableSize.height}];

// Draw the screen rectangle.
[self drawScreenRect: rect];
Expand All @@ -360,9 +361,16 @@ -(void)drawRect:(NSRect)rect
}
}

- (CGSize) screenSizeForTexture {
CGRect screenRect = [self bounds];
CGSize screenSize;
screenSize.width = (sqInt)screenRect.size.width;
screenSize.height = (sqInt)screenRect.size.height;
return screenSize;
}

- (void)loadTexturesFrom: (void*) displayStorage subRectangle: (NSRect) subRect {

CGSize drawableSize = self.drawableSize;
CGSize drawableSize = [self screenSizeForTexture];
if (!CGSizeEqualToSize(lastFrameSize,drawableSize) || !displayTexture ||
currentDisplayStorage != displayStorage) {
//NSLog(@"old %f %f %f %f new %f %f %f %f",lastFrameSize.origin.x,lastFrameSize.origin.y,lastFrameSize.size.width,lastFrameSize.size.height,self.frame.origin.x,r.origin.y,r.size.width,r.size.height);
Expand All @@ -380,7 +388,7 @@ - (void)loadTexturesFrom: (void*) displayStorage subRectangle: (NSRect) subRect
}

-(void) updateDisplayTextureStorage {
CGSize drawableSize = self.drawableSize;
CGSize drawableSize = [self screenSizeForTexture];
displayTextureWidth = drawableSize.width;
displayTextureHeight = drawableSize.height;
displayTexturePitch = displayTextureWidth*4;
Expand Down