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