Skip to content

Commit 85daead

Browse files
Merge branch 'master' into js/text-path
2 parents 72354cb + 9077deb commit 85daead

28 files changed

Lines changed: 170 additions & 92 deletions

src/ImageSharp.Drawing/ImageSharp.Drawing.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
<PackageProjectUrl>$(RepositoryUrl)</PackageProjectUrl>
1313
<PackageTags>Image Draw Shape Path Font</PackageTags>
1414
<Description>An extension to ImageSharp that allows the drawing of images, paths, and text.</Description>
15-
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;netstandard1.3;net472</TargetFrameworks>
15+
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;net472</TargetFrameworks>
1616
</PropertyGroup>
1717

1818
<ItemGroup>
1919
<None Include="..\..\shared-infrastructure\branding\icons\imagesharp.drawing\sixlabors.imagesharp.drawing.128.png" Pack="true" PackagePath="" />
2020
</ItemGroup>
2121

2222
<ItemGroup>
23-
<PackageReference Include="SixLabors.Fonts" Version="1.0.0-beta15.21" />
24-
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.4" />
23+
<PackageReference Include="SixLabors.Fonts" Version="1.0.0-beta15.24" />
24+
<PackageReference Include="SixLabors.ImageSharp" Version="2.0.0-alpha.0.156" />
2525
</ItemGroup>
2626

2727
<Import Project="..\..\shared-infrastructure\src\SharedInfrastructure\SharedInfrastructure.projitems" Label="Shared" />

src/ImageSharp.Drawing/Processing/GradientBrush.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public override void Apply(Span<float> scanline, int x, int y)
159159
}
160160
}
161161

162-
Span<TPixel> destinationRow = this.Target.GetPixelRowSpan(y).Slice(x, scanline.Length);
162+
Span<TPixel> destinationRow = this.Target.PixelBuffer.DangerousGetRowSpan(y).Slice(x, scanline.Length);
163163
this.Blender.Blend(this.Configuration, destinationRow, destinationRow, overlays, amounts);
164164
}
165165

src/ImageSharp.Drawing/Processing/ImageBrush.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public override void Apply(Span<float> scanline, int x, int y)
162162

163163
int offsetX = x - this.offsetX;
164164
int sourceY = ((y - this.offsetY) % this.sourceRegion.Width) + this.sourceRegion.Y;
165-
Span<TPixel> sourceRow = this.sourceFrame.GetPixelRowSpan(sourceY);
165+
Span<TPixel> sourceRow = this.sourceFrame.PixelBuffer.DangerousGetRowSpan(sourceY);
166166

167167
for (int i = 0; i < scanline.Length; i++)
168168
{
@@ -173,7 +173,7 @@ public override void Apply(Span<float> scanline, int x, int y)
173173
overlaySpan[i] = sourceRow[sourceX];
174174
}
175175

176-
Span<TPixel> destinationRow = this.Target.GetPixelRowSpan(y).Slice(x, scanline.Length);
176+
Span<TPixel> destinationRow = this.Target.PixelBuffer.DangerousGetRowSpan(y).Slice(x, scanline.Length);
177177
this.Blender.Blend(
178178
this.Configuration,
179179
destinationRow,

src/ImageSharp.Drawing/Processing/PathGradientBrush.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ public override void Apply(Span<float> scanline, int x, int y)
302302
}
303303
}
304304

305-
Span<TPixel> destinationRow = this.Target.GetPixelRowSpan(y).Slice(x, scanline.Length);
305+
Span<TPixel> destinationRow = this.Target.PixelBuffer.DangerousGetRowSpan(y).Slice(x, scanline.Length);
306306
this.Blender.Blend(this.Configuration, destinationRow, destinationRow, overlays, amounts);
307307
}
308308

src/ImageSharp.Drawing/Processing/PatternBrush.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public override void Apply(Span<float> scanline, int x, int y)
159159
overlays[i] = this.pattern[patternY, patternX];
160160
}
161161

162-
Span<TPixel> destinationRow = this.Target.GetPixelRowSpan(y).Slice(x, scanline.Length);
162+
Span<TPixel> destinationRow = this.Target.PixelBuffer.DangerousGetRowSpan(y).Slice(x, scanline.Length);
163163
this.Blender.Blend(
164164
this.Configuration,
165165
destinationRow,

src/ImageSharp.Drawing/Processing/Processors/Drawing/FillPathProcessor{TPixel}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ protected override void OnFrameApply(ImageFrame<TPixel> source)
121121
{
122122
if (hasOnes)
123123
{
124-
source.GetPixelRowSpan(y).Slice(minX, scanlineWidth).Fill(solidBrushColor);
124+
source.PixelBuffer.DangerousGetRowSpan(y).Slice(minX, scanlineWidth).Fill(solidBrushColor);
125125
}
126126

127127
continue;

src/ImageSharp.Drawing/Processing/Processors/Drawing/FillProcessor{TPixel}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public void Invoke(in RowInterval rows)
102102
{
103103
for (int y = rows.Min; y < rows.Max; y++)
104104
{
105-
this.source.GetPixelRowSpan(y).Slice(this.bounds.X, this.bounds.Width).Fill(this.color);
105+
this.source.PixelBuffer.DangerousGetRowSpan(y).Slice(this.bounds.X, this.bounds.Width).Fill(this.color);
106106
}
107107
}
108108
}

src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ protected override void BeforeImageApply()
3535
this.textRenderer = new CachingGlyphRenderer(
3636
this.Configuration.MemoryAllocator,
3737
this.definition.Text.Length,
38+
this.definition.TextOptions,
3839
this.definition.Pen,
3940
this.definition.Brush != null,
4041
this.definition.DrawingOptions.Transform)
@@ -127,7 +128,7 @@ void Draw(List<DrawingOperation> operations, IBrush brush)
127128
for (int row = firstRow; row < end; row++)
128129
{
129130
int y = startY + row;
130-
Span<float> span = buffer.GetRowSpan(row).Slice(offsetSpan);
131+
Span<float> span = buffer.DangerousGetRowSpan(row).Slice(offsetSpan);
131132
currentApp.Apply(span, startX, y);
132133
}
133134
}
@@ -173,22 +174,21 @@ private class CachingGlyphRenderer : IColorGlyphRenderer, IDisposable
173174
private readonly bool renderFill;
174175
private bool rasterizationRequired;
175176

176-
public CachingGlyphRenderer(MemoryAllocator memoryAllocator, int size, IPen pen, bool renderFill, Matrix3x2 transform)
177+
public CachingGlyphRenderer(MemoryAllocator memoryAllocator, int size, TextOptions textOptions, IPen pen, bool renderFill, Matrix3x2 transform)
177178
{
178179
this.MemoryAllocator = memoryAllocator;
179180
this.currentRenderPosition = default;
180181
this.Pen = pen;
181182
this.renderFill = renderFill;
182183
this.renderOutline = pen != null;
183-
this.offset = 2;
184+
this.offset = (int)textOptions.Font.Size;
184185
if (this.renderFill)
185186
{
186187
this.FillOperations = new List<DrawingOperation>(size);
187188
}
188189

189190
if (this.renderOutline)
190191
{
191-
this.offset = (int)MathF.Ceiling((pen.StrokeWidth * 2) + 2);
192192
this.OutlineOperations = new List<DrawingOperation>(size);
193193
}
194194

@@ -372,7 +372,7 @@ private Buffer2D<float> Render(IPath path)
372372
{
373373
while (scanner.MoveToNextPixelLine())
374374
{
375-
Span<float> scanline = fullBuffer.GetRowSpan(scanner.PixelLineY);
375+
Span<float> scanline = fullBuffer.DangerousGetRowSpan(scanner.PixelLineY);
376376
bool scanlineDirty = scanner.ScanCurrentPixelLineInto(0, xOffset, scanline);
377377

378378
if (scanlineDirty && !graphicsOptions.Antialias)

src/ImageSharp.Drawing/Processing/RecolorBrush.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public override void Apply(Span<float> scanline, int x, int y)
143143
overlays[i] = this[offsetX, y];
144144
}
145145

146-
Span<TPixel> destinationRow = this.Target.GetPixelRowSpan(y).Slice(x, scanline.Length);
146+
Span<TPixel> destinationRow = this.Target.PixelBuffer.DangerousGetRowSpan(y).Slice(x, scanline.Length);
147147
this.Blender.Blend(
148148
this.Configuration,
149149
destinationRow,

src/ImageSharp.Drawing/Processing/SolidBrush.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public SolidBrushApplicator(
7373
/// <inheritdoc />
7474
public override void Apply(Span<float> scanline, int x, int y)
7575
{
76-
Span<TPixel> destinationRow = this.Target.GetPixelRowSpan(y).Slice(x);
76+
Span<TPixel> destinationRow = this.Target.PixelBuffer.DangerousGetRowSpan(y).Slice(x);
7777

7878
// Constrain the spans to each other
7979
if (destinationRow.Length > scanline.Length)

0 commit comments

Comments
 (0)