Mira Grudzinska [Wed, 25 Aug 2021 08:49:51 +0000 (10:49 +0200)]
sw_engine neon: fix the iterations number of 'neon calls'
In the case, when the dst memory was not aligned,
we went out of the dst range in the 'neon loop'.
Michal Maciola [Mon, 30 Aug 2021 10:40:29 +0000 (12:40 +0200)]
README: updated svg2png section (#758)
Hermet Park [Mon, 30 Aug 2021 10:05:12 +0000 (19:05 +0900)]
Update README.md
Hermet Park [Mon, 30 Aug 2021 07:54:43 +0000 (16:54 +0900)]
sw_engine: code refactoring.
simplify neon code and fix the wrong range access.
Hermet Park [Mon, 30 Aug 2021 06:35:27 +0000 (15:35 +0900)]
tvg_loader: fixed a wrong delete call.
delete is not expected here, malloc-free must be paired.
Change-Id: I25ee480a238fa86d9cd01a3d5850031c9b443a89
Mira Grudzinska [Sun, 29 Aug 2021 22:36:59 +0000 (00:36 +0200)]
tvg saver: enabling gradient transformation
A gradient transformation was omitted when saving
into the tvg format. Fixed
Change-Id: Ifca25ef9608b3cab279e645f817b2829f0b972bb
JunsuChoi [Fri, 27 Aug 2021 05:14:36 +0000 (14:14 +0900)]
doc: Enhance appendPath docs
Added description according to api behavior change
Change-Id: I1abf748fa64d092e39199cbf99315586865e78a0
jykeon [Mon, 30 Aug 2021 05:54:54 +0000 (14:54 +0900)]
bump up version v0.4.3
Change-Id: Iaeecd0a7fcf617a00f1fc70e98e5914e0a9b300a
Signed-off-by: jykeon <jykeon@samsung.com>
Hermet Park [Sat, 28 Aug 2021 12:55:51 +0000 (21:55 +0900)]
tvg_format: fix broken clippath region.
there some multiple wrong calculation about size during tvg optimiation.
this patch fixes them.
1. picture needs to return the current desired size because
it will save the transformed the geometry. the final size should be
recorvered as the base size from the loader.
2. clippath missed to multiply parents transform, it's fixed.
@Issue: https://github.com/Samsung/thorvg/issues/752
Michal Maciola [Tue, 24 Aug 2021 12:31:26 +0000 (14:31 +0200)]
wasm: fix loading for binary files
This patch changes load function in thorvgwasm.cpp for using size()
instead of strlen(). It fixes loading of binary files like .tvg.
Hermet Park [Tue, 24 Aug 2021 06:04:06 +0000 (15:04 +0900)]
sw_engine shape: prevent crash when wrong pair of commands & points.
add an exception handling,
if the given points count is not matched with expected points count from commands.
@Issue: https://github.com/Samsung/thorvg/issues/735
Mira Grudzinska [Tue, 24 Aug 2021 23:19:25 +0000 (01:19 +0200)]
sw_engine avx: addad ALPHA_BLEND and avxRasterTranslucentRect functions
Both functions implemented using 128-bit registers.
avxRasterTranslucentRect is around 5 times faster than cRasterTranslucentRect (i7-8700 CPU - Coffe Lake)
Michal Maciola [Wed, 25 Aug 2021 12:36:35 +0000 (14:36 +0200)]
wasm: intoduce saveTvg via File System API
This patch adds saveTvg() function into thorvgwasm.cpp.
Functions saves tvg using File System API.
To enable fs, changed build flag: -s FORCE_FILESYSTEM=1.
Increase in result thorvg-wasm.js size: about 68kB to about 125kB.
Michal Maciola [Tue, 24 Aug 2021 12:59:54 +0000 (14:59 +0200)]
tvg_loader: make sure the pointer does not exceed the size
Hermet Park [Wed, 25 Aug 2021 12:41:02 +0000 (21:41 +0900)]
tvg format: fix broken encoding/decoding.
a regression bug was introduced by
52a7a257b2fb863f1e9e9292de7291b7e2986adf
in size calculation of data in case of uncompressed version.
@Issue: https://github.com/Samsung/thorvg/issues/739
Hermet Park [Wed, 25 Aug 2021 06:17:25 +0000 (15:17 +0900)]
common picture: quick fix the broken bounds() interface.
picture must return the boundary info - 0, 0, w, h
We assume that it has a designated picture size.
Aside from this issue,
bounds() api must be reviewed, its behavior is quite in a trouble...
unless the result is not transformed, its information is useless...
@Issue: https://github.com/Samsung/thorvg/issues/741
Michal Maciola [Thu, 19 Aug 2021 07:37:57 +0000 (09:37 +0200)]
svg: fix opacity percentage value parsing
Percentage values wasn't handled by _toOpacity() function. Other incorrect values
was handled wrongly. Now fixed.
Hermet Park [Tue, 24 Aug 2021 11:35:06 +0000 (20:35 +0900)]
Update CONTRIBUTING.md
Michal Szczecinski [Thu, 12 Aug 2021 14:02:40 +0000 (16:02 +0200)]
sw common: Added neon translucent rect API implementation.
Changes:
Added neonRasterTranslucentRect implementation. Rendering was tested on
32 lottie fiels. Without neon ~ 18.1 FPS was measured. With neon ~ 20.1
FPS was measured.
Hermet Park [Thu, 19 Aug 2021 09:37:51 +0000 (18:37 +0900)]
tvg_format: newly introduced for tvg data compression.
By choosing compress option, tvg tries to compress the data to reduce the binary size.
Since the compression has the double-edges sword, we provides an option to users
to select it by their demand. Basically, compression is better than non-compression.
After profiling, we decided to use the encoder/decoder of Guilherme R. Lampert's.
Here is the profiling result:
test.tvg: 296037 -> 243411 (-17%)
tiger.tvg: 54568 -> 50622 (-7%)
image-embedded.tvg: 2282 -> 1231 (-46%)
@Issue: https://github.com/Samsung/thorvg/issues/639
About compression method:
Lempel–Ziv–Welch (LZW) encoder/decoder by Guilherme R. Lampert
This is the compression scheme used by the GIF image format and the Unix 'compress' tool.
Main differences from this implementation is that End Of Input (EOI) and Clear Codes (CC)
are not stored in the output and the max code length in bits is 12, vs 16 in compress.
EOI is simply detected by the end of the data stream, while CC happens if the
dictionary gets filled. Data is written/read from bit streams, which handle
byte-alignment for us in a transparent way.
The decoder relies on the hardcoded data layout produced by the encoder, since
no additional reconstruction data is added to the output, so they must match.
The nice thing about LZW is that we can reconstruct the dictionary directly from
the stream of codes generated by the encoder, so this avoids storing additional
headers in the bit stream.
The output code length is variable. It starts with the minimum number of bits
required to store the base byte-sized dictionary and automatically increases
as the dictionary gets larger (it starts at 9-bits and grows to 10-bits when
code 512 is added, then 11-bits when 1024 is added, and so on). If the dictionary
is filled (4096 items for a 12-bits dictionary), the whole thing is cleared and
the process starts over. This is the main reason why the encoder and the decoder
must match perfectly, since the lengths of the codes will not be specified with
the data itself.
Hermet Park [Tue, 24 Aug 2021 05:22:28 +0000 (14:22 +0900)]
Update README.md
Hermet Park [Tue, 24 Aug 2021 05:20:56 +0000 (14:20 +0900)]
res: updated images
Hermet Park [Tue, 24 Aug 2021 05:19:20 +0000 (14:19 +0900)]
res: updated images.
documentation images are not updated,
remove the file first and add again.
Hermet Park [Tue, 24 Aug 2021 05:13:23 +0000 (14:13 +0900)]
res: updated images.
Hermet Park [Tue, 24 Aug 2021 05:13:02 +0000 (14:13 +0900)]
Update README.md
Hermet Park [Thu, 26 Aug 2021 02:35:27 +0000 (11:35 +0900)]
disable simd option.
it has some corruption issue on tizen mobile emulator
until stabilizing it, we turn off it
Change-Id: Iaa5aaa3ef270534f4672b4dc241d9b695ad01185
JunsuChoi [Fri, 20 Aug 2021 06:56:54 +0000 (15:56 +0900)]
[Tizen] Enable png, jpg loader
NUI's Picture class has been added, so png and jpg loaders are required.
Change-Id: If246d4105978048ea0d6d8afb3fb7f4314afba0a
Michal Maciola [Thu, 19 Aug 2021 08:57:51 +0000 (10:57 +0200)]
utc: increase coverage of picture and fill
Michal Maciola [Thu, 19 Aug 2021 09:53:54 +0000 (11:53 +0200)]
utc: increase coverage SwEngine
Hermet Park [Fri, 20 Aug 2021 03:33:18 +0000 (12:33 +0900)]
wasm: turn off the vectorization.
We can visit this feature later when it's stable.
Michal Maciola [Wed, 18 Aug 2021 15:07:51 +0000 (17:07 +0200)]
utc: increase coverage up #1
Michal Maciola [Wed, 18 Aug 2021 13:56:59 +0000 (15:56 +0200)]
utc: increase coverage up
Hermet Park [Wed, 18 Aug 2021 11:47:21 +0000 (20:47 +0900)]
infra: simplify vector meson option.
neon/avx can't be resided in together,
we replace it with a string variable.
Michal Maciola [Wed, 18 Aug 2021 11:29:10 +0000 (13:29 +0200)]
svg2png: enhance the feature.
Svg2png fully redesigned.
Introduced whole directory parsing. Created flags interface.
Usage:
svg2png [svgFileName] [-r resolution] [-b bgColor]
Flags:
-r set output image resolution.
-b set output image background color.
Examples:
$ svg2png input.svg
$ svg2png input.svg -r 200x200
$ svg2png input.svg -r 200x200 -b ff00ff
$ svg2png input1.svg input2.svg -r 200x200 -b ff00ff
Michal Maciola [Tue, 17 Aug 2021 13:03:19 +0000 (15:03 +0200)]
picture: fix reloading images
Calling picture->load after it was already once called resulted in
segmentation fault or memory leak (depending on whether the vector (svg, tvg)
or raster (jpg, png, raw) file was loaded).
This patch checks the image has already been loaded. If so, the load()
returns InsufficientCondition.
@issue: fixes #719
Hermet Park [Wed, 18 Aug 2021 10:00:48 +0000 (19:00 +0900)]
build: renamed the cpu vectorization option.
Change-Id: Id4de4fe05dcdfc550e81479ffe93e973ef958c94
Michal Szczecinski [Wed, 18 Aug 2021 07:49:50 +0000 (09:49 +0200)]
build: Fixed simd options detection
Change-Id: I58816d8b8a5bedffb9d9986f96f45ddc1ca0069b
Hermet Park [Tue, 17 Aug 2021 05:14:48 +0000 (14:14 +0900)]
Update README.md
Hermet Park [Tue, 17 Aug 2021 04:02:49 +0000 (13:02 +0900)]
bump up version v0.4.1
Change-Id: I7d35e83af8e3c0be08457a22c835cac85b5e2798
Michal Szczecinski [Wed, 11 Aug 2021 14:23:04 +0000 (16:23 +0200)]
sw_common neon: Fix issue with unaligned memory.
Neon operations should be performed on memory aligned to 8 bytes.
This commit fixes this issue and increase stability of neon rasterizer.
Change-Id: I348d18137dcd973d26948916758e1e523f565503
Hermet Park [Wed, 11 Aug 2021 15:39:36 +0000 (00:39 +0900)]
Add files via upload
Hermet Park [Wed, 11 Aug 2021 15:38:31 +0000 (00:38 +0900)]
Delete example_tvgsize.png
JunsuChoi [Fri, 13 Aug 2021 08:06:11 +0000 (17:06 +0900)]
Fix build error with log option
Change-Id: I716b8b72a1d050d414d6664491144d1a800bd838
Hermet Park [Thu, 12 Aug 2021 11:06:07 +0000 (20:06 +0900)]
sw_engine: memory optimization.
Save the size of the Countour array,
16 bits is large enough to count the points number in one Shape.
Hermet Park [Thu, 12 Aug 2021 10:40:59 +0000 (19:40 +0900)]
sw_engine shape: fix a corner case that close tag is overwritten with a wrong value.
if the last contour dispatching is dealt with closed command but actual command
is not the closed, the close tag is written with the opened
In this case, stroking rendering is buggy.
Hermet Park [Tue, 10 Aug 2021 08:43:28 +0000 (17:43 +0900)]
tvg_saver: optimize tvg format.
So this optimization stragtegy is to merging shapes.
If two shapes have the same layer, having save properties except the paths,
we can integrate two shapes to one, this helps to build up a simpler
scene-tree, reduce the runtime memory, helps for faster processing for rendering.
As far as I checked tiger.svg, it removes 142 shape nodes,
decreased the binary size: 60537 -> 54568.
Overall, avg 4% binary size can be reduced among our example svgs by this patch.
Hermet Park [Thu, 12 Aug 2021 04:09:47 +0000 (13:09 +0900)]
sw_engine: allow sharing shapes & connected strokes all in one.
This patch enhanced the sw raster engine to allow the both closed & open pathes
in one shape rendering.
@Issue: https://github.com/Samsung/thorvg/issues/266
Hermet Park [Wed, 11 Aug 2021 15:39:36 +0000 (00:39 +0900)]
Add files via upload
Hermet Park [Wed, 11 Aug 2021 15:38:31 +0000 (00:38 +0900)]
Delete example_tvgsize.png
Hermet Park [Wed, 11 Aug 2021 15:37:56 +0000 (00:37 +0900)]
Add files via upload
Hermet Park [Wed, 11 Aug 2021 15:37:44 +0000 (00:37 +0900)]
Delete example_tvg.webp
Hermet Park [Wed, 11 Aug 2021 15:37:36 +0000 (00:37 +0900)]
Delete example_tvgsize.png
Hermet Park [Wed, 11 Aug 2021 15:36:27 +0000 (00:36 +0900)]
Add files via upload
Hermet Park [Wed, 11 Aug 2021 15:35:57 +0000 (00:35 +0900)]
Update README.md
Hermet Park [Wed, 11 Aug 2021 15:33:57 +0000 (00:33 +0900)]
Add files via upload
Hermet Park [Wed, 11 Aug 2021 15:31:53 +0000 (00:31 +0900)]
Add files via upload
Hermet Park [Wed, 11 Aug 2021 15:31:28 +0000 (00:31 +0900)]
Update README.md
Michal Maciola [Tue, 10 Aug 2021 15:22:37 +0000 (17:22 +0200)]
common: RenderRegion x, y protect against negative value in unsigned int
This change protects against negative value in unsigned int of
RenderRegion.x/y. This fixes a problem of invisible paint if ClipPath
bounds was negative.
@issue: #704
Hermet Park [Tue, 10 Aug 2021 02:54:24 +0000 (11:54 +0900)]
tvg_saver: optimize saving data.
This optimizes binary size by skipping the scene if it has the only child.
though the reduced size is too trivial size (avg 0.4% as far as I checked our example svgs),
we can reduce the loading job & runtime memory as well.
Hermet Park [Tue, 10 Aug 2021 01:52:43 +0000 (10:52 +0900)]
common interator: add count() interface.
Hermet Park [Mon, 9 Aug 2021 11:31:49 +0000 (20:31 +0900)]
tvg_saver: skip the invisible paint as possible.
Hermet Park [Mon, 9 Aug 2021 12:21:01 +0000 (21:21 +0900)]
--annoying compiler warnings.
Hermet Park [Mon, 9 Aug 2021 11:26:30 +0000 (20:26 +0900)]
enable neon vectorization.
Change-Id: Idbbc47eebd3776899179ca9497206c0bbe958a0f
Hermet Park [Mon, 9 Aug 2021 09:21:45 +0000 (18:21 +0900)]
doc api: updated missed version info.
Change-Id: I3768a050884fa76e845c81459b277a1bccc706f1
Hermet Park [Mon, 9 Aug 2021 09:19:13 +0000 (18:19 +0900)]
doc api: up to date v0.4.0
Michal Maciola [Mon, 9 Aug 2021 08:16:17 +0000 (10:16 +0200)]
common: meson.build added default_options cpp_std=gnu++14
Hermet Park [Mon, 9 Aug 2021 11:53:27 +0000 (20:53 +0900)]
sw_engine raster: move neon implementation to the neon domained file.
Change-Id: I084f68269dcb49dace12162726768b77195f2c67
Hermet Park [Mon, 9 Aug 2021 07:14:36 +0000 (16:14 +0900)]
common initializer: remove unnecessary code.
x is always not equal to zero.
Change-Id: Iab2c3ab541df2c4911461b29342366552bfe052e
Hermet Park [Mon, 9 Aug 2021 06:37:19 +0000 (15:37 +0900)]
bump up version v0.4.0
Change-Id: Ifadb8643cef023393f0b94d67739138baf69c493
Hermet Park [Mon, 9 Aug 2021 06:21:32 +0000 (15:21 +0900)]
infra: just released v0.4.0
Change-Id: Ib5942f0d2eb880daf0617aab3d5f133fcc8ef984
Hermet Park [Mon, 9 Aug 2021 04:20:27 +0000 (13:20 +0900)]
common initializer: fix out of buffer access by the version info string.
String must be finished at termination charactor,
previous logic missed that handling, now fixed.
@Issue: https://github.com/Samsung/thorvg/issues/690
Hermet Park [Mon, 9 Aug 2021 04:51:25 +0000 (13:51 +0900)]
infra: update build test tvg -> tvg_beta
update it as acoording to the last change before v0.4
Hermet Park [Mon, 9 Aug 2021 03:56:11 +0000 (12:56 +0900)]
infra: fix missing tvg -> tvg_beta tag.
breakage was introduced by
6ad1b1bf732c108ec7e626b9005a76fbc4eb91df
Hermet Park [Mon, 9 Aug 2021 03:45:17 +0000 (12:45 +0900)]
infra: tvg format is still fragile, we gonna release it under the beta.
Change-Id: Id210f7c29857b78097d93f82eab21df5e1679a12
Hermet Park [Mon, 9 Aug 2021 03:30:25 +0000 (12:30 +0900)]
common picture: recover viewbox() api.
though picture has size() api, we have a regression issue in tizen,
we can't remove this api until we resolve any regression conditions.
Hermet Park [Fri, 6 Aug 2021 01:38:07 +0000 (10:38 +0900)]
tvg_saver: add 4 bytes reserved area for future extensions.
This memory can be used for storing feature flags.
Hermet Park [Thu, 5 Aug 2021 11:05:03 +0000 (20:05 +0900)]
tvg_saver: optimize binary format.
Skip to save transform data by accumulating them through the scene tree,
and then applying the final transform to the path points.
Assume that each transform have 36 bytes, it could be increased linear to paints node count
if every paints has transform in the worst case.
Fudamentally, this save their memory and only remains to Bitmap Pictures,
also helps to reduce the loading/rendering workloads since
it doesn't need to perform any transform jobs after converting.
Michal Maciola [Sat, 7 Aug 2021 03:00:04 +0000 (05:00 +0200)]
JPG loader: print error string on failure
Added error string printing on jpg image loading failure.
The error message help developer find the corrupted jpg file.
Error message is not printed for open from char* data as there the
loaders are tried on by one.
Hermet Park [Fri, 6 Aug 2021 01:30:42 +0000 (10:30 +0900)]
tvg_saver: verify view size earlier before the job is started.
JunsuChoi [Fri, 6 Aug 2021 01:07:21 +0000 (10:07 +0900)]
infra : Include dlog.h only when log is enabled
Change-Id: I91367053d6a9da83218e0b9bd5ad8638254d4617
Hermet Park [Wed, 4 Aug 2021 11:53:51 +0000 (20:53 +0900)]
tvg_loader: introduce tvg interpreter base class for future extension.
tvg binary format might break the compatibility if any major features have been changed.
It's allowed to do it when the major version is upgraded.
In that case, still we need to support the backward compatibility,
we can provide multiple binary interpreters and choose the proper one
based on the current loading tvg binary format version.
Thus, you can add further interpreters if it's necessary in the future.
Our policy is to derive the TvgBinInterpreterBase class to make it running on
the interface.
for example, if the major version is upgraded 1.x, you can implement TvgBinInterpreter1.
Hermet Park [Thu, 5 Aug 2021 02:15:10 +0000 (11:15 +0900)]
api: add deprecated syntax for deprecated apis.
Hermet Park [Thu, 5 Aug 2021 05:57:18 +0000 (14:57 +0900)]
common picture: return bounding box size with the current image size.
if the picture has a bitmap-based image,
it can return the bounding box size with the current image size.
JunsuChoi [Thu, 5 Aug 2021 05:36:40 +0000 (14:36 +0900)]
common Shape: Fix check to invalid argument
add cmds null check
Hermet Park [Thu, 5 Aug 2021 04:20:08 +0000 (13:20 +0900)]
tvg loader: code refactoring
revise the mimetype load method to keep it clean & neat.
Michal Maciola [Thu, 5 Aug 2021 02:02:26 +0000 (04:02 +0200)]
loaders: Pass mimetype to picture::load
* loaders: Pass mimetype to picture::load
Added mimetype attribute to enfaster loading using a proper loader.
@Changed api: Picture::load(const char* data, uint32_t size, const std::string& mimeType, bool copy = false)
@issue: #571
Hermet Park [Wed, 4 Aug 2021 10:11:12 +0000 (19:11 +0900)]
sw_engine raster: code refactoring.
Separate simd implementation by files to maintain them easier.
Now we have avx, c, neon version implementation base,
we can add implementations to them.
Hermet Park [Wed, 4 Aug 2021 10:58:15 +0000 (19:58 +0900)]
infra: updated meson summary.
Michal Szczecinski [Tue, 3 Aug 2021 13:33:29 +0000 (15:33 +0200)]
sw_engine common: Added neon alpha blending.
Changes:
- Prepare neon verison of ALPHA_BLEND API.
- Use ALPHA_BLEND_NEON in _translucentRle
Notes:
- _translucentRle with neon support reduces execution time of this
function ~ 300 % (measured on uint32_t 400 x 400 buffer).
- API was tested on ARMv7l device with GCC 9.2 based toolchain. Results
on other devices could be different.
Hermet Park [Wed, 4 Aug 2021 06:31:06 +0000 (15:31 +0900)]
tvg_format: force to check for compatibility by version comparision.
tvg file stores the version info of thorvg when it's generated,
in order to compare it with the runtime thorvg version when it's loaded.
For this, thorvg builds up the current version of symbol on the initilaization step,
that can be referred by the tvg loader.
Hermet Park [Wed, 4 Aug 2021 06:26:48 +0000 (15:26 +0900)]
common loader: use RawLoader class immediately.
no need to find it here.
Michal Maciola [Tue, 3 Aug 2021 10:56:31 +0000 (12:56 +0200)]
loader: removed loader finding for LoaderMgr::loader(data, w, h, copy)
LoaderMgr::loader(data, w, h, copy) is dedicated for raw images only.
No need to try other loaders.
Hermet Park [Wed, 4 Aug 2021 05:41:39 +0000 (14:41 +0900)]
bump up version 0.3.3
Change-Id: I7788d4c1bad31098e64f3baa86d1f83a65be1e34
Hermet Park [Fri, 30 Jul 2021 03:40:02 +0000 (12:40 +0900)]
tvg_saver: do not pass through if the view size is invalid.
Hermet Park [Fri, 30 Jul 2021 03:34:56 +0000 (12:34 +0900)]
common loader: lookup in the numberic order.
JunsuChoi [Fri, 30 Jul 2021 02:47:04 +0000 (11:47 +0900)]
svg_loader SvgLoader: Add 'href' attribute for parser
"xlink:href" will be deprecated.
https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/xlink:href
Hermet Park [Fri, 30 Jul 2021 02:01:08 +0000 (11:01 +0900)]
dexample Picture: improve the test coverage.
In this patch, it replaced the test images with Lenna.
and fix the wrong jpeg file size figuring.
Hermet Park [Thu, 29 Jul 2021 11:25:49 +0000 (20:25 +0900)]
tvg_format: optimize data format
This reduces tvg binary format size by converting PathCommand to more compact size.
This optimization increase +12% compress rate with our example:
195,668 => 174,071 (sum of all converted tvgs from svgs)
@Issues: https://github.com/Samsung/thorvg/issues/639
JunsuChoi [Fri, 30 Jul 2021 01:31:59 +0000 (10:31 +0900)]
sw_engine Raster: Apply bilinear interpolation to images
* Apply bilinear interpolation to images
Apply bilinear interpolation when drawing images with transformation
If the mapped coordinate value is a floating point value,
bilinear interpolation is performed using adjacent pixel values.
Interpolation is not performed in cases when the color values to beinterpolated
are the same or scale down case.
Hermet Park [Thu, 29 Jul 2021 11:08:38 +0000 (20:08 +0900)]
tvg_saver: code refactoring.
keep the macro naming convention.