-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f41f66
commit 5ed970f
Showing
6 changed files
with
82 additions
and
8 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
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
54 changes: 52 additions & 2 deletions
54
skiko/src/jvmMain/kotlin/org/jetbrains/skiko/SkiaLayerProperties.kt
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 |
---|---|---|
@@ -1,8 +1,58 @@ | ||
package org.jetbrains.skiko | ||
|
||
internal data class SkiaLayerProperties( | ||
|
||
/** | ||
* SkiaLayerProperties is a class that represents the rendering configuration for a SkiaLayer. | ||
* | ||
* @property isVsyncEnabled Specifies whether vertical synchronization (VSync) is enabled. | ||
* Default value is [SkikoProperties.vsyncEnabled]. Setting this to true is a hint toward underlying implementation | ||
* to synchronize the rendering with the display presentation. It guarantees that the frame is presented without | ||
* visual artifacts like tearing in exchange for a possible latency increase. | ||
* @property isVsyncFramelimitFallbackEnabled Specifies whether framelimit fallback is enabled (software renderer). | ||
* Default value is [SkikoProperties.vsyncFramelimitFallbackEnabled]. | ||
* @property renderApi Specifies the graphics API used for rendering. | ||
* Default value is [SkikoProperties.renderApi]. | ||
* @property adapterPriority Specifies the GPU that will be selected for rendering. | ||
* Default value is [SkikoProperties.gpuPriority]. | ||
*/ | ||
class SkiaLayerProperties( | ||
val isVsyncEnabled: Boolean = SkikoProperties.vsyncEnabled, | ||
val isVsyncFramelimitFallbackEnabled: Boolean = SkikoProperties.vsyncFramelimitFallbackEnabled, | ||
val renderApi: GraphicsApi = SkikoProperties.renderApi, | ||
val adapterPriority: GpuPriority = SkikoProperties.gpuPriority, | ||
) | ||
) { | ||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
|
||
val rhs = other as? SkiaLayerProperties ?: return false | ||
|
||
if (isVsyncEnabled != rhs.isVsyncEnabled) return false | ||
if (isVsyncFramelimitFallbackEnabled != rhs.isVsyncFramelimitFallbackEnabled) return false | ||
if (renderApi != rhs.renderApi) return false | ||
if (adapterPriority != rhs.adapterPriority) return false | ||
|
||
return true | ||
} | ||
|
||
fun copy( | ||
isVsyncEnabled: Boolean = this.isVsyncEnabled, | ||
isVsyncFramelimitFallbackEnabled: Boolean = this.isVsyncFramelimitFallbackEnabled, | ||
renderApi: GraphicsApi = this.renderApi, | ||
adapterPriority: GpuPriority = this.adapterPriority, | ||
): SkiaLayerProperties { | ||
return SkiaLayerProperties( | ||
isVsyncEnabled = isVsyncEnabled, | ||
isVsyncFramelimitFallbackEnabled = isVsyncFramelimitFallbackEnabled, | ||
renderApi = renderApi, | ||
adapterPriority = adapterPriority, | ||
) | ||
} | ||
|
||
override fun hashCode(): Int { | ||
var result = isVsyncEnabled.hashCode() | ||
result = 31 * result + isVsyncFramelimitFallbackEnabled.hashCode() | ||
result = 31 * result + renderApi.hashCode() | ||
result = 31 * result + adapterPriority.hashCode() | ||
return result | ||
} | ||
} |