Skip to content
This repository has been archived by the owner on Aug 15, 2019. It is now read-only.

Commit

Permalink
Cache MAX_TEXTURE_SIZE (#1312)
Browse files Browse the repository at this point in the history
BUG
  • Loading branch information
annxingyuan authored Oct 12, 2018
1 parent 925ae6d commit 591f0a6
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/environment_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,19 @@ export function isWebGLVersionEnabled(webGLVersion: 1|2, isBrowser: boolean) {
return false;
}

export function getWebGLMaxTextureSize(
webGLVersion: number, isBrowser: boolean): number {
const gl = getWebGLRenderingContext(webGLVersion, isBrowser);
return gl.getParameter(gl.MAX_TEXTURE_SIZE);
}
export const getWebGLMaxTextureSize = (() => {
// Caching MAX_TEXTURE_SIZE here because the environment gets reset between
// unit tests and we don't want to constantly query the WebGLContext for
// MAX_TEXTURE_SIZE.
let MAX_TEXTURE_SIZE: number = null;
return (webGLVersion: number, isBrowser: boolean): number => {
if (MAX_TEXTURE_SIZE === null) {
const gl = getWebGLRenderingContext(webGLVersion, isBrowser);
MAX_TEXTURE_SIZE = gl.getParameter(gl.MAX_TEXTURE_SIZE);
}
return MAX_TEXTURE_SIZE;
};
})();

export function getWebGLDisjointQueryTimerVersion(
webGLVersion: number, isBrowser: boolean): number {
Expand Down

0 comments on commit 591f0a6

Please sign in to comment.