diff --git a/src/examples/Accessor.cpp b/src/examples/Accessor.cpp index 3469bd90..89dcbf44 100644 --- a/src/examples/Accessor.cpp +++ b/src/examples/Accessor.cpp @@ -164,4 +164,4 @@ int main(int argc, char **argv) cout << "engine is not supported" << endl; } return 0; -} \ No newline at end of file +} diff --git a/src/examples/ImageScaleDown.cpp b/src/examples/ImageScaleDown.cpp index 7ed41bd7..1a867f70 100644 --- a/src/examples/ImageScaleDown.cpp +++ b/src/examples/ImageScaleDown.cpp @@ -187,4 +187,4 @@ int main(int argc, char **argv) cout << "engine is not supported" << endl; } return 0; -} \ No newline at end of file +} diff --git a/src/examples/ImageScaleUp.cpp b/src/examples/ImageScaleUp.cpp index 7b420efb..ebcc90bb 100644 --- a/src/examples/ImageScaleUp.cpp +++ b/src/examples/ImageScaleUp.cpp @@ -187,4 +187,4 @@ int main(int argc, char **argv) cout << "engine is not supported" << endl; } return 0; -} \ No newline at end of file +} diff --git a/src/lib/gl_engine/tvgGlCommon.h b/src/lib/gl_engine/tvgGlCommon.h index 11cc7c99..165103dd 100644 --- a/src/lib/gl_engine/tvgGlCommon.h +++ b/src/lib/gl_engine/tvgGlCommon.h @@ -1,65 +1,65 @@ -/* - * 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 -#include -#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 geometry; -}; - - -#endif /* _TVG_GL_COMMON_H_ */ +/* + * 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 +#include +#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 geometry; +}; + + +#endif /* _TVG_GL_COMMON_H_ */ diff --git a/src/lib/gl_engine/tvgGlGpuBuffer.cpp b/src/lib/gl_engine/tvgGlGpuBuffer.cpp index 12ee24d8..6f5b2e8f 100644 --- a/src/lib/gl_engine/tvgGlGpuBuffer.cpp +++ b/src/lib/gl_engine/tvgGlGpuBuffer.cpp @@ -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(target), 0)); -} \ No newline at end of file +} diff --git a/src/lib/sw_engine/tvgSwCommon.h b/src/lib/sw_engine/tvgSwCommon.h index 157fdb8f..47b0cb83 100644 --- a/src/lib/sw_engine/tvgSwCommon.h +++ b/src/lib/sw_engine/tvgSwCommon.h @@ -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 diff --git a/src/lib/sw_engine/tvgSwFill.cpp b/src/lib/sw_engine/tvgSwFill.cpp index 04014a9e..bba6f26a 100644 --- a/src/lib/sw_engine/tvgSwFill.cpp +++ b/src/lib/sw_engine/tvgSwFill.cpp @@ -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 diff --git a/src/lib/sw_engine/tvgSwMath.cpp b/src/lib/sw_engine/tvgSwMath.cpp index 7f136095..ced66ae3 100644 --- a/src/lib/sw_engine/tvgSwMath.cpp +++ b/src/lib/sw_engine/tvgSwMath.cpp @@ -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 +} diff --git a/src/lib/sw_engine/tvgSwMemPool.cpp b/src/lib/sw_engine/tvgSwMemPool.cpp index 3ab0b606..d2962e6d 100644 --- a/src/lib/sw_engine/tvgSwMemPool.cpp +++ b/src/lib/sw_engine/tvgSwMemPool.cpp @@ -153,4 +153,4 @@ bool mpoolTerm(SwMpool* mpool) free(mpool); return true; -} \ No newline at end of file +} diff --git a/src/lib/sw_engine/tvgSwRaster.cpp b/src/lib/sw_engine/tvgSwRaster.cpp index 156ce556..810df8d4 100644 --- a/src/lib/sw_engine/tvgSwRaster.cpp +++ b/src/lib/sw_engine/tvgSwRaster.cpp @@ -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 diff --git a/src/lib/sw_engine/tvgSwRasterC.h b/src/lib/sw_engine/tvgSwRasterC.h index d479ede1..de6b35fd 100644 --- a/src/lib/sw_engine/tvgSwRasterC.h +++ b/src/lib/sw_engine/tvgSwRasterC.h @@ -61,4 +61,4 @@ static bool inline cRasterTranslucentRect(SwSurface* surface, const SwBBox& regi } } return true; -} \ No newline at end of file +} diff --git a/src/lib/sw_engine/tvgSwRasterTexmap.h b/src/lib/sw_engine/tvgSwRasterTexmap.h index 1faedd60..abb57d7c 100644 --- a/src/lib/sw_engine/tvgSwRasterTexmap.h +++ b/src/lib/sw_engine/tvgSwRasterTexmap.h @@ -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 +} diff --git a/src/lib/sw_engine/tvgSwRle.cpp b/src/lib/sw_engine/tvgSwRle.cpp index aa975869..63e7fc94 100644 --- a/src/lib/sw_engine/tvgSwRle.cpp +++ b/src/lib/sw_engine/tvgSwRle.cpp @@ -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 +} diff --git a/src/lib/sw_engine/tvgSwStroke.cpp b/src/lib/sw_engine/tvgSwStroke.cpp index fa213cc5..be439274 100644 --- a/src/lib/sw_engine/tvgSwStroke.cpp +++ b/src/lib/sw_engine/tvgSwStroke.cpp @@ -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 diff --git a/src/lib/tvgAccessor.cpp b/src/lib/tvgAccessor.cpp index 9fd564dd..092c8b07 100644 --- a/src/lib/tvgAccessor.cpp +++ b/src/lib/tvgAccessor.cpp @@ -81,4 +81,4 @@ Accessor::Accessor() unique_ptr Accessor::gen() noexcept { return unique_ptr(new Accessor); -} \ No newline at end of file +} diff --git a/src/lib/tvgFill.cpp b/src/lib/tvgFill.cpp index 0c0581a1..eecf239c 100644 --- a/src/lib/tvgFill.cpp +++ b/src/lib/tvgFill.cpp @@ -112,4 +112,4 @@ Fill* Fill::duplicate() const noexcept uint32_t Fill::identifier() const noexcept { return pImpl->id; -} \ No newline at end of file +} diff --git a/src/lib/tvgPicture.cpp b/src/lib/tvgPicture.cpp index 1125b1eb..1e04e254 100644 --- a/src/lib/tvgPicture.cpp +++ b/src/lib/tvgPicture.cpp @@ -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 +} diff --git a/src/lib/tvgRadialGradient.cpp b/src/lib/tvgRadialGradient.cpp index 7aba550e..7f4e1d7e 100644 --- a/src/lib/tvgRadialGradient.cpp +++ b/src/lib/tvgRadialGradient.cpp @@ -94,4 +94,4 @@ unique_ptr RadialGradient::gen() noexcept uint32_t RadialGradient::identifier() noexcept { return TVG_CLASS_ID_RADIAL; -} \ No newline at end of file +} diff --git a/src/lib/tvgRender.cpp b/src/lib/tvgRender.cpp index 145f974c..90f0917e 100644 --- a/src/lib/tvgRender.cpp +++ b/src/lib/tvgRender.cpp @@ -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 +} diff --git a/src/lib/tvgScene.cpp b/src/lib/tvgScene.cpp index ff43d3c8..0beec47b 100644 --- a/src/lib/tvgScene.cpp +++ b/src/lib/tvgScene.cpp @@ -73,4 +73,4 @@ Result Scene::clear(bool free) noexcept pImpl->clear(free); return Result::Success; -} \ No newline at end of file +} diff --git a/src/lib/tvgShape.cpp b/src/lib/tvgShape.cpp index 3a3af5f7..e57f2eaf 100644 --- a/src/lib/tvgShape.cpp +++ b/src/lib/tvgShape.cpp @@ -424,4 +424,4 @@ Result Shape::fill(FillRule r) noexcept FillRule Shape::fillRule() const noexcept { return pImpl->rule; -} \ No newline at end of file +} diff --git a/src/lib/tvgSwCanvas.cpp b/src/lib/tvgSwCanvas.cpp index 8c9de8cb..b5cae424 100644 --- a/src/lib/tvgSwCanvas.cpp +++ b/src/lib/tvgSwCanvas.cpp @@ -102,4 +102,4 @@ unique_ptr SwCanvas::gen() noexcept return unique_ptr(new SwCanvas); #endif return nullptr; -} \ No newline at end of file +} diff --git a/src/loaders/jpg/tvgJpgLoader.cpp b/src/loaders/jpg/tvgJpgLoader.cpp index 7b90b4ae..ffdef300 100644 --- a/src/loaders/jpg/tvgJpgLoader.cpp +++ b/src/loaders/jpg/tvgJpgLoader.cpp @@ -134,4 +134,4 @@ void JpgLoader::run(unsigned tid) image = nullptr; } image = jpgdDecompress(decoder); -} \ No newline at end of file +} diff --git a/src/loaders/png/tvgLodePng.cpp b/src/loaders/png/tvgLodePng.cpp index 5c01c5a1..eaed025c 100644 --- a/src/loaders/png/tvgLodePng.cpp +++ b/src/loaders/png/tvgLodePng.cpp @@ -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 +} diff --git a/src/loaders/png/tvgLodePng.h b/src/loaders/png/tvgLodePng.h index c9f0e56a..0cdac7cb 100644 --- a/src/loaders/png/tvgLodePng.h +++ b/src/loaders/png/tvgLodePng.h @@ -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_ diff --git a/src/loaders/tvg/tvgTvgCommon.h b/src/loaders/tvg/tvgTvgCommon.h index 62181605..a0762d0f 100644 --- a/src/loaders/tvg/tvgTvgCommon.h +++ b/src/loaders/tvg/tvgTvgCommon.h @@ -51,4 +51,4 @@ public: }; -#endif //_TVG_TVG_COMMON_H_ \ No newline at end of file +#endif //_TVG_TVG_COMMON_H_ diff --git a/test/capi/capiScene.cpp b/test/capi/capiScene.cpp index 92120c78..38235d4d 100644 --- a/test/capi/capiScene.cpp +++ b/test/capi/capiScene.cpp @@ -1,115 +1,115 @@ -/* - * 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 -#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); -} +/* + * 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 +#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); +} diff --git a/test/testInitializer.cpp b/test/testInitializer.cpp index 6d8bf962..826229c7 100644 --- a/test/testInitializer.cpp +++ b/test/testInitializer.cpp @@ -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 +} diff --git a/test/testPaint.cpp b/test/testPaint.cpp index 39c1213f..1ef05f10 100644 --- a/test/testPaint.cpp +++ b/test/testPaint.cpp @@ -213,4 +213,4 @@ TEST_CASE("Composition", "[tvgPaint]") REQUIRE(shape->composite(&pComp2) == CompositeMethod::InvAlphaMask); REQUIRE(pComp == pComp2); -} \ No newline at end of file +} diff --git a/test/testShape.cpp b/test/testShape.cpp index f5c8dd95..0e4bfc3c 100644 --- a/test/testShape.cpp +++ b/test/testShape.cpp @@ -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 +}