-
Notifications
You must be signed in to change notification settings - Fork 285
Properly convert Java char to C char in inputSwizzle #876
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
8 commits
Select commit
Hold shift + click to select a range
5eea92e
Properly convert Java char to C char in inputSwizzle
javagl 0bedf8d
Add basic test for JNI input swizzle
javagl 4638ca0
Removed unused imports
javagl 0ff0788
Compare result of swizzle to reference
javagl 7da5422
Test swizzle without reference image
javagl 89b29cb
Organize imports
javagl 13a571c
Merge remote-tracking branch 'upstream/main' into fix-jni-input-swizzle
javagl 647a5fc
Fix test for input swizzling in JNI
javagl 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
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
67 changes: 67 additions & 0 deletions
67
interface/java_binding/src/test/java/org/khronos/ktx/test/TestUtils.java
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,67 @@ | ||
| /* | ||
| * Copyright (c) 2024, Khronos Group and Contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| package org.khronos.ktx.test; | ||
|
|
||
| import java.util.Locale; | ||
|
|
||
| /** | ||
| * Utilities for the test package | ||
| */ | ||
| class TestUtils { | ||
|
|
||
| /** | ||
| * Fill the specified range of rows of the given RGBA pixels array with the | ||
| * given RGBA components | ||
| * | ||
| * @param rgba The RGBA pixels array | ||
| * @param sizeX The size of the image in x-direction | ||
| * @param sizeY The size of the image in y-direction | ||
| * @param minRow The minimum row, inclusive | ||
| * @param maxRow The maximum row, exclusive | ||
| * @param r The red component (in [0,255]) | ||
| * @param g The green component (in [0,255]) | ||
| * @param b The blue component (in [0,255]) | ||
| * @param a The alpha component (in [0,255]) | ||
| */ | ||
| static void fillRows(byte rgba[], int sizeX, int sizeY, | ||
| int minRow, int maxRow, | ||
| int r, int g, int b, int a) { | ||
| for (int y = minRow; y < maxRow; y++) { | ||
| for (int x = 0; x < sizeX; x++) { | ||
| int index = (y * sizeX) + x; | ||
| rgba[index * 4 + 0] = (byte) r; | ||
| rgba[index * 4 + 1] = (byte) g; | ||
| rgba[index * 4 + 2] = (byte) b; | ||
| rgba[index * 4 + 3] = (byte) a; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Create a string representation of the RGBA components of the specified pixel | ||
| * in the given RGBA pixels array. | ||
| * | ||
| * This is mainly intended for debugging. Some details of the resulting string | ||
| * are not specified. | ||
| * | ||
| * @param rgba The RGBA pixels array | ||
| * @param pixelIndex The pixel index | ||
| * @return The string | ||
| */ | ||
| static String createRgbaString(byte rgba[], int pixelIndex) { | ||
| byte r = rgba[pixelIndex * 4 + 0]; | ||
| byte g = rgba[pixelIndex * 4 + 1]; | ||
| byte b = rgba[pixelIndex * 4 + 2]; | ||
| byte a = rgba[pixelIndex * 4 + 3]; | ||
| int ir = Byte.toUnsignedInt(r); | ||
| int ig = Byte.toUnsignedInt(g); | ||
| int ib = Byte.toUnsignedInt(b); | ||
| int ia = Byte.toUnsignedInt(a); | ||
| String s = String.format(Locale.ENGLISH, "%3d, %3d, %3d, %3d", ir, ig, ib, ia); | ||
| return s; | ||
|
|
||
| } | ||
|
|
||
| } |
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.