Browse Source

Merge branch 'master' of https://github.com/JimBobSquarePants/ImageSharp into progressive-playground

af/merge-core
Anton Firszov 9 years ago
parent
commit
8dd3d1afd6
  1. 0
      .github/CONTRIBUTING.md
  2. 23
      .github/ISSUE_TEMPLATE.md
  3. 11
      .github/PULL_REQUEST_TEMPLATE.md
  4. 4
      src/ImageSharp.Drawing/project.json
  5. 4
      src/ImageSharp.Formats.Bmp/project.json
  6. 4
      src/ImageSharp.Formats.Gif/project.json
  7. 4
      src/ImageSharp.Formats.Jpeg/project.json
  8. 4
      src/ImageSharp.Formats.Png/project.json
  9. 4
      src/ImageSharp.Processing/project.json
  10. 4
      src/ImageSharp/project.json
  11. 63
      tests/ImageSharp.Benchmarks/General/Clamp.cs
  12. 2
      tests/ImageSharp.Benchmarks/Image/DecodeJpeg.cs

0
contributing.md → .github/CONTRIBUTING.md

23
.github/ISSUE_TEMPLATE.md

@ -0,0 +1,23 @@
### Prerequisites
- [ ] I have written a descriptive issue title
- [ ] I have verified that I am running the latest version of ImageSharp
- [ ] I have verified if the problem exist in both `DEBUG` and `RELEASE` mode
- [ ] I have searched [open](https://github.com/JimBobSquarePants/ImageSharp/issuess) and [closed](https://github.com/JimBobSquarePants/ImageSharp/issues?q=is%3Aissue+is%3Aclosed) issues to ensure it has not already been reported
### Description
<!-- A description of the bug or feature -->
### Steps to Reproduce
<!-- List of steps, sample code, failing test or link to a project that reproduces the behavior -->
### System Configuration
<!-- Tell us about the environment where you are experiencing the bug -->
- ImageSharp version:
- Other ImageSharp packages and versions:
- Environment (Operating system, version and so on):
- .NET Framework version:
- Additional information:
<!-- Thanks for reporting the issue to ImageSharp! -->

11
.github/PULL_REQUEST_TEMPLATE.md

@ -0,0 +1,11 @@
### Prerequisites
- [ ] I have written a descriptive pull-request title
- [ ] I have verified that there are no overlapping [pull-requests](https://github.com/JimBobSquarePants/ImageSharp/pulls) open
- [ ] I have verified that I am following matches the existing coding patterns and practise as demonstrated in the repository. These follow strict Stylecop rules :cop:.
- [ ] I have provided test coverage for my change (where applicable)
### Description
<!-- A description of the changes proposed in the pull-request -->
<!-- Thanks for contributing to ImageSharp! -->

4
src/ImageSharp.Drawing/project.json

@ -80,7 +80,7 @@
"System.Threading.Tasks.Parallel": "4.0.0" "System.Threading.Tasks.Parallel": "4.0.0"
}, },
"frameworkAssemblies": { "frameworkAssemblies": {
"System.Runtime": "4.0.0.0" "System.Runtime": { "type": "build" }
} }
}, },
"net461": { "net461": {
@ -88,7 +88,7 @@
"System.Threading.Tasks.Parallel": "4.0.0" "System.Threading.Tasks.Parallel": "4.0.0"
}, },
"frameworkAssemblies": { "frameworkAssemblies": {
"System.Runtime": "4.0.20.0", "System.Runtime": { "type": "build" },
"System.Numerics": "4.0.0.0", "System.Numerics": "4.0.0.0",
"System.Numerics.Vectors": "4.0.0.0" "System.Numerics.Vectors": "4.0.0.0"
} }

4
src/ImageSharp.Formats.Bmp/project.json

@ -76,7 +76,7 @@
"System.Threading.Tasks.Parallel": "4.0.0" "System.Threading.Tasks.Parallel": "4.0.0"
}, },
"frameworkAssemblies": { "frameworkAssemblies": {
"System.Runtime": "4.0.0.0" "System.Runtime": { "type": "build" }
} }
}, },
"net461": { "net461": {
@ -84,7 +84,7 @@
"System.Threading.Tasks.Parallel": "4.0.0" "System.Threading.Tasks.Parallel": "4.0.0"
}, },
"frameworkAssemblies": { "frameworkAssemblies": {
"System.Runtime": "4.0.20.0", "System.Runtime": { "type": "build" },
"System.Numerics": "4.0.0.0", "System.Numerics": "4.0.0.0",
"System.Numerics.Vectors": "4.0.0.0" "System.Numerics.Vectors": "4.0.0.0"
} }

4
src/ImageSharp.Formats.Gif/project.json

@ -76,7 +76,7 @@
"System.Threading.Tasks.Parallel": "4.0.0" "System.Threading.Tasks.Parallel": "4.0.0"
}, },
"frameworkAssemblies": { "frameworkAssemblies": {
"System.Runtime": "4.0.0.0" "System.Runtime": { "type": "build" }
} }
}, },
"net461": { "net461": {
@ -84,7 +84,7 @@
"System.Threading.Tasks.Parallel": "4.0.0" "System.Threading.Tasks.Parallel": "4.0.0"
}, },
"frameworkAssemblies": { "frameworkAssemblies": {
"System.Runtime": "4.0.20.0", "System.Runtime": { "type": "build" },
"System.Numerics": "4.0.0.0", "System.Numerics": "4.0.0.0",
"System.Numerics.Vectors": "4.0.0.0" "System.Numerics.Vectors": "4.0.0.0"
} }

4
src/ImageSharp.Formats.Jpeg/project.json

@ -76,7 +76,7 @@
"System.Threading.Tasks.Parallel": "4.0.0" "System.Threading.Tasks.Parallel": "4.0.0"
}, },
"frameworkAssemblies": { "frameworkAssemblies": {
"System.Runtime": "4.0.0.0" "System.Runtime": { "type": "build" }
} }
}, },
"net461": { "net461": {
@ -84,7 +84,7 @@
"System.Threading.Tasks.Parallel": "4.0.0" "System.Threading.Tasks.Parallel": "4.0.0"
}, },
"frameworkAssemblies": { "frameworkAssemblies": {
"System.Runtime": "4.0.20.0", "System.Runtime": { "type": "build" },
"System.Numerics": "4.0.0.0", "System.Numerics": "4.0.0.0",
"System.Numerics.Vectors": "4.0.0.0" "System.Numerics.Vectors": "4.0.0.0"
} }

4
src/ImageSharp.Formats.Png/project.json

@ -76,7 +76,7 @@
"System.Threading.Tasks.Parallel": "4.0.0" "System.Threading.Tasks.Parallel": "4.0.0"
}, },
"frameworkAssemblies": { "frameworkAssemblies": {
"System.Runtime": "4.0.0.0" "System.Runtime": { "type": "build" }
} }
}, },
"net461": { "net461": {
@ -84,7 +84,7 @@
"System.Threading.Tasks.Parallel": "4.0.0" "System.Threading.Tasks.Parallel": "4.0.0"
}, },
"frameworkAssemblies": { "frameworkAssemblies": {
"System.Runtime": "4.0.20.0", "System.Runtime": { "type": "build" },
"System.Numerics": "4.0.0.0", "System.Numerics": "4.0.0.0",
"System.Numerics.Vectors": "4.0.0.0" "System.Numerics.Vectors": "4.0.0.0"
} }

4
src/ImageSharp.Processing/project.json

@ -76,7 +76,7 @@
"System.Threading.Tasks.Parallel": "4.0.0" "System.Threading.Tasks.Parallel": "4.0.0"
}, },
"frameworkAssemblies": { "frameworkAssemblies": {
"System.Runtime": "4.0.0.0" "System.Runtime": { "type": "build" }
} }
}, },
"net461": { "net461": {
@ -84,7 +84,7 @@
"System.Threading.Tasks.Parallel": "4.0.0" "System.Threading.Tasks.Parallel": "4.0.0"
}, },
"frameworkAssemblies": { "frameworkAssemblies": {
"System.Runtime": "4.0.20.0", "System.Runtime": { "type": "build" },
"System.Numerics": "4.0.0.0", "System.Numerics": "4.0.0.0",
"System.Numerics.Vectors": "4.0.0.0" "System.Numerics.Vectors": "4.0.0.0"
} }

4
src/ImageSharp/project.json

@ -72,7 +72,7 @@
"System.Threading.Tasks.Parallel": "4.0.0" "System.Threading.Tasks.Parallel": "4.0.0"
}, },
"frameworkAssemblies": { "frameworkAssemblies": {
"System.Runtime": "4.0.0.0" "System.Runtime": { "type": "build" }
} }
}, },
"net461": { "net461": {
@ -80,7 +80,7 @@
"System.Threading.Tasks.Parallel": "4.0.0" "System.Threading.Tasks.Parallel": "4.0.0"
}, },
"frameworkAssemblies": { "frameworkAssemblies": {
"System.Runtime": "4.0.20.0", "System.Runtime": { "type": "build" },
"System.Numerics": "4.0.0.0", "System.Numerics": "4.0.0.0",
"System.Numerics.Vectors": "4.0.0.0" "System.Numerics.Vectors": "4.0.0.0"
} }

63
tests/ImageSharp.Benchmarks/General/Clamp.cs

@ -6,6 +6,7 @@
namespace ImageSharp.Benchmarks.General namespace ImageSharp.Benchmarks.General
{ {
using System; using System;
using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Attributes;
@ -17,24 +18,24 @@ namespace ImageSharp.Benchmarks.General
[Benchmark(Baseline = true, Description = "Maths Clamp")] [Benchmark(Baseline = true, Description = "Maths Clamp")]
public byte ClampMaths() public byte ClampMaths()
{ {
int value = this.Value; int value = this.Value;
return (byte)Math.Min(Math.Max(0, value), 255); return (byte)Math.Min(Math.Max(byte.MinValue, value), byte.MaxValue);
} }
[Benchmark(Description = "No Maths Clamp")] [Benchmark(Description = "No Maths Clamp")]
public byte ClampNoMaths() public byte ClampNoMaths()
{ {
int value = this.Value; int value = this.Value;
value = value >= 255 ? 255 : value; value = value >= byte.MaxValue ? byte.MaxValue : value;
return (byte)(value <= 0 ? 0 : value); return (byte)(value <= byte.MinValue ? byte.MinValue : value);
} }
[Benchmark(Description = "No Maths No Equals Clamp")] [Benchmark(Description = "No Maths No Equals Clamp")]
public byte ClampNoMathsNoEquals() public byte ClampNoMathsNoEquals()
{ {
int value = this.Value; int value = this.Value;
value = value > 255 ? 255 : value; value = value > byte.MaxValue ? byte.MaxValue : value;
return (byte)(value < 0 ? 0 : value); return (byte)(value < byte.MinValue ? byte.MinValue : value);
} }
[Benchmark(Description = "No Maths Clamp No Ternary")] [Benchmark(Description = "No Maths Clamp No Ternary")]
@ -42,14 +43,14 @@ namespace ImageSharp.Benchmarks.General
{ {
int value = this.Value; int value = this.Value;
if (value >= 255) if (value >= byte.MaxValue)
{ {
return 255; return byte.MaxValue;
} }
if (value <= 0) if (value <= byte.MinValue)
{ {
return 0; return byte.MinValue;
} }
return (byte)value; return (byte)value;
@ -58,19 +59,37 @@ namespace ImageSharp.Benchmarks.General
[Benchmark(Description = "No Maths No Equals Clamp No Ternary")] [Benchmark(Description = "No Maths No Equals Clamp No Ternary")]
public byte ClampNoMathsEqualsNoTernary() public byte ClampNoMathsEqualsNoTernary()
{ {
int value = this.Value; int value = this.Value;
if (value > 255) if (value > byte.MaxValue)
{ {
return 255; return byte.MaxValue;
} }
if (value < 0) if (value < byte.MinValue)
{ {
return 0; return byte.MinValue;
} }
return (byte)value; return (byte)value;
}
[Benchmark(Description = "Clamp using Bitwise Abs")]
public byte ClampBitwise()
{
int x = this.Value;
int absmax = byte.MaxValue - x;
x = (x + byte.MaxValue - AbsBitwiseVer(ref absmax)) >> 1;
x = (x + byte.MinValue + AbsBitwiseVer(ref x)) >> 1;
return (byte)x;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static int AbsBitwiseVer(ref int x)
{
int y = x >> 31;
return (x ^ y) - y;
} }
} }
} }

2
tests/ImageSharp.Benchmarks/Image/DecodeJpeg.cs

@ -22,7 +22,7 @@ namespace ImageSharp.Benchmarks.Image
{ {
if (this.jpegBytes == null) if (this.jpegBytes == null)
{ {
this.jpegBytes = File.ReadAllBytes("../ImageSharp.Tests/TestImages/Formats/Jpg/Calliphora.jpg"); this.jpegBytes = File.ReadAllBytes("../ImageSharp.Tests/TestImages/Formats/Jpg/Baseline/Calliphora.jpg");
} }
} }

Loading…
Cancel
Save