From 484f8927f6a28c5042f5e16aebca44c7382772fe Mon Sep 17 00:00:00 2001 From: lw19901203 Date: Sun, 7 Apr 2024 17:42:14 +0800 Subject: [PATCH] interface sdk_c of B-site requirements Signed-off-by: lw19901203 --- .../native_drawing/drawing_canvas.h | 14 +++++ .../graphic_2d/native_drawing/drawing_path.h | 12 +++++ .../native_drawing/drawing_round_rect.h | 51 ++++++++++++++++++- .../graphic_2d/native_drawing/drawing_types.h | 8 +++ .../native_drawing/libnative_drawing.ndk.json | 16 ++++++ 5 files changed, 100 insertions(+), 1 deletion(-) diff --git a/graphic/graphic_2d/native_drawing/drawing_canvas.h b/graphic/graphic_2d/native_drawing/drawing_canvas.h index 521c93ec6..a393a1f2a 100644 --- a/graphic/graphic_2d/native_drawing/drawing_canvas.h +++ b/graphic/graphic_2d/native_drawing/drawing_canvas.h @@ -404,6 +404,20 @@ typedef enum { void OH_Drawing_CanvasClipRect(OH_Drawing_Canvas*, const OH_Drawing_Rect*, OH_Drawing_CanvasClipOp clipOp, bool doAntiAlias); +/** + * @brief Clip a round rect. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @param OH_Drawing_RoundRect Indicates the pointer to an OH_Drawing_RoundRect object. + * @param clipOp Indicates the operation to apply to clip. + * @param doAntiAlias Indicates whether clip operation requires anti-aliased. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_CanvasClipRoundRect(OH_Drawing_Canvas*, const OH_Drawing_RoundRect*, + OH_Drawing_CanvasClipOp clipOp, bool doAntiAlias); + /** * @brief Clip a path. * diff --git a/graphic/graphic_2d/native_drawing/drawing_path.h b/graphic/graphic_2d/native_drawing/drawing_path.h index 687bdf780..d82a70df8 100644 --- a/graphic/graphic_2d/native_drawing/drawing_path.h +++ b/graphic/graphic_2d/native_drawing/drawing_path.h @@ -334,6 +334,18 @@ void OH_Drawing_PathAddRoundRect(OH_Drawing_Path*, const OH_Drawing_RoundRect* r void OH_Drawing_PathAddOvalWithInitialPoint(OH_Drawing_Path*, const OH_Drawing_Rect*, uint32_t start, OH_Drawing_PathDirection); +/** + * @brief Adds a oval to the path, defined by the rect, and wound in the specified direction. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Path Indicates the pointer to an OH_Drawing_Path object. + * @param OH_Drawing_Rect Indicates the pointer to an OH_Drawing_Rect object. + * @param OH_Drawing_PathDirection Indicates the path direction. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_PathAddOval(OH_Drawing_Path*, const OH_Drawing_Rect*, OH_Drawing_PathDirection); + /** * @brief Appends arc to path, as the start of new contour.Arc added is part of ellipse bounded by oval, * from startAngle through sweepAngle. Both startAngle and sweepAngle are measured in degrees, where zero degrees diff --git a/graphic/graphic_2d/native_drawing/drawing_round_rect.h b/graphic/graphic_2d/native_drawing/drawing_round_rect.h index d17025de1..a31773a5c 100644 --- a/graphic/graphic_2d/native_drawing/drawing_round_rect.h +++ b/graphic/graphic_2d/native_drawing/drawing_round_rect.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 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 @@ -43,6 +43,31 @@ extern "C" { #endif +/** + * @brief Enumerates of corner radii position. + * + * @since 12 + * @version 1.0 + */ +typedef enum { + /** + * Index of top-left corner radii. + */ + CORNER_POS_TOP_LEFT, + /** + * Index of top-right corner radii. + */ + CORNER_POS_TOP_RIGHT, + /** + * Index of bottom-right corner radii. + */ + CORNER_POS_BOTTOM_RIGHT, + /** + * Index of bottom-left corner radii. + */ + CORNER_POS_BOTTOM_LEFT, +} OH_Drawing_CornerPos; + /** * @brief Creates an OH_Drawing_RoundRect object. * @@ -56,6 +81,30 @@ extern "C" { */ OH_Drawing_RoundRect* OH_Drawing_RoundRectCreate(const OH_Drawing_Rect*, float xRad, float yRad); +/** + * @brief Sets the radiusX and radiusY for a specific corner position. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_RoundRect Indicates the pointer to an OH_Drawing_Rect object. + * @param pos Indicates the corner radii position. + * @param OH_Drawing_Corner_Radii Indicates the corner radii on x-axis and y-axis. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_RoundRectSetCorner(OH_Drawing_RoundRect*, OH_Drawing_CornerPos pos, OH_Drawing_Corner_Radii); + +/** + * @brief Gets an OH_Drawing_Corner_Radii struct, the point is round corner radiusX and radiusY. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_RoundRect Indicates the pointer to an OH_Drawing_RoundRect object. + * @param pos Indicates the corner radii position. + * @return Returns the corner radii of OH_Drawing_Corner_Radii struct. + * @since 12 + * @version 1.0 + */ +OH_Drawing_Corner_Radii OH_Drawing_RoundRectGetCorner(OH_Drawing_RoundRect*, OH_Drawing_CornerPos pos); + /** * @brief Destroys an OH_Drawing_RoundRect object and reclaims the memory occupied by the object. * diff --git a/graphic/graphic_2d/native_drawing/drawing_types.h b/graphic/graphic_2d/native_drawing/drawing_types.h index 1d544bec9..ef9c7d5d1 100644 --- a/graphic/graphic_2d/native_drawing/drawing_types.h +++ b/graphic/graphic_2d/native_drawing/drawing_types.h @@ -120,6 +120,14 @@ typedef struct { float y; } OH_Drawing_Point2D; +/** + * @brief Defines a corner radii, which is on x-axis and y-axis. + * + * @since 12 + * @version 1.0 + */ +typedef OH_Drawing_Point2D OH_Drawing_Corner_Radii; + /** * @brief Defines a point of 3d, which is used to describe the coordinate point. * diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index 4279a87c2..020bfd802 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -85,6 +85,10 @@ "name": "OH_Drawing_CanvasDrawImageRectWithSrc" }, { "name": "OH_Drawing_CanvasClipRect" }, + { + "first_introduced": "12", + "name": "OH_Drawing_CanvasClipRoundRect" + }, { "name": "OH_Drawing_CanvasClipPath" }, { "name": "OH_Drawing_CanvasRotate" }, { "name": "OH_Drawing_CanvasTranslate" }, @@ -246,6 +250,10 @@ "first_introduced": "12", "name": "OH_Drawing_PathGetLength" }, + { + "first_introduced": "12", + "name": "OH_Drawing_PathAddOval" + }, { "name": "OH_Drawing_PathContains" }, { "name": "OH_Drawing_PathTransform" }, { @@ -365,6 +373,14 @@ }, { "name": "OH_Drawing_RectDestroy" }, { "name": "OH_Drawing_RoundRectCreate" }, + { + "first_introduced": "12", + "name": "OH_Drawing_RoundRectGetCorner" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_RoundRectSetCorner" + }, { "name": "OH_Drawing_RoundRectDestroy" }, { "name": "OH_Drawing_SetTextStyleColor" }, { "name": "OH_Drawing_SetTextStyleFontSize" }, -- Gitee