diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 74966e40..f062038b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -42,7 +42,7 @@ If your change don't belonged to any sub modules, you can replace with proper na The name must be written in all lower alphabet characters. - ex) build / doc / infra / common / sw_engine / gl_engine / svg_loader / examples / wasm / svg2png ... -- [Feature] is what major function/feature you changed. Normally this indicates a representive file name. +- [Feature] is what major function/feature you changed. Normally this indicates a representive file name. You can keep the file name, but don't please contain any prefix(tvg) nor suffix(Impl) here. - ex) Canvas / TaskScehduler / SvgLoader / SvgBuilder / SwRle / GlRenderer / ... @@ -51,51 +51,51 @@ You can keep the file name, but don't please contain any prefix(tvg) nor suffix( - ex) "Fixed compile warnings" - ex) "Code refactoring" - ex) "Fixed a rendering bug that overlapped shapes inproper way." - + - [Description] There is no any strict formats, but it must describe what you did in this patch as far as possible you can describe in detail. If you fixed any bugs, it must contain below: - - what type of bug + - what type of bug - conditions to reproduce it - root cause - - solution - + - solution + Or if you add a new feature or function, it must contain below: - what sort of features - api full specification (if any api additions) - any necessity - - condition / restriction + - condition / restriction - reference or sample - + Lastly, please append any issue ticket numbers in this section if any. - - + + - Here is a overall commit message what we expect to review: - + - common composite: newly added path clipping feature We introduced new method Paint::composite() to support composite behaviors.
This allows paints to composite with other paints instances.
Composite behaviors depend on its composite method type.
- Here we firstly introduced "ClipPath" method to support clipping by path unit of paint.
- + Here we firstly introduced "ClipPath" method to support clipping by path unit of paint.
+ tagetPaint->composite(srcPaint, CompositeMethod::ClipPath);
- + Beaware if the source paint doesn't contain any path info, clipping won't be applied as you expected. - + @API Additions:
enum CompositeMethod {None = 0, ClipPath};
Result Paint::composite(std::unique_ptr target, CompositeMethod method) const noexcept;
@Examples: added ClipPath
- + @References: any links to the references such as screenshot images. @Issues: (Issue Link)
## Pull Request - + Once you submitted a pull request(PR), please make it sure below check list. - Reviewers: Check Reviewers List - Assignees: You diff --git a/README.md b/README.md index 8b285a8f..b17dacc2 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ ThorVG has the threading mechanism so that it tries to acquire the next scenes w - [Tizen](#tizen) - [Rive](#rive) - [Godot](#godot) - - [Examples](#examples) + - [Examples](#examples) - [Documentation](#documentation) - [Tools](#tools) - [ThorVG Viewer](#thorvg-viewer) diff --git a/inc/thorvg.h b/inc/thorvg.h index 1429839f..594fe9b1 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -186,10 +186,10 @@ struct Matrix /** * @brief A data structure representing a texture mesh vertex - * + * * @param pt The vertex coordinate * @param uv The normalized texture coordinate in the range (0.0..1.0, 0.0..1.0) - * + * * @BETA_API */ struct Vertex @@ -201,9 +201,9 @@ struct Vertex /** * @brief A data structure representing a triange in a texture mesh - * + * * @param vertex The three vertices that make up the polygon - * + * * @BETA_API */ struct Polygon @@ -1197,38 +1197,38 @@ public: /** * @brief Sets or removes the triangle mesh to deform the image. - * + * * If a mesh is provided, the transform property of the Picture will apply to the triangle mesh, and the * image data will be used as the texture. - * + * * If @p triangles is @c nullptr, or @p triangleCnt is 0, the mesh will be removed. - * + * * Only raster image types are supported at this time (png, jpg). Vector types like svg and tvg do not support. * mesh deformation. However, if required you should be able to render a vector image to a raster image and then apply a mesh. - * + * * @param[in] triangles An array of Polygons(triangles) that make up the mesh, or null to remove the mesh. * @param[in] triangleCnt The number of Polygons(triangles) provided, or 0 to remove the mesh. - * + * * @retval Result::Success When succeed. * @retval Result::Unknown If fails - * + * * @note The Polygons are copied internally, so modifying them after calling Mesh::mesh has no affect. * @warning Please do not use it, this API is not official one. It could be modified in the next version. - * + * * @BETA_API */ Result mesh(const Polygon* triangles, const uint32_t triangleCnt) noexcept; /** * @brief Return the number of triangles in the mesh, and optionally get a pointer to the array of triangles in the mesh. - * + * * @param[out] triangles Optional. A pointer to the array of Polygons used by this mesh. - * + * * @return uint32_t The number of polygons in the array. - * + * * @note Modifying the triangles returned by this method will modify them directly within the mesh. * @warning Please do not use it, this API is not official one. It could be modified in the next version. - * + * * @BETA_API */ uint32_t mesh(const Polygon** triangles) const noexcept; diff --git a/src/bin/svg2tvg/svg2tvg.cpp b/src/bin/svg2tvg/svg2tvg.cpp index c2788f3e..fad70a44 100644 --- a/src/bin/svg2tvg/svg2tvg.cpp +++ b/src/bin/svg2tvg/svg2tvg.cpp @@ -38,7 +38,7 @@ void helpMsg() bool convert(string& in, string& out) { if (Initializer::init(CanvasEngine::Sw, 0) != Result::Success) return false; - + auto picture = Picture::gen(); if (picture->load(in) != Result::Success) return false; diff --git a/src/examples/TvgSaver.cpp b/src/examples/TvgSaver.cpp index 7cd76aa7..fdedb9b4 100644 --- a/src/examples/TvgSaver.cpp +++ b/src/examples/TvgSaver.cpp @@ -198,7 +198,7 @@ void exportTvg() //prepare image source const int width = 200; - const int height = 300; + const int height = 300; ifstream file(EXAMPLE_DIR"/rawimage_200x300.raw"); if (!file.is_open()) return; uint32_t *data = (uint32_t*) malloc(sizeof(uint32_t) * width * height); @@ -213,7 +213,7 @@ void exportTvg() //clipped image auto image = tvgClippedImage(data, width, height); if (scene->push(move(image)) != tvg::Result::Success) return; - + free(data); //prepare gradient common data @@ -246,7 +246,7 @@ void exportTvg() auto circ1 = tvgCircle1(colorStops3, 2); if (scene->push(move(circ1)) != tvg::Result::Success) return; - auto circ2 = tvgCircle2(colorStops3, 2); + auto circ2 = tvgCircle2(colorStops3, 2); if (scene->push(move(circ2)) != tvg::Result::Success) return; //inv mask applied to the main scene diff --git a/src/examples/all.sh b/src/examples/all.sh index fc1d2bcc..992752b2 100755 --- a/src/examples/all.sh +++ b/src/examples/all.sh @@ -14,7 +14,7 @@ do echo -e "Execute: "${GREEN}$EXAMPLE${NC}" for "$INTERVAL" second(s)" $EXAMPLE & EXAMPLE_PID=$! - sleep $INTERVAL + sleep $INTERVAL kill -s SIGTERM $EXAMPLE_PID if [ $? -ne 0 ]; then echo -e "Something wrong with: "${RED}$EXAMPLE${NC} diff --git a/src/lib/gl_engine/tvgGlGeometry.h b/src/lib/gl_engine/tvgGlGeometry.h index 7c9dbe47..79ffeb98 100644 --- a/src/lib/gl_engine/tvgGlGeometry.h +++ b/src/lib/gl_engine/tvgGlGeometry.h @@ -96,7 +96,7 @@ public: bool operator== (const GlPoint& rhs) { - if (&rhs == this) return true; + if (&rhs == this) return true; if (rhs.x == this->x && rhs.y == this->y) return true; return false; } diff --git a/src/lib/sw_engine/tvgSwImage.cpp b/src/lib/sw_engine/tvgSwImage.cpp index a1b8960e..2b139a76 100644 --- a/src/lib/sw_engine/tvgSwImage.cpp +++ b/src/lib/sw_engine/tvgSwImage.cpp @@ -53,9 +53,9 @@ static bool _genOutline(SwImage* image, Polygon* triangles, uint32_t triangleCou Point to[4]; if (triangleCount > 0) { - // TODO: Optimise me. We appear to calculate this exact min/max bounding area in multiple + // TODO: Optimise me. We appear to calculate this exact min/max bounding area in multiple // places. We should be able to re-use one we have already done? Also see: - // tvgPictureImpl.h --> bounds + // tvgPictureImpl.h --> bounds // tvgSwRasterTexmap.h --> _rasterTexmapPolygonMesh // // TODO: Should we calculate the exact path(s) of the triangle mesh instead? diff --git a/src/lib/sw_engine/tvgSwRasterNeon.h b/src/lib/sw_engine/tvgSwRasterNeon.h index a4b3cdae..4ce60c58 100644 --- a/src/lib/sw_engine/tvgSwRasterNeon.h +++ b/src/lib/sw_engine/tvgSwRasterNeon.h @@ -116,7 +116,7 @@ static bool neonRasterTranslucentRect(SwSurface* surface, const SwBBox& region, for (uint32_t x = 0; x < (w - align) / 2; ++x) vDst[x] = vadd_u8((uint8x8_t)vColor, ALPHA_BLEND(vDst[x], vIalpha)); - + auto leftovers = (w - align) % 2; if (leftovers > 0) dst[w - 1] = color + ALPHA_BLEND(dst[w - 1], ialpha); } diff --git a/src/lib/sw_engine/tvgSwRasterTexmap.h b/src/lib/sw_engine/tvgSwRasterTexmap.h index 32a772ed..9aebaaf6 100644 --- a/src/lib/sw_engine/tvgSwRasterTexmap.h +++ b/src/lib/sw_engine/tvgSwRasterTexmap.h @@ -517,7 +517,7 @@ static bool _apply(SwSurface* surface, AASpans* aaSpans) dst = surface->buffer + (offset + line->x[1] - 1); if (line->x[1] < (int32_t)(surface->w - 1)) pixel = *(dst + 1); else pixel = *dst; - + pos = width; while ((int32_t)(width - line->length[1]) < pos) { *dst = INTERPOLATE(255 - (line->coverage[1] * (line->length[1] - (width - pos))), *dst, pixel); @@ -543,7 +543,7 @@ static bool _apply(SwSurface* surface, AASpans* aaSpans) 0 -- 1 | / | | / | - 3 -- 2 + 3 -- 2 */ static bool _rasterTexmapPolygon(SwSurface* surface, const SwImage* image, const Matrix* transform, const SwBBox* region, uint32_t opacity, uint32_t (*blendMethod)(uint32_t)) { diff --git a/src/lib/tvgBezier.cpp b/src/lib/tvgBezier.cpp index 95e20559..f26f74f8 100644 --- a/src/lib/tvgBezier.cpp +++ b/src/lib/tvgBezier.cpp @@ -114,7 +114,7 @@ float bezAt(const Bezier& bz, float at) auto t = 0.5f; //just in case to prevent an infinite loop - if (at <= 0) return 0.0f; + if (at <= 0) return 0.0f; if (at >= len) return 1.0f; diff --git a/src/lib/tvgBinaryDesc.h b/src/lib/tvgBinaryDesc.h index bab6b791..a6a70a49 100644 --- a/src/lib/tvgBinaryDesc.h +++ b/src/lib/tvgBinaryDesc.h @@ -42,7 +42,7 @@ using TvgBinFlag = TvgBinByte; #define TVG_HEADER_VERSION_LENGTH 6 #define TVG_HEADER_RESERVED_LENGTH 1 //Storing flags for extensions #define TVG_HEADER_COMPRESS_SIZE 12 //TVG_HEADER_UNCOMPRESSED_SIZE + TVG_HEADER_COMPRESSED_SIZE + TVG_HEADER_COMPRESSED_SIZE_BITS -//Compress Size +//Compress Size #define TVG_HEADER_UNCOMPRESSED_SIZE 4 //SIZE (TvgBinCounter) #define TVG_HEADER_COMPRESSED_SIZE 4 //SIZE (TvgBinCounter) #define TVG_HEADER_COMPRESSED_SIZE_BITS 4 //SIZE (TvgBinCounter) diff --git a/src/lib/tvgLzw.cpp b/src/lib/tvgLzw.cpp index 1aaf3783..964af081 100644 --- a/src/lib/tvgLzw.cpp +++ b/src/lib/tvgLzw.cpp @@ -258,8 +258,8 @@ struct Dictionary Dictionary() { - /* First 256 dictionary entries are reserved to the byte/ASCII range. - Additional entries follow for the character sequences found in the input. + /* First 256 dictionary entries are reserved to the byte/ASCII range. + Additional entries follow for the character sequences found in the input. Up to 4096 - 256 (MaxDictEntries - FirstCode). */ size = FirstCode; diff --git a/src/lib/tvgMath.h b/src/lib/tvgMath.h index 74f34fb7..2cce3181 100644 --- a/src/lib/tvgMath.h +++ b/src/lib/tvgMath.h @@ -118,7 +118,7 @@ static inline void mathScale(Matrix* m, float scale) static inline void mathTranslate(Matrix* m, float x, float y) { m->e13 = x; - m->e23 = y; + m->e23 = y; } diff --git a/src/lib/tvgPictureImpl.h b/src/lib/tvgPictureImpl.h index 8bbb745d..172c6f64 100644 --- a/src/lib/tvgPictureImpl.h +++ b/src/lib/tvgPictureImpl.h @@ -173,7 +173,6 @@ struct Picture::Impl bool bounds(float* x, float* y, float* w, float* h) { if (triangleCnt > 0) { - Point min = { triangles[0].vertex[0].pt.x, triangles[0].vertex[0].pt.y }; Point max = { triangles[0].vertex[0].pt.x, triangles[0].vertex[0].pt.y }; diff --git a/src/loaders/jpg/tvgJpgd.cpp b/src/loaders/jpg/tvgJpgd.cpp index 56b40acf..f4b1d13e 100644 --- a/src/loaders/jpg/tvgJpgd.cpp +++ b/src/loaders/jpg/tvgJpgd.cpp @@ -80,7 +80,7 @@ enum jpgd_status enum { JPGD_IN_BUF_SIZE = 8192, JPGD_MAX_BLOCKS_PER_MCU = 10, JPGD_MAX_HUFF_TABLES = 8, JPGD_MAX_QUANT_TABLES = 4, - JPGD_MAX_COMPONENTS = 4, JPGD_MAX_COMPS_IN_SCAN = 4, JPGD_MAX_BLOCKS_PER_ROW = 8192, JPGD_MAX_HEIGHT = 16384, JPGD_MAX_WIDTH = 16384 + JPGD_MAX_COMPONENTS = 4, JPGD_MAX_COMPS_IN_SCAN = 4, JPGD_MAX_BLOCKS_PER_ROW = 8192, JPGD_MAX_HEIGHT = 16384, JPGD_MAX_WIDTH = 16384 }; // Input stream interface. @@ -151,7 +151,7 @@ public: // If JPGD_SUCCESS is returned you may then call decode() on each scanline. int begin_decoding(); // Returns the next scan line. - // For grayscale images, pScan_line will point to a buffer containing 8-bit pixels (get_bytes_per_pixel() will return 1). + // For grayscale images, pScan_line will point to a buffer containing 8-bit pixels (get_bytes_per_pixel() will return 1). // Otherwise, it will always point to a buffer containing 32-bit RGBA pixels (A will always be 255, and get_bytes_per_pixel() will return 4). // Returns JPGD_SUCCESS if a scan line has been returned. // Returns JPGD_DONE if all scan lines have been returned. @@ -1246,7 +1246,7 @@ void jpeg_decoder::read_sof_marker() uint32_t num_left = get_bits(16); if (get_bits(8) != 8) stop_decoding(JPGD_BAD_PRECISION); /* precision: sorry, only 8-bit precision is supported right now */ - + m_image_y_size = get_bits(16); if ((m_image_y_size < 1) || (m_image_y_size > JPGD_MAX_HEIGHT)) stop_decoding(JPGD_BAD_HEIGHT); @@ -1326,7 +1326,7 @@ void jpeg_decoder::read_sos_marker() } num_left -= 3; - while (num_left) { /* read past whatever is num_left */ + while (num_left) { /* read past whatever is num_left */ get_bits(8); num_left--; } @@ -1411,7 +1411,7 @@ int jpeg_decoder::process_markers() stop_decoding(JPGD_UNEXPECTED_MARKER); break; } - default: { /* must be DNL, DHP, EXP, APPn, JPGn, COM, or RESn or APP0 */ + default: { /* must be DNL, DHP, EXP, APPn, JPGn, COM, or RESn or APP0 */ skip_variable_marker(); break; } @@ -1441,7 +1441,7 @@ void jpeg_decoder::locate_soi_marker() if (lastchar == 0xFF) { if (thischar == M_SOI) break; - else if (thischar == M_EOI) stop_decoding(JPGD_NOT_JPEG); // get_bits will keep returning M_EOI if we read past the end + else if (thischar == M_EOI) stop_decoding(JPGD_NOT_JPEG); // get_bits will keep returning M_EOI if we read past the end } } @@ -1460,7 +1460,7 @@ void jpeg_decoder::locate_sof_marker() switch (c) { case M_SOF2: m_progressive_flag = true; case M_SOF0: /* baseline DCT */ - case M_SOF1: { /* extended sequential DCT */ + case M_SOF1: { /* extended sequential DCT */ read_sof_marker(); break; } @@ -1671,7 +1671,7 @@ void jpeg_decoder::transform_mcu_expand(int mcu_row) JPGD_ASSERT(m_mcu_block_max_zag[mcu_block] >= 1); JPGD_ASSERT(m_mcu_block_max_zag[mcu_block] <= 64); - int max_zag = m_mcu_block_max_zag[mcu_block++] - 1; + int max_zag = m_mcu_block_max_zag[mcu_block++] - 1; if (max_zag <= 0) max_zag = 0; // should never happen, only here to shut up static analysis switch (s_max_rc[max_zag]) { @@ -1789,7 +1789,7 @@ void jpeg_decoder::load_next_row() p[0] = pDC[0]; memcpy(&p[1], &pAC[1], 63 * sizeof(jpgd_block_t)); - for (i = 63; i > 0; i--) { + for (i = 63; i > 0; i--) { if (p[g_ZAG[i]]) break; } @@ -1809,7 +1809,7 @@ void jpeg_decoder::load_next_row() if (++block_y_mcu_ofs == m_comp_v_samp[component_id]) { block_y_mcu_ofs = 0; block_x_mcu[component_id] += m_comp_h_samp[component_id]; - } + } } } if (m_freq_domain_chroma_upsample) transform_mcu_expand(mcu_row); @@ -1865,7 +1865,7 @@ void jpeg_decoder::process_restart() static inline int dequantize_ac(int c, int q) -{ +{ c *= q; return c; } @@ -1910,7 +1910,7 @@ void jpeg_decoder::decode_next_row() while (n--) p[g_ZAG[kt++]] = 0; } k += r; - } + } s = JPGD_HUFF_EXTEND(extra_bits, s); JPGD_ASSERT(k < 64); p[g_ZAG[k]] = static_cast(dequantize_ac(s, q[k])); //s * q[k]; @@ -2204,7 +2204,7 @@ int jpeg_decoder::decode(const void** pScan_line, uint32_t* pScan_line_len) } else *pScan_line = m_pScan_line_1; break; - } + } case JPGD_YH2V1: { H2V1Convert(); *pScan_line = m_pScan_line_0; @@ -2609,11 +2609,11 @@ void jpeg_decoder::decode_block_ac_refine(jpeg_decoder *pD, int component_id, in int p1 = 1 << pD->m_successive_low; int m1 = static_cast(-1) << pD->m_successive_low; jpgd_block_t *p = pD->coeff_buf_getp(pD->m_ac_coeffs[component_id], block_x, block_y); - + JPGD_ASSERT(pD->m_spectral_end <= 63); - + k = pD->m_spectral_start; - + if (pD->m_eob_run == 0) { for ( ; k <= pD->m_spectral_end; k++) { s = pD->huff_decode(pD->m_pHuff_tabs[pD->m_comp_ac_tab[component_id]]); diff --git a/src/loaders/png/tvgLodePng.cpp b/src/loaders/png/tvgLodePng.cpp index eaed025c..509ccd17 100644 --- a/src/loaders/png/tvgLodePng.cpp +++ b/src/loaders/png/tvgLodePng.cpp @@ -1167,7 +1167,7 @@ static unsigned lodepng_crc32_table[256] = { }; -/* Calculate CRC32 of buffer +/* Calculate CRC32 of buffer Return the CRC of the bytes buf[0..len-1]. */ static unsigned lodepng_crc32(const unsigned char* data, size_t length) { @@ -1571,7 +1571,7 @@ static unsigned color_tree_add(ColorTree* tree, unsigned char r, unsigned char g /* put a pixel, given its RGBA color, into image of any color type */ static unsigned rgba8ToPixel(unsigned char* out, size_t i, const LodePNGColorMode* mode, ColorTree* tree /*for palette*/, unsigned char r, unsigned char g, unsigned char b, unsigned char a) -{ +{ if (mode->colortype == LCT_GREY) { unsigned char gray = r; /*((unsigned short)r + g + b) / 3u;*/ if (mode->bitdepth == 8) out[i] = gray; diff --git a/test/capi/capiFill.cpp b/test/capi/capiFill.cpp index a023c96a..24398574 100644 --- a/test/capi/capiFill.cpp +++ b/test/capi/capiFill.cpp @@ -25,7 +25,7 @@ TEST_CASE("Set/Get fill color", "[capiShapeFill]") -{ +{ Tvg_Paint *paint = tvg_shape_new(); REQUIRE(paint); @@ -43,7 +43,7 @@ TEST_CASE("Set/Get fill color", "[capiShapeFill]") } TEST_CASE("Set/Get fill color on invalid shape", "[capiShapeFill]") -{ +{ REQUIRE(tvg_shape_set_fill_color(NULL, 120, 154, 180, 100) == TVG_RESULT_INVALID_ARGUMENT); uint8_t r, g, b, a; @@ -51,7 +51,7 @@ TEST_CASE("Set/Get fill color on invalid shape", "[capiShapeFill]") } TEST_CASE("Set/Get shape fill rule", "[capiShapeFill]") -{ +{ Tvg_Paint *paint = tvg_shape_new(); REQUIRE(paint); @@ -65,7 +65,7 @@ TEST_CASE("Set/Get shape fill rule", "[capiShapeFill]") } TEST_CASE("Set/Get shape fill rule on invalid object", "[capiShapeFill]") -{ +{ REQUIRE(tvg_shape_set_fill_rule(NULL, TVG_FILL_RULE_EVEN_ODD) == TVG_RESULT_INVALID_ARGUMENT); Tvg_Fill_Rule rule; diff --git a/test/testAccessor.cpp b/test/testAccessor.cpp index b3790f8a..f5bf0524 100644 --- a/test/testAccessor.cpp +++ b/test/testAccessor.cpp @@ -44,7 +44,7 @@ TEST_CASE("Set", "[tvgAccessor]") REQUIRE(canvas); uint32_t buffer[100*100]; - REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success); + REQUIRE(canvas->target(buffer, 100, 100, 100, SwCanvas::Colorspace::ABGR8888) == Result::Success); auto picture = Picture::gen(); REQUIRE(picture); @@ -74,4 +74,4 @@ TEST_CASE("Set", "[tvgAccessor]") REQUIRE(picture); REQUIRE(Initializer::term(CanvasEngine::Sw) == Result::Success); -} \ No newline at end of file +}