Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
6b67931
ohos: Add skeleton code for OHOS text measurement and rendering
Sep 28, 2025
a34ddc2
feat:add picture recorder for render node
bulloo Oct 7, 2025
64268a2
Merge pull request #1 from bulloo/wxjer_renderNode
sebuntin Oct 9, 2025
c4be0c4
ohos: Implement OHComposeNativePaint and enhance AdaptiveCanvas with …
Oct 9, 2025
fc27bab
ohos: Implement save, restore, and translate methods in OHNativeCanva…
Oct 10, 2025
f2b2658
ohos: Introduce NativeBasicShader and related gradient shaders for en…
Oct 13, 2025
917adb0
Merge pull request #3 from ywenjing/ohos-compose-ywjing
ywenjing Oct 14, 2025
ff6eb1c
refactor: Update enum references and improve rendering node structure
Oct 16, 2025
10e1477
ohos: Fix OverScroll animation issues by correctly parsing VSync sign…
Oct 22, 2025
dbef123
ohos: Provides native support for measuring, layout, and drawing of o…
Oct 23, 2025
b90d637
Merge pull request #7 from ywenjing/oh-compoe-ywenjing
sebuntin Oct 23, 2025
11141c7
ohos: Add support for Debug configuration in build.gradle.kts and adj…
Oct 23, 2025
3a977da
ohos: Enhance AdaptiveCanvas with drawParagraph method and improve na…
Oct 24, 2025
7e33ba8
Merge pull request #8 from ywenjing/oh-compose-ywenjing
sebuntin Oct 25, 2025
9a32515
ohos: Refactor Paragraph handling to integrate spanStyle and placehol…
Oct 27, 2025
804a59c
ohos: Refactor Paragraph handling to integrate spanStyle and placehol…
Oct 27, 2025
9395ef8
feat:wrapper OH_HiTrace
bulloo Oct 18, 2025
f4cfc11
Merge branch 'ohos-compose-1.6.1-20250919' into wxjer_trace
bulloo Oct 28, 2025
e13a895
ohos: Refactor Paragraph handling to integrate spanStyle and placehol…
Oct 27, 2025
90b3e66
Merge pull request #5 from bulloo/wxjer_trace
bulloo Oct 29, 2025
18c323b
refactor: Update Paragraph class for improved style handling and memo…
Oct 29, 2025
9aaf8a8
feat: Add isTraceEnabled property to TraceUtil for trace control
Oct 29, 2025
2ce4f2f
refactor: Improve invalidate logic and enhance hash functions for bet…
Oct 29, 2025
1b2af1e
refactor: Enhance parameter passing and const correctness in canvas d…
Oct 30, 2025
2e0da5d
feat:implement drawingItem diff
bulloo Nov 1, 2025
6fe1a62
Merge pull request #9 from bulloo/wxjer_diff
sebuntin Nov 3, 2025
22fbf30
fix: 解决LazyColumn组件的滑动问题
Nov 2, 2025
c48de70
feat: Add LayerSourceType metadata to distinguish LazyList item layers
Nov 3, 2025
1e18964
refactor: Update logging syntax to use lambda expressions for better …
Nov 11, 2025
d78a58f
refactor: Add some trace point and improve rendering performance
Nov 13, 2025
ade7cf8
feat: Add support for drawing oval, arc, image, and path shapes in ca…
Nov 14, 2025
93de649
refactor: Improve rendering backend handling
Nov 18, 2025
604aeb2
feat: Add support for drawing points and rendering text by converting…
Nov 19, 2025
73b2f65
feat: Implement clipping functionality for rectangles, round rectangl…
Nov 20, 2025
432cdf5
feat: Enhance AdaptiveCanvas with clearClip, saveLayer, enableZ, and …
Nov 20, 2025
9ffee47
feat: Enhance AdaptiveCanvas with clearClip, saveLayer, enableZ, and …
Nov 20, 2025
f250582
feat: Enhance AdaptiveCanvas with clearClip, saveLayer, enableZ, and …
Nov 20, 2025
113de7d
feat: Refactor drawing logic to incorporate translation adjustments a…
Nov 20, 2025
181f80e
feat: Introduce AsyncTaskRenderNode for asynchronous rendering tasks …
Nov 24, 2025
f38294f
feat: Add CircleGradientRenderNode and PathGradientRenderNode for enh…
Nov 25, 2025
3d49d57
feat: Implement OHDrawingPixelMapCache for optimized pixel map handli…
Nov 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ actual object LogPrintUtil {
get() = TODO("Not yet implemented")
set(value) {}

actual fun verbose(message: String) {
println(message)
actual inline fun verbose(message: () -> String) {
if (isLogEnabled) {
println(message())
}
}

actual var isLogEnabled: Boolean
get() = TODO("Not yet implemented")
set(value) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@ actual object TraceUtil {
actual inline fun <T> traceSync(sectionName: String, block: () -> T): T {
return block()
}

actual var isTraceEnabled: Boolean
get() = TODO("Not yet implemented")
set(value) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,16 @@ interface LogPrintInterface {

expect object LogPrintUtil {
var logPrintImpl: LogPrintInterface?
fun verbose(message: String)
var isLogEnabled: Boolean

/**
* Lazy evaluation version of verbose. The message lambda is only evaluated when logging is enabled.
* This avoids unnecessary string concatenation when logging is disabled.
*
* Usage:
* ```
* LogPrintUtil.verbose { "AdaptiveCanvas::translate, dx: $dx, dy: $dy" }
* ```
*/
inline fun verbose(message: () -> String)
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface SyncTraceInterface {
expect object TraceUtil {
var traceImpl: SyncTraceInterface?
val globalVsyncId: Long
var isTraceEnabled: Boolean
fun increaseVsyncId(): Long
inline fun <T> traceSync(sectionName: String, block: () -> T): T
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,39 @@ import platform.ohos.LOG_APP
import platform.ohos.LOG_DEBUG
import platform.ohos.OH_LOG_Print


/**
* Compile-time constant to control verbose logging.
* When set to false, the compiler will completely remove all verbose log code (zero overhead).
* When set to true, verbose logging is controlled at runtime via [LogPrintUtil.isLogEnabled].
*/
const val ENABLE_VERBOSE_LOG_COMPILE_TIME = false

actual object LogPrintUtil {
private var _isLogEnabled: Boolean = true

private val DefaultLogger = object : LogPrintInterface {
override fun verbose(message: String) {
OH_LOG_Print(
type = LOG_APP,
level = LOG_DEBUG,
domain = 0x0000u,
tag = "ovCompose",
tag = "ovComposeKt",
fmt = message
)
}
}
actual var logPrintImpl: LogPrintInterface? = DefaultLogger

actual fun verbose(message: String) {
this.logPrintImpl?.verbose(message)
actual inline fun verbose(message: () -> String) {
if (ENABLE_VERBOSE_LOG_COMPILE_TIME && isLogEnabled) {
this.logPrintImpl?.verbose(message())
}
}

actual var isLogEnabled: Boolean
get() = _isLogEnabled
set(value) {
_isLogEnabled = value
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,24 @@ package androidx.compose.common.interop
import platform.ohos.OH_HiTrace_FinishTrace
import platform.ohos.OH_HiTrace_StartTrace


/**
* Compile-time constant to control verbose tracing.
* When set to false, the compiler will completely remove all verbose trace code (zero overhead).
* When set to true, verbose tracing is controlled at runtime via [TraceUtil.isTraceEnabled].
*/
const val ENABLE_VERBOSE_TRACE_COMPILE_TIME = false

actual object TraceUtil {
private var _isTraceEnabled = true
private val DefaultTrace = object : SyncTraceInterface {
override fun startTrace(scene: String) { OH_HiTrace_StartTrace(scene) }
override fun endTrace(sectionName: String?) { OH_HiTrace_FinishTrace() }
override fun startTrace(scene: String) {
OH_HiTrace_StartTrace(scene)
}

override fun endTrace(sectionName: String?) {
OH_HiTrace_FinishTrace()
}
}

actual var traceImpl: SyncTraceInterface? = DefaultTrace
Expand All @@ -35,7 +49,21 @@ actual object TraceUtil {
}

actual inline fun <T> traceSync(sectionName: String, block: () -> T): T {
traceImpl?.startTrace("$sectionName[VsyncId:$globalVsyncId]")
return try { block() } finally { traceImpl?.endTrace(sectionName) }
if (ENABLE_VERBOSE_TRACE_COMPILE_TIME) {
if (isTraceEnabled) traceImpl?.startTrace("$sectionName[VsyncId:$globalVsyncId]")
return try {
block()
} finally {
if (isTraceEnabled) traceImpl?.endTrace(sectionName)
}
} else {
return block()
}
}

actual var isTraceEnabled: Boolean
get() = _isTraceEnabled
set(value) {
_isTraceEnabled = value
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package androidx.compose.common.interop
import platform.Foundation.NSLog

actual object LogPrintUtil {
private var _isLogEnabled: Boolean = false
private val DefaultLogger = object : LogPrintInterface {
override fun verbose(message: String) {
NSLog(message)
Expand All @@ -27,7 +28,15 @@ actual object LogPrintUtil {

actual var logPrintImpl: LogPrintInterface? = DefaultLogger

actual fun verbose(message: String) {
this.logPrintImpl?.verbose("[shiqi]${message}")
actual inline fun verbose(message: () -> String) {
if (isLogEnabled) {
this.logPrintImpl?.verbose("[shiqi]${message()}")
}
}

actual var isLogEnabled: Boolean
get() = _isLogEnabled
set(value) {
_isLogEnabled = value
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ actual object TraceUtil {
private val DefaultTrace = DefaultSignPostSyncTrace
actual var traceImpl: SyncTraceInterface? = DefaultTrace
private var _vsyncId = 0L
private var _isTraceEnabled = true
actual val globalVsyncId: Long get() = _vsyncId

actual fun increaseVsyncId(): Long {
Expand All @@ -32,9 +33,19 @@ actual object TraceUtil {
}

actual inline fun <T> traceSync(sectionName: String, block: () -> T): T {
this.traceImpl?.startTrace("$sectionName[VsyncId:${this.globalVsyncId}]")
return try { block() } finally { TraceUtil.traceImpl?.endTrace(sectionName) }
if (isTraceEnabled) this.traceImpl?.startTrace("$sectionName[VsyncId:${this.globalVsyncId}]")
return try {
block()
} finally {
if (isTraceEnabled) this.traceImpl?.endTrace(sectionName)
}
}

actual var isTraceEnabled: Boolean
get() = _isTraceEnabled
set(value) {
_isTraceEnabled = value
}
}

object DefaultSignPostSyncTrace : SyncTraceInterface {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@file:Suppress("FunctionName")

package androidx.compose.export.ui.arkui

import androidx.compose.export.annotation.InternalExportApi
import androidx.compose.ui.platform.nativefoundation._invokeKotlinAsyncTask
import androidx.compose.ui.platform.nativefoundation._invokeKotlinMainThreadCallback


/**
* C++回调函数,用于异步执行Kotlin lambda
* 这个函数会被C++侧调用(在后台线程)
*
* @param stableRefPtr StableRef指针,指向Kotlin lambda
* @return 执行结果(PixelMap指针)
*/
@InternalExportApi
@CName("invokeKotlinAsyncTask")
fun _Export_invokeKotlinAsyncTask(stableRefPtr: Long) = _invokeKotlinAsyncTask(stableRefPtr)

@InternalExportApi
@CName("invokeKotlinMainThreadCallback")
fun _Export_invokeKotlinMainThreadCallback(
stableRefPtr: Long,
renderNodePtr: Long,
pixelMapPtr: Long
) =
_invokeKotlinMainThreadCallback(stableRefPtr, renderNodePtr, pixelMapPtr)


Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package androidx.compose.foundation.layout

import androidx.compose.common.interop.TraceUtil
import androidx.compose.runtime.Stable
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.Measurable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package androidx.compose.foundation

import androidx.annotation.FloatRange
import androidx.compose.common.interop.TraceUtil
import androidx.compose.runtime.Stable
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.compose.foundation.lazy.layout.LazyLayoutAnimation.Companion.Not
import androidx.compose.ui.Alignment
import androidx.compose.ui.graphics.GraphicsLayerScope
import androidx.compose.ui.layout.Placeable
import androidx.compose.ui.node.LayerSourceType
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.util.fastForEach
Expand Down Expand Up @@ -207,9 +208,21 @@ internal class LazyListMeasuredItem @ExperimentalFoundationApi constructor(
}
offset += visualOffset
if (isVertical) {
placeable.placeWithLayer(offset, layerBlock = layerBlock)
placeable.placeWithLayer(
offset,
layerBlock = layerBlock,
// region Huawei Code
sourceType = LayerSourceType.LAZY_LIST_ITEM
// end region
)
} else {
placeable.placeRelativeWithLayer(offset, layerBlock = layerBlock)
placeable.placeRelativeWithLayer(
offset,
layerBlock = layerBlock,
// region Huawei Code
sourceType = LayerSourceType.LAZY_LIST_ITEM
// end region
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package androidx.compose.foundation.text.modifiers
import androidx.compose.foundation.text.DefaultMinLines
import androidx.compose.runtime.ComposeTabService
import androidx.compose.runtime.EnableIOSParagraph
import androidx.compose.runtime.EnableOHOSParagraph
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
Expand Down Expand Up @@ -584,7 +585,7 @@ internal class TextAnnotatedStringNode(
val textLayoutResult = layoutCache.textLayoutResult
val localParagraph = textLayoutResult.multiParagraph
// region Tencent Code
if (drawInSkia || EnableIOSParagraph) {
if (drawInSkia || EnableIOSParagraph || EnableOHOSParagraph) {
localCanvas = canvas
} else {
val width = textLayoutResult.size.width
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package androidx.compose.foundation.text.modifiers
import androidx.compose.foundation.text.DefaultMinLines
import androidx.compose.runtime.ComposeTabService
import androidx.compose.runtime.EnableIOSParagraph
import androidx.compose.runtime.EnableOHOSParagraph
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
Expand Down Expand Up @@ -95,6 +96,7 @@ internal class TextStringSimpleNode(
PlatformTextNodeFactory.instance.createPlatformDelegateTextNode()
private var localBitmap: ImageBitmap? = null
private var localCanvas: Canvas? = null

// endregion
private var baselineCache: MutableMap<AlignmentLine, Int>? = null
private var _layoutCache: ParagraphLayoutCache? = null
Expand Down Expand Up @@ -487,15 +489,15 @@ internal class TextStringSimpleNode(

val localParagraph = requireNotNull(layoutCache.paragraph) { "no paragraph" }
// region Tencent Code
if (ComposeTabService.textAsyncPaint && !drawInSkia) {
if (ComposeTabService.textAsyncPaint && !drawInSkia && platformTextDelegate != null) {
asyncDrawIntoCanvas(localParagraph)
return
}
// endregion
drawIntoCanvas { canvas ->
var currentParagraphHashCode = 0
// region Tencent Code
if (drawInSkia || EnableIOSParagraph) {
if (drawInSkia || EnableIOSParagraph || EnableOHOSParagraph) {
localCanvas = canvas
} else {
currentParagraphHashCode = paragraphHashCode()
Expand Down Expand Up @@ -571,6 +573,7 @@ internal class TextStringSimpleNode(
}
}
}

private fun paragraphHashCode(): Int {
var result = text.hashCode()
result = 31 * result + style.hashCode()
Expand Down
1 change: 1 addition & 0 deletions compose/runtime/runtime/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ if(AndroidXComposePlugin.isMultiplatformEnabled(project)) {
implementation(libs.kotlinCoroutinesCore)
implementation(libs.atomicFu)
implementation(project(":collection:collection"))
api(project(":compose:common"))
}
jvmMain.dependencies {
implementation(libs.kotlinStdlib)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package androidx.compose.runtime

import androidx.compose.common.interop.TraceUtil
import androidx.compose.runtime.snapshots.fastForEach
import kotlin.coroutines.Continuation
import kotlin.coroutines.resumeWithException
Expand Down Expand Up @@ -59,18 +60,20 @@ class BroadcastFrameClock(
* [sendFrame].
*/
fun sendFrame(timeNanos: Long) {
synchronized(lock) {
// Rotate the lists so that if a resumed continuation on an immediate dispatcher
// bound to the thread calling sendFrame immediately awaits again we don't disrupt
// iteration of resuming the rest.
val toResume = awaiters
awaiters = spareList
spareList = toResume
TraceUtil.traceSync("BroadcastFrameClock.sendFrame") {
synchronized(lock) {
// Rotate the lists so that if a resumed continuation on an immediate dispatcher
// bound to the thread calling sendFrame immediately awaits again we don't disrupt
// iteration of resuming the rest.
val toResume = awaiters
awaiters = spareList
spareList = toResume

for (i in 0 until toResume.size) {
toResume[i].resume(timeNanos)
for (i in 0 until toResume.size) {
toResume[i].resume(timeNanos)
}
toResume.clear()
}
toResume.clear()
}
}

Expand Down
Loading