mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-07 21:23:32 +00:00

this shows a moving shape: how to update canvas every frames. Change-Id: I373e39757f4511d4e676f36d76e468d03b185a0c
85 lines
2 KiB
C++
85 lines
2 KiB
C++
/*
|
|
* Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*
|
|
*/
|
|
#ifndef _TVG_SWCANVAS_CPP_
|
|
#define _TVG_SWCANVAS_CPP_
|
|
|
|
#include "tvgCommon.h"
|
|
#include "tvgSwRenderer.h"
|
|
|
|
|
|
/************************************************************************/
|
|
/* Internal Class Implementation */
|
|
/************************************************************************/
|
|
|
|
struct SwCanvas::Impl
|
|
{
|
|
Impl() {}
|
|
};
|
|
|
|
|
|
/************************************************************************/
|
|
/* External Class Implementation */
|
|
/************************************************************************/
|
|
|
|
SwCanvas::SwCanvas() : Canvas(SwRenderer::inst()), pImpl(make_unique<Impl>())
|
|
{
|
|
}
|
|
|
|
|
|
SwCanvas::~SwCanvas()
|
|
{
|
|
}
|
|
|
|
|
|
int SwCanvas::clear() noexcept
|
|
{
|
|
auto renderer = dynamic_cast<SwRenderer*>(engine());
|
|
assert(renderer);
|
|
|
|
if (!renderer->clear()) return -1;
|
|
|
|
return Canvas::clear();
|
|
}
|
|
|
|
|
|
int SwCanvas::target(uint32_t* buffer, size_t stride, size_t w, size_t h) noexcept
|
|
{
|
|
auto renderer = dynamic_cast<SwRenderer*>(engine());
|
|
assert(renderer);
|
|
|
|
if (!renderer->target(buffer, stride, w, h)) return -1;
|
|
if (!renderer->clear()) return -1;
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
int SwCanvas::sync() noexcept
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
|
|
unique_ptr<SwCanvas> SwCanvas::gen() noexcept
|
|
{
|
|
auto canvas = unique_ptr<SwCanvas>(new SwCanvas);
|
|
assert(canvas);
|
|
|
|
return canvas;
|
|
}
|
|
|
|
#endif /* _TVG_SWCANVAS_CPP_ */
|