• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import { paramMock } from "../utils"
17
18export function mockwebgl2() {
19  const WebGLQuery = {
20  }
21  const WebGLSampler = {
22  }
23  const WebGLSync = {
24  }
25  const WebGLTransformFeedback = {
26  }
27  const WebGLVertexArrayObject = {
28  }
29  const WebGLActiveInfo = {
30    size: '[PC preview] unknow size',
31    type: '[PC preview] unknow type',
32    name: '[PC preview] unknow name'
33  }
34  const glParamMock = {
35    paramDoubleMock: '[PC Preview] unknow double',
36    paramAnyMock: '[PC Preview] unknow any',
37    stringArray: '[PC preview] unknow stringArray',
38    uint32Array: '[PC preview] unknow uint32Array',
39    glBooleanArray: '[PC preview] unknow glBooleanArray',
40    int32Array: '[PC preview] unknow int32Array',
41    uintArray: '[PC preview] unknow uintArray'
42  }
43  const GL_SAMPLES = 0x80A9;
44  const GL_QUERY_RESULT = 0x8866;
45  const GL_QUERY_RESULT_AVAILABLE = 0x8867;
46  const GL_TEXTURE_MAX_LOD = 0x813B;
47  const GL_TEXTURE_MIN_LOD = 0x813A;
48  const webgl2Mock = {
49    copyBufferSubData: function (...args) {
50      console.warn("webgl.copyBufferSubData interface mocked in the Previewer. How this interface works on the" +
51        " Previewer may be different from that on a real device.")
52    },
53    getBufferSubData: function (...args) {
54      console.warn("webgl.getBufferSubData interface mocked in the Previewer. How this interface works on the" +
55        " Previewer may be different from that on a real device.")
56    },
57    blitFramebuffer: function (...args) {
58      console.warn("webgl.blitFramebuffer interface mocked in the Previewer. How this interface works on the" +
59        " Previewer may be different from that on a real device.")
60    },
61    framebufferTextureLayer: function (...args) {
62      console.warn("webgl.framebufferTextureLayer interface mocked in the Previewer. How this interface works on the" +
63        " Previewer may be different from that on a real device.")
64    },
65    invalidateFramebuffer: function (...args) {
66      console.warn("webgl.invalidateFramebuffer interface mocked in the Previewer. How this interface works on the" +
67        " Previewer may be different from that on a real device.")
68    },
69    invalidateSubFramebuffer: function (...args) {
70      console.warn("webgl.invalidateFramebuffer interface mocked in the Previewer. How this interface works on the" +
71        " Previewer may be different from that on a real device.")
72    },
73    readBuffer: function (...args) {
74      console.warn("webgl.readBuffer interface mocked in the Previewer. How this interface works on the" +
75        " Previewer may be different from that on a real device.")
76    },
77    getInternalformatParameter: function (...args) {
78      console.warn("webgl.getInternalformatParameter interface mocked in the Previewer. How this interface works on the" +
79        " Previewer may be different from that on a real device.")
80      if (args[2] == GL_SAMPLES) {
81        return glParamMock.int32Array
82      }
83    },
84    renderbufferStorageMultisample: function (...args) {
85      console.warn("webgl.renderbufferStorageMultisample interface mocked in the Previewer. How this interface works on the" +
86        " Previewer may be different from that on a real device.")
87    },
88    texStorage2D: function (...args) {
89      console.warn("webgl.texStorage2D interface mocked in the Previewer. How this interface works on the" +
90        " Previewer may be different from that on a real device.")
91    },
92    texStorage3D: function (...args) {
93      console.warn("webgl.texStorage3D interface mocked in the Previewer. How this interface works on the" +
94        " Previewer may be different from that on a real device.")
95    },
96    texImage3D: function (...args) {
97      console.warn("webgl.texImage3D interface mocked in the Previewer. How this interface works on the" +
98        " Previewer may be different from that on a real device.")
99    },
100    texSubImage3D: function (...args) {
101      console.warn("webgl.texSubImage3D interface mocked in the Previewer. How this interface works on the" +
102        " Previewer may be different from that on a real device.")
103    },
104    copyTexSubImage3D: function (...args) {
105      console.warn("webgl.copyTexSubImage3D interface mocked in the Previewer. How this interface works on the" +
106        " Previewer may be different from that on a real device.")
107    },
108    compressedTexImage3D: function (...args) {
109      console.warn("webgl.compressedTexImage3D interface mocked in the Previewer. How this interface works on the" +
110        " Previewer may be different from that on a real device.")
111    },
112    compressedTexSubImage3D: function (...args) {
113      console.warn("webgl.compressedTexSubImage3D interface mocked in the Previewer. How this interface works on the" +
114        " Previewer may be different from that on a real device.")
115    },
116    getFragDataLocation: function (...args) {
117      console.warn("webgl.getFragDataLocation interface mocked in the Previewer. How this interface works on the" +
118        " Previewer may be different from that on a real device.")
119      return paramMock.paramNumberMock;
120    },
121    uniform1ui: function (...args) {
122      console.warn("webgl.uniform1ui interface mocked in the Previewer. How this interface works on the" +
123        " Previewer may be different from that on a real device.")
124    },
125    uniform2ui: function (...args) {
126      console.warn("webgl.uniform2ui interface mocked in the Previewer. How this interface works on the" +
127        " Previewer may be different from that on a real device.")
128    },
129    uniform3ui: function (...args) {
130      console.warn("webgl.uniform3ui interface mocked in the Previewer. How this interface works on the" +
131        " Previewer may be different from that on a real device.")
132    },
133    uniform4ui: function (...args) {
134      console.warn("webgl.uniform4ui interface mocked in the Previewer. How this interface works on the" +
135        " Previewer may be different from that on a real device.")
136    },
137    uniform1uiv: function (...args) {
138      console.warn("webgl.uniform1uiv interface mocked in the Previewer. How this interface works on the" +
139        " Previewer may be different from that on a real device.")
140    },
141    uniform2uiv: function (...args) {
142      console.warn("webgl.uniform2uiv interface mocked in the Previewer. How this interface works on the" +
143        " Previewer may be different from that on a real device.")
144    },
145    uniform3uiv: function (...args) {
146      console.warn("webgl.uniform3uiv interface mocked in the Previewer. How this interface works on the" +
147        " Previewer may be different from that on a real device.")
148    },
149    uniform4uiv: function (...args) {
150      console.warn("webgl.uniform4uiv interface mocked in the Previewer. How this interface works on the" +
151        " Previewer may be different from that on a real device.")
152    },
153    uniformMatrix3x2fv: function (...args) {
154      console.warn("webgl.uniformMatrix3x2fv interface mocked in the Previewer. How this interface works on the" +
155        " Previewer may be different from that on a real device.")
156    },
157    uniformMatrix4x2fv: function (...args) {
158      console.warn("webgl.uniformMatrix4x2fv interface mocked in the Previewer. How this interface works on the" +
159        " Previewer may be different from that on a real device.")
160    },
161    uniformMatrix2x3fv: function (...args) {
162      console.warn("webgl.uniformMatrix2x3fv interface mocked in the Previewer. How this interface works on the" +
163        " Previewer may be different from that on a real device.")
164    },
165    uniformMatrix4x3fv: function (...args) {
166      console.warn("webgl.uniformMatrix4x3fv interface mocked in the Previewer. How this interface works on the" +
167        " Previewer may be different from that on a real device.")
168    },
169    uniformMatrix2x4fv: function (...args) {
170      console.warn("webgl.uniformMatrix2x4fv interface mocked in the Previewer. How this interface works on the" +
171        " Previewer may be different from that on a real device.")
172    },
173    uniformMatrix3x4fv: function (...args) {
174      console.warn("webgl.uniformMatrix3x4fv interface mocked in the Previewer. How this interface works on the" +
175        " Previewer may be different from that on a real device.")
176    },
177    vertexAttribI4i: function (...args) {
178      console.warn("webgl.vertexAttribI4i interface mocked in the Previewer. How this interface works on the" +
179        " Previewer may be different from that on a real device.")
180    },
181    vertexAttribI4iv: function (...args) {
182      console.warn("webgl.vertexAttribI4iv interface mocked in the Previewer. How this interface works on the" +
183        " Previewer may be different from that on a real device.")
184    },
185    vertexAttribI4ui: function (...args) {
186      console.warn("webgl.vertexAttribI4ui interface mocked in the Previewer. How this interface works on the" +
187        " Previewer may be different from that on a real device.")
188    },
189    vertexAttribI4uiv: function (...args) {
190      console.warn("webgl.vertexAttribI4uiv interface mocked in the Previewer. How this interface works on the" +
191        " Previewer may be different from that on a real device.")
192    },
193    vertexAttribIPointer: function (...args) {
194      console.warn("webgl.vertexAttribIPointer interface mocked in the Previewer. How this interface works on the" +
195        " Previewer may be different from that on a real device.")
196    },
197    vertexAttribDivisor: function (...args) {
198      console.warn("webgl.vertexAttribDivisor interface mocked in the Previewer. How this interface works on the" +
199        " Previewer may be different from that on a real device.")
200    },
201    drawArraysInstanced: function (...args) {
202      console.warn("webgl.drawArraysInstanced interface mocked in the Previewer. How this interface works on the" +
203        " Previewer may be different from that on a real device.")
204    },
205    drawElementsInstanced: function (...args) {
206      console.warn("webgl.drawElementsInstanced interface mocked in the Previewer. How this interface works on the" +
207        " Previewer may be different from that on a real device.")
208    },
209    drawRangeElements: function (...args) {
210      console.warn("webgl.drawRangeElements interface mocked in the Previewer. How this interface works on the" +
211        " Previewer may be different from that on a real device.")
212    },
213    drawBuffers: function (...args) {
214      console.warn("webgl.drawBuffers interface mocked in the Previewer. How this interface works on the" +
215        " Previewer may be different from that on a real device.")
216    },
217    clearBufferfv: function (...args) {
218      console.warn("webgl.clearBufferfv interface mocked in the Previewer. How this interface works on the" +
219        " Previewer may be different from that on a real device.")
220    },
221    clearBufferiv: function (...args) {
222      console.warn("webgl.clearBufferiv interface mocked in the Previewer. How this interface works on the" +
223        " Previewer may be different from that on a real device.")
224    },
225    clearBufferuiv: function (...args) {
226      console.warn("webgl.clearBufferuiv interface mocked in the Previewer. How this interface works on the" +
227        " Previewer may be different from that on a real device.")
228    },
229    clearBufferfi: function (...args) {
230      console.warn("webgl.clearBufferfi interface mocked in the Previewer. How this interface works on the" +
231        " Previewer may be different from that on a real device.")
232    },
233    createQuery: function (...args) {
234      console.warn("webgl.createQuery interface mocked in the Previewer. How this interface works on the" +
235        " Previewer may be different from that on a real device.")
236      return WebGLQuery;
237    },
238    deleteQuery: function (...args) {
239      console.warn("webgl.deleteQuery interface mocked in the Previewer. How this interface works on the" +
240        " Previewer may be different from that on a real device.")
241    },
242    isQuery: function (...args) {
243      console.warn("webgl.isQuery interface mocked in the Previewer. How this interface works on the" +
244        " Previewer may be different from that on a real device.")
245      return paramMock.paramBooleanMock;
246    },
247    beginQuery: function (...args) {
248      console.warn("webgl.beginQuery interface mocked in the Previewer. How this interface works on the" +
249        " Previewer may be different from that on a real device.")
250    },
251    endQuery: function (...args) {
252      console.warn("webgl.endQuery interface mocked in the Previewer. How this interface works on the" +
253        " Previewer may be different from that on a real device.")
254    },
255    getQuery: function (...args) {
256      console.warn("webgl2.getQuery interface mocked in the Previewer. How this interface works on the" +
257        " Previewer may be different from that on a real device.")
258      return WebGLQuery;
259    },
260    getQueryParameter: function (...args) {
261      console.warn("webgl2.getQueryParameter interface mocked in the Previewer. How this interface works on the" +
262        " Previewer may be different from that on a real device.")
263      if (args[1] == GL_QUERY_RESULT) {
264        return paramMock.paramNumberMock;
265      } else if (args[1] == GL_QUERY_RESULT_AVAILABLE) {
266        return paramMock.paramBooleanMock;
267      }
268    },
269    createSampler: function (...args) {
270      console.warn("webgl2.createSampler interface mocked in the Previewer. How this interface works on the" +
271        " Previewer may be different from that on a real device.")
272      return WebGLSampler;
273    },
274    deleteSampler: function (...args) {
275      console.warn("webgl2.deleteSampler interface mocked in the Previewer. How this interface works on the" +
276        " Previewer may be different from that on a real device.")
277    },
278    isSampler: function (...args) {
279      console.warn("webgl2.isSampler interface mocked in the Previewer. How this interface works on the" +
280        " Previewer may be different from that on a real device.")
281      return paramMock.paramBooleanMock;
282    },
283
284    bindSampler: function (...args) {
285      console.warn("webgl2.bindSampler interface mocked in the Previewer. How this interface works on the" +
286        " Previewer may be different from that on a real device.")
287    },
288    samplerParameteri: function (...args) {
289      console.warn("webgl2.samplerParameteri interface mocked in the Previewer. How this interface works on the" +
290        " Previewer may be different from that on a real device.")
291    },
292    samplerParameterf: function (...args) {
293      console.warn("webgl2.samplerParameterf interface mocked in the Previewer. How this interface works on the" +
294        " Previewer may be different from that on a real device.")
295    },
296    getSamplerParameter: function (...args) {
297      console.warn("webgl2.getSamplerParameter interface mocked in the Previewer. How this interface works on the" +
298        " Previewer may be different from that on a real device.")
299      if (args[1] == GL_TEXTURE_MAX_LOD || args[1] == GL_TEXTURE_MIN_LOD) {
300        return glParamMock.paramDoubleMock;
301      } else {
302        return paramMock.paramNumberMock;
303      }
304    },
305    fenceSync: function (...args) {
306      console.warn("webgl2.fenceSync interface mocked in the Previewer. How this interface works on the" +
307        " Previewer may be different from that on a real device.")
308      return WebGLSync;
309    },
310    isSync: function (...args) {
311      console.warn("webgl2.isSync interface mocked in the Previewer. How this interface works on the" +
312        " Previewer may be different from that on a real device.")
313      return paramMock.paramBooleanMock;
314    },
315    deleteSync: function (...args) {
316      console.warn("webgl2.deleteSync interface mocked in the Previewer. How this interface works on the" +
317        " Previewer may be different from that on a real device.")
318    },
319    clientWaitSync: function (...args) {
320      console.warn("webgl2.clientWaitSync interface mocked in the Previewer. How this interface works on the" +
321        " Previewer may be different from that on a real device.")
322      return paramMock.paramNumberMock;
323    },
324    waitSync: function (...args) {
325      console.warn("webgl2.waitSync interface mocked in the Previewer. How this interface works on the" +
326        " Previewer may be different from that on a real device.")
327    },
328    getSyncParameter: function (...args) {
329      console.warn("webgl2.getSyncParameter interface mocked in the Previewer. How this interface works on the" +
330        " Previewer may be different from that on a real device.")
331      return glParamMock.paramAnyMock;
332    },
333    createTransformFeedback: function (...args) {
334      console.warn("webgl2.createTransformFeedback interface mocked in the Previewer. How this interface works on the" +
335        " Previewer may be different from that on a real device.")
336      return WebGLTransformFeedback;
337    },
338    deleteTransformFeedback: function (...args) {
339      console.warn("webgl2.deleteTransformFeedback interface mocked in the Previewer. How this interface works on the" +
340        " Previewer may be different from that on a real device.")
341    },
342    isTransformFeedback: function (...args) {
343      console.warn("webgl2.isTransformFeedback interface mocked in the Previewer. How this interface works on the" +
344        " Previewer may be different from that on a real device.")
345      return paramMock.paramBooleanMock;
346    },
347    bindTransformFeedback: function (...args) {
348      console.warn("webgl2.bindTransformFeedback interface mocked in the Previewer. How this interface works on the" +
349        " Previewer may be different from that on a real device.")
350    },
351    beginTransformFeedback: function (...args) {
352      console.warn("webgl2.beginTransformFeedback interface mocked in the Previewer. How this interface works on the" +
353        " Previewer may be different from that on a real device.")
354    },
355    endTransformFeedback: function (...args) {
356      console.warn("webgl2.endTransformFeedback interface mocked in the Previewer. How this interface works on the" +
357        " Previewer may be different from that on a real device.")
358    },
359    transformFeedbackVaryings: function (...args) {
360      console.warn("webgl2.transformFeedbackVaryings interface mocked in the Previewer. How this interface works on the" +
361        " Previewer may be different from that on a real device.")
362    },
363    getTransformFeedbackVarying: function (...args) {
364      console.warn("webgl2.getTransformFeedbackVarying interface mocked in the Previewer. How this interface works on the" +
365        " Previewer may be different from that on a real device.")
366      return WebGLActiveInfo;
367    },
368    pauseTransformFeedback: function (...args) {
369      console.warn("webgl2.pauseTransformFeedback interface mocked in the Previewer. How this interface works on the" +
370        " Previewer may be different from that on a real device.")
371    },
372    resumeTransformFeedback: function (...args) {
373      console.warn("webgl2.resumeTransformFeedback interface mocked in the Previewer. How this interface works on the" +
374        " Previewer may be different from that on a real device.")
375    },
376    bindBufferBase: function (...args) {
377      console.warn("webgl2.bindBufferBase interface mocked in the Previewer. How this interface works on the" +
378        " Previewer may be different from that on a real device.")
379    },
380    bindBufferRange: function (...args) {
381      console.warn("webgl2.bindBufferRange interface mocked in the Previewer. How this interface works on the" +
382        " Previewer may be different from that on a real device.")
383    },
384    getIndexedParameter: function (...args) {
385      console.warn("webgl2.getIndexedParameter interface mocked in the Previewer. How this interface works on the" +
386        " Previewer may be different from that on a real device.")
387      return glParamMock.paramAnyMock;
388    },
389    getUniformIndices: function (...args) {
390      console.warn("webgl2.getUniformIndices interface mocked in the Previewer. How this interface works on the" +
391        " Previewer may be different from that on a real device.")
392      return glParamMock.uintArray;
393    },
394    getActiveUniforms: function (...args) {
395      console.warn("webgl2.getActiveUniforms interface mocked in the Previewer. How this interface works on the" +
396        " Previewer may be different from that on a real device.")
397      return glParamMock.paramAnyMock;
398    },
399    getUniformBlockIndex: function (...args) {
400      console.warn("webgl2.getUniformBlockIndex interface mocked in the Previewer. How this interface works on the" +
401        " Previewer may be different from that on a real device.")
402      return paramMock.paramNumberMock;
403    },
404    getActiveUniformBlockParameter: function (...args) {
405      console.warn("webgl2.getActiveUniformBlockParameter interface mocked in the Previewer. How this interface works on the" +
406        " Previewer may be different from that on a real device.")
407      return glParamMock.paramAnyMock;
408    },
409    getActiveUniformBlockName: function (...args) {
410      console.warn("webgl2.getActiveUniformBlockName interface mocked in the Previewer. How this interface works on the" +
411        " Previewer may be different from that on a real device.")
412      return paramMock.paramStringMock;
413    },
414    uniformBlockBinding: function (...args) {
415      console.warn("webgl2.uniformBlockBinding interface mocked in the Previewer. How this interface works on the" +
416        " Previewer may be different from that on a real device.")
417    },
418    createVertexArray: function (...args) {
419      console.warn("webgl2.createVertexArray interface mocked in the Previewer. How this interface works on the" +
420        " Previewer may be different from that on a real device.")
421      return WebGLVertexArrayObject;
422    },
423    deleteVertexArray: function (...args) {
424      console.warn("webgl2.deleteVertexArray interface mocked in the Previewer. How this interface works on the" +
425        " Previewer may be different from that on a real device.")
426    },
427    isVertexArray: function (...args) {
428      console.warn("webgl2.isVertexArray interface mocked in the Previewer. How this interface works on the" +
429        " Previewer may be different from that on a real device.")
430      return paramMock.paramBooleanMock;
431    },
432    bindVertexArray: function (...args) {
433      console.warn("webgl2.bindVertexArray interface mocked in the Previewer. How this interface works on the" +
434        " Previewer may be different from that on a real device.")
435    },
436    bufferData: function (...args) {
437      console.warn("webgl2.bufferData interface mocked in the Previewer. How this interface works on the" +
438        " Previewer may be different from that on a real device.")
439    },
440    bufferSubData: function (...args) {
441      console.warn("webgl2.bufferSubData interface mocked in the Previewer. How this interface works on the" +
442        " Previewer may be different from that on a real device.")
443    },
444    texImage2D: function (...args) {
445      console.warn("webgl2.texImage2D interface mocked in the Previewer. How this interface works on the" +
446        " Previewer may be different from that on a real device.")
447    },
448    texSubImage2D: function (...args) {
449      console.warn("webgl2.texSubImage2D interface mocked in the Previewer. How this interface works on the" +
450        " Previewer may be different from that on a real device.")
451    },
452    compressedTexImage2D: function (...args) {
453      console.warn("webgl2.compressedTexImage2D interface mocked in the Previewer. How this interface works on the" +
454        " Previewer may be different from that on a real device.")
455    },
456    compressedTexSubImage2D: function (...args) {
457      console.warn("webgl2.compressedTexSubImage2D interface mocked in the Previewer. How this interface works on the" +
458        " Previewer may be different from that on a real device.")
459    },
460    uniform1fv: function (...args) {
461      console.warn("webgl2.uniform1fv interface mocked in the Previewer. How this interface works on the" +
462        " Previewer may be different from that on a real device.")
463    },
464    uniform2fv: function (...args) {
465      console.warn("webgl2.uniform2fv interface mocked in the Previewer. How this interface works on the" +
466        " Previewer may be different from that on a real device.")
467    },
468    uniform3fv: function (...args) {
469      console.warn("webgl2.uniform3fv interface mocked in the Previewer. How this interface works on the" +
470        " Previewer may be different from that on a real device.")
471    },
472    uniform4fv: function (...args) {
473      console.warn("webgl2.uniform4fv interface mocked in the Previewer. How this interface works on the" +
474        " Previewer may be different from that on a real device.")
475    },
476    uniform1iv: function (...args) {
477      console.warn("webgl2.uniform1iv interface mocked in the Previewer. How this interface works on the" +
478        " Previewer may be different from that on a real device.")
479    },
480    uniform2iv: function (...args) {
481      console.warn("webgl2.uniform2iv interface mocked in the Previewer. How this interface works on the" +
482        " Previewer may be different from that on a real device.")
483    },
484    uniform3iv: function (...args) {
485      console.warn("webgl2.uniform3iv interface mocked in the Previewer. How this interface works on the" +
486        " Previewer may be different from that on a real device.")
487    },
488    uniform4iv: function (...args) {
489      console.warn("webgl2.uniform4iv interface mocked in the Previewer. How this interface works on the" +
490        " Previewer may be different from that on a real device.")
491    },
492    uniformMatrix2fv: function (...args) {
493      console.warn("webgl2.uniformMatrix2fv interface mocked in the Previewer. How this interface works on the" +
494        " Previewer may be different from that on a real device.")
495    },
496    uniformMatrix3fv: function (...args) {
497      console.warn("webgl2.uniformMatrix3fv interface mocked in the Previewer. How this interface works on the" +
498        " Previewer may be different from that on a real device.")
499    },
500    uniformMatrix4fv: function (...args) {
501      console.warn("webgl2.uniformMatrix4fv interface mocked in the Previewer. How this interface works on the" +
502        " Previewer may be different from that on a real device.")
503    },
504    readPixels: function (...args) {
505      console.warn("webgl2.readPixels interface mocked in the Previewer. How this interface works on the" +
506        " Previewer may be different from that on a real device.")
507    }
508  }
509  return webgl2Mock;
510
511}