2019-04-11 14:40:54 +08:00
|
|
|
|
// Copyright (c) 2016-2018 Kiwano - Nomango
|
2020-01-21 10:09:55 +08:00
|
|
|
|
//
|
2019-03-31 01:37:06 +08:00
|
|
|
|
// 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:
|
2020-01-21 10:09:55 +08:00
|
|
|
|
//
|
2019-03-31 01:37:06 +08:00
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
|
|
// all copies or substantial portions of the Software.
|
2020-01-21 10:09:55 +08:00
|
|
|
|
//
|
2019-03-31 01:37:06 +08:00
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
2019-10-11 21:55:29 +08:00
|
|
|
|
#include <kiwano/2d/Actor.h>
|
2020-04-26 21:20:58 +08:00
|
|
|
|
#include <kiwano/render/Frame.h>
|
2020-02-16 20:14:01 +08:00
|
|
|
|
#include <kiwano/render/ShapeMaker.h>
|
2020-02-20 18:22:52 +08:00
|
|
|
|
#include <kiwano/render/RenderContext.h>
|
2019-03-31 01:37:06 +08:00
|
|
|
|
|
2019-04-11 14:40:54 +08:00
|
|
|
|
namespace kiwano
|
2019-03-31 01:37:06 +08:00
|
|
|
|
{
|
2020-02-06 16:54:47 +08:00
|
|
|
|
|
2020-01-21 10:09:55 +08:00
|
|
|
|
KGE_DECLARE_SMART_PTR(Canvas);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* \addtogroup Actors
|
|
|
|
|
|
* @{
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
* @details <EFBFBD><EFBFBD><EFBFBD>ڻ<EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD>Ρ<EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵȸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>ͼԪ<EFBFBD><EFBFBD>ͬʱ<EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
*/
|
|
|
|
|
|
class KGE_API Canvas : public Actor
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
2020-02-06 16:54:47 +08:00
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// @param size <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
2020-07-22 21:08:48 +08:00
|
|
|
|
Canvas(const Size& size);
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
/// \~chinese
|
2020-04-26 21:20:58 +08:00
|
|
|
|
/// @brief <20><>ȡ2D<32><44>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
RenderContextPtr GetContext2D() const;
|
2020-01-21 10:09:55 +08:00
|
|
|
|
|
2020-02-08 00:17:31 +08:00
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD>軭<EFBFBD><E8BBAD><EFBFBD><EFBFBD>С
|
2020-04-26 21:20:58 +08:00
|
|
|
|
/// @warning <20>ú<EFBFBD><C3BA><EFBFBD><EFBFBD>ᵼ<EFBFBD><E1B5BC>ԭ<EFBFBD><D4AD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧЧ
|
2020-02-08 00:17:31 +08:00
|
|
|
|
void ResizeAndClear(Size size);
|
|
|
|
|
|
|
2020-01-21 10:09:55 +08:00
|
|
|
|
/// \~chinese
|
2020-03-19 14:28:50 +08:00
|
|
|
|
/// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2020-01-21 10:09:55 +08:00
|
|
|
|
TexturePtr ExportToTexture() const;
|
|
|
|
|
|
|
|
|
|
|
|
void OnRender(RenderContext& ctx) override;
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
2020-02-20 18:22:52 +08:00
|
|
|
|
TexturePtr texture_cached_;
|
|
|
|
|
|
RenderContextPtr render_ctx_;
|
2020-01-21 10:09:55 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace kiwano
|