Skip to content

Commit

Permalink
CocoaSpice: save screenshot for GL backend
Browse files Browse the repository at this point in the history
  • Loading branch information
osy committed Oct 26, 2021
1 parent fb655c3 commit 16e3a3e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions CocoaSpice/CSDisplayMetal.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// limitations under the License.
//

@import CoreImage;
#import "TargetConditionals.h"
#import "UTMScreenshot.h"
#import "UTMShaderTypes.h"
Expand Down Expand Up @@ -431,9 +432,11 @@ - (UTMScreenshot *)screenshot {
CGDataProviderRef dataProviderRef = CGDataProviderCreateWithData(NULL, self.canvasData, self.canvasStride * self.canvasArea.size.height, nil);
img = CGImageCreate(self.canvasArea.size.width, self.canvasArea.size.height, 8, 32, self.canvasStride, colorSpaceRef, kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst, dataProviderRef, NULL, NO, kCGRenderingIntentDefault);
CGDataProviderRelease(dataProviderRef);
} else if (_glTexture) {
// TODO: make screenshot from IOSurface
img = NULL;
} else if (self.glTexture) {
CIImage *ciimage = [[CIImage alloc] initWithMTLTexture:self.glTexture options:nil];
CIImage *flipped = [ciimage imageByApplyingOrientation:kCGImagePropertyOrientationDownMirrored];
CIContext *cictx = [CIContext context];
img = [cictx createCGImage:flipped fromRect:flipped.extent];
} else {
img = NULL;
}
Expand Down

0 comments on commit 16e3a3e

Please sign in to comment.