Skip to content

Commit

Permalink
Update skiko to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
serivesmejia committed Sep 26, 2024
1 parent 898946d commit d418c43
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class PipelineExceptionTracker(private val pipelineManager: PipelineManager) {

companion object {
const val millisExceptionExpire = 35000L
const val cutStacktraceLines = 9
}

val logger by loggerForThis()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ class OpModePipelineHandler(val inputSourceManager: InputSourceManager, private
ThreadSourceHander.register(VisionInputSourceHander(pipeline?.notifier ?: return, viewport))

pipeline?.telemetry = telemetry
pipeline?.hardwareMap = HardwareMap();
}
pipeline?.hardwareMap = HardwareMap() }

override fun init() { }

Expand Down
4 changes: 4 additions & 0 deletions Vision/src/main/java/android/graphics/Bitmap.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ public static Bitmap createBitmap(int width, int height, Config config) {
return bm;
}

/**
* Internal: theBitmap represents the underlying skiko Bitmap
* This field is not present in native android.graphics
*/
public final org.jetbrains.skia.Bitmap theBitmap;

public Bitmap() {
Expand Down
4 changes: 4 additions & 0 deletions Vision/src/main/java/android/graphics/Canvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@

public class Canvas {

/**
* Internal: theCanvas represents the underlying skiko Canvas
* This field is not present in native android.graphics
*/
public final org.jetbrains.skia.Canvas theCanvas;

private Bitmap backingBitmap = null;
Expand Down
5 changes: 4 additions & 1 deletion Vision/src/main/java/android/graphics/FontCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@

import java.util.HashMap;

/**
* A cache for fonts to avoid creating the same font multiple times.
*/
class FontCache {

private static HashMap<Typeface, HashMap<Integer, Font>> cache = new HashMap<>();

public static Font makeFont(Typeface theTypeface, float textSize) {
static Font makeFont(Typeface theTypeface, float textSize) {
if(!cache.containsKey(theTypeface)) {
cache.put(theTypeface, new HashMap<>());
}
Expand Down
4 changes: 4 additions & 0 deletions Vision/src/main/java/android/graphics/Paint.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ public static class FontMetrics {
public float leading;
}

/**
* Internal: thePaint represents the underlying skiko paint
* This field is not present in native android.graphics
*/
public org.jetbrains.skia.Paint thePaint;

private Typeface typeface;
Expand Down
4 changes: 4 additions & 0 deletions Vision/src/main/java/android/graphics/Path.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ public enum Direction {
final int nativeInt;
}

/**
* Internal: thePath represents the underlying skiko Path
* This field is not present in native android.graphics
*/
public org.jetbrains.skia.Path thePath;

public Path() {
Expand Down
4 changes: 4 additions & 0 deletions Vision/src/main/java/android/graphics/Typeface.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public class Typeface {
public static Typeface DEFAULT_BOLD = new Typeface(FontMgr.Companion.getDefault().matchFamilyStyle(null, FontStyle.Companion.getBOLD()));
public static Typeface DEFAULT_ITALIC = new Typeface(FontMgr.Companion.getDefault().matchFamilyStyle(null, FontStyle.Companion.getITALIC()));

/**
* Internal: theTypeface represents the underlying skiko Typeface
* This field is not present in native android.graphics
*/
public org.jetbrains.skia.Typeface theTypeface;

public Typeface(long ptr) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import android.graphics.Canvas
import io.github.deltacv.common.image.MatPoster
import org.firstinspires.ftc.robotcore.internal.collections.EvictingBlockingQueue
import org.jetbrains.skia.Color
import org.jetbrains.skiko.GenericSkikoView
import org.jetbrains.skiko.SkiaLayer
import org.jetbrains.skiko.SkikoView
import org.jetbrains.skiko.SkiaLayerRenderDelegate
import org.jetbrains.skiko.SkikoRenderDelegate
import org.opencv.android.Utils
import org.opencv.core.Mat
import org.opencv.core.Size
Expand All @@ -44,7 +44,6 @@ import java.util.concurrent.ArrayBlockingQueue
import java.util.concurrent.TimeUnit
import javax.swing.JComponent
import javax.swing.SwingUtilities
import kotlin.jvm.Throws

class SwingOpenCvViewport(size: Size, fpsMeterDescriptor: String = "deltacv Vision") : OpenCvViewport, MatPoster {

Expand Down Expand Up @@ -94,7 +93,7 @@ class SwingOpenCvViewport(size: Size, fpsMeterDescriptor: String = "deltacv Visi
framebufferRecycler!!.returnMat(value)
}

skiaLayer.skikoView = GenericSkikoView(skiaLayer, object: SkikoView {
skiaLayer.renderDelegate = SkiaLayerRenderDelegate(skiaLayer, object: SkikoRenderDelegate {
override fun onRender(canvas: org.jetbrains.skia.Canvas, width: Int, height: Int, nanoTime: Long) {
renderCanvas(Canvas(canvas, width, height))

Expand Down
21 changes: 21 additions & 0 deletions Vision/src/main/java/org/openftc/easyopencv/OpenCvPipeline.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
/*
* Copyright (c) 2019 OpenFTC Team
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package org.openftc.easyopencv;

import android.graphics.Canvas;
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
log4j_version = "2.17.1"
opencv_version = "4.7.0-0"
apriltag_plugin_version = "2.0.0-C"
skiko_version = "0.7.75"
skiko_version = "0.8.15"

classgraph_version = "4.8.108"
opencsv_version = "5.5.2"
Expand Down

0 comments on commit d418c43

Please sign in to comment.