-
Notifications
You must be signed in to change notification settings - Fork 423
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Client gametest screenshot changes (#4329)
* Instant screenshots, with counter and more configurability * Force consistent window size across all systems and stretch framebuffer to fit the physical window * Docs * Wait ticks appropriately for the screenshots in the gametest test * Should -> must * Fix window resizing for different display scales * Fix framebuffer size not being changed at all * Add test for window resizing
- Loading branch information
1 parent
f371ccb
commit 1f6471e
Showing
16 changed files
with
626 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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 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
77 changes: 77 additions & 0 deletions
77
...-v1/src/client/java/net/fabricmc/fabric/api/client/gametest/v1/TestScreenshotOptions.java
This file contains 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,77 @@ | ||
/* | ||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.fabricmc.fabric.api.client.gametest.v1; | ||
|
||
import java.nio.file.Path; | ||
|
||
import com.google.common.base.Preconditions; | ||
import org.jetbrains.annotations.ApiStatus; | ||
|
||
import net.fabricmc.fabric.impl.client.gametest.TestScreenshotOptionsImpl; | ||
|
||
/** | ||
* Options to customize a screenshot. | ||
*/ | ||
@ApiStatus.NonExtendable | ||
public interface TestScreenshotOptions { | ||
/** | ||
* Creates a {@link TestScreenshotOptions} with the given screenshot name. | ||
* | ||
* @param name The name of the screenshot | ||
* @return The new screenshot options instance | ||
*/ | ||
static TestScreenshotOptions of(String name) { | ||
Preconditions.checkNotNull(name, "name"); | ||
return new TestScreenshotOptionsImpl(name); | ||
} | ||
|
||
/** | ||
* By default, screenshot file names will be prefixed by a counter so that the screenshots appear in sequence in the | ||
* screenshots directory. Use this method to disable this behavior. | ||
* | ||
* @return This screenshot options instance | ||
*/ | ||
TestScreenshotOptions disableCounterPrefix(); | ||
|
||
/** | ||
* Changes the tick delta to take this screenshot with. Tick delta controls interpolation between the previous tick and the | ||
* current tick to make objects appear to move more smoothly when there are multiple frames in a tick. Defaults to | ||
* {@code 1}, which renders all objects as their appear in the current tick. | ||
* | ||
* @param tickDelta The tick delta to take this screenshot with | ||
* @return This screenshot options instance | ||
*/ | ||
TestScreenshotOptions withTickDelta(float tickDelta); | ||
|
||
/** | ||
* Changes the resolution of the screenshot, which defaults to the resolution of the Minecraft window. | ||
* | ||
* @param width The width of the screenshot | ||
* @param height The height of the screenshot | ||
* @return This screenshot options instance | ||
*/ | ||
TestScreenshotOptions withSize(int width, int height); | ||
|
||
/** | ||
* Changes the directory in which this screenshot is saved, which defaults to the {@code screenshots} directory in | ||
* the game's run directory. | ||
* | ||
* @param destinationDir The directory in which to save the screenshot | ||
* @return This screenshot options instance | ||
*/ | ||
TestScreenshotOptions withDestinationDir(Path destinationDir); | ||
} |
This file contains 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 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 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 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
70 changes: 70 additions & 0 deletions
70
...1/src/client/java/net/fabricmc/fabric/impl/client/gametest/TestScreenshotOptionsImpl.java
This file contains 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,70 @@ | ||
/* | ||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.fabricmc.fabric.impl.client.gametest; | ||
|
||
import java.nio.file.Path; | ||
|
||
import com.google.common.base.Preconditions; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.joml.Vector2i; | ||
|
||
import net.fabricmc.fabric.api.client.gametest.v1.TestScreenshotOptions; | ||
|
||
public class TestScreenshotOptionsImpl implements TestScreenshotOptions { | ||
public final String name; | ||
public boolean counterPrefix = true; | ||
public float tickDelta = 1; | ||
@Nullable | ||
public Vector2i size; | ||
@Nullable | ||
public Path destinationDir; | ||
|
||
public TestScreenshotOptionsImpl(String name) { | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public TestScreenshotOptions disableCounterPrefix() { | ||
counterPrefix = false; | ||
return this; | ||
} | ||
|
||
@Override | ||
public TestScreenshotOptions withTickDelta(float tickDelta) { | ||
Preconditions.checkArgument(tickDelta >= 0 && tickDelta <= 1, "tickDelta must be between 0 and 1"); | ||
|
||
this.tickDelta = tickDelta; | ||
return this; | ||
} | ||
|
||
@Override | ||
public TestScreenshotOptions withSize(int width, int height) { | ||
Preconditions.checkArgument(width > 0, "width must be positive"); | ||
Preconditions.checkArgument(height > 0, "height must be positive"); | ||
|
||
this.size = new Vector2i(width, height); | ||
return this; | ||
} | ||
|
||
@Override | ||
public TestScreenshotOptions withDestinationDir(Path destinationDir) { | ||
Preconditions.checkNotNull(destinationDir, "destinationDir"); | ||
|
||
this.destinationDir = destinationDir; | ||
return this; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...gametest-api-v1/src/client/java/net/fabricmc/fabric/impl/client/gametest/WindowHooks.java
This file contains 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,26 @@ | ||
/* | ||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.fabricmc.fabric.impl.client.gametest; | ||
|
||
public interface WindowHooks { | ||
int fabric_getRealWidth(); | ||
int fabric_getRealHeight(); | ||
int fabric_getRealFramebufferWidth(); | ||
int fabric_getRealFramebufferHeight(); | ||
void fabric_resetSize(); | ||
void fabric_resize(int width, int height); | ||
} |
Oops, something went wrong.