Ver código fonte

Removed old caching approach

Marcin Ziąbek 1 ano atrás
pai
commit
a8a0f00b66

+ 0 - 12
Source/QuestPDF/Drawing/DocumentGenerator.cs

@@ -176,9 +176,6 @@ namespace QuestPDF.Drawing
             content.ApplyInheritedAndGlobalTexStyle(TextStyle.Default);
             content.ApplyInheritedAndGlobalTexStyle(TextStyle.Default);
             content.ApplyContentDirection(settings.ContentDirection);
             content.ApplyContentDirection(settings.ContentDirection);
             content.ApplyDefaultImageConfiguration(settings.ImageRasterDpi, settings.ImageCompressionQuality, useOriginalImages);
             content.ApplyDefaultImageConfiguration(settings.ImageRasterDpi, settings.ImageCompressionQuality, useOriginalImages);
-                    
-            if (Settings.EnableCaching)
-                content.ApplyCaching();
             
             
             return content;
             return content;
         }
         }
@@ -295,15 +292,6 @@ namespace QuestPDF.Drawing
             });
             });
         }
         }
 
 
-        private static void ApplyCaching(this Container content)
-        {
-            content.VisitChildren(x =>
-            {
-                if (x is ICacheable)
-                    x.CreateProxy(y => new CacheProxy(y));
-            });
-        }
-
         internal static void ApplyContentDirection(this Element? content, ContentDirection? direction = null)
         internal static void ApplyContentDirection(this Element? content, ContentDirection? direction = null)
         {
         {
             if (content == null)
             if (content == null)

+ 0 - 45
Source/QuestPDF/Drawing/Proxy/CacheProxy.cs

@@ -1,45 +0,0 @@
-using System;
-using QuestPDF.Infrastructure;
-
-namespace QuestPDF.Drawing.Proxy
-{
-    internal sealed class CacheProxy : ElementProxy
-    {
-        public Size? AvailableSpace { get; set; }
-        public SpacePlan? MeasurementResult { get; set; }
-
-        public CacheProxy(Element child)
-        {
-            Child = child;
-        }
-        
-        internal override SpacePlan Measure(Size availableSpace)
-        {
-            if (MeasurementResult != null &&
-                AvailableSpace != null &&
-                IsClose(AvailableSpace.Value.Width, availableSpace.Width) &&
-                IsClose(AvailableSpace.Value.Height, availableSpace.Height))
-            {
-                return MeasurementResult.Value;
-            }
-
-            AvailableSpace = availableSpace;
-            MeasurementResult = base.Measure(availableSpace);
-
-            return MeasurementResult.Value;
-        }
-
-        internal override void Draw(Size availableSpace)
-        { 
-            AvailableSpace = null;
-            MeasurementResult = null;
-            
-            base.Draw(availableSpace);
-        }
-
-        private static bool IsClose(float x, float y)
-        {
-            return Math.Abs(x - y) < Size.Epsilon;
-        }
-    }
-}

+ 1 - 1
Source/QuestPDF/Elements/AspectRatio.cs

@@ -5,7 +5,7 @@ using QuestPDF.Infrastructure;
 
 
 namespace QuestPDF.Elements
 namespace QuestPDF.Elements
 {
 {
-    internal sealed class AspectRatio : ContainerElement, ICacheable, IContentDirectionAware
+    internal sealed class AspectRatio : ContainerElement, IContentDirectionAware
     {
     {
         public ContentDirection ContentDirection { get; set; }
         public ContentDirection ContentDirection { get; set; }
         
         

+ 1 - 1
Source/QuestPDF/Elements/Column.cs

@@ -13,7 +13,7 @@ namespace QuestPDF.Elements
         public Position Offset { get; set; }
         public Position Offset { get; set; }
     }
     }
 
 
-    internal sealed class Column : Element, ICacheable, IStateResettable
+    internal sealed class Column : Element, IStateResettable
     {
     {
         internal List<Element> Items { get; } = new();
         internal List<Element> Items { get; } = new();
         internal float Spacing { get; set; }
         internal float Spacing { get; set; }

+ 1 - 1
Source/QuestPDF/Elements/Constrained.cs

@@ -5,7 +5,7 @@ using QuestPDF.Infrastructure;
 
 
 namespace QuestPDF.Elements
 namespace QuestPDF.Elements
 {
 {
-    internal sealed class Constrained : ContainerElement, ICacheable, IContentDirectionAware
+    internal sealed class Constrained : ContainerElement, IContentDirectionAware
     {
     {
         public ContentDirection ContentDirection { get; set; }
         public ContentDirection ContentDirection { get; set; }
         
         

+ 1 - 1
Source/QuestPDF/Elements/Decoration.cs

@@ -13,7 +13,7 @@ namespace QuestPDF.Elements
         public Position Offset { get; set; }
         public Position Offset { get; set; }
     }
     }
 
 
-    internal sealed class Decoration : Element, ICacheable, IContentDirectionAware
+    internal sealed class Decoration : Element, IContentDirectionAware
     {
     {
         public ContentDirection ContentDirection { get; set; }
         public ContentDirection ContentDirection { get; set; }
         
         

+ 1 - 1
Source/QuestPDF/Elements/EnsureSpace.cs

@@ -3,7 +3,7 @@ using QuestPDF.Infrastructure;
 
 
 namespace QuestPDF.Elements
 namespace QuestPDF.Elements
 {
 {
-    internal sealed class EnsureSpace : ContainerElement, ICacheable
+    internal sealed class EnsureSpace : ContainerElement
     {
     {
         public const float DefaultMinHeight = 150;
         public const float DefaultMinHeight = 150;
         public float MinHeight { get; set; } = DefaultMinHeight;
         public float MinHeight { get; set; } = DefaultMinHeight;

+ 1 - 1
Source/QuestPDF/Elements/Extend.cs

@@ -4,7 +4,7 @@ using QuestPDF.Infrastructure;
 
 
 namespace QuestPDF.Elements
 namespace QuestPDF.Elements
 {
 {
-    internal sealed class Extend : ContainerElement, ICacheable
+    internal sealed class Extend : ContainerElement
     {
     {
         public bool ExtendVertical { get; set; }
         public bool ExtendVertical { get; set; }
         public bool ExtendHorizontal { get; set; }
         public bool ExtendHorizontal { get; set; }

+ 1 - 1
Source/QuestPDF/Elements/Image.cs

@@ -5,7 +5,7 @@ using QuestPDF.Skia;
 
 
 namespace QuestPDF.Elements
 namespace QuestPDF.Elements
 {
 {
-    internal sealed class Image : Element, ICacheable, IStateResettable
+    internal sealed class Image : Element, IStateResettable
     {
     {
         private bool IsRendered { get; set; }
         private bool IsRendered { get; set; }
         
         

+ 1 - 1
Source/QuestPDF/Elements/Layers.cs

@@ -10,7 +10,7 @@ namespace QuestPDF.Elements
         public bool IsPrimary { get; set; }
         public bool IsPrimary { get; set; }
     }
     }
 
 
-    internal sealed class Layers : Element, ICacheable
+    internal sealed class Layers : Element
     {
     {
         public List<Layer> Children { get; set; } = new();
         public List<Layer> Children { get; set; } = new();
         
         

+ 1 - 1
Source/QuestPDF/Elements/Line.cs

@@ -15,7 +15,7 @@ namespace QuestPDF.Elements
         Horizontal
         Horizontal
     }
     }
 
 
-    internal sealed class Line : Element, ILine, ICacheable, IStateResettable
+    internal sealed class Line : Element, ILine, IStateResettable
     {
     {
         private bool IsRendered { get; set; }
         private bool IsRendered { get; set; }
         
         

+ 1 - 1
Source/QuestPDF/Elements/Padding.cs

@@ -5,7 +5,7 @@ using QuestPDF.Infrastructure;
 
 
 namespace QuestPDF.Elements
 namespace QuestPDF.Elements
 {
 {
-    internal sealed class Padding : ContainerElement, ICacheable
+    internal sealed class Padding : ContainerElement
     {
     {
         public float Top { get; set; }
         public float Top { get; set; }
         public float Right { get; set; }
         public float Right { get; set; }

+ 1 - 1
Source/QuestPDF/Elements/Row.cs

@@ -30,7 +30,7 @@ namespace QuestPDF.Elements
         public Position Offset { get; set; }
         public Position Offset { get; set; }
     }
     }
 
 
-    internal sealed class Row : Element, ICacheable, IStateResettable, IContentDirectionAware
+    internal sealed class Row : Element, IStateResettable, IContentDirectionAware
     {
     {
         public ContentDirection ContentDirection { get; set; }
         public ContentDirection ContentDirection { get; set; }
         
         

+ 1 - 1
Source/QuestPDF/Elements/Scale.cs

@@ -4,7 +4,7 @@ using QuestPDF.Infrastructure;
 
 
 namespace QuestPDF.Elements
 namespace QuestPDF.Elements
 {
 {
-    internal sealed class Scale : ContainerElement, ICacheable
+    internal sealed class Scale : ContainerElement
     {
     {
         public float ScaleX { get; set; } = 1;
         public float ScaleX { get; set; } = 1;
         public float ScaleY { get; set; } = 1;
         public float ScaleY { get; set; } = 1;

+ 1 - 1
Source/QuestPDF/Elements/ShowEntire.cs

@@ -3,7 +3,7 @@ using QuestPDF.Infrastructure;
 
 
 namespace QuestPDF.Elements
 namespace QuestPDF.Elements
 {
 {
-    internal sealed class ShowEntire : ContainerElement, ICacheable
+    internal sealed class ShowEntire : ContainerElement
     {
     {
         internal override SpacePlan Measure(Size availableSpace)
         internal override SpacePlan Measure(Size availableSpace)
         {
         {

+ 1 - 1
Source/QuestPDF/Elements/ShowOnce.cs

@@ -3,7 +3,7 @@ using QuestPDF.Infrastructure;
 
 
 namespace QuestPDF.Elements
 namespace QuestPDF.Elements
 {
 {
-    internal sealed class ShowOnce : ContainerElement, IStateResettable, ICacheable
+    internal sealed class ShowOnce : ContainerElement, IStateResettable
     {
     {
         private bool IsRendered { get; set; }
         private bool IsRendered { get; set; }
 
 

+ 1 - 1
Source/QuestPDF/Elements/SimpleRotate.cs

@@ -4,7 +4,7 @@ using QuestPDF.Infrastructure;
 
 
 namespace QuestPDF.Elements
 namespace QuestPDF.Elements
 {
 {
-    internal sealed class SimpleRotate : ContainerElement, ICacheable
+    internal sealed class SimpleRotate : ContainerElement
     {
     {
         public int TurnCount { get; set; }
         public int TurnCount { get; set; }
         public int NormalizedTurnCount => (TurnCount % 4 + 4) % 4;
         public int NormalizedTurnCount => (TurnCount % 4 + 4) % 4;

+ 1 - 1
Source/QuestPDF/Elements/Unconstrained.cs

@@ -3,7 +3,7 @@ using QuestPDF.Infrastructure;
 
 
 namespace QuestPDF.Elements
 namespace QuestPDF.Elements
 {
 {
-    internal sealed class Unconstrained : ContainerElement, IContentDirectionAware, ICacheable
+    internal sealed class Unconstrained : ContainerElement, IContentDirectionAware
     {
     {
         public ContentDirection ContentDirection { get; set; }
         public ContentDirection ContentDirection { get; set; }
         
         

+ 0 - 7
Source/QuestPDF/Infrastructure/ICacheable.cs

@@ -1,7 +0,0 @@
-namespace QuestPDF.Infrastructure
-{
-    internal interface ICacheable
-    {
-        
-    }
-}