2 * Copyright (c) 2020-2021 Samsung Electronics Co., Ltd. All rights reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in all
12 * copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 /************************************************************************/
25 /* Internal Class Implementation */
26 /************************************************************************/
29 /************************************************************************/
30 /* External Class Implementation */
31 /************************************************************************/
33 Fill::Fill():pImpl(new Impl())
44 Result Fill::colorStops(const ColorStop* colorStops, uint32_t cnt) noexcept
46 if ((!colorStops && cnt > 0) || (colorStops && cnt == 0)) return Result::InvalidArguments;
49 if (pImpl->colorStops) {
50 free(pImpl->colorStops);
51 pImpl->colorStops = nullptr;
54 return Result::Success;
57 if (pImpl->cnt != cnt) {
58 pImpl->colorStops = static_cast<ColorStop*>(realloc(pImpl->colorStops, cnt * sizeof(ColorStop)));
62 memcpy(pImpl->colorStops, colorStops, cnt * sizeof(ColorStop));
64 return Result::Success;
68 uint32_t Fill::colorStops(const ColorStop** colorStops) const noexcept
70 if (colorStops) *colorStops = pImpl->colorStops;
76 Result Fill::spread(FillSpread s) noexcept
80 return Result::Success;
84 FillSpread Fill::spread() const noexcept
90 Result Fill::transform(const Matrix& m) noexcept
92 if (!pImpl->transform) {
93 pImpl->transform = static_cast<Matrix*>(malloc(sizeof(Matrix)));
95 *pImpl->transform = m;
96 return Result::Success;
100 Matrix Fill::transform() const noexcept
102 if (pImpl->transform) return *pImpl->transform;
103 return {1, 0, 0, 0, 1, 0, 0, 0, 1};
107 Fill* Fill::duplicate() const noexcept
109 return pImpl->duplicate();
112 uint32_t Fill::identifier() const noexcept