Format code files with dos2unix, ensure newline at EOF 89/289489/1
authorRémi Verschelde <rverschelde@gmail.com>
Mon, 23 May 2022 16:35:10 +0000 (18:35 +0200)
committerPatryk Kaczmarek <patryk.k@partner.samsung.com>
Thu, 9 Mar 2023 00:41:42 +0000 (01:41 +0100)
Change-Id: I08dab1f492d295fdb9d9a4fb451578778be5b77a

30 files changed:
src/examples/Accessor.cpp
src/examples/ImageScaleDown.cpp
src/examples/ImageScaleUp.cpp
src/lib/gl_engine/tvgGlCommon.h
src/lib/gl_engine/tvgGlGpuBuffer.cpp
src/lib/sw_engine/tvgSwCommon.h
src/lib/sw_engine/tvgSwFill.cpp
src/lib/sw_engine/tvgSwMath.cpp
src/lib/sw_engine/tvgSwMemPool.cpp
src/lib/sw_engine/tvgSwRaster.cpp
src/lib/sw_engine/tvgSwRasterC.h
src/lib/sw_engine/tvgSwRasterTexmap.h
src/lib/sw_engine/tvgSwRle.cpp
src/lib/sw_engine/tvgSwStroke.cpp
src/lib/tvgAccessor.cpp
src/lib/tvgFill.cpp
src/lib/tvgPicture.cpp
src/lib/tvgRadialGradient.cpp
src/lib/tvgRender.cpp
src/lib/tvgScene.cpp
src/lib/tvgShape.cpp
src/lib/tvgSwCanvas.cpp
src/loaders/jpg/tvgJpgLoader.cpp
src/loaders/png/tvgLodePng.cpp
src/loaders/png/tvgLodePng.h
src/loaders/tvg/tvgTvgCommon.h
test/capi/capiScene.cpp
test/testInitializer.cpp
test/testPaint.cpp
test/testShape.cpp

index 3469bd906e27d3467ba35606373b2a1bc41e2df0..89dcbf44d1aa42972cc43af7acd365c49d0ec43e 100644 (file)
@@ -164,4 +164,4 @@ int main(int argc, char **argv)
         cout << "engine is not supported" << endl;
     }
     return 0;
-}
\ No newline at end of file
+}
index 7ed41bd7722a3ae9abfcb3fd09c8d5a1d46b21a8..1a867f70c62b56bed9635493faa130ce3d3d3bbd 100644 (file)
@@ -187,4 +187,4 @@ int main(int argc, char **argv)
         cout << "engine is not supported" << endl;
     }
     return 0;
-}
\ No newline at end of file
+}
index 7b420efbecb51808ac42b2a08c71bcf01e326f3b..ebcc90bbb3cecd0598514407b3d3afe5ad42d234 100644 (file)
@@ -187,4 +187,4 @@ int main(int argc, char **argv)
         cout << "engine is not supported" << endl;
     }
     return 0;
-}
\ No newline at end of file
+}
index 11cc7c993d3f2bb12019fae881707e9e132cd859..165103dd9f64325433daafc012cb7d14fa9fa240 100644 (file)
@@ -1,65 +1,65 @@
-/*\r
- * Copyright (c) 2020 - 2022 Samsung Electronics Co., Ltd. All rights reserved.\r
-\r
- * Permission is hereby granted, free of charge, to any person obtaining a copy\r
- * of this software and associated documentation files (the "Software"), to deal\r
- * in the Software without restriction, including without limitation the rights\r
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
- * copies of the Software, and to permit persons to whom the Software is\r
- * furnished to do so, subject to the following conditions:\r
-\r
- * The above copyright notice and this permission notice shall be included in all\r
- * copies or substantial portions of the Software.\r
-\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
- * SOFTWARE.\r
- */\r
-\r
-#ifndef _TVG_GL_COMMON_H_\r
-#define _TVG_GL_COMMON_H_\r
-\r
-#include <assert.h>\r
-#include <GLES2/gl2.h>\r
-#include "tvgCommon.h"\r
-#include "tvgRender.h"\r
-\r
-\r
-#define GL_CHECK(x) \\r
-        x; \\r
-        do { \\r
-          GLenum glError = glGetError(); \\r
-          if(glError != GL_NO_ERROR) { \\r
-            TVGERR("GL_ENGINE", "glGetError() = %i (0x%.8x)", glError, glError); \\r
-            assert(0); \\r
-          } \\r
-        } while(0)\r
-\r
-#define EGL_CHECK(x) \\r
-    x; \\r
-    do { \\r
-        EGLint eglError = eglGetError(); \\r
-        if(eglError != EGL_SUCCESS) { \\r
-            TVGERR("GL_ENGINE", "eglGetError() = %i (0x%.8x)", eglError, eglError); \\r
-            assert(0); \\r
-        } \\r
-    } while(0)\r
-\r
-\r
-class GlGeometry;\r
-\r
-struct GlShape\r
-{\r
-  const Shape* shape = nullptr;\r
-  float viewWd;\r
-  float viewHt;\r
-  RenderUpdateFlag updateFlag = None;\r
-  unique_ptr<GlGeometry> geometry;\r
-};\r
-\r
-\r
-#endif /* _TVG_GL_COMMON_H_ */\r
+/*
+ * Copyright (c) 2020 - 2022 Samsung Electronics Co., Ltd. All rights reserved.
+
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef _TVG_GL_COMMON_H_
+#define _TVG_GL_COMMON_H_
+
+#include <assert.h>
+#include <GLES2/gl2.h>
+#include "tvgCommon.h"
+#include "tvgRender.h"
+
+
+#define GL_CHECK(x) \
+        x; \
+        do { \
+          GLenum glError = glGetError(); \
+          if(glError != GL_NO_ERROR) { \
+            TVGERR("GL_ENGINE", "glGetError() = %i (0x%.8x)", glError, glError); \
+            assert(0); \
+          } \
+        } while(0)
+
+#define EGL_CHECK(x) \
+    x; \
+    do { \
+        EGLint eglError = eglGetError(); \
+        if(eglError != EGL_SUCCESS) { \
+            TVGERR("GL_ENGINE", "eglGetError() = %i (0x%.8x)", eglError, eglError); \
+            assert(0); \
+        } \
+    } while(0)
+
+
+class GlGeometry;
+
+struct GlShape
+{
+  const Shape* shape = nullptr;
+  float viewWd;
+  float viewHt;
+  RenderUpdateFlag updateFlag = None;
+  unique_ptr<GlGeometry> geometry;
+};
+
+
+#endif /* _TVG_GL_COMMON_H_ */
index 12ee24d8873a14cf8edc694dc5a83f76f32b704e..6f5b2e8fa0f844dcc062a26f2eb6c4cecf41fecc 100644 (file)
@@ -52,4 +52,4 @@ void GlGpuBuffer::updateBufferData(Target target, uint32_t size, const void* dat
 void GlGpuBuffer::unbind(Target target)
 {
     GL_CHECK(glBindBuffer(static_cast<uint32_t>(target), 0));
-}
\ No newline at end of file
+}
index 157fdb8f82a50b6b67971c0f1a362da719bba140..47b0cb83f523855d144d8cba3a57b36d31d8ba3f 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/*
  * Copyright (c) 2020 - 2022 Samsung Electronics Co., Ltd. All rights reserved.
 
  * Permission is hereby granted, free of charge, to any person obtaining a copy
index 04014a9ec3e17d98555bf421deab3e4d39ab8e72..bba6f26a0b8794b0c75bfa465d34b5b7727f919c 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/*
  * Copyright (c) 2020 - 2022 Samsung Electronics Co., Ltd. All rights reserved.
 
  * Permission is hereby granted, free of charge, to any person obtaining a copy
index 7f136095255284b71261a4dd04e9b292eb7075d5..ced66ae35cdbfd73fe1fef8d324297dca7e47512 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/*
  * Copyright (c) 2020 - 2022 Samsung Electronics Co., Ltd. All rights reserved.
 
  * Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -499,4 +499,4 @@ bool mathUpdateOutlineBBox(const SwOutline* outline, const SwBBox& clipRegion, S
         renderRegion.max.y = (yMax + 63) >> 6;
     }
     return mathClipBBox(clipRegion, renderRegion);
-}
\ No newline at end of file
+}
index 3ab0b6069ec0a38f991930d8db494850720a2bc3..d2962e6d8d7929c680027f48c7a859cecadd2f60 100644 (file)
@@ -153,4 +153,4 @@ bool mpoolTerm(SwMpool* mpool)
     free(mpool);
 
     return true;
-}
\ No newline at end of file
+}
index 156ce556183748e7fc10809d1d9dc21ad6f21eeb..810df8d435616b41e3a7b3846e5a007d76d720af 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/*
  * Copyright (c) 2020 - 2022 Samsung Electronics Co., Ltd. All rights reserved.
 
  * Permission is hereby granted, free of charge, to any person obtaining a copy
index d479ede15feb3323b471cf4ef1795474fe0502a4..de6b35fd647b8fce0e0f6c655f2bddef0873771c 100644 (file)
@@ -61,4 +61,4 @@ static bool inline cRasterTranslucentRect(SwSurface* surface, const SwBBox& regi
         }
     }
     return true;
-}
\ No newline at end of file
+}
index 1faedd60aa78850352f16a039d33ff0eb8cddcde..abb57d7c45361b97f1817bb71e6df1545d44df5f 100644 (file)
@@ -599,4 +599,4 @@ static bool _rasterTexmapPolygon(SwSurface* surface, const SwImage* image, const
     _rasterPolygonImage(surface, image, region, opacity, polygon, blendMethod, aaSpans);
 
     return _apply(surface, aaSpans);
-}
\ No newline at end of file
+}
index aa975869e04e12fc14ce239bd236f7930a51b880..63e7fc94473c32a315d625ca44b34e33d99f7283 100644 (file)
@@ -1040,4 +1040,4 @@ void rleClipRect(SwRleData *rle, const SwBBox* clip)
     _replaceClipSpan(rle, spans, spansEnd - spans);
 
     TVGLOG("SW_ENGINE", "Using ClipRect!");
-}
\ No newline at end of file
+}
index fa213cc5d327c5a4cb9ba6960c5c28dc7eb55edd..be4392740ed1956fd09ccd18f982b4cbec7b66e9 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/*
  * Copyright (c) 2020 - 2022 Samsung Electronics Co., Ltd. All rights reserved.
 
  * Permission is hereby granted, free of charge, to any person obtaining a copy
index 9fd564dd23dc81716d85c6e721e900d8fdaaaca1..092c8b0731d6661b864772f0656c61179e2ec2ff 100644 (file)
@@ -81,4 +81,4 @@ Accessor::Accessor()
 unique_ptr<Accessor> Accessor::gen() noexcept
 {
     return unique_ptr<Accessor>(new Accessor);
-}
\ No newline at end of file
+}
index 0c0581a1806c74d41dbd3a52d55e909597ef7484..eecf239ceefc45cfd77628f9e864c414a422b327 100644 (file)
@@ -112,4 +112,4 @@ Fill* Fill::duplicate() const noexcept
 uint32_t Fill::identifier() const noexcept
 {
     return pImpl->id;
-}
\ No newline at end of file
+}
index 1125b1eb5873a2a1697bf8da5ecc5335a46f77e0..1e04e25435306eaa78ad4c349b1a24aba9130df4 100644 (file)
@@ -118,4 +118,4 @@ const uint32_t* Picture::data(uint32_t* w, uint32_t* h) const noexcept
     }
     if (pImpl->surface) return pImpl->surface->buffer;
     else return nullptr;
-}
\ No newline at end of file
+}
index 7aba550e48bb699227196e6e9ce2d057fc67b3d3..7f4e1d7e17b069206aaf12e066479823f030362b 100644 (file)
@@ -94,4 +94,4 @@ unique_ptr<RadialGradient> RadialGradient::gen() noexcept
 uint32_t RadialGradient::identifier() noexcept
 {
     return TVG_CLASS_ID_RADIAL;
-}
\ No newline at end of file
+}
index 145f974cee09c828d206ec01215fa6ffec5387a0..90f0917e6bd1d76c7d5faa6b48eabf1f2d5c7caf 100644 (file)
@@ -70,4 +70,4 @@ RenderTransform::RenderTransform()
 RenderTransform::RenderTransform(const RenderTransform* lhs, const RenderTransform* rhs)
 {
     m = mathMultiply(&lhs->m, &rhs->m);
-}
\ No newline at end of file
+}
index ff43d3c881c42512fd7c2dc354feed47f072eb64..0beec47b3881e62c1e783a1b99bd72997140b1d3 100644 (file)
@@ -73,4 +73,4 @@ Result Scene::clear(bool free) noexcept
     pImpl->clear(free);
 
     return Result::Success;
-}
\ No newline at end of file
+}
index 3a3af5f76efc25d4fec9e557f42ac32e992575be..e57f2eafb2d2486913f5e548267a600c5d604867 100644 (file)
@@ -424,4 +424,4 @@ Result Shape::fill(FillRule r) noexcept
 FillRule Shape::fillRule() const noexcept
 {
     return pImpl->rule;
-}
\ No newline at end of file
+}
index 8c9de8cb51b7b351d1457a0321ee64e20d0f2d4a..b5cae424f71844586f76a521c1642a734cb259e4 100644 (file)
@@ -102,4 +102,4 @@ unique_ptr<SwCanvas> SwCanvas::gen() noexcept
     return unique_ptr<SwCanvas>(new SwCanvas);
 #endif
     return nullptr;
-}
\ No newline at end of file
+}
index 7b90b4aef90109e43804e1cade45f4365aad077a..ffdef3004cd998fafbc3e3defe8a4cafffcbdfa0 100644 (file)
@@ -134,4 +134,4 @@ void JpgLoader::run(unsigned tid)
         image = nullptr;
     }
     image = jpgdDecompress(decoder);
-}
\ No newline at end of file
+}
index 5c01c5a1e2038d961260d90e6a7120b0bbb91929..eaed025c5477739f3a466fd9c0e0f325ee9b0045 100644 (file)
@@ -2644,4 +2644,4 @@ void lodepng_state_cleanup(LodePNGState* state)
 {
     lodepng_color_mode_cleanup(&state->info_raw);
     lodepng_info_cleanup(&state->info_png);
-}
\ No newline at end of file
+}
index c9f0e56ab6db9ac16b369b32f50550242f70b6c5..0cdac7cbea95af2b6251a235ecea3f295305a147 100644 (file)
@@ -171,4 +171,4 @@ void lodepng_state_cleanup(LodePNGState* state);
 unsigned lodepng_decode(unsigned char** out, unsigned* w, unsigned* h, LodePNGState* state, const unsigned char* in, size_t insize);
 unsigned lodepng_inspect(unsigned* w, unsigned* h, LodePNGState* state, const unsigned char* in, size_t insize);
 
-#endif //_TVG_LODEPNG_H_
\ No newline at end of file
+#endif //_TVG_LODEPNG_H_
index 62181605a25fddfcf3692fcf80fe0c70c0c577bb..a0762d0fccc62a702f619defb7ce812d04e7d25e 100644 (file)
@@ -51,4 +51,4 @@ public:
 };
 
 
-#endif  //_TVG_TVG_COMMON_H_
\ No newline at end of file
+#endif  //_TVG_TVG_COMMON_H_
index 92120c7882a1eb399342914f618815b4074aa610..38235d4d686280e26ebd2e462ca10e3398898f6f 100644 (file)
-/*\r
- * Copyright (c) 2021 - 2022 Samsung Electronics Co., Ltd. All rights reserved.\r
-\r
- * Permission is hereby granted, free of charge, to any person obtaining a copy\r
- * of this software and associated documentation files (the "Software"), to deal\r
- * in the Software without restriction, including without limitation the rights\r
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
- * copies of the Software, and to permit persons to whom the Software is\r
- * furnished to do so, subject to the following conditions:\r
-\r
- * The above copyright notice and this permission notice shall be included in all\r
- * copies or substantial portions of the Software.\r
-\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
- * SOFTWARE.\r
- */\r
-\r
-#include <thorvg_capi.h>\r
-#include "../catch.hpp"\r
-\r
-TEST_CASE("Create a Scene", "[capiScene]")\r
-{\r
-    Tvg_Paint* scene = tvg_scene_new();\r
-    REQUIRE(scene);\r
-\r
-    REQUIRE(tvg_paint_del(scene) == TVG_RESULT_SUCCESS);\r
-}\r
-\r
-TEST_CASE("Paints Into a Scene", "[capiScene]")\r
-{\r
-    Tvg_Paint* scene = tvg_scene_new();\r
-    REQUIRE(scene);\r
-\r
-    //Pushing Paints\r
-    REQUIRE(tvg_scene_push(scene, tvg_shape_new()) == TVG_RESULT_SUCCESS);\r
-    REQUIRE(tvg_scene_push(scene, tvg_picture_new()) == TVG_RESULT_SUCCESS);\r
-    REQUIRE(tvg_scene_push(scene, tvg_scene_new()) == TVG_RESULT_SUCCESS);\r
-\r
-    //Pushing Null Pointer\r
-    REQUIRE(tvg_scene_push(scene, NULL) == TVG_RESULT_INVALID_ARGUMENT);\r
-    REQUIRE(tvg_scene_push(NULL, NULL) == TVG_RESULT_INVALID_ARGUMENT);\r
-\r
-    REQUIRE(tvg_paint_del(scene) == TVG_RESULT_SUCCESS);\r
-}\r
-\r
-TEST_CASE("Scene Reservation", "[capiScene]")\r
-{\r
-    Tvg_Paint* scene = tvg_scene_new();\r
-    REQUIRE(scene);\r
-\r
-    //Check Growth / Reduction\r
-    REQUIRE(tvg_scene_reserve(scene, 100) == TVG_RESULT_SUCCESS);\r
-    REQUIRE(tvg_scene_reserve(scene, 1000) == TVG_RESULT_SUCCESS);\r
-    REQUIRE(tvg_scene_reserve(scene, 100) == TVG_RESULT_SUCCESS);\r
-    REQUIRE(tvg_scene_reserve(scene, 0) == TVG_RESULT_SUCCESS);\r
-\r
-    //Invalid scene\r
-    REQUIRE(tvg_scene_reserve(NULL, 1) == TVG_RESULT_INVALID_ARGUMENT);\r
-\r
-    REQUIRE(tvg_paint_del(scene) == TVG_RESULT_SUCCESS);\r
-}\r
-\r
-TEST_CASE("Clear the Scene", "[capiScene]")\r
-{\r
-    Tvg_Paint* scene = tvg_scene_new();\r
-    REQUIRE(scene);\r
-\r
-    REQUIRE(tvg_scene_push(scene, tvg_shape_new()) == TVG_RESULT_SUCCESS);\r
-    REQUIRE(tvg_scene_clear(scene, true) == TVG_RESULT_SUCCESS);\r
-\r
-    //Invalid scene\r
-    REQUIRE(tvg_scene_clear(NULL, false) == TVG_RESULT_INVALID_ARGUMENT);\r
-\r
-    REQUIRE(tvg_paint_del(scene) == TVG_RESULT_SUCCESS);\r
-}\r
-\r
-TEST_CASE("Scene reusing paints", "[capiScene]")\r
-{\r
-    REQUIRE(tvg_engine_init(TVG_ENGINE_SW, 0) == TVG_RESULT_SUCCESS);\r
-\r
-    Tvg_Canvas* canvas = tvg_swcanvas_create();\r
-    REQUIRE(canvas);\r
-\r
-    uint32_t* buffer = (uint32_t*) malloc(sizeof(uint32_t) * 200 * 200);\r
-    REQUIRE(buffer);\r
-\r
-    REQUIRE(tvg_swcanvas_set_target(canvas, buffer, 200, 200, 200, TVG_COLORSPACE_ARGB8888) == TVG_RESULT_SUCCESS);\r
-\r
-    Tvg_Paint* scene = tvg_scene_new();\r
-    REQUIRE(scene);\r
-\r
-    Tvg_Paint* shape = tvg_shape_new();\r
-    REQUIRE(shape);\r
-\r
-    REQUIRE(tvg_scene_push(scene, shape) == TVG_RESULT_SUCCESS);\r
-    REQUIRE(tvg_canvas_push(canvas, scene) == TVG_RESULT_SUCCESS);\r
-    REQUIRE(tvg_canvas_update(canvas) == TVG_RESULT_SUCCESS);\r
-\r
-    //No deallocate shape.\r
-    REQUIRE(tvg_scene_clear(scene, false) == TVG_RESULT_SUCCESS);\r
-\r
-    //Reuse shape.\r
-    REQUIRE(tvg_scene_push(scene, shape) == TVG_RESULT_SUCCESS);\r
-\r
-    REQUIRE(tvg_canvas_destroy(canvas) == TVG_RESULT_SUCCESS);\r
-\r
-    REQUIRE(tvg_engine_term(TVG_ENGINE_SW) == TVG_RESULT_SUCCESS);\r
-\r
-    free(buffer);\r
-}\r
+/*
+ * Copyright (c) 2021 - 2022 Samsung Electronics Co., Ltd. All rights reserved.
+
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <thorvg_capi.h>
+#include "../catch.hpp"
+
+TEST_CASE("Create a Scene", "[capiScene]")
+{
+    Tvg_Paint* scene = tvg_scene_new();
+    REQUIRE(scene);
+
+    REQUIRE(tvg_paint_del(scene) == TVG_RESULT_SUCCESS);
+}
+
+TEST_CASE("Paints Into a Scene", "[capiScene]")
+{
+    Tvg_Paint* scene = tvg_scene_new();
+    REQUIRE(scene);
+
+    //Pushing Paints
+    REQUIRE(tvg_scene_push(scene, tvg_shape_new()) == TVG_RESULT_SUCCESS);
+    REQUIRE(tvg_scene_push(scene, tvg_picture_new()) == TVG_RESULT_SUCCESS);
+    REQUIRE(tvg_scene_push(scene, tvg_scene_new()) == TVG_RESULT_SUCCESS);
+
+    //Pushing Null Pointer
+    REQUIRE(tvg_scene_push(scene, NULL) == TVG_RESULT_INVALID_ARGUMENT);
+    REQUIRE(tvg_scene_push(NULL, NULL) == TVG_RESULT_INVALID_ARGUMENT);
+
+    REQUIRE(tvg_paint_del(scene) == TVG_RESULT_SUCCESS);
+}
+
+TEST_CASE("Scene Reservation", "[capiScene]")
+{
+    Tvg_Paint* scene = tvg_scene_new();
+    REQUIRE(scene);
+
+    //Check Growth / Reduction
+    REQUIRE(tvg_scene_reserve(scene, 100) == TVG_RESULT_SUCCESS);
+    REQUIRE(tvg_scene_reserve(scene, 1000) == TVG_RESULT_SUCCESS);
+    REQUIRE(tvg_scene_reserve(scene, 100) == TVG_RESULT_SUCCESS);
+    REQUIRE(tvg_scene_reserve(scene, 0) == TVG_RESULT_SUCCESS);
+
+    //Invalid scene
+    REQUIRE(tvg_scene_reserve(NULL, 1) == TVG_RESULT_INVALID_ARGUMENT);
+
+    REQUIRE(tvg_paint_del(scene) == TVG_RESULT_SUCCESS);
+}
+
+TEST_CASE("Clear the Scene", "[capiScene]")
+{
+    Tvg_Paint* scene = tvg_scene_new();
+    REQUIRE(scene);
+
+    REQUIRE(tvg_scene_push(scene, tvg_shape_new()) == TVG_RESULT_SUCCESS);
+    REQUIRE(tvg_scene_clear(scene, true) == TVG_RESULT_SUCCESS);
+
+    //Invalid scene
+    REQUIRE(tvg_scene_clear(NULL, false) == TVG_RESULT_INVALID_ARGUMENT);
+
+    REQUIRE(tvg_paint_del(scene) == TVG_RESULT_SUCCESS);
+}
+
+TEST_CASE("Scene reusing paints", "[capiScene]")
+{
+    REQUIRE(tvg_engine_init(TVG_ENGINE_SW, 0) == TVG_RESULT_SUCCESS);
+
+    Tvg_Canvas* canvas = tvg_swcanvas_create();
+    REQUIRE(canvas);
+
+    uint32_t* buffer = (uint32_t*) malloc(sizeof(uint32_t) * 200 * 200);
+    REQUIRE(buffer);
+
+    REQUIRE(tvg_swcanvas_set_target(canvas, buffer, 200, 200, 200, TVG_COLORSPACE_ARGB8888) == TVG_RESULT_SUCCESS);
+
+    Tvg_Paint* scene = tvg_scene_new();
+    REQUIRE(scene);
+
+    Tvg_Paint* shape = tvg_shape_new();
+    REQUIRE(shape);
+
+    REQUIRE(tvg_scene_push(scene, shape) == TVG_RESULT_SUCCESS);
+    REQUIRE(tvg_canvas_push(canvas, scene) == TVG_RESULT_SUCCESS);
+    REQUIRE(tvg_canvas_update(canvas) == TVG_RESULT_SUCCESS);
+
+    //No deallocate shape.
+    REQUIRE(tvg_scene_clear(scene, false) == TVG_RESULT_SUCCESS);
+
+    //Reuse shape.
+    REQUIRE(tvg_scene_push(scene, shape) == TVG_RESULT_SUCCESS);
+
+    REQUIRE(tvg_canvas_destroy(canvas) == TVG_RESULT_SUCCESS);
+
+    REQUIRE(tvg_engine_term(TVG_ENGINE_SW) == TVG_RESULT_SUCCESS);
+
+    free(buffer);
+}
index 6d8bf96237549fea5c6ea81c8b3330977e5e6f87..826229c757074418c778901efcc106cc7bf6365b 100644 (file)
@@ -51,4 +51,4 @@ TEST_CASE("Negative termination", "[tvgInitializer]")
 TEST_CASE("Invalid engine", "[tvgInitializer]")
 {
     REQUIRE(Initializer::init(CanvasEngine(0), 0) == Result::InvalidArguments);
-}
\ No newline at end of file
+}
index 39c1213f35b5f95e157d5e72b390ff316b525b52..1ef05f107565d8c32e7efa238f5023fb8270708f 100644 (file)
@@ -213,4 +213,4 @@ TEST_CASE("Composition", "[tvgPaint]")
 
     REQUIRE(shape->composite(&pComp2) == CompositeMethod::InvAlphaMask);
     REQUIRE(pComp == pComp2);
-}
\ No newline at end of file
+}
index f5c8dd95d69009139831bdc5990dcdfe4cebc21e..0e4bfc3c70afa7d4525219edd0d4732deb6256c0 100644 (file)
@@ -206,4 +206,4 @@ TEST_CASE("Shape Filling", "[tvgShape]")
     REQUIRE(shape->fillRule() == FillRule::Winding);
     REQUIRE(shape->fill(FillRule::EvenOdd) == Result::Success);
     REQUIRE(shape->fillRule() == FillRule::EvenOdd);
-}
\ No newline at end of file
+}