Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -95,6 +95,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,24 +488,24 @@ 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 || platformTextDelegate == null) {
localCanvas = canvas
} else {
currentParagraphHashCode = paragraphHashCode()
if (platformTextDelegate?.needRedrawText(
if (!platformTextDelegate.needRedrawText(
nativeCanvas = canvas,
paragraphHashKey = currentParagraphHashCode,
width = layoutCache.layoutSize.width,
height = layoutCache.layoutSize.height
) == false
)
) return
ensureTextBitmap()
}
Expand Down Expand Up @@ -571,6 +572,7 @@ internal class TextStringSimpleNode(
}
}
}

private fun paragraphHashCode(): Int {
var result = text.hashCode()
result = 31 * result + style.hashCode()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ internal class PlatformContextImpl(
override val textInputService: PlatformTextInputService,
override val textToolbar: TextToolbar,
override val semanticsOwnerListener: PlatformContext.SemanticsOwnerListener?,
override val drawInSkia: Boolean = false,
densityProvider: () -> Density,
) : PlatformContext by PlatformContext.Empty {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.compose.ui.graphics.Vertices
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.IntSize
import kotlinx.cinterop.COpaquePointer
import platform.arkui.ArkUI_RenderNodeHandle
import kotlin.experimental.ExperimentalObjCRefinement


Expand Down Expand Up @@ -55,6 +56,8 @@ private inline fun CornerRadius.greaterThen(rhs: CornerRadius): Boolean {
@OptIn(ExperimentalObjCRefinement::class)
@HiddenFromObjC
internal class AdaptiveCanvas(factory: COpaquePointer) : OHOSNativeCanvas {
override val canvasType: CanvasType get() = CanvasType.Native

// 持有原始Native指针
private val rawCanvasProxyHandle: OHNativeCanvasProxy_Handle? =
androidx_compose_ui_arkui_utils_createOHNativeCanvasProxy(factory)
Expand All @@ -67,7 +70,7 @@ internal class AdaptiveCanvas(factory: COpaquePointer) : OHOSNativeCanvas {
LogPrintUtil.verbose("AdaptiveCanvas::beginDraw")
}

override fun drawLayer() {
override fun drawLayer(layer: ArkUI_RenderNodeHandle) {
nativeCanvasProxy.drawLayer()
LogPrintUtil.verbose("AdaptiveCanvas::drawLayer")
}
Expand Down Expand Up @@ -325,6 +328,4 @@ internal class AdaptiveCanvas(factory: COpaquePointer) : OHOSNativeCanvas {
// TODO: destroy some resources
LogPrintUtil.verbose("AdaptiveCanvas::destroy")
}

override val canvasType: CanvasType get() = CanvasType.Native
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package androidx.compose.ui.platform.nativefoundation

import androidx.compose.ui.arkui.RenderingBackend
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.OHOSParagraph
import androidx.compose.ui.text.OHOSParagraphIntrinsics
import androidx.compose.ui.text.Paragraph
import androidx.compose.ui.text.ParagraphIntrinsics
import androidx.compose.ui.text.Placeholder
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.platform.PlatformParagraphFactory
import androidx.compose.ui.text.platform.platformParagraphFactory
import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.Density

private var didInject = false

internal fun injectForCompose(renderBackend: RenderingBackend) {

if (didInject) return
didInject = true

/*注入 OHOS 平台的 Paragraph */
platformParagraphFactory = object : PlatformParagraphFactory {
override fun createParagraph(
intrinsics: ParagraphIntrinsics,
maxLines: Int,
ellipsis: Boolean,
constraints: Constraints
): Paragraph? = if (renderBackend == RenderingBackend.ArkUIRenderNode) OHOSParagraph(
intrinsics as OHOSParagraphIntrinsics,
maxLines,
ellipsis,
constraints
) else null

override fun createParagraphIntrinsics(
text: String,
style: TextStyle,
spanStyles: List<AnnotatedString.Range<SpanStyle>>,
placeholders: List<AnnotatedString.Range<Placeholder>>,
density: Density,
fontFamilyResolver: FontFamily.Resolver
): ParagraphIntrinsics? =
if (renderBackend == RenderingBackend.ArkUIRenderNode) OHOSParagraphIntrinsics(
text,
style,
spanStyles,
placeholders,
density,
fontFamilyResolver
) else null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.compose.ui.geometry.RoundRect
import androidx.compose.ui.graphics.Canvas
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.RenderEffect
import platform.arkui.ArkUI_RenderNodeHandle

/*
* Tencent is pleased to support the open source community by making ovCompose available.
Expand All @@ -27,7 +28,7 @@ interface OHOSNativeCanvas : Canvas {
fun onPreDraw()

// fun drawLayer(layer: CALayer)
fun drawLayer()
fun drawLayer(layer: ArkUI_RenderNodeHandle)

fun drawLayerWithNativeCanvas(nativeCanvas: OHOSNativeCanvas)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ internal class ComposeSceneMediator(
TextInputService(),
PlatformTextToolbar(controller.messenger, PlatformClipboardProxy(controller.messenger)),
semanticsOwnerListener,
densityProvider = { scene.density }
densityProvider = { scene.density },
drawInSkia = configuration.renderingBackend == RenderingBackend.XComponent
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package androidx.compose.ui.text

import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.unit.Density
import platform.arkui.ArkUI_RenderNodeHandle
import org.jetbrains.skia.Point

class OHNativeParagraphProxy {

fun getRenderNodeHandle(): ArkUI_RenderNodeHandle? {
return null
}

fun getFirstBaseline(): Float {
// TODO: Implement logic to get the first baseline
return 0F
}

fun getLineLeft(lineIndex: Int): Float {
// TODO: Implement logic to get the line left
return 0F
}

fun getLineRight(lineIndex: Int): Float {
// TODO: Implement logic to get the line right
return 0F
}

fun getLineTop(lineIndex: Int): Float {
// TODO: Implement logic to get the line top
return 0F
}

fun getLineBottom(lineIndex: Int): Float {
// TODO: Implement logic to get the line bottom
return 0F
}

fun getLineHeight(lineIndex: Int): Float {
// TODO: Implement logic to get the line height
return 0F
}

fun getLineWidth(lineIndex: Int): Float {
// TODO: Implement logic to get the line width
return 0F
}

fun getLineStart(lineIndex: Int): Int {
// TODO: Implement logic to get the line start
return 0
}

fun getLineEnd(lineIndex: Int, visibleEnd: Boolean): Int {
// TODO: Implement logic to get the line end
return 0
}

fun isLineEllipsized(lineIndex: Int): Boolean {
// TODO: Implement logic to check if the line is ellipsized
return false
}

fun getLineForOffset(offset: Int): Int {
// TODO: Implement logic to get the line offset
return 0
}

fun lineCount(): Int {
// TODO: Implement logic to get the line count
return 0
}

fun getRectsForRange(start: Int, end: Int): List<Rect> {
// TODO: Implement logic to get the rects for the specified range
return emptyList()
}

fun getCursorRect(offset: Int): Rect {
// TODO: Implement logic to get the cursor rect at the specified offset
return Rect(0F, 0F, 0F, 0F)
}

// 获取坐标对应的字符所在的索引位置
fun getOffsetForPositionX(x: Float, y: Float): Int {
// TODO: Implement logic to get the offset for the specified position
return 0
}

fun getLastBaseline(): Float {
// TODO: Implement logic to get the last baseline
return 0F
}

// 根据字符所在的offset偏移找到该字符单词的范围
fun getWordBoundary(offset: Int): TextRange {
// TODO: Implement logic to get the word boundary for the specified offset
return TextRange(0, 0)
}

fun paintWithColor(colorValue: ULong) {
}

fun measureAndLayout(text: String, maxWidth: Float, maxHeight: Float, density: Density): Point {
// TODO: Implement text measurement and layout logic
return Point(0F, 0F)
}

fun relayoutWithMaxWidth(maxWidth: Float, maxHeight: Float, maxLines: Int, ellipsis: Boolean) {
// TODO: Implement text measurement and layout logic
}

}
Loading