MCPcopy Index your code
hub / github.com/gre/gl-react / Surface

Class Surface

packages/gl-react/src/createSurface.tsx:102–528  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100 cancelFrame,
101}: SurfaceOpts): any => {
102 return class Surface extends Component<
103 SurfaceProps,
104 {
105 ready: boolean;
106 rebootId: number;
107 debug: boolean;
108 }
109 > {
110 id: number = ++surfaceId;
111 gl: WebGLRenderingContext | null = null;
112 buffer!: WebGLBuffer;
113 loaderResolver: LoaderResolver | null = null;
114 glView: any;
115 root: Node | null = null;
116 shaders: { [key: string]: Shader } = {};
117 _preparingGL: Array<any> = [];
118 _needsRedraw: boolean = false;
119 state = {
120 ready: false,
121 rebootId: 0,
122 debug: false,
123 };
124
125 RenderLessElement = RenderLessElement;
126 mapRenderableContent = mapRenderableContent;
127
128 static propTypes = SurfacePropTypes;
129
130 componentDidMount() {
131 _instances.push(this);
132 this.getVisitors().forEach((v) => v.onSurfaceMount(this as any));
133 }
134
135 componentWillUnmount() {
136 this._stopLoop();
137 this._destroyGL();
138 const i = _instances.indexOf(this);
139 if (i !== -1) _instances.splice(i, 1);
140 this.getVisitors().forEach((v) => v.onSurfaceUnmount(this as any));
141 }
142
143 componentDidUpdate() {
144 this.redraw();
145 }
146
147 render() {
148 const {
149 props,
150 state: { ready, rebootId, debug },
151 } = this;
152 const { children, style } = props;
153
154 // We allow to pass-in all props we don't know so you can hook to DOM events.
155 const rest: any = {};
156 Object.keys(props).forEach((key) => {
157 if (allSurfaceProps.indexOf(key) === -1) {
158 rest[key] = (props as any)[key];
159 }

Callers

nothing calls this directly

Calls 10

_drawMethod · 0.95
_prepareGLMethod · 0.95
_stopLoopMethod · 0.95
_destroyGLMethod · 0.95
redrawMethod · 0.95
flushMethod · 0.95
_startLoopMethod · 0.95
getGLNameMethod · 0.95
_onContextLostMethod · 0.45
_onContextRestoredMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…