RCTConvert+GLData.m 1.38 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
#import "RCTConvert+GLData.h"

@implementation RCTConvert (GLData)

+ (GLData *)GLData:(id)json
{
  json = [self NSDictionary:json];
  
  NSNumber *shader = [self NSNumber:json[@"shader"]];
  NSDictionary *uniforms = [self NSDictionary:json[@"uniforms"]];
  NSNumber *width = [self NSNumber:json[@"width"]];
  NSNumber *height = [self NSNumber:json[@"height"]];
13
  NSNumber *pixelRatio = [self NSNumber:json[@"pixelRatio"]];
14 15
  NSNumber *fboId = [self NSNumber:json[@"fboId"]];
  NSArray *contextChildrenJSON = [self NSArray: json[@"contextChildren"]];
16 17
  NSArray *childrenJSON = [self NSArray: json[@"children"]];
  
18
  NSMutableArray *children = [NSMutableArray array];
19 20 21 22 23
  for (NSObject *childJSON in childrenJSON) {
    GLData *child = [self GLData:childJSON];
    [children addObject:child];
  }
  
24 25 26 27 28 29
  NSMutableArray *contextChildren = [NSMutableArray array];
  for (NSObject *childJSON in contextChildrenJSON) {
    GLData *child = [self GLData:childJSON];
    [contextChildren addObject:child];
  }

30 31 32 33
  return [[GLData alloc] initWithShader: shader
                           withUniforms: uniforms
                              withWidth: width
                             withHeight: height
34
                         withPixelRatio: pixelRatio
35 36
                              withFboId: fboId
                    withContextChildren: contextChildren
37
                           withChildren: children];
38 39 40
}

@end