From 65f5286435b5e6f0574ce9b89abbced094d71d68 Mon Sep 17 00:00:00 2001 From: lw19901203 Date: Tue, 21 May 2024 15:19:31 +0800 Subject: [PATCH 1/5] drawing interface sdkC upload 0530 Signed-off-by: lw19901203 --- .../graphic_2d/native_drawing/drawing_brush.h | 11 +++ .../native_drawing/drawing_canvas.h | 46 ++++++++++++ .../native_drawing/drawing_image_filter.h | 13 ++++ .../native_drawing/drawing_matrix.h | 11 +++ .../native_drawing/drawing_path_effect.h | 74 +++++++++++++++++++ .../graphic_2d/native_drawing/drawing_pen.h | 11 +++ .../graphic_2d/native_drawing/drawing_point.h | 34 +++++++++ .../native_drawing/drawing_region.h | 12 +++ .../native_drawing/drawing_round_rect.h | 12 +++ .../native_drawing/libnative_drawing.ndk.json | 72 ++++++++++++++++++ 10 files changed, 296 insertions(+) diff --git a/graphic/graphic_2d/native_drawing/drawing_brush.h b/graphic/graphic_2d/native_drawing/drawing_brush.h index 853c669a3..5dbbc1a50 100644 --- a/graphic/graphic_2d/native_drawing/drawing_brush.h +++ b/graphic/graphic_2d/native_drawing/drawing_brush.h @@ -156,6 +156,17 @@ void OH_Drawing_BrushSetAlpha(OH_Drawing_Brush*, uint8_t alpha); */ void OH_Drawing_BrushSetShaderEffect(OH_Drawing_Brush*, OH_Drawing_ShaderEffect*); +/** + * @brief Gets the shaderEffect from a brush. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Brush Indicates the pointer to an OH_Drawing_Brush object. + * @param OH_Drawing_ShaderEffect Indicates the pointer to an OH_Drawing_ShaderEffect object. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_BrushGetShaderEffect(OH_Drawing_Brush*, OH_Drawing_ShaderEffect*); + /** * @brief Sets the shadowLayer for a brush. * diff --git a/graphic/graphic_2d/native_drawing/drawing_canvas.h b/graphic/graphic_2d/native_drawing/drawing_canvas.h index a98e15828..b4d738051 100644 --- a/graphic/graphic_2d/native_drawing/drawing_canvas.h +++ b/graphic/graphic_2d/native_drawing/drawing_canvas.h @@ -731,6 +731,52 @@ bool OH_Drawing_CanvasReadPixels(OH_Drawing_Canvas*, OH_Drawing_Image_Info*, */ bool OH_Drawing_CanvasReadPixelsToBitmap(OH_Drawing_Canvas*, OH_Drawing_Bitmap*, int32_t srcX, int32_t srcY); +/** + * @brief Gets whether clip is empty. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @return Returns true if clip is empty; returns false otherwise. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_CanvasIsClipEmpty(OH_Drawing_Canvas*); + +/** + * @brief Gets whether clip is Rect and not empty. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @return Returns true if clip is rect and not empty; returns false otherwise. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_CanvasIsClipRect(OH_Drawing_Canvas*); + +/** + * @brief Gets imageInfo of canvas. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @param OH_Drawing_Image_Info Indicates the pointer to an OH_Drawing_Image_Info object. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_CanvasGetImageInfo(OH_Drawing_Canvas*, OH_Drawing_Image_Info*); + +/** + * @brief Replaces the clipping area with the intersection or difference of the + * current clipping area and region, and use a clipping edge that is aliased or anti-aliased. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Canvas Indicates the pointer to an OH_Drawing_Canvas object. + * @param OH_Drawing_Region Indicates the pointer to an OH_Drawing_Region object. + * @param OH_Drawing_CanvasClipOp To apply to clip, the default value is ClipOp::INTERSECT. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_CanvasClipRegion(OH_Drawing_Canvas*, const OH_Drawing_Region*, OH_Drawing_CanvasClipOp); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_image_filter.h b/graphic/graphic_2d/native_drawing/drawing_image_filter.h index 3db6e90d0..3bb6a93e7 100644 --- a/graphic/graphic_2d/native_drawing/drawing_image_filter.h +++ b/graphic/graphic_2d/native_drawing/drawing_image_filter.h @@ -76,6 +76,19 @@ OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateBlur(float sigmaX, float sig */ OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateFromColorFilter(OH_Drawing_ColorFilter*, OH_Drawing_ImageFilter*); +/** + * @brief Creates an OH_Drawing_ImageFilter object that composes them. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param ImageFilterOne Indicates the pointer to an OH_Drawing_ImageFilter object. + * @param ImageFilterTwo Indicates the pointer to an OH_Drawing_ImageFilter object. + * @return Returns the shared pointer to the OH_Drawing_ImageFilter object that it's type is compose. + * @since 12 + * @version 1.0 + */ +OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateComposeImageFilter(OH_Drawing_ImageFilter* ImageFilterOne, + OH_Drawing_ImageFilter* ImageFilterTwo); + /** * @brief Destroys an OH_Drawing_ImageFilter object and reclaims the memory occupied by the object. * diff --git a/graphic/graphic_2d/native_drawing/drawing_matrix.h b/graphic/graphic_2d/native_drawing/drawing_matrix.h index e26f2fb49..bc5629b59 100644 --- a/graphic/graphic_2d/native_drawing/drawing_matrix.h +++ b/graphic/graphic_2d/native_drawing/drawing_matrix.h @@ -497,6 +497,17 @@ bool OH_Drawing_MatrixIsIdentity(OH_Drawing_Matrix*); */ void OH_Drawing_MatrixDestroy(OH_Drawing_Matrix*); +/** + * @brief Copies nine scalar values contained by matrix into array. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Matrix Indicates the pointer to an OH_Drawing_Matrix object. + * @param value Storages for nine scalar values. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_MatrixGetAll(OH_Drawing_Matrix*, float value[9]); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_path_effect.h b/graphic/graphic_2d/native_drawing/drawing_path_effect.h index 90aee6f3a..6407ebab1 100644 --- a/graphic/graphic_2d/native_drawing/drawing_path_effect.h +++ b/graphic/graphic_2d/native_drawing/drawing_path_effect.h @@ -56,6 +56,80 @@ extern "C" { */ OH_Drawing_PathEffect* OH_Drawing_CreateDashPathEffect(float* intervals, int count, float phase); +typedef enum { + /** Translates the path dashed style */ + PATH_DASH_STYLE_TRANSLATE, + /** Rotates the path dashed style */ + PATH_DASH_STYLE_ROTATE, + /** Morphs the path dashed style */ + PATH_DASH_STYLE_MORPH, +} OH_Drawing_PathDashStyle; + +/** + * @brief Creates a path dash effect OH_Drawing_PathEffect object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param path Indicates the path to use. + * @param advance Indicates the spacing or progress of each path graph. + * @param phase Indicates the offset into intervals array. + * @param OH_Drawing_PathDashStyle Indicates the style of the path graph. + * @return Returns the pointer to the OH_Drawing_PathEffect object created. + * @since 12 + * @version 1.0 + */ +OH_Drawing_PathEffect* OH_Drawing_CreatePathDashEffect(const OH_Drawing_Path* path, + float advance, float phase, OH_Drawing_PathDashStyle); + +/** + * @brief Creates a corner path effect OH_Drawing_PathEffect object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param radius Indicates the distance from each corner and greater than 0. + * @return Returns the pointer to the OH_Drawing_PathEffect object created. + * @since 12 + * @version 1.0 + */ +OH_Drawing_PathEffect* OH_Drawing_CreateCornerPathEffect(float radius); + +/** + * @brief Creates a discrete path effect OH_Drawing_PathEffect object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param segLength Indicates the length of each discrete segment in the path effect. + * @param dev Indicates the offset of each discrete segment. + * @param seedAssist Indicates the caller-supplied seedAssist. If not supplied it defaults to 0. + * @return Returns the pointer to the OH_Drawing_PathEffect object created. + * @since 12 + * @version 1.0 + */ +OH_Drawing_PathEffect* OH_Drawing_CreateDiscretePathEffect(float segLength, float dev, uint32_t seedAssist); + +/** + * @brief Creates a sum path effect OH_Drawing_PathEffect object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param cPathEffectOne Indicates the first pathEffect. + * @param cPathEffectTwo Indicates the second pathEffect. + * @return Returns the pointer to the OH_Drawing_PathEffect object created. + * @since 12 + * @version 1.0 + */ +OH_Drawing_PathEffect* OH_Drawing_CreateSumPathEffect(OH_Drawing_PathEffect* cPathEffectOne, + OH_Drawing_PathEffect* cPathEffectTwo); + +/** + * @brief Creates a compose path effect OH_Drawing_PathEffect object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param cPathEffectOne Indicates the first pathEffect. + * @param cPathEffectTwo Indicates the second pathEffect. + * @return Returns the pointer to the OH_Drawing_PathEffect object created. + * @since 12 + * @version 1.0 + */ +OH_Drawing_PathEffect* OH_Drawing_CreateComposePathEffect(OH_Drawing_PathEffect* cPathEffectOne, + OH_Drawing_PathEffect* cPathEffectTwo); + /** * @brief Destroys an OH_Drawing_PathEffect object and reclaims the memory occupied by the object. * diff --git a/graphic/graphic_2d/native_drawing/drawing_pen.h b/graphic/graphic_2d/native_drawing/drawing_pen.h index f191ae91f..1ae0b211e 100644 --- a/graphic/graphic_2d/native_drawing/drawing_pen.h +++ b/graphic/graphic_2d/native_drawing/drawing_pen.h @@ -293,6 +293,17 @@ void OH_Drawing_PenSetJoin(OH_Drawing_Pen*, OH_Drawing_PenLineJoinStyle); */ void OH_Drawing_PenSetShaderEffect(OH_Drawing_Pen*, OH_Drawing_ShaderEffect*); +/** + * @brief Gets the shaderEffect from a pen. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Pen Indicates the pointer to an OH_Drawing_Pen object. + * @param OH_Drawing_ShaderEffect Indicates the pointer to an OH_Drawing_ShaderEffect object. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_PenGetShaderEffect(OH_Drawing_Pen*, OH_Drawing_ShaderEffect*); + /** * @brief Sets the shadowLayer for a pen. * diff --git a/graphic/graphic_2d/native_drawing/drawing_point.h b/graphic/graphic_2d/native_drawing/drawing_point.h index f63faf78d..8a4619b25 100644 --- a/graphic/graphic_2d/native_drawing/drawing_point.h +++ b/graphic/graphic_2d/native_drawing/drawing_point.h @@ -65,6 +65,40 @@ OH_Drawing_Point* OH_Drawing_PointCreate(float x, float y); */ void OH_Drawing_PointDestroy(OH_Drawing_Point*); +/** + * @brief Gets the x-axis coordinates of the point. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Point Indicates the pointer to an OH_Drawing_Point object. + * @return Returns the x-axis coordinates of the pointer. + * @since 12 + * @version 1.0 + */ +float OH_Drawing_PointGetX(const OH_Drawing_Point*); + +/** + * @brief Gets the y-axis coordinates of the point. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Point Indicates the pointer to an OH_Drawing_Point object. + * @return Returns the y-axis coordinates of the pointer. + * @since 12 + * @version 1.0 + */ +float OH_Drawing_PointGetY(const OH_Drawing_Point*); + +/** + * @brief Sets the x-axis and y-axis coordinates of the point. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Point Indicates the pointer to an OH_Drawing_Point object. + * @param x Indicates the x-axis coordinates of the point. + * @param y Indicates the y-axis coordinates of the point. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_PointSet(OH_Drawing_Point*, float x, float y); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/drawing_region.h b/graphic/graphic_2d/native_drawing/drawing_region.h index 572625aa7..a346dccea 100644 --- a/graphic/graphic_2d/native_drawing/drawing_region.h +++ b/graphic/graphic_2d/native_drawing/drawing_region.h @@ -137,6 +137,18 @@ bool OH_Drawing_RegionSetRect(OH_Drawing_Region* region, const OH_Drawing_Rect* */ bool OH_Drawing_RegionSetPath(OH_Drawing_Region* region, const OH_Drawing_Path* path, const OH_Drawing_Region* clip); +/** + * @brief Gets whether other region is in the OH_Drawing_Region object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param region Indicates the pointer to an OH_Drawing_Region object. + * @param other Indicates the pointer to an OH_Drawing_Region object. + * @return Returns true if other region is completely inside the region object; returns false otherwise. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_RegionIsContainsRegion(const OH_Drawing_Region* region, const OH_Drawing_Region* other); + /** * @brief Destroys an OH_Drawing_Region object and reclaims the memory occupied by the object. * diff --git a/graphic/graphic_2d/native_drawing/drawing_round_rect.h b/graphic/graphic_2d/native_drawing/drawing_round_rect.h index a31773a5c..cb45916b2 100644 --- a/graphic/graphic_2d/native_drawing/drawing_round_rect.h +++ b/graphic/graphic_2d/native_drawing/drawing_round_rect.h @@ -115,6 +115,18 @@ OH_Drawing_Corner_Radii OH_Drawing_RoundRectGetCorner(OH_Drawing_RoundRect*, OH_ */ void OH_Drawing_RoundRectDestroy(OH_Drawing_RoundRect*); +/** + * @brief Translates RoundRect by (dx, dy). + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_RoundRect Indicates the pointer to an OH_Drawing_RoundRect object. + * @param dx Offsets added to rect left and rect right. + * @param dy Offsets added to rect top and rect bottom. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_RoundRectOffset(OH_Drawing_RoundRect*, float dx, float dy); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index a720ac9d5..0ec87364d 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -45,6 +45,10 @@ "first_introduced": "12", "name": "OH_Drawing_BrushSetShadowLayer" }, + { + "first_introduced": "12", + "name": "OH_Drawing_BrushGetShaderEffect" + }, { "first_introduced": "12", "name": "OH_Drawing_BrushReset" @@ -122,8 +126,48 @@ { "name": "OH_Drawing_CanvasGetLocalClipBounds" }, { "name": "OH_Drawing_CanvasGetTotalMatrix" }, { "name": "OH_Drawing_CanvasConcatMatrix" }, + { + "first_introduced": "12", + "name": "OH_Drawing_MatrixGetAll" + }, { "name": "OH_Drawing_CanvasDrawShadow" }, + { + "first_introduced": "12", + "name": "OH_Drawing_CanvasIsClipEmpty" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_CanvasIsClipRect" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_CanvasGetImageInfo" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_CanvasClipRegion" + }, { "name": "OH_Drawing_CreateDashPathEffect" }, + { + "first_introduced": "12", + "name": "OH_Drawing_CreatePathDashEffect" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_CreateCornerPathEffect" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_CreateDiscretePathEffect" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_CreateSumPathEffect" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_CreateComposePathEffect" + }, { "name": "OH_Drawing_PathEffectDestroy" }, { "name": "OH_Drawing_ColorFilterCreateBlendMode" }, { "name": "OH_Drawing_ColorFilterCreateCompose" }, @@ -250,6 +294,10 @@ "first_introduced": "12", "name": "OH_Drawing_ImageFilterCreateFromColorFilter" }, + { + "first_introduced": "12", + "name": "OH_Drawing_ImageFilterCreateComposeImageFilter" + }, { "first_introduced": "12", "name": "OH_Drawing_ImageFilterDestroy" @@ -462,12 +510,28 @@ "first_introduced": "12", "name": "OH_Drawing_PenSetPathEffect" }, + { + "first_introduced": "12", + "name": "OH_Drawing_PenGetShaderEffect" + }, { "first_introduced": "12", "name": "OH_Drawing_PenReset" }, { "name": "OH_Drawing_PointCreate" }, { "name": "OH_Drawing_PointDestroy" }, + { + "first_introduced": "12", + "name": "OH_Drawing_PointGetX" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_PointGetY" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_PointSet" + }, { "name": "OH_Drawing_ColorSetArgb" }, { "first_introduced": "12", @@ -554,6 +618,10 @@ "name": "OH_Drawing_RoundRectSetCorner" }, { "name": "OH_Drawing_RoundRectDestroy" }, + { + "first_introduced": "12", + "name": "OH_Drawing_RoundRectOffset" + }, { "name": "OH_Drawing_SetTextStyleColor" }, { "name": "OH_Drawing_SetTextStyleFontSize" }, { "name": "OH_Drawing_SetTextStyleFontWeight" }, @@ -1038,6 +1106,10 @@ "first_introduced": "12", "name": "OH_Drawing_RegionSetRect" }, + { + "first_introduced": "12", + "name": "OH_Drawing_RegionIsContainsRegion" + }, { "first_introduced": "12", "name": "OH_Drawing_SetTypographyTextFontFamily" -- Gitee From ee99fd20d58602ccec4bdcc5d82f2859adc68d42 Mon Sep 17 00:00:00 2001 From: nongzhengheng Date: Thu, 23 May 2024 18:10:13 +0800 Subject: [PATCH 2/5] add c interface header Signed-off-by: nongzhengheng --- .../native_drawing/drawing_bitmap.h | 104 ++++++++++++++++++ .../native_drawing/libnative_drawing.ndk.json | 28 +++++ 2 files changed, 132 insertions(+) diff --git a/graphic/graphic_2d/native_drawing/drawing_bitmap.h b/graphic/graphic_2d/native_drawing/drawing_bitmap.h index beb238c74..2d4d2e4a6 100644 --- a/graphic/graphic_2d/native_drawing/drawing_bitmap.h +++ b/graphic/graphic_2d/native_drawing/drawing_bitmap.h @@ -56,6 +56,25 @@ typedef struct { OH_Drawing_AlphaFormat alphaFormat; } OH_Drawing_BitmapFormat; +/** + * @brief Enumerations bitmap color space type. + * + * @since 12 + * @version 1.0 + */ +typedef enum { + /** No color space type */ + NO_TYPE, + /** SRGB color space type */ + SRGB, + /** SRGB color space types with linear properties */ + SRGB_LINEAR, + /** The spatial type of the reference image */ + REF_IMAGE, + /** RGB color space */ + RGB, +} OH_Drawing_ColorSpaceType; + /** * @brief Creates an OH_Drawing_Bitmap object. * @@ -189,6 +208,91 @@ void OH_Drawing_BitmapGetImageInfo(OH_Drawing_Bitmap*, OH_Drawing_Image_Info*); */ bool OH_Drawing_BitmapReadPixels(OH_Drawing_Bitmap*, const OH_Drawing_Image_Info* dstInfo, void* dstPixels, size_t dstRowBytes, int32_t srcX, int32_t srcY); + +/** + * @brief Baseds on the information provided by OH_Drawing_Image_Info, create a OH_Drawing_Bitmap object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Image_Info Indicates the pointer to an OH_Drawing_Image_Info object. + * @param OH_Drawing_ColorSpace Indicates the pointer to an OH_Drawing_ColorSpace object. + * @param rowBytes Indicates the row bytes of the OH_Drawing_Bitmap object. + * @return Returns a OH_Drawing_Bitmap object. + * @since 12 + * @version 1.0 + */ +OH_Drawing_Bitmap* OH_Drawing_BitmapCreateFromImageInfo(const OH_Drawing_Image_Info*, OH_Drawing_ColorSpace*, + int32_t rowBytes); + +/** + * @brief Gets the row bytes of the OH_Drawing_Bitmap bject. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Bitmap Indicates the pointer to an OH_Drawing_Bitmap object. + * @return Returns the row bytes of the OH_Drawing_Bitmap bject. + * @since 12 + * @version 1.0 + */ +uint32_t OH_Drawing_BitmapGetRowBytes(const OH_Drawing_Bitmap*); + +/** + * @brief Gets the color space type of the OH_Drawing_Bitmap object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Bitmap Indicates the pointer to an OH_Drawing_Bitmap object. + * @return Returns bitmap color space type. + * @since 12 + * @version 1.0 + */ +OH_Drawing_ColorSpaceType OH_Drawing_BitmapGetColorSpaceType(OH_Drawing_Bitmap*); + +/** + * @brief Gets a subset of this bitmap. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param bitmap Indicates the pointer to an OH_Drawing_Bitmap object. + * @param dstBitmap Indicates the pointer to an OH_Drawing_Bitmap object. + * @param OH_Drawing_Rect Indicates the pointer to an OH_Drawing_Rect object. + * @return Returns true if the subset was retrieved, false otherwise. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_BitmapExtractSubset(const OH_Drawing_Bitmap* bitmap, const OH_Drawing_Bitmap* dstBitmap, + const OH_Drawing_Rect* subset); + +/** + * @brief Gets whether the content of the OH_Drawing_Bitmap object is immutable. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Bitmap Indicates the pointer to an OH_Drawing_Bitmap object. + * @return Returns true if it is immutable, false otherwise. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_BitmapIsImmutable(const OH_Drawing_Bitmap*); + +/** + * @brief Sets the OH_Drawing_Bitmap object as immutable. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Bitmap Indicates the pointer to an OH_Drawing_Bitmap object. + * @since 12 + * @version 1.0 + */ +void OH_Drawing_BitmapSetImmutable(OH_Drawing_Bitmap*); + +/** + * @brief Allocates the memory for the OH_Drawing_Bitmap object using the specified + * OH_Drawing_Image_Info object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Bitmap Indicates the pointer to an OH_Drawing_Bitmap object. + * @param OH_Drawing_Image_Info Indicates the pointer to an OH_Drawing_Image_Info object. + * @return Returns true if the allocation was successful, false otherwise. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_BitmapTryAllocPixels(OH_Drawing_Bitmap*, const OH_Drawing_Image_Info*); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index 0ec87364d..0d6d302b7 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -2,7 +2,15 @@ { "name": "OH_Drawing_BitmapCreate" }, { "name": "OH_Drawing_BitmapDestroy" }, { "name": "OH_Drawing_BitmapBuild" }, + { + "first_introduced": "12", + "name": "OH_Drawing_BitmapCreateFromImageInfo" + }, { "name": "OH_Drawing_BitmapCreateFromPixels" }, + { + "first_introduced": "12", + "name": "OH_Drawing_BitmapExtractSubset" + }, { "name": "OH_Drawing_BitmapGetWidth" }, { "name": "OH_Drawing_BitmapGetHeight" }, { @@ -13,11 +21,23 @@ "first_introduced": "12", "name": "OH_Drawing_BitmapGetAlphaFormat" }, + { + "first_introduced": "12", + "name": "OH_Drawing_BitmapGetRowBytes" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_BitmapGetColorSpaceType" + }, { "first_introduced": "12", "name": "OH_Drawing_BitmapGetImageInfo" }, { "name": "OH_Drawing_BitmapGetPixels" }, + { + "first_introduced": "12", + "name": "OH_Drawing_BitmapIsImmutable" + }, { "first_introduced": "12", "name": "OH_Drawing_BitmapReadPixels" @@ -53,6 +73,14 @@ "first_introduced": "12", "name": "OH_Drawing_BrushReset" }, + { + "first_introduced": "12", + "name": "OH_Drawing_BitmapSetImmutable" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_BitmapTryAllocPixels" + }, { "name": "OH_Drawing_CanvasCreate" }, { "name": "OH_Drawing_CanvasDestroy" }, { "name": "OH_Drawing_CanvasBind" }, -- Gitee From 6c8fc6d6a463459ff5b42e584043642d50623d91 Mon Sep 17 00:00:00 2001 From: congyue Date: Thu, 23 May 2024 17:45:43 +0800 Subject: [PATCH 3/5] add font and image interface --- .../graphic_2d/native_drawing/drawing_font.h | 14 ++++++ .../graphic_2d/native_drawing/drawing_image.h | 48 +++++++++++++++++++ .../native_drawing/libnative_drawing.ndk.json | 20 ++++++++ 3 files changed, 82 insertions(+) diff --git a/graphic/graphic_2d/native_drawing/drawing_font.h b/graphic/graphic_2d/native_drawing/drawing_font.h index 0fe56c1d5..7df550da7 100644 --- a/graphic/graphic_2d/native_drawing/drawing_font.h +++ b/graphic/graphic_2d/native_drawing/drawing_font.h @@ -393,6 +393,20 @@ void OH_Drawing_FontSetEdging(OH_Drawing_Font*, OH_Drawing_FontEdging); */ OH_Drawing_FontEdging OH_Drawing_FontGetEdging(const OH_Drawing_Font*); +/** + * @brief Calculates width of glyphs represented by text. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Font Indicates the pointer to an OH_Drawing_Font object. + * @param text Indicates the character storage encoded with text encoding. + * @param byteLength Indicates the text length in bytes. + * @param OH_Drawing_TextEncoding Indicates the text encoding. + * @return Returns the width of the glyphs represented by text. + * @since 12 + * @version 1.0 + */ +float OH_Drawing_FontMeasureText(OH_Drawing_Font*, const void* text, size_t byteLength, OH_Drawing_TextEncoding); + /** * @brief Destroys an OH_Drawing_Font object and reclaims the memory occupied by the object. * diff --git a/graphic/graphic_2d/native_drawing/drawing_image.h b/graphic/graphic_2d/native_drawing/drawing_image.h index ed2f1f491..07dfc1334 100644 --- a/graphic/graphic_2d/native_drawing/drawing_image.h +++ b/graphic/graphic_2d/native_drawing/drawing_image.h @@ -108,6 +108,54 @@ int32_t OH_Drawing_ImageGetHeight(OH_Drawing_Image*); */ void OH_Drawing_ImageGetImageInfo(OH_Drawing_Image*, OH_Drawing_Image_Info*); +/** + * @brief Gets an OH_Drawing_ColorSpace object from an OH_Drawing_Image object. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Image Indicates the pointer to an OH_Drawing_Image object. + * @return Returns the pointer to an OH_Drawing_ColorSpace object. + * @since 12 + * @version 1.0 + */ +OH_Drawing_ColorSpace* OH_Drawing_ImageGetColorSpace(const OH_Drawing_Image*); + +/** + * @brief Gets the unique id of image. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Image Indicates the pointer to an OH_Drawing_Image object. + * @return Returns the unique id of image. + * @since 12 + * @version 1.0 + */ +uint32_t OH_Drawing_ImageGetUniqueID(const OH_Drawing_Image*); + +/** + * @brief Gets whether the image is opaque. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Image Indicates the pointer to an OH_Drawing_Image object. + * @return Returns true if the image is opaque; returns false otherwise. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_ImageIsOpaque(const OH_Drawing_Image*); + +/** + * @brief Gets whether the image is scaled to fit the bitmap. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_Image Indicates the pointer to an OH_Drawing_Image object. + * @param OH_Drawing_Bitmap Indicates the pointer to an OH_Drawing_Bitmap object. + * @param OH_Drawing_SamplingOptions Indicates the pointer to an OH_Drawing_SamplingOptions object. + * @param isAllowCachingHint Indicates whether the image will be cached locally. + * @return Returns true if the image is scaled to fit the bitmap; returns false otherwise. + * @since 12 + * @version 1.0 + */ +bool OH_Drawing_ImageScalePixels(const OH_Drawing_Image*, const OH_Drawing_Bitmap*, const OH_Drawing_SamplingOptions*, + bool isAllowCachingHint); + #ifdef __cplusplus } #endif diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index 0ec87364d..28f0fe510 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -238,6 +238,10 @@ "first_introduced": "12", "name": "OH_Drawing_FontIsSubpixel" }, + { + "first_introduced": "12", + "name": "OH_Drawing_FontMeasureText" + }, { "first_introduced": "12", "name": "OH_Drawing_FontSetBaselineSnap" @@ -724,6 +728,22 @@ { "name": "OH_Drawing_ImageBuildFromBitmap" }, { "name": "OH_Drawing_ImageGetWidth" }, { "name": "OH_Drawing_ImageGetHeight" }, + { + "first_introduced": "12", + "name": "OH_Drawing_ImageGetColorSpace" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_ImageGetUniqueID" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_ImageIsOpaque" + }, + { + "first_introduced": "12", + "name": "OH_Drawing_ImageScalePixels" + }, { "first_introduced": "12", "name": "OH_Drawing_TextStyleGetShadowWithIndex" -- Gitee From bbfbef7244c743a0e1224dcdd79d4750587731bf Mon Sep 17 00:00:00 2001 From: lw19901203 Date: Fri, 24 May 2024 17:49:28 +0800 Subject: [PATCH 4/5] add interface 0530 Signed-off-by: lw19901203 --- .../native_drawing/drawing_color_filter.h | 10 ++++++++ .../native_drawing/drawing_image_filter.h | 13 ++++++++++ .../native_drawing/drawing_shader_effect.h | 25 +++++++++++++++++++ .../native_drawing/libnative_drawing.ndk.json | 16 ++++++++++++ 4 files changed, 64 insertions(+) diff --git a/graphic/graphic_2d/native_drawing/drawing_color_filter.h b/graphic/graphic_2d/native_drawing/drawing_color_filter.h index 67eefc7e5..091894196 100644 --- a/graphic/graphic_2d/native_drawing/drawing_color_filter.h +++ b/graphic/graphic_2d/native_drawing/drawing_color_filter.h @@ -43,6 +43,16 @@ extern "C" { #endif +/** + * @brief Creates an OH_Drawing_ColorFilter object and no filter type. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @return Returns the pointer to the OH_Drawing_ColorFilter object created. + * @since 12 + * @version 1.0 + */ +OH_Drawing_ColorFilter* OH_Drawing_ColorFilterCreate(); + /** * @brief Creates an OH_Drawing_ColorFilter with a blend mode. * diff --git a/graphic/graphic_2d/native_drawing/drawing_image_filter.h b/graphic/graphic_2d/native_drawing/drawing_image_filter.h index 3bb6a93e7..9f9e03bb8 100644 --- a/graphic/graphic_2d/native_drawing/drawing_image_filter.h +++ b/graphic/graphic_2d/native_drawing/drawing_image_filter.h @@ -61,6 +61,19 @@ extern "C" { OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateBlur(float sigmaX, float sigmaY, OH_Drawing_TileMode, OH_Drawing_ImageFilter*); +/** + * @brief Creates an OH_Drawing_ImageFilter object that composes them. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param ImageFilterOne Indicates the pointer to an OH_Drawing_ImageFilter object. + * @param ImageFilterTwo Indicates the pointer to an OH_Drawing_ImageFilter object. + * @return Returns the shared pointer to the OH_Drawing_ImageFilter object that its type is compose. + * @since 12 + * @version 1.0 + */ +OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateComposeImageFilter( + OH_Drawing_ImageFilter* ImageFilterOne, OH_Drawing_ImageFilter* ImageFilterTwo); + /** * @brief Creates an OH_Drawing_ImageFilter object that applies the color filter to the input. * diff --git a/graphic/graphic_2d/native_drawing/drawing_shader_effect.h b/graphic/graphic_2d/native_drawing/drawing_shader_effect.h index 8cf8e8802..9315468b8 100644 --- a/graphic/graphic_2d/native_drawing/drawing_shader_effect.h +++ b/graphic/graphic_2d/native_drawing/drawing_shader_effect.h @@ -69,6 +69,15 @@ typedef enum { DECAL, } OH_Drawing_TileMode; +/** + * @brief Creates an OH_Drawing_ShaderEffect that generates a extend shader. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @since 12 + * @version 1.0 + */ +OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreate(); + /** * @brief Creates an OH_Drawing_ShaderEffect that generates a shader with single color. * @@ -196,6 +205,22 @@ OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateSweepGradient(const OH_Dra OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreateImageShader(OH_Drawing_Image*, OH_Drawing_TileMode tileX, OH_Drawing_TileMode tileY, const OH_Drawing_SamplingOptions*, const OH_Drawing_Matrix*); +/** + * @brief Creates an OH_Drawing_ShaderEffect that generates a extend shader. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing + * @param OH_Drawing_PixelMap Indicates the pointer to an OH_Drawing_PixelMap object. + * @param tileX Indicates the tileX. + * @param tileY Indicates the tileY. + * @param OH_Drawing_SamplingOptions Indicates the pointer to an OH_Drawing_SamplingOptions object. + * @param OH_Drawing_Matrix Indicates the pointer to an OH_Drawing_Matrix object. + * @return Returns the pointer to the OH_Drawing_ShaderEffect object created. + * @since 12 + * @version 1.0 + */ +OH_Drawing_ShaderEffect* OH_Drawing_ShaderEffectCreatePixelMapShader(OH_Drawing_PixelMap*, OH_Drawing_TileMode tileX, + OH_Drawing_TileMode tileY, const OH_Drawing_SamplingOptions*, const OH_Drawing_Matrix*); + /** * @brief Destroys an OH_Drawing_ShaderEffect object and reclaims the memory occupied by the object. * diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index 0fd3eb293..a66b52165 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -197,6 +197,10 @@ "name": "OH_Drawing_CreateComposePathEffect" }, { "name": "OH_Drawing_PathEffectDestroy" }, + { + "first_introduced": "12", + "name": "OH_Drawing_ColorFilterCreate" + }, { "name": "OH_Drawing_ColorFilterCreateBlendMode" }, { "name": "OH_Drawing_ColorFilterCreateCompose" }, { "name": "OH_Drawing_ColorFilterCreateLinearToSrgbGamma" }, @@ -322,6 +326,10 @@ "first_introduced": "12", "name": "OH_Drawing_ImageFilterCreateBlur" }, + { + "first_introduced": "12", + "name": "OH_Drawing_ImageFilterCreateComposeImageFilter" + }, { "first_introduced": "12", "name": "OH_Drawing_ImageFilterCreateFromColorFilter" @@ -664,6 +672,10 @@ { "name": "OH_Drawing_SetTextStyleFontFamilies" }, { "name": "OH_Drawing_SetTextStyleFontStyle" }, { "name": "OH_Drawing_SetTextStyleLocale" }, + { + "first_introduced": "12", + "name": "OH_Drawing_ShaderEffectCreate" + }, { "first_introduced": "12", "name": "OH_Drawing_ShaderEffectCreateColorShader" @@ -683,6 +695,10 @@ "first_introduced": "12", "name": "OH_Drawing_ShaderEffectCreateImageShader" }, + { + "first_introduced": "12", + "name": "OH_Drawing_ShaderEffectCreatePixelMapShader" + }, { "name": "OH_Drawing_ShaderEffectDestroy" }, { "first_introduced": "12", -- Gitee From 3a6cf7a9afb7ef5c86fda6a8f516987d4002117c Mon Sep 17 00:00:00 2001 From: congyue Date: Wed, 29 May 2024 10:44:40 +0800 Subject: [PATCH 5/5] update region c interface --- graphic/graphic_2d/native_drawing/drawing_region.h | 2 +- graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/graphic/graphic_2d/native_drawing/drawing_region.h b/graphic/graphic_2d/native_drawing/drawing_region.h index 225a66e26..0123b40ae 100644 --- a/graphic/graphic_2d/native_drawing/drawing_region.h +++ b/graphic/graphic_2d/native_drawing/drawing_region.h @@ -147,7 +147,7 @@ bool OH_Drawing_RegionSetPath(OH_Drawing_Region* region, const OH_Drawing_Path* * @since 12 * @version 1.0 */ -bool OH_Drawing_RegionIsContainsRegion(const OH_Drawing_Region* region, const OH_Drawing_Region* other); +bool OH_Drawing_RegionIsRegionContained(const OH_Drawing_Region* region, const OH_Drawing_Region* other); /** * @brief Destroys an OH_Drawing_Region object and reclaims the memory occupied by the object. diff --git a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json index e3526252c..ff2964c26 100644 --- a/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json +++ b/graphic/graphic_2d/native_drawing/libnative_drawing.ndk.json @@ -1184,7 +1184,7 @@ }, { "first_introduced": "12", - "name": "OH_Drawing_RegionIsContainsRegion" + "name": "OH_Drawing_RegionIsRegionContained" }, { "first_introduced": "12", -- Gitee