This repository has been archived by the owner on Sep 16, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(emulator): require debug ext for webgl params
- Loading branch information
1 parent
1f76899
commit ed5e43f
Showing
2 changed files
with
19 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 18 additions & 15 deletions
33
...default-browser-emulator/injected-scripts/WebGLRenderingContext.prototype.getParameter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,30 @@ | ||
proxyFunction( | ||
const activatedDebugInfo = new WeakSet<WebGL2RenderingContext | WebGLRenderingContext>(); | ||
|
||
for (const context of [ | ||
self.WebGLRenderingContext.prototype, | ||
'getParameter', | ||
function (originalFunction, thisArg, argArray) { | ||
const parameter = argArray && argArray.length ? argArray[0] : null; | ||
// call api to make sure signature goes through | ||
self.WebGL2RenderingContext.prototype, | ||
]) { | ||
proxyFunction(context, 'getExtension', function (originalFunction, thisArg, argArray) { | ||
const result = Reflect.apply(originalFunction, thisArg, argArray); | ||
if (args[parameter]) { | ||
return args[parameter]; | ||
if (argArray?.[0] === 'WEBGL_debug_renderer_info') { | ||
activatedDebugInfo.add(thisArg); | ||
} | ||
|
||
return result; | ||
}, | ||
); | ||
}); | ||
|
||
proxyFunction( | ||
self.WebGL2RenderingContext.prototype, | ||
'getParameter', | ||
function (originalFunction, thisArg, argArray) { | ||
// eslint-disable-next-line @typescript-eslint/no-loop-func | ||
proxyFunction(context, 'getParameter', function (originalFunction, thisArg, argArray) { | ||
const parameter = argArray && argArray.length ? argArray[0] : null; | ||
// call api to make sure signature goes through | ||
const result = Reflect.apply(originalFunction, thisArg, argArray); | ||
if (args[parameter]) { | ||
if (!result && !activatedDebugInfo.has(context)) { | ||
return result; | ||
} | ||
|
||
return args[parameter]; | ||
} | ||
return result; | ||
}, | ||
); | ||
}); | ||
} |