Commit 711c728b authored by Roman Sedaikin's avatar Roman Sedaikin

Added [ColorSpace.sRGBLinear], refactored [Path] and [Paint].

parent 000e45b8
......@@ -22,6 +22,7 @@ class ColorSpace : Managed {
}
val sRGB = ColorSpace(_nMakeSRGB(), false)
val sRGBLinear = ColorSpace(_nMakeSRGBLinear(), false)
val displayP3 = ColorSpace(_nMakeDisplayP3(), false)
}
......
......@@ -438,13 +438,16 @@ class Paint : Managed {
*
* @return zero and greater miter limit
*/
val strokeMiter: Float
var strokeMiter: Float
get() = try {
Stats.onNativeCall()
_nGetStrokeMiter(_ptr)
} finally {
Reference.reachabilityFence(this)
}
set(value) {
setStrokeMiter(value)
}
/**
* Sets the limit at which a sharp corner is drawn beveled.
......@@ -465,13 +468,16 @@ class Paint : Managed {
/**
* @return the geometry drawn at the beginning and end of strokes.
*/
val strokeCap: PaintStrokeCap
var strokeCap: PaintStrokeCap
get() = try {
Stats.onNativeCall()
PaintStrokeCap.values().get(_nGetStrokeCap(_ptr))
} finally {
Reference.reachabilityFence(this)
}
set(value) {
setStrokeCap(value)
}
/**
* Sets the geometry drawn at the beginning and end of strokes.
......@@ -492,13 +498,16 @@ class Paint : Managed {
/**
* @return the geometry drawn at the corners of strokes.
*/
val strokeJoin: PaintStrokeJoin
var strokeJoin: PaintStrokeJoin
get() = try {
Stats.onNativeCall()
PaintStrokeJoin.values().get(_nGetStrokeJoin(_ptr))
} finally {
Reference.reachabilityFence(this)
}
set(value) {
setStrokeJoin(value)
}
/**
* Sets the geometry drawn at the corners of strokes.
......@@ -564,7 +573,7 @@ class Paint : Managed {
* @return [Shader] or null
* @see [https://fiddle.skia.org/c/@Paint_refShader](https://fiddle.skia.org/c/@Paint_refShader)
*/
val shader: Shader?
var shader: Shader?
get() = try {
Stats.onNativeCall()
val shaderPtr = _nGetShader(_ptr)
......@@ -572,6 +581,9 @@ class Paint : Managed {
} finally {
Reference.reachabilityFence(this)
}
set(value) {
setShader(value)
}
/**
* @param shader how geometry is filled with color; if null, color is used instead
......@@ -594,7 +606,7 @@ class Paint : Managed {
* @return [ColorFilter] or null
* @see [https://fiddle.skia.org/c/@Paint_refColorFilter](https://fiddle.skia.org/c/@Paint_refColorFilter)
*/
val colorFilter: ColorFilter?
var colorFilter: ColorFilter?
get() = try {
Stats.onNativeCall()
val colorFilterPtr = _nGetColorFilter(_ptr)
......@@ -602,6 +614,9 @@ class Paint : Managed {
} finally {
Reference.reachabilityFence(this)
}
set(value) {
setColorFilter(value)
}
/**
* @param colorFilter [ColorFilter] to apply to subsequent draw
......@@ -628,13 +643,16 @@ class Paint : Managed {
*
* @return mode used to combine source color with destination color
*/
val blendMode: BlendMode?
var blendMode: BlendMode?
get() = try {
Stats.onNativeCall()
BlendMode.values().get(_nGetBlendMode(_ptr))
} finally {
Reference.reachabilityFence(this)
}
set(value) {
setBlendMode(value)
}
/**
* @return true if BlendMode is BlendMode.SRC_OVER, the default.
......@@ -648,10 +666,10 @@ class Paint : Managed {
* @param mode BlendMode used to combine source color and destination
* @return this
*/
fun setBlendMode(mode: BlendMode): Paint {
fun setBlendMode(mode: BlendMode?): Paint {
assert(mode != null) { "Paint::setBlendMode expected mode != null" }
Stats.onNativeCall()
_nSetBlendMode(_ptr, mode.ordinal)
_nSetBlendMode(_ptr, mode!!.ordinal)
return this
}
......@@ -659,7 +677,7 @@ class Paint : Managed {
* @return [PathEffect] or null
* @see [https://fiddle.skia.org/c/@Paint_refPathEffect](https://fiddle.skia.org/c/@Paint_refPathEffect)
*/
val pathEffect: PathEffect?
var pathEffect: PathEffect?
get() = try {
Stats.onNativeCall()
val pathEffectPtr = _nGetPathEffect(_ptr)
......@@ -667,6 +685,9 @@ class Paint : Managed {
} finally {
Reference.reachabilityFence(this)
}
set(value) {
setPathEffect(value)
}
/**
* @param p replace [Path] with a modification when drawn
......
......@@ -447,13 +447,16 @@ class Path internal constructor(ptr: Long) : Managed(ptr, _FinalizerHolder.PTR),
}
}
val fillMode: PathFillMode
var fillMode: PathFillMode
get() = try {
Stats.onNativeCall()
PathFillMode.values().get(_nGetFillMode(_ptr))
} finally {
Reference.reachabilityFence(this)
}
set(value) {
setFillMode(value)
}
fun setFillMode(fillMode: PathFillMode): Path {
Stats.onNativeCall()
......
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