UNPKG

2.43 kBSource Map (JSON)View Raw
1{"version":3,"file":"maxRecommendedTextures.js","sources":["../../src/batch/maxRecommendedTextures.ts"],"sourcesContent":["import { isMobile, settings } from '@pixi/settings';\n\n/**\n * The maximum recommended texture units to use.\n * In theory the bigger the better, and for desktop we'll use as many as we can.\n * But some mobile devices slow down if there is to many branches in the shader.\n * So in practice there seems to be a sweet spot size that varies depending on the device.\n *\n * In v4, all mobile devices were limited to 4 texture units because for this.\n * In v5, we allow all texture units to be used on modern Apple or Android devices.\n * @private\n * @param {number} max\n * @returns {number} The maximum recommended texture units to use.\n */\nexport function maxRecommendedTextures(max: number): number\n{\n let allowMax = true;\n const navigator = settings.ADAPTER.getNavigator();\n\n if (isMobile.tablet || isMobile.phone)\n {\n if (isMobile.apple.device)\n {\n const match = (navigator.userAgent).match(/OS (\\d+)_(\\d+)?/);\n\n if (match)\n {\n const majorVersion = parseInt(match[1], 10);\n\n // Limit texture units on devices below iOS 11, which will be older hardware\n if (majorVersion < 11)\n {\n allowMax = false;\n }\n }\n }\n if (isMobile.android.device)\n {\n const match = (navigator.userAgent).match(/Android\\s([0-9.]*)/);\n\n if (match)\n {\n const majorVersion = parseInt(match[1], 10);\n\n // Limit texture units on devices below Android 7 (Nougat), which will be older hardware\n if (majorVersion < 7)\n {\n allowMax = false;\n }\n }\n }\n }\n\n return allowMax ? max : 4;\n}\n"],"names":["settings","isMobile"],"mappings":";;AAcO,SAAS,uBAAuB,KACvC;AACI,MAAI,WAAW;AACT,QAAA,YAAYA,SAAAA,SAAS,QAAQ,aAAa;AAE5C,MAAAC,kBAAS,UAAUA,SAAA,SAAS,OAChC;AACQ,QAAAA,SAAA,SAAS,MAAM,QACnB;AACI,YAAM,QAAS,UAAU,UAAW,MAAM,iBAAiB;AAEvD,eAEqB,SAAS,MAAM,CAAC,GAAG,EAAE,IAGvB,OAEf,WAAW;AAAA,IAGvB;AACI,QAAAA,SAAA,SAAS,QAAQ,QACrB;AACI,YAAM,QAAS,UAAU,UAAW,MAAM,oBAAoB;AAE1D,eAEqB,SAAS,MAAM,CAAC,GAAG,EAAE,IAGvB,MAEf,WAAW;AAAA,IAGvB;AAAA,EACJ;AAEA,SAAO,WAAW,MAAM;AAC5B;;"}
\No newline at end of file