コード例 #1
0
        public static PictureFlusher.CmdDraw fastShadow(PictureFlusher.RenderLayer layer, uiMeshMesh mesh, float sigma,
                                                        bool isRect, bool isCircle, float corner, Vector4 bound, uiColor color)
        {
            Vector4 viewport = layer.viewport;
            var     mat      = _shadowBox;

            if (!isRect)
            {
                mat = _shadowRBox;
            }

            var props = ObjectPool <MaterialPropertyBlockWrapper> .alloc();

            props.SetVector(_viewportId, viewport);
            props.SetFloat(_shadowSigmaId, sigma);
            props.SetVector(_shadowBoxId, bound);
            props.SetVector(_shadowColorId, _colorToVector4(color));
            if (!isRect)
            {
                props.SetFloat(_shadowCornerId, corner);
            }

            return(PictureFlusher.CmdDraw.create(
                       mesh: mesh,
                       pass: 0,
                       material: mat,
                       properties: props
                       ));
        }
コード例 #2
0
        public static PictureFlusher.CmdDraw strokeAlpha(PictureFlusher.RenderLayer layer, uiPaint paint, float alpha, float strokeMult, uiMeshMesh mesh)
        {
            var mat = _strokeAlphaMat.getMaterial(paint.blendMode, layer.ignoreClip);

            _getShaderPassAndProps(layer, paint, mesh.matrix, alpha, strokeMult, out var pass, out var props);

            return(PictureFlusher.CmdDraw.create(
                       mesh: mesh,
                       pass: pass,
                       material: mat,
                       properties: props
                       ));
        }
コード例 #3
0
        public static PictureFlusher.RenderDraw convexFill(PictureFlusher.RenderLayer layer, Paint paint,
                                                           MeshMesh mesh)
        {
            var mat = _convexFillMat.getMaterial(paint.blendMode, layer.ignoreClip);

            _getShaderPassAndProps(layer, paint, mesh, 1.0f, out var pass, out var props);

            return(new PictureFlusher.RenderDraw {
                mesh = mesh,
                pass = pass,
                material = mat,
                properties = props,
            });
        }
コード例 #4
0
        public static PictureFlusher.CmdDraw convexFill(PictureFlusher.RenderLayer layer, uiPaint paint,
                                                        uiMeshMesh mesh)
        {
            var mat = _convexFillMat.getMaterial(paint.blendMode, layer.ignoreClip);

            _getShaderPassAndProps(layer, paint, mesh.matrix, 1.0f, 0.0f, out var pass, out var props);

            return(PictureFlusher.CmdDraw.create(
                       mesh: mesh,
                       pass: pass,
                       material: mat,
                       properties: props
                       ));
        }
コード例 #5
0
        public static PictureFlusher.RenderDraw fill1(PictureFlusher.RenderLayer layer, Paint paint,
                                                      MeshMesh mesh)
        {
            var mat = _fill1Mat.getMaterial(paint.blendMode);

            _getShaderPassAndProps(layer, paint, mesh, 1.0f, out var pass, out var props);

            return(new PictureFlusher.RenderDraw {
                mesh = mesh.boundsMesh,
                pass = pass,
                material = mat,
                properties = props,
            });
        }
コード例 #6
0
        public static PictureFlusher.RenderDraw stroke0(PictureFlusher.RenderLayer layer, Paint paint,
                                                        float alpha, MeshMesh mesh)
        {
            var mat = _stroke0Mat.getMaterial(paint.blendMode, layer.ignoreClip);

            _getShaderPassAndProps(layer, paint, mesh, alpha, out var pass, out var props);

            return(new PictureFlusher.RenderDraw {
                mesh = mesh,
                pass = pass,
                material = mat,
                properties = props,
            });
        }
コード例 #7
0
        public static PictureFlusher.CmdDraw texRT(PictureFlusher.RenderLayer layer, uiPaint paint,
                                                   uiMeshMesh mesh, PictureFlusher.RenderLayer renderLayer)
        {
            var mat = _texMat.getMaterial(paint.blendMode, layer.ignoreClip);

            _getShaderPassAndProps(layer, paint, mesh.matrix, 1.0f, 0.0f, out var pass, out var props);
            props.SetInt(_texModeId, 1); // pre alpha

            return(PictureFlusher.CmdDraw.create(
                       mesh: mesh,
                       pass: pass,
                       material: mat,
                       properties: props,
                       layerId: renderLayer.rtID
                       ));
        }
コード例 #8
0
        public static PictureFlusher.RenderDraw texRT(PictureFlusher.RenderLayer layer, Paint paint,
                                                      MeshMesh mesh, PictureFlusher.RenderLayer renderLayer)
        {
            var mat = _texMat.getMaterial(paint.blendMode, layer.ignoreClip);

            _getShaderPassAndProps(layer, paint, mesh, 1.0f, out var pass, out var props);
            props.SetInt("_texMode", 1); // pre alpha

            return(new PictureFlusher.RenderDraw {
                mesh = mesh,
                pass = pass,
                material = mat,
                properties = props,
                layer = renderLayer,
            });
        }
コード例 #9
0
        public static PictureFlusher.RenderDraw stencil1(PictureFlusher.RenderLayer layer, MeshMesh mesh)
        {
            Vector4 viewport = layer.viewport;
            var     mat      = _stencilMat;

            var pass  = 2;
            var props = new MaterialPropertyBlock();

            props.SetVector("_viewport", viewport);

            return(new PictureFlusher.RenderDraw {
                mesh = mesh,
                pass = pass,
                material = mat,
                properties = props,
            });
        }
コード例 #10
0
        public static PictureFlusher.CmdDraw stencil1(PictureFlusher.RenderLayer layer, uiMeshMesh mesh)
        {
            Vector4 viewport = layer.viewport;
            var     mat      = _stencilMat;

            var pass  = 2;
            var props = ObjectPool <MaterialPropertyBlockWrapper> .alloc();

            props.SetVector(_viewportId, viewport);

            return(PictureFlusher.CmdDraw.create(
                       mesh: mesh,
                       pass: pass,
                       material: mat,
                       properties: props
                       ));
        }
コード例 #11
0
        public static PictureFlusher.CmdDraw fill0(PictureFlusher.RenderLayer layer, uiMeshMesh mesh)
        {
            Vector4 viewport = layer.viewport;
            var     mat      = _fill0Mat.getMaterial(layer.ignoreClip);

            var pass  = 0;
            var props = ObjectPool <MaterialPropertyBlockWrapper> .alloc();

            props.SetVector(_viewportId, viewport);

            return(PictureFlusher.CmdDraw.create(
                       mesh: mesh,
                       pass: pass,
                       material: mat,
                       properties: props
                       ));
        }
コード例 #12
0
ファイル: canvas_shader.cs プロジェクト: zmtzawqlp/UIWidgets
        public static PictureFlusher.RenderDraw stroke0(PictureFlusher.RenderLayer layer, Paint paint,
                                                        float alpha, MeshMesh mesh)
        {
            Vector4 viewport = layer.viewport;
            Matrix3 ctm      = layer.states[layer.states.Count - 1].matrix;

            var mat = _stroke0Mat.getMaterial(paint.blendMode, layer.ignoreClip);

            _getShaderPassAndProps(viewport, ctm, paint, alpha, out var pass, out var props);

            return(new PictureFlusher.RenderDraw {
                mesh = mesh,
                pass = pass,
                material = mat,
                properties = props,
            });
        }
コード例 #13
0
ファイル: canvas_shader.cs プロジェクト: zmtzawqlp/UIWidgets
        public static PictureFlusher.RenderDraw fill1(PictureFlusher.RenderLayer layer, Paint paint,
                                                      MeshMesh mesh)
        {
            Vector4 viewport = layer.viewport;
            Matrix3 ctm      = layer.states[layer.states.Count - 1].matrix;

            var mat = _fill1Mat.getMaterial(paint.blendMode);

            _getShaderPassAndProps(viewport, ctm, paint, 1.0f, out var pass, out var props);

            return(new PictureFlusher.RenderDraw {
                mesh = mesh.boundsMesh,
                pass = pass,
                material = mat,
                properties = props,
            });
        }
コード例 #14
0
        public static PictureFlusher.RenderDraw texAlpha(PictureFlusher.RenderLayer layer, Paint paint,
                                                         MeshMesh mesh, Texture tex)
        {
            var mat = _texMat.getMaterial(paint.blendMode, layer.ignoreClip);

            _getShaderPassAndProps(layer, paint, mesh, 1.0f, out var pass, out var props);
            tex.filterMode = paint.filterMode;
            props.SetTexture("_tex", tex);
            props.SetInt("_texMode", 2); // alpha only

            return(new PictureFlusher.RenderDraw {
                mesh = mesh,
                pass = pass,
                material = mat,
                properties = props,
            });
        }
コード例 #15
0
        public static PictureFlusher.RenderDraw fill0(PictureFlusher.RenderLayer layer, MeshMesh mesh)
        {
            Vector4 viewport = layer.viewport;
            var     mat      = _fill0Mat.getMaterial(layer.ignoreClip);

            var pass  = 0;
            var props = new MaterialPropertyBlock();

            props.SetVector("_viewport", viewport);

            return(new PictureFlusher.RenderDraw {
                mesh = mesh,
                pass = pass,
                material = mat,
                properties = props,
            });
        }
コード例 #16
0
        public static PictureFlusher.CmdDraw fill1(PictureFlusher.RenderLayer layer, uiPaint paint,
                                                   uiMeshMesh mesh)
        {
            var mat = _fill1Mat.getMaterial(paint.blendMode);

            _getShaderPassAndProps(layer, paint, mesh.matrix, 1.0f, 0.0f, out var pass, out var props);

            var ret = PictureFlusher.CmdDraw.create(
                mesh: mesh.boundsMesh,
                pass: pass,
                material: mat,
                properties: props
                );

            ObjectPool <uiMeshMesh> .release(mesh);

            return(ret);
        }
コード例 #17
0
        public static PictureFlusher.CmdDraw tex(PictureFlusher.RenderLayer layer, uiPaint paint,
                                                 uiMeshMesh mesh, Image image)
        {
            var mat = _texMat.getMaterial(paint.blendMode, layer.ignoreClip);

            _getShaderPassAndProps(layer, paint, mesh.matrix, 1.0f, 0.0f, out var pass, out var props);

            image.texture.filterMode = paint.filterMode;
            props.SetTexture(_texId, image.texture);
            props.SetInt(_texModeId, image.texture is RenderTexture || image.isDynamic ? 1 : 0); // pre alpha if RT else post alpha

            return(PictureFlusher.CmdDraw.create(
                       mesh: mesh,
                       pass: pass,
                       material: mat,
                       properties: props,
                       image: image // keep a reference to avoid GC.
                       ));
        }
コード例 #18
0
ファイル: canvas_shader.cs プロジェクト: zmtzawqlp/UIWidgets
        public static PictureFlusher.RenderDraw texRT(PictureFlusher.RenderLayer layer, Paint paint,
                                                      MeshMesh mesh, PictureFlusher.RenderLayer renderLayer)
        {
            Vector4 viewport = layer.viewport;
            Matrix3 ctm      = layer.states[layer.states.Count - 1].matrix;

            var mat = _texMat.getMaterial(paint.blendMode, layer.ignoreClip);

            _getShaderPassAndProps(viewport, ctm, paint, 1.0f, out var pass, out var props);
            props.SetInt("_texMode", 1); // pre alpha

            return(new PictureFlusher.RenderDraw {
                mesh = mesh,
                pass = pass,
                material = mat,
                properties = props,
                layer = renderLayer,
            });
        }
コード例 #19
0
        public static PictureFlusher.RenderDraw tex(PictureFlusher.RenderLayer layer, Paint paint,
                                                    MeshMesh mesh, Image image)
        {
            var mat = _texMat.getMaterial(paint.blendMode, layer.ignoreClip);

            _getShaderPassAndProps(layer, paint, mesh, 1.0f, out var pass, out var props);

            image.texture.filterMode = paint.filterMode;
            props.SetTexture("_tex", image.texture);
            props.SetInt("_texMode", image.texture is RenderTexture ? 1 : 0); // pre alpha if RT else post alpha

            return(new PictureFlusher.RenderDraw {
                mesh = mesh,
                pass = pass,
                material = mat,
                properties = props,
                image = image, // keep a reference to avoid GC.
            });
        }
コード例 #20
0
        public static PictureFlusher.CmdDraw texAlpha(PictureFlusher.RenderLayer layer, uiPaint paint,
                                                      uiMeshMesh mesh, TextBlobMesh textMesh, Texture tex)
        {
            var mat        = _texMat.getMaterial(paint.blendMode, layer.ignoreClip);
            var meshMatrix = mesh != null ? mesh.matrix : textMesh.matrix;

            _getShaderPassAndProps(layer, paint, meshMatrix, 1.0f, 0.0f, out var pass, out var props);
            tex.filterMode = paint.filterMode;
            props.SetTexture(_texId, tex);
            props.SetInt(_texModeId, 2); // alpha only

            return(PictureFlusher.CmdDraw.create(
                       mesh: mesh,
                       textMesh: textMesh,
                       pass: pass,
                       material: mat,
                       properties: props
                       ));
        }
コード例 #21
0
ファイル: canvas_shader.cs プロジェクト: zmtzawqlp/UIWidgets
        public static PictureFlusher.RenderDraw texAlpha(PictureFlusher.RenderLayer layer, Paint paint,
                                                         MeshMesh mesh, Texture tex)
        {
            Vector4 viewport = layer.viewport;
            Matrix3 ctm      = layer.states[layer.states.Count - 1].matrix;

            var mat = _texMat.getMaterial(paint.blendMode, layer.ignoreClip);

            _getShaderPassAndProps(viewport, ctm, paint, 1.0f, out var pass, out var props);
            tex.filterMode = paint.filterMode;
            props.SetTexture("_tex", tex);
            props.SetInt("_texMode", 2); // alpha only

            return(new PictureFlusher.RenderDraw {
                mesh = mesh,
                pass = pass,
                material = mat,
                properties = props,
            });
        }
コード例 #22
0
        public static PictureFlusher.CmdDraw maskFilter(PictureFlusher.RenderLayer layer, uiMeshMesh mesh,
                                                        PictureFlusher.RenderLayer renderLayer, float radius, Vector2 imgInc, float[] kernel)
        {
            Vector4 viewport = layer.viewport;
            var     mat      = _filterMat;

            var pass  = 0;
            var props = ObjectPool <MaterialPropertyBlockWrapper> .alloc();

            props.SetVector(_viewportId, viewport);

            props.SetFloat(_mfRadiusId, radius);
            props.SetVector(_mfImgIncId, imgInc);
            props.SetFloatArray(_mfKernelId, kernel);

            return(PictureFlusher.CmdDraw.create(
                       mesh: mesh,
                       pass: pass,
                       material: mat,
                       properties: props,
                       layerId: renderLayer.rtID
                       ));
        }
コード例 #23
0
        public static PictureFlusher.RenderDraw maskFilter(PictureFlusher.RenderLayer layer, MeshMesh mesh,
                                                           PictureFlusher.RenderLayer renderLayer, float radius, Vector2 imgInc, float[] kernel)
        {
            Vector4 viewport = layer.viewport;
            var     mat      = _filterMat;

            var pass  = 0;
            var props = new MaterialPropertyBlock();

            props.SetVector("_viewport", viewport);

            props.SetFloat("_mf_radius", radius);
            props.SetVector("_mf_imgInc", imgInc);
            props.SetFloatArray("_mf_kernel", kernel);

            return(new PictureFlusher.RenderDraw {
                mesh = mesh,
                pass = pass,
                material = mat,
                properties = props,
                layer = renderLayer,
            });
        }
コード例 #24
0
 public static PictureFlusher.CmdDraw texAlpha(PictureFlusher.RenderLayer layer, uiPaint paint,
                                               uiMeshMesh mesh, Texture tex)
 {
     return(texAlpha(layer, paint, mesh, null, tex));
 }
コード例 #25
0
        static void _getShaderPassAndProps(
            PictureFlusher.RenderLayer layer, uiPaint paint, uiMatrix3?meshMatrix, float alpha, float strokeMult,
            out int pass, out MaterialPropertyBlockWrapper props)
        {
            Vector4 viewport = layer.viewport;

            props = ObjectPool <MaterialPropertyBlockWrapper> .alloc();

            props.SetVector(_viewportId, viewport);
            props.SetFloat(_alphaId, alpha);
            props.SetFloat(_strokeMultId, strokeMult);

            switch (paint.shader)
            {
            case null:
                pass = 0;
                props.SetVector(_colorId, _colorToVector4(paint.color));
                return;

            case _LinearGradient linear:
                pass = 1;
                props.SetMatrix(_shaderMatId, linear.getGradientMat(
                                    _getShaderMatBase(layer.currentState, meshMatrix)).toMatrix4x4());
                props.SetTexture(_shaderTexId, linear.gradientTex.texture);
                props.SetVector(_leftColorId, _colorToVector4(linear.leftColor));
                props.SetVector(_rightColorId, _colorToVector4(linear.rightColor));
                props.SetInt(_tileModeId, (int)linear.tileMode);
                return;

            case _RadialGradient radial:
                pass = 2;
                props.SetMatrix(_shaderMatId, radial.getGradientMat(
                                    _getShaderMatBase(layer.currentState, meshMatrix)).toMatrix4x4());
                props.SetTexture(_shaderTexId, radial.gradientTex.texture);
                props.SetVector(_leftColorId, _colorToVector4(radial.leftColor));
                props.SetVector(_rightColorId, _colorToVector4(radial.rightColor));
                props.SetInt(_tileModeId, (int)radial.tileMode);
                return;

            case _SweepGradient sweep:
                pass = 3;
                props.SetMatrix(_shaderMatId, sweep.getGradientMat(
                                    _getShaderMatBase(layer.currentState, meshMatrix)).toMatrix4x4());
                props.SetTexture(_shaderTexId, sweep.gradientTex.texture);
                props.SetVector(_leftColorId, _colorToVector4(sweep.leftColor));
                props.SetVector(_rightColorId, _colorToVector4(sweep.rightColor));
                props.SetInt(_tileModeId, (int)sweep.tileMode);
                props.SetFloat(_biasId, sweep.bias);
                props.SetFloat(_scaleId, sweep.scale);
                return;

            case ImageShader image:
                pass = 4;
                props.SetMatrix(_shaderMatId, image.getShaderMat(
                                    _getShaderMatBase(layer.currentState, meshMatrix)).toMatrix4x4());
                props.SetTexture(_shaderTexId, image.image.texture);
                props.SetInt(_tileModeId, (int)image.tileMode);
                return;

            default:
                throw new Exception("Unknown paint.shader: " + paint.shader);
            }
        }
コード例 #26
0
 public static PictureFlusher.RenderDraw texAlpha(PictureFlusher.RenderLayer layer, Paint paint,
                                                  TextBlobMesh textMesh, Texture tex)
 {
     return(texAlpha(layer, paint, null, textMesh, tex));
 }
コード例 #27
0
        static void _getShaderPassAndProps(
            PictureFlusher.RenderLayer layer, Paint paint, MeshMesh mesh, float alpha,
            out int pass, out MaterialPropertyBlock props)
        {
            Vector4 viewport = layer.viewport;

            props = new MaterialPropertyBlock();
            props.SetVector("_viewport", viewport);
            props.SetFloat("_alpha", alpha);

            switch (paint.shader)
            {
            case null:
                pass = 0;
                props.SetVector("_color", _colorToVector4(paint.color));
                return;

            case _LinearGradient linear:
                pass = 1;
                props.SetMatrix("_shaderMat", linear.getGradientMat(
                                    _getShaderMatBase(layer.currentState, mesh.matrix)).toMatrix4x4());
                props.SetTexture("_shaderTex", linear.gradientTex.texture);
                props.SetVector("_leftColor", _colorToVector4(linear.leftColor));
                props.SetVector("_rightColor", _colorToVector4(linear.rightColor));
                props.SetInt("_tileMode", (int)linear.tileMode);
                return;

            case _RadialGradient radial:
                pass = 2;
                props.SetMatrix("_shaderMat", radial.getGradientMat(
                                    _getShaderMatBase(layer.currentState, mesh.matrix)).toMatrix4x4());
                props.SetTexture("_shaderTex", radial.gradientTex.texture);
                props.SetVector("_leftColor", _colorToVector4(radial.leftColor));
                props.SetVector("_rightColor", _colorToVector4(radial.rightColor));
                props.SetInt("_tileMode", (int)radial.tileMode);
                return;

            case _SweepGradient sweep:
                pass = 3;
                props.SetMatrix("_shaderMat", sweep.getGradientMat(
                                    _getShaderMatBase(layer.currentState, mesh.matrix)).toMatrix4x4());
                props.SetTexture("_shaderTex", sweep.gradientTex.texture);
                props.SetVector("_leftColor", _colorToVector4(sweep.leftColor));
                props.SetVector("_rightColor", _colorToVector4(sweep.rightColor));
                props.SetInt("_tileMode", (int)sweep.tileMode);
                props.SetFloat("_bias", sweep.bias);
                props.SetFloat("_scale", sweep.scale);
                return;

            case ImageShader image:
                pass = 4;
                props.SetMatrix("_shaderMat", image.getShaderMat(
                                    _getShaderMatBase(layer.currentState, mesh.matrix)).toMatrix4x4());
                props.SetTexture("_shaderTex", image.image.texture);
                props.SetInt("_tileMode", (int)image.tileMode);
                return;

            default:
                throw new Exception("Unknown paint.shader: " + paint.shader);
            }
        }