RCTConvert+GLData.m 1.26 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 14
  NSNumber *fboId = [self NSNumber:json[@"fboId"]];
  NSArray *contextChildrenJSON = [self NSArray: json[@"contextChildren"]];
15 16
  NSArray *childrenJSON = [self NSArray: json[@"children"]];
  
17
  NSMutableArray *children = [NSMutableArray array];
18 19 20 21 22
  for (NSObject *childJSON in childrenJSON) {
    GLData *child = [self GLData:childJSON];
    [children addObject:child];
  }
  
23 24 25 26 27 28
  NSMutableArray *contextChildren = [NSMutableArray array];
  for (NSObject *childJSON in contextChildrenJSON) {
    GLData *child = [self GLData:childJSON];
    [contextChildren addObject:child];
  }

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

@end