Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[coregraphics] Update for Xcode 11 beta 1 and 2#6337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
spouliot merged 5 commits intodotnet:xcode11fromspouliot:xcode11-coregraphics-b1
Jun 19, 2019
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
[coregraphics] Update for Xcode 11 beta 1
along with unit tests for p/invokes
  • Loading branch information
Sebastien Pouliot committedJun 17, 2019
commitd453f6b9f93b42ceab86834d6f1082160c4df96e
34 changes: 34 additions & 0 deletionssrc/CoreGraphics/CGColor.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -275,6 +275,40 @@ static CGColor CreateByMatchingToColorSpace (CGColorSpace space, CGColorRenderin
color == null ? IntPtr.Zero : color.Handle, options == null ? IntPtr.Zero : options.Handle);
return h == IntPtr.Zero ? null : new CGColor (h);
}

[Mac (10,15, onlyOn64: true)]
[iOS (13,0)]
[TV (13,0)]
[Watch (6,0)]
[DllImport (Constants.CoreGraphicsLibrary)]
static extern /* CGColorRef* */ IntPtr CGColorCreateSRGB (nfloat red, nfloat green, nfloat blue, nfloat alpha);

[Mac (10,15, onlyOn64: true)]
[iOS (13,0)]
[TV (13,0)]
[Watch (6,0)]
static public CGColor CreateSrgb (nfloat red, nfloat green, nfloat blue, nfloat alpha)
{
var h = CGColorCreateSRGB (red, green, blue, alpha);
return h == IntPtr.Zero ? null : new CGColor (h);
}

[Mac (10,15, onlyOn64: true)]
[iOS (13,0)]
[TV (13,0)]
[Watch (6,0)]
[DllImport (Constants.CoreGraphicsLibrary)]
static extern /* CGColorRef* */ IntPtr CGColorCreateGenericGrayGamma2_2 (nfloat gray, nfloat alpha);

[Mac (10,15, onlyOn64: true)]
[iOS (13,0)]
[TV (13,0)]
[Watch (6,0)]
static public CGColor CreateGenericGrayGamma2_2 (nfloat gray, nfloat alpha)
{
var h = CGColorCreateGenericGrayGamma2_2 (gray, alpha);
return h == IntPtr.Zero ? null : new CGColor (h);
}
#endif // !COREBUILD
}
}
33 changes: 33 additions & 0 deletionssrc/CoreGraphics/CGColorConversionInfo.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -134,6 +134,39 @@ public CGColorConversionInfo (CGColorSpace src, CGColorSpace dst)
throw new Exception ("Failed to create CGColorConversionInfo");
}

[Mac (10,15, onlyOn64: true)]
[iOS (13,0)]
[TV (13,0)]
[Watch (6,0)]
[DllImport(Constants.CoreGraphicsLibrary)]
static extern /* CGColorConversionInfoRef* */ IntPtr CGColorConversionInfoCreateWithOptions (/* CGColorSpaceRef* */ IntPtr src, /* CGColorSpaceRef* */ IntPtr dst, /* CFDictionaryRef _Nullable */ IntPtr options);

[Mac (10,15, onlyOn64: true)]
[iOS (13,0)]
[TV (13,0)]
[Watch (6,0)]
public CGColorConversionInfo (CGColorSpace src, CGColorSpace dst, NSDictionary options)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Minor: parameter names should not be abbreviated (src ->source,dst ->destination).

{
if (src == null)
throw new ArgumentNullException (nameof (src));
if (dst == null)
throw new ArgumentNullException (nameof (dst));

Handle = CGColorConversionInfoCreateWithOptions (src.Handle, dst.Handle, options.GetHandle ());

if (Handle == IntPtr.Zero)
throw new Exception ("Failed to create CGColorConversionInfo");
}

[Mac (10,15, onlyOn64: true)]
[iOS (13,0)]
[TV (13,0)]
[Watch (6,0)]
public CGColorConversionInfo (CGColorSpace src, CGColorSpace dst, CGColorConversionOptions options) :
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Same: parameter names.

this (src, dst, options?.Dictionary)
{
}

~CGColorConversionInfo ()
{
Dispose (false);
Expand Down
42 changes: 42 additions & 0 deletionssrc/CoreGraphics/CGContextPDF.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -249,6 +249,48 @@ public void SetDestination (string name, CGRect rect)
using (var s = new CFString (name))
CGPDFContextSetDestinationForRect (Handle, s.Handle, rect);
}

[Mac (10,15, onlyOn64: true)]
[iOS (13,0)]
[TV (13,0)]
[Watch (6,0)]
[DllImport (Constants.CoreGraphicsLibrary)]
static extern void CGPDFContextBeginTag (/* CGContextRef* */ IntPtr context, CGPdfTagType tagType, /* CFDictionaryRef* _Nullable */ IntPtr tagProperties);

[Mac (10,15, onlyOn64: true)]
[iOS (13,0)]
[TV (13,0)]
[Watch (6,0)]
public void BeginTag (CGPdfTagType tagType, NSDictionary tagProperties)
{
CGPDFContextBeginTag (Handle, tagType, tagProperties.GetHandle ());
}

[Mac (10,15, onlyOn64: true)]
[iOS (13,0)]
[TV (13,0)]
[Watch (6,0)]
public void BeginTag (CGPdfTagType tagType, CGPdfTagProperties tagProperties)
{
var d = tagProperties?.Dictionary;
CGPDFContextBeginTag (Handle, tagType, d.GetHandle ());
}

[Mac (10,15, onlyOn64: true)]
[iOS (13,0)]
[TV (13,0)]
[Watch (6,0)]
[DllImport (Constants.CoreGraphicsLibrary)]
static extern void CGPDFContextEndTag (/* CGContextRef* */ IntPtr context);

[Mac (10,15, onlyOn64: true)]
[iOS (13,0)]
[TV (13,0)]
[Watch (6,0)]
public void EndTag ()
{
CGPDFContextEndTag (Handle);
}

protected override void Dispose (bool disposing)
{
Expand Down
75 changes: 74 additions & 1 deletionsrc/CoreGraphics/CGEnums.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,13 +4,86 @@
// Author:
// Vincent Dondain (vidondai@microsoft.com)
//
// Copyright 2018 Microsoft
// Copyright 2018-2019 Microsoft Corporation
//

using System;
using System.Runtime.InteropServices;
using ObjCRuntime;

namespace CoreGraphics {

public enum MatrixOrder {
Prepend = 0,
Append = 1,
}

[Mac (10,15, onlyOn64: true)]
[iOS (13,0)]
public enum CGPdfTagType /* int32_t */ {
Document = 100,
Part,
Art,
Section,
Div,
BlockQuote,
Caption,
Toc,
Toci,
Index,
NonStructure,
Private,
Paragraph = 200,
Header,
Header1,
Header2,
Header3,
Header4,
Header5,
Header6,
List = 300,
ListItem,
Label,
ListBody,
Table = 400,
TableRow,
TableHeaderCell,
TableDataCell,
TableHeader,
TableBody,
TableFooter,
Span = 500,
Quote,
Note,
Reference,
Bibliography,
Code,
Link,
Annotation,
Ruby = 600,
RubyBaseText,
RubyAnnotationText,
RubyPunctuation,
Warichu,
WarichuText,
WarichuPunctiation,
Figure = 700,
Formula,
Form,
}

[Mac (10,15, onlyOn64: true)]
[iOS (13,0)]
[TV (13,0)]
[Watch (6,0)]
public static class CGPdfTagType_Extensions {

[DllImport (Constants.CoreGraphicsLibrary)]
static extern /* const char * _Nullable */ IntPtr CGPDFTagTypeGetName (CGPdfTagType tagType);

public static string GetName (this CGPdfTagType self)
{
return Marshal.PtrToStringAnsi (CGPDFTagTypeGetName (self));
}
}
}
45 changes: 45 additions & 0 deletionssrc/coregraphics.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -194,6 +194,18 @@ interface CGColorSpaceNames {
[iOS (11,0)][Mac (10,13)][Watch (4,0)][TV (11,0)]
[Field ("kCGColorSpaceGenericLab")]
NSString GenericLab { get; }

[Mac (10, 14, 3, onlyOn64: true), iOS (12, 3)]
[Field ("kCGColorSpaceExtendedLinearITUR_2020")]
NSString ExtendedLinearItur_2020 { get; }

[Mac (10, 14, 3, onlyOn64: true), iOS (12, 3)]
[Field ("kCGColorSpaceExtendedLinearDisplayP3")]
NSString ExtendedLinearDisplayP3 { get; }

[Mac (10, 14, onlyOn64: true), iOS (12, 0)]
[Field ("kCGColorSpaceITUR_2020_PQ_EOTF")]
NSString Itur_2020_PQ_Eotf { get; }
}

[Partial]
Expand DownExpand Up@@ -257,4 +269,37 @@ interface CGPDFOutlineOptions {
CGRect DestinationRect { get; set; }
#endif
}

[Mac (10,15, onlyOn64: true)]
[iOS (13,0)]
[TV (13,0)]
[Watch (6,0)]
[Static]
[Internal]
interface CGPdfTagPropertyKeys {
[Field ("kCGPDFTagPropertyActualText")]
NSString ActualTextKey { get; }

[Field ("kCGPDFTagPropertyAlternativeText")]
NSString AlternativeTextKey { get; }

[Field ("kCGPDFTagPropertyTitleText")]
NSString TitleTextKey { get; }

[Field ("kCGPDFTagPropertyLanguageText")]
NSString LanguageTextKey { get; }
}

[Mac (10,15, onlyOn64: true)]
[iOS (13,0)]
[TV (13,0)]
[Watch (6,0)]
[StrongDictionary ("CGPdfTagPropertyKeys")]
interface CGPdfTagProperties {
// <quote>The following CGPDFTagProperty keys are to be paired with CFStringRef values</quote>
string ActualText { get; set; }
string AlternativeText { get; set; }
string TitleText { get; set; }
string LanguageText { get; set; }
}
}
34 changes: 34 additions & 0 deletionstests/monotouch-test/CoreGraphics/ColorConversionInfoTest.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -153,6 +153,40 @@ public void CreateSimple_DeviceColorSpace ()
Assert.Throws<Exception> (() => new CGColorConversionInfo (from, to));
}
}

[Test]
public void CGColorSpace_CGColorSpace_NSDictionary ()
{
TestRuntime.AssertXcodeVersion (11, 0);
using (var from = CGColorSpace.CreateGenericGray ())
using (var to = CGColorSpace.CreateGenericRgb ()) {
using (var converter = new CGColorConversionInfo (from, to, (NSDictionary)null)) {
Assert.That (converter.Handle, Is.Not.EqualTo (IntPtr.Zero), "Handle - null");
}
using (var d = new NSDictionary ())
using (var converter = new CGColorConversionInfo (from, to, d)) {
Assert.That (converter.Handle, Is.Not.EqualTo (IntPtr.Zero), "Handle");
}
}
}

[Test]
public void CGColorSpace_CGColorSpace_CGColorConversionOptions ()
{
TestRuntime.AssertXcodeVersion (11, 0);
using (var from = CGColorSpace.CreateGenericGray ())
using (var to = CGColorSpace.CreateGenericRgb ()) {
using (var converter = new CGColorConversionInfo (from, to, (CGColorConversionOptions)null)) {
Assert.That (converter.Handle, Is.Not.EqualTo (IntPtr.Zero), "Handle-null");
}

var o = new CGColorConversionOptions ();
o.BlackPointCompensation = true;
using (var converter = new CGColorConversionInfo (from, to, o)) {
Assert.That (converter.Handle, Is.Not.EqualTo (IntPtr.Zero), "Handle");
}
}
}
}
}

21 changes: 21 additions & 0 deletionstests/monotouch-test/CoreGraphics/ColorTest.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -86,6 +86,27 @@ public void ColorSpace ()
}
}
#endif
[Test]
public void CreateSrgb ()
{
TestRuntime.AssertXcodeVersion (11, 0);
using (var c = CGColor.CreateSrgb (0.1f, 0.2f, 0.3f, 0.4f)) {
Assert.That (c.NumberOfComponents, Is.EqualTo (4), "NumberOfComponents");
Assert.That (c.Alpha, Is.InRange (0.4f, 0.40001f), "Alpha");
Assert.That (c.ColorSpace.Model, Is.EqualTo (CGColorSpaceModel.RGB), "CGColorSpaceModel");
}
}

[Test]
public void CreateGenericGrayGamma2_2 ()
{
TestRuntime.AssertXcodeVersion (11, 0);
using (var c = CGColor.CreateGenericGrayGamma2_2 (0.1f, 0.2f)) {
Assert.That (c.NumberOfComponents, Is.EqualTo (2), "NumberOfComponents");
Assert.That (c.Alpha, Is.InRange (0.2f, 0.20001f), "Alpha");
Assert.That (c.ColorSpace.Model, Is.EqualTo (CGColorSpaceModel.Monochrome), "CGColorSpaceModel");
}
}
}
}

39 changes: 39 additions & 0 deletionstests/monotouch-test/CoreGraphics/PDFContextTest.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -100,5 +100,44 @@ public void Constructors ()
Assert.Throws<Exception> (() => new CGContextPDF ((NSUrl) null, null), "null NSUrl, null");

}

[Test]
public void Context_Tag ()
{
TestRuntime.AssertXcodeVersion (11, 0);
using (var d = new NSDictionary ())
using (var url = new NSUrl (filename))
using (var ctx = new CGContextPDF (url)) {
ctx.BeginPage (PDFInfoTest.GetInfo ());
ctx.BeginTag (CGPdfTagType.Header, (NSDictionary) null);
ctx.EndTag ();
ctx.BeginTag (CGPdfTagType.Caption, d);
ctx.SetUrl (url, RectangleF.Empty);
ctx.EndTag ();
ctx.EndPage ();
}
}

[Test]
public void Context_Tag_Strong ()
{
TestRuntime.AssertXcodeVersion (11, 0);
using (var url = new NSUrl (filename))
using (var ctx = new CGContextPDF (url)) {
var tp = new CGPdfTagProperties () {
ActualText = "ActualText",
AlternativeText = "AlternativeText",
TitleText = "TitleText",
LanguageText = "LanguageText",
};
ctx.BeginPage (PDFInfoTest.GetInfo ());
ctx.BeginTag (CGPdfTagType.Header, tp);
ctx.EndTag ();
ctx.BeginTag (CGPdfTagType.Caption, (CGPdfTagProperties) null);
ctx.SetUrl (url, RectangleF.Empty);
ctx.EndTag ();
ctx.EndPage ();
}
}
}
}
Loading

[8]ページ先頭

©2009-2025 Movatter.jp