1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /* * 17 * @addtogroup Display 18 * @{ 19 * 20 * @brief Defines driver functions of the display module. 21 * 22 * This module provides driver functions for the graphics subsystem, including graphics layer management, 23 * device control, graphics hardware acceleration, display memory management, and callbacks. 24 * 25 * @since 3.0 26 */ 27 28 /* * 29 * @file display_vgu.h 30 * 31 * @brief Declares the driver functions for implementing 2D vector hardware acceleration. 32 * 33 * @since 3.0 34 */ 35 36 #ifndef DISPLAY_VGU_H 37 #define DISPLAY_VGU_H 38 #include "display_type.h" 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 #undef HDI_VGU_SCALAR_IS_FLOAT 45 #define HDI_VGU_SCALAR_IS_FLOAT 1 46 47 #ifdef HDI_VGU_SCALAR_IS_FLOAT 48 typedef float VGUScalar; 49 #else 50 typedef int32_t VGUScalar; 51 #endif 52 53 typedef PixelFormat VGUPixelFormat; /* < Pixel formats */ 54 typedef BlendType VGUBlendType; /* < Blend types supported by hardware acceleration */ 55 56 /* * 57 * @brief Enumerates data types of paths. 58 * 59 */ 60 typedef enum { 61 VGU_DATA_TYPE_S16 = 0, /* < Integer (2 bytes) */ 62 VGU_DATA_TYPE_S32, /* < Integer (4 bytes) */ 63 VGU_DATA_TYPE_F32 /* < Floating point number (4 bytes) */ 64 } VGUPathDataType; 65 66 /* * 67 * @brief Enumerates supported hardware acceleration capabilities. 68 * 69 */ 70 typedef enum { 71 VGU_CAP_BLIT = (1 << 0), /* < Bit blit */ 72 VGU_CAP_BLIT_NUM = (1 << 1), /* < Maximum number of images that can be combined during bit blit */ 73 VGU_CAP_PATH = (1 << 2), /* < Path filling and stroking */ 74 VGU_CAP_FILTER_BLUR = (1 << 3), /* < Blur filter */ 75 } VGUCapability; 76 77 /* * 78 * @brief Enumerates result codes that may return. 79 * 80 */ 81 typedef enum { 82 VGU_SUCCESS = 0, /* < The operation is successful. */ 83 VGU_NO_SUPPORT = -1, /* < This feature is not supported. */ 84 VGU_OPERATION_FAILED = -2, /* < The operation failed. */ 85 VGU_OUT_OF_MEMORY = -3, /* < The operation ran out of memory. */ 86 VGU_TIMEOUT = -4, /* < The operation times out. */ 87 VGU_INVALID_PARAMETER = -5, /* < One or more parameters are invalid. */ 88 VGU_BUSY = -6, /* < The device is busy. */ 89 VGU_NO_CONTEXT = -7, /* < There is no context specified. */ 90 } VGUResult; 91 92 /* * 93 * @brief Enumerates styles for the endpoints of a stroked line. 94 * 95 */ 96 typedef enum { 97 VGU_LINECAP_BUTT = 0, /* < A line with a squared-off end (default value) */ 98 VGU_LINECAP_ROUND, /* < A line with a rounded end */ 99 VGU_LINECAP_SQUARE /* < A line with a squared-off end */ 100 } VGULineCap; 101 102 /* * 103 * @brief Enumerates join types for stroked lines. 104 * 105 */ 106 typedef enum { 107 VGU_LINE_JOIN_MITER = 0, /* < A join with a sharp corner (default value) */ 108 VGU_LINE_JOIN_ROUND, /* < A join with a rounded end */ 109 VGU_LINE_JOIN_BEVEL, /* < A join with a squared-off end */ 110 VGU_LINE_JOIN_BUTT /* < Invalid definition */ 111 } VGUJointType; 112 113 /* * 114 * @brief Defines the coordinates of a point. 115 * 116 */ 117 typedef struct { 118 VGUScalar x; /* < Horizontal coordinate of the point */ 119 VGUScalar y; /* < Vertical coordinate of the point */ 120 } VGUPoint; 121 122 /* * 123 * @brief Defines a rectangle. 124 * 125 */ 126 typedef struct { 127 VGUScalar x; /* < Horizontal coordinate of the start point of the rectangle */ 128 VGUScalar y; /* < Vertical coordinate of the start point of the rectangle */ 129 VGUScalar w; /* < Width of the rectangle */ 130 VGUScalar h; /* < Height of the rectangle */ 131 } VGURect; 132 133 /* * 134 * @brief Enumerates filter types for rendering an image. 135 * 136 */ 137 typedef enum { 138 VGU_FILTER_BILINEAR = 0, /* < Bilinear interpolation filter (default value) */ 139 VGU_FILTER_NEAREST, /* < No interpolation filter */ 140 VGU_FILTER_LINEAR, /* < Linear interpolation filter */ 141 VGU_FILTER_BUTT /* < Invalid definition */ 142 } VGUFilter; 143 144 /* * 145 * @brief Enumerates fill rules for graphics. 146 * 147 */ 148 typedef enum { 149 VGU_RULE_WINDING = 0, /* < Non-zero winding rule (default value) */ 150 VGU_RULE_EVEN_ODD, /* < Even-odd rule */ 151 VGU_RULE_BUTT /* < Invalid definition */ 152 } VGUFillRule; 153 154 /* * 155 * @brief Enumerates fill types of the outside of the gradient area. 156 * 157 */ 158 typedef enum { 159 VGU_SPREAD_PAD = 0, /* < The area is filled with the closest gradient stop color. (Default value) */ 160 VGU_SPREAD_REFLECT, /* < The gradient is reflected outside the area. */ 161 VGU_SPREAD_REPEAT, /* < The gradient is repeated outside the area. */ 162 VGU_SPREAD_BUTT /* < Invalid definition */ 163 } VGUFillSpread; 164 165 /* * 166 * @brief Enumerates wrap types of a pattern. 167 * 168 */ 169 typedef enum { 170 VGU_WRAP_REFLECT = 0, /* < The pattern is reflected. */ 171 VGU_WRAP_REPEAT, /* < The pattern is repeated. */ 172 VGU_WRAP_BUTT /* < Invalid definition */ 173 } VGUWrapType; 174 175 /* * 176 * @brief Enumerates commands for drawing a path. 177 * 178 */ 179 typedef enum { 180 VGU_PATH_CMD_CLOSE = 0, /* < Close the current subpath (coordinates: none). */ 181 VGU_PATH_CMD_MOVE, /* < Move to the specified point (coordinates: x0, y0). */ 182 VGU_PATH_CMD_LINE, /* < Draw a line (coordinates: x0, y0). */ 183 VGU_PATH_CMD_HLINE, /* < Draw a horizontal line (coordinates: x0). */ 184 VGU_PATH_CMD_VLINE, /* < Draw a vertical line (coordinates: y0). */ 185 VGU_PATH_CMD_QUAD, /* < Draw a quadratic Bezier curve (coordinates: x0, y0, x1, y1). */ 186 VGU_PATH_CMD_CUBIC, /* < Draw a cubic Bezier curve (coordinates: x0, y0, x1, y1, x2, y2). */ 187 VGU_PATH_CMD_SQUAD, /* < Draw a smooth quadratic Bezier curve (coordinates: x1, y1). */ 188 VGU_PATH_CMD_SCUBIC, /* < Draw a smooth cubic Bezier curve (coordinates: x1, y1, x2, y2). */ 189 VGU_PATH_CMD_BUTT, /* < Invalid definition */ 190 } VGUPathCmd; 191 192 /* * 193 * @brief Defines a path object, which stores path-related commands and coordinates. 194 * 195 */ 196 typedef struct { 197 uint8_t *segment; /* < Pointer to the path command data */ 198 int32_t numSegments; /* < Total number of path commands */ 199 uint8_t *data; /* < Pointer to the coordinates used in the path commands */ 200 VGUPathDataType type; /* < Data type of the path */ 201 bool enAlias; /* < Whether to enable anti-aliasing */ 202 VGURect boundBox; /* < Bounding box of the path */ 203 } VGUPath; 204 205 /* * 206 * @brief Enumerates transform types. 207 * 208 */ 209 typedef enum { 210 VGU_TRANSFORM_TRANSLATE = (1 << 0), /* < Translate */ 211 VGU_TRANSFORM_SCALE = (1 << 1), /* < Scale */ 212 VGU_TRANSFORM_ROTATE_90 = (1 << 2), /* < Rotate by 90 degrees */ 213 VGU_TRANSFORM_ROTATE_180 = (1 << 3), /* < Rotate by 180 degrees */ 214 VGU_TRANSFORM_ROTATE_270 = (1 << 4), /* < Rotate by 270 degrees */ 215 VGU_TRANSFORM_OTHER = (1 << 16) /* < Other transform type */ 216 } VGUTransformType; 217 218 /* * 219 * @brief Defines a transformation matrix. 220 * 221 */ 222 typedef struct { 223 float m[3][3]; /* < 3x3 transformation matrix */ 224 uint32_t type; /* < Transform type, which can be scale, translate, or rotate by 90 x <i>N</i> degrees */ 225 } VGUMatrix3; 226 227 /* * 228 * @brief Stores bitmap information for hardware acceleration. 229 * 230 */ 231 typedef struct { 232 VGUPixelFormat pixelFormat; /* < Pixel format */ 233 uint32_t width; /* < Bitmap width */ 234 uint32_t height; /* < Bitmap height */ 235 uint32_t stride; /* < Bitmap stride */ 236 void *virAddr; /* < Virtual address of the requested memory */ 237 uint64_t phyAddr; /* < Physical memory address */ 238 } VGUBuffer; 239 240 /* * 241 * @brief Enumerates clip types of a surface. 242 * 243 */ 244 typedef enum { 245 VGU_CLIP_RECT = 0, /* < Rectangle clip (default value) */ 246 VGU_CLIP_PATH, /* < Path clip */ 247 VGU_CLIP_BUTT /* < Invalid definition */ 248 } VGUClipType; 249 250 /* * 251 * @brief Defines a mask layer. 252 * 253 */ 254 typedef struct { 255 VGUBuffer *buffer; /* < Pointer to the buffer for the mask */ 256 VGURect *rect; /* < Pointer to the rectangle for the mask */ 257 } VGUMaskLayer; 258 259 /* * 260 * @brief Stores surface information for 2D hardware acceleration. 261 * 262 */ 263 typedef struct { 264 VGUBuffer *buffer; /* < Bitmap buffer */ 265 union { 266 VGURect *clipRect; /* < Pointer to the clip rectangle. If it is null, the entire surface will be rendered. */ 267 VGUPath *clipPath; /* < Pointer to the clip path. If it is null, the entire surface will be rendered. */ 268 }; 269 VGUClipType clipType; /* < Clip type of the surface */ 270 VGUMaskLayer *mask; /* < Mask layer, which can be null */ 271 VGUBlendType blend; /* < Blend type, specifying how a new image is drawn onto an existing surface */ 272 VGUFilter filter; /* < Filter type */ 273 } VGUSurface; 274 275 /* * 276 * @brief Defines how the colors are distributed along the gradient. 277 * 278 */ 279 typedef struct { 280 float stop; /* < Stop position. The value ranges from 0.0 to 1.0. */ 281 uint32_t color; /* < Color of the stop */ 282 } VGUColorStop; 283 284 /* * 285 * @brief Defines a linear gradient. 286 * 287 */ 288 typedef struct { 289 VGUScalar x1; /* < Horizontal coordinate of the start point of the linear gradient */ 290 VGUScalar y1; /* < Vertical coordinate of the start point of the linear gradient */ 291 VGUScalar x2; /* < Horizontal coordinate of the end point of the linear gradient */ 292 VGUScalar y2; /* < Vertical coordinate of the end point of the linear gradient */ 293 } VGULinear; 294 295 /* * 296 * @brief Defines a radial gradient. 297 * 298 */ 299 typedef struct { 300 VGUScalar x0; /* < Horizontal coordinate of the center of the inner circle */ 301 VGUScalar y0; /* < Vertical coordinate of the center of the inner circle */ 302 VGUScalar r0; /* < Radius of the inner circle */ 303 VGUScalar x1; /* < Horizontal coordinate of the center of the outer circle */ 304 VGUScalar y1; /* < Vertical coordinate of the center of the outer circle */ 305 VGUScalar r1; /* < Radius of the outer circle */ 306 } VGURadial; 307 308 /* * 309 * @brief Defines a conic gradient. 310 * 311 */ 312 typedef struct { 313 VGUScalar cx; /* < Horizontal coordinate of the center of the circle */ 314 VGUScalar cy; /* < Vertical coordinate of the center of the circle */ 315 } VGUConic; 316 317 /* * 318 * @brief Defines an image. 319 * 320 */ 321 typedef struct { 322 VGUBuffer *buffer; /* < Image buffer */ 323 VGUMatrix3 *matrix; /* < Pointer to the transformation matrix. If it is null, the identity matrix is used. */ 324 VGURect *rect; /* < Pointer to the rectangle of the image. If it is null, the entire buffer data is used. */ 325 uint8_t opacity; /* < Opacity. The value ranges from 0 to 255. */ 326 } VGUImage; 327 328 /* * 329 * @brief Defines an image pattern. 330 * 331 */ 332 typedef struct { 333 VGUImage *image; /* < Pointer to the image object */ 334 VGUWrapType wrapx; /* < Wrap the image horizontally. */ 335 VGUWrapType wrapy; /* < Wrap the image vertically. */ 336 } VGUPattern; 337 338 /* * 339 * @brief Enumerates gradient types. 340 * 341 */ 342 typedef enum { 343 VGU_GRADIENT_LINEAR = 0, /* < Linear gradient */ 344 VGU_GRADIENT_RADIAL, /* < Radial gradient */ 345 VGU_GRADIENT_CONIC, /* < Conic gradient */ 346 VGU_GRADIENT_BUTT /* < Invalid definition */ 347 } VGUGradientType; 348 349 /* * 350 * @brief Defines a gradient object. 351 * 352 */ 353 typedef struct { 354 VGUMatrix3 *matrix; /* < Pointer to the transformation matrix of the gradient object */ 355 VGUColorStop *colorStops; /* < Pointer to the gradient stop color array */ 356 uint16_t stopCount; /* < Number of stop colors */ 357 union { 358 VGULinear linear; /* < Linear gradient object */ 359 VGURadial radial; /* < Radial gradient object */ 360 VGUConic conic; /* < Conic gradient object */ 361 }; 362 VGUGradientType type; /* < Gradient type */ 363 VGUFillSpread spread; /* < Gradient spread mode */ 364 uint8_t opacity; /* < Opacity. The value ranges from 0 to 255. */ 365 } VGUGradient; 366 367 /* * 368 * @brief Defines a solid color. 369 * 370 */ 371 typedef struct { 372 uint32_t color; /* < Solid color */ 373 uint8_t opacity; /* < Opacity. The value ranges from 0 to 255. */ 374 } VGUSolid; 375 376 /* * 377 * @brief Enumerates paint types. 378 * 379 */ 380 typedef enum { 381 VGU_PAINT_SOLID = 0, /* < Paint a solid color. */ 382 VGU_PAINT_GRADIENT, /* < Paint a gradient object. */ 383 VGU_PAINT_PATTERN, /* < Paint a pattern. */ 384 VGU_PAINT_BUTT /* < Invalid operation */ 385 } VGUPaintType; 386 387 /* * 388 * @brief Defines the paint style when filling or stroking a path. 389 * 390 */ 391 typedef struct { 392 union { 393 VGUGradient *gradient; /* < Pointer to the gradient object */ 394 VGUPattern *pattern; /* < Pointer to the pattern object */ 395 VGUSolid *solid; /* < Pointer to the solid color object */ 396 }; 397 VGUPaintType type; /* < Paint type */ 398 } VGUPaintStyle; 399 400 /* * 401 * @brief Defines path filling attributes. 402 * 403 */ 404 typedef struct { 405 VGUFillRule rule; /* < Fill rule */ 406 } VGUFillAttr; 407 408 /* * 409 * @brief Defines path stroking attributes. 410 * 411 */ 412 typedef struct { 413 VGULineCap cap; /* < Line cap style */ 414 VGUJointType join; /* < Join type */ 415 float miterLimit; /* < Miter limit */ 416 float width; /* < Line width */ 417 } VGUStrokeAttr; 418 419 /* * 420 * @brief Defines driver functions for 2D hardware acceleration. 421 */ 422 typedef struct { 423 /* * 424 * @brief Initializes hardware acceleration. 425 * 426 * @return Returns <b>VGU_SUCCESS</b> if the operation is successful; returns an error code defined in 427 * {@link VGUResult} otherwise. 428 * @see DeinitVgu 429 * @since 3.0 430 */ 431 VGUResult (*InitVgu)(void); 432 433 /* * 434 * @brief Deinitializes hardware acceleration. 435 * 436 * @return Returns <b>VGU_SUCCESS</b> if the operation is successful; returns an error code defined in 437 * {@link VGUResult} otherwise. 438 * @see InitVgu 439 * @since 3.0 440 */ 441 VGUResult (*DeinitVgu)(void); 442 443 /* * 444 * @brief Queries hardware acceleration capabilities. 445 * 446 * @param cap Indicates the capabilities to query, which are defined by <b>VGUCapability</b>. 447 * 448 * @return Returns a value greater than or equal to 0 if the operation is successful; returns an error code defined 449 * in {@link VGUResult} otherwise. 450 * @since 3.0 451 */ 452 int32_t (*QueryCapability)(uint32_t cap); 453 454 /* * 455 * @brief Fills the given path with a specified paint style. 456 * 457 * @param target Indicates the pointer to the target surface. 458 * @param path Indicates the pointer to the path object. 459 * @param matrix Indicates the pointer to the transformation matrix object. If this parameter is null, 460 * the identity matrix is used by default. 461 * @param attr Indicates the pointer to the path filling attributes. 462 * @param style Indicates the pointer to the paint style to use. 463 * 464 * @return Returns <b>VGU_SUCCESS</b> if the operation is successful; returns an error code defined in 465 * {@link VGUResult} otherwise. 466 * @since 3.0 467 */ 468 VGUResult (*RenderFill)(VGUSurface *target, const VGUPath *path, const VGUMatrix3 *matrix, const VGUFillAttr *attr, 469 const VGUPaintStyle *style); 470 471 /* * 472 * @brief Strokes the given path with a specified paint style. 473 * 474 * @param target Indicates the pointer to the target surface. 475 * @param path Indicates the pointer to the path object. 476 * @param matrix Indicates the pointer to the transformation matrix object. If this parameter is null, 477 * the identity matrix is used by default. 478 * @param attr Indicates the pointer to the path stroking attributes. 479 * @param style Indicates the pointer to the paint style to use. 480 * 481 * @return Returns <b>VGU_SUCCESS</b> if the operation is successful; returns an error code defined in 482 * {@link VGUResult} otherwise. 483 * @since 3.0 484 */ 485 VGUResult (*RenderStroke)(VGUSurface *target, const VGUPath *path, const VGUMatrix3 *matrix, 486 const VGUStrokeAttr *attr, const VGUPaintStyle *style); 487 488 /* * 489 * @brief Blurs a specified surface. 490 * 491 * @param target Indicates the pointer to the target surface. 492 * @param blur Indicates the blur radius. 493 * 494 * @return Returns <b>VGU_SUCCESS</b> if the operation is successful; returns an error code defined in 495 * {@link VGUResult} otherwise. 496 * @since 3.0 497 */ 498 VGUResult (*RenderBlur)(VGUSurface *target, uint16_t blur); 499 500 /* * 501 * @brief Blits an image to the target surface. 502 * 503 * During bit blit, color space conversion (CSC) and transformation can be implemented. 504 * 505 * @param target Indicates the pointer to the target surface. 506 * @param src Indicates the pointer to the source image. 507 * @param color Indicates the color for blending. If this parameter is <b>0</b>, color blending is not performed. 508 * 509 * @return Returns <b>VGU_SUCCESS</b> if the operation is successful; returns an error code defined in 510 * {@link VGUResult} otherwise. 511 * @since 3.0 512 */ 513 VGUResult (*RenderBlit)(VGUSurface *target, const VGUImage *src, uint32_t color); 514 515 /* * 516 * @brief Blits multiple images to the target surface. 517 * 518 * During bit blit, color space conversion (CSC) and transformation can be implemented. You can use this 519 * function to combine multiple source images to the target surface. 520 * To query the maximum number of source images allowed, call the <b>QueryCapability<b/> function. 521 * 522 * @param target Indicates the pointer to the target surface. 523 * @param src Indicates the pointer to the array of source images. 524 * @param count Indicates the number of source images. 525 * @param color Indicates the color for blending. If this parameter is <b>0</b>, color blending is not performed. 526 * 527 * @return Returns <b>VGU_SUCCESS</b> if the operation is successful; returns an error code defined in 528 * {@link VGUResult} otherwise. 529 * @since 3.0 530 */ 531 VGUResult (*RenderBlitN)(VGUSurface *target, const VGUImage *src, uint16_t count, uint32_t color); 532 533 /* * 534 * @brief Clears a rectangle with a given color on the target surface. 535 * 536 * @param target Indicates the pointer to the target surface. 537 * @param rect Indicates the pointer to the rectangle to clear. If this parameter is null, the entire surface 538 * will be cleared. 539 * @param color Indicates the color to fill. 540 * @param opacity Indicates the opacity to set. 541 * 542 * @return Returns <b>VGU_SUCCESS</b> if the operation is successful; returns an error code defined in 543 * {@link VGUResult} otherwise. 544 * @since 3.0 545 */ 546 VGUResult (*RenderClearRect)(VGUSurface *target, const VGURect *rect, uint32_t color, uint8_t opacity); 547 548 /* * 549 * @brief Disables hardware acceleration for rendering. 550 * 551 * @return Returns <b>VGU_SUCCESS</b> if the operation is successful; returns an error code defined in 552 * {@link VGUResult} otherwise. 553 * @since 3.0 554 */ 555 VGUResult (*RenderCancel)(); 556 557 /* * 558 * @brief Synchronizes hardware acceleration when it is used to draw and blit bitmaps. 559 * 560 * This function blocks the process until hardware acceleration is complete. 561 * 562 * @param timeOut Indicates the timeout duration for hardware acceleration synchronization. 563 * The value <b>0</b> indicates no timeout, so the process keeps waiting until hardware acceleration is complete. 564 * 565 * @return Returns <b>VGU_SUCCESS</b> if the operation is successful; returns an error code defined in 566 * {@link VGUResult} otherwise. 567 * @since 3.0 568 */ 569 VGUResult (*RenderSync)(int32_t timeOut); 570 } VGUFuncs; 571 572 /* * 573 * @brief Initializes a path object. 574 * 575 * @param path Indicates the pointer to the path object. 576 * @param type Indicates the data type of the path. 577 * @param segments Indicates the pointer to the path commands. 578 * @param numSegments Indicates the total number of path commands. 579 * @param data Indicates the pointer to the coordinate data used in the path commands. 580 * @param enAlias Specifies whether to enable anti-aliasing. 581 * @param boundBox Indicates the bounding box of the path. 582 * 583 * @return Returns <b>VGU_SUCCESS</b> if the operation is successful; returns an error code defined in 584 * {@link VGUResult} otherwise. 585 * @since 3.0 586 */ 587 VGUResult VGUPathInit(VGUPath *path, VGUPathDataType type, const uint8_t* segments, int numSegments, 588 const uint8_t *data, bool enAlias, VGURect boundBox); 589 590 /* * 591 * @brief Adds a subpath to a specified path. 592 * 593 * @param path Indicates the pointer to the path object. 594 * @param subpath Indicates the pointer to the subpath object. 595 * 596 * @return Returns <b>VGU_SUCCESS</b> if the operation is successful; returns an error code defined in 597 * {@link VGUResult} otherwise. 598 * @since 3.0 599 */ 600 VGUResult VGUPathAppend(VGUPath *path, const VGUPath *subpath); 601 602 /* * 603 * @brief Clears the memory of a specified path object. 604 * 605 * @param path Indicates the pointer to the path object. 606 * 607 * @return Returns <b>VGU_SUCCESS</b> if the operation is successful; returns an error code defined in 608 * {@link VGUResult} otherwise. 609 * @since 3.0 610 */ 611 VGUResult VGUPathClear(VGUPath *path); 612 613 /* * 614 * @brief Loads an identity matrix into a specified matrix object. 615 * 616 * @param matrix Indicates the pointer to the transformation matrix object. 617 * 618 * @return Returns <b>VGU_SUCCESS</b> if the operation is successful; returns an error code defined in 619 * {@link VGUResult} otherwise. 620 * @since 3.0 621 */ 622 VGUResult VGUMatrixIdentity(VGUMatrix3 *matrix); 623 624 /* * 625 * @brief Scales a specified transformation matrix. 626 * 627 * @param matrix Indicates the pointer to the transformation matrix object. 628 * @param xScale Indicates how much you want to scale the horizontal coordinate by. 629 * @param yScale Indicates how much you want to scale the vertical coordinate by. 630 * 631 * @return Returns <b>VGU_SUCCESS</b> if the operation is successful; returns an error code defined in 632 * {@link VGUResult} otherwise. 633 * @since 3.0 634 */ 635 VGUResult VGUMatrixScale(VGUMatrix3 *matrix, float xScale, float yScale); 636 637 /* * 638 * @brief Rotates a specified transformation matrix. 639 * 640 * @param matrix Indicates the pointer to the transformation matrix object. 641 * @param degree Indicates the number of degrees to rotate. 642 * 643 * @return Returns <b>VGU_SUCCESS</b> if the operation is successful; returns an error code defined in 644 * {@link VGUResult} otherwise. 645 * @since 3.0 646 */ 647 VGUResult VGUMatrixRotate(VGUMatrix3 *matrix, float degree); 648 649 /* * 650 * @brief Translates a specified transformation matrix. 651 * 652 * @param matrix Indicates the pointer to the transformation matrix object. 653 * @param x Indicates how much you want to translate the horizontal coordinate by. 654 * @param y Indicates how much you want to translate the vertical coordinate by. 655 * 656 * @return Returns <b>VGU_SUCCESS</b> if the operation is successful; returns an error code defined in 657 * {@link VGUResult} otherwise. 658 * @since 3.0 659 */ 660 VGUResult VGUMatrixTranslate(VGUMatrix3 *matrix, float x, float y); 661 662 /* * 663 * @brief Adds color stops to a specified gradient. 664 * 665 * @param gradient Indicates the pointer to the gradient object. 666 * @param colorStop Indicates the pointer to the color stop array. 667 * @param count Indicates the total number of color stops. 668 * 669 * @return Returns <b>VGU_SUCCESS</b> if the operation is successful; returns an error code defined in 670 * {@link VGUResult} otherwise. 671 * @since 3.0 672 */ 673 VGUResult VGUGradientColorStop(VGUGradient *gradient, const VGUColorStop *colorStop, uint32_t count); 674 675 /* * 676 * @brief Clears color stops of a specified gradient. 677 * 678 * @param gradient Indicates the pointer to the gradient object. 679 * 680 * @return Returns <b>VGU_SUCCESS</b> if the operation is successful; returns an error code defined in 681 * {@link VGUResult} otherwise. 682 * @since 3.0 683 */ 684 VGUResult VGUGradientClearStop(VGUGradient *gradient); 685 686 /* * 687 * @brief Sets a transformation matrix for a specified gradient. 688 * 689 * @param gradient Indicates the pointer to the gradient object. 690 * @param matrix Indicates the pointer to the transformation matrix object to set. 691 * 692 * @return Returns <b>VGU_SUCCESS</b> if the operation is successful; returns an error code defined in 693 * {@link VGUResult} otherwise. 694 * @since 3.0 695 */ 696 VGUResult VGUGradientMatrix(VGUGradient *gradient, const VGUMatrix3 *matrix); 697 698 /* * 699 * @brief Creates a linear gradient object. 700 * 701 * @param gradient Indicates the pointer to the gradient object. 702 * @param p1 Indicates the pointer to the coordinates of the start point. 703 * @param p2 Indicates the pointer to the coordinates of the end point. 704 * 705 * @return Returns <b>VGU_SUCCESS</b> if the operation is successful; returns an error code defined in 706 * {@link VGUResult} otherwise. 707 * @since 3.0 708 */ 709 VGUResult VGUGradientLinear(VGUGradient *gradient, const VGUPoint *p1, const VGUPoint *p2); 710 711 /* * 712 * @brief Creates a radial gradient object. 713 * 714 * @param gradient Indicates the pointer to the gradient object. 715 * @param p1 Indicates the pointer to the center point coordinates of the inner circle. 716 * @param r1 Indicates the radius of the inner circle. 717 * @param p2 Indicates the pointer to the center point coordinates of the outer circle. 718 * @param r2 Indicates the radius of the outer circle. 719 * 720 * @return Returns <b>VGU_SUCCESS</b> if the operation is successful; returns an error code defined in 721 * {@link VGUResult} otherwise. 722 * @since 3.0 723 */ 724 VGUResult VGUGradientRadial(VGUGradient *gradient, const VGUPoint *p1, VGUScalar r1, const VGUPoint *p2, VGUScalar r2); 725 726 /* * 727 * @brief Creates a conic gradient object. 728 * 729 * @param gradient Indicates the pointer to the gradient object. 730 * @param cx Indicates the horizontal coordinate of the center point of the gradient. 731 * @param cy Indicates the vertical coordinate of the center point of the gradient. 732 * 733 * @return Returns <b>VGU_SUCCESS</b> if the operation is successful; returns an error code defined in 734 * {@link VGUResult} otherwise. 735 * @since 3.0 736 */ 737 VGUResult VGUGradientConic(VGUGradient *gradient, VGUScalar cx, VGUScalar cy); 738 739 /* * 740 * @brief Initializes the hardware acceleration module to obtain the pointer to functions for 741 * hardware acceleration operations. 742 * 743 * @param funcs Indicates the double pointer to the functions for hardware acceleration operations. 744 * Memory is allocated automatically when you initiate the hardware acceleration module, so you can simply use 745 * the pointer to gain access to the functions. 746 * 747 * @return Returns <b>VGU_SUCCESS</b> if the operation is successful; returns an error code defined in 748 * {@link VGUResult} otherwise. 749 * 750 * @since 3.0 751 */ 752 VGUResult VGUInitialize(VGUFuncs **funcs); 753 754 /* * 755 * @brief Deinitializes the hardware acceleration module to release the pointer to functions 756 * for hardware acceleration operations. 757 * 758 * @param funcs Indicates the pointer to the functions for hardware acceleration operations. 759 * 760 * @return Returns <b>VGU_SUCCESS</b> if the operation is successful; returns an error code defined in 761 * {@link VGUResult} otherwise. 762 * @since 3.0 763 */ 764 VGUResult VGUUninitialize(VGUFuncs *funcs); 765 766 #ifdef __cplusplus 767 } 768 #endif 769 #endif 770