From 1409237af77b05dce07cbf565ac6c5b525d2f35b Mon Sep 17 00:00:00 2001 From: Lily Date: Mon, 18 Nov 2024 22:57:01 +0300 Subject: [PATCH] Update OpenGLRenderer.hx --- src/openfl/display/OpenGLRenderer.hx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/openfl/display/OpenGLRenderer.hx b/src/openfl/display/OpenGLRenderer.hx index b5356bdd1c..1918cb8763 100644 --- a/src/openfl/display/OpenGLRenderer.hx +++ b/src/openfl/display/OpenGLRenderer.hx @@ -70,6 +70,10 @@ class OpenGLRenderer extends DisplayObjectRenderer @SuppressWarnings("checkstyle:Dynamic") public var gl:#if lime WebGLRenderContext #else Dynamic #end; + @:noCompletion private static var __staticDefaultDisplayShader:DisplayObjectShader; + @:noCompletion private static var __staticDefaultGraphicsShader:GraphicsShader; + @:noCompletion private static var __staticMaskShader:Context3DMaskShader; + @:noCompletion private var __context3D:Context3D; @:noCompletion private var __clipRects:Array; @:noCompletion private var __currentDisplayShader:Shader; @@ -159,14 +163,18 @@ class OpenGLRenderer extends DisplayObjectRenderer __stencilReference = 0; __tempRect = new Rectangle(); - __defaultDisplayShader = new DisplayObjectShader(); - __defaultGraphicsShader = new GraphicsShader(); + if (__staticDefaultDisplayShader == null) __staticDefaultDisplayShader = new DisplayObjectShader(); + if (__staticDefaultGraphicsShader == null) __staticDefaultGraphicsShader = new GraphicsShader(); + if (__staticMaskShader == null) __staticMaskShader = new Context3DMaskShader(); + + __defaultDisplayShader = __staticDefaultDisplayShader; + __defaultGraphicsShader = __staticDefaultGraphicsShader; __defaultShader = __defaultDisplayShader; __initShader(__defaultShader); __scrollRectMasks = new ObjectPool(function() return new Shape()); - __maskShader = new Context3DMaskShader(); + __maskShader = __staticMaskShader; } /**