Skip to content
Open
Show file tree
Hide file tree
Changes from 8 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 @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ expect val CurrentPlatform: PlatformType
/** IOSParagraph开关 */
var EnableIOSParagraph = false

/** OHOSParagraph开关 **/
var EnableOHOSParagraph = false

var EnableSkiaBackedCanvasLog = false

var DeleteRedundantGraphicsLayer = false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
package = androidx.compose.ui.arkui.utils
headers = arkui_utils_export.h canvas/oh_native_canvas_export.h
headers = arkui_utils_export.h canvas/oh_native_canvas_export.h constants/oh_native_enums.h
3 changes: 2 additions & 1 deletion compose/ui/ui-arkui/src/ohosArm64Main/cinterop/arkui.def
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ headers = ace/xcomponent/native_interface_xcomponent.h native_interface_accessib
napi/common.h napi/native_api.h \
js_native_api_types.h js_native_api.h node_api.h node_api_types.h \
drawable_descriptor.h native_type.h native_node.h native_node_napi.h native_interface.h \
ui_input_event.h native_gesture.h native_render.h
ui_input_event.h native_gesture.h native_render.h \
native_drawing/drawing_types.h native_drawing/drawing_shader_effect.h native_drawing/drawing_point.h native_drawing/drawing_error_code.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,304 @@
/*
* Copyright (c) 2021-2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* @addtogroup Drawing
* @{
*
* @brief Provides functions such as 2D graphics rendering, text drawing, and image display.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
*
* @since 8
* @version 1.0
*/

/**
* @file drawing_brush.h
*
* @brief Declares functions related to the <b>brush</b> object in the drawing module.
*
* @kit ArkGraphics2D
* @library libnative_drawing.so
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @since 8
* @version 1.0
*/

#ifndef C_INCLUDE_DRAWING_BRUSH_H
#define C_INCLUDE_DRAWING_BRUSH_H

#include "drawing_error_code.h"
#include "drawing_types.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief Defines a colorspace manager. Introduces the color space information defined by ColorManager.
* @since 20
*/
typedef struct OH_NativeColorSpaceManager OH_NativeColorSpaceManager;

/**
* @brief Creates an <b>OH_Drawing_Brush</b> object.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @return Returns the pointer to the <b>OH_Drawing_Brush</b> object created.
* @since 8
* @version 1.0
*/
OH_Drawing_Brush* OH_Drawing_BrushCreate(void);

/**
* @brief Creates an <b>OH_Drawing_Brush</b> copy object.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object.
* @return Returns the pointer to the <b>OH_Drawing_Brush</b> object created.
* If nullptr is returned, the creation fails.
* The possible cause of the failure is that the available memory is empty or a nullptr is passed.
* @since 12
* @version 1.0
*/
OH_Drawing_Brush* OH_Drawing_BrushCopy(OH_Drawing_Brush* brush);

/**
* @brief Destroys an <b>OH_Drawing_Brush</b> object and reclaims the memory occupied by the object.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object.
* @since 8
* @version 1.0
*/
void OH_Drawing_BrushDestroy(OH_Drawing_Brush* brush);

/**
* @brief Checks whether anti-aliasing is enabled for a brush. If anti-aliasing is enabled,
* edges will be drawn with partial transparency.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object.
* @return Returns <b>true</b> if anti-aliasing is enabled; returns <b>false</b> otherwise.
* @since 8
* @version 1.0
*/
bool OH_Drawing_BrushIsAntiAlias(const OH_Drawing_Brush* brush);

/**
* @brief Enables or disables anti-aliasing for a brush. If anti-aliasing is enabled,
* edges will be drawn with partial transparency.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object.
* @param antiAlias Specifies whether to enable anti-aliasing. The value <b>true</b> means
* to enable anti-aliasing, and <b>false</b> means the opposite.
* @since 8
* @version 1.0
*/
void OH_Drawing_BrushSetAntiAlias(OH_Drawing_Brush* brush, bool antiAlias);

/**
* @brief Obtains the color of a brush. The color is used by the brush to fill in a shape.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object.
* @return Returns a 32-bit (ARGB) variable that describes the color.
* @since 8
* @version 1.0
*/
uint32_t OH_Drawing_BrushGetColor(const OH_Drawing_Brush* brush);

/**
* @brief Sets the color for a brush. The color will be used by the brush to fill in a shape.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object.
* @param color Indicates the color to set, which is a 32-bit (ARGB) variable.
* @since 8
* @version 1.0
*/
void OH_Drawing_BrushSetColor(OH_Drawing_Brush* brush, uint32_t color);

/**
* @brief Obtains the alpha of a brush. The alpha is used by the brush to fill in a shape.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object.
* @return Returns a 8-bit variable that describes the alpha.
* @since 11
* @version 1.0
*/
uint8_t OH_Drawing_BrushGetAlpha(const OH_Drawing_Brush* brush);

/**
* @brief Sets the alpha for a brush. The alpha will be used by the brush to fill in a shape.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object.
* @param alpha Indicates the alpha to set, which is a 8-bit variable.
* @since 11
* @version 1.0
*/
void OH_Drawing_BrushSetAlpha(OH_Drawing_Brush* brush, uint8_t alpha);

/**
* @brief Sets the color for a brush. The color will be used by the brush to fill in a shape.
* The color is an ARGB structure described by floating point numbers and interpreted as being in the colorSpaceManager.
* If colorSpaceManager is nullptr, then color is assumed to be in the sRGB color space.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object.
* @param a Indicates the alpha component of color, represented as a floating point number between 0 and 1.
* @param r Indicates the red component of color, represented as a floating point number between 0 and 1.
* @param g Indicates the green component of color, represented as a floating point number between 0 and 1.
* @param b Indicates the blue component of color, represented as a floating point number between 0 and 1.
* @param colorSpaceManager Indicates the pointer to an <b>OH_NativeColorSpaceManager</b> object.
* @return Returns the error code.
* Returns {@link OH_DRAWING_SUCCESS} if the operation is successful.
* Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if brush is nullptr.
* @since 20
* @version 1.0
*/
OH_Drawing_ErrorCode OH_Drawing_BrushSetColor4f(OH_Drawing_Brush* brush, float a, float r, float g, float b,
OH_NativeColorSpaceManager* colorSpaceManager);

/**
* @brief Obtains the alpha component of a brush.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object.
* @param a Indicates the alpha component of color.
* @return Returns the error code.
* Returns {@link OH_DRAWING_SUCCESS} if the operation is successful.
* Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if brush or a is nullptr.
* @since 20
* @version 1.0
*/
OH_Drawing_ErrorCode OH_Drawing_BrushGetAlphaFloat(const OH_Drawing_Brush* brush, float* a);

/**
* @brief Obtains the red component of a brush.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object.
* @param r Indicates the red component of color.
* @return Returns the error code.
* Returns {@link OH_DRAWING_SUCCESS} if the operation is successful.
* Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if brush or r is nullptr.
* @since 20
* @version 1.0
*/
OH_Drawing_ErrorCode OH_Drawing_BrushGetRedFloat(const OH_Drawing_Brush* brush, float* r);

/**
* @brief Obtains the green component of a brush.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object.
* @param g Indicates the green component of color.
* @return Returns the error code.
* Returns {@link OH_DRAWING_SUCCESS} if the operation is successful.
* Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if brush or g is nullptr.
* @since 20
* @version 1.0
*/
OH_Drawing_ErrorCode OH_Drawing_BrushGetGreenFloat(const OH_Drawing_Brush* brush, float* g);

/**
* @brief Obtains the blue component of a brush.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object.
* @param b Indicates the blue component of color.
* @return Returns the error code.
* Returns {@link OH_DRAWING_SUCCESS} if the operation is successful.
* Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if brush or b is nullptr.
* @since 20
* @version 1.0
*/
OH_Drawing_ErrorCode OH_Drawing_BrushGetBlueFloat(const OH_Drawing_Brush* brush, float* b);

/**
* @brief Sets the shaderEffect for a brush.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object.
* @param shaderEffect Indicates the pointer to an <b>OH_Drawing_ShaderEffect</b> object.
* @since 11
* @version 1.0
*/
void OH_Drawing_BrushSetShaderEffect(OH_Drawing_Brush* brush, OH_Drawing_ShaderEffect* shaderEffect);

/**
* @brief Sets the shadowLayer for a brush.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object.
* @param shadowLayer Indicates the pointer to an <b>OH_Drawing_ShadowLayer</b> object.
* @since 12
* @version 1.0
*/
void OH_Drawing_BrushSetShadowLayer(OH_Drawing_Brush* brush, OH_Drawing_ShadowLayer* shadowLayer);

/**
* @brief Sets the filter for a brush.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object.
* @param filter Indicates the pointer to an <b>OH_Drawing_Filter</b> object.
* @since 11
* @version 1.0
*/
void OH_Drawing_BrushSetFilter(OH_Drawing_Brush* brush, OH_Drawing_Filter* filter);

/**
* @brief Gets the filter from a brush.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object.
* @param filter Indicates the pointer to an <b>OH_Drawing_Filter</b> object.
* @since 12
* @version 1.0
*/
void OH_Drawing_BrushGetFilter(OH_Drawing_Brush* brush, OH_Drawing_Filter* filter);

/**
* @brief Sets a blender that implements the specified blendmode enum for a brush.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object.
* @param blendMode Indicates the blend mode.
* @since 12
* @version 1.0
*/
void OH_Drawing_BrushSetBlendMode(OH_Drawing_Brush* brush, OH_Drawing_BlendMode blendMode);

/**
* @brief Resets all brush contents to their initial values.
*
* @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
* @param brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object.
* @since 12
* @version 1.0
*/
void OH_Drawing_BrushReset(OH_Drawing_Brush* brush);

#ifdef __cplusplus
}
#endif
/** @} */
#endif
Loading