UNPKG

2.3 kBPlain TextView Raw
1import { Component, ComponentClass } from 'react';
2import { ViewProps } from 'react-native';
3
4import WebGL2RenderingContext from './WebGL2RenderingContext';
5
6export type SurfaceCreateEvent = {
7 nativeEvent: {
8 exglCtxId: number;
9 };
10};
11
12export type SnapshotOptions = {
13 flip?: boolean;
14 framebuffer?: WebGLFramebuffer;
15 rect?: {
16 x: number;
17 y: number;
18 width: number;
19 height: number;
20 };
21 format?: 'jpeg' | 'png';
22 compress?: number;
23};
24
25export type GLSnapshot = {
26 uri: string | Blob | null;
27 localUri: string;
28 width: number;
29 height: number;
30};
31
32export interface ExpoWebGLRenderingContext extends WebGL2RenderingContext {
33 __exglCtxId: number;
34 endFrameEXP(): void;
35 __expoSetLogging(option: GLLoggingOption): void;
36}
37
38export type ComponentOrHandle = null | number | Component<any, any> | ComponentClass<any>;
39
40/**
41 *
42 * A View that acts as an OpenGL ES render target. On mounting, an OpenGL ES
43 * context is created. Its drawing buffer is presented as the contents of
44 * the View every frame.
45 */
46export interface BaseGLViewProps extends ViewProps {
47 /**
48 * Called when the OpenGL context is created, with the context object as a parameter. The context
49 * object has an API mirroring WebGL's WebGLRenderingContext.
50 */
51 onContextCreate(gl: ExpoWebGLRenderingContext): void;
52
53 /**
54 * [iOS only] Number of samples for Apple's built-in multisampling.
55 */
56 msaaSamples?: number;
57}
58
59export enum GLLoggingOption {
60 /**
61 * Disables logging entirely.
62 */
63 DISABLED = 0,
64
65 /**
66 * Logs method calls, their parameters and results.
67 */
68 METHOD_CALLS = 1,
69
70 /**
71 * Calls `gl.getError()` after each other method call and prints an error if any is returned.
72 * This option has a significant impact on the performance as this method is blocking.
73 */
74 GET_ERRORS = 2,
75
76 /**
77 * Resolves parameters of type `number` to their constant names.
78 */
79 RESOLVE_CONSTANTS = 4,
80
81 /**
82 * When this option is enabled, long strings will be truncated.
83 * It's useful if your shaders are really big and logging them significantly reduces performance.
84 */
85 TRUNCATE_STRINGS = 8,
86
87 /**
88 * Enables all other options. It implies `GET_ERRORS` so be aware of the slowdown.
89 */
90 ALL = METHOD_CALLS | GET_ERRORS | RESOLVE_CONSTANTS | TRUNCATE_STRINGS,
91}