-
-
Notifications
You must be signed in to change notification settings - Fork 888
Expose final internals to allow decoupling Drawing. #1046
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
97cac49
Fix color and pixel operations. Touches #967 #1002
JimBobSquarePants 40b69a5
Fix span access
JimBobSquarePants 7e5794d
Allow bulk Color => TPixel conversion.
JimBobSquarePants 628eb65
Fix GraphicsOptions
JimBobSquarePants f8ae0c1
Fix ImageFrame.Configuration
JimBobSquarePants f7eed91
Fix float clamp accessibility.
JimBobSquarePants ff023b8
Fix #1044
JimBobSquarePants 87f4947
Convert options into classes.
JimBobSquarePants 86c056a
Fix MemoryAllocator access.
JimBobSquarePants 58fd887
Expose Allocate2D
JimBobSquarePants eae0a95
Simplify options and add clone + tests
JimBobSquarePants f20666a
Update GraphicsOptions.cs
JimBobSquarePants 56e5575
Drop Default, use DeepClone + tests
JimBobSquarePants 05bc8c8
Normalize GraphicsOptions parameter position
JimBobSquarePants 50e5cdc
Remove unused properties.
JimBobSquarePants 1f28f0c
Prevent duplicate ctr in extensions
JimBobSquarePants File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
src/ImageSharp.Drawing/Common/Extensions/GraphicsOptionsExtensions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| // Copyright (c) Six Labors and contributors. | ||
| // Licensed under the Apache License, Version 2.0. | ||
|
|
||
| using System.Numerics; | ||
| using SixLabors.ImageSharp.PixelFormats; | ||
|
|
||
| namespace SixLabors.ImageSharp | ||
| { | ||
| /// <summary> | ||
| /// Extensions methods fpor the <see cref="GraphicsOptions"/> class. | ||
| /// </summary> | ||
| internal static class GraphicsOptionsExtensions | ||
| { | ||
| /// <summary> | ||
| /// Evaluates if a given SOURCE color can completely replace a BACKDROP color given the current blending and composition settings. | ||
| /// </summary> | ||
| /// <param name="options">The graphics options.</param> | ||
| /// <param name="color">The source color.</param> | ||
| /// <returns>true if the color can be considered opaque</returns> | ||
| /// <remarks> | ||
| /// Blending and composition is an expensive operation, in some cases, like | ||
| /// filling with a solid color, the blending can be avoided by a plain color replacement. | ||
| /// This method can be useful for such processors to select the fast path. | ||
| /// </remarks> | ||
| public static bool IsOpaqueColorWithoutBlending(this GraphicsOptions options, Color color) | ||
| { | ||
| if (options.ColorBlendingMode != PixelColorBlendingMode.Normal) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| if (options.AlphaCompositionMode != PixelAlphaCompositionMode.SrcOver | ||
| && options.AlphaCompositionMode != PixelAlphaCompositionMode.Src) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| const float Opaque = 1F; | ||
|
|
||
| if (options.BlendPercentage != Opaque) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| if (((Vector4)color).W != Opaque) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.