예제 #1
0
        PictureLayer _highlightConflictingLayer(PhysicalModelLayer child)
        {
            PictureRecorder recorder = new PictureRecorder();
            var             canvas   = new RecorderCanvas(recorder);

            canvas.drawPath(child.clipPath, new Paint()
            {
                color       = new Color(0xFFAA0000),
                style       = PaintingStyle.stroke,
                strokeWidth = child.elevation + 10.0f,
            });
            PictureLayer pictureLayer = new PictureLayer(child.clipPath.getBounds());

            pictureLayer.picture      = recorder.endRecording();
            pictureLayer.debugCreator = child;
            child.append(pictureLayer);
            return(pictureLayer);
        }
예제 #2
0
 List <PictureLayer> _processConflictingPhysicalLayers(PhysicalModelLayer predecessor, PhysicalModelLayer child)
 {
     UIWidgetsError.reportError(new UIWidgetsErrorDetails(
                                    exception: new UIWidgetsError("Painting order is out of order with respect to elevation.\n" +
                                                                  "See https://api.flutter.dev/flutter/rendering/debugCheckElevations.html " +
                                                                  "for more details."),
                                    context: "during compositing",
                                    informationCollector: (StringBuilder builder) => {
         builder.AppendLine("Attempted to composite layer");
         builder.AppendLine(child.ToString());
         builder.AppendLine("after layer");
         builder.AppendLine(predecessor.ToString());
         builder.AppendLine("which occupies the same area at a higher elevation.");
     }
                                    ));
     return(new List <PictureLayer> {
         this._highlightConflictingLayer(predecessor),
         this._highlightConflictingLayer(child)
     });
 }
예제 #3
0
        protected List <PictureLayer> _debugCheckElevations()
        {
            List <PhysicalModelLayer> physicalModelLayers =
                this.depthFirstIterateChildren().OfType <PhysicalModelLayer>().ToList();
            List <PictureLayer> addedLayers = new List <PictureLayer>();

            for (int i = 0; i < physicalModelLayers.Count; i++)
            {
                PhysicalModelLayer physicalModelLayer = physicalModelLayers[i];
                D.assert(physicalModelLayer.lastChild?.debugCreator != physicalModelLayer,
                         () => "debugCheckElevations has either already visited this layer or failed to remove the" +
                         " added picture from it.");
                float accumulatedElevation = physicalModelLayer.elevation;
                Layer ancestor             = physicalModelLayer.parent;
                while (ancestor != null)
                {
                    if (ancestor is PhysicalModelLayer modelLayer)
                    {
                        accumulatedElevation += modelLayer.elevation;
                    }

                    ancestor = ancestor.parent;
                }

                for (int j = 0; j <= i; j++)
                {
                    PhysicalModelLayer predecessor        = physicalModelLayers[j];
                    float predecessorAccumulatedElevation = predecessor.elevation;
                    ancestor = predecessor.parent;
                    while (ancestor != null)
                    {
                        if (ancestor == predecessor)
                        {
                            continue;
                        }

                        if (ancestor is PhysicalModelLayer modelLayer)
                        {
                            predecessorAccumulatedElevation += modelLayer.elevation;
                        }

                        ancestor = ancestor.parent;
                    }

                    if (predecessorAccumulatedElevation <= accumulatedElevation)
                    {
                        continue;
                    }

                    Path intersection = Path.combine(
                        PathOperation.intersect,
                        predecessor._debugTransformedClipPath,
                        physicalModelLayer._debugTransformedClipPath);

                    if (intersection != null && intersection.computeMetrics().Any((metric) => metric.length > 0))
                    {
                        addedLayers.AddRange(this._processConflictingPhysicalLayers(predecessor, physicalModelLayer));
                    }
                }
            }

            return(addedLayers);
        }