Commit c8c45b09 authored by Roman Sedaikin's avatar Roman Sedaikin

Added API to get the current SkiaLayer graphics API.

parent 40cd2b02
......@@ -113,7 +113,7 @@ fun displayScene(renderer: Renderer, width: Int, height: Int, nanoTime: Long, xp
val watchStrokeAA = Paint().setColor(0xFF000000.toInt()).setMode(PaintMode.STROKE).setStrokeWidth(1f)
val watchFillHover = Paint().setColor(0xFFE4FF01.toInt())
for (x in 0 .. (width - 50) step 50) {
for (y in 0 .. (height - 50) step 50) {
for (y in 20 .. (height - 50) step 50) {
val hover = xpos > x + 0 && xpos < x + 50 && ypos > y + 0 && ypos < y + 50
val fill = if (hover) watchFillHover else watchFill
val stroke = if (x > width / 2) watchStrokeAA else watchStroke
......@@ -153,9 +153,9 @@ fun displayScene(renderer: Renderer, width: Int, height: Int, nanoTime: Long, xp
val style = ParagraphStyle()
val paragraph = ParagraphBuilder(style, fontCollection)
.pushStyle(TextStyle().setColor(0xFF000000.toInt()))
.addText("Text")
.addText("Graphics API: ${renderer.layer.renderApi}")
.popStyle()
.build()
paragraph.layout(Float.POSITIVE_INFINITY)
paragraph.paint(canvas, 0f, 0f)
paragraph.paint(canvas, 5f, 5f)
}
......@@ -73,17 +73,20 @@ open class SkiaLayer(
internal var redrawer: Redrawer? = null
private var contextHandler: ContextHandler? = null
private val fallbackRenderApiQueue = SkikoProperties.fallbackRenderApiQueue.toMutableList()
var renderApi: GraphicsApi = fallbackRenderApiQueue[0]
private set
@Volatile
private var picture: PictureHolder? = null
private val pictureRecorder = PictureRecorder()
private val pictureLock = Any()
open fun init() {
backedLayer.init()
val initialRenderApi = fallbackRenderApiQueue.removeAt(0)
contextHandler = createContextHandler(this, initialRenderApi)
redrawer = platformOperations.createRedrawer(this, initialRenderApi, properties)
renderApi = fallbackRenderApiQueue.removeAt(0)
contextHandler = createContextHandler(this, renderApi)
redrawer = platformOperations.createRedrawer(this, renderApi, properties)
isInited = true
}
......@@ -212,12 +215,12 @@ open class SkiaLayer(
}
private fun fallbackToNextApi() {
val nextApi = fallbackRenderApiQueue.removeAt(0)
println("Falling back to $nextApi rendering...")
renderApi = fallbackRenderApiQueue.removeAt(0)
println("Falling back to $renderApi rendering...")
contextHandler?.dispose()
redrawer?.dispose()
contextHandler = createContextHandler(this, nextApi)
redrawer = platformOperations.createRedrawer(this, nextApi, properties)
needRedraw()
contextHandler = createContextHandler(this, renderApi)
redrawer = platformOperations.createRedrawer(this, renderApi, properties)
repaint()
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment