示例#1
0
        protected internal override Lime.RenderObject GetRenderObject()
        {
            var ro = RenderObjectPool <RenderObject> .Acquire();

            ro.CaptureRenderState(this);
            ro.Texture = Texture;
            for (var n = FirstChild; n != null; n = n.NextSibling)
            {
                var p = (DistortionMeshPoint)n;
                ro.Vertices.Add(new Vertex {
                    Pos   = p.TransformedPosition,
                    Color = p.Color * GlobalColor,
                    UV1   = p.UV
                });
            }
            for (int i = 0; i < NumRows; ++i)
            {
                for (int j = 0; j < NumCols; ++j)
                {
                    var t = i * (NumCols + 1) + j;
                    ro.Indices.Add(t);
                    ro.Indices.Add(t + NumCols + 1);
                    ro.Indices.Add(t + NumCols + 2);
                    ro.Indices.Add(t + 1);
                }
            }
            return(ro);
        }
示例#2
0
        protected internal override Lime.RenderObject GetRenderObject()
        {
            var blending = GlobalBlending;
            var shader   = GlobalShader;

            if (material == null)
            {
                material = WidgetMaterial.GetInstance(blending, shader, 1);
            }
            var UV1 = new Vector2 {
                X = Size.X / texture.ImageSize.Width * TileRatio.X + TileOffset.X,
                Y = Size.Y / texture.ImageSize.Height * TileRatio.Y + TileOffset.Y
            };

            if (TileRounding)
            {
                UV1.X = (float)Math.Truncate(UV1.X);
                UV1.Y = (float)Math.Truncate(UV1.Y);
            }
            var ro = RenderObjectPool <RenderObject> .Acquire();

            ro.CaptureRenderState(this);
            ro.Texture    = Texture;
            ro.Material   = CustomMaterial ?? material;
            ro.TileOffset = TileOffset;
            ro.UV1        = UV1;
            ro.Color      = GlobalColor;
            ro.Position   = ContentPosition;
            ro.Size       = ContentSize;
            return(ro);
        }
示例#3
0
        public Lime.RenderObject GetRenderObject(Node node)
        {
            if (!selectionStart.IsVisible || !selectionEnd.IsVisible)
            {
                return(null);
            }
            var s = selectionStart.WorldPos;
            var e = selectionEnd.WorldPos;

            if (s == e)
            {
                return(null);
            }
            if (s.Y > e.Y || s.Y == e.Y && s.X > e.X)
            {
                var t = s;
                s = e;
                e = t;
            }
            var text = (SimpleText)node;
            var ro   = RenderObjectPool <RenderObject> .Acquire();

            ro.CaptureRenderState(text);
            ro.SelectionStart   = s;
            ro.SelectionEnd     = e;
            ro.OutlineThickness = selectionParams.OutlineThickness;
            ro.OutlineColor     = selectionParams.OutlineColor;
            ro.Color            = selectionParams.Color;
            ro.Padding          = selectionParams.Padding;
            ro.Bounds           = text.MeasureText().ShrinkedBy(new Thickness(selectionParams.OutlineThickness));
            ro.FontHeight       = text.FontHeight;
            return(ro);
        }
示例#4
0
        protected internal override Lime.RenderObject GetRenderObject()
        {
            if (Parent.AsWidget == null)
            {
                return(null);
            }
            IImageCombinerArg arg1, arg2;

            if (!GetArgs(out arg1, out arg2))
            {
                return(null);
            }
            if (!arg1.GloballyVisible || !arg2.GloballyVisible)
            {
                return(null);
            }
            var texture1 = arg1.GetTexture();
            var texture2 = arg2.GetTexture();

            if (texture1 == null || texture2 == null)
            {
                return(null);
            }
            var ro = RenderObjectPool <RenderObject> .Acquire();

            ro.Arg12CommonMaterial = CustomMaterial;
            ro.Arg1Material        = CustomMaterial;
            if (ro.Arg1Material == null)
            {
                var shader = Shader == ShaderId.Inherited ? Parent.AsWidget.GlobalShader : Shader;
                if (arg2.Shader == ShaderId.Silhuette)
                {
                    shader = ShaderId.Silhuette;
                }
                else if (arg1.Shader == ShaderId.Silhuette)
                {
                    shader = ShaderId.Silhuette;
                    Toolbox.Swap(ref arg1, ref arg2);
                    Toolbox.Swap(ref texture1, ref texture2);
                }
                var blending = Blending == Blending.Inherited ? Parent.AsWidget.GlobalBlending : Blending;
                ro.Arg1Material        = WidgetMaterial.GetInstance(blending, shader, WidgetMaterial.GetNumTextures(texture1, null));
                ro.Arg12CommonMaterial = WidgetMaterial.GetInstance(
                    blending, shader, WidgetMaterial.GetNumTextures(texture1, texture2),
                    Operation == ImageCombinerOperation.Multiply ? TextureBlending.Multiply : TextureBlending.CutOut);
            }
            ro.Arg1Texture           = texture1;
            ro.Arg2Texture           = texture2;
            ro.Operation             = Operation;
            ro.Arg1Transform         = Matrix32.Scaling(arg1.Size) * arg1.CalcLocalToParentTransform();
            ro.Arg2Transform         = Matrix32.Scaling(arg2.Size) * arg2.CalcLocalToParentTransform();
            ro.Arg1UVTransform       = arg1.UVTransform;
            ro.Arg2UVTransform       = arg2.UVTransform;
            ro.LocalToWorldTransform = Parent.AsWidget.LocalToWorldTransform;
            ro.Color = arg1.Color * arg2.Color * Parent.AsWidget.GlobalColor;
            return(ro);
        }
示例#5
0
        protected internal override Lime.RenderObject GetRenderObject()
        {
            var ro = RenderObjectPool <RenderObject> .Acquire();

            ro.CaptureRenderState(this);
            ro.Texture = movieTexture;
            ro.Color   = GlobalColor;
            ro.Size    = Size;
            return(ro);
        }
示例#6
0
        public Lime.RenderObject GetRenderObject(Node node)
        {
            var widget = (Widget)node;
            var ro     = RenderObjectPool <RenderObject> .Acquire();

            ro.CaptureRenderState(widget);
            ro.Size  = widget.Size;
            ro.Color = Theme.Colors.GrayBackground;
            return(ro);
        }
示例#7
0
            public Lime.RenderObject GetRenderObject(Node node)
            {
                var widget = (Widget)node;
                var ro     = RenderObjectPool <RenderObject> .Acquire();

                ro.CaptureRenderState(widget);
                ro.Color = active || widget.IsMouseOverThisOrDescendant() ? Theme.Colors.TabActive : Theme.Colors.TabNormal;
                ro.Size  = widget.Size;
                return(ro);
            }
示例#8
0
        public Lime.RenderObject GetRenderObject(Node node)
        {
            var widget = (Widget)node;
            var ro     = RenderObjectPool <RenderObject> .Acquire();

            ro.CaptureRenderState(widget);
            ro.Size        = widget.Size;
            ro.InnerColor  = widget.GloballyEnabled ? innerColor : Theme.Colors.DisabledBackground;
            ro.BorderColor = borderColor;
            return(ro);
        }
示例#9
0
        protected internal override Lime.RenderObject GetRenderObject()
        {
            EnsureSpriteList();
            var ro = RenderObjectPool <RenderObject> .Acquire();

            ro.CaptureRenderState(this);
            ro.SpriteList         = spriteList;
            ro.GradientMapIndices = gradientMapIndices;
            ro.Color = GlobalColor;
            return(ro);
        }
示例#10
0
        public Lime.RenderObject GetRenderObject(Node node)
        {
            var widget = (Widget)node;
            var ro     = RenderObjectPool <RenderObject> .Acquire();

            ro.CaptureRenderState(widget);
            ro.Size  = widget.Size;
            ro.Color = color;
            ro.Shape = Shape;
            return(ro);
        }
示例#11
0
            public virtual Lime.RenderObject GetRenderObject(Node node)
            {
                var widget = (Widget)node;
                var ro     = RenderObjectPool <RenderObject> .Acquire();

                ro.CaptureRenderState(widget);
                ro.Size        = widget.Size;
                ro.Gradient    = innerGradient;
                ro.BorderColor = Theme.Colors.ControlBorder;
                return(ro);
            }
示例#12
0
            public Lime.RenderObject GetRenderObject(Node node)
            {
                var splitter = (Splitter)node;
                var ro       = RenderObjectPool <RenderObject> .Acquire();

                ro.CaptureRenderState(splitter);
                ro.SeparatorWidth = splitter.SeparatorWidth;
                ro.SeparatorColor = splitter.SeparatorColor;
                GetLines(splitter, ro.Lines);
                return(ro);
            }
示例#13
0
        protected internal override Lime.RenderObject GetRenderObject()
        {
            PrepareSpriteListAndSyncCaret();
            var ro = RenderObjectPool <RenderObject> .Acquire();

            ro.CaptureRenderState(this);
            ro.SpriteList       = spriteList;
            ro.GradientMapIndex = GradientMapIndex;
            ro.RenderMode       = RenderMode;
            ro.Color            = GlobalColor * textColor;
            return(ro);
        }
示例#14
0
            public Lime.RenderObject GetRenderObject(Node node)
            {
                var dd = (CommonDropDownList)node;
                var ro = RenderObjectPool <RenderObject> .Acquire();

                ro.CaptureRenderState(dd);
                ro.Size        = dd.Size;
                ro.Gradient    = Theme.Colors.ButtonDefault;
                ro.BorderColor = Theme.Colors.ControlBorder;
                ro.IconColor   = dd.Items.Count > 0 ? Theme.Colors.BlackText : Theme.Colors.GrayText;
                return(ro);
            }
示例#15
0
            public Lime.RenderObject GetRenderObject(Node node)
            {
                var widget = (Widget)node;
                var ro     = RenderObjectPool <RenderObject> .Acquire();

                ro.CaptureRenderState(widget);
                ro.Size            = widget.Size;
                ro.BackgroundColor = Theme.Colors.WhiteBackground;
                ro.BorderColor     = Theme.Colors.ControlBorder;
                ro.CheckBoxSize    = Theme.Metrics.CheckBoxSize;
                ro.State           = checkBox.State;
                return(ro);
            }
示例#16
0
        public Lime.RenderObject GetRenderObject(Node node)
        {
            var ro = RenderObjectPool <RenderObject> .Acquire();

            for (var i = Count - 1; i >= 0; i--)
            {
                var obj = this[i].GetRenderObject(node);
                if (obj != null)
                {
                    ro.Objects.Add(obj);
                }
            }
            return(ro);
        }
示例#17
0
        public Lime.RenderObject GetRenderObject(Node node)
        {
            var ro = RenderObjectPool <RenderObject> .Acquire();

            var prevRenderer = RendererWrapper.Current;

            RendererWrapper.Current = ro.Renderer;
            try {
                Render(node);
            } finally {
                RendererWrapper.Current = prevRenderer;
            }
            return(ro);
        }
示例#18
0
        protected internal override Lime.RenderObject GetRenderObject()
        {
            var ro = RenderObjectPool <RenderObject> .Acquire();

            ro.CaptureRenderState(this);
            ro.Texture      = Texture;
            ro.LeftOffset   = LeftOffset;
            ro.RightOffset  = RightOffset;
            ro.TopOffset    = TopOffset;
            ro.BottomOffset = BottomOffset;
            ro.Size         = Size;
            ro.Color        = GlobalColor;
            return(ro);
        }
示例#19
0
            public Lime.RenderObject GetRenderObject(Node node)
            {
                var widget = (Widget)node;

                if (widget.GloballyEnabled && widget.IsMouseOverThisOrDescendant())
                {
                    var ro = RenderObjectPool <RenderObject> .Acquire();

                    ro.CaptureRenderState(widget);
                    ro.Size  = widget.Size;
                    ro.Color = Colors.KeyboardFocusBorder;
                    return(ro);
                }
                return(null);
            }
示例#20
0
文件: Frame.cs 项目: x5f3759df/Citrus
        protected internal override Lime.RenderObject GetRenderObject()
        {
            if (renderTexture == null && ClipChildren != ClipMethod.ScissorTest && ClipChildren != ClipMethod.StencilTest)
            {
                return(null);
            }
            var ro = RenderObjectPool <RenderObject> .Acquire();

            ro.CaptureRenderState(this);
            ro.RenderTexture = renderTexture;
            ro.FrameSize     = Size;
            ro.ScissorTest   = ro.StencilTest = false;
            var clipBy     = ClipByWidget ?? this;
            var clipRegion = RenderChain.DefaultClipRegion;

            ro.ClipByLocalToWorld = clipBy.LocalToWorldTransform;
            ro.ClipBySize         = clipBy.Size;
            if (renderTexture != null)
            {
                // TODO: Implement clipping, for now disable it.
                clipRegion = RenderChain.DefaultClipRegion;
                if (GetTangerineFlag(TangerineFlags.DisplayContent))
                {
                    ro.ScissorTest = true;
                }
            }
            else if (ClipChildren == ClipMethod.ScissorTest)
            {
                ro.ScissorTest = true;
                clipRegion     = CalcGlobalBoundingRect();
            }
            else if (ClipChildren == ClipMethod.StencilTest)
            {
                ro.StencilTest = true;
                ro.StencilRect = new Rectangle(clipBy.ContentPosition, clipBy.ContentPosition + clipBy.ContentSize);
                clipRegion     = RenderChain.DefaultClipRegion;
            }
            EnsureRenderChain();
            renderChain.Clear();
            renderChain.ClipRegion = clipRegion;
            foreach (var node in Nodes)
            {
                node.RenderChainBuilder?.AddToRenderChain(renderChain);
            }
            renderChain.GetRenderObjects(ro.Objects);
            return(ro);
        }
示例#21
0
        protected internal override Lime.RenderObject GetRenderObject()
        {
            EnsureSpriteLists();
            var ro = RenderObjectPool <RenderObject> .Acquire();

            //ro.CaptureRenderState causes RichText invalidation on every frame,
            //so use local values for blending and shader
            ro.LocalToWorldTransform = LocalToWorldTransform;
            ro.Blending = Blending;
            ro.Shader   = Shader;
            ro.Objects  = new RenderObjectList();
            var scale = Mathf.Sqrt(Math.Max(LocalToWorldTransform.U.SqrLength, LocalToWorldTransform.V.SqrLength));

            for (int i = 0; i < renderer.Styles.Count; i++)
            {
                var style        = renderer.Styles[i];
                var sdfComponent = style.Components.Get <SignedDistanceFieldComponent>();
                if (sdfComponent != null)
                {
                    var sdfRO = sdfComponent.GetRenderObject();
                    foreach (var obj in sdfRO.Objects)
                    {
                        obj.SpriteList            = spriteLists[i];
                        obj.Color                 = GlobalColor;
                        obj.LocalToWorldTransform = LocalToWorldTransform;
                        obj.Shader                = Shader;
                        obj.Blending              = Blending;
                    }
                    ro.Objects.Add(sdfRO);
                }
                else
                {
                    var styleRO = RenderObjectPool <TextRenderObject> .Acquire();

                    styleRO.SpriteList            = spriteLists[i];
                    styleRO.RenderMode            = TextRenderingMode.TwoPasses;
                    styleRO.Color                 = GlobalColor;
                    styleRO.GradientMapIndex      = style.GradientMapIndex;
                    styleRO.LocalToWorldTransform = LocalToWorldTransform;
                    styleRO.Shader                = Shader;
                    styleRO.Blending              = Blending;
                    ro.Objects.Add(styleRO);
                }
            }
            return(ro);
        }
示例#22
0
        public Lime.RenderObject GetRenderObject(Node node)
        {
            if (!Visible)
            {
                return(null);
            }
            var text = (SimpleText)node;
            var ro   = RenderObjectPool <RenderObject> .Acquire();

            ro.CaptureRenderState(text);
            ro.Position   = Position;
            ro.Color      = Color;
            ro.Thickness  = Thickness;
            ro.Width      = Width;
            ro.FontHeight = text.FontHeight;
            return(ro);
        }
示例#23
0
文件: Mesh3D.cs 项目: aologos/Citrus
        protected internal override Lime.RenderObject GetRenderObject()
        {
            if (SkipRender)
            {
                return(null);
            }
            var ro = RenderObjectPool <RenderObject> .Acquire();

            ro.World            = GlobalTransform;
            ro.WorldInverse     = GlobalTransformInverse;
            ro.CullMode         = CullMode;
            ro.ColorFactor      = GlobalColor;
            ro.Opaque           = Opaque;
            ro.DistanceToCamera = CalcDistanceToCamera(Viewport.Camera);
            var totalBoneCount = 0;

            foreach (var submesh in Submeshes)
            {
                totalBoneCount += submesh.Bones.Count;
            }
            if (ro.Bones == null || ro.Bones.Length < totalBoneCount)
            {
                ro.Bones         = new Matrix44[totalBoneCount];
                ro.BoneBindPoses = new Matrix44[totalBoneCount];
            }
            var firstBone = 0;

            foreach (var submesh in Submeshes)
            {
                for (var i = 0; i < submesh.Bones.Count; i++)
                {
                    ro.Bones[firstBone + i]         = submesh.Bones[i].GlobalTransform;
                    ro.BoneBindPoses[firstBone + i] = submesh.BoneBindPoses[i];
                }
                ro.Meshes.Add(submesh.Mesh);
                ro.Materials.Add(submesh.Material);
                ro.Submeshes.Add(new SubmeshRenderData {
                    Mesh      = ro.Meshes.Count - 1,
                    Material  = ro.Materials.Count - 1,
                    FirstBone = firstBone,
                    BoneCount = submesh.Bones.Count
                });
                firstBone += submesh.Bones.Count;
            }
            return(ro);
        }
示例#24
0
        protected internal override Lime.RenderObject GetRenderObject()
        {
            if (Camera == null)
            {
                return(null);
            }
            AdjustCameraAspectRatio();
            var ro = RenderObjectPool <RenderObject> .Acquire();

            ro.Width      = Width;
            ro.Height     = Height;
            ro.Transform  = LocalToWorldTransform;
            ro.View       = Camera.View;
            ro.Projection = Camera.Projection;
            try {
                foreach (var node in Nodes)
                {
                    node.RenderChainBuilder?.AddToRenderChain(renderChain);
                }
                for (var i = 0; i < RenderChain.LayerCount; i++)
                {
                    var layer = renderChain.Layers[i];
                    if (layer == null || layer.Count == 0)
                    {
                        continue;
                    }
                    var first = ro.Objects.Count;
                    foreach (var item in layer)
                    {
                        var renderObject = item.Presenter.GetRenderObject(item.Node);
                        if (renderObject != null)
                        {
                            ro.Objects.Add(renderObject);
                        }
                    }
                    ro.Layers.Add(new RenderLayer {
                        FirstObject = first,
                        ObjectCount = ro.Objects.Count - first
                    });
                }
            } finally {
                renderChain.Clear();
            }
            return(ro);
        }
示例#25
0
            public Lime.RenderObject GetRenderObject(Node node)
            {
                var slider = (Widget)node;
                var ro     = RenderObjectPool <RenderObject> .Acquire();

                ro.ScrollViewTransform = scrollView.LocalToWorldTransform;
                ro.ScrollViewBlending  = scrollView.GlobalBlending;
                ro.ScrollViewShader    = scrollView.GlobalShader;
                ro.ScrollViewSize      = scrollView.Size;
                ro.SliderTransform     = slider.LocalToWorldTransform;
                ro.SliderBlending      = slider.GlobalBlending;
                ro.SliderShader        = slider.GlobalShader;
                ro.SliderSize          = slider.Size;
                ro.BackgroundColor     = Theme.Colors.ScrollbarBackground;
                ro.ThumbColor          = Theme.Colors.ScrollbarThumb;
                ro.Direction           = scrollView.Direction;
                return(ro);
            }
示例#26
0
        public Lime.RenderObject GetRenderObject(Node node)
        {
            var widget = node as Widget;

            if (widget == null || widget.Layout == null)
            {
                return(null);
            }
            var ro = RenderObjectPool <RenderObject> .Acquire();

            ro.CaptureRenderState(widget);
            ro.Color     = Color;
            ro.Thickness = Thickness > 0 ? Thickness : 1 / CommonWindow.Current.PixelScale;
            foreach (var r in widget.Layout.DebugRectangles)
            {
                ro.DebugRectangles.Add(r);
            }
            return(ro);
        }
示例#27
0
        public Lime.RenderObject GetRenderObject(Node node)
        {
            var widget = (Widget)node;
            var ro     = RenderObjectPool <RenderObject> .Acquire();

            ro.CaptureRenderState(widget);
            ro.Color = Color * widget.GlobalColor;
            if (IgnorePadding)
            {
                ro.Position = Vector2.Zero;
                ro.Size     = widget.Size;
            }
            else
            {
                ro.Position = widget.ContentPosition;
                ro.Size     = widget.ContentSize;
            }
            return(ro);
        }
示例#28
0
        protected internal override Lime.RenderObject GetRenderObject()
        {
            var blending = GlobalBlending;
            var shader   = GlobalShader;

            if (material == null)
            {
                material = WidgetMaterial.GetInstance(blending, shader, 1);
            }
            var ro = RenderObjectPool <RenderObject> .Acquire();

            ro.Texture  = Texture;
            ro.Material = CustomMaterial ?? material;
            ro.UV0      = UV0;
            ro.UV1      = UV1;
            ro.LocalToWorldTransform = LocalToWorldTransform;
            ro.Position = ContentPosition;
            ro.Size     = ContentSize;
            ro.Color    = GlobalColor;
            return(ro);
        }
示例#29
0
        protected internal override Lime.RenderObject GetRenderObject()
        {
            var ro = RenderObjectPool <RenderObject> .Acquire();

            ro.CaptureRenderState(this);
            var t = Matrix32.Identity;

            if (StaticThickness)
            {
                t = ro.LocalToWorldTransform;
                ro.LocalToWorldTransform = Matrix32.Identity;
            }
            ro.Vertices.Clear();
            foreach (PolylinePoint point in Nodes)
            {
                ro.Vertices.Add(StaticThickness ? point.TransformedPosition * t : point.TransformedPosition);
            }
            ro.Color     = GlobalColor;
            ro.Thickness = Thickness;
            ro.Closed    = Closed;
            return(ro);
        }
示例#30
0
        protected internal override Lime.RenderObject GetRenderObject()
        {
            var ro = RenderObjectPool <RenderObject> .Acquire();

            var basicWidget = GetBasicWidget();

            if (basicWidget != null)
            {
                ro.Matrix = basicWidget.LocalToWorldTransform;
                ro.Color  = basicWidget.GlobalColor;
            }
            else
            {
                ro.Matrix = Matrix32.Identity;
                ro.Color  = Color4.White;
            }
            ro.Blending = GlobalBlending;
            ro.Shader   = GlobalShader;
            foreach (var p in particles)
            {
                if (p.ColorCurrent.A <= 0)
                {
                    continue;
                }
                var angle = p.Angle;
                if (AlongPathOrientation)
                {
                    angle += p.FullDirection;
                }
                ro.Particles.Add(new ParticleRenderData {
                    Texture   = p.Modifier.GetTexture((int)p.TextureIndex - 1),
                    Transform = p.Transform,
                    Color     = p.ColorCurrent,
                    Angle     = angle
                });
            }
            return(ro);
        }