diff --git a/packages/app/src/Application.ts b/packages/app/src/Application.ts index 3e8490a017..f1f55e9f2a 100644 --- a/packages/app/src/Application.ts +++ b/packages/app/src/Application.ts @@ -70,9 +70,7 @@ export class Application * @param {number} [options.width=800] - The width of the renderers view. * @param {number} [options.height=600] - The height of the renderers view. * @param {PIXI.ICanvas} [options.view] - The canvas to use as a view, optional. - * @param {boolean} [options.useContextAlpha=true] - Pass-through value for canvas' context `alpha` property. - * If you want to set transparency, please use `backgroundAlpha`. This option is for cases where the - * canvas needs to be opaque, possibly for performance reasons on some older devices. + * @param {boolean} [options.premultipliedAlpha=true] - Set to `false` to disable premultipliedAlpha. * @param {boolean} [options.autoDensity=false] - Resizes renderer view in CSS pixels to allow for * resolutions other than 1. * @param {boolean} [options.antialias=false] - Sets antialias diff --git a/packages/canvas-renderer/src/CanvasRenderer.ts b/packages/canvas-renderer/src/CanvasRenderer.ts index 78cd9dd536..d1919d0943 100644 --- a/packages/canvas-renderer/src/CanvasRenderer.ts +++ b/packages/canvas-renderer/src/CanvasRenderer.ts @@ -164,9 +164,6 @@ export class CanvasRenderer extends SystemManager implements IRe * @param {number} [options.width=800] - the width of the screen * @param {number} [options.height=600] - the height of the screen * @param {PIXI.ICanvas} [options.view] - the canvas to use as a view, optional - * @param {boolean} [options.useContextAlpha=true] - Pass-through value for canvas' context `alpha` property. - * If you want to set transparency, please use `backgroundAlpha`. This option is for cases where the - * canvas needs to be opaque, possibly for performance reasons on some older devices. * @param {boolean} [options.autoDensity=false] - Resizes renderer view in CSS pixels to allow for * resolutions other than 1 * @param {boolean} [options.antialias=false] - sets antialias @@ -215,6 +212,14 @@ export class CanvasRenderer extends SystemManager implements IRe this.setup(systemConfig); + if ('useContextAlpha' in options) + { + // #if _DEBUG + deprecation('7.0.0', 'options.useContextAlpha is deprecated, use options.backgroundAlpha instead'); + // #endif + options.backgroundAlpha = options.useContextAlpha === false ? 1 : options.backgroundAlpha; + } + // convert our big blob of options into system specific ones.. const startupOptions: StartupOptions = { hello: options.hello, diff --git a/packages/core/src/Renderer.ts b/packages/core/src/Renderer.ts index 44fe9007de..de48d514a7 100644 --- a/packages/core/src/Renderer.ts +++ b/packages/core/src/Renderer.ts @@ -286,9 +286,7 @@ export class Renderer extends SystemManager implements IRenderer * @param {number} [options.width=800] - The width of the screen. * @param {number} [options.height=600] - The height of the screen. * @param {PIXI.ICanvas} [options.view] - The canvas to use as a view, optional. - * @param {boolean} [options.useContextAlpha=true] - Pass-through value for canvas' context `alpha` property. - * If you want to set transparency, please use `backgroundAlpha`. This option is for cases where the - * canvas needs to be opaque, possibly for performance reasons on some older devices. + * @param {boolean} [options.premultipliedAlpha=true] - Set to `false` to disable premultipliedAlpha. * @param {boolean} [options.autoDensity=false] - Resizes renderer view in CSS pixels to allow for * resolutions other than 1. * @param {boolean} [options.antialias=false] - Sets antialias. If not available natively then FXAA @@ -368,6 +366,16 @@ export class Renderer extends SystemManager implements IRenderer this.setup(systemConfig); + if ('useContextAlpha' in options) + { + // #if _DEBUG + // eslint-disable-next-line max-len + deprecation('7.0.0', 'options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead'); + // #endif + options.premultipliedAlpha = options.useContextAlpha && options.useContextAlpha !== 'notMultiplied'; + options.backgroundAlpha = options.useContextAlpha === false ? 1 : options.backgroundAlpha; + } + // new options! const startupOptions: StartupOptions = { hello: options.hello, @@ -388,8 +396,7 @@ export class Renderer extends SystemManager implements IRenderer antialias: options.antialias, context: options.context, powerPreference: options.powerPreference, - premultipliedAlpha: options.premultipliedAlpha - ?? (options.useContextAlpha && options.useContextAlpha !== 'notMultiplied'), + premultipliedAlpha: options.premultipliedAlpha, preserveDrawingBuffer: options.preserveDrawingBuffer, }, }; @@ -547,7 +554,7 @@ export class Renderer extends SystemManager implements IRenderer { // #if _DEBUG // eslint-disable-next-line max-len - deprecation('7.0.0', 'renderer.useContextAlpha has been deprecated, please use renderer.background.clearBeforeRender instead.'); + deprecation('7.0.0', 'renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead.'); // #endif return this.background.clearBeforeRender; @@ -563,7 +570,7 @@ export class Renderer extends SystemManager implements IRenderer { // #if _DEBUG // eslint-disable-next-line max-len - deprecation('7.0.0', 'Renderer#useContextAlpha has been deprecated, please use Renderer#context.premultipliedAlpha instead.'); + deprecation('7.0.0', 'renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead.'); // #endif return this.context.useContextAlpha; diff --git a/packages/core/src/context/ContextSystem.ts b/packages/core/src/context/ContextSystem.ts index e8918e8e51..8abce994f4 100644 --- a/packages/core/src/context/ContextSystem.ts +++ b/packages/core/src/context/ContextSystem.ts @@ -134,7 +134,7 @@ export class ContextSystem implements ISystem else { const alpha = this.renderer.background.alpha < 1; - const premultipliedAlpha = options.premultipliedAlpha ?? true; + const premultipliedAlpha = options.premultipliedAlpha; this.preserveDrawingBuffer = options.preserveDrawingBuffer; this.useContextAlpha = options.useContextAlpha; diff --git a/packages/settings/src/settings.ts b/packages/settings/src/settings.ts index 6c5ab1336b..2948868663 100644 --- a/packages/settings/src/settings.ts +++ b/packages/settings/src/settings.ts @@ -16,7 +16,9 @@ export interface IRenderOptions backgroundColor: number | string; background?: number | string; backgroundAlpha: number; - useContextAlpha: boolean | 'notMultiplied'; + premultipliedAlpha: boolean; + /** @deprecated */ + useContextAlpha?: boolean | 'notMultiplied'; clearBeforeRender: boolean; preserveDrawingBuffer: boolean; width: number; @@ -151,7 +153,7 @@ export const settings: ISettings = { * @property {PIXI.ICanvas} [view=null] - * @property {boolean} [antialias=false] - * @property {boolean} [autoDensity=false] - - * @property {boolean} [useContextAlpha=true] - + * @property {boolean} [premultipliedAlpha=true] - * @property {number} [backgroundColor=0x000000] - * @property {number} [backgroundAlpha=1] - * @property {boolean} [clearBeforeRender=true] - @@ -167,7 +169,7 @@ export const settings: ISettings = { autoDensity: false, backgroundColor: 0x000000, backgroundAlpha: 1, - useContextAlpha: true, + premultipliedAlpha: true, clearBeforeRender: true, preserveDrawingBuffer: false, width: 800,