Unverified Commit 56b88584 authored by Roman Sedaikin's avatar Roman Sedaikin Committed by GitHub

Refactoring skia-part according to CFD use. (#160)

* Refactoring skia-part according to CFD use.
* Updated test according to refactoring.
parent 5c256dcf
......@@ -421,8 +421,6 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
* @see [https://fiddle.skia.org/c/@Canvas_drawPoints](https://fiddle.skia.org/c/@Canvas_drawPoints)
*/
fun drawPolygon(coords: FloatArray, paint: Paint): Canvas {
require(coords != null) { "Can’t drawPolygon with coords == null" }
require(paint != null) { "Can’t drawPolygon with paint == null" }
Stats.onNativeCall()
_nDrawPoints(_ptr, 2 /* SkCanvas::PointMode::kPolygon_PointMode */, coords, getPtr(paint))
reachabilityBarrier(paint)
......@@ -430,7 +428,6 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
}
fun drawLine(x0: Float, y0: Float, x1: Float, y1: Float, paint: Paint): Canvas {
require(paint != null) { "Can’t drawLine with paint == null" }
Stats.onNativeCall()
_nDrawLine(_ptr, x0, y0, x1, y1, getPtr(paint))
reachabilityBarrier(paint)
......@@ -447,7 +444,6 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
includeCenter: Boolean,
paint: Paint
): Canvas {
require(paint != null) { "Can’t drawArc with paint == null" }
Stats.onNativeCall()
_nDrawArc(_ptr, left, top, right, bottom, startAngle, sweepAngle, includeCenter, getPtr(paint))
reachabilityBarrier(paint)
......@@ -455,8 +451,6 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
}
fun drawRect(r: Rect, paint: Paint): Canvas {
require(r != null) { "Can’t drawRect with r == null" }
require(paint != null) { "Can’t drawRect with paint == null" }
Stats.onNativeCall()
_nDrawRect(_ptr, r.left, r.top, r.right, r.bottom, getPtr(paint))
reachabilityBarrier(paint)
......@@ -464,8 +458,6 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
}
fun drawOval(r: Rect, paint: Paint): Canvas {
require(r != null) { "Can’t drawOval with r == null" }
require(paint != null) { "Can’t drawOval with paint == null" }
Stats.onNativeCall()
_nDrawOval(_ptr, r.left, r.top, r.right, r.bottom, getPtr(paint))
reachabilityBarrier(paint)
......@@ -473,7 +465,6 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
}
fun drawCircle(x: Float, y: Float, radius: Float, paint: Paint): Canvas {
require(paint != null) { "Can’t drawCircle with paint == null" }
Stats.onNativeCall()
_nDrawOval(_ptr, x - radius, y - radius, x + radius, y + radius, getPtr(paint))
reachabilityBarrier(paint)
......@@ -481,8 +472,6 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
}
fun drawRRect(r: RRect, paint: Paint): Canvas {
require(r != null) { "Can’t drawRRect with r == null" }
require(paint != null) { "Can’t drawRRect with paint == null" }
Stats.onNativeCall()
_nDrawRRect(_ptr, r.left, r.top, r.right, r.bottom, r.radii, getPtr(paint))
reachabilityBarrier(paint)
......@@ -490,9 +479,6 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
}
fun drawDRRect(outer: RRect, inner: RRect, paint: Paint): Canvas {
require(outer != null) { "Can’t drawDRRect with outer == null" }
require(inner != null) { "Can’t drawDRRect with inner == null" }
require(paint != null) { "Can’t drawDRRect with paint == null" }
Stats.onNativeCall()
_nDrawDRRect(
_ptr,
......@@ -517,7 +503,6 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
}
fun drawRectShadow(r: Rect, dx: Float, dy: Float, blur: Float, spread: Float, color: Int): Canvas {
require(r != null) { "Can’t drawRectShadow with r == null" }
val insides = r.inflate(-1f)
if (!insides.isEmpty) {
save()
......@@ -529,11 +514,10 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
}
fun drawRectShadowNoclip(r: Rect, dx: Float, dy: Float, blur: Float, spread: Float, color: Int): Canvas {
require(r != null) { "Can’t drawRectShadow with r == null" }
val outline = r.inflate(spread)
makeDropShadowOnly(dx, dy, blur / 2f, blur / 2f, color).use { f ->
Paint().use { p ->
p.setImageFilter(f)
org.jetbrains.skia.Paint().use { p ->
p.imageFilter = f
if (outline is RRect) drawRRect(outline, p) else drawRect(outline, p)
}
}
......@@ -612,10 +596,6 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
paint: Paint?,
strict: Boolean
): Canvas {
require(image != null) { "Can’t drawImageRect with image == null" }
require(src != null) { "Can’t drawImageRect with src == null" }
require(dst != null) { "Can’t drawImageRect with dst == null" }
require(samplingMode != null) { "Can’t drawImageRect with samplingMode == null" }
Stats.onNativeCall()
_nDrawImageRect(
_ptr,
......@@ -638,10 +618,6 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
}
fun drawImageNine(image: Image, center: IRect, dst: Rect, filterMode: FilterMode, paint: Paint?): Canvas {
require(image != null) { "Can’t drawImageNine with image == null" }
require(center != null) { "Can’t drawImageNine with center == null" }
require(dst != null) { "Can’t drawImageNine with dst == null" }
require(filterMode != null) { "Can’t drawImageNine with filterMode == null" }
Stats.onNativeCall()
_nDrawImageNine(
_ptr,
......@@ -663,8 +639,6 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
}
fun drawRegion(r: Region, paint: Paint): Canvas {
require(r != null) { "Can’t drawRegion with r == null" }
require(paint != null) { "Can’t drawRegion with paint == null" }
Stats.onNativeCall()
_nDrawRegion(_ptr, getPtr(r), getPtr(paint))
reachabilityBarrier(r)
......@@ -673,8 +647,6 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
}
fun drawString(s: String, x: Float, y: Float, font: Font?, paint: Paint): Canvas {
require(s != null) { "Can’t drawString with s == null" }
require(paint != null) { "Can’t drawString with paint == null" }
Stats.onNativeCall()
_nDrawString(_ptr, s, x, y, getPtr(font), getPtr(paint))
reachabilityBarrier(font)
......@@ -683,8 +655,6 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
}
fun drawTextBlob(blob: TextBlob, x: Float, y: Float, paint: Paint): Canvas {
require(blob != null) { "Can’t drawTextBlob with blob == null" }
require(paint != null) { "Can’t drawTextBlob with paint == null" }
Stats.onNativeCall()
_nDrawTextBlob(_ptr, getPtr(blob), x, y, getPtr(paint))
reachabilityBarrier(blob)
......@@ -693,9 +663,7 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
}
fun drawTextLine(line: TextLine, x: Float, y: Float, paint: Paint): Canvas {
require(line != null) { "Can’t drawTextLine with line == null" }
require(paint != null) { "Can’t drawTextLine with paint == null" }
line.textBlob?.use { blob -> drawTextBlob(blob, x, y, paint) }
line.textBlob?.use { blob -> blob.let { drawTextBlob(it, x, y, paint) } }
return this
}
......@@ -797,11 +765,9 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
mode: BlendMode,
paint: Paint
): Canvas {
require(positions != null) { "Can’t drawTriangles with positions == null" }
require(positions.size % 3 == 0) { "Expected positions.length % 3 == 0, got: " + positions.size }
require(colors == null || colors.size == positions.size) { "Expected colors.length == positions.length, got: " + colors!!.size + " != " + positions.size }
require(texCoords == null || texCoords.size == positions.size) { "Expected texCoords.length == positions.length, got: " + texCoords!!.size + " != " + positions.size }
require(paint != null) { "Can’t drawTriangles with paint == null" }
Stats.onNativeCall()
_nDrawVertices(
_ptr,
......@@ -903,11 +869,8 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
mode: BlendMode,
paint: Paint
): Canvas {
require(positions != null) { "Can’t drawTriangleStrip with positions == null" }
require(colors == null || colors.size == positions.size) { "Expected colors.length == positions.length, got: " + colors!!.size + " != " + positions.size }
require(texCoords == null || texCoords.size == positions.size) { "Expected texCoords.length == positions.length, got: " + texCoords!!.size + " != " + positions.size }
require(mode != null) { "Can’t drawTriangles with mode == null" }
require(paint != null) { "Can’t drawTriangles with paint == null" }
Stats.onNativeCall()
_nDrawVertices(
_ptr,
......@@ -1136,13 +1099,9 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
mode: BlendMode,
paint: Paint
): Canvas {
require(cubics != null) { "Can’t drawPatch with cubics == null" }
require(cubics.size == 12) { "Expected cubics.length == 12, got: " + cubics.size }
require(colors != null) { "Can’t drawPatch with colors == null" }
require(colors.size == 4) { "Expected colors.length == 4, got: " + colors.size }
require(texCoords == null || texCoords.size == 4) { "Expected texCoords.length == 4, got: " + texCoords!!.size }
require(mode != null) { "Can’t drawPatch with mode == null" }
require(paint != null) { "Can’t drawPatch with paint == null" }
Stats.onNativeCall()
_nDrawPatch(
_ptr,
......@@ -1212,7 +1171,6 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
* @see [https://fiddle.skia.org/c/@Canvas_drawDrawable](https://fiddle.skia.org/c/@Canvas_drawDrawable)
*/
fun drawDrawable(drawable: Drawable, matrix: Matrix33?): Canvas {
require(drawable != null) { "Can’t drawDrawable with drawable == null" }
Stats.onNativeCall()
_nDrawDrawable(_ptr, getPtr(drawable), matrix?.mat)
reachabilityBarrier(drawable)
......@@ -1226,7 +1184,6 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
}
fun drawPaint(paint: Paint): Canvas {
require(paint != null) { "Can’t drawPaint with paint == null" }
Stats.onNativeCall()
_nDrawPaint(_ptr, getPtr(paint))
reachabilityBarrier(paint)
......@@ -1242,7 +1199,6 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
* @see [https://fiddle.skia.org/c/@Canvas_setMatrix](https://fiddle.skia.org/c/@Canvas_setMatrix)
*/
fun setMatrix(matrix: Matrix33): Canvas {
require(matrix != null) { "Can’t setMatrix with matrix == null" }
Stats.onNativeCall()
_nSetMatrix(_ptr, matrix.mat)
return this
......@@ -1276,8 +1232,6 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
get() = localToDevice.asMatrix33()
fun clipRect(r: Rect, mode: ClipMode, antiAlias: Boolean): Canvas {
require(r != null) { "Can’t clipRect with r == null" }
require(mode != null) { "Can’t clipRect with mode == null" }
Stats.onNativeCall()
_nClipRect(_ptr, r.left, r.top, r.right, r.bottom, mode.ordinal, antiAlias)
return this
......@@ -1296,8 +1250,6 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
}
fun clipRRect(r: RRect, mode: ClipMode, antiAlias: Boolean): Canvas {
require(r != null) { "Can’t clipRRect with r == null" }
require(mode != null) { "Can’t clipRRect with mode == null" }
Stats.onNativeCall()
_nClipRRect(_ptr, r.left, r.top, r.right, r.bottom, r.radii, mode.ordinal, antiAlias)
return this
......@@ -1316,8 +1268,6 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
}
fun clipPath(p: Path, mode: ClipMode, antiAlias: Boolean): Canvas {
require(p != null) { "Can’t clipPath with p == null" }
require(mode != null) { "Can’t clipPath with mode == null" }
Stats.onNativeCall()
_nClipPath(_ptr, getPtr(p), mode.ordinal, antiAlias)
reachabilityBarrier(p)
......@@ -1337,8 +1287,6 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
}
fun clipRegion(r: Region, mode: ClipMode): Canvas {
require(r != null) { "Can’t clipRegion with r == null" }
require(mode != null) { "Can’t clipRegion with mode == null" }
Stats.onNativeCall()
_nClipRegion(_ptr, getPtr(r), mode.ordinal)
reachabilityBarrier(r)
......@@ -1370,14 +1318,12 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
}
fun concat(matrix: Matrix33): Canvas {
require(matrix != null) { "Can’t concat with matrix == null" }
Stats.onNativeCall()
_nConcat(_ptr, matrix.mat)
return this
}
fun concat(matrix: Matrix44): Canvas {
require(matrix != null) { "Can’t concat with matrix == null" }
Stats.onNativeCall()
_nConcat44(_ptr, matrix.mat)
return this
......@@ -1430,7 +1376,6 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
*/
fun readPixels(bitmap: Bitmap, srcX: Int, srcY: Int): Boolean {
return try {
require(bitmap != null) { "Can’t readPixels with bitmap == null" }
Stats.onNativeCall()
_nReadPixels(
_ptr,
......@@ -1496,7 +1441,6 @@ open class Canvas internal constructor(ptr: Long, managed: Boolean, internal val
*/
fun writePixels(bitmap: Bitmap, x: Int, y: Int): Boolean {
return try {
require(bitmap != null) { "Can’t writePixels with bitmap == null" }
Stats.onNativeCall()
_nWritePixels(
_ptr,
......
......@@ -6,6 +6,7 @@ import org.jetbrains.skia.impl.Managed
import org.jetbrains.skia.impl.Native
import org.jetbrains.skia.impl.Stats
import org.jetbrains.skia.impl.reachabilityBarrier
import kotlin.jvm.JvmStatic
/**
* Data holds an immutable data buffer.
......@@ -35,15 +36,15 @@ class Data internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR)
return Data(_nMakeEmpty())
}
external fun _nGetFinalizer(): Long
external fun _nSize(ptr: Long): Long
external fun _nBytes(ptr: Long, offset: Long, length: Long): ByteArray
external fun _nEquals(ptr: Long, otherPtr: Long): Boolean
external fun _nToByteBuffer(ptr: Long): ByteBuffer
external fun _nMakeFromBytes(bytes: ByteArray?, offset: Long, length: Long): Long
external fun _nMakeFromFileName(path: String?): Long
external fun _nMakeSubset(ptr: Long, offset: Long, length: Long): Long
external fun _nMakeEmpty(): Long
@JvmStatic external fun _nGetFinalizer(): Long
@JvmStatic external fun _nSize(ptr: Long): Long
@JvmStatic external fun _nBytes(ptr: Long, offset: Long, length: Long): ByteArray
@JvmStatic external fun _nEquals(ptr: Long, otherPtr: Long): Boolean
@JvmStatic external fun _nToByteBuffer(ptr: Long): ByteBuffer
@JvmStatic external fun _nMakeFromBytes(bytes: ByteArray?, offset: Long, length: Long): Long
@JvmStatic external fun _nMakeFromFileName(path: String?): Long
@JvmStatic external fun _nMakeSubset(ptr: Long, offset: Long, length: Long): Long
@JvmStatic external fun _nMakeEmpty(): Long
init {
staticLoad()
......
package org.jetbrains.skia
class IRange(internal val start: Int, internal val end: Int) {
class IRange(val start: Int, val end: Int) {
override fun equals(o: Any?): Boolean {
if (o === this) return true
......
......@@ -162,6 +162,8 @@ class Paint : Managed {
}
/**
* Requests, but does not require, that edge pixels draw opaque or with partial transparency.
*
* Returns true if pixels on the active edges of Path may be drawn with partial transparency.
*
* @return antialiasing state
......@@ -189,15 +191,20 @@ class Paint : Managed {
}
/**
* Requests, but does not require, to distribute color error.
*
* @return true if color error may be distributed to smooth color transition.
*/
val isDither: Boolean
var isDither: Boolean
get() = try {
Stats.onNativeCall()
_nIsDither(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) {
setDither(value)
}
/**
* Requests, but does not require, to distribute color error.
......@@ -212,6 +219,12 @@ class Paint : Managed {
}
/**
* Sets whether the geometry is filled, stroked, or filled and stroked.
*
* @see [https://fiddle.skia.org/c/@Paint_setStyle](https://fiddle.skia.org/c/@Paint_setStyle)
*
* @see [https://fiddle.skia.org/c/@Stroke_Width](https://fiddle.skia.org/c/@Stroke_Width)
*
* @return whether the geometry is filled, stroked, or filled and stroked.
*/
var mode: PaintMode
......@@ -233,7 +246,6 @@ class Paint : Managed {
* @see [https://fiddle.skia.org/c/@Stroke_Width](https://fiddle.skia.org/c/@Stroke_Width)
*/
fun setMode(style: PaintMode): Paint {
require(style != null) { "Paint::setMode expected style != null" }
Stats.onNativeCall()
_nSetMode(_ptr, style.ordinal)
return this
......@@ -246,10 +258,16 @@ class Paint : Managed {
* @return this
*/
fun setStroke(value: Boolean): Paint {
return setMode(if (value) PaintMode.STROKE else PaintMode.FILL)
mode = (if (value) PaintMode.STROKE else PaintMode.FILL)
return this
}
/**
* Sets alpha and RGB used when stroking and filling. The color is a 32-bit value,
* unpremultiplied, packing 8-bit components for alpha, red, blue, and green.
*
* @see [https://fiddle.skia.org/c/@Paint_setColor](https://fiddle.skia.org/c/@Paint_setColor)
*
* Retrieves alpha and RGB, unpremultiplied, packed into 32 bits.
* Use helpers [Color.getA], [Color.getR], [Color.getG], and [Color.getB] to extract
* a color component.
......@@ -268,6 +286,23 @@ class Paint : Managed {
}
/**
* Sets alpha and RGB used when stroking and filling. The color is a 32-bit value,
* unpremultiplied, packing 8-bit components for alpha, red, blue, and green.
*
* @param color unpremultiplied ARGB
*
* @see [https://fiddle.skia.org/c/@Paint_setColor](https://fiddle.skia.org/c/@Paint_setColor)
*/
fun setColor(color: Int): Paint {
Stats.onNativeCall()
_nSetColor(_ptr, color)
return this
}
/**
* Sets alpha and RGB used when stroking and filling. The color is four floating
* point values, unpremultiplied. The color values are interpreted as being in sRGB.
*
* Retrieves alpha and RGB, unpremultiplied, as four floating point values. RGB are
* extended sRGB values (sRGB gamut, and encoded with the sRGB transfer function).
*
......@@ -284,20 +319,6 @@ class Paint : Managed {
setColor4f(value)
}
/**
* Sets alpha and RGB used when stroking and filling. The color is a 32-bit value,
* unpremultiplied, packing 8-bit components for alpha, red, blue, and green.
*
* @param color unpremultiplied ARGB
*
* @see [https://fiddle.skia.org/c/@Paint_setColor](https://fiddle.skia.org/c/@Paint_setColor)
*/
fun setColor(color: Int): Paint {
Stats.onNativeCall()
_nSetColor(_ptr, color)
return this
}
/**
* Sets alpha and RGB used when stroking and filling. The color is four floating
* point values, unpremultiplied. The color values are interpreted as being in sRGB.
......@@ -321,7 +342,6 @@ class Paint : Managed {
*/
fun setColor4f(color: Color4f, colorSpace: ColorSpace?): Paint {
return try {
require(color != null) { "Paint::setColor4f expected color != null" }
Stats.onNativeCall()
_nSetColor4f(
_ptr,
......@@ -366,7 +386,8 @@ class Paint : Managed {
* @return this
*/
fun setAlphaf(a: Float): Paint {
return setColor4f(color4f.withA(a))
setColor4f(color4f.withA(a), null)
return this
}
/**
......@@ -403,6 +424,15 @@ class Paint : Managed {
}
/**
* Sets the thickness of the pen used by the paint to outline the shape.
* A stroke-width of zero is treated as "hairline" width. Hairlines are always exactly one
* pixel wide in device space (their thickness does not change as the canvas is scaled).
* Negative stroke-widths are invalid; setting a negative width will have no effect.
*
* @see [https://fiddle.skia.org/c/@Miter_Limit](https://fiddle.skia.org/c/@Miter_Limit)
*
* @see [https://fiddle.skia.org/c/@Paint_setStrokeWidth](https://fiddle.skia.org/c/@Paint_setStrokeWidth)
*
* Returns the thickness of the pen used by Paint to outline the shape.
*
* @return zero for hairline, greater than zero for pen thickness
......@@ -437,6 +467,12 @@ class Paint : Managed {
}
/**
* Sets the limit at which a sharp corner is drawn beveled.
* Valid values are zero and greater.
* Has no effect if miter is less than zero.
*
* @see [https://fiddle.skia.org/c/@Paint_setStrokeMiter](https://fiddle.skia.org/c/@Paint_setStrokeMiter)
*
* Returns the limit at which a sharp corner is drawn beveled.
*
* @return zero and greater miter limit
......@@ -469,6 +505,12 @@ class Paint : Managed {
}
/**
* Sets the geometry drawn at the beginning and end of strokes.
*
* @see [https://fiddle.skia.org/c/@Paint_setStrokeCap_a](https://fiddle.skia.org/c/@Paint_setStrokeCap_a)
*
* @see [https://fiddle.skia.org/c/@Paint_setStrokeCap_b](https://fiddle.skia.org/c/@Paint_setStrokeCap_b)
*
* @return the geometry drawn at the beginning and end of strokes.
*/
var strokeCap: PaintStrokeCap
......@@ -492,13 +534,17 @@ class Paint : Managed {
* @see [https://fiddle.skia.org/c/@Paint_setStrokeCap_b](https://fiddle.skia.org/c/@Paint_setStrokeCap_b)
*/
fun setStrokeCap(cap: PaintStrokeCap): Paint {
require(cap != null) { "Paint::setStrokeCap expected cap != null" }
Stats.onNativeCall()
_nSetStrokeCap(_ptr, cap.ordinal)
return this
}
/**
* Sets the geometry drawn at the corners of strokes.
*
* @see [https://fiddle.skia.org/c/@Paint_setStrokeJoin](https://fiddle.skia.org/c/@Paint_setStrokeJoin)
*
* @return the geometry drawn at the corners of strokes.
*/
var strokeJoin: PaintStrokeJoin
......@@ -520,7 +566,6 @@ class Paint : Managed {
* @see [https://fiddle.skia.org/c/@Paint_setStrokeJoin](https://fiddle.skia.org/c/@Paint_setStrokeJoin)
*/
fun setStrokeJoin(join: PaintStrokeJoin): Paint {
require(join != null) { "Paint::setStrokeJoin expected join != null" }
Stats.onNativeCall()
_nSetStrokeJoin(_ptr, join.ordinal)
return this
......@@ -547,7 +592,6 @@ class Paint : Managed {
*/
fun getFillPath(src: Path, cull: Rect?, resScale: Float): Path {
return try {
require(src != null) { "Paint::getFillPath expected src != null" }
Stats.onNativeCall()
if (cull == null) org.jetbrains.skia.Path(
_nGetFillPath(
......@@ -573,6 +617,12 @@ class Paint : Managed {
}
/**
* @param shader how geometry is filled with color; if null, color is used instead
*
* @see [https://fiddle.skia.org/c/@Color_Filter_Methods](https://fiddle.skia.org/c/@Color_Filter_Methods)
*
* @see [https://fiddle.skia.org/c/@Paint_setShader](https://fiddle.skia.org/c/@Paint_setShader)
*
* @return [Shader] or null
* @see [https://fiddle.skia.org/c/@Paint_refShader](https://fiddle.skia.org/c/@Paint_refShader)
*/
......@@ -606,6 +656,12 @@ class Paint : Managed {
}
/**
* @param colorFilter [ColorFilter] to apply to subsequent draw
*
* @see [https://fiddle.skia.org/c/@Blend_Mode_Methods](https://fiddle.skia.org/c/@Blend_Mode_Methods)
*
* @see [https://fiddle.skia.org/c/@Paint_setColorFilter](https://fiddle.skia.org/c/@Paint_setColorFilter)
*
* @return [ColorFilter] or null
* @see [https://fiddle.skia.org/c/@Paint_refColorFilter](https://fiddle.skia.org/c/@Paint_refColorFilter)
*/
......@@ -642,6 +698,9 @@ class Paint : Managed {
}
/**
* Sets SkBlendMode to mode. Does not check for valid input.
* BlendMode used to combine source color and destination.
*
* Returns BlendMode. By default, returns [BlendMode.SRC_OVER].
*
* @return mode used to combine source color with destination color
......@@ -657,12 +716,6 @@ class Paint : Managed {
setBlendMode(value)
}
/**
* @return true if BlendMode is BlendMode.SRC_OVER, the default.
*/
val isSrcOver: Boolean
get() = blendMode == BlendMode.SRC_OVER
/**
* Sets SkBlendMode to mode. Does not check for valid input.
*
......@@ -676,6 +729,18 @@ class Paint : Managed {
}
/**
* @return true if BlendMode is BlendMode.SRC_OVER, the default.
*/
val isSrcOver: Boolean
get() = blendMode == BlendMode.SRC_OVER
/**
* Replace [Path] with a modification when drawn
*
* @see [https://fiddle.skia.org/c/@Mask_Filter_Methods](https://fiddle.skia.org/c/@Mask_Filter_Methods)
*
* @see [https://fiddle.skia.org/c/@Paint_setPathEffect](https://fiddle.skia.org/c/@Paint_setPathEffect)
*
* @return [PathEffect] or null
* @see [https://fiddle.skia.org/c/@Paint_refPathEffect](https://fiddle.skia.org/c/@Paint_refPathEffect)
*/
......@@ -708,11 +773,18 @@ class Paint : Managed {
}
}
/**
* maskFilter modifies clipping mask generated from drawn geometry
*
* @see [https://fiddle.skia.org/c/@Paint_setMaskFilter](https://fiddle.skia.org/c/@Paint_setMaskFilter)
*
* @see [https://fiddle.skia.org/c/@Typeface_Methods](https://fiddle.skia.org/c/@Typeface_Methods)
*
* @return [MaskFilter] if previously set, null otherwise
* @see [https://fiddle.skia.org/c/@Paint_refMaskFilter](https://fiddle.skia.org/c/@Paint_refMaskFilter)
*/
val maskFilter: MaskFilter?
var maskFilter: MaskFilter?
get() = try {
Stats.onNativeCall()
val maskFilterPtr = _nGetMaskFilter(_ptr)
......@@ -720,6 +792,9 @@ class Paint : Managed {
} finally {
reachabilityBarrier(this)
}
set(value) {
setMaskFilter(value)
}
/**
* @param maskFilter modifies clipping mask generated from drawn geometry
......@@ -743,10 +818,16 @@ class Paint : Managed {
}
/**
* imageFilter how SkImage is sampled when transformed
*
* @see [https://fiddle.skia.org/c/@Draw_Looper_Methods](https://fiddle.skia.org/c/@Draw_Looper_Methods)
*
* @see [https://fiddle.skia.org/c/@Paint_setImageFilter](https://fiddle.skia.org/c/@Paint_setImageFilter)
*
* @return [ImageFilter] or null
* @see [https://fiddle.skia.org/c/@Paint_refImageFilter](https://fiddle.skia.org/c/@Paint_refImageFilter)
*/
val imageFilter: ImageFilter?
var imageFilter: ImageFilter?
get() = try {
Stats.onNativeCall()
val imageFilterPtr = _nGetImageFilter(_ptr)
......@@ -754,6 +835,9 @@ class Paint : Managed {
} finally {
reachabilityBarrier(this)
}
set(value) {
setImageFilter(value)
}
/**
* @param imageFilter how SkImage is sampled when transformed
......
......@@ -408,7 +408,6 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
}
/**
*
* Interpolates between Path with [Point] array of equal size.
* Copy verb array and weights to out, and set out Point array to a weighted
* average of this Point array and ending Point array, using the formula:
......@@ -601,6 +600,20 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
}
/**
*
* Specifies whether Path is volatile; whether it will be altered or discarded
* by the caller after it is drawn. Path by default have volatile set false, allowing
* SkBaseDevice to attach a cache of data which speeds repeated drawing.
*
* Mark temporary paths, discarded or modified after use, as volatile
* to inform SkBaseDevice that the path need not be cached.
*
* Mark animating Path volatile to improve performance.
* Mark unchanging Path non-volatile to improve repeated rendering.
*
* raster surface Path draws are affected by volatile for some shadows.
* GPU surface Path draws are affected by volatile for some shadows and concave geometries.
*
* Returns true if the path is volatile; it will not be altered or discarded
* by the caller after it is drawn. Path by default have volatile set false, allowing
* [Surface] to attach a cache of data which speeds repeated drawing. If true, [Surface]
......@@ -608,13 +621,17 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
*
* @return true if caller will alter Path after drawing
*/
val isVolatile: Boolean
var isVolatile: Boolean
get() = try {
Stats.onNativeCall()
_nIsVolatile(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) {
Stats.onNativeCall()
_nSetVolatile(_ptr, value)
}
/**
*
......
......@@ -5,6 +5,7 @@ import org.jetbrains.skia.impl.Library.Companion.staticLoad
import org.jetbrains.skia.impl.Managed
import org.jetbrains.skia.impl.Stats
import org.jetbrains.skia.impl.reachabilityBarrier
import kotlin.jvm.JvmStatic
class PathSegmentIterator internal constructor(val _path: Path?, ptr: Long) : Managed(ptr, _nGetFinalizer()),
MutableIterator<PathSegment?> {
......@@ -21,9 +22,9 @@ class PathSegmentIterator internal constructor(val _path: Path?, ptr: Long) : Ma
}
}
external fun _nMake(pathPtr: Long, forceClose: Boolean): Long
external fun _nGetFinalizer(): Long
external fun _nNext(ptr: Long): PathSegment?
@JvmStatic external fun _nMake(pathPtr: Long, forceClose: Boolean): Long
@JvmStatic external fun _nGetFinalizer(): Long
@JvmStatic external fun _nNext(ptr: Long): PathSegment?
init {
staticLoad()
......
......@@ -2,7 +2,7 @@ package org.jetbrains.skia
import kotlin.jvm.JvmStatic
open class Rect internal constructor(val left: Float, val top: Float, val right: Float, val bottom: Float) {
open class Rect constructor(val left: Float, val top: Float, val right: Float, val bottom: Float) {
val width: Float
get() = right - left
val height: Float
......
......@@ -48,13 +48,16 @@ class ParagraphStyle : Managed(_nMake(), _FinalizerHolder.PTR) {
}
}
val strutStyle: StrutStyle
var strutStyle: StrutStyle
get() = try {
Stats.onNativeCall()
StrutStyle(_nGetStrutStyle(_ptr))
} finally {
reachabilityBarrier(this)
}
set(value) {
setStrutStyle(value)
}
fun setStrutStyle(s: StrutStyle?): ParagraphStyle {
return try {
......@@ -66,13 +69,16 @@ class ParagraphStyle : Managed(_nMake(), _FinalizerHolder.PTR) {
}
}
val textStyle: TextStyle
var textStyle: TextStyle
get() = try {
Stats.onNativeCall()
TextStyle(_nGetTextStyle(_ptr))
} finally {
reachabilityBarrier(this)
}
set(value) {
setTextStyle(value)
}
fun setTextStyle(style: TextStyle?): ParagraphStyle {
return try {
......@@ -84,13 +90,16 @@ class ParagraphStyle : Managed(_nMake(), _FinalizerHolder.PTR) {
}
}
val direction: Direction
var direction: Direction
get() = try {
Stats.onNativeCall()
Direction.values()[_nGetDirection(_ptr)]
} finally {
reachabilityBarrier(this)
}
set(value) {
setDirection(value)
}
fun setDirection(style: Direction): ParagraphStyle {
Stats.onNativeCall()
......@@ -98,13 +107,16 @@ class ParagraphStyle : Managed(_nMake(), _FinalizerHolder.PTR) {
return this
}
val alignment: Alignment
var alignment: Alignment
get() = try {
Stats.onNativeCall()
Alignment.values()[_nGetAlignment(_ptr)]
} finally {
reachabilityBarrier(this)
}
set(value) {
setAlignment(value)
}
fun setAlignment(alignment: Alignment): ParagraphStyle {
Stats.onNativeCall()
......@@ -112,13 +124,16 @@ class ParagraphStyle : Managed(_nMake(), _FinalizerHolder.PTR) {
return this
}
val maxLinesCount: Long
var maxLinesCount: Long
get() = try {
Stats.onNativeCall()
_nGetMaxLinesCount(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) {
setMaxLinesCount(value)
}
fun setMaxLinesCount(count: Long): ParagraphStyle {
Stats.onNativeCall()
......@@ -126,13 +141,16 @@ class ParagraphStyle : Managed(_nMake(), _FinalizerHolder.PTR) {
return this
}
val ellipsis: String
var ellipsis: String
get() = try {
Stats.onNativeCall()
_nGetEllipsis(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) {
setEllipsis(value)
}
fun setEllipsis(ellipsis: String?): ParagraphStyle {
Stats.onNativeCall()
......@@ -140,13 +158,16 @@ class ParagraphStyle : Managed(_nMake(), _FinalizerHolder.PTR) {
return this
}
val height: Float
var height: Float
get() = try {
Stats.onNativeCall()
_nGetHeight(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) {
setHeight(value)
}
fun setHeight(height: Float): ParagraphStyle {
Stats.onNativeCall()
......@@ -154,13 +175,16 @@ class ParagraphStyle : Managed(_nMake(), _FinalizerHolder.PTR) {
return this
}
val heightMode: HeightMode
var heightMode: HeightMode
get() = try {
Stats.onNativeCall()
HeightMode.values()[_nGetHeightMode(_ptr)]
} finally {
reachabilityBarrier(this)
}
set(value) {
setHeightMode(value)
}
fun setHeightMode(behavior: HeightMode): ParagraphStyle {
Stats.onNativeCall()
......@@ -175,6 +199,7 @@ class ParagraphStyle : Managed(_nMake(), _FinalizerHolder.PTR) {
} finally {
reachabilityBarrier(this)
}
val isHintingEnabled: Boolean
get() = try {
Stats.onNativeCall()
......
......@@ -64,13 +64,16 @@ class StrutStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder
return this
}
val fontStyle: FontStyle
var fontStyle: FontStyle
get() = try {
Stats.onNativeCall()
FontStyle(_nGetFontStyle(_ptr))
} finally {
reachabilityBarrier(this)
}
set(value) {
setFontStyle(value)
}
fun setFontStyle(style: FontStyle): StrutStyle {
Stats.onNativeCall()
......@@ -78,13 +81,16 @@ class StrutStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder
return this
}
val fontSize: Float
var fontSize: Float
get() = try {
Stats.onNativeCall()
_nGetFontSize(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) {
setFontSize(value)
}
fun setFontSize(value: Float): StrutStyle {
Stats.onNativeCall()
......@@ -92,13 +98,16 @@ class StrutStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder
return this
}
val height: Float
var height: Float
get() = try {
Stats.onNativeCall()
_nGetHeight(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) {
setHeight(value)
}
fun setHeight(value: Float): StrutStyle {
Stats.onNativeCall()
......@@ -106,13 +115,16 @@ class StrutStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder
return this
}
val leading: Float
var leading: Float
get() = try {
Stats.onNativeCall()
_nGetLeading(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) {
setLeading(value)
}
fun setLeading(value: Float): StrutStyle {
Stats.onNativeCall()
......@@ -120,13 +132,16 @@ class StrutStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder
return this
}
val isEnabled: Boolean
var isEnabled: Boolean
get() = try {
Stats.onNativeCall()
_nIsEnabled(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) {
setEnabled(value)
}
fun setEnabled(value: Boolean): StrutStyle {
Stats.onNativeCall()
......@@ -134,13 +149,16 @@ class StrutStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder
return this
}
val isHeightForced: Boolean
var isHeightForced: Boolean
get() = try {
Stats.onNativeCall()
_nIsHeightForced(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) {
setHeightForced(value)
}
fun setHeightForced(value: Boolean): StrutStyle {
Stats.onNativeCall()
......@@ -148,13 +166,16 @@ class StrutStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder
return this
}
val isHeightOverridden: Boolean
var isHeightOverridden: Boolean
get() = try {
Stats.onNativeCall()
_nIsHeightOverridden(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) {
setHeightOverridden(value)
}
fun setHeightOverridden(value: Boolean): StrutStyle {
Stats.onNativeCall()
......
......@@ -97,13 +97,16 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
}
}
val color: Int
var color: Int
get() = try {
Stats.onNativeCall()
_nGetColor(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) {
setColor(value)
}
fun setColor(color: Int): TextStyle {
Stats.onNativeCall()
......@@ -111,7 +114,7 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
return this
}
val foreground: Paint?
var foreground: Paint?
get() = try {
Stats.onNativeCall()
val ptr = _nGetForeground(_ptr)
......@@ -119,6 +122,9 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
} finally {
reachabilityBarrier(this)
}
set(value) {
setForeground(value)
}
fun setForeground(paint: Paint?): TextStyle {
return try {
......@@ -133,7 +139,7 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
}
}
val background: Paint?
var background: Paint?
get() = try {
Stats.onNativeCall()
val ptr = _nGetBackground(_ptr)
......@@ -141,6 +147,9 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
} finally {
reachabilityBarrier(this)
}
set(value) {
setBackground(value)
}
fun setBackground(paint: Paint?): TextStyle {
return try {
......@@ -155,13 +164,16 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
}
}
val decorationStyle: org.jetbrains.skia.paragraph.DecorationStyle
var decorationStyle: org.jetbrains.skia.paragraph.DecorationStyle
get() = try {
Stats.onNativeCall()
_nGetDecorationStyle(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) {
setDecorationStyle(value)
}
fun setDecorationStyle(d: DecorationStyle): TextStyle {
Stats.onNativeCall()
......@@ -178,13 +190,16 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
return this
}
val fontStyle: FontStyle
var fontStyle: FontStyle
get() = try {
Stats.onNativeCall()
FontStyle(_nGetFontStyle(_ptr))
} finally {
reachabilityBarrier(this)
}
set(value) {
setFontStyle(value)
}
fun setFontStyle(s: FontStyle): TextStyle {
Stats.onNativeCall()
......@@ -242,13 +257,16 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
return this
}
val fontSize: Float
var fontSize: Float
get() = try {
Stats.onNativeCall()
_nGetFontSize(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) {
setFontSize(value)
}
fun setFontSize(size: Float): TextStyle {
Stats.onNativeCall()
......@@ -256,13 +274,16 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
return this
}
val fontFamilies: Array<String>
var fontFamilies: Array<String>
get() = try {
Stats.onNativeCall()
_nGetFontFamilies(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) {
setFontFamilies(value)
}
fun setFontFamily(family: String): TextStyle {
return setFontFamilies(arrayOf(family))
......@@ -274,13 +295,16 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
return this
}
val height: Float?
var height: Float?
get() = try {
Stats.onNativeCall()
_nGetHeight(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) {
setHeight(value)
}
fun setHeight(height: Float?): TextStyle {
Stats.onNativeCall()
......@@ -288,13 +312,16 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
return this
}
val letterSpacing: Float
var letterSpacing: Float
get() = try {
Stats.onNativeCall()
_nGetLetterSpacing(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) {
setLetterSpacing(value)
}
fun setLetterSpacing(letterSpacing: Float): TextStyle {
Stats.onNativeCall()
......@@ -302,13 +329,16 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
return this
}
val wordSpacing: Float
var wordSpacing: Float
get() = try {
Stats.onNativeCall()
_nGetWordSpacing(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) {
setWordSpacing(value)
}
fun setWordSpacing(wordSpacing: Float): TextStyle {
Stats.onNativeCall()
......@@ -316,7 +346,7 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
return this
}
val typeface: Typeface?
var typeface: Typeface?
get() = try {
Stats.onNativeCall()
val ptr = _nGetTypeface(_ptr)
......@@ -324,6 +354,9 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
} finally {
reachabilityBarrier(this)
}
set(value) {
setTypeface(value)
}
fun setTypeface(typeface: Typeface?): TextStyle {
return try {
......@@ -338,13 +371,16 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
}
}
val locale: String
var locale: String
get() = try {
Stats.onNativeCall()
_nGetLocale(_ptr)
} finally {
reachabilityBarrier(this)
}
set(value) {
setLocale(value)
}
fun setLocale(locale: String?): TextStyle {
Stats.onNativeCall()
......@@ -352,13 +388,16 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
return this
}
val baselineMode: BaselineMode
var baselineMode: BaselineMode
get() = try {
Stats.onNativeCall()
BaselineMode.values().get(_nGetBaselineMode(_ptr))
} finally {
reachabilityBarrier(this)
}
set(value) {
setBaselineMode(value)
}
fun setBaselineMode(baseline: BaselineMode): TextStyle {
Stats.onNativeCall()
......@@ -373,6 +412,7 @@ class TextStyle internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.
} finally {
reachabilityBarrier(this)
}
val isPlaceholder: Boolean
get() = try {
Stats.onNativeCall()
......
package org.jetbrains.skia.svg
class SVGLength(internal val value: Float, unit: SVGLengthUnit) {
class SVGLength(val value: Float, unit: SVGLengthUnit) {
internal val _unit: SVGLengthUnit
......
......@@ -25,7 +25,6 @@ class SVGLengthContext @JvmOverloads constructor(
height.toDouble()
) / Math.sqrt(2.0) / 100.0).toFloat()
}
length.value * dpi / 2.54f
}
SVGLengthUnit.CM -> length.value * dpi / 2.54f
SVGLengthUnit.MM -> length.value * dpi / 25.4f
......
......@@ -26,113 +26,137 @@ class SVGSVG internal constructor(ptr: Long) : SVGContainer(ptr) {
}
}
val x: SVGLength
var x: SVGLength
get() = try {
Stats.onNativeCall()
_nGetX(_ptr)
} finally {
Reference.reachabilityFence(this)
}
val y: SVGLength
get() = try {
set(value) {
setX(value)
}
fun setX(length: SVGLength): SVGSVG {
return try {
Stats.onNativeCall()
_nGetY(_ptr)
_nSetX(_ptr, length.value, length._unit.ordinal)
this
} finally {
Reference.reachabilityFence(this)
}
val width: SVGLength
}
var y: SVGLength
get() = try {
Stats.onNativeCall()
_nGetWidth(_ptr)
_nGetY(_ptr)
} finally {
Reference.reachabilityFence(this)
}
val height: SVGLength
get() = try {
set(value) {
setY(value)
}
fun setY(length: SVGLength): SVGSVG {
return try {
Stats.onNativeCall()
_nGetHeight(_ptr)
_nSetY(_ptr, length.value, length._unit.ordinal)
this
} finally {
Reference.reachabilityFence(this)
}
val preserveAspectRatio: SVGPreserveAspectRatio
}
var width: SVGLength
get() = try {
Stats.onNativeCall()
_nGetPreserveAspectRatio(_ptr)
_nGetWidth(_ptr)
} finally {
Reference.reachabilityFence(this)
}
val viewBox: Rect?
get() = try {
set(value) {
setWidth(value)
}
fun setWidth(length: SVGLength): SVGSVG {
return try {
Stats.onNativeCall()
_nGetViewBox(_ptr)
_nSetWidth(_ptr, length.value, length._unit.ordinal)
this
} finally {
Reference.reachabilityFence(this)
}
}
fun getIntrinsicSize(lc: SVGLengthContext): Point {
return try {
var height: SVGLength
get() = try {
Stats.onNativeCall()
_nGetIntrinsicSize(_ptr, lc.width, lc.height, lc.dpi)
_nGetHeight(_ptr)
} finally {
Reference.reachabilityFence(this)
}
set(value) {
setHeight(value)
}
fun setX(length: SVGLength): SVGSVG {
fun setHeight(length: SVGLength): SVGSVG {
return try {
Stats.onNativeCall()
_nSetX(_ptr, length.value, length._unit.ordinal)
_nSetHeight(_ptr, length.value, length._unit.ordinal)
this
} finally {
Reference.reachabilityFence(this)
}
}
fun setY(length: SVGLength): SVGSVG {
return try {
var preserveAspectRatio: SVGPreserveAspectRatio
get() = try {
Stats.onNativeCall()
_nSetY(_ptr, length.value, length._unit.ordinal)
this
_nGetPreserveAspectRatio(_ptr)
} finally {
Reference.reachabilityFence(this)
}
set(value) {
setPreserveAspectRatio(value)
}
fun setWidth(length: SVGLength): SVGSVG {
fun setPreserveAspectRatio(ratio: SVGPreserveAspectRatio): SVGSVG {
return try {
Stats.onNativeCall()
_nSetWidth(_ptr, length.value, length._unit.ordinal)
_nSetPreserveAspectRatio(_ptr, ratio._align._value, ratio._scale.ordinal)
this
} finally {
Reference.reachabilityFence(this)
}
}
fun setHeight(length: SVGLength): SVGSVG {
return try {
var viewBox: Rect?
get() = try {
Stats.onNativeCall()
_nSetHeight(_ptr, length.value, length._unit.ordinal)
this
_nGetViewBox(_ptr)
} finally {
Reference.reachabilityFence(this)
}
set(value) {
require(value != null) { "Can't set viewBox with value == null" }
setViewBox(value)
}
fun setPreserveAspectRatio(ratio: SVGPreserveAspectRatio): SVGSVG {
fun setViewBox(viewBox: Rect): SVGSVG {
return try {
Stats.onNativeCall()
_nSetPreserveAspectRatio(_ptr, ratio._align._value, ratio._scale.ordinal)
_nSetViewBox(_ptr, viewBox.left, viewBox.top, viewBox.right, viewBox.bottom)
this
} finally {
Reference.reachabilityFence(this)
}
}
fun setViewBox(viewBox: Rect): SVGSVG {
fun getIntrinsicSize(lc: SVGLengthContext): Point {
return try {
Stats.onNativeCall()
_nSetViewBox(_ptr, viewBox.left, viewBox.top, viewBox.right, viewBox.bottom)
this
_nGetIntrinsicSize(_ptr, lc.width, lc.height, lc.dpi)
} finally {
Reference.reachabilityFence(this)
}
......
......@@ -32,9 +32,10 @@ class SkiaWindowTest {
private fun paragraph(size: Float, text: String) =
ParagraphBuilder(ParagraphStyle(), fontCollection)
.pushStyle(
TextStyle()
.setColor(Color.RED.rgb)
.setFontSize(size)
TextStyle().apply {
color = Color.RED.rgb
fontSize = size
}
)
.addText(text)
.popStyle()
......@@ -344,7 +345,7 @@ class SkiaWindowTest {
}
canvas.drawRect(Rect(x.toFloat(), 0f, x.toFloat() + size.toFloat(), size.toFloat()), Paint().apply {
setColor(Color.RED.rgb)
color = Color.RED.rgb
})
layer.needRedraw()
......
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