Skip to content

Commit

Permalink
Move 2 Drawing APIs that are not implemented in netfx to netcoreapp (d…
Browse files Browse the repository at this point in the history
…otnet#60599)

* Move 2 Drawing APIs that are not implemented in netfx to netcoreapp3.1 or later (dotnet#60371)

* Don't use ifdefs on ref file
  • Loading branch information
safern committed Oct 19, 2021
1 parent 9362323 commit 21bdf48
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -594,14 +594,6 @@ public void Flush(System.Drawing.Drawing2D.FlushIntention intention) { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
public static System.Drawing.Graphics FromHwndInternal(System.IntPtr hwnd) { throw null; }
public static System.Drawing.Graphics FromImage(System.Drawing.Image image) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
[System.ObsoleteAttribute("Use the Graphics.GetContextInfo overloads that accept arguments for better performance and fewer allocations.", DiagnosticId = "SYSLIB0016", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
public object GetContextInfo() { throw null; }
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
public void GetContextInfo(out PointF offset) { throw null; }
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
public void GetContextInfo(out PointF offset, out Region? clip) { throw null; }
public static System.IntPtr GetHalftonePalette() { throw null; }
public System.IntPtr GetHdc() { throw null; }
public System.Drawing.Color GetNearestColor(System.Drawing.Color color) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ namespace System.Drawing
public sealed partial class Graphics
{
public System.Numerics.Matrix3x2 TransformElements { get { throw null; } set { } }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
[System.ObsoleteAttribute("Use the Graphics.GetContextInfo overloads that accept arguments for better performance and fewer allocations.", DiagnosticId = "SYSLIB0016", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
public object GetContextInfo() { throw null; }
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
public void GetContextInfo(out PointF offset) { throw null; }
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
public void GetContextInfo(out PointF offset, out Region? clip) { throw null; }
}
}
namespace System.Drawing.Drawing2D
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ public static partial class ColorTranslator
public static int ToOle(System.Drawing.Color c) { throw null; }
public static int ToWin32(System.Drawing.Color c) { throw null; }
}
public sealed partial class Graphics
{
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
public object GetContextInfo() { throw null; }
}
public static partial class SystemColors
{
public static System.Drawing.Color ActiveBorder { get { throw null; } }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:System.Drawing.Graphics.GetContextInfo(System.Drawing.PointF@)</Target>
<Left>lib/netstandard2.0/System.Drawing.Common.dll</Left>
<Right>lib/net462/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:System.Drawing.Graphics.GetContextInfo(System.Drawing.PointF@,System.Drawing.Region@)</Target>
<Left>lib/netstandard2.0/System.Drawing.Common.dll</Left>
<Right>lib/net462/System.Drawing.Common.dll</Right>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:System.Drawing.FontConverter</Target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ public object GetContextInfo()
throw new NotImplementedException();
}

#if NETCOREAPP3_1_OR_GREATER
[EditorBrowsable(EditorBrowsableState.Never)]
[SupportedOSPlatform("windows")]
public void GetContextInfo(out PointF offset)
Expand All @@ -596,6 +597,7 @@ public void GetContextInfo(out PointF offset, out Region? clip)
{
throw new PlatformNotSupportedException();
}
#endif

private void CheckErrorStatus(int status)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,9 @@ public unsafe void EnumerateMetafile(
/// WARNING: This method is for internal FX support only.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
#if NETCOREAPP3_1_OR_GREATER
[Obsolete(Obsoletions.GetContextInfoMessage, DiagnosticId = Obsoletions.GetContextInfoDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
#endif
[SupportedOSPlatform("windows")]
public object GetContextInfo()
{
Expand Down Expand Up @@ -763,6 +765,7 @@ private void GetContextInfo(out Matrix3x2 cumulativeTransform, bool calculateCli
}
}

#if NETCOREAPP3_1_OR_GREATER
/// <summary>
/// Gets the cumulative offset.
/// </summary>
Expand All @@ -789,6 +792,7 @@ public void GetContextInfo(out PointF offset, out Region? clip)
Vector2 translation = cumulativeTransform.Translation;
offset = new PointF(translation.X, translation.Y);
}
#endif

public RectangleF VisibleClipBounds
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public static WindowsGraphics FromGraphics(Graphics g, ApplyGraphicsProperties p
{
Region? clip = null;

#if NETCOREAPP3_1_OR_GREATER
if (properties.HasFlag(ApplyGraphicsProperties.Clipping))
{
g.GetContextInfo(out offset, out clip);
Expand All @@ -69,6 +70,21 @@ public static WindowsGraphics FromGraphics(Graphics g, ApplyGraphicsProperties p
{
g.GetContextInfo(out offset);
}
#else
Matrix? worldTransf = null;
if (g.GetContextInfo() is object[] data && data.Length == 2)
{
if (properties.HasFlag(ApplyGraphicsProperties.Clipping))
{
clip = data[0] as Region;
}
worldTransf = data[1] as Matrix;
if (worldTransf != null)
{
offset = worldTransf.Offset;
}
}
#endif

if (clip is not null)
{
Expand Down

0 comments on commit 21bdf48

Please sign in to comment.