コード例 #1
0
 private void ResetTransform(Transform transform, DecorationSettings setting)
 {
     transform.localPosition = setting.position;
 }
コード例 #2
0
        private void RasterizePass(
            ref UIOperationContext context,
            ref DecorationSettings settings, IDecorator decorations,
            bool compositing, ref RasterizePassSet passSet,
            ref ImperativeRenderer renderer, RasterizePasses pass
            )
        {
            UIOperationContext passContext;

            context.Clone(out passContext);
            passContext.Pass = pass;
            var hasNestedContext = (pass == RasterizePasses.Content) &&
                                   (ShouldClipContent || (HasChildren && CreateNestedContextForChildren));

            if (hasNestedContext)
            {
                UpdateVisibleRegion(ref passContext, ref settings.Box);
            }

            // FIXME: The memset for these actually burns a measurable amount of time
            ImperativeRenderer contentRenderer;
            RasterizePassSet   childrenPassSet;
            UIOperationContext contentContext;

            int previousStackDepth = passSet.StackDepth, newStackDepth = previousStackDepth;

            // For clipping we need to create a separate batch group that contains all the rasterization work
            //  for our children. At the start of it we'll generate the stencil mask that will be used for our
            //  rendering operation(s).
            if (hasNestedContext)
            {
                NestedContextPassSetup(
                    ref context, ref passSet, ref renderer, ref passContext,
                    out contentRenderer, out childrenPassSet, out contentContext,
                    previousStackDepth, ref newStackDepth
                    );
            }
            else
            {
                contentContext  = passContext;
                childrenPassSet = default;
                contentRenderer = default;
            }

            // TODO: all the copying of settings here burns CPU time

            if (HasPreRasterizeHandler && (pass == RasterizePasses.Content))
            {
                OnPreRasterize(ref contentContext, settings, decorations);
            }

            if (hasNestedContext)
            {
                OnRasterize(ref contentContext, ref contentRenderer, settings, decorations);
            }
            else
            {
                OnRasterize(ref contentContext, ref renderer, settings, decorations);
            }

            if ((pass == RasterizePasses.Content) && HasChildren)
            {
                if (hasNestedContext)
                {
                    OnRasterizeChildren(ref contentContext, ref childrenPassSet, settings);
                }
                else
                {
                    // FIXME: Save/restore layers?
                    OnRasterizeChildren(ref contentContext, ref passSet, settings);
                }
            }

            if (hasNestedContext)
            {
                // GROSS OPTIMIZATION HACK: Detect that any rendering operation(s) occurred inside the
                //  group and if so, set up the stencil mask so that they will be clipped.
                if (ShouldClipContent && !contentRenderer.Container.IsEmpty)
                {
                    NestedContextPassTeardown(
                        ref context, ref settings, decorations, ref passSet,
                        ref contentRenderer, ref contentContext, previousStackDepth
                        );
                }

                renderer.Layer += 1;
            }
        }
コード例 #3
0
 protected virtual void OnRasterize(ref UIOperationContext context, ref ImperativeRenderer renderer, DecorationSettings settings, IDecorator decorations)
 {
     decorations?.Rasterize(ref context, ref renderer, settings);
 }
コード例 #4
0
 protected virtual void OnRasterizeChildren(ref UIOperationContext context, ref RasterizePassSet passSet, DecorationSettings settings)
 {
 }
コード例 #5
0
 protected virtual void OnPreRasterize(ref UIOperationContext context, DecorationSettings settings, IDecorator decorations)
 {
     UpdateAnimation(context.NowL);
 }