1 | {"version":3,"file":"maxRecommendedTextures.mjs","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":[],"mappings":";;AAcO,SAAA,sBAAA,CAAgC,GACvC,EAAA;AACI,EAAA,IAAI,QAAW,GAAA,IAAA,CAAA;AACf,EAAM,MAAA,SAAA,GAAY,QAAS,CAAA,OAAA,CAAQ,YAAa,EAAA,CAAA;AAEhD,EAAI,IAAA,QAAA,CAAS,MAAU,IAAA,QAAA,CAAS,KAChC,EAAA;AACI,IAAI,IAAA,QAAA,CAAS,MAAM,MACnB,EAAA;AACI,MAAA,MAAM,KAAS,GAAA,SAAA,CAAU,SAAW,CAAA,KAAA,CAAM,iBAAiB,CAAA,CAAA;AAE3D,MAAA,IAAI,KACJ,EAAA;AACI,QAAA,MAAM,YAAe,GAAA,QAAA,CAAS,KAAM,CAAA,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA;AAG1C,QAAA,IAAI,eAAe,EACnB,EAAA;AACI,UAAW,QAAA,GAAA,KAAA,CAAA;AAAA,SACf;AAAA,OACJ;AAAA,KACJ;AACA,IAAI,IAAA,QAAA,CAAS,QAAQ,MACrB,EAAA;AACI,MAAA,MAAM,KAAS,GAAA,SAAA,CAAU,SAAW,CAAA,KAAA,CAAM,oBAAoB,CAAA,CAAA;AAE9D,MAAA,IAAI,KACJ,EAAA;AACI,QAAA,MAAM,YAAe,GAAA,QAAA,CAAS,KAAM,CAAA,CAAA,CAAA,EAAI,EAAE,CAAA,CAAA;AAG1C,QAAA,IAAI,eAAe,CACnB,EAAA;AACI,UAAW,QAAA,GAAA,KAAA,CAAA;AAAA,SACf;AAAA,OACJ;AAAA,KACJ;AAAA,GACJ;AAEA,EAAA,OAAO,WAAW,GAAM,GAAA,CAAA,CAAA;AAC5B;;;;"} |