Skip to content

Commit

Permalink
Fix performance issues on iOS by upgrading internal rendering engine …
Browse files Browse the repository at this point in the history
…to PixiJS v6 (#2447)

* Thanks @Bouh and @arthuro555 for the help!

Co-authored-by: Bouh <[email protected]>
  • Loading branch information
4ian and Bouh authored Apr 9, 2021
1 parent c846a7a commit 54ef748
Show file tree
Hide file tree
Showing 89 changed files with 1,322 additions and 1,099 deletions.
2 changes: 1 addition & 1 deletion Extensions/Effects/adjustment-pixi-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace gdjs {
},
update: function (filter, layer) {},
updateDoubleParameter: function (filter, parameterName, value) {
const adjustmentFilter = filter as PIXI.filters.AdjustmentFilter;
const adjustmentFilter = (filter as unknown) as PIXI.filters.AdjustmentFilter;
if (parameterName === 'gamma') {
adjustmentFilter.gamma = value;
} else if (parameterName === 'saturation') {
Expand Down
2 changes: 1 addition & 1 deletion Extensions/Effects/advanced-bloom-pixi-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace gdjs {
},
update: function (filter, layer) {},
updateDoubleParameter: function (filter, parameterName, value) {
const advancedBloomFilter = filter as PIXI.filters.AdvancedBloomFilter;
const advancedBloomFilter = (filter as unknown) as PIXI.filters.AdvancedBloomFilter;
if (parameterName === 'threshold') {
advancedBloomFilter.threshold = value;
} else if (parameterName === 'bloomScale') {
Expand Down
2 changes: 1 addition & 1 deletion Extensions/Effects/ascii-pixi-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace gdjs {
},
update: function (filter, layer) {},
updateDoubleParameter: function (filter, parameterName, value) {
const asciiFilter = filter as PIXI.filters.AsciiFilter;
const asciiFilter = (filter as unknown) as PIXI.filters.AsciiFilter;
if (parameterName === 'size') {
asciiFilter.size = value;
}
Expand Down
4 changes: 2 additions & 2 deletions Extensions/Effects/bevel-pixi-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace gdjs {
},
update: function (filter, layer) {},
updateDoubleParameter: function (filter, parameterName, value) {
const bevelFilter = filter as PIXI.filters.BevelFilter;
const bevelFilter = (filter as unknown) as PIXI.filters.BevelFilter;
if (parameterName === 'rotation') {
bevelFilter.rotation = value;
} else if (parameterName === 'thickness') {
Expand All @@ -21,7 +21,7 @@ namespace gdjs {
}
},
updateStringParameter: function (filter, parameterName, value) {
const bevelFilter = filter as PIXI.filters.BevelFilter;
const bevelFilter = (filter as unknown) as PIXI.filters.BevelFilter;
if (parameterName === 'lightColor') {
bevelFilter.lightColor = gdjs.PixiFiltersTools.rgbOrHexToHexNumber(
value
Expand Down
4 changes: 3 additions & 1 deletion Extensions/Effects/black-and-white-pixi-filter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace gdjs {
import PIXI = GlobalPIXIModule.PIXI;
gdjs.PixiFiltersTools.registerFilterCreator('BlackAndWhite', {
makePIXIFilter: function (layer, effectData) {
const colorMatrix = new PIXI.filters.ColorMatrixFilter();
Expand All @@ -7,7 +8,8 @@ namespace gdjs {
},
update: function (filter, layer) {},
updateDoubleParameter: function (filter, parameterName, value) {
const colorMatrix = filter as PIXI.filters.ColorMatrixFilter;
// @ts-ignore - unsure why PIXI.filters is not recognised.
const colorMatrix = (filter as unknown) as PIXI.filters.ColorMatrixFilter;
if (parameterName !== 'opacity') {
return;
}
Expand Down
4 changes: 3 additions & 1 deletion Extensions/Effects/blending-mode-pixi-filter.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
namespace gdjs {
import PIXI = GlobalPIXIModule.PIXI;
gdjs.PixiFiltersTools.registerFilterCreator('BlendingMode', {
makePIXIFilter: function (layer, effectData) {
const blendingModeFilter = new PIXI.filters.AlphaFilter();
return blendingModeFilter;
},
update: function (filter, layer) {},
updateDoubleParameter: function (filter, parameterName, value) {
const blendingModeFilter = filter as PIXI.filters.AlphaFilter;
// @ts-ignore - unsure why PIXI.filters is not recognised.
const blendingModeFilter = (filter as unknown) as PIXI.filters.AlphaFilter;
if (parameterName === 'alpha') {
blendingModeFilter.alpha = value;
} else if (parameterName === 'blendmode') {
Expand Down
1 change: 1 addition & 0 deletions Extensions/Effects/blur-pixi-filter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace gdjs {
import PIXI = GlobalPIXIModule.PIXI;
gdjs.PixiFiltersTools.registerFilterCreator('Blur', {
makePIXIFilter: function (layer, effectData) {
const blur = new PIXI.filters.BlurFilter();
Expand Down
4 changes: 3 additions & 1 deletion Extensions/Effects/brightness-pixi-filter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace gdjs {
import PIXI = GlobalPIXIModule.PIXI;
gdjs.PixiFiltersTools.registerFilterCreator('Brightness', {
makePIXIFilter: function (layer, effectData) {
const brightness = new PIXI.filters.ColorMatrixFilter();
Expand All @@ -7,7 +8,8 @@ namespace gdjs {
},
update: function (filter, layer) {},
updateDoubleParameter: function (filter, parameterName, value) {
const brightnessFilter = filter as PIXI.filters.ColorMatrixFilter;
// @ts-ignore - unsure why PIXI.filters is not recognised.
const brightnessFilter = (filter as unknown) as PIXI.filters.ColorMatrixFilter;
if (parameterName !== 'brightness') {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion Extensions/Effects/bulge-pinch-pixi-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace gdjs {
},
update: function (filter, layer) {},
updateDoubleParameter: function (filter, parameterName, value) {
const bulgePinchFilter = filter as PIXI.filters.BulgePinchFilter;
const bulgePinchFilter = (filter as unknown) as PIXI.filters.BulgePinchFilter;
if (parameterName === 'centerX') {
bulgePinchFilter.center[0] = value;
} else if (parameterName === 'centerY') {
Expand Down
5 changes: 2 additions & 3 deletions Extensions/Effects/color-map-pixi-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ namespace gdjs {
.getGame()
.getImageManager()
.getPIXITexture(effectData.stringParameters.colorMapTexture);
const colorMapSprite = new PIXI.Sprite(colorMapTexture);
const colorMapFilter = new PIXI.filters.ColorMapFilter(
colorMapTexture,
effectData.booleanParameters.nearest,
Expand All @@ -20,7 +19,7 @@ namespace gdjs {
},
update: function (filter, layer) {},
updateDoubleParameter: function (filter, parameterName, value) {
const colorMapFilter = filter as PIXI.filters.ColorMapFilter;
const colorMapFilter = (filter as unknown) as PIXI.filters.ColorMapFilter;
if (parameterName === 'mix') {
colorMapFilter.mix = gdjs.PixiFiltersTools.clampValue(
value / 100,
Expand All @@ -31,7 +30,7 @@ namespace gdjs {
},
updateStringParameter: function (filter, parameterName, value) {},
updateBooleanParameter: function (filter, parameterName, value) {
const colorMapFilter = filter as PIXI.filters.ColorMapFilter;
const colorMapFilter = (filter as unknown) as PIXI.filters.ColorMapFilter;
if (parameterName === 'nearest') {
colorMapFilter.nearest = value;
}
Expand Down
4 changes: 2 additions & 2 deletions Extensions/Effects/color-replace-pixi-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ namespace gdjs {
},
update: function (filter, layer) {},
updateDoubleParameter: function (filter, parameterName, value) {
const colorReplaceFilter = filter as PIXI.filters.ColorReplaceFilter;
const colorReplaceFilter = (filter as unknown) as PIXI.filters.ColorReplaceFilter;
if (parameterName === 'epsilon') {
colorReplaceFilter.epsilon = value;
}
},
updateStringParameter: function (filter, parameterName, value) {
const colorReplaceFilter = filter as PIXI.filters.ColorReplaceFilter;
const colorReplaceFilter = (filter as unknown) as PIXI.filters.ColorReplaceFilter;
if (parameterName === 'originalColor') {
colorReplaceFilter.originalColor = gdjs.PixiFiltersTools.rgbOrHexToHexNumber(
value
Expand Down
4 changes: 3 additions & 1 deletion Extensions/Effects/displacement-pixi-filter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace gdjs {
import PIXI = GlobalPIXIModule.PIXI;
gdjs.PixiFiltersTools.registerFilterCreator('Displacement', {
makePIXIFilter: function (layer, effectData) {
const displacementMapTexture = layer
Expand All @@ -15,7 +16,8 @@ namespace gdjs {
},
update: function (filter, layer) {},
updateDoubleParameter: function (filter, parameterName, value) {
const displacementFilter = filter as PIXI.filters.DisplacementFilter;
// @ts-ignore - unsure why PIXI.filters is not recognised.
const displacementFilter = (filter as unknown) as PIXI.filters.DisplacementFilter;
if (parameterName === 'scaleX') {
displacementFilter.scale.x = value;
}
Expand Down
2 changes: 1 addition & 1 deletion Extensions/Effects/dot-pixi-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace gdjs {
},
update: function (filter, layer) {},
updateDoubleParameter: function (filter, parameterName, value) {
const dotFilter = filter as PIXI.filters.DotFilter;
const dotFilter = (filter as unknown) as PIXI.filters.DotFilter;
if (parameterName === 'scale') {
dotFilter.scale = value;
} else if (parameterName === 'angle') {
Expand Down
6 changes: 3 additions & 3 deletions Extensions/Effects/drop-shadow-pixi-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace gdjs {
},
update: function (filter, layer) {},
updateDoubleParameter: function (filter, parameterName, value) {
const dropShadowFilter = filter as PIXI.filters.DropShadowFilter;
const dropShadowFilter = (filter as unknown) as PIXI.filters.DropShadowFilter;
if (parameterName === 'blur') {
dropShadowFilter.blur = value;
} else if (parameterName === 'quality') {
Expand All @@ -20,15 +20,15 @@ namespace gdjs {
}
},
updateStringParameter: function (filter, parameterName, value) {
const dropShadowFilter = filter as PIXI.filters.DropShadowFilter;
const dropShadowFilter = (filter as unknown) as PIXI.filters.DropShadowFilter;
if (parameterName === 'color') {
dropShadowFilter.color = gdjs.PixiFiltersTools.rgbOrHexToHexNumber(
value
);
}
},
updateBooleanParameter: function (filter, parameterName, value) {
const dropShadowFilter = filter as PIXI.filters.DropShadowFilter;
const dropShadowFilter = (filter as unknown) as PIXI.filters.DropShadowFilter;
if (parameterName === 'shadowOnly') {
dropShadowFilter.shadowOnly = value;
}
Expand Down
4 changes: 2 additions & 2 deletions Extensions/Effects/glow-pixi-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace gdjs {
},
update: function (filter, layer) {},
updateDoubleParameter: function (filter, parameterName, value) {
const glowFilter = filter as PIXI.filters.GlowFilter;
const glowFilter = (filter as unknown) as PIXI.filters.GlowFilter;
if (parameterName === 'innerStrength') {
glowFilter.innerStrength = value;
} else if (parameterName === 'outerStrength') {
Expand All @@ -17,7 +17,7 @@ namespace gdjs {
}
},
updateStringParameter: function (filter, parameterName, value) {
const glowFilter = filter as PIXI.filters.GlowFilter;
const glowFilter = (filter as unknown) as PIXI.filters.GlowFilter;
if (parameterName === 'color') {
glowFilter.color = gdjs.PixiFiltersTools.rgbOrHexToHexNumber(value);
}
Expand Down
2 changes: 1 addition & 1 deletion Extensions/Effects/kawase-blur-pixi-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace gdjs {
},
update: function (filter, layer) {},
updateDoubleParameter: function (filter, parameterName, value) {
const kawaseBlurFilter = filter as PIXI.filters.KawaseBlurFilter;
const kawaseBlurFilter = (filter as unknown) as PIXI.filters.KawaseBlurFilter;
if (parameterName === 'pixelizeX') {
// @ts-ignore: fix these wrong parameters
kawaseBlurFilter.pixelizeX = value;
Expand Down
1 change: 1 addition & 0 deletions Extensions/Effects/light-night-pixi-filter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace gdjs {
import PIXI = GlobalPIXIModule.PIXI;
export class LightNightPixiFilter extends PIXI.Filter {
constructor() {
const vertexShader = undefined;
Expand Down
1 change: 1 addition & 0 deletions Extensions/Effects/night-pixi-filter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace gdjs {
import PIXI = GlobalPIXIModule.PIXI;
export class NightPixiFilter extends PIXI.Filter {
constructor() {
const vertexShader = undefined;
Expand Down
4 changes: 3 additions & 1 deletion Extensions/Effects/noise-pixi-filter.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
namespace gdjs {
import PIXI = GlobalPIXIModule.PIXI;
gdjs.PixiFiltersTools.registerFilterCreator('Noise', {
makePIXIFilter: function (layer, effectData) {
const noiseFilter = new PIXI.filters.NoiseFilter();
return noiseFilter;
},
update: function (filter, layer) {},
updateDoubleParameter: function (filter, parameterName, value) {
const noiseFilter = filter as PIXI.filters.NoiseFilter;
// @ts-ignore - unsure why PIXI.filters is not recognised.
const noiseFilter = (filter as unknown) as PIXI.filters.NoiseFilter;
if (parameterName !== 'noise') {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions Extensions/Effects/outline-pixi-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ namespace gdjs {
},
update: function (filter, layer) {},
updateDoubleParameter: function (filter, parameterName, value) {
const outlineFilter = filter as PIXI.filters.OutlineFilter;
const outlineFilter = (filter as unknown) as PIXI.filters.OutlineFilter;
if (parameterName === 'thickness') {
outlineFilter.thickness = value;
}
},
updateStringParameter: function (filter, parameterName, value) {
const outlineFilter = filter as PIXI.filters.OutlineFilter;
const outlineFilter = (filter as unknown) as PIXI.filters.OutlineFilter;
if (parameterName === 'color') {
outlineFilter.color = gdjs.PixiFiltersTools.rgbOrHexToHexNumber(value);
}
Expand Down
2 changes: 1 addition & 1 deletion Extensions/Effects/pixelate-pixi-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace gdjs {
},
update: function (filter, layer) {},
updateDoubleParameter: function (filter, parameterName, value) {
const pixelateFilter = filter as PIXI.filters.PixelateFilter;
const pixelateFilter = (filter as unknown) as PIXI.filters.PixelateFilter;
if (parameterName === 'size') {
pixelateFilter.size = value;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare namespace PIXI.filters {
import PIXI = GlobalPIXIModule.PIXI;
export class AdjustmentFilter extends PIXI.Filter {
constructor(options?: AdjustmentOptions);
gamma: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare namespace PIXI.filters {
import PIXI = GlobalPIXIModule.PIXI;
export class AdvancedBloomFilter extends PIXI.Filter {
constructor(options?: AdvancedBloomOptions);
constructor(threshold?: number);
Expand Down
1 change: 1 addition & 0 deletions Extensions/Effects/pixi-filters/types/ascii/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare namespace PIXI.filters {
import PIXI = GlobalPIXIModule.PIXI;
export class AsciiFilter extends PIXI.Filter {
constructor(size?: number);
size: number;
Expand Down
1 change: 1 addition & 0 deletions Extensions/Effects/pixi-filters/types/bevel/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare namespace PIXI.filters {
import PIXI = GlobalPIXIModule.PIXI;
export class BevelFilter extends PIXI.Filter {
constructor(options?: BevelOptions);
rotation: number;
Expand Down
1 change: 1 addition & 0 deletions Extensions/Effects/pixi-filters/types/bloom/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare namespace PIXI.filters {
import PIXI = GlobalPIXIModule.PIXI;
export class BloomFilter extends PIXI.Filter {
constructor(
blur?: number | PIXI.Point | number[],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare namespace PIXI.filters {
import PIXI = GlobalPIXIModule.PIXI;
export interface BulgePinchFilterOptions {
center?: PIXI.Point | [number, number];
radius?: number;
Expand Down
1 change: 1 addition & 0 deletions Extensions/Effects/pixi-filters/types/color-map/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare namespace PIXI.filters {
import PIXI = GlobalPIXIModule.PIXI;
export class ColorMapFilter extends PIXI.Filter {
constructor(
colorMap?:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare namespace PIXI.filters {
import PIXI = GlobalPIXIModule.PIXI;
export class ColorOverlayFilter extends PIXI.Filter {
constructor(color?: number | [number, number, number]);
color: number | [number, number, number];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare namespace PIXI.filters {
import PIXI = GlobalPIXIModule.PIXI;
export class ColorReplaceFilter extends PIXI.Filter {
constructor(
originalColor?: number | number[],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare namespace PIXI.filters {
import PIXI = GlobalPIXIModule.PIXI;
export class ConvolutionFilter extends PIXI.Filter {
constructor(matrix: number[], width: number, height: number);
height: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare namespace PIXI.filters {
import PIXI = GlobalPIXIModule.PIXI;
class CrossHatchFilter extends PIXI.Filter {
constructor();
}
Expand Down
1 change: 1 addition & 0 deletions Extensions/Effects/pixi-filters/types/crt/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare namespace PIXI.filters {
import PIXI = GlobalPIXIModule.PIXI;
export class CRTFilter extends PIXI.Filter {
constructor(options?: CRTFilterOptions);
curvature: number;
Expand Down
1 change: 1 addition & 0 deletions Extensions/Effects/pixi-filters/types/dot/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare namespace PIXI.filters {
import PIXI = GlobalPIXIModule.PIXI;
export class DotFilter extends PIXI.Filter {
constructor(scale?: number, angle?: number);
angle: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare namespace PIXI.filters {
import PIXI = GlobalPIXIModule.PIXI;
export class DropShadowFilter extends PIXI.Filter {
constructor(options?: DropShadowFilterOptions);
alpha: number;
Expand Down
1 change: 1 addition & 0 deletions Extensions/Effects/pixi-filters/types/emboss/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare namespace PIXI.filters {
import PIXI = GlobalPIXIModule.PIXI;
export class EmbossFilter extends PIXI.Filter {
constructor(strength?: number);
strength: number;
Expand Down
1 change: 1 addition & 0 deletions Extensions/Effects/pixi-filters/types/glitch/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare namespace PIXI.filters {
import PIXI = GlobalPIXIModule.PIXI;
export class GlitchFilter extends PIXI.Filter {
constructor(options?: GlitchFilterOptions);
slices: number;
Expand Down
1 change: 1 addition & 0 deletions Extensions/Effects/pixi-filters/types/glow/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare namespace PIXI.filters {
import PIXI = GlobalPIXIModule.PIXI;
export class GlowFilter extends PIXI.Filter {
constructor(options?: GlowFilterOptions);
color: number;
Expand Down
1 change: 1 addition & 0 deletions Extensions/Effects/pixi-filters/types/godray/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare namespace PIXI.filters {
import PIXI = GlobalPIXIModule.PIXI;
export class GodrayFilter extends PIXI.Filter {
constructor(options?: GodrayFilterOptions);
angle: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
declare namespace PIXI.filters {
import PIXI = GlobalPIXIModule.PIXI;
export class KawaseBlurFilter extends PIXI.Filter {
constructor(blur?: number | number[], quality?: number, clamp?: boolean);
kernels: number[];
Expand Down
Loading

0 comments on commit 54ef748

Please sign in to comment.