2 * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef _TVG_SWCANVAS_CPP_
18 #define _TVG_SWCANVAS_CPP_
20 #include "tvgCommon.h"
21 #include "tvgCanvasBase.h"
22 #include "tvgSwRenderer.h"
25 /************************************************************************/
26 /* Internal Class Implementation */
27 /************************************************************************/
29 struct SwCanvas::Impl : CanvasBase
31 Impl() : CanvasBase(SwRenderer::inst()) {}
35 /************************************************************************/
36 /* External Class Implementation */
37 /************************************************************************/
39 int SwCanvas::target(uint32_t* buffer, size_t stride, size_t height) noexcept
41 auto impl = pImpl.get();
44 dynamic_cast<SwRenderer*>(impl->renderer)->target(buffer, stride, height);
50 int SwCanvas::draw(bool async) noexcept
52 auto impl = pImpl.get();
58 int SwCanvas::sync() noexcept
64 int SwCanvas::push(unique_ptr<PaintNode> paint) noexcept
66 auto impl = pImpl.get();
69 return impl->push(move(paint));
73 int SwCanvas::clear() noexcept
75 auto impl = pImpl.get();
81 SwCanvas::SwCanvas() : pImpl(make_unique<Impl>())
91 unique_ptr<SwCanvas> SwCanvas::gen(uint32_t* buffer, size_t stride, size_t height) noexcept
93 auto canvas = unique_ptr<SwCanvas>(new SwCanvas);
96 int ret = canvas.get()->target(buffer, stride, height);
97 if (ret > 0) return nullptr;
103 int SwCanvas::update() noexcept
105 auto impl = pImpl.get();
107 return impl->update();
111 RenderMethod* SwCanvas::engine() noexcept
113 auto impl = pImpl.get();
115 return impl->renderer;
118 #endif /* _TVG_SWCANVAS_CPP_ */