From 159cdcae43f3126e1dc1c3c2ae9e62c302a91c46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Thu, 3 Sep 2015 18:43:08 +0200 Subject: [PATCH] Fix GL.Target rasterization for Retina screens. Fix #4 --- RNGL/GLTexture.m | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/RNGL/GLTexture.m b/RNGL/GLTexture.m index 9de818c..8393520 100644 --- a/RNGL/GLTexture.m +++ b/RNGL/GLTexture.m @@ -1,5 +1,6 @@ #import "GLTexture.h" #import "RCTLog.h" +#import "RCTUtils.h" GLImageData* genPixelsEmpty (int width, int height) { @@ -53,13 +54,14 @@ GLImageData* genPixelsWithImage (UIImage *image) GLImageData* genPixelsWithView (UIView *view) { - int width = view.bounds.size.width; - int height = view.bounds.size.height; + float width = RCTScreenScale() * view.bounds.size.width; + float height = RCTScreenScale() * view.bounds.size.height; GLubyte *data = (GLubyte *)malloc(4 * width * height); CGColorSpaceRef colourSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef ctx = CGBitmapContextCreate(data, width, height, 8, 4 * width, colourSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); CGColorSpaceRelease(colourSpace); - CGContextClearRect(ctx, view.bounds); + CGContextClearRect(ctx, CGRectMake(0.0, 0.0, width, height)); + CGContextScaleCTM(ctx, RCTScreenScale(), RCTScreenScale()); [view.layer renderInContext:ctx]; CGContextRelease(ctx); return [[GLImageData alloc] initWithData:data withWidth:width withHeight:height]; -- 2.26.2